The polynomial that produces your values is $p(x)=x^3+4x-9$. Then indeed the regula-falsi or false position method, that is, the bracketing method using the secant root,
a,b=1,2
f=lambda x: x*(x*x+4)-9
fa,fb = f(a),f(b)
for k in range(2,20):
c = b-fb*(b-a)/(fb-fa)
fc = f(c)
if fa*fc > 0:
a,fa = b,fb
if abs(c-b) < 1e-10: break
b,fb = c,fc
produces the points and values
| step |
x |
f(x) |
| c[0]=a |
1 |
-4 |
| c[1]=b |
2 |
7 |
| c[2] |
1.3636363636363638 |
-1.0097670924117192 |
| c[3] |
1.443860801050558 |
-0.21449107408405865 |
| c[4] |
1.46039514739571 |
-0.04375583788976023 |
| c[5] |
1.4637471747797475 |
-0.008851314007729982 |
| ... |
... |
... |
| c[15] |
1.4645957011474617 |
-9.946194978738276e-10 |
| c[16] |
1.4645957012235364 |
-2.007709554163739e-10 |
As all the values found are negative, only the point with negative value gets changed, the other side of the interval with the positive value remains unchanged. This stalling behavior is rather typical of the "plain vanilla" regula falsi method.
There are anti-stalling modifications that shift the calculated mid-point more and more towards the stalling side so that eventually a point gets found that replaces that end of the interval. The easiest is the so-called Illinois variant that reduces the function value at the stalling side by a factor of 2 in each stalling step.
a,b=1,2
f=lambda x: x*(x*x+4)-9
fa,fb = f(a),f(b)
for k in range(2,20):
c = b-fb*(b-a)/(fb-fa)
fc = f(c)
if fa*fc > 0:
a,fa = b,fb
else: # this new branch is the only change
fa *= 0.5
if abs(c-b) < 1e-10: break
b,fb = c,fc
resulting in an iteration
| step |
x |
f(x) |
| c[0]=a |
1 |
-4 |
| c[1]=b |
2 |
7 |
| c[2] |
1.3636363636363638 |
-1.0097670924117192 |
| c[3] |
1.443860801050558 |
-0.21449107408405865 |
| c[4] |
1.475974727761858 |
0.11931191740107039 |
| c[5] |
1.4644961782313235 |
-0.0010384912181606865 |
| c[6] |
1.4645952254470451 |
-4.964985366839869e-06 |
| c[7] |
1.4645961724498568 |
4.9171042082463146e-06 |
| c[8] |
1.464595701242682 |
-9.841016890277388e-13 |
| c[9] |
1.4645957012427764 |
0.0 |
Note that the sign of the values alternates frequently, and apparently the convergence is super-linear, here as fast as the Newton method in terms of function evaluations.
See also Bracketing root-finding methods: my modified Illinois method, https://stackoverflow.com/questions/22273751/regula-falsi-algorithm
Using a multi-precision floating point type, one can continue the table above to ever smaller errors, where the period-3 pattern of the error progression becomes clearly visible
| k |
$c_k$ |
$c_k-c_{k-1}$ |
$f(c_k)$ |
| 8 |
1.464595701242682 |
-4.7120717493e-07 |
-9.8507967689e-13 |
| 9 |
1.464595701242776 |
9.4400382608e-14 |
-1.9544502434e-19 |
| 10 |
1.464595701242776 |
3.7459071605e-20 |
1.9544494679e-19 |
| 11 |
1.464595701242776 |
-1.8729532086e-20 |
-1.5413207939e-39 |
| 12 |
1.464595701242776 |
1.4770510950e-40 |
-1.2155181734e-59 |
| 13 |
1.464595701242776 |
2.3296674592e-60 |
1.2155181734e-59 |
| 14 |
1.464595701242776 |
-1.1648337296e-60 |
-5.9616556262e-120 |
| 15 |
1.464595701242776 |
5.7130676528e-121 |
-2.9239659746e-180 |
| 16 |
1.464595701242776 |
5.6040860040e-181 |
2.9239659746e-180 |