Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If we want to compute the nth Fibonacci number we just power the matrix $M = \left[\begin{array}{cc} 1 & 1 \\ 1 & 0 \end{array}\right]$ $n$ times and we get $M =\left[ \begin{array}{cc} F_{n+1} & F_n \\ F_n & F_{n-1} \end{array}\right]$ But, How should be the elements arranged when I want to find the $n$th term of the fibonnaci series whose starting elements are $a$ and $b$?

share|cite|improve this question
up vote 4 down vote accepted

If $a_{n} = a_{n-1} + a_{n-2}$, then $$ {\begin{bmatrix} 1 & 1 \\ 1 & 0 \\ \end{bmatrix}}^n \begin{bmatrix} a_1 \\ a_0 \\ \end{bmatrix} = \begin{bmatrix} a_{n+1} \\ a_n \end{bmatrix} $$ for any $a_0, a_1$. Any linear recurrence relation can be solved using matrix exponentiation, e.g., $a_{n}=a_{n-1}-3a_{n-3}+5a_{n-5}-7$. See this blog post: Recurrence relation and matrix exponentiation.

share|cite|improve this answer

If you have a sequence, say $G_{-1} = a, G_0 = b$, and $G_{n+1} = G_{n} + G_{n-1}$, note that $$\left[\begin{array}{cc} 1 & 1 \\ 1 & 0 \end{array}\right]\cdot\left[\begin{array}{c} G_n \\ G_{n-1} \end{array}\right] = \left[\begin{array}{c} G_n + G_{n-1} \\ G_n \end{array}\right] = \left[\begin{array}{c} G_{n+1} \\ G_n \end{array}\right].$$

Then it isn't too hard to show that $$\left[\begin{array}{cc} 1 & 1 \\ 1 & 0 \end{array}\right]^n\cdot\left[\begin{array}{c} b \\ a \end{array}\right] = \left[\begin{array}{c} G_{n} \\ G_{n-1} \end{array}\right].$$

share|cite|improve this answer

Just multiply your power matrix by the vector $[a,b]$ and you will get the $n+1$th and $n$th terms of your sequence as the resultant vector.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.