logo

Application of Computing Coursework

   

Added on  2023-01-17

10 Pages1458 Words83 Views
Running head: APPLICATION OF COMPUTING COURSEWORK
APPLICATION OF COMPUTING COURSEWORK
Name of the Student
Name of the University
Author Note

1APPLICATION OF COMPUTING COURSEWORK
Q1:
i) The ratio of Fn/Fn-1 for the first 50 Fibonacci numbers are calculated by the following
MATLAB code.
MATLAB code:
%% Q1 i)
% generating Fibonacci numbers
F(1) = 1; F(2) = 1;
for i=3:50
F(i) = F(i-1) + F(i-2);
end
% computing ratio Fn/Fn-1
n = zeros(1,49);
ratio = zeros(1,49);
for i=2:50
n(i) = i;
ratio(i) = F(i)/F(i-1);
end
%% Q1 ii)
% plotting ratio as a function of n

2APPLICATION OF COMPUTING COURSEWORK
plot(n,ratio)
xlabel('sequence number')
ylabel('Ratio')
title('Ratio as a function of the sequence number')
%% Q1 iii)
i=1;ratio(1)=F(2)/F(1);
g_mean = (1+sqrt(5))/2; % defining golden mean
while (abs(ratio(i)-g_mean)/g_mean)*100 > 0.1 % finding n for which ratio is within 0.1% of
golden mean
i=i+1;
end
sprintf('The smallest value of n=%i for which the ratio is 0.1 percent accurate of golden
mean. The percentage of tolerance is %f',i,(abs(ratio(i)-g_mean)/g_mean)*100)
Output:
fibonacci
ans =
'The smallest value of n=9 for which the ratio is 0.1 percent accurate of golden mean. The
percentage of tolerance is 0.062646'

End of preview

Want to access all the pages? Upload your documents or become a member.

Related Documents
MATLAB Solutions for Mechanical Engineering Problems | Desklib
|7
|1116
|482

MATLAB Homework Assignment Report
|13
|1310
|15

CourseWork Questions
|8
|979
|215

MATLAB Interpolation Techniques
|56
|6920
|97

Physics Questions and Answers | Acceleration and Mass
|4
|648
|22

Transient analysis stability and surge protection Solution 2022
|13
|1513
|19