Regula falsi with error in x-axis I want the regula falsi to get x +- .0001 so that f(x) = 0. But all the implemetations I see get x so that f(x) +- .0001 = 0 which doesn't make much sense. (f(x) = x^3).
How do I  stop the regula falsi method when the error is .0001 on the x-axis?
I have this scilab code:
function salida = falsaposicion(fun, tolerancia, a, b)
   deff(&quot;y=f(x)&quot;, &quot;y=&quot;+fun);
   if (f(a)*f(b)&gt;0) then
       disp(&quot;Error&quot;);
   end
   
   cAnt = 1e100
   c =  b - f(b)*((b - a)/(f(b) - f(a)));
   
   while 0 == 0
       if f(b) - f(a) == 0 then
           disp(&quot;Error&quot;);
           break;
       end
       
       if abs(f(c)) &lt; tolerancia then
           break;
       elseif f(a)*f(c) &lt; 0 then
           b = c;
       elseif f(b)*f(c) &lt; 0 then
           a = c;
       end
       
       cAnt = c;
       c = b - f(b)*((b - a)/(f(b) - f(a)));
   end
   
   salida = c;
endfunction

disp(falsaposicion(&quot;x^3&quot;, 0.0001, -6, 3));

```
A loop invariant of regula falsi is that $f(a)f(b)&lt;0$. Under the assumption that $f$ is continuous, this implies that there is a solution $x_0$ of $f(x0)=0$ inside $(a,b)$, since the eventual output $c$ is also in $(a,b)$, then for any output you have that $|c−x_0|≤|a−b|$. Therefore, you can add to the breaking condition, instead of it being abs(f(c))&lt;tolerancia, to be abs(f(c))&lt;tolerancia and abs(b-a)&lt;.0001, or replace it completely by abs(b-a)&lt;.0001.
It is true that the distance between $a$ and $b$ doesn't always go to zero. That's the price you pay for converging faster than bisection in some cases. Still, that is the only condition that you have to bound the error, if regula falsi is applied by itself, since $c$ could be approaching a root only from one side. What people do is not to apply regula falsi by itself, but to mix it, among other methods, with bisection. For example, what is done in Brent's method.