Iteration method to find root of a function.
Geometrically, in this method we replace the function f(x) by a straight line, l
or a chord passing through the points (xk, fk) and
(xk-1, fk-1) and take the point of intersection, xk+1 of the straight line with the x-axis
as the next approximation to the root.
Equating slope of the line, m gives :
m = (fk - fk-1)/(xk - xk-1) = (-fk)/(xk+1 - xk)
=> xk+1 = xk - (xk - xk-1)*fk / (fk - fk-1)
If the approximations are such that fk * fk-1 < 0 then the method is known as Regula Falsi method.
For next iteration use :
xk = xk+1 if fk * fk-1 < 0
xk-1 = xk+1 if fk * fk-1 > 0