Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write an m-file (using Matlab) that uses the false position method to determine

ID: 3824081 • Letter: W

Question

Write an m-file (using Matlab) that uses the false position method to determine the mass of the bungee jumper with a drag coefficient (cd) of 0.25kg/m to have a velocity of 36m/s after 4s of free fall. (Note: acceleration due to Earth’s gravity is 9.81m/s2 ).

Your m-file should prompt the user to enter the lower limit and upper limit and check if the initial guesses bracket a root. If not, your program should prompt the user for new guesses until the user provides values that do bracket the root.

Your m-file should then print the iteration number, xl, xu, xr and f(xr) for each iteration. Note that since you are printing values at each iteration, you should not write a function file for the false-position method. Rather, have the false-position code embedded in a regular m-file. Test your m-file for a precision of 0.005 using various initial guesses

F (m) = Squareroot gm/c_d tanh (Squareroot gc_d/m middot t) - v (t)

Explanation / Answer

Matlab Code:

function[x,y]=false_position(func)
x1=input('enter lower bound x1= ');
xu=input('enter upper bound xu= ');
es=input('allowable tolerance= ');
maxit=input('max iterations= ');
a(1)=x1;b(1)=xu;
ya(1)=feval(func,a(1));
yb(1)=feval(func,b(1));
if ya(1)*yb(1)>0.0
error('Function has same sign at end pointts');
end
for i=1:maxit
x(i)=b(i)-yb(i)*(b(i)-a(i))/(yb(i)-ya(i));
y(i)=feval(func,x(i));
if y(i)==0.0
disp('exact zero found');break;
elseif y(i)*ya(i)<0
a(i+1)=a(i);ya(i+1)=ya(i);
b(i+1)=x(i);yb(i+1)=yb(i);
else
a(i+1)=x(i);ya(i+1)=y(i);
b(i+1)=b(i);yb(i+1)=yb(i);
end
if((i>1)&(abs(x(i)-x(i-1))<es))
disp('Display false position method has converged');break;
end
iter=i;
end
if(iter>=maxit)
disp('Zero not found to desired tolerance');
end
n=length(x);k=1:n;out=[k' a(1:n)' b(1:n)' x' y'];
disp('step x1 xu xr f(xr)');
disp(out);
  

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote