(40gs & 40G) 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: (40gs & 40G) Applying a Function to a Matrix (/thread-10557.html) |
(40gs & 40G) Applying a Function to a Matrix - Gerald H - 04-22-2018 08:39 PM The programme MFUN applies a function to matrix entered from the input line, returning the answer in Ans. The desired function should be stored in the programme FNC & take S1 as its argument. eg To find the natural log of a matrix enter the programme FNC thus: Code: FNC [[.1,.2,.7] [.2,.5,.3] [.4,.6,.3]] MFUN returns [[(-1.08299683723,1.64723871982),(1.31662026735,1.38974446983),(-.015353548285,-2.47915087845)],[(.421744560769,-3.15309862063E-2),(-1.25370018315,-2.66021027682E-2),(.692275221592,.04745521776)],[(.246905317147,-1.0105789431),(.787966638792,-.852606535171),(-.720910656897,1.52095603654)]] in Ans. As a check if FNC is then changed to FNC e^S1: MFUN returns [[(.1,-3.62115808644E-13),(.2,-9.29185821507E-13),(.7,4.83742749326E-13)],[(.200000000001,2.19158416549E-13),(.500000000001,-1.41370518606E-13),(.300000000002,-9.654916805E-14)],[(.400000000001,2.74516025436E-13),(.6,-5.57575448933E-13),(.300000000001,3.0309250954E-14)]] On inspection all the imaginary parts are near zero & real parts are near the original values. NB The values above are for 40gs, 40G may return slightly different values. Here the programme: Code: MFUN |