Raising a matrix to a large power when the values are fractions (precision problem) I have a matrix $M$ where various elements may be in the form of $x/y$. If I use the decimal form of that number, I lose precision if I raise $M$ to a large power.
My question: is it possible to do two exponentiations? One for the numerator only, and then one for the denominator, and then somehow combine the results?
 A: I'd go like Shu: diagonalize first.
If you insist on raw computations, take $d$ a common multiple of all the denominators and put $A = d M$. Then A has only integer coefficients and $M^n = A^n /d^n$ with $d$ integer.
A: You want to transform the matrix to a nicer form, either diagonal or Jordan normal form.  The transformation is $M=PDP^{-1}$ for diagonal or $M=PJP^{-1}$  The nice thing is that powers of these are easy to compute:  $M^2=PDP^{-1}PDP^{-1}$ and the central $P$'s multiply to the identity, so $M^2=PD^2P^{-1}$.  Both diagonal and Jordan matrices are easy to raise to powers, and diagonal ones are easy to take roots of.  The Jordan matrices are sensitive to roundoff.  There are packages available for this, which are highly recommended because 1)why reinvent the wheel and 2)there are numeric pitfalls to avoid.
A: Here is the most general way of computing a power of a matrix.
If the eigenvalues $\lambda_1,..,\lambda_n$ of your matrix $A$ are distinct, you can diagonalize it to the form
$$A=PBP^{-1},\text{where }B=\begin{pmatrix}\lambda_1&0&\dots&0\\0&\lambda_2&\dots&0\\\dots\\0&\dots&0&\lambda_n\end{pmatrix}$$
It is easy to see that $A^m=(PBP^{-1})^m=P(B^m)P^{-1}$. Computing $B^m$ is easy,
$$B^m=\begin{pmatrix}\lambda_1^m&0&\dots&0\\0&\lambda_2^m&\dots&0\\\dots\\0&\dots&0&\lambda_n^m\end{pmatrix}$$
If you are not that lucky, you may not be able to diagonalize your matrix. The best you can do is make it into Jordan form, which is not important for you at this stage I guess.
