Find a root of f(x)=0 using Newton-Raphson iteration with tolerance and iteration control.
Newton-Raphson finds a root of f(x) = 0 by iterating x_{n+1} = x_n - f(x_n)/f'(x_n). It converges quadratically near simple roots, meaning the number of correct digits roughly doubles each iteration. The derivative is computed numerically via central differences. The method may fail if the derivative is zero or the initial guess is too far from a root.
Newton-Raphson iteration
x(n+1) = x(n) - f(x(n)) / f'(x(n))
Try a different initial guess closer to the root, or use bisection which always converges if you can bracket the root.
Quadratically for simple roots: once close, digits of accuracy double per iteration. It may be slower or fail for multiple roots.