Tutorials › Linear Algebra › The Fibonacci Sequence from Its Companion Matrix

Applications of Diagonalization · Tutorial 586 of 1000

The Fibonacci Sequence from Its Companion Matrix

Use a companion matrix and its eigenvectors to derive and verify a closed formula for every Fibonacci number.

Intermediate 9 min read

What You'll Learn

  • Encode consecutive Fibonacci numbers as a state vector and derive its companion matrix.
  • Find the companion matrix’s eigenvalues and eigenvectors.
  • Diagonalize the matrix and use the initial state to derive the closed formula.
  • Check exact Fibonacci values using both matrix iteration and the formula.
  • Recognize and correct common indexing and eigenvector errors.

From a Recurrence to a Matrix

The Fibonacci sequence is generated by a rule that uses the two preceding terms. A matrix can encode that rule in a single multiplication, so repeated multiplication produces successive pairs of terms. Diagonalizing the matrix then turns those repeated multiplications into powers of its eigenvalues. This gives an explicit formula for the \(n\)th term rather than a step-by-step recurrence.

We use the indexing \(F_0=0\), \(F_1=1\), and \(F_{n+2}=F_{n+1}+F_n\) for every integer \(n\geq 0\). All scalars and matrices in this tutorial are real. The order of the two entries in the state vector matters: define \(\mathbf{x}_n\) to list the later term first.

Definition: The Fibonacci sequence is the sequence \((F_n)_{n\geq 0}\) determined by \(F_0=0\), \(F_1=1\), and the recurrence \(F_{n+2}=F_{n+1}+F_n\) for \(n\geq0\). Its state vector is \(\mathbf{x}_n=\begin{bmatrix}F_{n+1}\\F_n\end{bmatrix}\).

Using the recurrence, the next state is \(\mathbf{x}_{n+1}=\begin{bmatrix}F_{n+2}\\F_{n+1}\end{bmatrix}=\begin{bmatrix}F_{n+1}+F_n\\F_{n+1}\end{bmatrix}\). The coefficients in these two entries give the companion matrix \(\mathbf{C}\):

$$ \mathbf{x}_{n+1}=\mathbf{C}\mathbf{x}_n, \qquad \mathbf{C}=\begin{bmatrix}1&1\\1&0\end{bmatrix}, \qquad \mathbf{x}_0=\begin{bmatrix}1\\0\end{bmatrix}. $$

In particular, \(\mathbf{x}_n=\mathbf{C}^n\mathbf{x}_0\). This follows by applying the one-step rule repeatedly; the exponent \(n\) counts the number of updates from \(\mathbf{x}_0\). The first entry of \(\mathbf{x}_n\) is \(F_{n+1}\), while the second is \(F_n\).

Proposition: For every integer \(n\geq0\), the Fibonacci state is \(\mathbf{x}_n=\mathbf{C}^n\mathbf{x}_0\), where \(\mathbf{C}=\begin{bmatrix}1&1\\1&0\end{bmatrix}\) and \(\mathbf{x}_0=\begin{bmatrix}1\\0\end{bmatrix}\).

Proof. At \(n=0\), \(\mathbf{C}^0\mathbf{x}_0=\mathbf{I}_2\mathbf{x}_0=\mathbf{x}_0=\begin{bmatrix}F_1\\F_0\end{bmatrix}\), as required. Suppose for some \(n\geq0\) that \(\mathbf{x}_n=\begin{bmatrix}F_{n+1}\\F_n\end{bmatrix}\). Then \(\mathbf{C}\mathbf{x}_n=\begin{bmatrix}F_{n+1}+F_n\\F_{n+1}\end{bmatrix}=\begin{bmatrix}F_{n+2}\\F_{n+1}\end{bmatrix}=\mathbf{x}_{n+1}\). Thus, if \(\mathbf{x}_n=\mathbf{C}^n\mathbf{x}_0\), then \(\mathbf{x}_{n+1}=\mathbf{C}^{n+1}\mathbf{x}_0\). Induction proves the formula for all \(n\geq0\). \(\square\)

Eigenvalues and Eigenvectors of the Companion Matrix

To diagonalize \(\mathbf{C}\), first solve the eigenvector equation \(\mathbf{C}\mathbf{v}=\lambda\mathbf{v}\) for a nonzero vector \(\mathbf{v}\). For a vector of the form \(\begin{bmatrix}\lambda\\1\end{bmatrix}\), direct multiplication gives \(\mathbf{C}\begin{bmatrix}\lambda\\1\end{bmatrix}=\begin{bmatrix}\lambda+1\\\lambda\end{bmatrix}\). This equals \(\lambda\begin{bmatrix}\lambda\\1\end{bmatrix}\) precisely when \(\lambda+1=\lambda^2\). The resulting equation \(\lambda^2-\lambda-1=0\) has two distinct real roots.

$$ \phi=\frac{1+\sqrt{5}}{2}, \qquad \psi=\frac{1-\sqrt{5}}{2}. $$

Both roots satisfy \(\lambda^2=\lambda+1\), so each produces an eigenvector. Put these eigenvectors into the columns of \(\mathbf{P}\). The two columns are independent because the determinant of \(\mathbf{P}\) is \(\phi-\psi=\sqrt{5}\ne0\); hence \(\mathbf{P}\) is invertible. The computations below give a diagonalization without requiring a general diagonalizability criterion.

$$ \mathbf{P}= \begin{bmatrix}\phi&\psi\\1&1\end{bmatrix}, \qquad \mathbf{D}= \begin{bmatrix}\phi&0\\0&\psi\end{bmatrix}, \qquad \mathbf{C}\mathbf{P}=\mathbf{P}\mathbf{D}. $$

Since \(\mathbf{P}\) is invertible, multiplying the last identity on the right by \(\mathbf{P}^{-1}\) gives \(\mathbf{C}=\mathbf{P}\mathbf{D}\mathbf{P}^{-1}\). Repeating this factorization yields \(\mathbf{C}^n=\mathbf{P}\mathbf{D}^n\mathbf{P}^{-1}\) for every \(n\geq0\). For \(n=0\), both sides equal \(\mathbf{I}_2\); for positive \(n\), adjacent factors \(\mathbf{P}^{-1}\mathbf{P}\) cancel, leaving \(\mathbf{P}\mathbf{D}^n\mathbf{P}^{-1}\).

Deriving the Closed Formula

The inverse of \(\mathbf{P}\) is particularly simple because its determinant is \(\sqrt{5}\):

$$ \mathbf{P}^{-1} = \frac{1}{\sqrt{5}} \begin{bmatrix}1&-\psi\\-1&\phi\end{bmatrix}. $$

Applying this inverse to the initial state, and then multiplying by the diagonal powers and by \(\mathbf{P}\), gives the full state in terms of \(\phi\) and \(\psi\).

$$ \begin{aligned} \mathbf{x}_n &=\mathbf{C}^n\mathbf{x}_0 =\mathbf{P}\mathbf{D}^n\mathbf{P}^{-1}\mathbf{x}_0\\ &=\frac{1}{\sqrt{5}}\mathbf{P} \begin{bmatrix}\phi^n&0\\0&\psi^n\end{bmatrix} \begin{bmatrix}1\\-1\end{bmatrix}\\ &=\frac{1}{\sqrt{5}} \left( \phi^n\begin{bmatrix}\phi\\1\end{bmatrix} -\psi^n\begin{bmatrix}\psi\\1\end{bmatrix} \right). \end{aligned} $$

The second coordinate of \(\mathbf{x}_n\) is \(F_n\), so the expression for that coordinate is the closed formula. It is valid starting at \(n=0\), not just for positive indices.

Theorem (Fibonacci closed formula): For every integer \(n\geq0\), \(F_n=\dfrac{\phi^n-\psi^n}{\sqrt{5}}\), where \(\phi=\dfrac{1+\sqrt{5}}{2}\) and \(\psi=\dfrac{1-\sqrt{5}}{2}\).

Proof. The diagonalization above gives \(\mathbf{x}_n=\dfrac{1}{\sqrt{5}}\left(\phi^n\begin{bmatrix}\phi\\1\end{bmatrix}-\psi^n\begin{bmatrix}\psi\\1\end{bmatrix}\right)\) for each \(n\geq0\). By definition, the second coordinate of \(\mathbf{x}_n\) is \(F_n\). Taking the second coordinate of the displayed vector therefore gives \(F_n=(\phi^n-\psi^n)/\sqrt{5}\), as claimed. The argument includes \(n=0\): the formula gives \((1-1)/\sqrt{5}=0=F_0\). \(\square\)

Worked Checks: Recurrence, Matrix, and Formula

Worked Example: Iterating the Matrix to Find \(F_4\)

Compute the first four matrix updates and use the state to identify \(F_4\). Starting from \(\mathbf{x}_0=\begin{bmatrix}1\\0\end{bmatrix}\), direct multiplication gives

$$ \mathbf{C}\mathbf{x}_0 = \begin{bmatrix}1&1\\1&0\end{bmatrix} \begin{bmatrix}1\\0\end{bmatrix} = \begin{bmatrix}1\\1\end{bmatrix} =\mathbf{x}_1, \qquad \mathbf{C}^2= \begin{bmatrix}2&1\\1&1\end{bmatrix}. $$

Squaring is not needed to continue: multiply each current state by \(\mathbf{C}\). The powers through the fourth update are

$$ \mathbf{C}^3= \begin{bmatrix}3&2\\2&1\end{bmatrix}, \qquad \mathbf{C}^4= \begin{bmatrix}5&3\\3&2\end{bmatrix}, \qquad \mathbf{x}_4=\mathbf{C}^4\mathbf{x}_0= \begin{bmatrix}5\\3\end{bmatrix}. $$

Thus \(F_4=3\). Check: the recurrence gives \(F_2=1+0=1\), \(F_3=1+1=2\), and \(F_4=2+1=3\), so the second coordinate of \(\mathbf{x}_4\) agrees with the recurrence. Also, multiplying the displayed matrix by the initial state selects its first column, \(\begin{bmatrix}5\\3\end{bmatrix}\), as stated.

Worked Example: Evaluating the Closed Formula at \(n=6\)

Use the closed formula to compute \(F_6\). The roots satisfy \(\phi^2=\phi+1\) and \(\psi^2=\psi+1\). Repeated use of these identities gives \(\phi^3=2+\sqrt{5}\) and \(\psi^3=2-\sqrt{5}\); squaring each expression gives \(\phi^6=9+4\sqrt{5}\) and \(\psi^6=9-4\sqrt{5}\). Therefore

$$ F_6 =\frac{\phi^6-\psi^6}{\sqrt{5}} =\frac{(9+4\sqrt{5})-(9-4\sqrt{5})}{\sqrt{5}} =\frac{8\sqrt{5}}{\sqrt{5}} =8. $$

Check: starting with \(F_0=0\) and \(F_1=1\), the recurrence gives \(F_2=1\), \(F_3=2\), \(F_4=3\), \(F_5=5\), and \(F_6=5+3=8\). The value from the formula agrees with the recurrence.

Worked Example: Checking \(F_9\) by Both Methods

Compute \(F_9\) by matrix iteration and compare with the closed formula. First, squaring \(\mathbf{C}^4\) from the previous example gives

$$ \mathbf{C}^8 = \begin{bmatrix}5&3\\3&2\end{bmatrix} \begin{bmatrix}5&3\\3&2\end{bmatrix} = \begin{bmatrix}34&21\\21&13\end{bmatrix}. $$

One more multiplication gives \(\mathbf{C}^9=\mathbf{C}^8\mathbf{C}=\begin{bmatrix}55&34\\34&21\end{bmatrix}\). Thus \(\mathbf{x}_9=\mathbf{C}^9\mathbf{x}_0=\begin{bmatrix}55\\34\end{bmatrix}\), so matrix iteration gives \(F_9=34\).

For the formula, using \(\phi^2=\phi+1\) repeatedly gives \(\phi^9=38+17\sqrt{5}\); because \(\psi=(1-\sqrt{5})/2\), the corresponding odd power is \(\psi^9=38-17\sqrt{5}\). Hence

$$ \frac{\phi^9-\psi^9}{\sqrt{5}} = \frac{(38+17\sqrt{5})-(38-17\sqrt{5})}{\sqrt{5}} =34. $$

Check: the recurrence gives \(F_7=13\), \(F_8=21\), and \(F_9=21+13=34\). This matches both the matrix calculation and the closed formula.

Common Pitfall: Keep the State Order Consistent

The companion matrix depends on how the state entries are ordered. With our convention, the state is \(\begin{bmatrix}F_{n+1}\\F_n\end{bmatrix}\), and the update matrix is \(\begin{bmatrix}1&1\\1&0\end{bmatrix}\). A wrong calculation is to use that same matrix with the reversed initial state \(\begin{bmatrix}F_0\\F_1\end{bmatrix}=\begin{bmatrix}0\\1\end{bmatrix}\):

$$ \begin{bmatrix}1&1\\1&0\end{bmatrix} \begin{bmatrix}0\\1\end{bmatrix} = \begin{bmatrix}1\\0\end{bmatrix}. $$

This result is not the next reversed-order state, which should be \(\begin{bmatrix}F_1\\F_2\end{bmatrix}=\begin{bmatrix}1\\1\end{bmatrix}\). The correction is to use the matching matrix for that order: if \(\mathbf{y}_n=\begin{bmatrix}F_n\\F_{n+1}\end{bmatrix}\), then \(\mathbf{y}_{n+1}=\begin{bmatrix}0&1\\1&1\end{bmatrix}\mathbf{y}_n\). Indeed, multiplying \(\begin{bmatrix}0&1\\1&1\end{bmatrix}\begin{bmatrix}0\\1\end{bmatrix}\) gives \(\begin{bmatrix}1\\1\end{bmatrix}\), as required. Either convention works, but the state, update matrix, and initial vector must all agree.

A second potential error is to assume that \(\begin{bmatrix}1\\\lambda\end{bmatrix}\) is an eigenvector of \(\mathbf{C}\) for an eigenvalue \(\lambda\). In fact, \(\mathbf{C}\begin{bmatrix}1\\\lambda\end{bmatrix}=\begin{bmatrix}1+\lambda\\1\end{bmatrix}\), which is generally not \(\lambda\begin{bmatrix}1\\\lambda\end{bmatrix}\). For the chosen matrix, the correct eigenvector is \(\begin{bmatrix}\lambda\\1\end{bmatrix}\); its eigenvector equation works because the root satisfies \(\lambda^2=\lambda+1\).

Why the Diagonalization Helps

The recurrence is an efficient way to generate terms one at a time, but it requires retaining earlier values. The matrix form organizes those values as a state, and diagonalization explains how the state changes after many updates: each eigenvector component is multiplied by a power of its eigenvalue. In this example the initial state contributes to both eigenvectors, and the second coordinate of their combined powers yields the Fibonacci formula. The formula is useful for understanding the sequence and for checking exact values; the recurrence remains convenient for computing a short list of consecutive terms.

Check Your Understanding

Use the state convention and calculations in the tutorial to answer the following questions.

  1. Write the state vector \(\mathbf{x}_2\) and verify it by multiplying \(\mathbf{C}^2\mathbf{x}_0\).
  2. Show directly that \(\begin{bmatrix}\phi\\1\end{bmatrix}\) is an eigenvector of \(\mathbf{C}\) with eigenvalue \(\phi\).
  3. Use the closed formula to calculate \(F_5\), keeping the radical arithmetic exact.
  4. Explain why \(\mathbf{P}\) is invertible by computing its determinant.
  5. If the state is instead \(\mathbf{y}_n=\begin{bmatrix}F_n\\F_{n+1}\end{bmatrix}\), write its initial vector and its matching update matrix.

Test yourself: Linear Algebra final exam practice

Ready to check what you know? Work a full-length practice final, then open the complete worked solutions.

Want all 1,114 practice problems?

This tutorial covers one topic. Calc Pass covers the full Calculus AB & BC curriculum (the core of Calculus I and II): full review, every practice question, and step-by-step solutions to each one.

QR code to download the Calc Pass app

Get the Calc Pass App

Scan to download and practice on the go, with instant scoring.

Calc Pass Volume 1: 1,114 Practice Questions book cover

Vol. 1: 1,114 Questions

The complete practice question bank, organized by AB & BC topic.

View on Amazon
Calc Pass Volume 2: Solutions Manual book cover

Vol. 2: Solutions Manual

Fully worked solutions to every question in Volume 1.

View on Amazon