# Stable formula for a specific root of a depressed cubic

I have a cubic of the form $$x^3 - a x - b = 0$$ where $a, b > 0$. Thus, I know there is exactly one positive root.

Is there a nice stable formula for this unique positive root?

• This might mean the answer is no on the "nice" front: en.wikipedia.org/wiki/Casus_irreducibilis – Geoffrey Irving Apr 16 '13 at 23:24
• Casus irreducibilis is the case of three real roots, so this is not too applicable for you. Still, have you seen this? – J. M. Apr 18 '13 at 11:56
• Yeah, I was aware of those, but somehow thought I'd need to compute all the roots and choose between them. Fortunately, although you do need to branch on whether all roots are real, exactly one of the three root formulas in the all real case is positive, so no need for further branching. I'll write this up as a solution unless you want to. – Geoffrey Irving Apr 18 '13 at 17:05
• I don't mind, go ahead. :) – J. M. Apr 18 '13 at 17:06

In the special case of a depressed cubic $x^3 - ax - b = 0$ with linear and constant coefficients negative, let $Q = a/3$, $R = -q/2$. Then $Q > 0$, $R < 0$, and the unique positive root is given by $$x = \begin{cases} -2 \sqrt{Q} \cos{\frac{2\pi+\cos^{-1} {R/Q^{3/2}}}{3}} & \mbox{if } R^2 < Q^3 \\ A + \frac{Q}{A} & \mbox{if } R^2 \ge Q^3 \\ \end{cases}$$ where $$A = \left(-R + \sqrt{R^2 - Q^3} \right)^{1/3}$$ Note that the first case is always positive since $R/Q^{3/2} < 0$ so that $$\frac{\pi}{2} < \cos^{-1} \frac{R}{Q^{3/2}} < \pi,$$ eliminating the need to check through the other real roots (which are guaranteed to be negative).