(49G) Function of a Matrix
|
05-05-2015, 03:47 PM
(This post was last modified: 11-01-2017 11:22 AM by Gerald H.)
Post: #1
|
|||
|
|||
(49G) Function of a Matrix
MFUN applies a function to a square matrix, calculator should be in approx & complex modes. For example, to find the natural log of matrix
M1=[[ -9. 0. -1. -4. ] [ 4. 9. 3. 3. ] [ 0. 4. -9. 9. ] [ 5. -1. -6. -4. ]] place M1 on stack level Y & 'LN(X)' on stack level X. MFUN returns the complex matrix M2=[[ (2.17927367373,1.99350072846) (-.185449038469,-.25062812471) (.12978172209,1.13653167793) (-1.21072226166,-.24561453301) ] [ (-.349990278973,-.725022350755) (2.17006519946,9.11517059164E-2) (.316994726521,-.413348667032) (-8.29926914019E-3,8.93282974816E-2) ] [ (.499972969813,1.87320392796) (.360844076572,-.235504096367) (1.81399293871,1.06794824449) (2.26427803714,-.230793047339) ] [ (1.5738586231,8.93453089839E-2) (.311847366461,-1.12327258886E-2) (-1.58567642989,5.09374150115E-2) (2.97368489567,-.011008025242) ]] to stack level X. As a check, you could then put 'e^X' on the stack & actuate MFUN again, to return [[ (-8.99999999989,-1.62595437076E-10) (-7.789692811E-12,2.87950512152E-11) (-.999999999977,-1.80997814311E-10) (-3.99999999999,-1.76112719874E-11) ] [ (3.99999999998,4.21474277251E-11) (9.00000000017,7.44661562123E-11) (2.99999999996,3.96498859739E-11) (3.00000000004,1.34469661894E-12) ] [ (2.98413096713E-11,-1.53814112532E-10) (3.99999999998,4.04329178333E-11) (-8.99999999998,-1.19988781132E-10) (8.99999999994,1.82967287016E-10) ] [ (4.99999999998,6.94233268647E-11) (-1.00000000004,6.827569037E-12) (-5.99999999997,-5.4121217567E-11) (-4.00000000003,1.19154531002E-10) ]] where the imaginary parts are v small, so RE 0 RND looks more like the original M1. I am sure the programme has enormous inefficiencies & would welcome improvements. TI fans - the TI-92 does this out of the box, just use LN(M1). Code: :: |
|||
05-15-2015, 03:09 PM
(This post was last modified: 11-01-2017 11:23 AM by Gerald H.)
Post: #2
|
|||
|
|||
RE: HP 49G: Function of a Matrix
Here a second attempt, shorter & faster.
Input is a square matrix & a programme, eg [Matrix] << LN >> Code: :: |
|||
10-31-2017, 05:16 PM
(This post was last modified: 10-31-2017 05:31 PM by Gilles59.)
Post: #3
|
|||
|
|||
RE: (49G) Function of a Matrix
Hi Gerald
I think you can do this with the integrated DIAGMAP function. With your example : Code: [[ -9 0 -1 -4 ] takes ~11,6s in approx mode on a 50g (i dont test with the 49g) Then : Code: 'EXP(X)' DIAGMAP XNUM |
|||
10-31-2017, 10:04 PM
Post: #4
|
|||
|
|||
RE: (49G) Function of a Matrix
Well done, Gilles.
I've never used nor heard of DIAGMAP, how ignorant I am & how good a device the 50g is. My programme above requires 6.7s to transform the example matrix, so remains of some use. |
|||
10-31-2017, 10:15 PM
Post: #5
|
|||
|
|||
RE: (49G) Function of a Matrix
If you try DIAGMAP with a your matrix * 1. &
<< LN >> the time comes down to 6.7s. |
|||
10-31-2017, 11:03 PM
(This post was last modified: 10-31-2017 11:05 PM by Gilles59.)
Post: #6
|
|||
|
|||
RE: (49G) Function of a Matrix
(10-31-2017 10:15 PM)Gerald H Wrote: If you try DIAGMAP with << LN >> Interesting... And no need of XNUM in this case! But the precision is less. Curious. It seems that for example 'LN(X)' syntax use partially a symbolic calculation (so need an XNUM). << LN >> is full numerical |
|||
11-01-2017, 01:19 PM
(This post was last modified: 11-01-2017 01:20 PM by Gerald H.)
Post: #7
|
|||
|
|||
RE: (49G) Function of a Matrix
I shall use the programme below in future as I only require numerical answers. The programme also has the advantage of returning LASTARG if required.
FPTR 7 134 is internal DIAGMAP FPTR 7 1DC is internal PUSH FPTR 7 1DD is internal POP All three addresses are the same in OS 1.19-6 & 2.10-8. Size: 54. CkSum: # D173h Code: :: |
|||
11-01-2017, 06:06 PM
(This post was last modified: 11-01-2017 06:08 PM by pier4r.)
Post: #8
|
|||
|
|||
RE: (49G) Function of a Matrix
(10-31-2017 10:04 PM)Gerald H Wrote: I've never used nor heard of DIAGMAP, how ignorant I am & how good a device the 50g is. I agree with this a lot (and thanks Gilles for sharing!). I estimate that I know the 50g way less than Gerald H, so I wonder how many years of problems I should solve before having a grasp of it. PS: and thanks Gerald H to share your solutions, they provide nice inputs. I wish people would share their work often (I say this because in my experience many people don't share their work unless they know it is really good for many and that is a pity. See Gauss and his works, or Riemann. The same applies to small but potentially interesting works like little programs.) Wikis are great, Contribute :) |
|||
11-01-2017, 06:27 PM
Post: #9
|
|||
|
|||
RE: (49G) Function of a Matrix
I agree with you wholeheartedly, pier4r.
Who knows what gems of programmes are never published. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)