Matrix Exponentiation

Let's call our matrix (1110)\begin{pmatrix} 1 & 1 \\ 1 & 0 \\ \end{pmatrix} that represents a single iteration of the Fibonacci recurrence MM. What can we do now that we have MM as a matrix?

Well, let's start with our initial values V=(10)V = \begin{pmatrix}1 \\ 0\end{pmatrix}. We have that MV=(21)MV = \begin{pmatrix}2 \\ 1\end{pmatrix}

All is as expected: we've moved along to the next value of the Fibonacci sequence.1 Doing it more, we get

M(MV)=(32)M(M(MV))=(53)M(M(M(MV)))=(85) \begin{aligned} M(MV) &= \begin{pmatrix}3 \\ 2\end{pmatrix} \\ M(M(MV)) &= \begin{pmatrix}5 \\ 3\end{pmatrix} \\ M(M(M(MV))) &= \begin{pmatrix}8 \\ 5\end{pmatrix} \\ \end{aligned}

In general, we seem to have that

MnV=(F(n+1)F(n)) M^n V = \begin{pmatrix} F(n + 1) \\ F(n) \end{pmatrix}

(Remember, order matters but we can remove the parentheses: matrix multiplication is associative but not commutative.)

So now we have a new question: how can we compute MnM^n efficiently?


  1. If you're new to matrices, try doing these calculations yourself and verifying my work.

Matrix Exponentiation

Let's call our matrix (1110)\begin{pmatrix} 1 & 1 \\ 1 & 0 \\ \end{pmatrix} that represents a single iteration of the Fibonacci recurrence MM. What can we do now that we have MM as a matrix?

Well, let's start with our initial values V=(10)V = \begin{pmatrix}1 \\ 0\end{pmatrix}. We have that MV=(21)MV = \begin{pmatrix}2 \\ 1\end{pmatrix}

All is as expected: we've moved along to the next value of the Fibonacci sequence.1 Doing it more, we get

M(MV)=(32)M(M(MV))=(53)M(M(M(MV)))=(85) \begin{aligned} M(MV) &= \begin{pmatrix}3 \\ 2\end{pmatrix} \\ M(M(MV)) &= \begin{pmatrix}5 \\ 3\end{pmatrix} \\ M(M(M(MV))) &= \begin{pmatrix}8 \\ 5\end{pmatrix} \\ \end{aligned}

In general, we seem to have that

MnV=(F(n+1)F(n)) M^n V = \begin{pmatrix} F(n + 1) \\ F(n) \end{pmatrix}

(Remember, order matters but we can remove the parentheses: matrix multiplication is associative but not commutative.)

So now we have a new question: how can we compute MnM^n efficiently?


  1. If you're new to matrices, try doing these calculations yourself and verifying my work.