Is the cubic formula numerically unstable?

522 Views Asked by At

Are there numerical rounding issues in using the cubic formula to find roots of cubic equations? Similarly with the quartic formula?

I do know for the quadratic formula to solve $ax^2+bx+c = 0$ that you use the formulas $x = \frac{-b \pm \sqrt{b^2-4ac}}{2a}$ or $x = \frac{2c}{-b \mp \sqrt{b^2-4ac}}$ so that the numerator or denominator respectively are chosen so that they are the sum of two terms with the same sign.

1

There are 1 best solutions below

7
On BEST ANSWER

It could certainly be.

You have

$$S = \sqrt [3] {R + \sqrt{Q^3 + R^2}}$$ and $$T = \sqrt [3] {R - \sqrt{Q^3 + R^2}}$$

so if $Q$ is small compared with $R$, there could be trouble.

The $\sqrt{}$s could be computed safely in that case, as in the quadratic case, by $a-\sqrt{a^2+b} =(a-\sqrt{a^2+b})\frac{a+\sqrt{a^2+b}}{a+\sqrt{a^2+b}} =\frac{-b}{a+\sqrt{a^2+b}} $.

I wouldn't be surprised if standard libraries took these kind of precautions.