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 a99 step by step takes forever, so we need a method to turn the step-by-step rule into a direct formula for an.
1
Hidden Pure Multiplier Sequences
Suppose we want a direct formula for the sequence built by
an=an−1+2an−2(a0=2,a1=1),
which starts 2,1,5,7,17,31,65,… and hides its pattern until we test simpler starting pairs on the same rule.
Hidden Pure Multiplier Sequences
Running the rule from 1,2 produces pure powers of 2, and running it from 1,−1 produces pure powers of −1. Adding those two pure multiplier sequences column by column gives our sequence at every step:
an=2n+(−1)n
Because the list starts at n=0, the 100th number is at step n=99, where plugging in n=99 jumps straight to a99=299+(−1)99=299−1.
2
The Characteristic Equation
To find those pure multiplier sequences an=rn for any linear recurrence without guessing starting numbers, we plug rn directly into the recurrence rule and solve for r.
The Characteristic Equation
Plugging an=rn into an=an−1+2an−2 puts the earliest step rn−2 inside every term, so dividing by rn−2 clears n completely:
Because a linear recurrence only scales and adds earlier terms, any combination of the building blocks 2n and (−1)n also obeys the rule:
an=A⋅2n+B⋅(−1)n
Once a0 and a1 are chosen, every later term is locked in by the recurrence, so choosing A and B to match a0 and a1 guarantees that this formula matches the sequence forever.
In the graph below, every choice of a0 and a1 locks in a unique sequence whose terms are the column-by-column sum of A⋅2n and B⋅(−1)n, and setting a1=2a0 or a1=−a0 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=5an−1−6an−2(a0=1,a1=4).
Solving a Two-Step Recurrence
ana0an=5an−1−6an−2=1,a1=4=?
Text solution
Replace an,an−1,an−2 with r2,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.
r2r2−5r+6(r−2)(r−3)⟹r=5r−6=0=0=2,r=3
Write the general mix of the building blocksCombining 2n and 3n with constants A and B covers every sequence that obeys the rule.
an=A⋅2n+B⋅3n
Plug in n=0 and n=1 to solve for A and BMatching the formula to a0=1 and a1=4 gives a two-equation system for A and B.
n=0:A+B⟹An=1:2A+3B2(1−B)+3B⟹B=1=1−B=4=4=2,A=−1
Putting A=−1 and B=2 back into the mix gives an=−1⋅2n+2⋅3n, which reproduces the hand-computed terms 1,4,14,46,… for every n.
4
Repeated Roots
Matching any pair of starting values a0 and a1 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=4an−1−4an−2(a0=3,a1=10).
Repeated Roots
When we plug an=n⋅rn into an−4an−1+4an−2, expanding the (n−1) and (n−2) terms separates the pieces with n from the leftover constants:
Because r=2 is a repeated root of (r−2)2=0, both parentheses equal 0, giving n⋅2n as the second building block.
Text solution
Factor the characteristic equation and include n⋅2n for the double rootSince r=2 repeats, multiplying 2n by n provides the second independent building block.
With a0=3 held fixed below, the first building block 3⋅2n stays pinned at step 0, while B⋅n2n equals 0 at n=0 and stretches to meet any choice of a1 without changing a0.
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,1, with three building blocks to match three starting values:
an=6an−1−11an−2+6an−3(a0=2,a1=5,a2=15).
Three-Step Recurrences
Text solution
Test small integer factors of −6 to factor the characteristic cubicPlugging r=1 into r3−6r2+11r−6=0 gives 0, so (r−1) factors out and leaves a quadratic.
Subtract adjacent equations to eliminate A and solve for B,C,ASubtracting the first equation from the second, and the second from the third, drops A out right away.
B+2C⟹B2B+6C2(3−2C)+6C⟹C=3=3−2C=10=10=2,B=−1,A=1
Putting A=1,B=−1, and C=2 into the mix gives an=1−2n+2⋅3n, which matches a3=1−8+54=47. If a cubic equation ever gives a triple root like (r−2)3=0, multiplying by n a second time gives the three building blocks A⋅2n+B⋅n2n+C⋅n22n.
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:
an=5an−1−6an−2+4(a0=3,a1=6).
Nonhomogeneous Recurrences and Baseline Sequences
Moving the a terms to the left side gives nonhomogeneous recurrencean−5an−1+6an−2=4. Because A⋅2n+B⋅3n always makes the left side equal 0, we first find one simple baseline sequence that makes the left side equal 4, and then add A⋅2n+B⋅3n on top of it to fit the starting values.
Text solution
Test a constant trial sequence an=c to match the constant +4Setting an=c,an−1=c, and an−2=c turns the left side into a single equation for the baseline constant c.
c−5c+6c2c=4=4⟹c=2
Add the zero-output building blocks A⋅2n+B⋅3n to the baseline 2The roots of r2−5r+6=0 give the zero-output mix, which gives us A and B to fit the starting values without changing the 4 on the right-hand side.
an=outputs 0A⋅2n+B⋅3n+baseline (outputs 4)2
Plug in n=0 and n=1 with the baseline +2 in placeBecause the baseline contributes 2 at every step, it must be included when matching a0=3 and a1=6.
n=0:A+B+2⟹A+Bn=1:2A+3B+2⟹2A+3BB=3=1=6=4=2,A=−1
This gives the complete formula an=−1⋅2n+2⋅3n+2, which checks at n=2 with a2=−4+18+2=16.
In the graph below, the constant baseline y=2 stays fixed in place while the zero-output mix A⋅2n+B⋅3n stretches to close the vertical gap between the baseline 2 and the starting points a0 and a1.
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 n
Now suppose the extra term at each step grows with n instead of staying constant:
an=2an−1+n(a0=1).
Extra Terms That Grow with n
Text solution
Find the zero-output building block from an−2an−1=0A rule that looks one step back has a first-degree characteristic equation with a single multiplier.
r−2=0⟹r=2,building block A⋅2n
Substitute a linear trial baseline an=cn+d and match the n and constant partsReplacing n with n−1 inside an−1=c(n−1)+d produces a leftover constant −c, so we include +d to make the constant part equal 0.
Combine the building block with the baseline −n−2 and plug in a0=1Adding A⋅2n to the baseline before setting n=0 locks in A.
ann=0:A⋅20−0−2⟹A=A⋅2n−n−2=1=3
So the sequence is an=3⋅2n−n−2, which gives a3=3(8)−3−2=19.
For any nonhomogeneous recurrence, match the trial baseline to the shape of the extra term on the right: try c for a constant like +4, try cn+d for a linear term like +n, and try c⋅4n for an exponential like +4n. If that trial shape is already one of your zero-output building blocks (such as +2n when r=2 is a root, or a constant +1 when r=1 is a root), plugging it into the left side gives 0, so multiply the trial baseline by n (trying c⋅n2n, or 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,… to lock in A,B,C at the very end.
For the homogeneous part (all a terms moved to the left and set to 0), replace the steps with powers of r (such as r2,r,1 for two steps back or r3,r2,r,1 for three steps back) to get the characteristic equation. Distinct roots like (r−2)(r−3)=0 give separate pure powers A⋅2n+B⋅3n, and a root of r=1 simplifies A⋅1n to a plain constant A. Whenever a root repeats, multiply by n for each repetition so you still have enough independent building blocks: (r−2)2=0 uses A⋅2n+B⋅n2n, and (r−2)3=0 uses A⋅2n+B⋅n2n+C⋅n22n. (If a recurrence is already a simple one-step multiplier an=3an−1 with no extra term, you don't need a system of equations at all: it is already the pure power an=a0⋅3n.)
When an extra term sits on the right-hand side, like an−5an−1+6an−2=4 or an−2an−1=n, don't solve for A and B on the homogeneous mix alone. First find a baseline sequence by plugging in a trial that matches the extra term's shape (c for a constant, cn+d for a linear term in n, or c⋅kn for an exponential kn), multiplying the trial by n if that shape is already one of the zero-output building blocks (such as trying c⋅n2n for an−2an−1=2n). Add the zero-output building blocks to the baseline, and only then plug in a0,a1,… to find A,B,C.
8
Practice
1
Solve the recurrence an=2an−1+3an−2 for n≥2 with starting values a0=3 and a1=5, and use your formula to find a50.
At n=1,(−1)1=−1; writing 3A+B=5 instead of 3A−B=5 leads to the wrong formula 3n+2(−1)n.
Move all terms of r2=2r+3 to one side before factoring, and check the sign of (−1)n at n=1 and n=50.
Replacing an,an−1,an−2 with r2,r,1 gives the characteristic equation:
r2−2r−3⟹(r−3)(r+1)⟹r=0=0=3,r=−1
So the general mix is an=A⋅3n+B⋅(−1)n. Plugging in n=0 and n=1:
n=0:A+Bn=1:3A−B=3=5
(Watch out: at n=1,(−1)1=−1; writing 3A+B=5 instead of 3A−B=5 leads to the wrong formula 3n+2(−1)n.) Adding the two equations gives 4A=8⟹A=2 and B=1, so
an=2⋅3n+(−1)n.
At n=50, since 50 is even, (−1)50=1(not −1, which would give 2⋅350−1):
a50=2⋅350+1
2
Solve the recurrence an=6an−1−9an−2 for n≥2 with starting values a0=2 and a1=15.
At n=1, the second term is B⋅(1)⋅31=3B; forgetting the factor of 31 and writing 6+B=15 gives B=9 and (2+9n)3n.
Factor r2−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⟹(r−3)2⟹r=0=0=3 (double root)
Multiplying 3n by n for the second building block gives an=A⋅3n+B⋅n3n. Plugging in n=0 and n=1:
(Watch out: at n=1, the second term is B⋅(1)⋅31=3B; forgetting the factor of 31 and writing 6+B=15 gives B=9 and (2+9n)3n.)
an=2⋅3n+3n⋅3n=(2+3n)3n
3
Solve the three-step recurrence an=2an−1+an−2−2an−3 for n≥3 with starting values a0=3,a1=2 and a2=6.
At n=2,(−1)2=+1; leaving a minus sign on C and writing 4A+B−C=6 gives A=2 and 2⋅2n−21+23(−1)n.
Test r=1 in the cubic characteristic equation to factor out (r−1), then compare the n=0 and n=2 equations.
Moving all terms to the left gives the cubic characteristic equation:
r3−2r2−r+2⟹(r−1)(r2−r−2)⟹(r−1)(r+1)(r−2)=0=0=0
With roots r=2,1,−1, the general mix is an=A⋅2n+B+C(−1)n. Plugging in n=0,1,2:
n=0:A+B+Cn=1:2A+B−Cn=2:4A+B+C=3=2=6
(Watch out: at n=2,(−1)2=+1; leaving a minus sign on C and writing 4A+B−C=6 gives A=2 and 2⋅2n−21+23(−1)n.) Subtracting the n=0 equation from the n=2 equation gives 3A=3⟹A=1. Then B+C=2 and B−C=0, which gives B=1 and C=1:
an=1+(−1)n+2n
4
Solve the nonhomogeneous recurrence an=3an−1+4an−2−12 for n≥2 with starting values a0=4 and a1=5.
Plugging a0=4 and a1=5 into A⋅4n+B⋅(−1)n before adding +2 gives the wrong constants A=59,B=511 and 59⋅4n+511(−1)n+2.
Rewrite as an−3an−1−4an−2=−12 and find the constant baseline an=c before solving for A and B.
For the homogeneous part an−3an−1−4an−2=0, the characteristic equation is
r2−3r−4⟹(r−4)(r+1)⟹r=0=0=4,r=−1.
For the constant extra term −12, plug a constant trial an=c into an−3an−1−4an−2=−12:
c−3c−4c=−12⟹−6c=−12⟹c=2.
Adding the baseline 2 to the zero-output mix gives an=A⋅4n+B⋅(−1)n+2.(Watch out: plugging a0=4 and a1=5 into A⋅4n+B⋅(−1)n before adding +2 gives the wrong constants A=59,B=511 and 59⋅4n+511(−1)n+2.) With +2 in place:
n=0:A+B+2⟹A+Bn=1:4A−B+2⟹4A−B=4=2=5=3
Adding the two equations gives 5A=5⟹A=1 and B=1:
an=4n+(−1)n+2
5
Solve the recurrence an=3an−1+4n for n≥1 with starting value a0=1.
Forgetting to replace n with n−1 in an−1 drops the 3c term and leads to d=0 and 3n−2n.
Try a full linear baseline an=cn+d in an−3an−1=4n, remembering to replace n with n−1 inside an−1.
From an−3an−1=0, the multiplier is r=3, giving the zero-output block A⋅3n. Substituting the linear trial an=cn+d into an−3an−1=4n:
(cn+d)−3(c(n−1)+d)⟹−2cn+(3c−2d)=4n=4n+0
(Watch out: forgetting to replace n with n−1 in an−1 drops the 3c term and leads to d=0 and 3n−2n.) Matching coefficients gives −2c=4⟹c=−2 and 3(−2)−2d=0⟹d=−3, so the baseline is −2n−3. Combining and plugging in a0=1:
ann=0:A⋅30−0−3⟹A=A⋅3n−2n−3=1=4
an=4⋅3n−2n−3
6
Solve the recurrence an=3an−1−2an−2+2n for n≥2 with starting values a0=1 and a1=5.
Dividing the left side by 2n−2 while leaving 1 instead of 22=4 on the right gives 2c=1⟹c=21 and −2+3⋅2n+21n2n.
Check the roots of r2−3r+2=0 first; why won't a plain c⋅2n trial baseline work for +2n?
Moving the a terms to the left gives an−3an−1+2an−2=2n. The characteristic equation is
r2−3r+2⟹(r−1)(r−2)⟹r=0=0=1,r=2,
so the zero-output building blocks are A+B⋅2n. Because the extra term 2n is already a zero-output building block, we multiply the trial baseline c⋅2n by n and try an=c⋅n2n:
cn2n−3c(n−1)2n−1+2c(n−2)2n−2=2n
Dividing every term by 2n−2 leaves 22=4 on the right-hand side:
c(4n−6(n−1)+2(n−2))⟹2c⟹c=4=4=2
(Watch out: dividing the left side by 2n−2 while leaving 1 instead of 22=4 on the right gives 2c=1⟹c=21 and −2+3⋅2n+21n2n.) Adding the baseline 2n⋅2n to the zero-output blocks gives an=A+B⋅2n+2n⋅2n. Plugging in n=0 and n=1:
n=0:A+B+0⟹A+Bn=1:A+2B+4⟹A+2B=1=1=5=1
Subtracting the first equation from the second gives B=0 and A=1: