What a recurrence relation is
Before you start: you should be able to solve a quadratic equation. Closed forms are often proved by mathematical induction.
A recurrence relation gives each term of a sequence using earlier terms. Together with enough initial conditions, it fixes the whole sequence. Solving it means finding a closed form: a formula for \(a_n\) in terms of \(n\) alone.
| Situation | Recurrence | Closed form |
|---|---|---|
| Fibonacci numbers | \(F_n = F_{n-1} + F_{n-2}\), \(F_0 = 0, F_1 = 1\) | \(\dfrac{\varphi^n - \psi^n}{\sqrt 5}\) |
| Tower of Hanoi (moves for \(n\) discs) | \(H_n = 2H_{n-1} + 1\), \(H_1 = 1\) | \(2^n - 1\) |
| \(P\) rupees at \(i\%\) a year, compounded yearly | \(A_n = \left(1 + \tfrac{i}{100}\right)A_{n-1}\), \(A_0 = P\) | \(P\left(1 + \tfrac{i}{100}\right)^n\) |
Here \(\varphi = \dfrac{1 + \sqrt 5}{2}\) and \(\psi = \dfrac{1 - \sqrt 5}{2}\). Modelling is half the work in exam questions: you decide what \(a_n\) counts, then ask how a problem of size \(n\) breaks into smaller ones. For the Tower of Hanoi, move the top \(n - 1\) discs to the spare peg (\(H_{n-1}\) moves), move the largest disc (1 move), then put the \(n - 1\) discs back on top (\(H_{n-1}\) moves).
Linear homogeneous recurrences
A recurrence like \(a_n = c_1 a_{n-1} + c_2 a_{n-2}\), with constants \(c_1, c_2\) and nothing else added, is linear homogeneous with constant coefficients, of order 2.
For \(a_n = c_1 a_{n-1} + c_2 a_{n-2}\), solve the characteristic equation \[r^2 - c_1 r - c_2 = 0\]
Distinct roots \(r_1 \ne r_2\)
\(a_n = A\,r_1^{\,n} + B\,r_2^{\,n}\)
Repeated root \(r\)
\(a_n = (A + Bn)\,r^n\)
Find \(A\) and \(B\) from the initial conditions.
Why it works. Try \(a_n = r^n\). Then \(r^n = c_1 r^{n-1} + c_2 r^{n-2}\); divide by \(r^{n-2}\) and you get the characteristic equation. So each root gives a solution, and because the recurrence is linear, any combination \(A r_1^n + B r_2^n\) is also a solution. With a repeated root you get only one \(r^n\), and it turns out \(n r^n\) works too, which supplies the second constant.
The same idea works for any order: a root \(r\) repeated \(m\) times contributes \((A_0 + A_1 n + \cdots + A_{m-1} n^{m-1})\,r^n\).
- Write the characteristic equation by replacing \(a_{n-k}\) with \(r^{\,2-k}\) (for order 2).
- Solve it and note whether the roots are distinct or repeated.
- Write the general solution with unknown constants.
- Use the initial conditions to get simultaneous equations for the constants.
- Check one or two terms against the recurrence.
Non-homogeneous recurrences
Now something extra is added: \(a_n = c_1 a_{n-1} + c_2 a_{n-2} + f(n)\). The answer has two parts.
\[a_n = a_n^{(h)} + a_n^{(p)}\]
\(a_n^{(h)}\) is the general solution of the homogeneous part (drop \(f(n)\)). \(a_n^{(p)}\) is any one particular solution of the full recurrence. Apply the initial conditions to the sum, at the very end.
| \(f(n)\) | Trial particular solution |
|---|---|
| constant \(d\) | \(p\) (a constant) |
| polynomial of degree \(k\) | \(c_k n^k + \cdots + c_1 n + c_0\) |
| \(d\cdot s^n\) | \(P\,s^n\) |
The clash rule. If \(s\) is a root of the characteristic equation with multiplicity \(m\), multiply the trial by \(n^m\). For constants and polynomials, \(s = 1\): if 1 is a root, multiply by \(n\). Without this, the trial solves the homogeneous part and gives you an impossible equation like \(0 = 1\).
Generating functions in brief
A generating function packs a whole sequence into one power series: \(G(x) = \sum_{n \ge 0} a_n x^n\). A recurrence becomes an algebra equation for \(G(x)\), and partial fractions give the terms back. Take \(a_n = 2a_{n-1} + 1\) with \(a_0 = 0\).
- Multiply by \(x^n\) and add over \(n \ge 1\): \(G(x) - a_0 = 2x\,G(x) + \dfrac{x}{1 - x}\), using \(x + x^2 + \cdots = \dfrac{x}{1 - x}\).
- So \(G(x)(1 - 2x) = \dfrac{x}{1 - x}\), giving \(G(x) = \dfrac{x}{(1 - x)(1 - 2x)}\).
- Partial fractions: \(G(x) = \dfrac{1}{1 - 2x} - \dfrac{1}{1 - x} = \sum (2^n - 1)\,x^n\).
So \(a_n = 2^n - 1\), the Tower of Hanoi count again (with \(H_0 = 0\)). In exams, the characteristic equation is quicker for the standard types. Generating functions pay off in counting problems, where the same partial-fraction step reads off a formula for every term at once.
Solved examples
Example 1: Tower of Hanoi
EasySolve \(H_n = 2H_{n-1} + 1\) with \(H_1 = 1\). How many moves are needed for 10 discs?
- First terms: \(H_1 = 1,\ H_2 = 3,\ H_3 = 7,\ H_4 = 15\). Each is one less than a power of 2, so guess \(H_n = 2^n - 1\).
- Check the guess in the recurrence: \(2H_{n-1} + 1 = 2(2^{n-1} - 1) + 1 = 2^n - 1\). ✓ And \(H_1 = 2 - 1 = 1\). ✓
- For 10 discs: \(H_{10} = 2^{10} - 1 = 1023\).
Answer\(H_n = 2^n - 1\); 1023 moves for 10 discs
Example 2: Compound interest
Easy₹10,000 is invested at 8% a year, compounded yearly. Write a recurrence for the amount \(A_n\) after \(n\) years, solve it and find \(A_3\).
- Each year the amount grows by 8%: \(A_n = 1.08\,A_{n-1}\), with \(A_0 = 10000\).
- Unroll it: \(A_n = 1.08 \times 1.08 \times \cdots \times A_0 = 10000\,(1.08)^n\).
- \(A_3 = 10000 \times 1.259712 = 12597.12\).
Answer\(A_n = 10000\,(1.08)^n\); \(A_3 = ₹12{,}597.12\)
Example 3: Distinct roots
MediumSolve \(a_n = 5a_{n-1} - 6a_{n-2}\) with \(a_0 = 1,\ a_1 = 4\).
- Characteristic equation: \(r^2 - 5r + 6 = 0\), so \((r - 2)(r - 3) = 0\) and \(r = 2, 3\).
- General solution: \(a_n = A\cdot 2^n + B\cdot 3^n\).
- \(n = 0\): \(A + B = 1\). \(n = 1\): \(2A + 3B = 4\). Subtracting twice the first: \(B = 2\), so \(A = -1\).
- Check: the recurrence gives \(a_2 = 5(4) - 6(1) = 14\); the formula gives \(2\cdot 9 - 4 = 14\). ✓
Answer\(a_n = 2\cdot 3^n - 2^n\)
Example 4: Fibonacci closed form
MediumFind a closed form for \(F_n = F_{n-1} + F_{n-2}\), \(F_0 = 0,\ F_1 = 1\).
- Characteristic equation: \(r^2 - r - 1 = 0\), so \(r = \dfrac{1 \pm \sqrt 5}{2}\). Call these \(\varphi\) and \(\psi\).
- \(F_n = A\varphi^n + B\psi^n\). From \(F_0 = 0\): \(B = -A\).
- From \(F_1 = 1\): \(A(\varphi - \psi) = 1\). Since \(\varphi - \psi = \sqrt 5\), \(A = \dfrac{1}{\sqrt 5}\).
- Check \(n = 2\): \[\dfrac{\varphi^2 - \psi^2}{\sqrt 5} = \dfrac{(\varphi - \psi)(\varphi + \psi)}{\sqrt 5} = \varphi + \psi = 1 = F_2. \checkmark\]
Answer\[F_n = \dfrac{1}{\sqrt 5}\left[\left(\dfrac{1 + \sqrt 5}{2}\right)^n - \left(\dfrac{1 - \sqrt 5}{2}\right)^n\right]\]
Example 5: Repeated root
MediumSolve \(a_n = 6a_{n-1} - 9a_{n-2}\) with \(a_0 = 1,\ a_1 = 6\).
- Characteristic equation: \(r^2 - 6r + 9 = 0\), so \((r - 3)^2 = 0\): \(r = 3\) twice.
- General solution: \(a_n = (A + Bn)\,3^n\).
- \(n = 0\): \(A = 1\). \(n = 1\): \((1 + B)\cdot 3 = 6\), so \(B = 1\).
- Check: \(a_2 = 6(6) - 9(1) = 27\), and \((1 + 2)\cdot 9 = 27\). ✓
Answer\(a_n = (n + 1)\,3^n\)
Example 6: Constant added
MediumSolve \(a_n = 3a_{n-1} + 2\) with \(a_0 = 1\).
- Homogeneous part \(a_n = 3a_{n-1}\): \(a_n^{(h)} = A\cdot 3^n\).
- \(f(n) = 2\) is a constant and 1 is not a root, so try \(a_n^{(p)} = p\): \(p = 3p + 2\), giving \(p = -1\).
- So \(a_n = A\cdot 3^n - 1\). Now use \(a_0 = 1\): \(A - 1 = 1\), so \(A = 2\).
- Check: \(a_1 = 3(1) + 2 = 5\) and \(2\cdot 3 - 1 = 5\). ✓
Answer\(a_n = 2\cdot 3^n - 1\)
Example 7: Polynomial added
Exam levelSolve \(a_n = 2a_{n-1} + n\) with \(a_0 = 1\).
- Homogeneous part: \(a_n^{(h)} = A\cdot 2^n\).
- \(f(n) = n\) has degree 1, so try \(a_n^{(p)} = cn + d\). Substituting: \[cn + d = 2\big(c(n - 1) + d\big) + n = (2c + 1)n + (2d - 2c)\]
- Compare coefficients. Of \(n\): \(c = 2c + 1\), so \(c = -1\). Constants: \(d = 2d - 2c\), so \(d = 2c = -2\).
- So \(a_n = A\cdot 2^n - n - 2\). From \(a_0 = 1\): \(A - 2 = 1\), so \(A = 3\).
- Check: \(a_2 = 2a_1 + 2 = 2(3) + 2 = 8\), and \(3\cdot 4 - 2 - 2 = 8\). ✓
Answer\(a_n = 3\cdot 2^n - n - 2\)
Example 8: Exponential that clashes with a root
Exam levelSolve \(a_n = 5a_{n-1} - 6a_{n-2} + 2^n\) with \(a_0 = 2,\ a_1 = 4\).
- Homogeneous part, from Example 3: \(a_n^{(h)} = A\cdot 2^n + B\cdot 3^n\).
- \(f(n) = 2^n\), and 2 is a root (once). So the trial is \(a_n^{(p)} = Pn\cdot 2^n\), not \(P\cdot 2^n\).
- Substitute and divide by \(2^{n-2}\): \[4Pn = 10P(n - 1) - 6P(n - 2) + 4 = 4Pn + 2P + 4\]
- So \(2P + 4 = 0\), \(P = -2\), and \(a_n^{(p)} = -2n\cdot 2^n\).
- So \(a_n = A\cdot 2^n + B\cdot 3^n - 2n\cdot 2^n\).
- \(n = 0\): \(A + B = 2\). \(n = 1\): \(2A + 3B - 4 = 4\), so \(2A + 3B = 8\).
- Solving: \(B = 4\), \(A = -2\). Then \(a_n = 4\cdot 3^n - 2\cdot 2^n - 2n\cdot 2^n\).
- The last two terms combine: \(-(2 + 2n)\,2^n = -(n + 1)\,2^{n+1}\).
- Check: \(a_2 = 5(4) - 6(2) + 4 = 12\), and \(36 - 3\cdot 8 = 12\). ✓
Answer\(a_n = 4\cdot 3^n - (n + 1)\,2^{n+1}\)
Always check your closed form against \(a_2\) (and \(a_3\) if you have time) computed straight from the recurrence. It takes thirty seconds and catches nearly every sign slip in the constants. If the check fails, look first at the trial solution and at whether you applied the initial conditions to the full answer.
Common mistakes
1. Fitting the initial conditions before adding the particular solution
In Example 6, fitting \(a_0 = 1\) to \(A\cdot 3^n\) alone gives \(A = 1\) and the wrong answer \(3^n - 1\). The constants belong to the full solution \(A\cdot 3^n - 1\), which gives \(A = 2\).
2. Writing \(A r^n + B r^n\) for a repeated root
\(A r^n + B r^n = (A + B) r^n\) has really only one constant, so it can't fit two initial conditions. The correct form is \((A + Bn)\,r^n\).
3. Ignoring the clash rule
For \(a_n = 2a_{n-1} + 2^n\), trying \(P\cdot 2^n\) gives \(P = P + 1\), which is impossible. Since 2 is a root, try \(Pn\cdot 2^n\): \(Pn = P(n - 1) + 1\), so \(P = 1\) and \(a_n^{(p)} = n\cdot 2^n\).
Practice questions
Try each one on paper before you open the answer.
Q1Solve \(a_n = 4a_{n-1}\) with \(a_0 = 3\).
Each term is 4 times the last: \(a_n = 3\cdot 4^n\).
Q2Solve \(a_n = a_{n-1} + 6a_{n-2}\) with \(a_0 = 3,\ a_1 = 4\).
\(r^2 - r - 6 = 0\) gives \(r = 3, -2\). \(A + B = 3\) and \(3A - 2B = 4\) give \(A = 2,\ B = 1\). So \(a_n = 2\cdot 3^n + (-2)^n\).
Q3Solve \(a_n = 4a_{n-1} - 4a_{n-2}\) with \(a_0 = 1,\ a_1 = 6\).
\((r - 2)^2 = 0\), so \(a_n = (A + Bn)2^n\). \(A = 1\) and \(2(1 + B) = 6\) give \(B = 2\). So \(a_n = (1 + 2n)\,2^n\).
Q4Solve \(a_n = a_{n-1} + 3\) with \(a_0 = 2\).
The characteristic root is 1, and \(f(n) = 3\) is a constant, so try \(pn\): \(pn = p(n - 1) + 3\) gives \(p = 3\). Then \(a_n = A + 3n\) and \(A = 2\): \(a_n = 3n + 2\).
Q5Solve \(a_n = 2a_{n-1} + 3^n\) with \(a_0 = 1\).
Try \(P\cdot 3^n\): \(3P = 2P + 3\), so \(P = 3\) and \(a_n^{(p)} = 3^{n+1}\). Then \(a_n = A\cdot 2^n + 3^{n+1}\) with \(A + 3 = 1\), so \(a_n = 3^{n+1} - 2^{n+1}\).
Q6Let \(b_n\) be the number of binary strings of length \(n\) with no two consecutive 1s. Find a recurrence and \(b_5\).
A good string ends in 0 (any good string of length \(n - 1\), then 0) or in 01 (any good string of length \(n - 2\), then 01). So \(b_n = b_{n-1} + b_{n-2}\) with \(b_1 = 2,\ b_2 = 3\). Then \(b_3 = 5,\ b_4 = 8,\ b_5 = 13\).
Bring it to a free demo class and work through it with Vipul Sir. Book on WhatsApp.
Frequently asked questions
What is a recurrence relation?
An equation that gives each term of a sequence from earlier terms, such as \(a_n = a_{n-1} + a_{n-2}\). With initial conditions it determines the whole sequence.
What is the characteristic equation of a recurrence?
For \(a_n = c_1 a_{n-1} + c_2 a_{n-2}\) it is \(r^2 - c_1 r - c_2 = 0\). You get it by trying \(a_n = r^n\). Its roots give the form of the general solution.
What if the characteristic equation has repeated roots?
A root \(r\) repeated twice gives \((A + Bn)\,r^n\). Repeated three times gives \((A + Bn + Cn^2)\,r^n\), and so on.
How do I find the particular solution?
Guess a form that looks like \(f(n)\): a constant for a constant, a polynomial of the same degree for a polynomial, \(P s^n\) for \(s^n\). If that form already solves the homogeneous part, multiply it by \(n\) (or \(n^m\) for a root of multiplicity \(m\)).