Regula falsi
In numerical analysis, the false position method or regula falsi method is a root-finding algorithm that combines features from the bisection method and the secant method.
The Method
Let r be a x-intercept of a secant line with points
and slope of
In point-slope form, the secant line can be defined as
For f(r), we have
which, when solved for the x-intercept r, gives the false position method formula
To find a root in interval [a, b], the false position method would initially have s = a and t = b. Then, r would be calculated and if the root is bracketed by s and r, the new interval to check would be [s, r] so t would be replaced by r. Otherwise, if the root is bracketed by r and t, the new interval to check would be [r, t] so s would be replaced by r.
Example code
The following C code was wrote for clarity instead of efficiency. It was designed to solve the same problem as solved by the Newton's method and Secant method code: to find the positive number x where cos(x) = x3. This problem is transformed into a root-finding problem of the form f(x) = cos(x) - x3 = 0.
#include <stdio.h> #include <math.h>
double f(double x) { return cos(x) - x*x*x; }
double FalsiMethod(double s, double t, double e, double m) { int n; double r; double d; for (n = 1; n <= m; n++) { r = t - f(t) * (s - t) / (f(s) - f(t)); if (f(r) < e) return r; if (f(s) * f(r) < 0) t = r; else if (f(r) * f(t) < 0) s = r; } return r; }
int main(void) { printf("%0.15f\n", FalsiMethod(0, 1, 5E-11, 100)); return 0; }