# Eigenvalues for HP-41cv/cx

This program determines the eigenvalues of a real number matrix.

## Theory

Multiplying a vector with a square matrix, usually changes both the magnitude (scale) and the direction of the vector.  In the special case where it changes only the magnitude of the vector and leaves the direction unchanged (or switches the vector to the opposite direction), that vector is called an eigenvector of that matrix.

When multiplied by a matrix, each eigenvector of that matrix changes its magnitude by a factor, called the eigenvalue corresponding to that eigenvector.  In other words: vector x is called an eigenvector of the matrix A with eigenvalue λ if the following equation holds 

$$Ax=\lambda x$$

The eigenvalues of A are precisely the solutions λ to the equation $$det(A – \lambda x) = 0$$. Here $$det()$$ is the determinant of matrix formed by $$A – \lambda I$$ in which $$I$$ is a $$n\times n$$ identity matrix. This equation is called the characteristic equation of $$A$$.

For a more detailed description including complex eigenvalues, refer to my piece “Complex Eigenvalues for HP-41cv/cx

## Method

The program uses the iterative power method to determine the largest eigenvalue. This value is removed from the matrix using the deflation method of Hotelling . The remaining eigenvalues are determined in a similar way. Note that accumulation of rounding errors will affect the accuracy of successive eigenvalues.

The power method is an iterative method for approximating eigenvalues. This method is perhaps not the most respected method, and can only be used when:

• There are no two identical eigenvalues.
• The start vector is not the null vector.
• The matrix does not contain complex eigenvalues. (The method will typically work well with a strongly dominated diagonal).

If desired, the eigenvectors can be calculated from the original matrix A. (The deflation method spoils the eigenvector, but not the eigenvalue.)

## Examples

### Example 1

$$A=\left(\begin{array}{cc} 8 & 4 \\ 4 & 6 \end{array}\right)$$
A=$$\left(\begin{array}{cc} 8 & 4 \\ 4 & 6 \end{array}\right)$$

keystrokes display
FIX 3
XEQ “EW” DIM?
2 R/S INV.MATRIX:
1:1=0.000?
8 R/S 1:2=0.000?
4 R/S 2:1=0.000?
3 R/S 2:2=0.000?
6 R/S INV.STARTV.:
1:1=0.000?
1 R/S 2:1=0.000?
1 R/S EPS=0.001?
R/S 10.500
:
10.605
EW=10.606
R/S INV.STARTV.:
1:1=0.838?
1 R/S 2:1=0.546?
1 R/S EPS=0.001?
R/S -0.230
3.393
3.394
EW=3.394
R/S EINDE

The computed eigenvalues $$10.606,\ 3.394$$ can be verified through:

$$Ax=\lambda x$$

as in

\left\{ \begin{aligned} \left(\begin{array}{cc} 8 & 4 \\ 4 & 6 \end{array}\right)\times \left(\begin{array}{cc} 1.535\\ 1 \end{array}\right) &= \left(\begin{array}{cc} 8\times1.535 + 4\times1 \\ 4\times1.535 + 6\times1 \end{array}\right)\\ &= \left(\begin{array}{c} 16.280\\ 10.606\\ \end{array}\right) = 10.606\times \left(\begin{array}{c} 1.535 \\ 1 \end{array}\right)\\ \left(\begin{array}{cc} 8 & 4 \\ 4 & 6 \end{array}\right)\times \left(\begin{array}{cc} -0.8685\\ 1 \end{array}\right) &= \left(\begin{array}{cc} 8\times(-0.8685) + 4\times1 \\ 4\times(-0.8685) + 6\times1 \end{array}\right)\\ &= \left(\begin{array}{c} -2.948\\ 3.394\\ \end{array}\right) = 3.394\times \left(\begin{array}{c} -0.8695 \\ 1 \end{array}\right) \end{aligned} \right.

This is also verified through the characteristic polynomial. The eigenvalues of $$A$$ are precisely the solutions $$\lambda$$ to the equation listed below with $$I$$ is the $$n\times n$$ identify matrix.

$$det(A-\lambda I)=0$$

Therefore

\require{amsmath}\require{amssymb}\begin{aligned} A=\left(\begin{array}{cc} 8 & 4 \\ 3 & 6 \end{array}\right)\ \land\ det(A-\lambda I)&=0 \\ \Rightarrow\ det\left[\left(\begin{array}{cc} 8 & 4 \\ 3 & 6 \end{array}\right) – \lambda \left( \begin{array}{cc} 8 & 4 \\ 3 & 6 \end{array} \right)\right]&=0\\ \Rightarrow\ det\left(\begin{array}{cc} 8-\lambda & 4\\ 3 & 6-\lambda \end{array}\right)&=0\\ \Rightarrow\ (8-\lambda)(6-\lambda)-(4)(3)=0\\ \\ \Rightarrow\ \lambda^2-14\lambda+36=0 \end{aligned}

## Source code

• Requires X-Functions module on the HP-41cv and the Advantage ROM
• Available as source code, raw for the V41 emulator and bar code for the HP Wand (HP82153A).
• Size is 39 registers
• Registers:
• alfa, X, Y, Z, T, L
• R00: epsilon
• R01: loop counter
• R02: eigenvalue
• Long jumps:
• 41
• 95

## References

  Eigenwaarden Coert Vonk, 27 September 1986 HP User News, SEP86 N9, blz. 48-50  Matrixrekenen Dictaat Lineaire Algebra, blz. 51 e.v. Ir. A. van der Knaap HTS Dordrecht, the Netherlands  Wiskunde voor het HBO Deel 2, blz. 153 e.v. R. van Asselt ISBN 90 11 008480  Dictaat Lineaire Algebra 4e druk, blz. 152 ev. G. W. Decnop & H. van Iperen ISBN 90 65 620362  Eigenvalues and eigenvectors Wikipedia https://en.wikipedia.org/wiki/Eigenvalues_and_eigenvectors  Eigenwerte und Eigenvektoren berechnen Arndt Brünner http://www.arndt-bruenner.de/mathe/scripts/engl_eigenwert2.htm
Embedded software developer
Passionately curious and stubbornly persistent. Enjoys to inspire and consult with others to exchange the poetry of logical ideas.

This site uses Akismet to reduce spam. Learn how your comment data is processed.