Post Reply 
(DM42) Matrix exponential
08-12-2023, 09:27 AM
Post: #3
RE: (DM42) Matrix exponential
Hi Gil

Thanks for your interest.

This method for calculation the matrix exponential with power series expansion is a summation of many terms until convergence, not only 3 first terms.
In addition there is a significant risk of overflow in intermediate terms which can be much larger than the converged results.
Thus the halving calculations in lines 04 to 17, and repeated squaring (by matrix multiplication) lines 58 to 63 of matrix after convergence is achieved.

DM42 and Free42 allows for numbers range up to about +/-1E6145, HP50g to about +/-1E499.
Unfortunately I am not able catch overflow error on the DM42 for matrix multiplication (not sure whats happening). I can only get it for element-wise operations, and have updated the program with a final test so overflows are likely catched when flag 24 is cleared.
The update is
63 LBL 04
64 FNRM
65 LAST
66 RTN
67 END
In addition I will add instructions that for the DM42 or Free42 flag 24 should be cleared to catch out of range errors.

On the HP50G:
if you are writing a user-rpl program, be sure to set system flag -21 "Overflow --> error" and clear system flag -22 "Infinite --> error". There is also a HPGCC2 implementation for matrix exponential (probably more accurate and 50-100 times faster than any simple user-rpl implementation) at https://www.hpcalc.org/hp49/math/numeric/utilgcc.zip
If you are willing to do a rom update to enable HPGCC3 programs, I have an even faster update. Send me a message if that is interesting.

For very simple testing, you can use a square matrix with entries only at the diagonal, then (and only then) the matrix exponential is equal to elementwise exponention of diagonal elements.

For testing on HP50G, you can e.g. use the EIG function on (symmetric) matrix on the HP50G to diagonalize the matrix. See e.g. Wikipedia on matrix exponential for limitations and how to do that.



Best regards
Gjermund
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: (DM42) Matrix exponential - Gil - 08-11-2023, 11:46 PM
RE: (DM42) Matrix exponential - Gjermund Skailand - 08-12-2023 09:27 AM
RE: (DM42) Matrix exponential - Gil - 08-12-2023, 10:01 AM
RE: (DM42) Matrix exponential - Gil - 08-12-2023, 08:26 PM
RE: (DM42) Matrix exponential - Gil - 08-12-2023, 08:55 PM
RE: (DM42) Matrix exponential - Gil - 08-13-2023, 10:51 AM
RE: (DM42) Matrix exponential - Gil - 08-13-2023, 09:46 PM
RE: (DM42) Matrix exponential - Gil - 08-15-2023, 11:42 PM
RE: (DM42) Matrix exponential - John Keith - 08-16-2023, 12:01 PM
RE: (DM42) Matrix exponential - Gil - 08-16-2023, 12:45 PM
RE: (DM42) Matrix exponential - Werner - 08-23-2023, 07:16 AM
RE: (DM42) Matrix exponential - John Keith - 08-27-2023, 04:46 PM
RE: (DM42) Matrix exponential - Gil - 08-23-2023, 09:09 AM
RE: (DM42) Matrix exponential - Werner - 08-24-2023, 01:14 PM
RE: (DM42) Matrix exponential - Gil - 08-28-2023, 08:57 AM



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