0
$\begingroup$

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

$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – Ian Apr 13 '18 at 9:59
0
$\begingroup$

In general, you cannot. You don't know the true value of the solution.

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.

You can iterate the NR method until the difference between terms becomes small, then test by looking for a change of sign. If there is a change of sign then you have a proven root. If there is no certain way of telling whether a root even exists or not.

$\endgroup$
  • $\begingroup$ Also, give yourself a maximum number of iterations to be take into account the possible non-convergence. $\endgroup$ – Bernard Massé Apr 13 '18 at 11:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.