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
Post Reply 


Messages In This Thread
Applying a function to a matrix (hp-50g) - Juan14 - 06-13-2020 03:22 PM



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