2
$\begingroup$

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?

$\endgroup$
  • $\begingroup$ This might mean the answer is no on the "nice" front: en.wikipedia.org/wiki/Casus_irreducibilis $\endgroup$ – Geoffrey Irving Apr 16 '13 at 23:24
  • $\begingroup$ Casus irreducibilis is the case of three real roots, so this is not too applicable for you. Still, have you seen this? $\endgroup$ – J. M. Apr 18 '13 at 11:56
  • $\begingroup$ 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. $\endgroup$ – Geoffrey Irving Apr 18 '13 at 17:05
  • $\begingroup$ I don't mind, go ahead. :) $\endgroup$ – J. M. Apr 18 '13 at 17:06
3
$\begingroup$

As J.M. pointed out, the standard stable formulas for arbitrary cubics also work for this case, and happily they nicely simplify. The arbitrary formulas are given here.

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).

$\endgroup$
2
$\begingroup$

I am not sure there is a stable formula, but given one that is numerically not stable, you could follow it by a single Newton step and improve the accuracy considerably

$\endgroup$
  • $\begingroup$ Yes, there are various ways to do it with Newton's method that take advantage of the special form. In particular, the cubic is convex up after the positive root. However, I am specifically curious about formulae here. $\endgroup$ – Geoffrey Irving Apr 17 '13 at 20:41

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.