1 | initial version |
In many cases the following works:
A=matrix(SR,[[1,2],[2,1]])
D,P=A.eigenmatrix_right()
n=var('n')
An=P*matrix(SR,[[D[0,0]^n,0],[0,D[1,1]^n]])*P.inverse()
An
Here one obtains An as follows:
[1/2*3^n + 1/2*(-1)^n 1/2*3^n - 1/2*(-1)^n]
[1/2*3^n - 1/2*(-1)^n 1/2*3^n + 1/2*(-1)^n].
It does not work if the given matrix is not similar to a diagonal matrix.