# Roots of Cubic Equations ```Obtaining the Roots of a Cubic Equations
Given a cubic equation,
3
2
z + A⋅ z + B⋅ z + C = 0
Let
z= x−
A
3
then
−1 2
2 3
1
⋅ A + B ⋅ x +
⋅ A + C − ⋅ B⋅ A = 0
27
3
3

x + 
3
or
3
x + p⋅ x = q
where,
−1 2
⋅ A + B
3

p = 
2 3
1
q = − ⋅ A + C − ⋅ B⋅ A
3
 27

Further, let
x= y−
p
3y
then we obtain a 6th order polynomial equation in y given by
6
3
y − q⋅ y −
1
27
3
⋅p = 0
whose roots are:
1
2
3
q
q
p 



y=
+   +  
2

 2  3  
3
Now let the discriminant ∆ be the term inside the square root above, i.e.
2
q
P
∆ =   +  
 2  3 
3
then we will have two cases that will depend on whether the discriminant is
positive or negative.
∆ &gt; 0 Then we will have one real root and a complex conjugate pair
Case 1:
The first root is given by
z1 = sign ( h) ⋅ ( h
)
1
3
−
A
3
where,
h=
q
2
+
∆
The other roots can then be obtained by using the values of the first root:
z2 =
z3 =
Case 2:
(
)
− A + z1 +
( A + z1) 2 − 4⋅ B + z1⋅ ( A + z1)
2
(
)
− A + z1 −
∆&lt; 0
( A + z1) 2 − 4⋅ B + z1⋅ ( A + z1)
2
There will be three real roots.
The first root will be obained as follows (whose proof is given below):

 −∆  
 atan q  


  − p  
A
2 

−
z1 = 2⋅ 
 ⋅ cos 
3
  3  
 3
And the two remaining roots can be determined by the following equations:
z2 =
z3 =
(
)
( A + z1) 2 − 4⋅ B + z1⋅ ( A + z1)
− A + z1 +
2
(
)
( A + z1) 2 − 4⋅ B + z1⋅ ( A + z1)
− A + z1 −
2
Proof for formula to obtain the first root:
2
Let
q
 q  p
h = + i −  −  
2
 2  3 
3
whose magnitude and angle are given by
−p
h =  
 3 
3
 −∆ 

q


 2 
θ = arg ( h) = atan 
allowing one to evaluate the cube root of the polar representation:
y= h
1
3
i⋅
θ
−p
3
⋅e
3
=
from which we obtain
i⋅
x=
θ
−p
3
⋅e
+
3
−p
3
i⋅
θ
−p
3
⋅e
3
x=
(
)
− p i⋅ θ
−p
− i⋅ θ
θ
⋅ e +e
= 2⋅
⋅ cos  
3
3
3
or
A
−p
θ A
z1 = x −
= 2⋅
⋅ cos   −
3
3
3 3
```