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

A Fibonacci series (sequence) is one in which given two initial values, they sub

ID: 3545216 • Letter: A

Question

A Fibonacci series (sequence) is one in which given two initial values, they subsequent values in the sequence are the sum of the previous two numbers in the sequence. For example if the initial two values are 1 and 1, the sequence would be

1 2 3 5 8 13 21 34 ...



Similarly if the first two numbers were 4 and 6, the sequence would be

4 6 10 16 26 42 68 110 ...

You are to create a function that will accept the first two numbers of a Fibonacci sequence as function inputs (you may assume these are valid values) and will return (as a function output) an array containing a sequence. Your function should then calculate the third element in the sequence. Next your function should contain a loop that will continue calculating new elements of the sequence as long as the absolute value of the difference between the ratios of immediately previous pairs of adjacent elements of the series is greater than or equal to 0.005. Suppose your sequence is F, you should continue generating new values for F , Fn , until


| (Fn / Fn-1)

Explanation / Answer

%comment: save it in a .m file with filename myFibonacci.m and run in matlab

function[] = myFibanacci()

fibonacci1(4,6)

end



function[x] = fibonacci1(y1,y2)

y3 = y1 + y2;

x(1) = y1;

x(2) = y2;

x(3) = y3;

i = 4;

while(abs((y3/y2) - (y2/y1)) < 0.005)

x(i) = y3 + y2;

y1=y2;

y2 = y3;

y3 = x(i);

i=i+1;

end

end

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