Showing posts with label Eigenvalues. Show all posts
Showing posts with label Eigenvalues. Show all posts

Saturday, August 1, 2026

DM42 and HP 42S: Quadratic Equation, Characteristic Polynomial, and Eigenvalues

DM42 and HP 42S: Quadratic Equation, Characteristic Polynomial, and Eigenvalues




The programs are listed for the Swiss Micros DM42 and Hewlett Packard 42S.



All examples are on rounded to four decimal places and complex mode turned on (CPXRES).



Monic Quadratic Equation: quad2.raw



The program QUAD2 solves the equation for w:

w² + Y * w + X = 0

Y: contents of stack Y

X: contents of stack X



Code:

00 { 35-Byte Prgm }

01▸LBL "QUAD2"

02 X<>Y

03 ENTER

04 2

05 ÷

06 +/-

07 ENTER

08 X↑2

09 X<>Y

10 R↓

11 X<>Y

12 -

13 SQRT

14 R↑

15 X<>Y

16 ENTER

17 ENTER

18 R↑

19 ENTER

20 R↓

21 X<>Y

22 +

23 R↓

24 -

25 R↑

26 RTN

27 .END.



Example 1: w² + 7 * w + 5 = 0

Stack: Y: 7, X: 5

Results: -6.1926, -0.8074



Example 2: w² – 4 = 0

Stack: Y: 0, X: -4

Results: -2.0000, 2.0000



Characteristic Polynomial: char2.raw



The program CHAR2 find the coefficients of 2 x 2 matrix:

[ [ A, B ] [ C , D ] ]

Result: λ² – T1 * λ + T2 = 0 where

T1 = A + D

T2 = det([[ A, B ] [ C, D ]]) = A * D – C * B



The program provides prompts and results in messages.



Code:

00 { 81-Byte Prgm }

01▸LBL "CHAR2"

02 "[[A,B][C,D]]"

03 AVIEW

04 PSE

05 PSE

06 "L↑2-T1×L+T2=0"

07 AVIEW

08 PSE

09 PSE

10 INPUT "A"

11 ENTER

12 ENTER

13 INPUT "D"

14 ENTER

15 R↓

16 +

17 "T1= "

18 ARCL ST X

19 AVIEW

20 STOP

21 R↓

22 ×

23 INPUT "C"

24 INPUT "B"

25 ×

26 -

27 "T2= "

28 ARCL ST X

29 AVIEW

30 RTN

31 .END.



Example 1: [ [ -6, 4 ] [ 2, 3 ] ]

Results: T1: 3, T2: -26



Example 2: [ [ 5, 8 ] [ -1, 2 ] ]

Results: T1: 7, T2: 18



Eigenvalues of 2 x 2 Matrices: egn2.raw



The program EGNV2 calculates the eigenvalues of a 2 x 2 matrix:

[ [ A, B ] [ C , D ] ]



The program provides prompts and results in messages. The command CPXRES sets the calculator to accept complex number results.



Code:

00 { 106-Byte Prgm }

01▸LBL "EGNV2"

02 CPXRES

03 "[[A,B][C,D]]"

04 AVIEW

05 PSE

06 PSE

07 INPUT "A"

08 INPUT "B"

09 INPUT "C"

10 INPUT "D"

11 RCL "A"

12 RCL "D"

13 +

14 +/-

15 RCL "A"

16 RCL "D"

17 ×

18 RCL "B"

19 RCL "C"

20 ×

21 -

22 X<>Y

23 ENTER

24 2

25 ÷

26 +/-

27 ENTER

28 X↑2

29 X<>Y

30 R↓

31 X<>Y

32 -

33 SQRT

34 R↑

35 X<>Y

36 ENTER

37 ENTER

38 R↑

39 ENTER

40 R↓

41 X<>Y

42 +

43 "E1="

44 ARCL ST X

45 AVIEW

46 PSE

47 PSE

48 R↓

49 -

50 "E2="

51 ARCL ST X

52 AVIEW

53 PSE

54 PSE

55 R↑

56 RTN

57 .END.



Example 1: [ [ -6, 4 ] [ 2, 3 ] ]

Results: 3.8151, - 6.8151



Example 2: [ [ 5, 8 ] [ -1, 2 ] ]

Results: 3.5 ± 2.37792 i


You can download the three programs here: https://drive.google.com/file/d/1SKcVIhKYHnnuhrvBJxfOmwsV8sRTSj0X/view?usp=sharing





Eddie


All original content copyright, © 2011-2026. Edward Shore. Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited. This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.

Saturday, June 28, 2025

fx-991 CW: Finding the Eigenvalues of a 2 x 2 Matrix

fx-991 CW: Finding the Eigenvalues of a 2 x 2 Matrix



Finding the Eigenvalues of a 2 x 2 Matrix


To find the eigenvalues of a matrix M, the characteristic polynomial must be solved in terms of λ:


det( M – λ * I) = 0


where:

M = a square matrix of dimension n x n

I = an identity matrix of size n x n.


The identity matrix is a square matrix in which all elements have a value 0 except the diagonal elements, which have the value 1.


A 2 x 2 identity matrix: [ [ 1, 0 ] [ 0, 1 ] ]

A 3 x 3 identity matrix: [ [ 1, 0, 0 ] [ 0, 1, 0 ] [ 0, 0, 1 ] ]


For a 2 x 2 matrix:


M = [ [ a, b ] [ c , d ] ]


The characteristic polynomial used to find the eigenvalues are:


det( M – λ * I) = 0

det( [ [ a, b ] [ c , d ] ] - λ * [ [ 1, 0 ] [ 0, 1 ] ] ) = 0

det( [ [ a, b ] [ c , d ] ] - [ [ λ, 0 ] [ 0, λ ] ] ) = 0

det( [ [ a - λ, b ] [ c , d - λ ] ] ) = 0

(a – λ) * (d – λ) – b * c = 0

λ^2 – (a + d) * λ + (a * d – b * c) = 0


Note:

trace(M) = a + d

det(M) = a * d – b * c


The characteristic equation to be solved is:


λ^2 – (a + d) * λ + (a * d – b * c) = 0

λ^2 – trace(M) * λ + det(M) = 0



Casio fx-991CW Algorithm


The algorithm will involve two apps: Matrix and Equation. Here is a way of finding the eigenvalues of a 2 x 2 matrices using only the fx-991 CW calculator without the need for writing anything down.


Note: The variables I use in the procedure is just for illustrative purposes. You can use any variables you want to designate the corner elements, the trace, and the determinant. The point is to be organized.


Variables used in this procedure:

A = upper-left element

B = lower-right element

C = trace = A + B

D = determinant


Settings: It is assumed that the MathI/MathO Input/Output mode and a+bi is selected for Complex result.


The screen shots are generated using the ClassPad Math (classpad.net) emulator for the fx-991CW and illustrates finding the eigenvalues of the matrix:


MatA = [ [ 4, 2 ] [ 5, 4 ] ]


Matrix App


Step 1: Press the [ HOME ] key, select the Matrix app.


Step 2: Use the TOOLS key to define a Matrix of dimension 2 x 2.


Step 3: Enter the matrix’s elements. Register each element is registered by using [ OK ] or [ EXE ]. Be careful not to press [ EXE ] or [ OK ] without entering a value first, as we need to keep the matrix editing screen up.


Step 4: Go to element (1,1) (upper-left hand corner), press the [ VARIABLE] key, go to variable A, press [ OK ], and select Store. Then go to element (2,2) (lower-right hand corner), press the [ VARIABLE] key, go to variable B, press [ OK ], and select Store.**


Step 5: Without entering or editing an element, press either [ EXE ] or [ OK ] to leave the matrix editor. When the message “Press [TOOLS] to define Matrix.” appears, we are in the calculation mode of the Matrix app.


Note: If you leave the matrix edit mode before storing the corner elements, you can go back into matrix edit mode by pressing [ TOOLS ], selecting your matrix, and then selecting Edit. You can check to see if corner values are stored by pressing [ VARIABLE ].





Step 6: Press [ SHIFT ] [ 4 ] (A) + [ SHIFT ] [ 7 ] ( B ) [ EXE ]. This calculates the matrix’s trace. Then press [ VARIABLE ], choose C, press [ OK ], choose Store.


Step 7: Press [ CATALOG ], select the Matrix sub-menu, then the Matrix Calc sub-menu, and select Determinant. Then use the catalog to grab the matrix and press [ EXE ] to calculate the matrix. Use the variable list to store the value in D (similar procedure in Step 6).





When transferring between apps, the values stored in the memory registers A-F, x, y, and z are retained, even when the fx-991CW is turned off.


Equations App


Step 8: Press [ HOME ] and select the Equation app and press [ OK ]. Select Polynomial, ax²+bx+c (2nd order polynomial, quadratic equation).


Step 9: Enter the following coefficients: 1 x² – C x + D (note the minus sign on C).


Step 10: Press [ OK ]. The first eigenvalue is displayed. Press the down arrow ([↓]) to get the other eigenvalue. 

 An optional step is to use the [ VARIABLE ] key to store the results (like in E or F, for example). 

 Another optional step is to press [ FORMAT ], select Decimal to see the decimal approximation.





The results are:


C = trace = 8

D = determinant = 6

Eigenvalues:

λ1 = 4 + √10

λ2 = 4 - √10



Other Examples



Find the eigenvalues of Mat B = [ [ -8, 1 ] [ 16, 7 ] ]


Results:

C = trace = -1

D = determinant = -72

Eigenvalues:

λ1 = 8

λ2 = -9





Find the eigenvalues of Mat C = [ [ -5, -7 ] [ 3, - 2] ]


Results:

C = trace = -7

D = determinant = 31

Eigenvalues:

λ1 = (-7 + 5 * √3 * i) / 2

λ2 = (-7 - 5 * √3 * i) / 2




I hope you find this useful and beneficial. Until next time,


Eddie


All original content copyright, © 2011-2025. Edward Shore. Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited. This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.

Saturday, May 16, 2015

TI-84 Plus Wish List

TI-84 Plus Wish List

TI-84 Plus C Silver Edition in action


While awaiting the delivery of the next generation TI-84 Plus (TI-84 Plus CE), it has been a while since TI has upgraded the operating software of the TI-84 family, both the monochrome and color editions.  Hopefully, Texas Instruments has an update of the operator software in the near future. 

Here is my wish list, should Texas Instruments decide to update the software for the TI-84 family:

Applies to both the Monochrome and Color TI-84s:

* Eigenvalues and eigenvector functions for matrices, even if these functions have an upper limit on what the matrix size can be (6 x 6, 10 x 10, etc.).

* Expand complex number support to include trigonometric functions.  The TI-84 already supports complex number arguments for the logarithm, exponential, square root, and power functions.

* A quick polynomial solver function.  The TI-85 and TI-86 had a poly function where you can enter a list that represents the polynomial’s coefficients.  For example, poly {3,2,-5} returned {1, -1.666666667}.  This would be a super command for programming applications.

* Vectors.  Many advanced math classes, starting in pre-calculus, teach vectors and their operations.  Functions can include, at the minimum, dot product, cross product, and the norm. These functions can be added to the Matrix menu. 

* Expand the days between dates (dbd function from the Finance App) to include four-digit years.  With the current setup, the dbd function restricts dates from 1950 to 2049.

* Allow lower case text. 

* Add the string commands (sub, Equ>String, String>Equ) to the PRGM I/O menu. 

* Allow the factorial function (!) to include non-positive integers.


For the Color TI-84s:

* Add a RGB (red, green, blue) function.  This would allow users to use all the colors that the TI-84 instead of merely just 15.  The RGB function could be tacked on to the Vars, Color menu as the last option after the built-in 15 colors.

* Allow the Output command to show text in color.  The color can be an optional fourth argument which either takes the name of one of the 15 preset colors, it’s color value, or color determined by the RGB function.

If you are reading this Texas Instruments, please consider these suggestions and thank you for your time.  By the way, the TI Connect CE software is excellent; I love the interface and ease of connectivity. 

Readers and commentators:  if you see something that you would like to add or feel like I have missed something, please leave a comment or two.    

A Musical Bonus

While out in Los Angeles, I came across this mini piano calculator at The Green Bean in the Eagle Rock community.  It is basic, solar, and fun to look at.  I only wish the keys were not so rubbery.  Oh well, it is fun to look at and play with.  Here is a picture: 

Mini Piano Calculator


Thank you to all my readers, followers, and commentators.  It is always appreciated! 

Eddie

This blog is property of Edward Shore.  2015.




Wednesday, October 30, 2013

Matrix Calculations: det(A - B * λ)=0

Let A and B be square matrices. B is a diagonal matrix. A diagonal matrix is a matrix with entries in it's diagonal positions, (1,1), (2,2), and so on, and 0 everywhere else. The identity matrix is a diagonal matrix. Another example is:

[ [2, 0, 0],[0, -2, 0],[0, 0, 5] ]

Let m, n, r, s, and t be numerical constants. Let a1, a2, and a3 be entries on the first row. Similar for b1, b2, b3, c1, c2, and c3.



det(A - B * ident(λ)) = 0



Comparison of 2 x 2 Matrices:
Note the constant term (λ^0), typed in green, the same.

B is a 2 x 2 identity matrix.

det( [ [a1, a2],[b1, b2] ] - λ * [ [1,0],[0,1] ] ) = 0
det( [ [a1, a2],[b1, b2] ] - [ [λ, 0],[0, λ] ]) = 0
λ^2 - (a1 + b2) * λ + a1*b2 - a2*b1 = 0

B is a diagonal matrix [ [m, 0],[0, n] ].

det( [ [a1, a2],[b1, b2] ] - λ * [ [m,0],[0,n] ] ) = 0
det( [ [a1, a2],[b1, b2] ] - [ [m*λ, 0],[0, n*λ] ]) = 0
m*n*λ^2 - (a1*n + b2*m)*λ + (a1*b2 - a2*b1) = 0



Comparison of 3 x 3 Matrices:
Note the constant term (λ^0), typed in green, the same.

B is a 3 x 3 identity matrix.

det( [ [a1,a2,a3],[b1,b2,b3],[c1,c2,c3] ] - λ * [ [1, 0, 0],[0, 1, 0],[0, 0, 1] ] ) = 0
det( [ [a1,a2,a3],[b1,b2,b3],[c1,c2,c3] ] - [ [λ, 0, 0],[0, λ, 0],[0, 0, λ] ] ) = 0

- λ^3
+ λ^2 * (a1 + b2 + c3)
+ λ * (-a1*b2 - a1*c3 - b2*c3 + a2*b1 + a3*c1 + b3*c2)
+ (a1*b2*c3 - a1*b3*c2 - a3*b2*c1 - a2*b1*c3 + a2*b3*c1 + a3*b1*c2) = 0

B is a general 3 x 3 diagonal matrix, [ [r, 0, 0],[0, s, 0],[0, 0, t] ].

det( [ [a1,a2,a3],[b1,b2,b3],[c1,c2,c3] ] - λ * [ [r, 0, 0],[0, s, 0],[0, 0, t] ] ) = 0
det( [ [a1,a2,a3],[b1,b2,b3],[c1,c2,c3] ] - [ [r*λ, 0, 0],[0, s*λ, 0],[0, 0, t*λ] ] ) = 0

- λ^3 * r*s*t
+ λ^2 * (s*t*a1 + r*t*b2 + r*s*c 3)
+ λ * (a1*b2*c3 - a1*b3*c2 - a3*b2*c1 - a2*b1*c3 + a2*b3*c1 + a3*b1*c2) = 0


Of course to get the eigenvalues (λ), solve the appropriate polynomial.

Hope this is helpful to those studying linear algebra or for those who are curious. This post was inspired from a program I was helping a fellow HP Prime programmer.

This post is dedicated to Michael de Estrada.


This blog is property of Edward Shore. 2013

Wednesday, December 5, 2012

Numeric CAS - Part 11: Eigenvalues of 3 x 3 Matrices

Eigenvalues of 3 x 3 Matrices

Many graphing calculators that do not have CAS (computer algebraic systems) do not have eigenvalues and eigenvector functions.

The programs for the Casio Prizm and TI-84+ gives eigenvalues of 3 x 3 matrices.

For the HP 39gii has the functions EIGENVAL for eigenvalues.

Example:
A = [[2, -2, 3][-1, 0, 1][6, -3, 3]]

Eigenvalues:
≈ 0.2465, -1.8447, 6.5982


Casio Prizm:

EIGEN3
Eigenvalues of a 3 × 3 Matrix
Circa 2011 - 244 bytes

a+bi
"3 × 3 Matrix"? → Mat A
Mat A[1,1] + Mat A[2,2] + Mat A[3,3] → T
(Mat A)² → Mat B
Mat B[1,1] + Mat B[2,2] + Mat B[3,3] → U
Solve(-X^3 + X^2 × T + X × 1/2 × (U-T^2) + Det Mat A,0)→ R ◢
-R^2 + R × T - T^2 ÷ 2 + U ÷ 2 → A
-R + T → B
1/2 × (B - √(4A + B^2)) → E ◢
1/2 × (B + √(4A + B^2)) → F ◢
"STORED IN R, E, F"


TI-84+:

EIGEN3
Eigenvalues of a 3 × 3 matrix - 193 bytes
12/3/12

a+bi
Input "3 X 3 MATRIX:", [A]
[A](1,1) + [A](2,2) + [A](3,3) → T
[A]² → [B]
[B](1,1) + [B](2,2) + [B](3,3) → U
solve(-X³ + X² T + .5X(U-T²) + det([A]), X, 0) → R
Pause R
-R² + RT - T²/2 + U/2 → A
-R + T → B
.5(B - √(4A+B²)) → E
.5(B + √(4A+B²)) → F
Pause E
Pause F




This blog is property of Edward Shore. 2012

Numeric CAS Part 10 - Eigenvalues of 2 x 2 Matrices

Eigenvalues of 2 x 2 Matrices

Many graphing calculators that do not have CAS (computer algebraic systems) do not have eigenvalues and eigenvector functions.

The program for the Casio Prizm gives eigenvalues. The TI-84+ program gives both eigenvalues and eigenvectors.

For the HP 39gii has the functions EIGENVAL and EIGENVV for eigenvalues and eigenvectors, respectively.

Example:
A = [[2, 7][-3, 9]]

Eigenvalues: ≈ 5.5 ± 2.9580i


Casio Prizm:

Eigenvalues of a 2 × 2 Matrix
EIGEN2 - 136 Bytes

a+bi
"2 × 2 MATRIX:"? → Mat A
Mat A[1,1] + Mat A[2,2] → T
Det Mat A→ D
(T+√(T^2-4D))÷2 → R ◢
(T-√(T^2-4D))÷2 → S ◢
"λS STORED IN R,S"


TI-84+:

EIGEN2
Eigenvalues of 2 × 2 matrices - Approximately 280 bytes
Bonus! A pair of eigenvectors are given
5/15/2011

a+bi
Input "2 X 2 MATRIX:", [J]
[J](1,1) + [J](2,2) → T
det([J]) → D
(T + √(T^2 - 4D))/2 → U
(T - √(T^2 - 4D))/2 → V
Disp "EIGENVAL. U"
Pause U
(U - [J](1,1)) / [J](1,2) → A
√(1 + A^2)⁻¹ * [[1][A]] → [H]
Disp "EIGENVEC. [H]"
Pause [H]
(V - [J](1,1)) / [J](1,2) → B
√(1 + B^2)⁻¹ * [[1][B]] → [I]
Disp "EIGENVAL. V"
Pause V
Disp "EIGENVECT. [I]"
Pause [I]




This blog is property of Edward Shore. 2012

Python in Numworks: Duplicating and Grayscale

Python in Numworks: Duplicating and Grayscale All three scripts presented today use the math, random, and the Numworks specific ...