Post Reply 
(HP 15C) (DM15) Eigenvalues and eigenvectors of symmetric matrices
05-26-2023, 11:52 PM (This post was last modified: 06-06-2023 06:22 PM by rawi.)
Post: #1
(HP 15C) (DM15) Eigenvalues and eigenvectors of symmetric matrices
Code:

01 f LBL A
02 f RESULT B
03 RCL DIM A
04 1
05 f DIM B
06 x<>y
07 EEX
08 3
09 /
10 +
11 STO I
12 f MATRIX 1
13 f LBL 0
14 f RAN#
15 STO B
16 1
17 STO+ 0
18 f ISG I
19 GTO 0
20 RCL MATRIX B
21 ENTER
22 f MATRIX 8
23 /
24 0
25 STO I
26 f LBL 1
27 g CF 0
28 f RESULT C
29 RCL MATRIX A
30 RCL MATRIX B
31 *
32 f RESULT D
33 RCL MATRIX B
34 f MATRIX 5
35 f MATRIX 1
36 RCL D
37 g TEST 2
38 g SF 0
39 RCL MATRIX C
40 ENTER
41 f RESULT B
42 f MATRIX 8
43 /
44 g LST X
45 g F? 0
46 CHS
47 RCL I
48 x<>y
49 STO I
50 -
51 g ABS
52 EEX
53 8
54 CHS
55 g TEST 8
56 GTO 1
57 RCL MATRIX B
58 RCL I
59 f MATRIX 1
60 R/S
61 RCL MATRIX B
62 f MATRIX 4
63 f RESULT C
64 RCL MATRIX B
65 ENTER
66 f MATRIX 5
67 RCL MATRIX A
68 RCL MATRIX C
69 RCL I
70 *
71 f RESULT A
72 -
73 GTO A

USAGE INSTRUCTIONS:
Store Matrix in Matrix A
Start program: GSB A
When execution stops, the first eigenvalue is shown.
x<>y -> The eigenvector to the eigenvalue is shown. Eigenvectors are normalized to the length of 1.
R/S continues the procedure for the next eigenvalue / eigenvector.

EXAMPLE:

Matrix A:
1 -0.36 0.12
-0.36 1 0.09
0.12 0.09 1
Store Matrix A
Activate user-Mode
Start program: GSB A

First stop:
1.3614 (greatest absolute eigenvalue)
x<>y -> b 3 1
RCL B: 0,7149
RCL B: -0.6962
RCL B: 0,0641

R/S -> Second stop:
1,0521 (second eigenvalue)
x<>y -> b 3 1
RCL B: -0.1934
RCL B: -0.2851
RCL B: -0.9388

R/S -> Third stop:
0.5866 (last eigenvalue)
x<>y -> b 3 1
RCL B: 0,6719
RCL B: 0,6588
RCL B: -0,3385

METHOD:
The program generates a random vector x and computes b = A*x. The length of b is computed, and b is normalized and replaces x. This is repeated until the length of b changes less than 1E-8. Then the length l of b is an estimate of the biggest eigenvalue, and x is an estimate of the corresponding eigenvector. Then l*x*x’ is subtracted from Matrix A, and the procedure is repeated.
Since random numbers are used your results can be different in the fourth decimal place of the elements of the eigenvectors.

MEMORY:
Matrices: If n is number of rows / columns of matrix you need 2*n^2+n+1 and I.
The DM 15L can handle up to 8X8 matrices.

Edit: Two commands taken out, line numbers added, more explanation.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 3 Guest(s)