Post Reply 
Applying a function to a matrix (hp-50g)
06-13-2020, 03:22 PM
Post: #1
Applying a function to a matrix (hp-50g)
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 ]]
Find all posts by this user
Quote this message in a reply
06-13-2020, 08:14 PM (This post was last modified: 06-13-2020 08:41 PM by Simone Cerica.)
Post: #2
RE: Applying a function to a matrix (hp-50g)
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
Find all posts by this user
Quote this message in a reply
06-14-2020, 07:31 PM (This post was last modified: 06-14-2020 08:04 PM by Juan14.)
Post: #3
RE: Applying a function to a matrix (hp-50g)
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.
Find all posts by this user
Quote this message in a reply
06-16-2020, 06:18 AM
Post: #4
RE: Applying a function to a matrix (hp-50g)
… And also see matrix trigonometric functions https://en.wikipedia.org/wiki/Trigonomet...f_matrices , automatically calculated in the TI 86 or TI 89 Smile
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)