You are on page 1of 1

function [ c,n,err ] = bissec( f,a,b,tol )

%UNTITLED2 Summary of this function goes here


% Detailed explanation goes here
n=0;
while abs(a-b)>=tol
c=(a+b)/2; n=n+1;
x=a; fa=eval(f);
x=c; fc=eval(f);
if fa*fc<0
b=c;
else
a=c;
end
end
err=abs(a-b);
end

You might also like