You are on page 1of 1

REGULAR FALSE POSITION METHOD

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

Name of the student :Shubham Chapparghare Roll No.:351013

INPUT
SC_FPM(@(x)exp(x)*cos(x)-1.2*sin(x)-0.5,0,1,0.0001)

PROGRAM & RESULT


function[]=SC_FPM(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*y2-x2*y1)/(y2-y1);
y0=feval(fun,x0);
if y1*y0<0
x2=x0;
y2=y0;
else x1=x0;
y1=y0;
end
end
x0=(x1*y2-x2*y1)/(y2-y1);
fprintf('The root of given function is %f\n',x0);

The root of given function is 0.971001

Published with MATLAB® R2017a

You might also like