BIT152 ยท 2082 ยท 5 marks
Solve the recurrence relation an = an-1 + an-2 with initial conditions a0 = 0 and a1 = 1.
Solve the recurrence relation $a_n = a_{n-1} + a_{n-2}$ with initial conditions $a_0 = 0$ and $a_1 = 1$. [5]
Solving the Recurrence Relation $a_n = a_{n-1} + a_{n-2}$
Given Data
- Recurrence: $a_n = a_{n-1} + a_{n-2}$
- Initial conditions: $a_0 = 0$, $a_1 = 1$
Step 1: Characteristic Equation
This is a linear homogeneous recurrence with constant coefficients. Assume $a_n = r^n$:
$$r^n = r^{n-1} + r^{n-2}$$
Divide by $r^{n-2}$:
$$r^2 = r + 1 \implies r^2 - r - 1 = 0$$
Step 2: Solve for the Roots
$$r = \frac{1 \pm \sqrt{1 + 4}}{2} = \frac{1 \pm \sqrt{5}}{2}$$
$$r_1 = \frac{1 + \sqrt{5}}{2}, \qquad r_2 = \frac{1 - \sqrt{5}}{2}$$
Since the roots are distinct and real.
Step 3: General Solution
$$a_n = A\left(\frac{1+\sqrt{5}}{2}\right)^n + B\left(\frac{1-\sqrt{5}}{2}\right)^n$$
Step 4: Apply Initial Conditions
$a_0 = 0$: $$A + B = 0 \implies B = -A$$
$a_1 = 1$: $$A\left(\frac{1+\sqrt{5}}{2}\right) + B\left(\frac{1-\sqrt{5}}{2}\right) = 1$$
Substitute $B = -A$:
$$A\cdot\frac{(1+\sqrt5)-(1-\sqrt5)}{2} = 1 \implies A\cdot\frac{2\sqrt5}{2}=1 \implies A\sqrt5 = 1$$
$$A = \frac{1}{\sqrt5}, \qquad B = -\frac{1}{\sqrt5}$$
Step 5: Closed-Form Solution
$$\boxed{a_n = \frac{1}{\sqrt{5}}\left(\frac{1+\sqrt{5}}{2}\right)^n - \frac{1}{\sqrt{5}}\left(\frac{1-\sqrt{5}}{2}\right)^n}$$
This is Binet's Formula for the Fibonacci numbers.
Verification
| $n$ | Formula value | Recurrence value |
|---|---|---|
| 0 | 0 | 0 โ |
| 1 | 1 | 1 โ |
| 2 | 1 | 1 โ |
| 3 | 2 | 2 โ |
| 4 | 3 | 3 โ |
The sequence produced is the Fibonacci sequence $0, 1, 1, 2, 3, 5, 8, \ldots$
Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.