Matlab Code For Bisection and Newton Method PDF
Matlab Code For Bisection and Newton Method PDF
F=@(x) x^2-exp(-x);
a= 0;
b=1;
Fa= F(a);
Fb = F(b);
max_iterations = 20;
tolerance = 0.002;
for i= 1: max_iterations
c = (a+b)/2;
Fc =F(c);
if i>1
tol = abs((c-g)/c);
if tol < tolerance
break
end
end
g = c;
if F(a)*F(c)<0
b = c;
else
a = c;
end
end
c
1
Xi = Xnew;
Xans = Xnew;
end
Xans