(38G) Applying a Function to a Matrix - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (/forum-10.html) +--- Forum: General Software Library (/forum-13.html) +--- Thread: (38G) Applying a Function to a Matrix (/thread-3845.html) |
(38G) Applying a Function to a Matrix - Gerald H - 05-15-2015 07:11 AM The programme MFUN applies a function to matrix M1, returning the answer in M3. The desired function should be stored in the programme FNC & take Ans as its argument. eg To find the natural log of M1 enter the programme FNC thus: FNC Code: LN(Ans): If M1 = [[.1,.2,.7] [.2,.5,.3] [.4,.6,.3]] MFUN returns M3= [[(-1.08299683723,1.64723871982),(1.31662026735,1.38974446983),(-1.53535482848E-2,-2.47915087845)] [(.421744560769,-3.15309862062E-2),(-1.25370018315,-2.66021027682E-2),(.692275221593,4.74552177599E-2)] [(.246905317147,-1.0105789431),(.787966638794,-.852606535171),(-.720910656896,1.52095603654)]] As a check if FNC is then changed to FNC e^(Ans) & M3 is stored in M1 MFUN returns [[(9.99999999991E-2,-5.63571200564E-13),(.2,-1.3919361913E-12),(.700000000001,4.22835444129E-13)] [(.2,1.16499952167E-13),(.500000000001,-2.33804747728E-13),(.300000000002,6.51270513835E-14)] [(.399999999999,2.35369027549E-13),(.600000000001,-4.06005700045E-13),(.300000000002,3.12707095374E-13)]] On inspection all the imaginary parts are near zero & real parts are near the original M1 values. Here the programme: MFUN Code: EIGENVV(M1)►L1: |