08 Sequences and Recurrences

A structured guide to describing sequences, simplifying sums, modeling and solving recurrence relations, using generating functions, and analyzing recursive algorithms.

Describing Sequences

A is an ordered list whose terms are indexed. It may be written as a0,a1,a2,…a_0,a_1,a_2,\ldots, or as a function a:N→Ra:\mathbb{N}\to\mathbb{R}. Always identify the starting index, because a formula based at 00 differs from one based at 11.

There are two common ways to describe a :

  • A gives a term directly. For example, an=3n+2a_n=3n+2 gives a0=2a_0=2, a1=5a_1=5, and a2=8a_2=8.

  • A gives initial value or values and a rule for obtaining later terms. For example,

a0=2,an=an−1+3(n≥1).a_0=2,\qquad a_n=a_{n-1}+3\quad(n\ge 1).

This produces 2,5,8,11,…2,5,8,11,\ldots. A recurrence rule alone is generally insufficient; the initial conditions identify which satisfies the rule.

Takeaway: Before manipulating a , determine its indexing convention and whether it is described directly or recursively.

Arithmetic and Geometric Patterns

Two important families are recognized by how neighboring terms are related.

An has constant difference dd:

an=a0+nd.a_n=a_0+nd.

The sum of its first n+1n+1 terms is

∑k=0nak=n+12(a0+an).\sum_{k=0}^{n}a_k=\frac{n+1}{2}(a_0+a_n).

A has constant ratio rr:

an=a0rn.a_n=a_0r^n.

For r≠1r\ne 1, the finite geometric sum is

∑k=0na0rk=a01−rn+11−r.\sum_{k=0}^{n}a_0r^k=a_0\frac{1-r^{n+1}}{1-r}.

If ∣r∣<1|r|<1, the infinite geometric series converges and

∑k=0∞a0rk=a01−r.\sum_{k=0}^{\infty}a_0r^k=\frac{a_0}{1-r}.

To classify a , subtract consecutive terms to test for an arithmetic pattern and divide consecutive terms, where defined, to test for a geometric pattern.

Takeaway: Constant differences lead to arithmetic formulas; constant ratios lead to geometric formulas and, under ∣r∣<1|r|<1, a useful infinite sum.

Summation Techniques

Summation notation compresses a list of additions:

∑k=mnf(k)=f(m)+f(m+1)+⋯+f(n).\sum_{k=m}^{n}f(k)=f(m)+f(m+1)+\cdots+f(n).

Linearity allows sums to be separated:

∑k=mn(cf(k)+dg(k))=c∑k=mnf(k)+d∑k=mng(k).\sum_{k=m}^{n}\bigl(cf(k)+dg(k)\bigr)=c\sum_{k=m}^{n}f(k)+d\sum_{k=m}^{n}g(k).

Important standard sums are

∑k=1nk=n(n+1)2,\sum_{k=1}^{n}k=\frac{n(n+1)}{2},
∑k=1nk2=n(n+1)(2n+1)6,\sum_{k=1}^{n}k^2=\frac{n(n+1)(2n+1)}{6},

and

∑k=1nk3=(n(n+1)2)2.\sum_{k=1}^{n}k^3=\left(\frac{n(n+1)}{2}\right)^2.

A sum telescopes when adjacent terms cancel. If f(k)=g(k+1)−g(k)f(k)=g(k+1)-g(k), then

∑k=mnf(k)=g(n+1)−g(m).\sum_{k=m}^{n}f(k)=g(n+1)-g(m).

For example,

∑k=1n(1k−1k+1)=1−1n+1=nn+1.\sum_{k=1}^{n}\left(\frac{1}{k}-\frac{1}{k+1}\right)=1-\frac{1}{n+1}=\frac{n}{n+1}.

Reindexing changes the index and its bounds together. Setting j=k−1j=k-1 gives

∑k=1nak−1=∑j=0n−1aj.\sum_{k=1}^{n}a_{k-1}=\sum_{j=0}^{n-1}a_j.

Takeaway: When simplifying a sum, use linearity, look for cancellation, and change bounds whenever the index changes.

Building Recurrence Models

A defines a term from earlier terms. Its order is the number of previous terms required. For example, an=4an−1−an−2a_n=4a_{n-1}-a_{n-2} has order 22. A recurrence becomes a complete only after enough initial conditions are supplied.

The Fibonacci illustrates this structure:

F0=0,F1=1,Fn=Fn−1+Fn−2(n≥2).F_0=0,\qquad F_1=1,\qquad F_n=F_{n-1}+F_{n-2}\quad(n\ge 2).

To model a counting problem with a recurrence:

  1. Define exactly what ana_n counts or measures.

  2. Partition the objects into disjoint cases.

  3. Relate each case to a smaller instance.

  4. State the initial conditions.

  5. Check the first few values.

For tilings of a 1×n1\times n board by squares of length 11 and dominoes of length 22, the final tile is either a square or a domino. Therefore,

an=an−1+an−2,a0=1,a1=1.a_n=a_{n-1}+a_{n-2},\qquad a_0=1,\quad a_1=1.

The value a0=1a_0=1 counts the one empty tiling.

Takeaway: A well-constructed recurrence comes from disjoint cases, smaller instances, and explicit initial conditions.

Solving Linear Recurrences

For a homogeneous linear recurrence with constant coefficients,

an=c1an−1+c2an−2+⋯+ckan−k,a_n=c_1a_{n-1}+c_2a_{n-2}+\cdots+c_ka_{n-k},

try a solution of the form an=rna_n=r^n. This produces the

rk−c1rk−1−c2rk−2−⋯−ck=0.r^k-c_1r^{k-1}-c_2r^{k-2}-\cdots-c_k=0.

If the roots r1,…,rkr_1,\ldots,r_k are distinct, the general solution is

an=C1r1n+C2r2n+⋯+Ckrkn.a_n=C_1r_1^n+C_2r_2^n+\cdots+C_kr_k^n.

The constants are found from the initial conditions. For example,

an=5an−1−6an−2,a0=1,a1=2a_n=5a_{n-1}-6a_{n-2},\qquad a_0=1,\quad a_1=2

has

r2−5r+6=(r−2)(r−3)=0.r^2-5r+6=(r-2)(r-3)=0.

Thus an=A2n+B3na_n=A2^n+B3^n. The initial conditions give A+B=1A+B=1 and 2A+3B=22A+3B=2, so A=1A=1, B=0B=0, and

an=2n.a_n=2^n.

If a root rr has multiplicity mm, its contribution is

(C0+C1n+⋯+Cm−1nm−1)rn.(C_0+C_1n+\cdots+C_{m-1}n^{m-1})r^n.

For a nonhomogeneous recurrence, write the solution as

an=an(h)+an(p),a_n=a_n^{(h)}+a_n^{(p)},

where the first term solves the associated homogeneous recurrence and the second is one particular solution. Choose the trial form for the particular solution from the shape of the forcing term; if it duplicates a homogeneous solution, multiply the trial by a sufficient power of nn.

Takeaway: Find the characteristic roots, construct the correct general form, and use initial conditions to determine its constants.

Generating Functions

An ordinary packages the terms of a into a formal power series:

A(x)=∑n=0∞anxn.A(x)=\sum_{n=0}^{\infty}a_nx^n.

To use this method, multiply the recurrence by xnx^n, sum over the valid indices, and express the resulting shifted sums in terms of A(x)A(x).

Consider

an=3an−1−2an−2,a0=1,a1=3.a_n=3a_{n-1}-2a_{n-2},\qquad a_0=1,\quad a_1=3.

Summing after multiplication by xnx^n gives

A(x)−1−3x=3x(A(x)−1)−2x2A(x).A(x)-1-3x=3x(A(x)-1)-2x^2A(x).

Solving for the yields

A(x)=11−3x+2x2=1(1−x)(1−2x).A(x)=\frac{1}{1-3x+2x^2}=\frac{1}{(1-x)(1-2x)}.

Partial fractions give

A(x)=−11−x+21−2x,A(x)=-\frac{1}{1-x}+\frac{2}{1-2x},

so the is

an=2n+1−1.a_n=2^{n+1}-1.

Generating functions are especially useful for counting problems and for recurrences whose algebra is difficult to handle directly.

Takeaway: Generating functions turn shifts in a recurrence into algebraic factors, allowing the to be recovered from a power-series identity.

Recursion in Algorithms and Counting

Recursion also describes algorithms. A recursive algorithm needs a , which is solved directly, and a recursive case, which reduces the input toward that .

For factorial,

0!=1,n!=n(n−1)!(n≥1).0!=1,\qquad n!=n(n-1)!\quad(n\ge 1).

If T(n)T(n) counts multiplication operations, then

T(n)=T(n−1)+1,T(0)=0,T(n)=T(n-1)+1,\qquad T(0)=0,

so T(n)=nT(n)=n. The running time is therefore linear in nn.

split a problem into smaller subproblems and combine their solutions. If a problem of size nn is divided into two subproblems of size approximately n/2n/2, a typical recurrence is

T(n)=2T(n/2)+cn.T(n)=2T(n/2)+cn.

This describes the pattern of merge sort: two recursive sorting calls followed by linear-time merging. Its running time is O(nlog⁡n)O(n\log n).

Recurrences also arise in counting. If sns_n counts lists with entries from {1,2,3}\{1,2,3\} whose entries sum to nn, classifying by the first entry gives

sn=sn−1+sn−2+sn−3,s_n=s_{n-1}+s_{n-2}+s_{n-3},

with s0=1s_0=1 and sn=0s_n=0 for n<0n<0.

Takeaway: To analyze a recursive process, identify its stopping condition, describe how one step reduces the problem, and translate that structure into a recurrence.