Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
The Fibonacci Numbers Dr. Liam Naughton 1 The Fibonacci Numbers The Fibonacci sequence is named after Leonardo of Pisa who is better known by the name Fibonacci. He coined the sequence as follows “A certain man put a pair of rabbits in a place surrounded by a wall. How many pairs of rabbits can be produced from that pair in a year if it is supposed that every month each pair begets a new pair from which the second month on becomes productive?” The sequence considers the growth of a (slightly unrealistic) population of rabbits. The rules governing the growth of the population of rabbits are as follows • A newborn pair of rabbits, one male, one female, are put in a field. • Rabbits are able to mate at the age of one month so that at the end of its second month a female can produce another pair of rabbits. • Rabbits never die and a mating pair always produces one new pair (one male, one female) every month from the second month on. Fibonacci asked, “how many pairs of rabbits will there be at the end of one year?” We analyse the problem as follows • At the end of month one the rabbits mate. There is still only 1 pair. • At the end of month two the female gives birth to a new pair. There are 2 pairs of rabbits. • At the end of month three, the original female gives birth to a second pair. There are 3 pairs of rabbits. • At the end of the fourth month, the original female gives birth to another new pair. The female born two months ago gives birth to a pair. There are 5 pairs of rabbits. We can visulise the population growth using the graphic below 1 At the end of the nth month, the number of pairs of rabbits is equal to the number of new pairs (which is the number of pairs in month n − 2) plus the number of pairs alive last month (n − 1). This is the nth Fibonacci number. The Fibonacci Sequences begins 0, 1 and continues according to the rule that each number in the sequences is the sum of the previous two numbers in the sequence. The first eight terms in the Fibonacci sequence are shown below 0, 1, 1, 2, 3, 5, 8, 13, . . . We use the notation Fn to represent the nth entry in the sequence so for example F0 F1 F2 F3 F4 F5 F6 .. . = = = = = = = .. . 0 1 0+1=1 1+1=2 1+2=3 2+3=5 3+5=8 .. . This notation enables us to write down a simple formula for the nth Fibonacci number Fn = Fn−1 + Fn−2 for n ≥ 2. This type of formula is often referred to as a textbfrecursive formula or as a recurrence relation, This is a nice formula but it has one unpleasant aspect. In order to calculate the bth Fibonacci number we need to know the previous two and when n is large this can be extremely tedious and time consuming. What we would really like is a formula for the nth Fibonacci number which doesn’t require such calculations. Such a formula could be considered a solution to the recurrence relation. In fact there is a formula which generates the nth Fibonacci number known as Binet’s Formula. It is beyond the scope of this course but the formula is given below. 2 Binet’s Fibonacci Formula The nth Fibonacci number is given by √ √ (1 + 5)n − (1 − 5)n √ . Fn = 2n 5 Those with a keen eye might recognize that this formula can be written as Fn = where φ = √ 1+ 5 2 φn − (−φ)−n √ , 5 the golden ratio! 3