TITLE: How to calculate square matrix to power n?
QUESTION [18 upvotes]: I have a matrix of non-negative numbers, say $A$.
(1) How do we calculate $A^n$?
(2) How can we calculate $A^n$ using usual matrix exponential trick to do it fast ?
Edit 1
Also theres another property of matrix A that its diagonals consists always of 0 & other elements either 0 or 1. 
Can we do this just by involving matrix multiplication ?

REPLY [2 votes]: You may use Cayley-Hamilton Theorem which states every matrix satisfies its characteristic polynomial. 
Suppose you have a $k\times k$ matrix $A$.
In order to find $A^n$  for a large n, you divide $x^n$ by $P(x)$, the characteristic polynomial to get a remainder $R(x)$ which has degree less than $k$. 
Note that $ A^n = P(A)Q(A)+R(A) = R(A)$  where R(A) is easy to find. 
For example if $n=100$ and $k=3$ then $R(x)$ is a polynomial of second degree.