Javascript required
Skip to content Skip to sidebar Skip to footer

Formula to Find Solution of Cubic Equation


Cubic Formula

DOWNLOAD Mathematica Notebook

The cubic formula is the closed-form solution for a cubic equation, i.e., the roots of a cubic polynomial. A general cubic equation is of the form

 z^3+a_2z^2+a_1z+a_0=0

(1)

(the coefficient a_3 of z^3 may be taken as 1 without loss of generality by dividing the entire equation through by a_3). The Wolfram Language can solve cubic equations exactly using the built-in command Solve[a3 x^3 + a2 x^2 + a1 x + a0 == 0, x]. The solution can also be expressed in terms of the Wolfram Language algebraic root objects by first issuing SetOptions[Roots, Cubics -> False].

The solution to the cubic (as well as the quartic) was published by Gerolamo Cardano (1501-1576) in his treatise Ars Magna. However, Cardano was not the original discoverer of either of these results. The hint for the cubic had been provided by Niccolò Tartaglia, while the quartic had been solved by Ludovico Ferrari. However, Tartaglia himself had probably caught wind of the solution from another source. The solution was apparently first arrived at by a little-remembered professor of mathematics at the University of Bologna by the name of Scipione del Ferro (ca. 1465-1526). While del Ferro did not publish his solution, he disclosed it to his student Antonio Maria Fior (Boyer and Merzbach 1991, p. 283). This is apparently where Tartaglia learned of the solution around 1541.

To solve the general cubic (1), it is reasonable to begin by attempting to eliminate the a_2 term by making a substitution of the form

 z=x-lambda.

(2)

Then

The x^2 is eliminated by letting lambda=a_2/3, so

 z=x-1/3a_2.

(6)

Then

z^3 = (x-1/3a_2)^3=x^3-a_2x^2+1/3a_2^2x-1/(27)a_2^3

(7)

a_2z^2 = a_2(x-1/3a_2)^2=a_2x^2-2/3a_2^2x+1/9a_2^3

(8)

a_1z = a_1(x-1/3a_2)=a_1x-1/3a_1a_2,

(9)

so equation (◇) becomes

Defining

then allows (◇) to be written in the standard form

 x^3+px=q.

(15)

The simplest way to proceed is to make Vieta's substitution

 x=w-p/(3w),

(16)

which reduces the cubic to the equation

 w^3-(p^3)/(27w^3)-q=0,

(17)

which is easily turned into a quadratic equation in w^3 by multiplying through by w^3 to obtain

 (w^3)^2-q(w^3)-1/(27)p^3=0

(18)

(Birkhoff and Mac Lane 1996, p. 106). The result from the quadratic formula is

w^3 = 1/2(q+/-sqrt(q^2+4/(27)p^3))

(19)

= 1/2q+/-sqrt(1/4q^2+1/(27)p^3)

(20)

= R+/-sqrt(R^2+Q^3),

(21)

where Q and R are sometimes more useful to deal with than are p and q. There are therefore six solutions for w (two corresponding to each sign for each root of w^3). Plugging w back in to (19) gives three pairs of solutions, but each pair is equal, so there are three solutions to the cubic equation.

Equation (◇) may also be explicitly factored by attempting to pull out a term of the form (x-B) from the cubic equation, leaving behind a quadratic equation which can then be factored using the quadratic formula. This process is equivalent to making Vieta's substitution, but does a slightly better job of motivating Vieta's "magic" substitution, and also at producing the explicit formulas for the solutions. First, define the intermediate variables

(which are identical to p and q up to a constant factor). The general cubic equation (◇) then becomes

 x^3+3Qx-2R=0.

(24)

Let B and C be, for the moment, arbitrary constants. An identity satisfied by perfect cubic polynomial equations is that

 x^3-B^3=(x-B)(x^2+Bx+B^2).

(25)

The general cubic would therefore be directly factorable if it did not have an x term (i.e., if Q=0). However, since in general Q!=0, add a multiple of (x-B)--say C(x-B)--to both sides of (25) to give the slightly messy identity

 (x^3-B^3)+C(x-B)=(x-B)(x^2+Bx+B^2+C)=0,

(26)

which, after regrouping terms, is

 x^3+Cx-(B^3+BC)=(x-B)[x^2+Bx+(B^2+C)]=0.

(27)

We would now like to match the coefficients C and -(B^3+BC) with those of equation (◇), so we must have

 C=3Q

(28)

 B^3+BC=2R.

(29)

Plugging the former into the latter then gives

 B^3+3QB=2R.

(30)

Therefore, if we can find a value of B satisfying the above identity, we have factored a linear term from the cubic, thus reducing it to a quadratic equation. The trial solution accomplishing this miracle turns out to be the symmetrical expression

 B=[R+sqrt(Q^3+R^2)]^(1/3)+[R-sqrt(Q^3+R^2)]^(1/3).

(31)

Taking the second and third powers of B gives

B^2 = [R+sqrt(Q^3+R^2)]^(2/3)+2[R^2-(Q^3+R^2)]^(1/3)+[R-sqrt(Q^3+R^2)]^(2/3)

(32)

= [R+sqrt(Q^3+R^2)]^(2/3)+[R-sqrt(Q^3+R^2)]^(2/3)-2Q

(33)

B^3 = -2QB+{[R+sqrt(Q^3+R^2)]^(1/3)+[R-sqrt(Q^3+R^2)]^(1/3)}×{[R+sqrt(Q^3+R^2)]^(2/3)+[R-sqrt(Q^3+R^2)]^(2/3)}

(34)

= [R+sqrt(Q^3+R^2)]+[R-sqrt(Q^3+R^2)]+[R+sqrt(Q^3+R^2)]^(1/3)[R-sqrt(Q^3+R^2)]^(2/3)+[R+sqrt(Q^3+R^2)]^(2/3)[R-sqrt(Q^3+R^2)]^(1/3)-2QB

(35)

= -2QB+2R+[R^2-(Q^3+R^2)]^(1/3)×[(R+sqrt(Q^3+R^2))^(1/3)+(R-sqrt(Q^3+R^2))^(1/3)]

(36)

= -2QB+2R-QB

(37)

= -3QB+2R.

(38)

Plugging B^3 and B into the left side of (◇) gives

 (-3QB+2R)+3QB=2R,

(39)

so we have indeed found the factor (x-B) of (◇), and we need now only factor the quadratic part. Plugging C=3Q into the quadratic part of (◇) and solving the resulting

 x^2+Bx+(B^2+3Q)=0

(40)

then gives the solutions

x = 1/2[-B+/-sqrt(B^2-4(B^2+3Q))]

(41)

= -1/2B+/-1/2sqrt(-3B^2-12Q)

(42)

= -1/2B+/-1/2sqrt(3)isqrt(B^2+4Q).

(43)

These can be simplified by defining

A = [R+sqrt(Q^3+R^2)]^(1/3)-[R-sqrt(Q^3+R^2)]^(1/3)

(44)

A^2 = [R+sqrt(Q^3+R^2)]^(2/3)-2[R^2-(Q^3+R^2)]^(1/3)+[R-sqrt(Q^3+R^2)]^(2/3)

(45)

= [R+sqrt(Q^3+R^2)]^(2/3)+[R-sqrt(Q^3+R^2)]^(2/3)+2Q

(46)

= B^2+4Q,

(47)

so that the solutions to the quadratic part can be written

 x=-1/2B+/-1/2sqrt(3)iA.

(48)

Defining

D = Q^3+R^2

(49)

S = RadicalBox[{R, +, {sqrt(, D, )}}, 3]

(50)

T = RadicalBox[{R, -, {sqrt(, D, )}}, 3],

(51)

where D is the polynomial discriminant (which is defined slightly differently, including the opposite sign, by Birkhoff and Mac Lane 1996) then gives very simple expressions for A and B, namely

Therefore, at last, the roots of the original equation in z are then given by

z_1 = -1/3a_2+(S+T)

(54)

z_2 = -1/3a_2-1/2(S+T)+1/2isqrt(3)(S-T)

(55)

z_3 = -1/3a_2-1/2(S+T)-1/2isqrt(3)(S-T),

(56)

with a_2 the coefficient of z^2 in the original equation, and S and T as defined above. These three equations giving the three roots of the cubic equation are sometimes known as Cardano's formula. Note that if the equation is in the standard form of Vieta

 x^3+px=q,

(57)

in the variable x, then a_2=0, a_1=p, and a_0=-q, and the intermediate variables have the simple form (cf. Beyer 1987)

Q = 1/3p

(58)

R = 1/2q

(59)

D = Q^3+R^2=(p/3)^3+(q/2)^2.

(60)

The solutions satisfy Vieta's formulas

z_1+z_2+z_3 = -a_2

(61)

z_1z_2+z_2z_3+z_1z_3 = a_1

(62)

z_1z_2z_3 = -a_0.

(63)

In standard form (◇), a_2=0, a_1=p, and a_0=-q, so eliminating q gives

 p=-(z_i^2+z_iz_j+z_j^2)

(64)

for i!=j, and eliminating p gives

 q=-z_iz_j(z_i+z_j)

(65)

for i!=j. In addition, the properties of the symmetric polynomials appearing in Vieta's formulas give

z_1^2+z_2^2+z_3^2 = -2p

(66)

z_1^3+z_2^3+z_3^3 = 3q

(67)

z_1^4+z_2^4+z_3^4 = 2p^2

(68)

z_1^5+z_2^5+z_3^5 = -5pq.

(69)

The equation for z_1 in Cardano's formula does not have an i appearing in it explicitly while z_2 and z_3 do, but this does not say anything about the number of real and complex roots (since S and T are themselves, in general, complex). However, determining which roots are real and which are complex can be accomplished by noting that if the polynomial discriminant D>0, one root is real and two are complex conjugates; if D=0, all roots are real and at least two are equal; and if D<0, all roots are real and unequal. If D<0, define

 theta=cos^(-1)(R/(sqrt(-Q^3))).

(70)

Then the real solutions are of the form

z_1 = 2sqrt(-Q)cos(theta/3)-1/3a_2

(71)

z_2 = 2sqrt(-Q)cos((theta+2pi)/3)-1/3a_2

(72)

z_3 = 2sqrt(-Q)cos((theta+4pi)/3)-1/3a_2.

(73)

This procedure can be generalized to find the real roots for any equation in the standard form (◇) by using the identity

 sin^3theta-3/4sintheta+1/4sin(3theta)=0

(74)

(Dickson 1914) and setting

 x=sqrt((4|p|)/3)y

(75)

(Birkhoff and Mac Lane 1996, pp. 90-91), then

 ((4|p|)/3)^(3/2)y^3+psqrt((4|p|)/3)y=q

(76)

 y^3+3/4p/(|p|)y=(3/(4|p|))^(3/2)q

(77)

 4y^3+3sgn(p)y=1/2q(3/(|p|))^(3/2)=C.

(78)

If p>0, then use

 sinh(3theta)=4sinh^3theta+3sinhtheta

(79)

to obtain

 y=sinh(1/3sinh^(-1)C).

(80)

If p<0 and |C|>=1, use

 cosh(3theta)=4cosh^3theta-3coshtheta,

(81)

and if p<0 and |C|<=1, use

 cos(3theta)=4cos^3theta-3costheta,

(82)

to obtain

 y={cosh(1/3cosh^(-1)C)   for C>=1; -cosh(1/3cosh^(-1)|C|)   for C<=-1; cos(1/3cos^(-1)C) [three solutions]   for |C|<1.

(83)

The solutions to the original equation are then

 x_i=2sqrt((|p|)/3)y_i-1/3a_2.

(84)

An alternate approach to solving the cubic equation is to use Lagrange resolvents (Faucette 1996). Let omega=e^(2pii/3), define

(1,x_1) = x_1+x_2+x_3

(85)

(omega,x_1) = x_1+omegax_2+omega^2x_3

(86)

(omega^2,x_1) = x_1+omega^2x_2+omegax_3,

(87)

where x_i are the roots of

 x^3+px-q=0,

(88)

and consider the equation

 [x-(u_1+u_2)][x-(omegau_1+omega^2u_2)][x-(omega^2u_1+omegau_2)]=0,

(89)

where u_1 and u_2 are complex numbers. The roots are then

 x_j=omega^ju_1+omega^(2j)u_2

(90)

for j=0, 1, 2. Multiplying through gives

 x^3-3u_1u_2x-(u_1^3+u_2^3)=0,

(91)

which can be written in the form (88), where

Some curious identities involving the roots of a cubic equation due to Ramanujan are given by Berndt (1994).

Wolfram Web Resources

Mathematica »

The #1 tool for creating Demonstrations and anything technical.

Wolfram|Alpha »

Explore anything with the first computational knowledge engine.

Wolfram Demonstrations Project »

Explore thousands of free applications across science, mathematics, engineering, technology, business, art, finance, social sciences, and more.

Computerbasedmath.org »

Join the initiative for modernizing math education.

Online Integral Calculator »

Solve integrals with Wolfram|Alpha.

Step-by-step Solutions »

Walk through homework problems step-by-step from beginning to end. Hints help you try the next step on your own.

Wolfram Problem Generator »

Unlimited random practice problems and answers with built-in Step-by-step solutions. Practice online or make a printable study sheet.

Wolfram Education Portal »

Collection of teaching and learning tools built by Wolfram education experts: dynamic textbook, lesson plans, widgets, interactive Demonstrations, and more.

Wolfram Language »

Knowledge-based programming for everyone.

Formula to Find Solution of Cubic Equation

Source: https://mathworld.wolfram.com/CubicFormula.html