HP Forums

Full Version: Applying a function to a matrix (hp-50g)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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 ]]
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)' ]]
your ex.
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)' ]]
[[ 1 -1 ][ 0 2 ]] MATEXP --> [[ 'EXP(X)' '-(EXP(2*X)-EXP(X))' ][ 0 'EXP(2*X)' ]]


Best regards,
Simone
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.
… And also see matrix trigonometric functions https://en.wikipedia.org/wiki/Trigonomet...f_matrices , automatically calculated in the TI 86 or TI 89 Smile
Reference URL's