1

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.

Stephen Montgomery-Smith
  • 26,430
  • 2
  • 35
  • 64

1 Answers1

2

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.

marty cohen
  • 107,799
  • Do any standard libraries actually use the cubic or quartic formulas? Or do they use some kind of numerical technique (like finding eigenvalues of the companion matrix)? – Stephen Montgomery-Smith Jul 16 '15 at 20:59
  • If they used the formulae, I certainly hope they practice safe computation. – marty cohen Jul 16 '15 at 21:07
  • I would not be surprised if many standard libraries use regula falsi to get a real zero, since it's known (if I recall correctly) to be quite well behaved. – Robert Lewis Jul 16 '15 at 21:28
  • If the libraries have good numerical methods for solving higher-degree polynomials, I don't see why they would bother trying to use the cubic or quartic formula for finding numerical solutions. – Robert Israel Jul 16 '15 at 21:40
  • Here's a link to matlab where they say that "Note that these solution formulas are well known to be numerically unstable." https://www.mathworks.com/matlabcentral/answers/151683-solving-a-cubic-equation – marty cohen Jul 23 '15 at 02:34
  • Some sites produce perfect radical solutions, so I doubt that they could have used numerical techniques. – Simply Beautiful Art Dec 26 '15 at 13:39
  • Here, Wolfram Alpha appears to use your precautions. http://www.wolframalpha.com/input/?i=x%5E3%2B2x%5E2%2B3x%2B4%3D0 – Simply Beautiful Art Dec 26 '15 at 13:42