ON THE FIBONACCI NUMBERS Prepared by Kei Nakamura The Fibonacci numbers are terms of the sequence defined in a quite simple recursive fashion. However, despite its simplicity, they have some curious properties which are worth attention. In this set of notes, we will look at some of the important features of these numbers. In the first half of the notes, our attention shall be paid to the relationship of the Fibonacci numbers and the Euclidean algorithm. The main theorem is that of Gabriel Lamé, which relates the complexity of the Euclidean algorithm with the Fibonacci numbers. In the second half of the notes, we will look at the Fibonacci numbers from linear algebraic point of view. Our treatment shall essentially be a glimpse of the more general theory of linear recurrence. 1 The Fibonacci Numbers Definition 1 The sequence {fn }∞ n=0 of natural numbers defined by the equations f0 = 0, f1 = 1, and fn+2 = fn+1 + fn is called the Fibonacci sequence or the sequence of the Fibonacci numbers. The n-th term in the sequence is called the n-th Fibonacci number. Despite its simplicity, the Fibonacci sequence yields some substantial results in relation to other topics in mathematics. In many cases, the theory surround√ ing the Fibonacci numbers would often involve a special number 21 (1 + 5). We will denote this number by ϕ in this set of notes without further mentioning. First, we will state some properties of this number ϕ in the following lemma. Lemma 2 For every natural number n, we have: 1) ϕn+2 = ϕn+1 + ϕn , and 2) (1 − ϕ)n+2 = (1 − ϕ)n+1 + (1 − ϕ)n . Proof: It is easy to verify ϕ2 = ϕ + 1 and (1 − ϕ)2 = (1 − ϕ) + 1 by calculating directly or by using the fact that ϕ and 1 − ϕ are solutions to the quadratic equation x2 − x − 1 = 0. Now, multiplying both sides of these equations by ϕn and (1 − ϕ)n respectively, we obtain the desired results. Note that the above equations resemble the equation fn+2 = fn+1 +fn , which we saw in the definition of the Fibonacci numbers. This resemblance turns out to be far from a coincidence. However, we will not discuss further about this for now, and treat the above lemma as just useful facts in computations. Besides this naive observation, a strong connection between the Fibonacci numbers and the number ϕ can be seen more explicitly in the next theorem, which gives an explicit formula for the Fibonacci number fn in terms of ϕ. Theorem 3 For every natural number n, fn = 1 √1 (ϕn 5 − (1 − ϕ)n ). Proof: We will prove this by an induction. First, as base cases, we will consider the cases when n = 0 and n = 1. It is easy to verify √1 (ϕ0 − (1 − ϕ)0 ) = √1 (1 − 1) = 0 = f0 , 5 5 √ √1 (ϕ1 − (1 − ϕ)1 ) = √1 (2ϕ − 1) = √1 ((1 + 5) − 1) = 1 = f1 , 5 5 5 so the statement is indeed true for n = 0 and n = 1. Now, as an induction hypothesis, suppose that fi = √15 (ϕi − (1 − ϕ)i ) for all i such that 0 ≤ i ≤ k +1. Using the previous lemma together with the definition of the Fibonacci numbers and the induction hypothesis, we compute fk+2 = fk+1 + fk = √15 (ϕk+1 − (1 − ϕ)k+1 ) + √15 (ϕk − (1 − ϕ)k ) = √15 ((ϕk+1 + ϕk ) − ((1 − ϕ)k+1 + (1 − ϕ)k )) = √15 (ϕk+2 − (1 − ϕ)k+2 ) as desired. Thus, by the mathematical induction principle, we conclude that fn = √15 (ϕn − (1 − ϕ)n ) for all natural number n. Corollary 4 For every natural number n, fn is the closest integer to √1 ϕn . 5 Proof: We saw fn = √15 (ϕn − (1 − ϕ)n ) = √15 ϕn − √15 (1 − ϕ)n . We would like to show that the second term is small in absolute value. Indeed, it suffices to show that this second term is less than 12 in absolute value. Note that √15 < 12 and |1 − ϕ| < 1. Thus, we observe | √15 (1 − ϕ)n | = √15 |1 − ϕ|n < 12 · 1n < 12 . It is clear from the above corollary that fn grows in somewhat exponential manner, in accordance with ϕn . The deviation of fn from √15 ϕn is measured by | √15 (1 − ϕ)n | = √15 |1 − ϕ|n . This decreases fairly quickly as n grows, since it is exponential. We should note fn is slightly more than or less than √15 ϕn , depending on whether n is odd or even. Another interesting connection between the Fibonacci numbers and ϕ is that the positive powers of ϕ are always between two consecutive Fibonacci numbers. This, in turn, gives upper bounds and lower bounds for most of the Fibonacci numbers in terms of powers of ϕ. We shall state this fact in the following lemma. Lemma 5 For every integer n such that n ≥ 1, we have fn+1 < ϕn < fn+2 . Proof: Again, we will prove this by an induction. First, as base cases, we will consider the cases when n = 1 and n = 2. Note that 1 < ϕ < 2. By adding 1 to each term in the inequality, we obtain 2 < ϕ + 1 < 3. The two inequalities together yield 1 < ϕ < 2 < ϕ + 1 < 3. Using the lemma and the first few Fibonacci numbers, we can write this as f2 < ϕ < f3 < ϕ2 < f4 which shows that the statement is true for n = 1 and n = 2. Now, as the induction hypothesis, suppose that fi+1 < ϕi < fi+2 for all i such that 0 ≤ i ≤ k + 1. In particular, we have 2 fk+2 < ϕk+1 < fk+3 and fk+1 < ϕk < fk+2 . Adding each term of the two inequalities, we obtain fk+2 + fk+1 < ϕk+1 + ϕk < fk+3 + fk+2 . Using the lemma and the definition of the Fibonacci numbers, we can rewrite this inequality as fk+3 < ϕk+2 < fk+4 which shows that the inequality holds for n = k + 2. Thus, by the mathematical induction principle, we conclude that fn+1 < ϕn < fn+2 for every natural number n such that n ≥ 1. 2 Euclidean Algorithm The greatest common divisor of a and b, denoted by gcd(a, b), is defined for integers a and b that are not both zero. The Euclidean Algorithm is a well known algorithm for computing this gcd(a, b), and is based on the following lemma. Indeed, the Euclidean Algorithm is essentially just repeated applications of this lemma. Lemma 6 Let a be an integer and b be a positive integer. Then, we have gcd(a, b) = gcd(b, (a mod b)) Proof: It suffices to show that the set of common divisors of a and b coincides with the set of common divisors of b and (a mod b). Recall that the division theorem gives a = bq + (a mod b). Now, suppose d divides a and b. Then, d also divides a − bq = (a mod b). Thus, a common divisor of a and b must be a common divisor of b and (a mod b). On the other hand, suppose d divides b and (a mod b). Then, d divides bq + (a mod b) = a. Thus, a common divisor of b and (a mod b) must be a common divisor of a and b. Suppose we wish to compute gcd(a, b). Before describing the Euclidean Algorithm, we will make a few remarks on a few basic properties of the gcd which follows from the definition. Those properties are the following: (i) gcd(a, b) = gcd(b, a), (ii) gcd(a, −b) = gcd(a, b), and (iii) if a > 0 then gcd(a, 0) = a. Those three properties together allows us to reduce the computation to the case where a ≥ 0 and b ≥ 0 with one of them nonzero. We will assume these conditions henceforth. Now, we describe the Euclidean algorithm. First, if b = 0, then we know that a > 0 and gcd(a, b) = a. If b 6= 0, then we apply the above lemma, and thus it follows that gcd(a, b) = gcd(b, (a mod b)). Notice that b > (a mod b) ≥ 0, since (a mod b) is indeed the remainder in the division theorem. So, if we apply the lemma repeatedly, the second arguments will strictly decrease each time in the repetition. Of course, the second argument eventually reaches zero. Then, the last gcd(r̃, 0) would be equal to the first argument r̃. Tracing back the series of equality, this number is indeed gcd(a, b). 3 This procedure eventually terminates because the repetition will stops when the strictly decreasing sequence of the nonnegative second arguments reaches zero. Also, each step is precisely defined computation. So it is, of course, an algorithm. Here are some examples. gcd(8, 5) = gcd(5, 3) = gcd(3, 2) = gcd(2, 1) = gcd(1, 0) = 1 gcd(70, 28) = gcd(28, 14) = gcd(14, 0) = 14 gcd(12, 42) = gcd(42, 12) = gcd(12, 6) = gcd(6, 0) = 6 gcd(0, 91) = gcd(91, 0) = 91 The repeated application of the lemma in this algorithm makes it suitable for a recursive definition. Namely, we can view the Euclidean Algorithm as calling itself recursively in a specific manner until the second argument is zero. Here is one coded example of the definition of Euclidean algorithm. In this syntax, % is the modulus as usual, and $ [i ] is the (i +1)-st element of the input array. sub gcd { if ($ [1]) { return gcd($ [1], $ [0] % $ [1]) } else { return $ [0] } } 3 Lamé’s Theorem In this section, we will investigate the worst case complexity of the Euclidean Algorithm. Theorem by Gabiel Lamé gives a way to relate the complexity of the Euclidean Algorithm to the Fibonacci numbers as we shall see presently. As we will see later in the corollary to the theorem, the complexity can indeed be calculated in terms of a logarithm in the Big-O notation. Before stating the theorem, let us remark the following. First, the Euclidean Algorithm can be applied to any non-negative integers a and b such that not both zero. Obviously, we can further enforce the condition a ≥ b by choosing a to be the maximum of two numbers. Second, there are a few cases where the number of recursive calls in Euclidean Algorithm to find gcd(a, b) is obvious. If b = 0, then there is no recursive calls. If a = b, then gcd(a, a) = gcd(a, 0) = a, so the Euclidean Algorithm requires exactly one call for any a. So, we may look at slightly more restrictive conditions a ≥ b > 0 or a > b ≥ 0. Under those conditions, it is redundant to state a and b are not both zero, since such case is impossible anyway. In many books, the condition used is a ≥ b > 0 for the Euclidean Algorithm. This is the case in Rosen, too. I shall state Lamé’s theorem in accordance with this condition. Note that our version of Lamé’s theorem is somewhat different from the one found in Rosen. The statement in Rosen indeed follows from our version of the theorem, as we will see in the corollary. For the simplicity, I will 4 use the notation E(a, b) to mean the number of recursive calls required in the Euclidean algorithm to find gcd(a, b). Theorem 7 (Lamé) Suppose a, b be integers such that a ≥ b > 0. For any natural number n, we have E(a, b) < n whenever b < fn+1 or a < fn+2 Proof: First, we remark that it suffices to prove the contrapositive statement. Namely, it is enough to prove that, for any natural number n, we have b ≥ fn+1 and a ≥ fn+2 whenever E(a, b) ≥ n. We will do this by the mathematical induction. First we consider the base case with n = 0. Suppose E(a, b) ≥ n = 0. Since b > 0 from our premise, we actually know that b ≥ 1 anyway. Also as a premise, we supposed a ≥ b, so a ≥ 1. Note that 1 = f1 = f2 . So, we indeed have b ≥ 1 = f0+1 and a ≥ 1 = f0+2 . Namely, the statement holds for n = 0. Now, as an induction hypothesis, suppose that our statement is true for n = k. Namely, suppose that E(a.b) ≥ k implies b ≥ fk+1 and a ≥ fk+2 for natural number k. We wish to show that the statement is true for n = k + 1. Namely, we wish to show E(a, b) ≥ k + 1 implies b ≥ fk+2 and a ≥ fk+3 . Suppose E(a, b) ≥ k + 1. Note that this implies E(a, b) is positive. Thus, we can indeed look at the result of the first recursive call. One recursive call gives gcd(a, b) = gcd(a, a mod b). Let ã = b and b̃ = a mod b. Note that gcd(ã, b̃) requires one less recursive calls than gcd(a, b). So, gcd(ã, b̃) requires E(a, b) − 1 recursive calls. Since E(a, b) ≥ k +1 by our supposition, we have E(a, b)−1 ≥ k. Then, by the induction hypothesis, it follows that fk+1 ≤ b̃ = a mod b and fk+2 ≤ ã = b. It remains to show that a ≥ fk+3 . The division algorithm gives a = bq + (a mod b). From our premise, we know a ≥ b. It follows that q ≥ 1 in the above equation of the division theorem. So, we have a = bq + (a mod b) ≥ b + (a mod b) ≥ fk+2 + fk+1 = fk+3 . This completes the proof. Now, the next corollaries to the theorem allows us to express the worst case complexity of Euclidean Algorithm in terms of the Big-O notations and in terms of number of decimal digits. To state the result rigorously using the Big-O notation, there are a few things we need to be careful. In the definition of the Big-O, we find that we can use the phrase f (x) is O(g(x)) if f and g are functions from R or Z to R. Since the Big-O essentially concerns with the relationship between the behaviours of f (x) and g(x) for arbitrarily large x, we can indeed extend the definition of the Big-O for functions f and g which are from {x ∈ R | x ≥ c} or {x ∈ Z | x ≥ c} to R where c is some real constant. We can also use > in place of ≥ in the definition of the restricted domains. Now, the number of recursive calls, E(a, b), can be regarded as a function of a and b, where a and b are positive integers such that a ≥ b. In order to make a Big-O statement with a as a variable, we need to somehow regard E(a, b) as a function of a only. To do this, we can fix b = b0 . Then, for each b0 > 0, E(a, b0 ) 5 can be regarded as a function of a, where the domain is {a ∈ Z | a ≥ b0 }. By the above remark, then it make sense to discuss the Big-O of E(a, b0 ). The corresponding consideration of E(a, b) with respect to the variable b requires a bit more care, if we wish to talk about the Big-O notion with respect to b. If we fix a = a0 , then the domain of this function E(a0 , b) of b would be {b ∈ Z | a0 ≥ b > 0}. The problem is that b is not allowed to take values greater than this fixed a0 . This prevents us from making sense out of the Big-O notion. So, alternatively, we consider a sequence {ab }∞ b=1 which satisfies ab ≥ b for all b. For any such sequence, E(ab , b) is defined and can be regarded as a function of b, where the domain is {b ∈ Z | b > 0}. Then, it makes sense to discuss the Big-O of E(ab , b). Corollary 8 The worst case complexity of E(a, b) can be stated as follows: 1) For any fixed integer b0 > 0, E(a, b0 ) as a function of a is O(log a). 2) If {ab }∞ b=1 is a sequence such that ab ≥ b for each b, then E(ab , b) as a function of b is O(log b). Proof: For the first statement, let n = E(a, b0 ) where a is some positive integer such that a ≥ b0 . Then, by the contrapositive of the Lamé’s theorem, we obtain a ≥ fn+2 . Note that fn+2 > ϕn from the previous lemma, so it follows that a > ϕn . Taking logϕ of both sides, we have logϕ a > logϕ ϕn = n = E(a, b0 ) which indicates that E(a, b0 ) is indeed O(log a). Now for the second statement, let {ab }∞ b=1 be a sequence such that ab ≥ b for each b. Now let n = E(ab , b) where b is some positive integer. Then, again by the contrapositive of the Lamé’s theorem, we obtain b ≥ fn+1 . Note that we have fn+1 > ϕn−1 from the previous lemma, so it follows that b > ϕn−1 . Taking the logϕ of both sides, we have logϕ b > logϕ ϕn−1 = (n − 1), thus, logϕ b + 1 > n. Since the constant term 1 has no growth, this indicates that E(ab , b) is indeed O(log b). Corollary 9 The upper limit of E(a, b) can be given as follows: 1) 5da > E(a, b) where da is the number of decimal digits in a, 2) 5db ≥ E(a, b) where db is the number of decimal digits in b. Proof: Let a and b be integers such that a ≥ b > 0. In the same manner as in the proof of the last corollary, we have a > ϕn b > ϕn−1 . Now, taking log10 of both sides, and using the fact that log10 ϕ > 15 , we have log10 a > log10 ϕn = n log10 ϕ > 15 n log10 b > log10 ϕn−1 = (n − 1) log10 ϕ > 15 (n − 1). Thus, by simple manipulation, we obtain 5 log10 a > n = E(a, b) 6 5 log10 b + 1 > n = E(a, b). The number of decimal digits in a and b are given by da = blog10 ac + 1 and db = blog10 bc + 1 respectively. We also know log10 a = blog10 ac + εa where 0 ≤ εa < 1 log10 b = blog10 bc + εb where 0 ≤ εb < 1. Thus, da > log10 a and db > log10 b. Thus, combined with the above result, we have 5da > 5 log10 a > E(a, b) 5db + 1 > 5 log10 b > E(a, b). Note that E(a, b) is an integer, so the second inequality indeed implies that 5db ≥ E(a, b). 4 More on the Fibonacci Numbers In the previous sections, we saw the number ϕ repeatedly. In particular, we had an explicit formula fn = √15 (ϕn − (1 − ϕ)n ) for the Fibonacci numbers. It is natural to wonder how and from where this number ϕ arose. In this section, we will investigate the relationship between the Fibonacci numbers and the number ϕ. The material is essentially covered in §5.2 of Rosen. We will use linear algebra a little more explicitly. Lemma 10 Let A be a 2 by 2 matrix and u0 be a 2 by 1 matrix, given by 1 1 1 A= and u0 = . 1 0 0 Suppose uk is defined recursively by uk = Auk−1 . Then, for all n ∈ N, we have fn+1 n un = A u0 = fn where fn is the n-th Fibonacci number. Proof: It is easy to verify the first equality un = An u0 . With the convention A0 = I, the equality holds for the base case n = 0. As an induction hypothesis, suppose the equality holds for n = k − 1, namely uk−1 = Ak−1 u0 ; then, by the definition of uk and the induction hypothesis, we have uk = A(Ak−1 u0 ) = Ak u0 . Thus, by the mathematical induction, the equality holds for all n ∈ N. We will show the remaining also by the mathematical induction. Again, as a base case, we consider the case when n = 0. This is trivial, as we see 1 f1 f0+1 u0 = = = . 0 f0 f0 Now, as an induction hypothesis, suppose the statement is true for n = k − 1. Namely, suppose fk uk−1 = . fk−1 7 Then, by the definition of uk and the definition of the Fibonacci numbers, we have 1 1 fk fk + fk−1 fk+1 uk = Auk−1 = = = , 1 0 fk−1 fk fk so the statement is true for the case n = k. Thus by the principle of mathematical induction, we conclude that the statement holds for all natural number n. In the view of the equation above lemma, all the Fibonacci numbers can be derived from the powers of the matrix A. So, it would be of our interest to find a mean to compute Ak . This is where linear algebra comes into play. We will conclude this section by giving an alternative proof to the theorem from the previous section. In this proof, the number ϕ arises naturally as an “eigenvalue” of the matrix A. Proof of Theorem 3: As observed in the last lemma, the second component of un = An u0 is fn . Using techniques from linear algebra, we can indeed compute An as follows. First, we take the determinant of A − λI. This yields a polynomial called characteristic polynomial. The actual computation gives 1−λ 1 det(A − λI) = det = (1 − λ)(−λ) − 1 = λ2 − λ − 1. 1 −λ The associated characteristic equation is obtained by equating the characteristic polynomial with 0. So, in our case, it is λ2 − λ − 1 = 0. The eigenvalues for the matrix A are indeed the roots of this equation. By the quadratic formula, √ we find λ = 12 (1 ± 5). Namely, the eigenvalues of A are precisely ϕ and 1 − ϕ. Then, we can find the eigenvectors corresponding each of the eigenvalues. We obtain 1−ϕ 1 xϕ 0 xϕ ϕ = when = 1 −ϕ yϕ 0 yϕ 1 1 − (1 − ϕ) 1 x1−ϕ 0 x1−ϕ 1−ϕ = when = 1 −(1 − ϕ) y1−ϕ 0 y1−ϕ 1 We would like to express u0 as a linear combination of those eigenvectors vϕ and v1−ϕ , so that the multiplication by any power of A would split nicely. Therefore, we need to solve a vector equation u0 = αvϕ + βv1−ϕ . In a matrix form, we have ϕ 1−ϕ α 1 = . 1 1 β 0 The 2×2 matrix that appear in the above equation is nonsingular since ϕ 6= 1−ϕ. So, we can solve this equation for α and β, and we find that α = √15 and β = − √15 . 8 We can now compute un very efficiently, using the definition of the eigenvalues and the corresponding eigenvectors, together with the linearity of the matrix multiplication. Computation yields un = An u0 = An (αvϕ + βv1−ϕ ) = An (αvϕ ) + An (βv1−ϕ ) = αAn vϕ + βAn v1−ϕ = αϕn vϕ + β(1 − ϕ)n v1−ϕ . The second component of this vector un is indeed fn . Since the second components of vϕ and v1−ϕ are both just 1, we compute fn = αϕn yϕ + β(1 − ϕ)n y1−ϕ = αϕn + β(1 − ϕ)n = √15 (ϕn − (1 − ϕ)n ) which is the formula we desired. 5 Towards the Generalization The methods we used in the last section to find the explicit formula for the Fibonacci numbers can be applied to the more general class of sequences which contains the Fibonacci sequence. Such class of interest consists of sequences which are solutions to some linear recurrence relations, namely the sequences defined by some linear recurrence relation together with some initial values. Indeed, we could investigate the various properties of linear recurrence relations and its solutions using linear algebra. The generalization shall allow us to tie many of our previous results on the Fibonacci numbers together in the larger context, and to develop better understanding of the Fibonacci numbers. As we saw the flavour of such theory already in this set of notes, linear algebra would be the essential tool for this approach. The concrete results from the studies in this direction were introduced in §5.2 of Rosen. However, since the book does not assume readers’ knowledge in linear algebra, many of the results were stated without proofs and the exposition does not provide the overview of the underlying theory in depth. If one does understand some of the elementary linear algebra, it may be advisable to seek some further exposure to the subject. 9