Matrix powers for a diagonalizable matrix with two eigenvalues (source code)

= Matrix powers for a diagonalizable matrix with two eigenvalues
{title2=$A^n=\frac{r^n-s^n}{r-s}A+\frac{rs^n-sr^n}{r-s}I$}

If a <diagonalizable matrix> has distinct <eigenvalues> $r,s$, its <spectral projections of a diagonalizable matrix> are $(A-sI)/(r-s)$ and $(rI-A)/(r-s)$. Raising the diagonal form to a nonnegative integer power gives the displayed formula. Equivalently, interpolate the scalar function $t^n$ by a degree-one polynomial at $r,s$, then apply it to $A$. The <diagonalizability> assumption matters: knowledge of two eigenvalues alone does not exclude nontrivial <Jordan blocks>.