numeric analysis Bisection method. MATLAB provides tools to solve math. Using linear programing techniques we can easily solve system of equations. This file provides a running code of Bisection Method
Size: 107.6 KB
Language: en
Added: Jan 30, 2017
Slides: 2 pages
Slide Content
bisetion:
function [r] = ncasinmt(f,a,b,N,eps)
f = inline('x^3-9*x+1')
a=2;
b=4;
N=18;
eps=0.0001;
if(f(a)==0)
r=a;
return;
elseif(f(b)==0)
r=b;
return;
elseif(f(a)*f(b)>0)
error('f(a) and f(b) donot have opposite sign')
end
for i = 2:N
c=(a+b)/2;
if(f(c)==0)
r=c;
return;
elseif(f(a)*f(c)<0)
b=c;
else a=c;
end
if (b-a)/2<eps;
if(abs(f(a))<abs(f(b))&&abs(f(a))<eps)
r=a;
return;
elseif(abs(f(b))<eps)
r=b;
return;
end
end
end
end