Post Reply 
[VA] SRC #015b - HP-15C & clones: COMPLEX Matrix Inverse up to 8x8
09-29-2023, 01:20 PM (This post was last modified: 10-03-2023 07:16 AM by Werner.)
Post: #5
RE: [VA] SRC #015b - HP-15C & clones: COMPLEX Matrix Inverse up to 8x8
[Update: shaved off 2 bytes ;-) ]
Apologies for monopolizing this thread ;-)
Forget all that came before; well, save the previous post on multiplying two complex matrices, which may still be useful as is.
The following three small routines are all you need for complex matrix solving and inverting, in 'split' format.
Enter matrices A,B,C and D separately as before.
- to solve (A+iB)*(X+iY) = C+iD, press (GSB) C and (GSB) D
- to invert A+iB, do (GSB) C and (GSB) E
The GSB C part need only be done once - think of it as the LU-decomposition for regular matrices. So you can solve subsequent right-hand sides (C,D,D,..), and combine solving and inverting (C,D,D,..,E).
If you leave off LBL E, you have a routine of 48 bytes for solving complex equations, and subsequent ones, if needed. This routine thus replaces the one I previously posted, which couldn't handle subsequent solves - but it still fits in an original 15C and allows solving a 4x4 complex system. (the 15CE can solve a 5x5, the 15C-2 a 7x7 and the DM15L an 8x8 system)

The inversion routine alone needs 3.N^2 registers, the solve routine an additional 2N.M registers, where M is the number of right-hand side columns.
So, to solve a single 4x4 system, you'd need 3.4^2+2.4 = 56 registers. Since the program of 48 bytes uses 7 additional registers, it still fits in an original 15C.

Routine C (Factor) - 21 bytes
Routine D (Solve) - 27 bytes
Routine E (Invert) - 15 bytes
for a total of 63 bytes.

001 LBL C
002 RCL MATRIX B
003 RCL MATRIX A
004 RESULT E
005 -
006 RCL MATRIX A
007 RCL MATRIX B
008 RESULT A
009 +
010 1/x
011 RESULT B
012 x
013 CHS
014 RCL MATRIX A
015 RESULT A
016 1/x
017 X<>Y
018 RCL MATRIX E
019 MATRIX 6
020 RTN
021 LBL D
022 RCL MATRIX D
023 RCL MATRIX C
024 RESULT E
025 -
026 RCL MATRIX C
027 RCL MATRIX D
028 RESULT C
029 +
030 STO MATRIX D
031 RCL MATRIX B
032 RCL MATRIX E
033 MATRIX 6
034 RCL MATRIX A
035 /
036 RCL MATRIX B
037 RCL MATRIX D
038 CHS
039 RESULT E
040 MATRIX 6
041 RCL MATRIX A
042 RESULT D
043 /
044 RTN
045 LBL E
046 RCL MATRIX B
047 RCL MATRIX A
048 RESULT E
049 /
050 RCL MATRIX A
001 RESULT A
002 1/x
053 RESULT B
054 -
055 RCL MATRIX E
056 RCL MATRIX A
057 RESULT A
058 +
059 RTN


Cheers, Werner

41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: [VA] SRC #015b - HP-15C & clones: COMPLEX Matrix Inverse up to 8x8 - Werner - 09-29-2023 01:20 PM



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