Symbolic matrix power



 Example. Compute A^k, when A=matrix([2, 0, 0], [0, 2, 0], [-1, 0, 3])

 Diagonalization can be used to compute the powers of a matrix A
efficiently, provided the matrix is diagonalizable.
Suppose we have found matrix P  that
P^{-1}*A*P = D
is a diagonal matrix. Then,
A^k = P*D^k*P^{-1}.
(from http://en.wikipedia.org/wiki/Diagonalizable_matrix )

(%i1) load(diag)$
(%i2) A:matrix([2, 0, 0], [0, 2, 0], [-1, 0, 3])$
(%i3) P:ModeMatrix(A);
(%o3) matrix([1,0,0],[0,1,0],[1,0,1])
(%i4) D:dispJordan(jordan(A));
(%o4) matrix([2,0,0],[0,2,0],[0,0,3])
(%i5) P.D^k.invert(P);
(%o5) matrix([2^k,0,0],[0,2^k,0],[2^k-3^k,0,3^k])

best

Aleksas D