Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

help with matlab needed %% SCRIPT TO ESTIMATE THE EXECUTION TIME TO FIBNUM(N) % NOTE YOU PROBABLY DON'T WANT TO EXCEED 35 OR IT WILL

help with matlab needed

%% SCRIPT TO ESTIMATE THE EXECUTION TIME TO FIBNUM(N)

% NOTE YOU PROBABLY DON'T WANT TO EXCEED 35 OR IT WILL TAKE A LONG TIME

% IF YOU DO, REMEMBER CTRL+c TO STOP :)

time=zeros(1,35);

n=length( );

for i=15:n

tic;

f = fibnum(i);

time(i)= ;

end

%%

figure(1)

plot(time)

xlabel('Number Fibonacci Terms');

ylabel('Execution time (sec)');

title('Execution time in linear space');

%%

figure(2)

semilogy(time)

xlabel('

ylabel('

title('Execution time in semi-log space');

%% FIND THE SLOPE

figure(3)

slope_vector = diff(log(time));

plot(slope_vector)

xlabel('Number Fibonacci Terms');

ylabel('Approximate slope');

title('Approximate slope of log(time) vs Number Fibonacci Terms');

%% TAKE THE LAST VALUE OF slope_vector TO BE THE SLOPE

slope = slope_vector(end); % 'end' as an index just grabs the last one

fprintf('The slope is %f. ', );

%% WHAT ABOUT THE Y INTERCEPT?

% Think abouth the equation of a line. At n = 35

intcpt=-slope*35+time(35);

%% THUS EXTRAPOLATING TO n = 50

log_time_50 = *50 + intcpt;

%% AND THE TIME IN SECONDS IS APPROXIMATELY

% Think about what the inverse of a log based-ten number is

time_at_50 = ;

fprintf('It would take approximately %g seconds to ecvaluate fibnum(50). ',time_at_50);

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Factory Active Database For Enterprise Computing

Authors: Schur, Stephen

1st Edition

0471558443, 9780471558446

More Books

Students also viewed these Databases questions