From: Ross on
PS: I think I've just properly understood. The Planet Math equations
are correct, but produce complex numbers in their solution, as said.
This causes difficulty to me, as I'm creating a computational example,
and upgrading the code to handle complex numbers would be too
difficult and computationally expensive. Since sqrt( a ) = sqrt( -1 * -
a ) = i sqrt( -a ), I could do the algebra to handle the case where
the operand of the sqrt is negative, by solving the equation to remove
i, then using that resulting equation when the operand is negative.
And of course, the other "more complicated looking" solutions use
"discriminants" to branch in the solution structure.

So, I'd guess that the lengthier solution that does work for me is a
similar, or even the same, solution method. Just that more steps have
been done so that no complex arithmetic is performed. In which case, I
have a solution, and it's probably as simple as any I'm going to get.

This is similar to designing digital filters by direct pole/zero
placement on an Argand diagram. When the poles or zeroes are not on
the real axis, they must be in conjugate pairs (r,omega), (r,-omega),
so that when the filter different equation is derived, the imaginary
parts drop out of the working, and final equation.
From: Gottfried Helms on
Am 13.01.2010 09:56 schrieb Ross:
> Are the formulae for findin the roots of cubic equations on Wikipedia
> correct? I've been through it over and over, and simply don't get
> roots.
>
A long time ago I found a pdf-version of

R. W. D. Nickalls
A NEW APPROACH TO SOLVING THE CUBIC
THE MATHEMATICAL GAZETTE, 1993, VOL 77

online. Perhaps it is still available, don't know. It appeared to be a
special nice approach to me since it takes care of the geometric
interpretation of all of the intermediate values in the process of
solving.

Gottfried Helms
From: JEMebius on
Ross wrote:
> Are the formulae for findin the roots of cubic equations on Wikipedia
> correct? I've been through it over and over, and simply don't get
> roots.
>
> I've gone to the original source, which is:
> http://planetmath.org/?op=getobj&from=objects&name=CubicFormula
>
> Just looking at the first equation to calculate r1, then if I have the
> cubic x^3 -2x^2 -11x + 12, then I get NaNs when I try to find r1.
>
> Specifically, if I set a1=-2, b1=-11, and c1=12, then the value of
> which the square root is taken:
> (2*a1^3 - 9*a1*b1 + 27*c1)^2 + 4*(-(a1^2)+3*b1)^3
>
> works out to be negative, leading to the NaN result.
>
> Here's a cut and paste from "bc" where I first confirm that my
> variables are set properly, then work out the operand of the square
> root.
>
> a1
> -2
> b1
> -11
> c1
> 12
> (2*a1^3 - 9*a1*b1 + 27*c1)^2 + 4*(-(a1^2)+3*b1)^3
> -190512
>
> Negative!
>
> I've also tried the modified form of these equations from the
> Wikipedia page, but I get the same result. NaNs.
>
> I've really tried to find the error in my calculations or reasoning,
> but I just can't see any. Are these equations correct? Am I misusing
> them?
>
> I can successfully use the method in this page: http://www.1728.com/cubic2.htm.
> However, I'd still like to know what I'm doing wrong with the
> Wikipedia method.
>
> Any hints/help?

See and study http://en.wikipedia.org/wiki/Casus_irreducibilis

Good luck: Johan E. Mebius
From: Ray Vickson on
On Jan 13, 4:00 am, Ross <rossclem...(a)gmail.com> wrote:
> PS: I think I've just properly understood. The Planet Math equations
> are correct, but produce complex numbers in their solution, as said.
> This causes difficulty to me, as I'm creating a computational example,
> and upgrading the code to handle complex numbers would be too
> difficult and computationally expensive. Since sqrt( a ) = sqrt( -1 * -
> a ) = i sqrt( -a ), I could do the algebra to handle the case where
> the operand of the sqrt is negative, by solving the equation to remove
> i, then using that resulting equation when the operand is negative.

You can express the solution in this case using trigonometric
functions (the end result of using and simplifying the complex
numbers). Look at
http://mathworld.wolfram.com/CubicFormula.html and scroll down about
2/3 of the way. Of course, this would all require your code to embody
some "if-then-else" branches. Note also, that some cubics have three
real roots (in which case you might need the trigonometric formulas to
obtain two of them), while others have only one real root and have two
genuinely complex ones. The formulas in the link above can help you
decide which is which.

R.G. Vickson

> And of course, the other "more complicated looking" solutions use
> "discriminants" to branch in the solution structure.
>
> So, I'd guess that the lengthier solution that does work for me is a
> similar, or even the same, solution method. Just that more steps have
> been done so that no complex arithmetic is performed. In which case, I
> have a solution, and it's probably as simple as any I'm going to get.
>
> This is similar to designing digital filters by direct pole/zero
> placement on an Argand diagram. When the poles or zeroes are not on
> the real axis, they must be in conjugate pairs (r,omega), (r,-omega),
> so that when the filter different equation is derived, the imaginary
> parts drop out of the working, and final equation.

From: Achava Nakhash, the Loving Snake on
On Jan 13, 4:00 am, Ross <rossclem...(a)gmail.com> wrote:
> PS: I think I've just properly understood. The Planet Math equations
> are correct, but produce complex numbers in their solution, as said.
> This causes difficulty to me, as I'm creating a computational example,
> and upgrading the code to handle complex numbers would be too
> difficult and computationally expensive. Since sqrt( a ) = sqrt( -1 * -
> a ) = i sqrt( -a ), I could do the algebra to handle the case where
> the operand of the sqrt is negative, by solving the equation to remove
> i, then using that resulting equation when the operand is negative.
> And of course, the other "more complicated looking" solutions use
> "discriminants" to branch in the solution structure.
>
> So, I'd guess that the lengthier solution that does work for me is a
> similar, or even the same, solution method. Just that more steps have
> been done so that no complex arithmetic is performed. In which case, I
> have a solution, and it's probably as simple as any I'm going to get.
>
> This is similar to designing digital filters by direct pole/zero
> placement on an Argand diagram. When the poles or zeroes are not on
> the real axis, they must be in conjugate pairs (r,omega), (r,-omega),
> so that when the filter different equation is derived, the imaginary
> parts drop out of the working, and final equation.

Are you sure that you want to use closed-form solutions for solving
these equations on the computer? A glance at the formula for solving
quadratic equations shows you that it can be very sensitive to small
changes in the coefficients, and my practical experience with solving
quadratic equations on the computer showed that the result were often
quite inaccurate. I finally ditched that approach and used the Newton
method. I would not be a bit surprised if that approach is far more
stable and accurate for cubic equations as well, particularly if you
know in advance that you only get one root.


Regards,
Achava