Exploration for Fibonacci Numbers
In Mathematica, the Fibonacci numbers can be defined recursively as follows:
Caveat. When using
a recursion, a function call usually computes the value making all of
the necessary previous recursive steps. Sometimes it is
faster to store all the previous values so that a second function
call can use information previously calculated. If the
Mathematica function is written in the following way, it
includes this "remember" feature.
Without the "remember" feature the function is:
Global`F
|
Let us compute the Fibonacci number ![]()
The function can be viewed with the command:
Global`F
|
Now let us add the "remember" feature to the function:
![[Graphics:../Images/FibonacciSearchMod_gr_37.gif]](../Images/FibonacciSearchMod_gr_37.gif)
Let us compute the Fibonacci number ![]()
The function can be viewed with the command:
Global`F
|
We see that all of the Fibonacci numbers
through
are actually saved in Mathematica and if a second call to them
is made then the value will be retrieved from memory.
Another nice way to define the Fibonacci numbers is using a function
defined on subscripts.
Closed form formula for Fibonacci
numbers
Using the standard technique for solving a difference equation, it is
easy to show that
can be computed with the formula
![]()
Limit of the ratio
of Fibonacci numbers
The ratio of consecutive Fibonacci numbers is
![]()
The limit of this ratio is
as
shown by the computation
But this is just a disguised way of writing the
value
for
the "golden ratio."
Since the Fibonacci search uses the ratios
when n large
the two methods are almost identical.
Even for the small value
the
first six values of
are
very close to the golden ratio ![]()
(c) John H. Mathews 2004