Applying a function to a matrix (hp-50g) - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: General Forum (/forum-4.html) +--- Thread: Applying a function to a matrix (hp-50g) (/thread-15184.html) |
Applying a function to a matrix (hp-50g) - Juan14 - 06-13-2020 03:22 PM If a matrix is diagonalizable, you can use eigendecomposition of a matrix ( A = QΛQ^(-1) ) then apply the function to each element of the diagonal in matrix Λ and assembling everything back. This program takes a matrix and a program with the function to apply and return the matrix with the function applied. « SWAP EGV @ Q in level 2 and diagonal of Λ (as a vector)in level 1 ROT MAP @ The function is applied to each eigenvalue OVER SIZE DIAG→ @ Get a diagonal matrix OVER INV @ Get the inverse of Q * * @ assemble the matrix with the function applied « EVAL » MAP @ Evaluate each element of the new matrix » 'AFM' |STO| Example: Find the square root of [[-5 6] [-9 10]] [[-5 6] -9 10] |ENTER| « √ » |ENTER| |VAR| |AFM| 1: [[ -1 2 ] [ -3 4 ]] RE: Applying a function to a matrix (hp-50g) - Simone Cerica - 06-13-2020 08:14 PM You can use DIAGMAP command, see HP 50g AUR http://www.hpcalc.org/details.php?id=7141 at page 3-58: ex. Code: [[ 1 1 ] [ 0 2 ]] 'EXP(X)' DIAGMAP --> [[ 'EXP(1)' '-EXP(1)+EXP(2)' ][ 0 'EXP(2)' ]] Code: [[ -5 6 ] [ -9 10 ]] '\v/X' DIAGMAP --> [[ '3*\v/1-\v/4*2' '-2*\v/1+\v/4*2' ] [ '3*\v/1-\v/4*3' '-2*\v/1+\v/4*3' ]] EXPAND --> [[ -1 2 ] [ -3 4 ]] When the matrix is not diagonalizable you can use this code: Code: \<< DUP SIZE OBJ\-> DROP2 XQ IDN RCLVX * SWAP - INV ILAP EXPAND \>> 'MATEXP' STO ex. Code: [[ 3 0 0 ][ 0 2 1 ][ 0 0 2 ]] MATEXP --> [[ 'EXP(3*X)' 0 0 ][ 0 'EXP(2*X)' 'X*EXP(2*X)' ][ 0 0 'EXP(2*X)' ]] Best regards, Simone RE: Applying a function to a matrix (hp-50g) - Juan14 - 06-14-2020 07:31 PM Very interesting, the user guide doesn't have any information about that command. I am going to take a look at it. Thank you for the information Simone Cerica. RE: Applying a function to a matrix (hp-50g) - Pekis - 06-16-2020 06:18 AM … And also see matrix trigonometric functions https://en.wikipedia.org/wiki/Trigonometric_functions_of_matrices , automatically calculated in the TI 86 or TI 89 |