The reciprocal Fibonacci constant psi is defined by the infi

The reciprocal Fibonacci constant psi is defined by the infinite sum: psi = sigma^infinity_n = 1 1/F_n where F_n are the Fibonacci numbers 1, 1, 2, 3, 5, 8, 13, .... Each element in this sequence of numbers is the sum of the previous two. Start by setting the first two elements equal to 1, then F_n = F_n-1 + F_n-2. Write a MATLAB program in a script file that calculates psi for a given n. Execute the program for n = 10, 50, and 100.

Solution

n=10,50 and 100

n=input(,enter the value of n \ \');

y(1)=1;y(2)=1

s=0

for i=3:n

y(i)=y(i-2)+y(i-1)

end

for i=1:n

s=s+1/y(i);

end

fprintf(\'the fibonacci constant for n=%i is %i \ \',n,s)

The MATLAB output is,

Enter the value of n 10

The Fibonacci cnstant for n=10 is 3.3305

Enter the value of n 50

The Fibonacci constant for n = 50 is 3.3598

Enter the value of n 100

The Fibonacci constant for n=100 is 3.3598

 The reciprocal Fibonacci constant psi is defined by the infinite sum: psi = sigma^infinity_n = 1 1/F_n where F_n are the Fibonacci numbers 1, 1, 2, 3, 5, 8, 13

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site