MATLAB question Italian mathematician Fibonacci Is famous fo

MATLAB question:

Italian mathematician Fibonacci Is famous for introducing the \'Fibonacci series\' to modern mathematics. Any term in the Fibonacci series is the sum of the previous two terms. For example, the first 5 terms of the series are 1, 1, 2, 3, 5 Use for loop to perform the following exercises. Compute the first 50 terms of the series and put the answer in vector p1a. Use for loop to compute the sum of all terms in the series in part (a). Put the answer in p1b. Find the ratio of two consecutive terms in the series in part (a) and put the answer in vector p1c.

Solution

Matlab code for the problem 1

%%%%%% Part a) %%%%%
pla(1) = 1; % First number in Fibonacci series
pla(2) = 1; % Second number in Fibonacci series
% We need first two numbers in Fibonacci series to compute next numbers
for k = 3:50 % k vary from 3 to 50
    pla(k) = pla(k-1)+pla(k-2);% Calculating the Fibonacci series up to 50 terms
end
% displaying the content of pla variable
fprintf(\'First 50 terms of Fibonacci series\ \');
disp(pla);
%%%%%%%%%% part b) %%%%%%%
plb = 0;
for k = 1:50
    plb = plb + pla(k);% Calculating the sum of first 50 terms
end
% displaying the content of plb variable
fprintf(\'The sum of first 50 terms of Fibonacci series\ \');
disp(plb);
%%%%%%%%%% part c) %%%%%%%
plc(1) = 0;% plc(0) is setting
for k =2:50
    plc(k) = pla(k)/pla(k-1);% Calculating ratio of two consecutive terms
end
% displaying the content of plc variable
fprintf(\'The ratio of two consecutive terms in the series\ \');
disp(plc);

Output

>> Fibonacci
First 50 terms of Fibonacci series
   1.0e+10 *

Columns 1 through 6

    0.0000    0.0000    0.0000    0.0000    0.0000    0.0000

Columns 7 through 12

    0.0000    0.0000    0.0000    0.0000    0.0000    0.0000

Columns 13 through 18

    0.0000    0.0000    0.0000    0.0000    0.0000    0.0000

Columns 19 through 24

    0.0000    0.0000    0.0000    0.0000    0.0000    0.0000

Columns 25 through 30

    0.0000    0.0000    0.0000    0.0000    0.0001    0.0001

Columns 31 through 36

    0.0001    0.0002    0.0004    0.0006    0.0009    0.0015

Columns 37 through 42

    0.0024    0.0039    0.0063    0.0102    0.0166    0.0268

Columns 43 through 48

    0.0433    0.0701    0.1135    0.1836    0.2971    0.4808

Columns 49 through 50

    0.7779    1.2586

The sum of first 50 terms of Fibonacci series
   3.2951e+10

The ratio of two consecutive terms in the series
Columns 1 through 6

         0    1.0000    2.0000    1.5000    1.6667    1.6000

Columns 7 through 12

    1.6250    1.6154    1.6190    1.6176    1.6182    1.6180

Columns 13 through 18

    1.6181    1.6180    1.6180    1.6180    1.6180    1.6180

Columns 19 through 24

    1.6180    1.6180    1.6180    1.6180    1.6180    1.6180

Columns 25 through 30

    1.6180    1.6180    1.6180    1.6180    1.6180    1.6180

Columns 31 through 36

    1.6180    1.6180    1.6180    1.6180    1.6180    1.6180

Columns 37 through 42

    1.6180    1.6180    1.6180    1.6180    1.6180    1.6180

Columns 43 through 48

    1.6180    1.6180    1.6180    1.6180    1.6180    1.6180

Columns 49 through 50

    1.6180    1.6180

>>

MATLAB question: Italian mathematician Fibonacci Is famous for introducing the \'Fibonacci series\' to modern mathematics. Any term in the Fibonacci series is t
MATLAB question: Italian mathematician Fibonacci Is famous for introducing the \'Fibonacci series\' to modern mathematics. Any term in the Fibonacci series is t

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site