evan's notes
cal 3discreteodeenv systems
中文

On this page

  • Recursive and explicit definitions
  • Example: factorials
  • Example: a geometric recurrence
  • Counting with a recurrence: Tower of Hanoi
  • Linear first-order recurrences
  • The homogeneous recurrence
  • Finding a particular solution
  • Choosing the trial form
  • Higher-order recurrences
  • Characteristic equations
  • A second characteristic-root example
  • What changes in other cases?

Discrete Structures

§4 Recurrence Relations

Evan Luo · Sep 15, 2026

Discrete Structures

§4 Recurrence Relations

Evan LuoSep 15, 2026

9 min read

A recurrence relation defines each term of a sequence from earlier terms. It is useful when a problem naturally breaks into a smaller copy of itself.

Recursive and explicit definitions

Let (an)n∈N(a_n)_{n\in\mathbb N}(an​)n∈N​ be a sequence, read as “the sequence ana_nan​ indexed by the natural numbers.” A first-order recurrence uses only the preceding term. It needs two parts:

  1. a base case, such as a0=ca_0=ca0​=c;
  2. a recurrence rule, such as
an=F(n,an−1)(n≥1).a_n=F(n,a_{n-1})\qquad(n\ge1). an​=F(n,an−1​)(n≥1).

Here, nnn is the index, an−1a_{n-1}an−1​ is the preceding term, and FFF is the rule that produces the next term.

An explicit formula, also called a closed form, gives ana_nan​ directly from nnn:

an=φ(n).a_n=\varphi(n). an​=φ(n).

The symbol φ\varphiφ is the Greek letter phi, read “fee.” A recurrence tells us how to compute forward; a closed form lets us jump directly to any index.

Example: factorials

The factorial sequence has base case

0!=10!=1 0!=1

and recurrence

n!=n(n−1)!(n≥1).n!=n(n-1)!\qquad(n\ge1). n!=n(n−1)!(n≥1).

For example,

4!=4⋅3!=4⋅3⋅2!=4⋅3⋅2⋅1!=4⋅3⋅2⋅1⋅0!=24.\begin{aligned} 4! &=4\cdot3!\\ &=4\cdot3\cdot2!\\ &=4\cdot3\cdot2\cdot1!\\ &=4\cdot3\cdot2\cdot1\cdot0!\\ &=24. \end{aligned} 4!​=4⋅3!=4⋅3⋅2!=4⋅3⋅2⋅1!=4⋅3⋅2⋅1⋅0!=24.​

Each substitution reduces the index until it reaches the base case.

Example: a geometric recurrence

Suppose

{a0=c,an=ran−1(n≥1),\begin{cases} a_0=c,\\ a_n=r a_{n-1}\qquad(n\ge1), \end{cases} {a0​=c,an​=ran−1​(n≥1),​

where ccc is the initial value and rrr is a fixed multiplier. Expanding several terms gives

a1=cr,a2=cr2,a3=cr3.a_1=cr, \qquad a_2=cr^2, \qquad a_3=cr^3. a1​=cr,a2​=cr2,a3​=cr3.

The pattern leads to the closed form

an=crn.\boxed{a_n=cr^n}. an​=crn​.

A proposed closed form should satisfy both the base case and the recurrence. Those two checks confirm that it describes the same sequence.

Counting with a recurrence: Tower of Hanoi

The Tower of Hanoi puzzle has three pegs and nnn disks of different sizes. All disks begin on the first peg, largest at the bottom. The goal is to move the entire stack to the third peg while following three rules:

  • move only one disk at a time;
  • only the top disk of a peg may be moved;
  • never place a larger disk on top of a smaller one.

Let hnh_nhn​ be the minimum number of legal moves needed for nnn disks. The empty puzzle gives the base case

h0=0.h_0=0. h0​=0.

To solve the puzzle for n≥1n\ge1n≥1:

  1. move the top n−1n-1n−1 disks to the middle peg, using hn−1h_{n-1}hn−1​ moves;
  2. move the largest disk to the final peg, using one move;
  3. move the n−1n-1n−1 smaller disks onto it, using another hn−1h_{n-1}hn−1​ moves.

One legal solution fornnndisks

Tower of Hanoi recurrenceFour states show the top n minus one disks moving to the middle peg, the largest disk moving to the final peg, and the top disks moving onto it. The move count is h sub n minus one, plus one, plus h sub n minus one.
hn−1h_{n-1}hn−1​moves
111move
hn−1h_{n-1}hn−1​moves
Start
Move the topn−1n-1n−1disks
Move the largest disk
Repeat the smaller
problem
hn=hn−1+1+hn−1=2hn−1+1h_n = h_{n-1} + 1 + h_{n-1} = 2h_{n-1} + 1hn​=hn−1​+1+hn−1​=2hn−1​+1
Solving thennn-disk puzzle contains two copies of the same problem withn−1n-1n−1disks, separated by one move of the largest disk.

This construction is also optimal. Before the largest disk can move, all n−1n-1n−1 smaller disks must be moved to the spare peg, which takes at least hn−1h_{n-1}hn−1​ moves. After the largest disk moves once, those same disks must be moved onto it, taking at least another hn−1h_{n-1}hn−1​ moves. Therefore,

hn=2hn−1+1.\boxed{h_n=2h_{n-1}+1}. hn​=2hn−1​+1​.

The first values are

h0=0,h1=1,h2=3,h3=7,h4=15,h5=31.h_0=0, \quad h_1=1, \quad h_2=3, \quad h_3=7, \quad h_4=15, \quad h_5=31. h0​=0,h1​=1,h2​=3,h3​=7,h4​=15,h5​=31.

These values are one less than successive powers of two. To derive the pattern, add 111 to both sides of the recurrence:

hn+1=2(hn−1+1).h_n+1=2(h_{n-1}+1). hn​+1=2(hn−1​+1).

If bn=hn+1b_n=h_n+1bn​=hn​+1, then b0=1b_0=1b0​=1 and bn=2bn−1b_n=2b_{n-1}bn​=2bn−1​. This is a geometric recurrence, so bn=2nb_n=2^nbn​=2n. Hence

hn=2n−1.\boxed{h_n=2^n-1}. hn​=2n−1​.

For the traditional puzzle with 64 disks,

h64=264−1=18,446,744,073,709,551,615h_{64}=2^{64}-1 =18{,}446{,}744{,}073{,}709{,}551{,}615 h64​=264−1=18,446,744,073,709,551,615

moves. At one move per second, that is about 1.84×10191.84\times10^{19}1.84×1019 seconds, or 5.85×10115.85\times10^{11}5.85×1011 years—roughly 42 times the current age of the universe.

Linear first-order recurrences

A linear first-order recurrence has the form

{a0=c,an=f(n)an−1+g(n)(n≥1),\begin{cases} a_0=c,\\ a_n=f(n)a_{n-1}+g(n)\qquad(n\ge1), \end{cases} {a0​=c,an​=f(n)an−1​+g(n)(n≥1),​

where f(n)f(n)f(n) and g(n)g(n)g(n) are known functions. The term g(n)g(n)g(n) is called the nonhomogeneous term or forcing term.

Consider

{a0=3,an=2an−1+n.\begin{cases} a_0=3,\\ a_n=2a_{n-1}+n. \end{cases} {a0​=3,an​=2an−1​+n.​

Computing forward gives the sequence

3,7,16,35,74,…3,7,16,35,74,\ldots 3,7,16,35,74,…

To find a closed form, separate the recurrence into its homogeneous behavior and a particular response to the forcing term.

The homogeneous recurrence

Remove the forcing term g(n)g(n)g(n) to get the associated homogeneous recurrence:

hn=f(n)hn−1.h_n=f(n)h_{n-1}. hn​=f(n)hn−1​.

For the example, this becomes

hn=2hn−1,h_n=2h_{n-1}, hn​=2hn−1​,

whose general solution is

hn=C⋅2n,h_n=C\cdot2^n, hn​=C⋅2n,

where CCC is an arbitrary constant.

A particular solution is any one sequence that satisfies the full recurrence. Suppose (pn)(p_n)(pn​) and (qn)(q_n)(qn​) are two particular solutions. Subtracting their equations cancels the forcing term:

pn−qn=f(n)pn−1+g(n)−(f(n)qn−1+g(n))=f(n)(pn−1−qn−1).\begin{aligned} p_n-q_n &=f(n)p_{n-1}+g(n)-\bigl(f(n)q_{n-1}+g(n)\bigr)\\ &=f(n)(p_{n-1}-q_{n-1}). \end{aligned} pn​−qn​​=f(n)pn−1​+g(n)−(f(n)qn−1​+g(n))=f(n)(pn−1​−qn−1​).​

Thus, the difference between any two particular solutions satisfies the homogeneous recurrence. Once one particular solution pnp_npn​ is known, every solution has the form

an=pn+hn.\boxed{a_n=p_n+h_n}. an​=pn​+hn​​.

Finding a particular solution

For

an=2an−1+n,a_n=2a_{n-1}+n, an​=2an−1​+n,

the forcing term g(n)=ng(n)=ng(n)=n is a polynomial of degree one. Guess a particular solution of the same form:

pn=An+B,p_n=An+B, pn​=An+B,

where AAA and BBB are constants to determine. Substitute the guess into the recurrence:

An+B=2(A(n−1)+B)+n=(2A+1)n+(−2A+2B).\begin{aligned} An+B &=2\bigl(A(n-1)+B\bigr)+n\\ &=(2A+1)n+(-2A+2B). \end{aligned} An+B​=2(A(n−1)+B)+n=(2A+1)n+(−2A+2B).​

Matching the coefficients of nnn and the constant terms gives

A=2A+1,B=−2A+2B.A=2A+1, \qquad B=-2A+2B. A=2A+1,B=−2A+2B.

Therefore,

A=−1,B=−2,A=-1, \qquad B=-2, A=−1,B=−2,

so one particular solution is

pn=−n−2.p_n=-n-2. pn​=−n−2.

Add the homogeneous solution:

an=−n−2+C⋅2n.a_n=-n-2+C\cdot2^n. an​=−n−2+C⋅2n.

Use the base case a0=3a_0=3a0​=3:

3=−2+C,C=5.3=-2+C, \qquad C=5. 3=−2+C,C=5.

The closed form is

an=5⋅2n−n−2.\boxed{a_n=5\cdot2^n-n-2}. an​=5⋅2n−n−2​.

Checking n=0n=0n=0 gives a0=3a_0=3a0​=3, and substituting the formula into the recurrence gives an=2an−1+na_n=2a_{n-1}+nan​=2an−1​+n.

Choosing the trial form

The trial-form shortcut below applies to a constant-coefficient recurrence

an=ran−1+g(n),a_n=r a_{n-1}+g(n), an​=ran−1​+g(n),

where rrr is fixed. In this case, the shape of g(n)g(n)g(n) suggests a useful guess for pnp_npn​:

Forcing term g(n)g(n)g(n)Trial particular solution pnp_npn​
polynomial of degree dddA0+A1n+⋯+AdndA_0+A_1n+\cdots+A_dn^dA0​+A1​n+⋯+Ad​nd
cbncb^ncbnAbnAb^nAbn
a sum of termsthe sum of the corresponding trial forms
a product of a polynomial and bnb^nbna polynomial of the same degree multiplied by bnb^nbn

For example, if

g(n)=2n+n23n,g(n)=2^n+n^2 3^n, g(n)=2n+n23n,

try

pn=A2n+(B+Cn+Dn2)3n.p_n=A2^n+(B+Cn+Dn^2)3^n. pn​=A2n+(B+Cn+Dn2)3n.

There is one important exception. If the trial already has the same form as a homogeneous solution, it will cancel during substitution. Multiply the trial by nnn—and by a higher power of nnn if necessary—until the forms no longer overlap. When g(n)g(n)g(n) is a sum, adjust only the overlapping part of the trial.

For this constant-coefficient case, the complete method is:

  1. solve the associated homogeneous recurrence to obtain hnh_nhn​;
  2. choose a trial pnp_npn​ from the form of g(n)g(n)g(n);
  3. substitute pnp_npn​ into the original recurrence and solve for its coefficients;
  4. write an=pn+hna_n=p_n+h_nan​=pn​+hn​;
  5. use the base case to determine the remaining constant.

Higher-order recurrences

A recurrence has order 222 when each term can depend on the two preceding terms. It therefore needs two base cases. The shifted Fibonacci sequence is a standard example:

{f0=1,f1=2,fn=fn−1+fn−2(n≥2).\begin{cases} f_0=1,\\ f_1=2,\\ f_n=f_{n-1}+f_{n-2}\qquad(n\ge2). \end{cases} ⎩⎨⎧​f0​=1,f1​=2,fn​=fn−1​+fn−2​(n≥2).​

Computing forward gives

1,2,3,5,8,13,21,34,…,1,2,3,5,8,13,21,34,\ldots, 1,2,3,5,8,13,21,34,…,

and in particular

f12=377.f_{12}=377. f12​=377.

This indexing matches a rabbit-population model that starts with one breeding pair at month zero. Each month, the pairs already alive contribute fn−1f_{n-1}fn−1​ pairs. Every pair that was alive one month earlier is now old enough to produce one new pair, contributing fn−2f_{n-2}fn−2​ newborn pairs. Therefore

fn=fn−1+fn−2.f_n=f_{n-1}+f_{n-2}. fn​=fn−1​+fn−2​.
Rabbit recurrence decompositionExisting rabbit pairs counted by f sub n minus one and newborn pairs counted by f sub n minus two flow into f sub n.
The pairs already present and the newborn pairs are disjoint contributions to the next month's total.

The recurrence computes terms efficiently in order, but a characteristic equation gives a direct formula for fnf_nfn​.

Characteristic equations

For a homogeneous second-order recurrence with constant coefficients,

an=C1an−1+C2an−2,a_n=C_1a_{n-1}+C_2a_{n-2}, an​=C1​an−1​+C2​an−2​,

try an exponential solution an=xna_n=x^nan​=xn, motivated by the geometric solutions of first-order recurrences. Substitution gives

xn=C1xn−1+C2xn−2.x^n=C_1x^{n-1}+C_2x^{n-2}. xn=C1​xn−1+C2​xn−2.

For a genuine second-order recurrence, C2≠0C_2\ne0C2​=0. A characteristic root is then nonzero, so dividing by xn−2x^{n-2}xn−2 gives the characteristic equation

x2−C1x−C2=0.x^2-C_1x-C_2=0. x2−C1​x−C2​=0.

For the Fibonacci recurrence, this is

x2−x−1=0.x^2-x-1=0. x2−x−1=0.

Its roots are

φ=1+52,φˉ=1−52.\varphi=\frac{1+\sqrt5}{2}, \qquad \bar\varphi=\frac{1-\sqrt5}{2}. φ=21+5​​,φˉ​=21−5​​.

The symbol φ\varphiφ is the golden ratio. The second root φˉ\bar\varphiφˉ​ is negative and has magnitude below one.

A single exponential cannot usually satisfy two independent base cases. With two distinct roots, their exponential sequences are linearly independent. A second-order recurrence is determined by two initial values, so these two independent solutions span every solution:

fn=Aφn+Bφˉn.f_n=A\varphi^n+B\bar\varphi^n. fn​=Aφn+Bφˉ​n.

The base cases give the system

1=A+B,2=Aφ+Bφˉ.1=A+B, \qquad 2=A\varphi+B\bar\varphi. 1=A+B,2=Aφ+Bφˉ​.

Solving it yields

A=5+325,B=5−325.A=\frac{\sqrt5+3}{2\sqrt5}, \qquad B=\frac{\sqrt5-3}{2\sqrt5}. A=25​5​+3​,B=25​5​−3​.

Therefore,

fn=5+325φn+5−325φˉn.\boxed{ f_n= \frac{\sqrt5+3}{2\sqrt5}\varphi^n + \frac{\sqrt5-3}{2\sqrt5}\bar\varphi^n }. fn​=25​5​+3​φn+25​5​−3​φˉ​n​.

Equivalently,

fn=φn+2−φˉn+25.f_n=\frac{\varphi^{n+2}-\bar\varphi^{n+2}}{\sqrt5}. fn​=5​φn+2−φˉ​n+2​.

Since ∣φˉ∣<1|\bar\varphi|<1∣φˉ​∣<1, this is also the nearest integer to the dominant term:

fn=⌊φn+25+12⌋.f_n=\left\lfloor\frac{\varphi^{n+2}}{\sqrt5}+\frac12\right\rfloor. fn​=⌊5​φn+2​+21​⌋.

Because φ>1\varphi>1φ>1 while ∣φˉ∣<1|\bar\varphi|<1∣φˉ​∣<1, the first term controls long-run growth and the second term shrinks in magnitude while alternating sign.

Fibonacci growth from characteristic roots

Shifted Fibonacci growth and conjugate-root correctionThe upper panel compares shifted Fibonacci values with the dominant characteristic-root term. The lower panel magnifies the small conjugate-root correction, which alternates in sign and shrinks toward zero.Sequence growthAlternating correction term0246810120100200300400-0.20.00.2Index
  • fn​recurrence values
  • Aφndominant-root term
  • Bφˉ​nconjugate-root correction
The root φ is greater than one. In the upper panel, Aφn controls the visible growth while the points mark the exact recurrence values. The lower panel magnifies Bφˉ​n, showing why the correction alternates in sign and shrinks toward zero.

A second characteristic-root example

Consider

{an=an−1+2an−2,a0=2,a1=7.\begin{cases} a_n=a_{n-1}+2a_{n-2},\\ a_0=2,\\ a_1=7. \end{cases} ⎩⎨⎧​an​=an−1​+2an−2​,a0​=2,a1​=7.​

The characteristic equation is

x2−x−2=0,x^2-x-2=0, x2−x−2=0,

with roots r1=−1r_1=-1r1​=−1 and r2=2r_2=2r2​=2. Hence

an=A(−1)n+B2n.a_n=A(-1)^n+B2^n. an​=A(−1)n+B2n.

The base cases give

2=A+B,7=−A+2B,2=A+B, \qquad 7=-A+2B, 2=A+B,7=−A+2B,

so A=−1A=-1A=−1 and B=3B=3B=3. The closed form is

an=−(−1)n+3⋅2n.\boxed{a_n=-(-1)^n+3\cdot2^n}. an​=−(−1)n+3⋅2n​.

What changes in other cases?

  • Repeated root: if the characteristic polynomial has one double root rrr, the independent basis solutions are rnr^nrn and nrnnr^nnrn. Thus the general form is (A+Bn)rn(A+Bn)r^n(A+Bn)rn.
  • Complex roots: the same method works over the complex numbers; conjugate roots can be combined into a real sine-cosine form.
  • Nonhomogeneous recurrence: solve the homogeneous recurrence, find one particular solution, and add them: an=hn+pna_n=h_n+p_nan​=hn​+pn​.
  • Order greater than two: the method still works, but the degree of the characteristic polynomial matches the order. For example,
an=an−1+an−2−an−3a_n=a_{n-1}+a_{n-2}-a_{n-3} an​=an−1​+an−2​−an−3​

leads to

x3−x2−x+1=0.x^3-x^2-x+1=0. x3−x2−x+1=0.

The characteristic-polynomial shortcut requires a linear recurrence with constant coefficients. Variable coefficients or nonlinear terms need other methods.

Source: https://notes.ohevan.com/notes/discrete-structures/04-recurrence-relations

© 2026 Evan Luo. All rights reserved.

Back to Discrete Structures

0 reads

·Last edited Oct 19, 2026
  • newsletter

  • about me

  • sponsor

© 2026 Evan Luo. All rights reserved.