Post Reply 
15c challenge: accuracy of a complex equation system
08-14-2023, 11:20 AM (This post was last modified: 08-14-2023 11:56 AM by Albert Chan.)
Post: #10
RE: 15c challenge: accuracy of a complex equation system
This just setup matrix A and B, 10-digits precision

10 DESTROY ALL @ OPTION BASE 1
20 R=4 @ COMPLEX A(R,R),B(R),X(R)
30 DATA (100,-116.6666667),(0,266.6666667),(0,0),(0,0)
31 DATA (0,266.6666667),(1E6,-116.6666667),(-1E6,0),(0,0)
32 DATA (0,0),(-1E6,0),(1E6,147.3333333),(0,-150)
33 DATA (0,0),(0,0),(0,-150),(1E5,147.3333333)
40 FOR I=1 TO R @ FOR J=1 TO R @ READ A(I,J) @ NEXT J @ NEXT I
45 DATA 10,0,0,0
50 FOR I=1 TO R @ READ B(I) @ NEXT I

Code:
>RUN
>MAT X=SYS(A,B) @ MAT DISP X
 ( 1.99579513038E-4, 4.09639907507E-3)
 (-1.44883361599E-3,-3.56329830823E-2)
 (-1.45408317044E-3,-3.56327608305E-2)
 ( 5.34458117065E-5,-2.25986825155E-6)

X(2) and X(3) are extremely close.
If we solve X(2), X(3)-X(2) instead, we get *full* 12 digits accuracy.

Code:
>FOR I=1 TO R @ A(I,2)=A(I,2)+A(I,3) @ NEXT I
>MAT X=SYS(A,B) @ X(3)=X(3)+X(2) @ MAT DISP X
 ( 1.99579513351E-4, 4.09639907503E-3)
 (-1.44883361584E-3,-3.56329830822E-2)
 (-1.45408317029E-3,-3.56327608304E-2)
 ( 5.34458117064E-5,-2.25986825132E-6)

MathPac2 Owner's Manual Supplement for HP-71 Wrote:MAT X=INV(A)*B directly computes the solution of the matrix equation A X=B instead of
inverting A then multiplying by B. It is however not exactly equivalent to MAT X=SYS(A,B)
in that it doesn't compute the residual correction that MAT..SYS does.

Newly adjusted A is very stable.
Without resdiual correction, this run twice as fast, without giving up much accuracy.

Code:
>MAT X=INV(A)*B @ X(3)=X(3)+X(2) @ MAT DISP X
 ( 1.99579513352E-4, 4.09639907504E-3)
 (-1.44883361584E-3,-3.56329830822E-2)
 (-1.45408317029E-3,-3.56327608304E-2)
 ( 5.34458117064E-5,-2.25986825133E-6)
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: 15c challenge: accuracy of a complex equation system - Albert Chan - 08-14-2023 11:20 AM



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