# estimation of error - Newton-Raphson method

I am trying to write code that solves equations using Newton-Raphson method. I want the iterations would stop when the error is smaller than the tolerance defiend by the user. How can I validate the error is smaller than the tolerance?

thanks

• For the so-called "backward" error i.e. the error in the solution, in general you cannot. For the so-called "forward" error i.e. the deviation in the value of the function from 0, it is easy to see how to do it. But quantitatively converting a forward error estimate into a backward error estimate is hard and is generally not done. – Ian Apr 13 '18 at 9:59

Consider solving $x^2+0.00001 =0$ and $x^2-0.00001$, the first has no solution, but a NR method will initially appear to be converging to a value close to zero, before diverging.
If you have an estimate for the root $\alpha$, and a tolerance $\epsilon$ then you can evaluate $f(\alpha\pm\epsilon)$. If these two values have different signs then you know that there is a root in the interval $\alpha\pm\epsilon$. If they have the same sign then either there is either no root in the range, a double root, or an even number of roots.