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

Additional information: The value of the Golden Ratio, in decimal form, is = 1.6

ID: 2998249 • Letter: A

Question

Additional information: The value of the Golden Ratio, in decimal form, is = 1.61803398875 If programmed properly, your MATLAB program should yield an answer that is close, but not equal, to psi. This will be your basis for checking that your program is working correctly. Further tip: Use format long PART C From Homework #14, we attempted to compute the Golden Ratio from the Fibonacci sequence. Given the Fibonacci sequence: 1, 1, 2, 3, 5, 8, 13, ... we can estimate the Golden Ratio by dividing a number from the above sequence by its preceding number. For example, 8/5 = 1.6 and 13/8 = 1.625 are approximations of the Golden Ratio. We observe that this approximation converges to the Golden Ratio if you divide the nth number in the Fibonacci sequence by its preceding (n-1)th number, where n is sufficiently large. This implies that the ratio of the 20th to the 19th number in the Fibonacci sequence, for example, will yield a better approximation of the Golden Ratio than the ratio of the 10th to the 9th number in the Fibonacci sequence. Write a MATLAB program incorporating a while loop to build the Fibonacci sequence and to approximate the Golden Ratio. Store the approximated ratios in the form of a column or row matrix and keep executing the loop until the magnitude of the difference of the newly computed ratio and the preceding computed ratio is less than 10^-8. Mathematically speaking, set the loop to keep reiterating until |ratioi+1- ratioi|

Explanation / Answer

fib(1) = 1;
fib(2) = 1;
fib(3) = 2;
k=2;
j=4;
ratio(1) = 1;
ratio(2) = 2;
diff = ratio(2)-ratio(1);
while diff>1e-8                 %terminating condition
    fib(j) = fib(j-1)+fib(j-2);
    ratio(j) = fib(j)./fib(j-1); %obtatining ratio
    j=j+1;
    k=k+1;
    diff = abs(ratio(k)-ratio(k-1)); %calculating diff. in ratios
end
disp(k);          %displaying no of iterations
format long;
disp(ratio(k));   %displaying golden ratio

OUTPUT:

23       (no. of iterations)

1.618033990175597        (final value of golden ratio)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote