SORU 1
SORU 2
clc;close all;clear all;
% Plot function f(x)
t=4;
x=50:1:200; %%%%%%% Mass of the bungee jumper
g=9.81;
cd=0.25;
v=36;
f = sqrt(g.*x/cd).tanh(sqrt(gcd./x)*t)-v; %%%%%%% The function
f(x)i.e. f(m)
plot(x,f,'b','LineWidth',3); %%%%Plot the function
title('f(m) = sqrt(g.*x/cd).tanh(sqrt(gcd./x)*t)-v')
xlabel('mass(kg)')
ylabel('f(m)')
% Bisection Method's
xl = 140; % Lower limit of the closed interval
xu = 150; % Upper limit of the closed interval
fx =@(x) sqrt(g.*x/cd).tanh(sqrt(gcd./x)*t)-v; % Define the function
f(x)
es = 0.01; % Given approximate absolute relative error tolerance.
imax = 100; % Define maximum # iteration
xl_all = []; % Store all calculated values of xl
xu_all = []; % Store all calculated values of xu
xr_all = []; % Store all calculated values of xr
ea_all = []; % Store all calculated values of ea
fxl_all = []; % Store all calculated values of f(xl)
fxu_all = []; % Store all calculated values of f(xu)
fxr_all = []; % Store all calculated values of f(xr)
if fx(xl)*fx(xu) > 0 % if guesses do not bracket
disp('no bracket')
return
end
for i=1:1:imax
xr=(xu+xl)/2 ;
ea = abs((xu-xl)/xl);
test= fx(xl)*fx(xr);
if test < 0
xu=xr;
end
if test > 0
xl=xr;
end
if test == 0
ea=0;
end
if ea < es
break;
end
% Store calculated values in vectors
xl_all(i) = xl;
xu_all(i) = xu;
xr_all(i) = xr;
ea_all(i) = ea;
fxl_all(i) = fx(xl);
fxu_all(i) = fx(xu);
fxr_all(i) = fx(xr);
end
fprintf('\n Root= %f #Iterations = %d \n', xr,i);
fprintf(' How close is f(root) to zero? f(root)= %f \n', fx(xr));
% Display stored values
fprintf('\nStored Values:\n');
fprintf('xl_all: ');
disp(xl_all);
fprintf('xu_all: ');
disp(xu_all);
fprintf('xr_all: ');
disp(xr_all);
fprintf('ea_all: ');
disp(ea_all);
fprintf('fxl_all: ');
disp(fxl_all);
fprintf('fxu_all: ');
disp(fxu_all);
fprintf('fxr_all: ');
disp(fxr_all);
SORU 3
SORU 4
SORU 5