Discrete MathematicsRecursion and Recurrences4 of 4
Recursion and Recurrences · 4

Solving Linear Recurrences with the Characteristic Equation

When a recurrence rule builds each term from earlier ones, computing a far-off term like a99a_{99} step by step takes forever, so we need a method to turn the step-by-step rule into a direct formula for ana_n.

1

Hidden Pure Multiplier Sequences

Suppose we want a direct formula for the sequence built by

an\displaystyle a_n =an−1+2an−2(a0=2,  a1=1),\displaystyle = a_{n-1} + 2a_{n-2} \quad (a_0 = 2, \; a_1 = 1),

which starts 2,1,5,7,17,31,65,…2, 1, 5, 7, 17, 31, 65, \dots and hides its pattern until we test simpler starting pairs on the same rule.

Hidden Pure Multiplier Sequences
an=an−1+2an−2a_n = a_{n-1} + 2a_{n-2}
n\htmlClass{lc-mute}{n}
0\htmlClass{lc-mute}{0}
1\htmlClass{lc-mute}{1}
2\htmlClass{lc-mute}{2}
3\htmlClass{lc-mute}{3}
4\htmlClass{lc-mute}{4}
5\htmlClass{lc-mute}{5}
6\htmlClass{lc-mute}{6}
⋯\htmlClass{lc-mute}{\cdots}
97\htmlClass{lc-mute}{97}
98\htmlClass{lc-mute}{98}
99\htmlClass{lc-mute}{99}
ana_n
22
11
55
77
1717
3131
6565
…\dots
?{\htmlClass{lc-orange}{?}}
×2\htmlClass{lc-pink}{\times 2}

Running the rule from 1,2\blockA{1, 2} produces pure powers of 2\blockA{2}, and running it from 1,−1\blockB{1, -1} produces pure powers of −1\blockB{-1}. Adding those two pure multiplier sequences column by column gives our sequence at every step:

an\displaystyle a_n =2n+(−1)n\displaystyle = \blockA{2^n} + \blockB{(-1)^n}

Because the list starts at n=0n = 0, the 100th number is at step n=99n = 99, where plugging in n=99n = 99 jumps straight to a99a_{99} == 299+(−1)99\blockA{2^{99}} + \blockB{(-1)^{99}} == 299−1\blockA{2^{99}} \blockB{- 1}.

2

The Characteristic Equation

To find those pure multiplier sequences an=rna_n = r^n for any linear recurrence without guessing starting numbers, we plug rnr^n directly into the recurrence rule and solve for rr.

The Characteristic Equation
an=an−1+2an−2a_n = a_{n-1} + 2a_{n-2}
an=rna_n = r^n
11
rr
r2r^2
r3r^3
r4r^4
…\dots
×r\htmlClass{lc-mute}{\times r}
r=?r = {\htmlClass{lc-orange}{?}}
an−2a_{n-2}
an−1a_{n-1}
ana_n
rn−2r^{n-2}
rn−1r^{n-1}
rnr^n
=rn−2⋅1= \htmlClass{lc-orange}{r^{n-2}} \cdot 1
=rn−2⋅r= \htmlClass{lc-orange}{r^{n-2}} \cdot r
=rn−2⋅r2= \htmlClass{lc-orange}{r^{n-2}} \cdot r^2
÷ rn−2\div\, \htmlClass{lc-orange}{r^{n-2}}
11
rr
r2r^2
×r\htmlClass{lc-mute}{\times r}
×r\htmlClass{lc-mute}{\times r}
a0a_0
a1a_1
a2a_2
a3a_3
a4a_4
⋯\htmlClass{lc-green}{\cdots}

Plugging an=rna_n = r^n into an=an−1+2an−2a_n = a_{n-1} + 2a_{n-2} puts the earliest step rn−2\leftover{r^{n-2}} inside every term, so dividing by rn−2\leftover{r^{n-2}} clears nn completely:

rn=rn−1+2rn−2r2=r+2r2−r−2=0⏟characteristicequation  ⟹  (r−2)(r+1)=0  ⟹  r=2,  r=−1\displaystyle \begin{aligned} r^n &= r^{n-1} + 2r^{n-2} \\ r^2 &= r + 2 \\ \underbrace{r^2 - r - 2 = 0}_{\begin{gathered}\scriptstyle\text{characteristic} \\[-3pt] \scriptstyle\text{equation}\end{gathered}} &\implies \blockA{(r - 2)}\blockB{(r + 1)} = 0 \\ &\implies \blockA{r = 2}, \; \blockB{r = -1} \end{aligned}

Because a linear recurrence only scales and adds earlier terms, any combination of the building blocks 2n\blockA{2^n} and (−1)n\blockB{(-1)^n} also obeys the rule:

an\displaystyle a_n =A⋅2n+B⋅(−1)n\displaystyle = \blockA{A \cdot 2^n} + \blockB{B \cdot (-1)^n}

Once a0a_0 and a1a_1 are chosen, every later term is locked in by the recurrence, so choosing A\blockA{A} and B\blockB{B} to match a0a_0 and a1a_1 guarantees that this formula matches the sequence forever.

In the graph below, every choice of a0a_0 and a1a_1 locks in a unique sequence whose terms are the column-by-column sum of A⋅2n\blockA{A \cdot 2^n} and B⋅(−1)n\blockB{B \cdot (-1)^n}, and setting a1=2a0a_1 = \blockA{2}a_0 or a1=−a0a_1 = \blockB{-}a_0 zeroes out one part to leave a single pure power.

Every choice of the first two steps locks in the rest of the sequence as one unique mix of a doubling sequence and an alternating sequence.
3

Solving a Two-Step Recurrence

Now let's use the characteristic equation from start to finish to find the exact formula for

an\displaystyle a_n =5an−1−6an−2(a0=1,  a1=4).\displaystyle = 5a_{n-1} - 6a_{n-2} \quad (a_0 = 1, \; a_1 = 4).
Solving a Two-Step Recurrence
an=5an−1−6an−2a0=1,a1=4an=?\displaystyle \begin{aligned} a_n &= 5a_{n-1} - 6a_{n-2} \\ a_0 &= 1, \quad a_1 = 4 \\[6pt] a_n &= {\htmlClass{lc-orange}{?}} \end{aligned}
Text solution
Replace an,an−1,an−2a_n, a_{n-1}, a_{n-2} with r2,r,1r^2, r, 1 and factor for the multipliersAcross two steps back, the recurrence turns into a quadratic equation whose roots give the two pure power building blocks.
r2=5r−6r2−5r+6=0(r−2)(r−3)=0  ⟹  r=2,  r=3\displaystyle \begin{aligned} r^2 &= 5r - 6 \\ r^2 - 5r + 6 &= 0 \\ \blockA{(r - 2)}\blockB{(r - 3)} &= 0 \\ \implies \blockA{r} &\blockA{= 2}, \; \blockB{r = 3} \end{aligned}
Write the general mix of the building blocksCombining 2n\blockA{2^n} and 3n\blockB{3^n} with constants A\blockA{A} and B\blockB{B} covers every sequence that obeys the rule.
an\displaystyle a_n =A⋅2n+B⋅3n\displaystyle = \blockA{A \cdot 2^n} + \blockB{B \cdot 3^n}
Plug in n=0n = 0 and n=1n = 1 to solve for A\blockA{A} and B\blockB{B}Matching the formula to a0=1a_0 = 1 and a1=4a_1 = 4 gives a two-equation system for A\blockA{A} and B\blockB{B}.
n=0:A+B=1  ⟹  A=1−Bn=1:2A+3B=42(1−B)+3B=4  ⟹  B=2,  A=−1\displaystyle \begin{aligned} n = 0: \quad \blockA{A} + \blockB{B} &= 1 \\ \implies \blockA{A} &= 1 - \blockB{B} \\ n = 1: \quad \blockA{2A} + \blockB{3B} &= 4 \\ \blockA{2(1 - \blockB{B})} + \blockB{3B} &= 4 \\ \implies \blockB{B} &\blockB{= 2}, \; \blockA{A = -1} \end{aligned}

Putting A=−1\blockA{A = -1} and B=2\blockB{B = 2} back into the mix gives an=−1⋅2n+2⋅3na_n = \blockA{-1 \cdot 2^n} + \blockB{2 \cdot 3^n}, which reproduces the hand-computed terms 1,4,14,46,…1, 4, 14, 46, \dots for every nn.

4

Repeated Roots

Matching any pair of starting values a0a_0 and a1a_1 requires two independent building blocks, so our method runs into trouble when the characteristic quadratic factors into the same root twice. Let's find the missing second building block and solve

an\displaystyle a_n =4an−1−4an−2(a0=3,  a1=10).\displaystyle = 4a_{n-1} - 4a_{n-2} \quad (a_0 = 3, \; a_1 = 10).
Repeated Roots
(r−2)(r−3)=0\htmlClass{lc-blue}{(r - 2)}\htmlClass{lc-pink}{(r - 3)} = 0
r=2\htmlClass{lc-blue}{r = 2}
r=3\htmlClass{lc-pink}{r = 3}
A⋅2n\htmlClass{lc-blue}{A \cdot 2^n}
B⋅3n\htmlClass{lc-pink}{B \cdot 3^n}
(r−2)(r−2)=0\htmlClass{lc-blue}{(r - 2)}\htmlClass{lc-blue}{(r - 2)} = 0
r=2\htmlClass{lc-blue}{r = 2}
r=2\htmlClass{lc-blue}{r = 2}
A⋅2n\htmlClass{lc-blue}{A \cdot 2^n}
?{\htmlClass{lc-orange}{?}}

When we plug an=n⋅rna_n = \blockB{n \cdot r^n} into an−4an−1+4an−2a_n - 4a_{n-1} + 4a_{n-2}, expanding the (n−1)(n - 1) and (n−2)(n - 2) terms separates the pieces with nn from the leftover constants:

nrn−2(r2−4r+4)⏟= 0+4rn−2(r−2)⏟=0at double rootr=2=0\displaystyle \begin{aligned} &n r^{n-2}\underbrace{(r^2 - 4r + 4)}_{\holds{=\,0}} \\ &\quad + \leftover{4r^{n-2}}\underbrace{\leftover{(r - 2)}}_{\begin{gathered}\scriptstyle\holds{=\,0} \\[-3pt] \scriptstyle\text{at double root} \\[-3pt] \scriptstyle \blockA{r = 2}\end{gathered}} = 0 \end{aligned}

Because r=2\blockA{r = 2} is a repeated root of (r−2)2=0\blockA{(r - 2)^2} = 0, both parentheses equal 00, giving n⋅2n\blockB{n \cdot 2^n} as the second building block.

Text solution
Factor the characteristic equation and include n⋅2n\blockB{n \cdot 2^n} for the double rootSince r=2\blockA{r = 2} repeats, multiplying 2n\blockA{2^n} by nn provides the second independent building block.
r2−4r+4=0(r−2)2=0  ⟹  r=2 (double root)an=A⋅2n+B⋅n2n\displaystyle \begin{aligned} r^2 - 4r + 4 &= 0 \\ \blockA{(r - 2)^2} &= 0 \\ \implies \blockA{r} &\blockA{= 2} \text{ (double root)} \\ a_n &= \blockA{A \cdot 2^n} + \blockB{B \cdot n2^n} \end{aligned}
Plug in n=0n = 0 and n=1n = 1 to lock in A\blockA{A} and B\blockB{B}At step n=0n = 0, the factor of nn zeroes out the B\blockB{B} term so A\blockA{A} comes out immediately, and step n=1n = 1 fixes B\blockB{B}.
n=0:A⋅20+B⋅(0)⋅20=3  ⟹  A=3n=1:3⋅21+B⋅(1)⋅21=106+2B=10  ⟹  B=2\displaystyle \begin{aligned} n = 0: \quad \blockA{A \cdot 2^0} + \blockB{B \cdot (0) \cdot 2^0} &= 3 \\ \implies \blockA{A} &\blockA{= 3} \\ n = 1: \quad \blockA{3 \cdot 2^1} + \blockB{B \cdot (1) \cdot 2^1} &= 10 \\ \blockA{6} + \blockB{2B} &= 10 \\ \implies \blockB{B} &\blockB{= 2} \end{aligned}

So the exact formula is ana_n == 3⋅2n+2n⋅2n\blockA{3 \cdot 2^n} + \blockB{2n \cdot 2^n} == (3+2n)2n(\blockA{3} + \blockB{2n})2^n.

With a0=3a_0 = 3 held fixed below, the first building block 3⋅2n\blockA{3 \cdot 2^n} stays pinned at step 00, while B⋅n2n\blockB{B \cdot n2^n} equals 00 at n=0n = 0 and stretches to meet any choice of a1a_1 without changing a0a_0.

The first building block stays fixed while the second starts at zero and stretches to match any value you pick at the next step.
5

Three-Step Recurrences

A rule that looks three steps back works the exact same way using r3,r2,r,1r^3, r^2, r, 1, with three building blocks to match three starting values:

an\displaystyle a_n =6an−1−11an−2+6an−3(a0=2,  a1=5,  a2=15).\displaystyle = 6a_{n-1} - 11a_{n-2} + 6a_{n-3} \quad (a_0 = 2, \; a_1 = 5, \; a_2 = 15).
Three-Step Recurrences
an=6an−1−11an−2+6an−3a_n = 6a_{n-1} - 11a_{n-2} + 6a_{n-3}
a0=2,a1=5,a2=15a_0 = 2, \quad a_1 = 5, \quad a_2 = 15
an−3a_{n-3}
an−2a_{n-2}
an−1a_{n-1}
ana_n
an=?a_n = {\htmlClass{lc-orange}{?}}
Text solution
Test small integer factors of −6-6 to factor the characteristic cubicPlugging r=1\blockA{r = 1} into r3−6r2+11r−6=0r^3 - 6r^2 + 11r - 6 = 0 gives 00, so (r−1)\blockA{(r - 1)} factors out and leaves a quadratic.
r3−6r2+11r−6=0(r−1)(r2−5r+6)=0(r−1)(r−2)(r−3)=0  ⟹  r=1,  r=2,  r=3\displaystyle \begin{aligned} r^3 - 6r^2 + 11r - 6 &= 0 \\ \blockA{(r - 1)}(r^2 - 5r + 6) &= 0 \\ \blockA{(r - 1)}\blockB{(r - 2)}\blockC{(r - 3)} &= 0 \\ \implies \blockA{r = 1}, \; \blockB{r = 2}, \; \blockC{r = 3} \end{aligned}
Write the three-term mix and plug in n=0,1,2n = 0, 1, 2Because 1n=1\blockA{1^n = 1} for every nn, the first building block A⋅1n\blockA{A \cdot 1^n} is simply a constant A\blockA{A}.
an=A+B⋅2n+C⋅3nn=0:A+B+C=2n=1:A+2B+3C=5n=2:A+4B+9C=15\displaystyle \begin{aligned} a_n &= \blockA{A} + \blockB{B \cdot 2^n} \\ &\quad + \blockC{C \cdot 3^n} \\ n = 0: \blockA{A} + \blockB{B} + \blockC{C} &= 2 \\ n = 1: \blockA{A} + \blockB{2B} + \blockC{3C} &= 5 \\ n = 2: \blockA{A} + \blockB{4B} + \blockC{9C} &= 15 \end{aligned}
Subtract adjacent equations to eliminate A\blockA{A} and solve for B\blockB{B}, C\blockC{C}, A\blockA{A}Subtracting the first equation from the second, and the second from the third, drops A\blockA{A} out right away.
B+2C=3  ⟹  B=3−2C2B+6C=102(3−2C)+6C=10  ⟹  C=2,  B=−1,  A=1\displaystyle \begin{aligned} \blockB{B} + \blockC{2C} &= 3 \\ \implies \blockB{B} &= 3 - \blockC{2C} \\ \blockB{2B} + \blockC{6C} &= 10 \\ \blockB{2(3 - \blockC{2C})} + \blockC{6C} &= 10 \\ \implies \blockC{C} &\blockC{= 2}, \; \\ &\quad \blockB{B = -1}, \; \blockA{A = 1} \end{aligned}

Putting A=1\blockA{A = 1}, B=−1\blockB{B = -1}, and C=2\blockC{C = 2} into the mix gives ana_n == 1−2n+2⋅3n\blockA{1} \blockB{- 2^n} + \blockC{2 \cdot 3^n}, which matches a3a_3 == 1−8+54\blockA{1} \blockB{- 8} + \blockC{54} == 4747. If a cubic equation ever gives a triple root like (r−2)3=0\blockA{(r - 2)^3} = 0, multiplying by nn a second time gives the three building blocks A⋅2n+B⋅n2n+C⋅n22n\blockA{A \cdot 2^n} + \blockB{B \cdot n2^n} + \blockC{C \cdot n^2 2^n}.

6

Nonhomogeneous Recurrences and Baseline Sequences

Many counting recurrences add an extra term at each step that isn't a multiple of earlier terms. Let's solve one with a constant extra term +4\baseline{+ 4}:

an\displaystyle a_n =5an−1−6an−2+4(a0=3,  a1=6).\displaystyle = 5a_{n-1} - 6a_{n-2} \baseline{+ 4} \quad (a_0 = 3, \; a_1 = 6).
Nonhomogeneous Recurrences and Baseline Sequences
an=a_n ={}
5an−1−6an−25a_{n-1} - 6a_{n-2}
+4\htmlClass{lc-green}{{}+ 4}
blocks 2n,3n\text{blocks } \htmlClass{lc-blue}{2^n}, \htmlClass{lc-pink}{3^n}
a0=3,a1=6a_0 = 3, \quad a_1 = 6
an=?a_n = {\htmlClass{lc-orange}{?}}
2,2,2,…\htmlClass{lc-green}{2, 2, 2, \dots}
++
A⋅2n+B⋅3n\htmlClass{lc-blue}{A \cdot 2^n} + \htmlClass{lc-pink}{B \cdot 3^n}
an−5an−1+6an−2a_n - 5a_{n-1} + 6a_{n-2}
4\htmlClass{lc-green}{4}
++
00
==
4\htmlClass{lc-green}{4}

Moving the aa terms to the left side gives an−5an−1+6an−2=4⏟nonhomogeneous recurrence\underbrace{a_n - 5a_{n-1} + 6a_{n-2} = \baseline{4}}_{\text{nonhomogeneous recurrence}}. Because A⋅2n+B⋅3n\blockA{A \cdot 2^n} + \blockB{B \cdot 3^n} always makes the left side equal 00, we first find one simple baseline sequence that makes the left side equal 4\baseline{4}, and then add A⋅2n+B⋅3n\blockA{A \cdot 2^n} + \blockB{B \cdot 3^n} on top of it to fit the starting values.

Text solution
Test a constant trial sequence an=ca_n = \baseline{c} to match the constant +4\baseline{+ 4}Setting an=ca_n = \baseline{c}, an−1=ca_{n-1} = \baseline{c}, and an−2=ca_{n-2} = \baseline{c} turns the left side into a single equation for the baseline constant c\baseline{c}.
c−5c+6c=42c=4  ⟹  c=2\displaystyle \begin{aligned} \baseline{c} - 5\baseline{c} + 6\baseline{c} &= \baseline{4} \\ 2\baseline{c} &= \baseline{4} \implies \baseline{c = 2} \end{aligned}
Add the zero-output building blocks A⋅2n+B⋅3n\blockA{A \cdot 2^n} + \blockB{B \cdot 3^n} to the baseline 2\baseline{2}The roots of r2−5r+6=0r^2 - 5r + 6 = 0 give the zero-output mix, which gives us A\blockA{A} and B\blockB{B} to fit the starting values without changing the 4\baseline{4} on the right-hand side.
an\displaystyle a_n =A⋅2n+B⋅3n⏟outputs 0+2⏟baseline (outputs 4)\displaystyle = \underbrace{\blockA{A \cdot 2^n} + \blockB{B \cdot 3^n}}_{\text{outputs } 0} + \underbrace{\baseline{2}}_{\text{baseline (outputs } \baseline{4}\text{)}}
Plug in n=0n = 0 and n=1n = 1 with the baseline +2\baseline{+ 2} in placeBecause the baseline contributes 2\baseline{2} at every step, it must be included when matching a0=3a_0 = 3 and a1=6a_1 = 6.
n=0:A+B+2=3  ⟹  A+B=1n=1:2A+3B+2=6  ⟹  2A+3B=4B=2,  A=−1\displaystyle \begin{aligned} n = 0: \blockA{A} + \blockB{B} + \baseline{2} &= 3 \\ \implies \blockA{A} + \blockB{B} &= 1 \\ n = 1: \blockA{2A} + \blockB{3B} + \baseline{2} &= 6 \\ \implies \blockA{2A} + \blockB{3B} &= 4 \\ \blockB{B} &= \blockB{2}, \; \blockA{A = -1} \end{aligned}

This gives the complete formula ana_n == −1⋅2n+2⋅3n+2\blockA{-1 \cdot 2^n} + \blockB{2 \cdot 3^n} + \baseline{2}, which checks at n=2n = 2 with a2=−4+18+2=16a_2 = \blockA{-4} + \blockB{18} + \baseline{2} = 16.

In the graph below, the constant baseline y=2\baseline{y = 2} stays fixed in place while the zero-output mix A⋅2n+B⋅3n\blockA{A \cdot 2^n} + \blockB{B \cdot 3^n} stretches to close the vertical gap between the baseline 2\baseline{2} and the starting points a0a_0 and a1a_1.

The baseline sequence stays put at every step, while the mix stretches from that baseline to reach the starting dots.
7

Extra Terms That Grow with nn

Now suppose the extra term at each step grows with nn instead of staying constant:

an\displaystyle a_n =2an−1+n(a0=1).\displaystyle = 2a_{n-1} \baseline{+ n} \quad (a_0 = 1).
Extra Terms That Grow with n
an=2an−1+n,a0=1a_n = 2a_{n-1} \htmlClass{lc-green}{+ n}, \quad a_0 = 1
n\htmlClass{lc-mute}{n}
0\htmlClass{lc-mute}{0}
1\htmlClass{lc-mute}{1}
2\htmlClass{lc-mute}{2}
3\htmlClass{lc-mute}{3}
ana_n
11
33
88
1919
…\dots
×2 +1\htmlClass{lc-pink}{\times 2}\, \htmlClass{lc-green}{{+}1}
×2 +2\htmlClass{lc-pink}{\times 2}\, \htmlClass{lc-green}{{+}2}
×2 +3\htmlClass{lc-pink}{\times 2}\, \htmlClass{lc-green}{{+}3}
an=?a_n = {\htmlClass{lc-orange}{?}}
Text solution
Find the zero-output building block from an−2an−1=0a_n - 2a_{n-1} = 0A rule that looks one step back has a first-degree characteristic equation with a single multiplier.
r−2\displaystyle \blockA{r - 2} =0  ⟹  r=2,building block A⋅2n\displaystyle = 0 \implies \blockA{r = 2}, \quad \text{building block } \blockA{A \cdot 2^n}
Substitute a linear trial baseline an=cn+da_n = \baseline{cn + d} and match the nn and constant partsReplacing nn with n−1n - 1 inside an−1=c(n−1)+da_{n-1} = \baseline{c(n - 1) + d} produces a leftover constant −c\leftover{-c}, so we include +d\baseline{+ d} to make the constant part equal 00.
(cn+d)−2(c(n−1)+d)=n−cn+(2c−d)=1⋅n+0−c=1  ⟹  c=−12(−1)−d=0  ⟹  d=−2\displaystyle \begin{aligned} (\baseline{c}n + \baseline{d}) \\ {} - 2\big(\baseline{c}(n - 1) + \baseline{d}\big) &= \baseline{n} \\ -\baseline{c}n + (\leftover{2c} - \baseline{d}) &= 1 \cdot \baseline{n} + 0 \\ -\baseline{c} = 1 \implies \baseline{c} &\baseline{= -1} \\ 2(-1) - \baseline{d} = 0 \implies \baseline{d} &\baseline{= -2} \end{aligned}
Combine the building block with the baseline −n−2\baseline{-n - 2} and plug in a0=1a_0 = 1Adding A⋅2n\blockA{A \cdot 2^n} to the baseline before setting n=0n = 0 locks in A\blockA{A}.
an=A⋅2n−n−2n=0:A⋅20−0−2=1  ⟹  A=3\displaystyle \begin{aligned} a_n &= \blockA{A \cdot 2^n} \baseline{- n - 2} \\ n = 0: \\ \blockA{A \cdot 2^0} \baseline{- 0 - 2} &= 1 \\ \implies \blockA{A} &\blockA{= 3} \end{aligned}

So the sequence is an=3⋅2n−n−2a_n = \blockA{3 \cdot 2^n} \baseline{- n - 2}, which gives a3=3(8)−3−2=19a_3 = \blockA{3(8)} \baseline{- 3 - 2} = 19.

For any nonhomogeneous recurrence, match the trial baseline to the shape of the extra term on the right: try c\baseline{c} for a constant like +4\baseline{+ 4}, try cn+d\baseline{cn + d} for a linear term like +n\baseline{+ n}, and try c⋅4n\baseline{c \cdot 4^n} for an exponential like +4n\baseline{+ 4^n}. If that trial shape is already one of your zero-output building blocks (such as +2n\baseline{+ 2^n} when r=2r = 2 is a root, or a constant +1\baseline{+ 1} when r=1r = 1 is a root), plugging it into the left side gives 00, so multiply the trial baseline by nn (trying c⋅n2n\baseline{c \cdot n2^n}, or cn\baseline{cn}).

Key concepts

Every linear recurrence is solved in the same order: build the general formula from the recurrence rule first, and use the starting values a0,a1,…a_0, a_1, \dots to lock in A\blockA{A}, B\blockB{B}, C\blockC{C} at the very end.

For the homogeneous part (all aa terms moved to the left and set to 00), replace the steps with powers of rr (such as r2,r,1r^2, r, 1 for two steps back or r3,r2,r,1r^3, r^2, r, 1 for three steps back) to get the characteristic equation. Distinct roots like (r−2)(r−3)=0\blockA{(r - 2)}\blockB{(r - 3)} = 0 give separate pure powers A⋅2n+B⋅3n\blockA{A \cdot 2^n} + \blockB{B \cdot 3^n}, and a root of r=1\blockA{r = 1} simplifies A⋅1n\blockA{A \cdot 1^n} to a plain constant A\blockA{A}. Whenever a root repeats, multiply by nn for each repetition so you still have enough independent building blocks: (r−2)2=0\blockA{(r - 2)^2} = 0 uses A⋅2n+B⋅n2n\blockA{A \cdot 2^n} + \blockB{B \cdot n2^n}, and (r−2)3=0\blockA{(r - 2)^3} = 0 uses A⋅2n+B⋅n2n+C⋅n22n\blockA{A \cdot 2^n} + \blockB{B \cdot n2^n} + \blockC{C \cdot n^2 2^n}. (If a recurrence is already a simple one-step multiplier an=3an−1a_n = 3a_{n-1} with no extra term, you don't need a system of equations at all: it is already the pure power an=a0⋅3na_n = a_0 \cdot \blockA{3^n}.)

When an extra term sits on the right-hand side, like an−5an−1+6an−2=4a_n - 5a_{n-1} + 6a_{n-2} = \baseline{4} or an−2an−1=na_n - 2a_{n-1} = \baseline{n}, don't solve for A\blockA{A} and B\blockB{B} on the homogeneous mix alone. First find a baseline sequence by plugging in a trial that matches the extra term's shape (c\baseline{c} for a constant, cn+d\baseline{cn + d} for a linear term in nn, or c⋅kn\baseline{c \cdot k^n} for an exponential kn\baseline{k^n}), multiplying the trial by nn if that shape is already one of the zero-output building blocks (such as trying c⋅n2n\baseline{c \cdot n2^n} for an−2an−1=2na_n - 2a_{n-1} = \baseline{2^n}). Add the zero-output building blocks to the baseline, and only then plug in a0,a1,…a_0, a_1, \dots to find A\blockA{A}, B\blockB{B}, C\blockC{C}.

8

Practice

1

Solve the recurrence an=2an−1+3an−2a_n = 2a_{n-1} + 3a_{n-2} for n≥2n \ge 2 with starting values a0=3a_0 = 3 and a1=5a_1 = 5, and use your formula to find a50a_{50}.

Move all terms of r2=2r+3r^2 = 2r + 3 to one side before factoring, and check the sign of (−1)n(-1)^n at n=1n = 1 and n=50n = 50.

Replacing an,an−1,an−2a_n, a_{n-1}, a_{n-2} with r2,r,1r^2, r, 1 gives the characteristic equation:
r2−2r−3=0  ⟹  (r−3)(r+1)=0  ⟹  r=3,  r=−1\displaystyle \begin{aligned} r^2 - 2r - 3 &= 0 \\ \implies \blockA{(r - 3)}\blockB{(r + 1)} &= 0 \\ \implies \blockA{r} &\blockA{= 3}, \; \blockB{r = -1} \end{aligned}
So the general mix is ana_n == A⋅3n+B⋅(−1)n\blockA{A \cdot 3^n} + \blockB{B \cdot (-1)^n}. Plugging in n=0n = 0 and n=1n = 1:
n=0:A+B=3n=1:3A−B=5\displaystyle \begin{aligned} n = 0: \quad \blockA{A} + \blockB{B} &= 3 \\ n = 1: \quad \blockA{3A} \blockB{- B} &= 5 \end{aligned}
(Watch out: at n=1n = 1, (−1)1=−1\blockB{(-1)^1 = -1}; writing 3A+B=5\blockA{3A} \mistake{+ B} = 5 instead of 3A−B=5\blockA{3A} \blockB{- B} = 5 leads to the wrong formula 3n+2(−1)n3^n + 2(-1)^n.) Adding the two equations gives 4A=8\blockA{4A} = 8   ⟹  \implies A=2\blockA{A = 2} and B=1\blockB{B = 1}, so
an\displaystyle a_n =2⋅3n+(−1)n.\displaystyle = \blockA{2 \cdot 3^n} + \blockB{(-1)^n}.
At n=50n = 50, since 5050 is even, (−1)50=1\blockB{(-1)^{50} = 1} (not −1\mistake{-1}, which would give 2⋅350−12 \cdot 3^{50} - 1):
a50\displaystyle a_{50} =2⋅350+1\displaystyle = \blockA{2 \cdot 3^{50}} + \blockB{1}
2

Solve the recurrence an=6an−1−9an−2a_n = 6a_{n-1} - 9a_{n-2} for n≥2n \ge 2 with starting values a0=2a_0 = 2 and a1=15a_1 = 15.

Factor r2−6r+9=0r^2 - 6r + 9 = 0; how do you write the second building block when the root repeats?

The characteristic equation has a repeated root:
r2−6r+9=0  ⟹  (r−3)2=0  ⟹  r=3 (double root)\displaystyle \begin{aligned} r^2 - 6r + 9 &= 0 \\ \implies \blockA{(r - 3)^2} &= 0 \\ \implies \blockA{r} &\blockA{= 3} \text{ (double root)} \end{aligned}
Multiplying 3n\blockA{3^n} by nn for the second building block gives an=A⋅3n+B⋅n3na_n = \blockA{A \cdot 3^n} + \blockB{B \cdot n3^n}. Plugging in n=0n = 0 and n=1n = 1:
n=0:A⋅30+B⋅(0)⋅30=2  ⟹  A=2n=1:2⋅31+B⋅(1)⋅31=15  ⟹  6+3B=15  ⟹  B=3\displaystyle \begin{aligned} n = 0: \quad \blockA{A \cdot 3^0} + \blockB{B \cdot (0) \cdot 3^0} &= 2 \\ \implies \blockA{A} &\blockA{= 2} \\ n = 1: \quad \blockA{2 \cdot 3^1} + \blockB{B \cdot (1) \cdot 3^1} &= 15 \\ \implies \blockA{6} + \blockB{3B} &= 15 \\ \implies \blockB{B} &\blockB{= 3} \end{aligned}
(Watch out: at n=1n = 1, the second term is B⋅(1)⋅31=3B\blockB{B \cdot (1) \cdot 3^1 = 3B}; forgetting the factor of 313^1 and writing 6+B=15\blockA{6} + \mistake{B} = 15 gives B=9B = 9 and (2+9n)3n(2 + 9n)3^n.)
an\displaystyle a_n =2⋅3n+3n⋅3n\displaystyle = \blockA{2 \cdot 3^n} + \blockB{3n \cdot 3^n} =(2+3n)3n\displaystyle = (\blockA{2} + \blockB{3n})3^n
3

Solve the three-step recurrence an=2an−1+an−2−2an−3a_n = 2a_{n-1} + a_{n-2} - 2a_{n-3} for n≥3n \ge 3 with starting values a0=3a_0 = 3, a1=2a_1 = 2 and a2=6a_2 = 6.

Test r=1r = 1 in the cubic characteristic equation to factor out (r−1)(r - 1), then compare the n=0n = 0 and n=2n = 2 equations.

Moving all terms to the left gives the cubic characteristic equation:
r3−2r2−r+2=0  ⟹  (r−1)(r2−r−2)=0  ⟹  (r−1)(r+1)(r−2)=0\displaystyle \begin{aligned} r^3 - 2r^2 - r + 2 &= 0 \\ \implies \blockB{(r - 1)}(r^2 - r - 2) &= 0 \\ \implies \blockB{(r - 1)}\blockC{(r + 1)}\blockA{(r - 2)} &= 0 \end{aligned}
With roots r=2\blockA{r = 2}, 1\blockB{1}, −1\blockC{-1}, the general mix is ana_n == A⋅2n+B+C(−1)n\blockA{A \cdot 2^n} + \blockB{B} + \blockC{C(-1)^n}. Plugging in n=0,1,2n = 0, 1, 2:
n=0:A+B+C=3n=1:2A+B−C=2n=2:4A+B+C=6\displaystyle \begin{aligned} n = 0: \quad \blockA{A} + \blockB{B} + \blockC{C} &= 3 \\ n = 1: \quad \blockA{2A} + \blockB{B} \blockC{- C} &= 2 \\ n = 2: \quad \blockA{4A} + \blockB{B} + \blockC{C} &= 6 \end{aligned}
(Watch out: at n=2n = 2, (−1)2=+1\blockC{(-1)^2 = +1}; leaving a minus sign on C\blockC{C} and writing 4A+B−C=6\blockA{4A} + \blockB{B} \mistake{- C} = 6 gives A=2A = 2 and 2⋅2n−12+32(−1)n2 \cdot 2^n - \frac{1}{2} + \frac{3}{2}(-1)^n.) Subtracting the n=0n = 0 equation from the n=2n = 2 equation gives 3A=3\blockA{3A} = 3   ⟹  \implies A=1\blockA{A = 1}. Then B+C=2\blockB{B} + \blockC{C} = 2 and B−C=0\blockB{B} - \blockC{C} = 0, which gives B=1\blockB{B = 1} and C=1\blockC{C = 1}:
an\displaystyle a_n =1+(−1)n+2n\displaystyle = \blockB{1} + \blockC{(-1)^n} + \blockA{2^n}
4

Solve the nonhomogeneous recurrence an=3an−1+4an−2−12a_n = 3a_{n-1} + 4a_{n-2} - 12 for n≥2n \ge 2 with starting values a0=4a_0 = 4 and a1=5a_1 = 5.

Rewrite as an−3an−1−4an−2=−12a_n - 3a_{n-1} - 4a_{n-2} = -12 and find the constant baseline an=ca_n = c before solving for AA and BB.

For the homogeneous part an−3an−1−4an−2=0a_n - 3a_{n-1} - 4a_{n-2} = 0, the characteristic equation is
r2−3r−4=0  ⟹  (r−4)(r+1)=0  ⟹  r=4,  r=−1.\displaystyle \begin{aligned} r^2 - 3r - 4 &= 0 \\ \implies \blockA{(r - 4)}\blockB{(r + 1)} &= 0 \\ \implies \blockA{r} &\blockA{= 4}, \; \blockB{r = -1}. \end{aligned}
For the constant extra term −12\baseline{-12}, plug a constant trial an=ca_n = \baseline{c} into an−3an−1−4an−2=−12a_n - 3a_{n-1} - 4a_{n-2} = \baseline{-12}:
c−3c−4c\displaystyle \baseline{c} - 3\baseline{c} - 4\baseline{c} =−12  ⟹  −6c\displaystyle = \baseline{-12} \implies -6\baseline{c} =−12  ⟹  c=2.\displaystyle = \baseline{-12} \implies \baseline{c = 2}.
Adding the baseline 2\baseline{2} to the zero-output mix gives ana_n == A⋅4n+B⋅(−1)n+2\blockA{A \cdot 4^n} + \blockB{B \cdot (-1)^n} + \baseline{2}. (Watch out: plugging a0=4a_0 = 4 and a1=5a_1 = 5 into A⋅4n+B⋅(−1)n\blockA{A \cdot 4^n} + \blockB{B \cdot (-1)^n} before adding +2\baseline{+ 2} gives the wrong constants A=95,B=115A = \frac{9}{5}, B = \frac{11}{5} and 95⋅4n+115(−1)n+2\frac{9}{5} \cdot 4^n + \frac{11}{5}(-1)^n + 2.) With +2\baseline{+ 2} in place:
n=0:A+B+2=4  ⟹  A+B=2n=1:4A−B+2=5  ⟹  4A−B=3\displaystyle \begin{aligned} n = 0: \quad \blockA{A} + \blockB{B} + \baseline{2} &= 4 \\ \implies \blockA{A} + \blockB{B} &= 2 \\ n = 1: \quad \blockA{4A} \blockB{- B} + \baseline{2} &= 5 \\ \implies \blockA{4A} \blockB{- B} &= 3 \end{aligned}
Adding the two equations gives 5A=5\blockA{5A} = 5   ⟹  \implies A=1\blockA{A = 1} and B=1\blockB{B = 1}:
an\displaystyle a_n =4n+(−1)n+2\displaystyle = \blockA{4^n} + \blockB{(-1)^n} + \baseline{2}
5

Solve the recurrence an=3an−1+4na_n = 3a_{n-1} + 4n for n≥1n \ge 1 with starting value a0=1a_0 = 1.

Try a full linear baseline an=cn+da_n = cn + d in an−3an−1=4na_n - 3a_{n-1} = 4n, remembering to replace nn with n−1n - 1 inside an−1a_{n-1}.

From an−3an−1=0a_n - 3a_{n-1} = 0, the multiplier is r=3\blockA{r = 3}, giving the zero-output block A⋅3n\blockA{A \cdot 3^n}. Substituting the linear trial an=cn+da_n = \baseline{cn + d} into an−3an−1=4na_n - 3a_{n-1} = \baseline{4n}:
(cn+d)−3(c(n−1)+d)=4n  ⟹  −2cn+(3c−2d)=4n+0\displaystyle \begin{aligned} (\baseline{c}n + \baseline{d}) - 3\big(\baseline{c}(n - 1) + \baseline{d}\big) &= \baseline{4n} \\ \implies -2\baseline{c}n + (\leftover{3c} - 2\baseline{d}) &= \baseline{4n} + 0 \end{aligned}
(Watch out: forgetting to replace nn with n−1n - 1 in an−1a_{n-1} drops the 3c\leftover{3c} term and leads to d=0d = 0 and 3n−2n3^n - 2n.) Matching coefficients gives −2c=4  ⟹  c=−2-2\baseline{c} = 4 \implies \baseline{c = -2} and 3(−2)−2d=03(-2) - 2\baseline{d} = 0   ⟹  \implies d=−3\baseline{d = -3}, so the baseline is −2n−3\baseline{-2n - 3}. Combining and plugging in a0=1a_0 = 1:
an=A⋅3n−2n−3n=0:A⋅30−0−3=1  ⟹  A=4\displaystyle \begin{aligned} a_n &= \blockA{A \cdot 3^n} \baseline{- 2n - 3} \\ n = 0: \\ \blockA{A \cdot 3^0} \baseline{- 0 - 3} &= 1 \\ \implies \blockA{A} &\blockA{= 4} \end{aligned}
an\displaystyle a_n =4⋅3n−2n−3\displaystyle = \blockA{4 \cdot 3^n} \baseline{- 2n - 3}
6

Solve the recurrence an=3an−1−2an−2+2na_n = 3a_{n-1} - 2a_{n-2} + 2^n for n≥2n \ge 2 with starting values a0=1a_0 = 1 and a1=5a_1 = 5.

Check the roots of r2−3r+2=0r^2 - 3r + 2 = 0 first; why won't a plain c⋅2nc \cdot 2^n trial baseline work for +2n+ 2^n?

Moving the aa terms to the left gives an−3an−1+2an−2=2na_n - 3a_{n-1} + 2a_{n-2} = \baseline{2^n}. The characteristic equation is
r2−3r+2=0  ⟹  (r−1)(r−2)=0  ⟹  r=1,  r=2,\displaystyle \begin{aligned} r^2 - 3r + 2 &= 0 \\ \implies \blockA{(r - 1)}\blockB{(r - 2)} &= 0 \\ \implies \blockA{r} &\blockA{= 1}, \; \blockB{r = 2}, \end{aligned}
so the zero-output building blocks are A+B⋅2n\blockA{A} + \blockB{B \cdot 2^n}. Because the extra term 2n\baseline{2^n} is already a zero-output building block, we multiply the trial baseline c⋅2n\baseline{c \cdot 2^n} by nn and try an=c⋅n2na_n = \baseline{c \cdot n2^n}:
cn2n−3c(n−1)2n−1+2c(n−2)2n−2=2n\displaystyle \begin{aligned} &\baseline{c}n2^n - 3\baseline{c}(n - 1)2^{n-1} \\ &\quad + 2\baseline{c}(n - 2)2^{n-2} = \baseline{2^n} \end{aligned}
Dividing every term by 2n−2\leftover{2^{n-2}} leaves 22=4\baseline{2^2 = 4} on the right-hand side:
c(4n−6(n−1)+2(n−2))=4  ⟹  2c=4  ⟹  c=2\displaystyle \begin{aligned} \baseline{c}\big(4n - 6(n - 1) + 2(n - 2)\big) &= \baseline{4} \\ \implies 2\baseline{c} &= \baseline{4} \\ \implies \baseline{c} &\baseline{= 2} \end{aligned}
(Watch out: dividing the left side by 2n−2\leftover{2^{n-2}} while leaving 1\mistake{1} instead of 22=4\baseline{2^2 = 4} on the right gives 2c=1  ⟹  c=122c = 1 \implies c = \frac{1}{2} and −2+3⋅2n+12n2n-2 + 3 \cdot 2^n + \frac{1}{2}n2^n.) Adding the baseline 2n⋅2n\baseline{2n \cdot 2^n} to the zero-output blocks gives ana_n == A+B⋅2n+2n⋅2n\blockA{A} + \blockB{B \cdot 2^n} + \baseline{2n \cdot 2^n}. Plugging in n=0n = 0 and n=1n = 1:
n=0:A+B+0=1  ⟹  A+B=1n=1:A+2B+4=5  ⟹  A+2B=1\displaystyle \begin{aligned} n = 0: \quad \blockA{A} + \blockB{B} + \baseline{0} &= 1 \\ \implies \blockA{A} + \blockB{B} &= 1 \\ n = 1: \quad \blockA{A} + \blockB{2B} + \baseline{4} &= 5 \\ \implies \blockA{A} + \blockB{2B} &= 1 \end{aligned}
Subtracting the first equation from the second gives B=0\blockB{B = 0} and A=1\blockA{A = 1}:
an\displaystyle a_n =1+2n⋅2n\displaystyle = \blockA{1} + \baseline{2n \cdot 2^n}