You are on page 1of 1

BISECTION METHOD

Table of Contents
INPUT .............................................................................................................................. 1
PROGRAM & RESULT ...................................................................................................... 1

Name of the Student:Shubham Chapparghare Roll No:351013

INPUT
SC_BSM(@(x)cos(x)-1.3*x,0,1,0.01)

PROGRAM & RESULT


function[]=SC_BSM(fun,x1,x2,acc)
y1=feval(fun,x1);
y2=feval(fun,x2);
while y1*y2>0
x1=input('Enter new value of x1:');
x2=input('Enter new value of x2:');
y1=feval(fun,x1);
y2=feval(fun,x2);
end
while abs(x2-x1)>acc
x0=(x1+x2)/2;
y0=feval(fun,x0);
if y1*y0<0
x2=x0;
y2=y0;
else x1=x0;
y1=y0;
end
end
x0=(x1+x2)/2;
fprintf('The root of given function is %f\n',x0);

The root of given function is 0.621094

Published with MATLAB® R2017a

You might also like