(HP71B) Eigenvalues of Symmetric Real Matrix
|
11-26-2023, 09:26 PM
(This post was last modified: 11-29-2023 12:13 PM by Albert Chan.)
Post: #5
|
|||
|
|||
RE: (HP71B) Eigenvalues of Symmetric Real Matrix
HP71B, version 2
1. Suggested by Werner, assume user inputed symmetric square matrix. Remove code: A=(A+AT)/2 2. Bij = tan(θ/2) replace with tan(θ)/2, (|θ|≤pi/4), which use 1 sqrt, instead of 2 This has a slight effect to convergence rate, but likely not noticeable. For OP example, it converged slightly better. Cas> float(eigenvals([[0,1,2],[1,2,3],[2,3,4]])) /* for reference */ [0., 6.87298334621, −0.872983346207] This is 6th iteration, with old Bij = tan(θ/2) Code: FNORM(B)= 7.60886994417E-10 This is 6th iteration, with new Bij = tan(θ)/2 Code: FNORM(B)= 8.7618796429E-11 3. Q correction: I = (I+B)-1 (I+B) 2 (I+B)-1 - I = (I+B)-1 - (I+B)-1 B = (I+B)-1 (I-B) HP71-MathPac-suppl_manual.pdf Wrote:MAT X=INV(A)*B directly computes the solution of the matrix equation A X=B instead of RHS cost the same as matrix inverse. (although in this case, LHS is cheap to compute too) 4. Combine "MAT L=TRN(Q) @ MAT L=L*A" to MAT L=TRN(Q)*A 10 DESTROY ALL @ OPTION BASE 1 @ INPUT "N=";N 20 DIM A(N,N),B(N,N),L(N,N),Q(N,N),I0(N,N) @ MAT I0=IDN @ MAT Q=I0 30 MAT INPUT A @ MAT L=A 40 DEF FNF(N,D)=N/(D+(1-2*(D<0))*SQRT(N*N+D*D)) ! = tan(atan(N/D)/2) 100 MAT B=ZER 110 FOR I=2 to N @ FOR J=1 to I-1 120 X=L(I,J) @ IF X THEN B(I,J)=FNF(2*X,L(I,I)-L(J,J))*.5 130 NEXT J @ NEXT I 140 MAT L=TRN(B) @ MAT B=B-L @ DISP "FNORM(B)=";FNORM(B) 150 MAT L=I0-B @ MAT B=I0+B @ MAT L=INV(B)*L @ MAT Q=Q*L 160 DISP "Q=" @ MAT DISP Q 170 MAT L=TRN(Q)*A @ MAT L=L*Q 180 DISP "L=" @ MAT DISP L Comment: this patch make bij closer to tan(θ/2), with little cost, if desired. Cas> series(tan(x/2),polynom) → 1/2*x+1/24*x^3+1/240*x^5 Cas> series(tan(x)/2,polynom) → 1/2*x+1/6*x^3+1/15*x^5 >120 X=L(I,J) @ IF X THEN X=FNF(2*X,L(I,I)-L(J,J))*.5 @ B(I,J)=X-X*X*X |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
(HP71B) Eigenvalues of Symmetric Real Matrix - Albert Chan - 11-26-2023, 05:16 PM
RE: (HP71B) Eigenvalues of Symmetric Real Matrix - Thomas Klemm - 11-26-2023, 07:20 PM
RE: (HP71B) Eigenvalues of Symmetric Real Matrix - Albert Chan - 11-26-2023, 07:41 PM
RE: (HP71B) Eigenvalues of Symmetric Real Matrix - Werner - 11-27-2023, 07:01 AM
RE: (HP71B) Eigenvalues of Symmetric Real Matrix - Werner - 11-26-2023, 07:44 PM
RE: (HP71B) Eigenvalues of Symmetric Real Matrix - Albert Chan - 11-26-2023 09:26 PM
RE: (HP71B) Eigenvalues of Symmetric Real Matrix - Albert Chan - 11-26-2023, 10:05 PM
RE: (HP71B) Eigenvalues of Symmetric Real Matrix - Albert Chan - 11-27-2023, 08:07 PM
RE: (HP71B) Eigenvalues of Symmetric Real Matrix - Werner - 11-27-2023, 08:51 PM
|
User(s) browsing this thread: 2 Guest(s)