# Cubic Formula Theory

Discussion in 'Math' started by Adanovinivici, May 24, 2015.

Sep 5, 2014
58
0
Hello All,

I'm attempting to understand the derivation of the cubic formula. I used the website, http://mathworld.wolfram.com/CubicFormula.html, to understand how the formula was originally derived, but I don't understand how to use the result for w. I'm referring to equation number 21 on the website. I know the other half of the page uses additional substitutions, but I'm trying to approach it one step at a time. I have done the substitutions by hand up to equation 21 as well and did try to use the results to solve a cubic equation, but didn't have any luck.

My main problem was that the result for w is a quadratic formula, and I don't see how you can obtain 3 solutions from that equation. I tried to do it, but was only able to obtain two even after solving for w^3 and substituting all the way back to the starting equation before the first substitution.

I've attached my work below. Could someone please help me understand how three solutions were obtained and why none of my substitutions worked?

The equation I tried to solve is x^3 + 2x^2 - 5x - 6. I know rational root theorem or a plot will solve the problem, but I want to understand the equation as well.

• ###### Cubic Formula Work.pdf
File size:
1.2 MB
Views:
19
Last edited: May 24, 2015
2. ### studiot AAC Fanatic!

Nov 9, 2007
5,005
515

Sep 5, 2014
58
0
Yes, but my question is how? The formula on the website uses a quadratic formula to solve for w^3, but you can only obtain two answers and I wasn't even able to obtain an answer out of those. Could you please explain where all three terms come from in terms of w? I've already tried to understand it myself and did some research, but I really need a technical explanation before I completely understand it.

4. ### studiot AAC Fanatic!

Nov 9, 2007
5,005
515
This is going to take some time to write out all the Latex for the steps.

5. ### studiot AAC Fanatic!

Nov 9, 2007
5,005
515
Consider

$ax^{3}+3bx^{2}+3cx+d=0$

Set
$H = ac - b^{2}$
and
$G = a^{2}d - 3abc + 2b^{3}$

If $G^{2}+4H^{3}> 0$
use Cardan's solution
If $G^{2}+4H^{3}= 0$
There is a repeated root of either $+\sqrt{\left ( -H \right )}$ or $-\sqrt{\left ( -H \right )}$

If $G^{2}+4H^{3}< = 0$
use trig solution the roots are real if a,b,c and are real
Let
$cos\left ( \phi \right )=\frac{1}{2}G\left ( -H \right )^{-\frac{3}{2}}$
taking the positive value for $\left ( -H \right )^{-\frac{3}{2}}$
Can't work out where the arrow in the cos has come from,just ignore it.

6. ### studiot AAC Fanatic!

Nov 9, 2007
5,005
515
Taking the positive square root each time

The roots are

$2\sqrt{-H}cos\left ( \frac{1}{3}\phi \right )$

$2\sqrt{-H}cos\left ( \frac{1}{3}\phi +\frac{2\pi }{3} \right )$
$2\sqrt{-H}cos\left ( \frac{1}{3}\phi +\frac{4\pi }{3} \right )$

again ignore the arrows in the cos terms

There are also complicated formulae for the roots in the other two cases but I haven't written them out.

7. ### MrAl Distinguished Member

Jun 17, 2014
2,546
512
Hi,

Here is the 'p' and 'q' solution, if this helps...i used it in a routine a long time ago.

complex: u,v,srD,Du,Dv,y,y2,y3,umv

ba=b/a ca=c/a da=d/a
ba2=ba
ba=ba/3
ba2=ba*ba2
p=(ca-ba2)/3
q=ba2*ba/3+(da-ba*ca)/2
D=power(p,3)+power(q,2)

IF D>=0 then
srD=sqrt(D)
Du=q-srD
Dv=q+srD
u=-power(fabs(Du),1/3)*Sgn(Du)
v=-power(fabs(Dv),1/3)*Sgn(Dv)
y=u+v
umv=(u-v)*Sqrt3/2
y2={-y/2,umv}
y3={-y/2,-umv}
return {{y,0}-{ba,0},y2-{ba,0},y3-{ba,0}}
ELSE
srD={0,sqrt(fabs(D))}
u=-cPower({q,0}-srD,{1/3,0})
v=-cPower({q,0}+srD,{1/3,0})
y=u+v
umv=cMult(Sqrt3*(u-v)/2,{0,1})
y2=-y/2+umv
y3=-y/2-umv
return {y-{ba,0},y2-{ba,0},y3-{ba,0}}
END IF

Sometimes two solutions are complex so complex numbers have to be used.
They are represented as:
{real,imaginary}
in the above code.
The coefficients of the third degree equation are all real: a,b,c and d as usual:
a*x^3+b*x^2+c*x+d

There are always three 'return' values in brackets {y1,y2,y3} and two may be complex.

If you think this is fun, wait till you get to the quartic

Sep 5, 2014
58
0
Thanks for the post MrAI. I kind of understand what you did, but its still a bit confusing. What does {a,b}--{c,d} do? In adition, what language did you use to write this?

Thanks Again,

9. ### MrAl Distinguished Member

Jun 17, 2014
2,546
512

Hello again,

I think you meant:
{a,b}-{c,d}

right?

That is simply the subtraction of two complex numbers, where in that example a and c are the real parts and b and d are the imaginary parts. So for a number:
2+3*j
we would represent it in code as:
{2,3}

Some variables are complex too though, so they could be represented as simply A for example, where:
A={2,3}

which would make A here equal to the above 2+3*j complex number. So we can operate on that as in:
B=A-{2,3}

and because A is the same as {2,3} here this would make B equal to {0,0}, where both the real and imag parts came out to zero after the subtraction.

The language used is called "Euphoria" and it is a free and open source language.
In that language we also have 'sequences' like:
{1,2,3,4,5}

so in one line of the routine i posted we have:
return {y-{ba,0},y2-{ba,0},y3-{ba,0}}

so the first return value if we call it r1 it is:
r1=y-{ba,0}

and here we are simply subtracting {ba,0} from the complex y.
Similarly, we have the other two return values r2 and r3:
r2=y2-{ba,0}
r3=y3-{ba,0}

and in the 'return' statement they are grouped into one sequence:
{r1,r2,r3}

and to make it a return value:
return {r1,r2,r3}

and those are the three solutions (the cubic always has three solutions, possibly two of the three are a complex conjugate pair).
so that is the same as:
return {y-{ba,0},y2-{ba,0},y3-{ba,0}}

The only real difference with that routine is that the complex numbers are handled as sequences of two numbers {a,b}.
A note on the functions:
fabs() is just taking the absolute value of a number.
Sgn() just finds the sign of the number.
cPower() is a function that calulates a complex power X^Y with both X and Y complex and returns a complex number.
cMult() is a function that multiplies two complex numbers and returns a complex number.
Sqrt3 is simply a constant equal to the square root of 3.

Last edited: May 26, 2015

Sep 5, 2014
58
0
Thank you. I really appreciate the explanation.

Best,

11. ### The Electrician AAC Fanatic!

Oct 9, 2007
2,300
335
Here's the solution to the cubic in Latex:

$\text{a0}+\text{a1} x+\text{a2} x^2+x^3=0$

${x1\to \frac{\sqrt[3]{3 \sqrt{3} \sqrt{27 \text{a0}^2-18 \text{a0} \text{a1} \text{a2}+4 \text{a0} \text{a2}^3+4 \text{a1}^3-\text{a1}^2 \text{a2}^2}-27 \text{a0}+9 \text{a1} \text{a2}-2 \text{a2}^3}}{3 \sqrt[3]{2}}-\frac{\sqrt[3]{2} \left(3 \text{a1}-\text{a2}^2\right)}{3 \sqrt[3]{3 \sqrt{3} \sqrt{27 \text{a0}^2-18 \text{a0} \text{a1} \text{a2}+4 \text{a0} \text{a2}^3+4 \text{a1}^3-\text{a1}^2\text{a2}^2}-27 \text{a0}+9 \text{a1} \text{a2}-2 \text{a2}^3}}-\frac{\text{a2}}{3}
x2\to -\frac{\left(1-i \sqrt{3}\right) \sqrt[3]{3 \sqrt{3} \sqrt{27 \text{a0}^2-18 \text{a0} \text{a1} \text{a2}+4 \text{a0} \text{a2}^3+4 \text{a1}^3-\text{a1}^2 \text{a2}^2}-27 \text{a0}+9 \text{a1} \text{a2}-2 \text{a2}^3}}{6 \sqrt[3]{2}}+\frac{\left(1+i \sqrt{3}\right) \left(3 \text{a1}-\text{a2}^2\right)}{3\ 2^{2/3} \sqrt[3]{3 \sqrt{3} \sqrt{27 \text{a0}^2-18 \text{a0} \text{a1} \text{a2}+4 \text{a0} \text{a2}^3+4 \text{a1}^3-\text{a1}^2 \text{a2}^2}-27 \text{a0}+9 \text{a1} \text{a2}-2 \text{a2}^3}}-\frac{\text{a2}}{3}
x3\to -\frac{\left(1+i \sqrt{3}\right) \sqrt[3]{3 \sqrt{3} \sqrt{27 \text{a0}^2-18 \text{a0} \text{a1} \text{a2}+4 \text{a0} \text{a2}^3+4 \text{a1}^3-\text{a1}^2 \text{a2}^2}-27 \text{a0}+9 \text{a1} \text{a2}-2 \text{a2}^3}}{6 \sqrt[3]{2}}+\frac{\left(1-i \sqrt{3}\right) \left(3 \text{a1}-\text{a2}^2\right)}{3\ 2^{2/3} \sqrt[3]{3 \sqrt{3} \sqrt{27 \text{a0}^2-18 \text{a0} \text{a1}\text{a2}+4 \text{a0} \text{a2}^3+4 \text{a1}^3-\text{a1}^2 \text{a2}^2}-27 \text{a0}+9 \text{a1} \text{a2}-2 \text{a2}^3}}-\frac{\text{a2}}{3}$

And in text:

x1 -> -a2/3 - (2^(1/3)*(3*a1 - a2^2))/(3*(-27*a0 + 9*a1*a2 - 2*a2^3 + 3*Sqrt[3]*Sqrt[27*a0^2 + 4*a1^3 - 18*a0*a1*a2 - a1^2*a2^2 + 4*a0*a2^3])^(1/3)) + (-27*a0 + 9*a1*a2 - 2*a2^3 + 3*Sqrt[3]*Sqrt[27*a0^2 + 4*a1^3 - 18*a0*a1*a2 - a1^2*a2^2 + 4*a0*a2^3])^(1/3)/(3*2^(1/3))

x2 -> -a2/3 + ((1 + I*Sqrt[3])*(3*a1 - a2^2))/ (3*2^(2/3)*(-27*a0+9*a1*a2-2*a2^3+3*Sqrt[3]*Sqrt[27*a0^2 + 4*a1^3 - 18*a0*a1*a2 - a1^2*a2^2 + 4*a0*a2^3])^(1/3)) - ((1 - I*Sqrt[3])*(-27*a0 + 9*a1*a2 - 2*a2^3 + 3*Sqrt[3]*Sqrt[27*a0^2 + 4*a1^3 - 18*a0*a1*a2 - a1^2*a2^2 +4*a0*a2^3])^(1/3))/(6*2^(1/3))

x3 -> -a2/3 + ((1 - I*Sqrt[3])*(3*a1 - a2^2))/ (3*2^(2/3)*(-27*a0 + 9*a1*a2 - 2*a2^3 +3*Sqrt[3]*Sqrt[27*a0^2 + 4*a1^3 - 18*a0*a1*a2 - a1^2*a2^2 + 4*a0*a2^3])^(1/3)) - ((1 + I*Sqrt[3])*(-27*a0 + 9*a1*a2 - 2*a2^3 + 3*Sqrt[3]*Sqrt[27*a0^2 + 4*a1^3 - 18*a0*a1*a2 - a1^2*a2^2 + 4*a0*a2^3])^(1/3))/(6*2^(1/3))

Last edited: May 30, 2015
12. ### studiot AAC Fanatic!

Nov 9, 2007
5,005
515
Yes I agree with you,.

But I disagree strongly with your views on LaTex, and would be happy to continue your offer of civil discourse on that subject if the mods would split this subject off to a new thread.

As regards to the purpose of this thread, namely the solution of cubic equations since no one is interested in my details of the simplest way to solve the given equations ( at considerable effort due to LaTex issues) I do not wish to waste further time and effort on this here.

13. ### MrAl Distinguished Member

Jun 17, 2014
2,546
512
Hi again,

If you like one of us can start a new thread and discuss this (Latex and related) some more, i'd be interested in talking about it a little more too.

Here is the simplified procedural p and q method. This is about the same as before but more straightforward, where each step does a smaller piece of the puzzle. Note some intermediate results may come out to be complex...

Definition:
cuberoot(x)=x^(1/3)

For the cubic equation:
A*x^3+B*x^2+C*x+D

define:
b=B/A
c=C/A
d=D/A

then:
p=(3*c-b^2)/3
q=(27*d-9*b*c+2*b^3)/27
D=(q/2)^2+(p/3)^3
sD=sqrt(D)

then:
u=-cuberoot(q/2-sD)
v=-cuberoot(q/2+sD)

then (note 'z' below contains the imaginary operator 'j'):
w=-(u+v)/2
z=sqrt(3)*j*(u-v)/2

then:
y1=u+v
y2=w+z
y3=w-z

then finally the solutions to the original cubic equation:
x1=y1-b/3
x2=y2-b/3
x3=y3-b/3

14. ### WBahn Moderator

Mar 31, 2012
18,079
4,917
MOD NOTE: I've tried to split off the LaTeX discussion into a new thread: