You are on page 1of 1

%Program to calculate root using Bisection Method(accuracy criteria)

%Academic Year:2016-17
%Roll No:
%Batch:

clc
clear all
format long
f=inline('x^3-4*x-9','x');
xa=input('Enter the Lower Guess xa =');
xb=input('Enter the Upper Guess xb =');
acc=input('Enter the accuracy =');
fa=f(xa);
fb=f(xb);
if fa*fb>0.0
disp('Function does not have root in given limit')
return
end
while(abs(xb-xa)>acc)
xc=(xa+xb)/2;
fc=f(xc);
if fc==0
break
end
if fa*fc<0
xb=xc;
else
xa=xc;
end
end
fprintf('\n The root of equation is:%f',xc);

Solver:
f=inline('x^3-4*x-9');
fzero(f,2)

You might also like