Recursive Definitions
Recursive Definitions
A recursive definition describes an object by saying how to build it from smaller instances of itself. Instead of giving a formula for the 50th term of a sequence directly, you state where the sequence starts and how each new term follows from the ones before it. You meet this idea in sequences such as account balances and the Fibonacci numbers, in functions such as the factorial, and in sets such as the strings a program accepts. Recursive definitions are also the objects that proofs by induction are built to reason about.
The two parts of a recursive definition
A recursive definition has two parts:
- A base case that states one or more values outright.
- A recursive step that gives every other value in terms of values already defined.
When the object is a sequence, the recursive step is called a recurrence relation. For example:
Unwinding it one step at a time gives a1=2(3)+1=7, then a2=2(7)+1=15 and a3=2(15)+1=31. Each new term needs only the term before it, so one base case is enough.
The factorial function is defined the same way: 0!=1 and n!=n⋅(n−1)! for n≥1. Unwinding gives 4!=4⋅3!=4⋅3⋅2!=⋯=24.
A recurrence that reaches further back needs more starting values. The Fibonacci numbers satisfy Fn=Fn−1+Fn−2, which looks two terms back, so the definition must supply two base cases, F0=0 and F1=1, and the recursive step applies only for n≥2. With only F0 supplied, F1 remains unspecified. Attempting to extend the recurrence to n=1 would additionally reference F−1, an input outside the domain.
Recursive and explicit formulas
A recursive definition and an explicit, or closed-form, formula can describe the same sequence. The recursive form matches situations that change step by step, such as a monthly balance or a count of moves; the explicit form is faster when you need a distant term.
Sequence | Recursive definition | Explicit formula |
|---|---|---|
Arithmetic, common difference d | a0 given, an=an−1+d | an=a0+nd |
Geometric, common ratio r | a0 given, an=ran−1 | an=a0rn |
Example above | a0=3, an=2an−1+1 | an=2n+2−1 |
Fibonacci | F0=0, F1=1, Fn=Fn−1+Fn−2 | Exists, but involves 5 |
You can often guess an explicit formula by listing the first few terms. A guess is only a conjecture until it is shown to satisfy both the base case and the recursive step for every n; that confirmation is a proof by induction.
Recursively defined sets and functions
Sets can be built the same way. Define S by:
- Base case: 3∈S.
- Recursive step: if x∈S and y∈S, then x+y∈S.
- Exclusion rule: nothing is in S unless it comes from the base case by finitely many recursive steps.
Starting from 3 you get 3+3=6, then 3+6=9, and so on, so S is the set of positive multiples of 3. Without the exclusion rule, the set of all positive integers would also satisfy the first two rules, so the definition would not pin down a single set.
Strings work the same way. For an alphabet Σ, the set Σ∗ has the base case that the empty string λ is in Σ∗, and the recursive step that if w∈Σ∗ and x∈Σ, then wx∈Σ∗, the string w with the symbol x appended. For Σ={0,1}, one step gives 0 and 1, the next gives 00, 01, 10 and 11, and so on.
A recursive definition of a function is well defined only if every value traces back to a base case in finitely many steps. The rule h(0)=5 with h(n)=h(n+1)+2 for n≥1 fails: h(1) needs h(2), which needs h(3), and the chain never reaches h(0). A step does not have to move down by exactly one, though; it only has to move to a smaller input that eventually lands on a base case.
What to remember
- A recursive definition has a base case and a recursive step; for sequences the step is a recurrence relation.
- A recurrence that looks back k terms usually needs k base values.
- Check which index the base case uses before computing terms.
- A recursively defined set needs an exclusion rule so it contains only what the rules build.
- Every value must reach a base case in finitely many steps.
Example: A savings balance defined recursively
A student opens a savings account with $200. At the end of each month the bank adds 1% interest on the current balance, and then the student deposits another $50. Let Bn be the balance in dollars just after the deposit at the end of month n, with B0 the opening balance.
a) Write a recursive definition of Bn, giving both the base case and the recursive step.
Base case: before any month has passed, the balance is the opening deposit, so B0=200.
Recursive step: adding 1% interest multiplies the previous balance by ________, and the deposit then adds 50 dollars. Because interest is applied before the deposit, that month's 50 dollars earns no interest until the following month. For every month after the start:
One base case is enough because each balance depends only on the balance one month earlier.
b) Find the balance after three months, B3, to the nearest cent.
Apply the recursive step three times, starting from the base case and keeping full precision until the end.
- Month 1: B1=1.01(200)+50= ________ dollars.
- Month 2: B2=1.01(252)+50= ________ dollars.
- Month 3: B3=1.01(304.52)+50=307.5652+50=357.5652 dollars.
Rounded to the nearest cent, the balance after three months is $357.57.
c) In which month does the balance first exceed $500?
No explicit formula is needed: keep applying the recursive step from B3=357.5652 until the balance passes 500. Use the exact intermediate balances in every substitution and round only the reported dollar amounts.
- Month 4: B4=1.01(357.5652)+50=411.140852 dollars. Rounded to the nearest cent, this is ________ dollars.
- Month 5: B5=1.01(411.140852)+50=465.25226052 dollars, still below 500. Rounded to the nearest cent, this is ________ dollars.
- Month 6: B6=1.01(465.25226052)+50=519.9047831252 dollars, which is above 500. Rounded to the nearest cent, this is 519.90 dollars.
The balance first exceeds $500 at the end of month 6, after that month's deposit.
Check: each month adds the 50-dollar deposit plus about 4 dollars of interest, roughly 54 dollars in total, so rising from about 358 to more than 500 should take three more months after month 3, which agrees.
A sequence begins 2,6,18,54,… and its first term is labelled a1. Which recursive definition produces exactly this sequence, with every listed term in its correct position?