Question: Please answer #4 using Mathematica The Fibonacci numbers F(n) are determined by the following recursive relation: F(0) 0 E(1)= 1 F(n) F(n-1)+F(n-2) for n>1 1.
The Fibonacci numbers F(n) are determined by the following recursive relation: F(0) 0 E(1)= 1 F(n) F(n-1)+F(n-2) for n>1 1. Use Mathematica to give a recursive definition of the Fibonacci numbers: see the MathematicaR documentation on how to define functions in Mathematica, and see also this further documentation giving an example of a recursively defined function. 2. From the recursive definition, compute F[2], F[3], F[4] and F[5] 3. Calculate and plot Fn) for 0 Sn 20 4. Time how long it takes Mathematica to compute the F[n] up to F[30] T-TablelTiminglF[nll, In, 0, 303] gives a table (named T) of times taken, and the values computed Extract just the times taken as TIIAll,1l and ListPlot these times. What do you notice? Apply the (natural) logarithm function Log to the list of times and ListPlot that. What do you notice? What does this suggest about the time it takes to compute the nth Fibonacci number from the given recursive definition? We can speed up the time takes to calculate the Fibonacci numbers by getting Mathematica to remember previously calculated values. It does this by placing those values in an associative array-a look-up table which it can access rapidly Fibl00; Repeat the timings experiment for calculating Fibn], for n from 0 through 30, and ListPlot the timings. What do you notice about them? Repeat this up to Fib[100] and then Fib[500]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
