二分法在很多地方应该都会见到,这里是通过迭代逼近的方法求出一个方程的根。
function xc = bisection(f,a,b,tol)
% use the bisection method to find the root of the function
% Page 30,computer problem 7(Bisection method)
% input:
% f:the function that transform from the equation
% a,b:the left and right value of the interval which the root is in
% tol: