a different implementation of Newton’s method that is both faster and more accurate, despite the fact that it is algebraically equivalent to the above implementation.

$X \gets initial\; guess$ $X_{\rm prev 1} \gets \mathit{NaN}$ $X_{\rm prev 2} \gets X_{\rm prev 1}$ $X_{\rm prev 1} \gets X$ $X \gets (X\cdot f'(X)-f(X))/f'(X)$

Note that the equal sign in the above breakout condition is evaluated in floating-point precision. In comparison to the first algorithm, at each iteration step we test whether the iteration has converged by a simple comparison rather than by a slow division and absolute-value operation.

We keep track of two previous values instead of just one because for certain initial conditions, the iteration can cycle indefinitely between two nearby floating-point numbers and not converge to a single floating-point number.

Our implementation thus ensures that the value of $X$ is more accurately calculated than in the straightforward implementation using a heuristic value of ${\ensuremath{\mathit{eps}}}$. A further advantage of rewriting Newton’s method in the above form is that the term on the right-hand-side of the last line can be simplified significantly for the Kepler problem, giving: $$\begin{aligned}
X \gets  \frac{X (\eta_0 G_1 + \zeta_0 G_2) -\eta_0 G_2 -\zeta_0 G_3+dt }{r_0+\eta_0 G_1 +\zeta_0 