Question: please write the code in MatLab Complete the following questions related to Bracket methods: (a) Write a function to perform the Bisection method for any
Complete the following questions related to Bracket methods: (a) Write a function to perform the Bisection method for any scalar nonlinear equation f(x)= 0 . The inputs to your function should be: a function that calculates the nonlinear equation, the endpoints of the bracketing region, a convergence tolerance and a maximum number of iterations. The function should output the approximate root and the number of iterations. Your function should include an error check to make sure that the bracketing region is valid (a root exists). As an error measure, use both a which is related to the length of the bracketing region and f which is related to the value of f(x). Both are defined in the problem above. Thoroughly comment your code to show you know what you are doing. (b) Write a function to perform the False Position method for any scalar nonlinear equation f(x)=0. The instructions for this function are the same as for the Bisection method (see above). (c) Use both of your developed functions in (a) and (b) to complete the following problem: The upward velocity of a rocket can be computed by v=utln(m0qtm0)gt2 where v= upward velocity, u= the velocity at which fuel is expelled relative to the rocket, m0= the initial mass of the rocket at time t=0,q= the fuel consumption rate, and the downward gravitational acceleration g=9.81[m/s2]. If u=1500[m/s],m0=200000[kg], and q=3200[kg/s], compute the time at which v=5000[m/s]. Note: t is somewhere between 5 and 35[s]. Use a convergence tolerance of 1105. In addition, calculate the value of f(x) at the root to show that it is indeed a root of the
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
