The reciprocal Fibonacci constant Psi is defined by the infinite sum: Psi = sigm
ID: 3828742 • Letter: T
Question
The reciprocal Fibonacci constant Psi is defined by the infinite sum: Psi = sigma_n = 1^infinity 1/F_n where F_n are the Fibonacci numbers 1, 1, 2, 3, 4, 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 that will calculate Psi until the difference between successive terms of the sum is less than 0.0001. Use an fprintf command to output the value of the estimate.Explanation / Answer
inverseFib = 2;
allowed_error = 0.00001;
fib_prev = 1;
fib_prev_prev = 1;
calc_error = 1
while allowed_error < calc_error
fib_new = fib_prev + fib_prev_prev;
inverseFibNew = inverseFib + 1/fib_new;
calc_error = abs(inverseFibNew - inverseFib);
inverseFib = inverseFibNew;
fib_prev_prev = fib_prev;
fib_prev = fib_new;
end
fprintf("Value of reciprocal of fib constant : %f ", inverseFib);
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.