HP Forums
matrix Inverse using Hp-17BII+ - Printable Version

+- HP Forums (https://archived.hpcalc.org/museumforum)
+-- Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum-1.html)
+--- Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum-2.html)
+--- Thread: matrix Inverse using Hp-17BII+ (/thread-76603.html)



matrix Inverse using Hp-17BII+ - Chris Dean - 08-09-2005

The HP 27S and 19B Technical Manual uses the matrix of 
(cofactors / determinant) method to solve Ax=B. I originally
started doing the inversion using LU decomposition to be able
to invert N*N matrices but soon found that I could not enter
values into the ITEM() array at run time (i.e. whilst trying
to solve). Therefore I pursued a solution for a 3*3 matrix
only, just to say that I had done it!

The underlying equations using LU decomposition are shown below.

L11=A11
L21=A21
L31=A31
U12=A12 / L11
U13=A13 / L11
L22=A22 - L21.U12
U23=(A23 - L21.U13) / L22
L32=A32-L31.U12
L33=A33 - L31.U13 - L32.U23
Y1=1 / L11
Y2=-L21.Y1 / L22
Y3=(-L31.Y1 - L32.Y2) / L33
V31=Y3
V21=Y2 - U23.V31
V11=Y1 - V21.U12 - U13.V31
Y1=0
Y2=1 / L22
Y3=-L32.Y2 / L33
V32=Y3
V22=Y2 - U23.V32
V12=Y1 - U12.V22 - U13.V32
Y1=0
Y2=0
Y3=1 / L33
V33=Y3
V23=Y2 - U23.V33
V13=Y1 - U12.V23 - U13.V33

I had to split the equations into Z for variable registration, 
SUM for the input array A and AINV for calculation otherwise
the equation seemed to run out memory at run time and did not
calculate the last few terms.

Z=V11+V12+V13+V21+V22+V23+V31+V32+V33+
L11+L21+L22+L31+L32+L33+U12+U13+U23+
Y1+Y2+Y3

AINV=0x(L(l11:ITEM(A:1)) 
+L(L21:ITEM(A:4))
+L(L31:ITEM(A:7))
+L(U12:ITEM(A:2)/G(11))
+L(U13:ITEM(A:3)+G(L11))
+L(L22:ITEM(A:5)-G(L21)xG(U12))
+L(U23:ITEM(A:6)- G(L21)xG(U13))/G(L22))
+L(L32:ITEM(A:8)-G(L31)xG(U12))
+L(L33:ITEM(A:9)-G(L31)xG(U13)-G(L32)xG(U23))
+L(Y1:1/G(L11))
+L(Y2:-G(L21)xG(Y1)/G(L22))
+L(V31:(-G(L31)xG(Y1)-G(L32)xG(Y2)/G(L33))
+L(V21:G(Y2)-G(U23)xG(V31))
+L(V11:G(Y1)-G(V21)xG(U12)-G(V31)xG(U13))
+L(Y2:1/G(L22))
+L(V32:-G(L32)xG(Y2)/G(L33))
+L(V22:G(Y2)-G(U23)xG(V32))
+L(V12:-G(U12)xG(V22)-G(U13)xG(V32))
+L(V33:1/G(L33))
+L(V23:-G(U23)xG(V33))
+L(V13:-G(U12)xG(V23)-G(U13)xG(V33)))

Use the SUM menu to input the values for the 9 matrix elements
where element k = (row-1)*3 + column. Click on NAME and save the
data as A.

Go to the solve menu, find the Z formula and click on CALC to
register the variables.

Find the AINV formula and click on CALC. Click on AINV, when it
is finished the display should show AINV=0.000…

Click on EXIT and go to the Z equation. Click on CALC and then
RCL V11, RCL V12, RCL …. to show all the elements of the inverse
matrix of A.

A useful test matrix is the Hilbert matrix 1, ½, 1/3, ½, 1/3, ¼,
1/3, ¼, 1/5 with the resultant inverse matrix elements 9, -36,
30, -36, 192, -180, 30, -180, 180 ignoring the rounding errors.

I have not studied the accuracy of the results as yet but
thought I would post it for any comments and hopefully any
improvements on technique. Also are there any tricks that I do
not know about that I could have used?


Edited: 9 Aug 2005, 9:07 a.m.