Recursion

Introduction

Recursion is a fundamental technique in mathematics and computer science where an object is defined in terms of itself. A recursive definition has two essential components: base cases that provide concrete values, and recursive cases that express larger instances in terms of smaller ones.

Recursive thinking appears throughout mathematics: the factorial function, Fibonacci numbers, tree structures, fractal geometry, and mathematical induction all rely on recursive principles. Understanding recursion deeply opens doors to elegant problem-solving and algorithm design.

Recursive Definitions

Structure of Recursive Definitions

A recursive definition consists of:

  1. Base case(s): Explicitly defined values for the smallest inputs

  2. Recursive case(s): Rules expressing ƒ⁡(n) f with hook of n in terms of ƒ⁡(k) f with hook of k for k<n k is less than n

The Factorial Function

The factorial n! n factorial counts permutations of n n objects. It is defined recursively:

n!={1if n=0n⋅(n−1)!if n≥1 n factorial equals 2 cases Case 1: 1 if n equals 0 Case 2: n times open paren n minus 1 close paren factorial if n is greater than or equal to 1

Fibonacci Numbers

The Fibonacci sequence is defined by:

Fn={0if n=01if n=1Fn−1+Fn−2if n≥2 F sub n equals 3 cases Case 1: 0 if n equals 0 Case 2: 1 if n equals 1 Case 3: F sub n minus 1 plus F sub n minus 2 if n is greater than or equal to 2

This gives the sequence: 0,1,1,2,3,5,8,13,21,34,…​ 0 comma 1 comma 1 comma 2 comma 3 comma 5 comma 8 comma 13 comma 21 comma 34 comma dot dot dot

Solving Recurrence Relations

A recurrence relation expresses each term of a sequence in terms of previous terms. Finding a closed-form solution means expressing an a sub n directly as a function of n n

Linear Homogeneous Recurrences

For a recurrence an=c1⁢an−1+c2⁢an−2+⋯+ck⁢an−k a sub n equals c sub 1 a sub n minus 1 plus c sub 2 a sub n minus 2 plus dot dot dot plus c sub k a sub n minus k form the characteristic equation:

xk=c1⁢xk−1+c2⁢xk−2+⋯+ck x to the k-th power equals c sub 1 x raised to the k minus 1 power plus c sub 2 x raised to the k minus 2 power plus dot dot dot plus c sub k

If r1,r2,…,rk r sub 1 comma r sub 2 comma dot dot dot comma r sub k are distinct roots, the general solution is:

an=α1⁢r1n+α2⁢r2n+⋯+αk⁢rkn a sub n equals alpha sub 1 r sub 1 to the n-th power plus alpha sub 2 r sub 2 to the n-th power plus dot dot dot plus alpha sub k r sub k to the n-th power

The constants αi alpha sub i are determined by initial conditions.

Example: Solving the Fibonacci Recurrence

For Fn=Fn−1+Fn−2 F sub n equals F sub n minus 1 plus F sub n minus 2 the characteristic equation is x2=x+1 x squared equals x plus 1 or x2−x−1=0 x squared minus x minus 1 equals 0

The roots are ϕ=1+52 phi equals the fraction with numerator 1 plus the square root of 5 and denominator 2 (the golden ratio) and ϕ^=1−52 phi hat equals the fraction with numerator 1 minus the square root of 5 and denominator 2

Using initial conditions F0=0 F sub 0 equals 0 and F1=1 F sub 1 equals 1 we get Binets formula:

Fn=ϕn−ϕ^n5=15⁢[(1+52)n−(1−52)n] F sub n equals the fraction with numerator phi to the n-th power minus phi hat to the n-th power and denominator the square root of 5 equals the fraction with numerator 1 and denominator the square root of 5 times open bracket open paren the fraction with numerator 1 plus the square root of 5 and denominator 2 close paren to the n-th power minus open paren the fraction with numerator 1 minus the square root of 5 and denominator 2 close paren to the n-th power close bracket

Recursion and Mathematical Induction

Recursion and induction are deeply connected. A recursive definition provides a natural framework for inductive proofs: the base case of induction corresponds to the base case of the recursion, and the inductive step uses the recursive structure.

To prove a property P⁡(n) P of n about a recursively defined sequence:

  1. Prove P⁡(0) P of 0 (or the base cases)

  2. Assuming P⁡(k) P of k for all k<n k is less than n prove P⁡(n) P of n using the recursive definition

Recursive Structures

Trees

A binary tree is recursively defined as: either empty, or a node with a left subtree and a right subtree (each of which is a binary tree). This definition enables recursive algorithms for tree traversal, searching, and manipulation.

Fractals

Fractals like the Sierpinski triangle and Koch snowflake are defined recursively. Each iteration applies a rule to every part of the current figure, creating self-similar patterns at all scales.

Computational Considerations

Naive recursive implementations can be inefficient. Computing Fn F sub n directly from the definition requires O⁡(ϕn) O of open paren phi to the n-th power close paren operations due to redundant computations.

Memoization (caching results) or dynamic programming (building up from base cases) reduces this to O⁡(n) O of n The closed form gives O⁢(log⁡n) O times log n using fast exponentiation.

The Master Theorem

For divide-and-conquer recurrences of the form T⁡(n)=a⁢T⁢(n/b)+ƒ⁡(n) T of n equals a T times open paren n divided by b close paren plus f with hook of n the Master Theorem provides asymptotic solutions based on comparing ƒ⁡(n) f with hook of n with nlogb⁡a n raised to the log base b of a power

Summary

Recursion defines objects in terms of simpler versions of themselves. Base cases anchor the definition; recursive cases build complexity from simplicity.

Linear recurrences can be solved via characteristic equations. Recursion connects deeply to mathematical induction, providing both proof techniques and computational algorithms.

Recursive thinking is essential in discrete mathematics, algorithm design, and the study of data structures. Mastering recursion means understanding how complex structures emerge from simple rules applied repeatedly.