I'm looking for a fast and robust method for finding a root of a cubic polynomial
$x^3 + px^2 + qx + r$
To make the search more robust and faster, I'd like to leverage these properties:
- The polynomial has exactly one real positive root (two other roots are either complex or real and negative).
- Only the value of the positive root is needed.
- There's a decent initial guess on the value of the root.
So far my approach was to directly apply Newton's method to the function using the initial guess and that would give me a decent result in just a couple of iterations.
However in some cases the iteration would cause the current guess for the root to jump closer to one of the negative roots and the method would incorrectly start converging towards that root instead. While it's possible to detect this situation, it's hard to bring the iteration back on the right track.
There's an interesting article about solving quartics and cubics and a also an example implementation, but the methods are very generic, too slow for my needs and have robustness issues of their own.
It would be interesting to know if there's a way to make my iterative search more robust or possibly that there's a faster analytical method taking advantage of the extra properties.