107. Functions with more than one starting point
The Fibonacci function is an example of a function defined in terms of two previous values (hence requiring two initial conditions):
107.1 Definition: Fibonacci function
The Fibonacci function $F\colon \mathrm{N} \to \mathrm{N}$ is defined by
$$\begin{cases} F(0) = 0 \\ F(1) = 1 \\ F (n ) =F (n- 1) +F (n-2) \end{cases} \tag{107.1}$$
107.1.1 Remarks
a) The Fibonacci function is called “Fibonacci” after Leonardo di Pisa, who described it in 1220 AD. He was the son (Fi, short for Figlio) of Bonaccio.
b) The Fibonacci function has traditionally been described as the formula for the number of pairs of rabbits you have after $n$ months under these assumptions: initially you have just one pair of rabbits, and every month each pair of rabbits over one month old have a pair of children, one male and one female. And none of them die.
Suppose you buy (trap?) the first pair of rabbits at the beginning of month 1. Then $F$(0) = 0 and $F$(1) = 1. At the $n$th month, $F$ must satisfy the equation
$$F (n ) =F (n- 1) +F (n- 2) \quad (n \geq 2)$$
since the $F (n-1)$ rabbits you had one month ago are still around and you have a new pair for each of the $F (n-2)$ pairs born two or more months ago.
This explanation bears no relation to reality since rabbits take six months, not one, to mature sexually, and they do not reliably produce one male and one female each gestation period.
107.1.2 Example The Perrin function is defined with three starting points:
$$\begin{cases} P(0) = 3 \\ P(1) = 0 \\ P(2) = 2 \\ P (n ) =P (n- 2) +P (n-3) \end{cases} \tag{107.2}$$
For integers larger than 1 up to a fairly large number, this function has the property
$$n\mid P (n )\Leftrightarrow n \text{ is prime.}$$
The smallest integer $>1$ for which this is false is apparently $271,441$, which is $521^{2}$, but I have not been able to check this.
A number $n$ for which $n\mid P (n)$ is called a Perrin pseudoprime.
107.2 Recurrence relations
Since the Fibonacci function has domain $\mathrm{N}$, it is the same as an infinite sequence (see Example 97.2.2). The values $F (0),F (1),F (2),\ldots$ are often called the Fibonacci numbers. When expressed in sequence notation, the definition becomes
$$\begin{cases} f_{0}= 0 \\ f_{1} = 1 \\ f_{n} =f_{n-1} +f_{n-2} \end{cases} \tag{107.3}$$
Fibonacci function is called a recurrence relation or simply a recurrence.
Sometimes, but not always, a function defined by a recurrence relation can be given a noninductive definition by a formula. Finding such a “closed form” definition is called solving the recurrence relation. We have already solved some recurrence relations. For example, the statement that the sum of the first $n$ odd integers is $n^{2}$ can be reworded to say that the solution to the recurrence relation
$$\begin{cases} s_{1} = 1 \\ s_{n+1} = 2n + 1 +s_{n} \end{cases} \tag{107.4}$$
is $s_{n} =n^{2}$.
If you can guess a solution to a recurrence relation, you can often prove it is correct by induction. Problem 107.3.11 gives a closed solution to the Fibonacci recurrence. Note that it would generally be better to calculate Fibonacci numbers for small $n$ using the recurrence relation rather that the complicated formula given in Problem 107.3.11.
107.3 Exercise set
Exercises 107.3.2 through 107.3.11 refer to the Fibonacci sequence.
107.3.1 Exercise Prove that for all nonnegative integers $n, f_{n+1}^{2} -f_{n}f_{n+2}=$ $(- 1)^{n}$. (Answer on page 249.)
107.3.2 Exercise Prove that for all nonnegative integers $n, f_{n}$ is even if and only if $3\mid n$.
107.3.3 Exercise Prove that for all [positive integers $n, f_{n+1} \mathbin{\mathrm{div}} f_{n}= 1$ and $f_{n+1} \mathbin{\mathrm{mod}} f_{n} =f_{n-1}$.
107.3.4 Exercise Prove that for all nonnegative integers $n$,
$$f_{n}f_{n+3} -f_{n+1}f_{n+2} = (- 1)^{n+1}$$
107.3.5 Exercise Prove that for all nonnegative integers $n$, GCD($f_{n+1},f_{n}) = 1$. (Hint: You can use Exercise 107.3.3, or you can look at Exercise 107.3.4 and meditate upon Bézout.)
107.3.6 Exercise Prove by induction that
$$\Sigma_{k=1}^{n}f_{k}^{2} =f_{n}f_{n+1}$$
107.3.7 Exercise Give a proof by induction on $n$ that for all $n\geq 0$,
$$f_{n+2} \geq \left(\frac{8}{5}\right)^{n}$$
(You can also prove this using Problem 107.3.11 below.)
107.3.8 Exercise Show that for all $n\geq 0,f_{n+1}^{2}-f_{n}f_{n+1} -f_{n}^{2} =\pm 1$.
107.3.9 Exercise (hard) (Matijasevich) Prove that if $x$ and $y$ are nonnegative integers such that $y^{2} -xy -x^{2} =\pm 1$, then for some nonnegative integer $n, x =f_{n}$ and $y =f_{n+1}$. (Be careful: You are not being asked to show that $\langle f_{n},f_{n+1}\rangle$ is a solution of the equation for each $n$ — that is what the Problem 107.3.8 asks for. You are being asked to show that no other pair of integers is a solution.)
107.3.10 Exercise (hard) (Matijasevich) Show that for all nonnegative integers $m$ and $n$, if $f_{m}^{2} \mid f_{n}$, then $f_{m}\mid n$.
107.3.11 Exercise (hard) Prove that for all nonnegative integers $n$,
$$f_{n} = (1/\sqrt{5})(r^{n} -s^{n})$$
where $r$ and $s$ are the two roots of the equation $x^{2}-x-1 = 0$ and $r > s$.
107.3.12 Exercise Let a function $F\colon \mathrm{N} \to \mathrm{N}$ be defined by
$$\begin{cases} F(0) = 0 \\ F(1) = 1 \\ F (n ) = 5F (n- 1)- 6F (n- 2) \quad (n >1) \end{cases}$$
Prove by induction that for all $n\geq 0,F (n ) = 3^{n} - 2^{n}$.
107.3.13 Exercise Define a function $F\colon \mathrm{N} \to \mathrm{N}$ by
$$\begin{cases} F (0) =F(1) = 1 \\ F (n ) = 2F (n- 1) +F (n-2) \qquad (n > 1). \end{cases}$$
Show
a) $F (n)$ is always odd.
b) $F (4k+ 2)$ is divisible by 3 for any integer $k \geq 0$.
107.3.14 Exercise (hard) (Myerson and van der Poorten [1995]) Define a function $G\colon \mathrm{N} \to \mathrm{N}$ by $G (1) =G (3) =G (5) = 0,G (0) =G (4) = 8,G$(2) = 9, and $G (n+$ $6) = 6G (n + 4)- 12G (n + 2) + 8G (n$) for $n >5$. Show that $G (n) = 0$ if $n$ is odd and
$$G (n ) = (n- 8)^{2} \cdot 2^{\frac{n-6}{2}}$$
otherwise.
107.3.15 Exercise (Myerson and van der Poorten [1995]) Define a function $G\colon \mathrm{N} \to \mathrm{Z}$ by $G (0) = 0,G (1) = 1,G (2) =-1$, and
$$G (n ) =-G (n- 1) +G (n- 2) +G (n-3)$$
for $n >2$. Show that
$$G (n) = \begin{cases} -\dfrac{n}{2} & n \text{ even} \\[1ex] \dfrac{n+1}{2} & n \text{ odd} \end{cases}$$
(Compare Exercise 94.1.4, page 136.)
Pages 160–163 of the book (PDF).