Question: Please solved by use matlab function [x e] = bisectionmethod (fxx,a,b,n) % n: number of iterations % Inputs : fxx -- a function; a,b --

 Please solved by use matlab function [x e] = bisectionmethod (fxx,a,b,n)

Please solved by use matlab

function [x e] = bisectionmethod (fxx,a,b,n) % n: number of iterations % Inputs : fxx -- a function; a,b -- left and right edges of the interval % Outputs : x -- the estimated root of f(x) = 0 % e -- an upper bound on the error c = f(a); d = f(b); if c*d > 0.0 error ('Function has same sign at both endpoints .') end disp (' x y') for i = 1:n % find the middle and evaluate there x = (a + b )/2; y = f(x); disp ([ x y]) if y == 0.0 a = x; b = x; break end % if c*y The following function estimates the roots of a given function using bisection method. Modify the same to solve until the absolute error is bounded by a given tolerance. Use a while loop to do this. Run your program on the function f(x)= 23+3x1 with starting interval [0,1] and a tolerance of 108. How many steps does the program use to achieve this tolerance? (You can count the step by adding 1 to a counting variable i in the loop of the program.) How big is the final residual f(x) ? Add necessary print statements to print xl,xr,xu, error in each iteration function [xe]= bisectionmethod (fxx,a,b,n) %n : number of iterations % Inputs : fxX -- a function; a,bleft and right edges of the interval \% Outputs : x-- the estimated root of f(x)=0 % e -- an upper bound on the error c=f(a);d=f(b) if cd>0.0 error ('Function has same sign at both endpoints .') end disp(xy) for i=1:n % find the middle and evaluate there x=(a+b)/2 y=f(x); disp([xy]) if y=0.0 a=x b=x break end

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!