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

Problem 3 (1 point. Instructor\'s Initials One of the many interesting propertie

ID: 3282294 • Letter: P

Question

Problem 3 (1 point. Instructor's Initials One of the many interesting properties of the Fibonacci sequence is that the ratio of adjacent members of the sequence gradually converges on a number called the golden ratio, which has applications in mathematies and art. For example, the ratios in the fanmiliar 1, 1,2, 3,5,8.13 many 1.625. These values are converging on the golden ratio. You can google golden ratio to find what it is, but we're going to use our ability to generate Fibonacci sequences to determine it ourselves. Write a program that creates a Fibonacci sequence based on any 2 starting numbers nl and n2. The program will compute the ratio of the kth element to the (k-1)th element. The program should keep adding elements to the sequence until the ratio converges to within 001 of the correcet number. You can use a while loop to do this. Supposing you call the Fibonacci sequence x, he while statement will look like this: while (abs( x(k)/x(k-1)- x(k-1)/x(k-2))> 0.001)

Explanation / Answer

MATLAB code

close all
clear
clc

n1 = 1;
n2 = 1;
x = [n1 n2 n1+n2];
k = 3;
while abs(x(k)/x(k-1) - x(k-1)/x(k-2)) > 0.001
k = k + 1;
x(k) = x(k-1) + x(k-2);
end
x
fprintf('k = %d ', k);
fprintf('Ratio = %.4f ', x(k)/x(k-1));

Output

x =
1 1 2 3 5 8 13 21 34 55 89
k = 11
Ratio = 1.6182

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