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)](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f4ec9eb1e37_39066f4ec9e22502.jpg)
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
Get step-by-step solutions from verified subject matter experts
