TOPICS
Search

Cubic Formula


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

(x-lambda)^3+a_2(x-lambda)^2+a_1(x-lambda)+a_0=0
(3)
(x^3-3lambdax^2+3lambda^2x-lambda^3)+a_2(x^2-2lambdax+lambda^2)+a_1(x-lambda)+a_0=0
(4)
x^3+(a_2-3lambda)x^2+(a_1-2a_2lambda+3lambda^2)x+(a_0-a_1lambda+a_2lambda^2-lambda^3)=0.
(5)

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

x^3+(-a_2+a_2)x^2+(1/3a_2^2-2/3a_2^2+a_1)x-(1/(27)a_2^3-1/9a_2^3+1/3a_1a_2-a_0)=0
(10)
x^3+(a_1-1/3a_2^2)x-(1/3a_1a_2-2/(27)a_2^3-a_0)=0
(11)
x^3+3·(3a_1-a_2^2)/9x-2·(9a_1a_2-27a_0-2a_2^3)/(54)=0.
(12)

Defining

p=(3a_1-a_2^2)/3
(13)
q=(9a_1a_2-27a_0-2a_2^3)/(27)
(14)

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

Q=(3a_1-a_2^2)/9
(22)
R=(9a_2a_1-27a_0-2a_2^3)/(54)
(23)

(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

B=S+T
(52)
A=S-T.
(53)

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

u_1^3+u_2^3=q
(92)
u_1^3u_2^3=-(p/3)^3.
(93)

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


See also

Casus Irreducibilis, Cubic Equation, Cubic Polynomial, Polynomial Discriminant, Quadratic Equation, Quartic Equation, Quintic Equation, Sextic Equation

Explore with Wolfram|Alpha

References

Abramowitz, M. and Stegun, I. A. (Eds.). Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables, 9th printing. New York: Dover, p. 17, 1972.Berger, M. §16.4.1-16.4.11.1 in Geometry I. New York: Springer-Verlag, 1994.Berndt, B. C. Ramanujan's Notebooks, Part IV. New York: Springer-Verlag, pp. 22-23, 1994.Beyer, W. H. CRC Standard Mathematical Tables, 28th ed. Boca Raton, FL: CRC Press, pp. 9-11, 1987.Birkhoff, G. and Mac Lane, S. A Survey of Modern Algebra, 5th ed. New York: Macmillan, pp. 90-91, 106-107, and 414-417, 1996.Borwein, P. and Erdélyi, T. "Cubic Equations." §1.1.E.1b in Polynomials and Polynomial Inequalities. New York: Springer-Verlag, p. 4, 1995.Boyer, C. B. and Merzbach, U. C. A History of Mathematics, 2nd ed. New York: Wiley, pp. 282-286, 1991.Dickson, L. E. "A New Solution of the Cubic Equation." Amer. Math. Monthly 5, 38-39, 1898.Dickson, L. E. Elementary Theory of Equations. New York: Wiley, pp. 36-37, 1914.Dunham, W. "Cardano and the Solution of the Cubic." Ch. 6 in Journey through Genius: The Great Theorems of Mathematics. New York: Wiley, pp. 133-154, 1990.Ehrlich, G. §4.16 in Fundamental Concepts of Abstract Algebra. Boston, MA: PWS-Kent, 1991.Faucette, W. M. "A Geometric Interpretation of the Solution of the General Quartic Polynomial." Amer. Math. Monthly 103, 51-57, 1996.Jones, J. "Omar Khayyám and a Geometric Solution of the Cubic." http://jwilson.coe.uga.edu/emt669/Student.Folders/Jones.June/omar/omarpaper.html.Kennedy, E. C. "A Note on the Roots of a Cubic." Amer. Math. Monthly 40, 411-412, 1933.King, R. B. Beyond the Quartic Equation. Boston, MA: Birkhäuser, 1996. Lichtblau, D. "Various Ways to Tackle Algebraic Equations with Mathematica." 1998 WorldWide Mathematica Conference. http://library.wolfram.com/infocenter/Conferences/337/.Press, W. H.; Flannery, B. P.; Teukolsky, S. A.; and Vetterling, W. T. "Quadratic and Cubic Equations." §5.6 in Numerical Recipes in FORTRAN: The Art of Scientific Computing, 2nd ed. Cambridge, England: Cambridge University Press, pp. 178-180, 1992.Spanier, J. and Oldham, K. B. "The Cubic Function x^3+ax^2+bx+c and Higher Polynomials." Ch. 17 in An Atlas of Functions. Washington, DC: Hemisphere, pp. 131-147, 1987.van der Waerden, B. L. §64 in Algebra. New York: Frederick Ungar, 1970.Whittaker, E. T. and Robinson, G. "The Solution of the Cubic." §62 in The Calculus of Observations: A Treatise on Numerical Mathematics, 4th ed. New York: Dover, pp. 124-126, 1967.

Referenced on Wolfram|Alpha

Cubic Formula

Cite this as:

Weisstein, Eric W. "Cubic Formula." From MathWorld--A Wolfram Web Resource. https://mathworld.wolfram.com/CubicFormula.html

Subject classifications