I need help on solving it by using Bisection Method in Matla
I need help on solving it by using Bisection Method in Matlab
1. The speed of a rocket (v) moving vertically near the Earth\'s surface is approximated as MO v(t) In Mo mt In this equation, variable value definition 2510 m/s velocity of exhaust relative to rocket MT 2.8 x 106 kg mass of rocket at liftoff Im 13.3 x 10 kg/s rate of fuel consumption 9.81 m/s2 acceleration due to gravity (near Earth surface time since liftoff in seconds Find the time at which the rocket reaches the speed of sound 340 m/s). Use any of the methods discussed in class except MATLAB-provided functions Solve until the relative approximation error is S 0.00001. What would be the mass of the rocket at the time it reaches the speed of soundSolution
Matlab script to solve the problem
clc;clear; % clearing commandwindow and workspace
 u = 2510; % velocity of exhaust relative to rocket
 Mo = 2.6*10^6; % mass of the rocket at liftoff
 m = 13.3*10^3; % rate of fuel consumption
 g = 9.81;% acceleration due to gravity
 v = 340; %speed of sound
 f = @(t) u*log(Mo./(Mo-m*t))-g*t-v; % the function
 xl = 0;xu =100;%initial guesses
 toler = 0.00001; % Tolerence
 iter = 0; % iteration counter initially zero
 Max_iter = 100; % Maximum number of iteration
 u = f(xl); % the function value at xl
 v = f(xu);% the function value at xs
 c=(xl+xu)*0.5; % mid point of xl and xs
 err=abs(xu-xl)*0.5; % error
 if (u*v<=0) % proced only f(%f)if u nad v are of oposit sign
    while (err>toler)&&(iter<=Max_iter) % loop
       w=f(c); % function value ate the middle
       if (w*u<0) % checking the sign of the new functional value
          xu=c;v=w; % if w and u are oposite sign replace xu with c
       end
       if (w*u>0)% if w and u are same sign replace xl with c
          xl=c;u=w;
       end
       iter=iter+1; % increment iteration count
       c=(xl+xu)*0.5;% mid point of xl and xs
       err=abs(xu-xl)*0.5;% error
    end
    if (iter>Max_iter) % mathod faild if iteration reach Max_iter
       disp(\'Method failed to converge\')
    else % else method converges and print the result
        fprintf(\'The time at which the rocket reach the speed of sound is t = %f s\ \',c);
        fprintf(\'Mass of the rocket at the time it reach the speed of sound is M = %f Kg \ \',Mo-m*c);
    end
 else% display error if f(xl) and f(xu) are same sign
    disp(\'The method cannot be applied f(xl)f(xu)>0\')
 end
 OutPut
The time at which the rocket reach the speed of sound is t = 60.956377 s
 Mass of the rocket at the time it reach the speed of sound is M = 1789280.188680 Kg

