HP-41 Complex Determinants w/ SandMatrix and 41Z
|
06-11-2018, 08:51 AM
(This post was last modified: 06-14-2018 12:35 AM by Ángel Martin.)
Post: #1
|
|||
|
|||
HP-41 Complex Determinants w/ SandMatrix and 41Z
Complex Determinants with the SandMatrix and 41Z Modules
The programs below are a first-pass successful attempt at calculating Complex Matrix determinants up to order 4. The Complex Matrix is to be stored using the SandMatrix convention - which is identical to the HP-41 Advantage's. With this convention each complex number is represented by four elements in the complex matrix - refer to the manuals for details. Code: [[ Re(aij) -Im(aij) ] The SandMatrix comes well-equipped with routines to calculate the TRACE and integer powers of a matrix (M^2 and MPWR), therefore it lends itself rather nicely to the direct formulas using those elements, as described at: https://en.wikipedia.org/wiki/Determinant The program includes 4 sections: 1. A Complex Matrix trace routine, "CMTR" 2. Determinant of a Complex 2x2 Matrix, "CMDT2" 3. Determinant of a Complex 3x3 Matrix, "CMDT3" 4. Determinant of a Complex 4x4 Matrix, "CMDT4" The last three can be grouped into a single one, using the matrix DIMension as criteria to branch to the appropriate section - but I left it as-is for easier readability. Also the code can be optimized putting repeated lines in independent subroutines; yet ditto as before. Only CMDT4 is commented, as it's a superset of the other two and can be used as a reference. Here's the program listing: Code: 01 LBL "CMTR" 63 2 The complex matrix won't be altered in any way, as all operations are made on a scratch copy. It can be stored in X-Mem, CL_Y-Mem, or standard Data registers area. The easiest way to enter the matrix is by using the CMEDIT routine - which expects the matrix name in ALPHA. It expects the matrix already created, using 2n x 2n as dimension - with "n" being the order. If you place it in the standard registers area, be aware that data registers R00, R01 are used by the routine MPWR for scratch. Additionally, data register R02 is used to store the Matrix Name (thus can't exceed 6 characters). As you can see there are numerous 41Z functions - used for the complex arithmetic using the Complex Stack. This has the additional advantage that doesn't require additional data registers, be that standard or CL Y-RAM. Examples.- Calculate the determinant of the 4x4 Complex Matrix: Code: [[ 1+i 2+2i 3+3i 4+4i ] Solution: det = -62-8i https://www.wolframalpha.com/input/?i=de...,+0%7D%7D) The program is slow in non-turbo settings- there are lots of moving pars behind the scenes, despite the straight-forward program listing. Using TURBO_50 the 4x4 determinant is obtained in 5 seconds approx. The accuracy for integer matrices holds up nicely, giving exact integer real and imaginary parts in the solution. Feel free to add your comments and suggestions for improvement. Cheers, ÁM "To live or die by your own sword one must first learn to wield it aptly." |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
HP-41 Complex Determinants w/ SandMatrix and 41Z - Ángel Martin - 06-11-2018 08:51 AM
RE: HP-41 Complex Determinants w/ SandMatrix and 41Z - Valentin Albillo - 06-11-2018, 11:09 PM
RE: HP-41 Complex Determinants w/ SandMatrix and 41Z - Ángel Martin - 06-12-2018, 04:57 AM
RE: HP-41 Complex Determinants w/ SandMatrix and 41Z - Valentin Albillo - 06-12-2018, 10:41 PM
RE: HP-41 Complex Determinants w/ SandMatrix and 41Z - J-F Garnier - 06-13-2018, 07:19 AM
RE: HP-41 Complex Determinants w/ SandMatrix and 41Z - Valentin Albillo - 06-13-2018, 10:15 AM
|
User(s) browsing this thread: 1 Guest(s)