Method line M13 · When and why do we use it?

Recursion

In the Chinese book: 递推方法

Let aₙ be the answer for size n; split on the last element to get a recurrence.

📖 Chapter 13 of 《解题方法与策略》

One idea, one pictureIncrease n step by step. Are the sizes of the two piles always numbers that already appeared earlier in the table?

Loading figure…

In one sentence

Let be the answer for size . Instead of counting head-on, ask: what happens to the last element? In each case, once it is removed, what is left is often the same problem of size or .

So there are four steps: ① express what you want as ; ② work out the initial values by hand; ③ set up the recurrence; ④ get from the recurrence (by iterating, by the characteristic equation, or by computing up to the term you need).

Predict first

How many subsets of (including the empty set) contain no two consecutive integers?

Choose an answer first; then you can see the result.

Example: subsets with no two consecutive numbers

Step 1 / 5
Loading figure…
  1. Name the unknown, count the start

    Let be the number of subsets of with no two consecutive numbers. : .

Stop 1 · Counting finite sets: derangements (Vol. 1)

A rearrangement of in which no number stays in its original place is called a derangement. Again, look at where the last number goes, and who comes to position .

Example: the recurrence for the derangement numbers Dₙ

Step 1 / 5
Loading figure…
  1. Small cases

    , (), ().

Stop 2 · Linear recurrences and the characteristic equation (Vol. 5)

Once the recurrence is set up, if it is linear with constant coefficients, the characteristic equation gives the general term directly.

Example: how many strings of length n made of 0, 1, 2 have no two adjacent 0s?

Step 1 / 4
  1. Look at the last digit

    Call the number . If the last digit is or , the rest can be any good string: . If the last digit is , the one before it must be or : .

Stop 3 · Iteration of a function (Vol. 2)

is itself a recursion. The key is to find a quantity that makes this recursion simple.

One problem, several solutions

Let (). Find .

Guess, then prove

and . Guess . If it holds for , then .

CostYou need a few terms to see the pattern, then one induction.

Take reciprocals: an arithmetic recursion

Let . Since , we get with . So and .

CostSee through it at once, no guessing.

Stop 4 · Functional equations by recursion (Vol. 2)

For a functional equation on the positive integers, set one variable equal to and you get a recurrence for .

Example: f: N⁺ → R, f(1) = 1, f(m + n) = f(m) + f(n) + mn. Find f(n)

Step 1 / 3
  1. Set one variable to 1

    Put : .

Practice

Exercise 1Basic

How many subsets of (including the empty set) contain no two consecutive integers?

Exercise 2Basic

people each write a greeting card. The cards are put together, and each person takes one at random. In how many ways can this happen so that nobody gets the card they wrote?

Exercise 3Advanced

How many strings of length made of (the first digit may be ) contain no two adjacent s?

Exercise 4Challenge

There are circles in the plane; every two of them meet in two points, and no three pass through the same point. Into how many regions do they divide the plane?

Mistake Museum · Exhibits from this stop

Before you leave, look at the traps other people fell into here.See every exhibit in the museum →

Exhibit

The right recurrence with the wrong initial values

The wrong step: The number of subsets of with no two consecutive numbers satisfies , and , so .
What went wrong? Think first, then open

Diagnosis The empty set also qualifies. should be ( and ), and (). Once an initial value is wrong, every later term is wrong too: the correct value is .

The right step: Always count the initial values by hand from the definition, and say clearly whether the empty set counts. A recurrence that uses the two previous terms needs two initial values.

“Initial values are the foundation of a recursion; count them by hand”

Exhibit

A case left out of the split

The wrong step: Derangements: goes to some position ( choices); then has to go to position , and the remaining numbers are deranged, so .
What went wrong? Think first, then open

Diagnosis does not have to go to position . “ and swap” is only one case. In the other case does not go to position ; treat position as 's “forbidden” place and you get a derangement of numbers, contributing .

The right step: When splitting by the last element, check that the cases do not overlap and miss nothing, so together they make up everything. .

“The cases must add up to the whole”

Stops on this line

The same idea, used once in each of several places.

  1. Recursive SequencesVol. 5 Sequences and Mathematical Induction, ch. 7
  2. The Fibonacci SequenceVol. 5 Sequences and Mathematical Induction, ch. 9
  3. Finding the n-th IterateVol. 2 Functions and Functional Equations, §6.2
  4. Functional Equations: RecursionVol. 2 Functions and Functional Equations, §7.4
  5. Counting the Elements of a Finite SetVol. 1 Sets, ch. 3
  6. Guess, Then ProveVol. 5 Sequences and Mathematical Induction, ch. 14