[VA] SRC #015b - HP-15C & clones: COMPLEX Matrix Inverse up to 8x8
|
09-25-2023, 02:52 PM
Post: #2
|
|||
|
|||
RE: [VA] SRC #015b - HP-15C & clones: COMPLEX Matrix Inverse up to 8x8
Very nice, Valentin!
You make it increasingly harder for me to improve upon your code ;-) I did manage to squeeze off a puny byte, a stack instruction, which will make little to no difference. The one thing I miss in your extensive posts, however, is some explanation of the algorithm used. So here goes, and it is based on my version of your code - which simply switches the roles of matrices E and B. To invert a complex matrix A+iB = X+iY, you need to solve A.X – B.Y = I B.X + A.Y = 0 Add and subtract: (This step is needed to make reasonably certain that the main matrix is invertible) (A+B).X - (B-A).Y = I (B-A).X + (A+B).Y = -I Let E := B - A; B := A + B; then the equations become B.X - E.Y = I (1) E.X + B.Y = -I (2) multiply (2) by E.B^-1 and add to (1): (B + E.B^-1.E).X = I - E.B^-1 multiply (1) by E.B^-1 and subtract from (2): (B + E.B^-1.E).Y = -I – E.B^-1 Then the algorithm becomes: (with double inversion to keep the number of matrices needed down to 3) E := B - A; B := (A + B)^-1; A := -E*B; B := B^-1; B := (B – A*E)^-1; E := B*A; A := E + B; B := E - B; listing (30 lines, 31 bytes): LBL C RCL MATRIX B RCL MATRIX A RESULT E - RCL MATRIX A RCL MATRIX B RESULT B + 1/x RESULT A x CHS RCL MATRIX B RESULT B 1/x X<>Y RCL MATRIX E MATRIX 6 1/x RCL MATRIX A RESULT E x RESULT A + RCL MATRIX E RCL MATRIX B RESULT B - RTN Cheers, Werner 41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)