Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(b) Write a MATLAB script named that calls a Fibonacci sequence function to esti

ID: 3676976 • Letter: #

Question

(b) Write a MATLAB script named that calls a Fibonacci sequence function to estimate ?.

0O Problem 3 (20 pts) Looking closely at the infinite series n, it would be reasonable (and correct) to conclude that it diverges. However, it may be surprising that the similar infinite series does not diverge, instead converging to a number (albeit irrational): 1.645. In similar fashion, when reciprocals of the factorials are added together, they also produce a series that 0O T2 converges to an important (and irrational) number with which you are probably familiar: e (Euler's number) n! 1 12 6 24 n=0 Another convergent series is that of the reciprocals of the Fibonacci numbers, which sum to produce another irrational number called the reciprocal Fibonacci constant, or . (As an aside, note that the Fibonacci series-and thus -are intimately related to the golden ratio, 1.61803.) Your estimates must be to at least 10 decimal places. (Hint: You'l need to set a tolerance in each script to determine when to finish refining its estimate and exit the loop.)

Explanation / Answer

% get_fac.m file
a=0;
k=1;
out=0.0;
while 1/get_fib(k) > 1e-10
out = out+1/get_fib(k);
k=k+1;
end
format long;
out

% get_fib.m file
function [ output ] = get_fib( n )

if n==1
output=1;
elseif n==0
output=0;
  
else
a1=0;
a2=1;
i=1;
while i<n
a3 = a1+a2;
a1=a2;
a2=a3;
i=i+1;
end
output =a3;
end

end

% part (a) PP1_P3a.m file
a=0;
k=0;
out=0.0;
while 1/get_fac(k) > 1e-10
out = out+1/get_fac(k);
k=k+1;
end
format long;
out

% Part (b) PP1_P3b.m file
a=0;
k=1;
out=0.0;
while 1/get_fib(k) > 1e-10
out = out+1/get_fib(k);
k=k+1;
end
format long;
out