MathGroup Archive 1994

[Date Index] [Thread Index] [Author Index]

Search the Archive

Real Roots of cubics

  • To: mathgroup at yoda.physics.unc.edu
  • Subject: Real Roots of cubics
  • From: paul at earwax.pd.uwa.edu.au (Paul Abbott)
  • Date: Mon, 14 Mar 1994 17:10:51 +0800

>>Actually, I'd suggest that WRI's version of the cubic formula
>>is defective and provides unnecessary "I" values.  This bug
>>was corrected in Macsyma, as I recall, about 20 years ago.

If you need them, the real roots of a cubic can be expressed in explicitly
form using trigs and arctrigs.  The following is a slightly modified
version of a column that appeared in The Mathematica Journal (Vol 2, Issue
3, 1992):

Consider the polynomial 

        poly = 11 x^3 - 20 x^2 - 10 x + 22

                        2       3
        22 - 10 x - 20 x  + 11 x

Its roots:

        sol = Solve[poly == 0, x];

are all real as is easily determined numerically:

        N[sol] // Chop

        {{x -> 1.61319}, {x -> -1.01567}, {x -> 1.22065}}

but this is certainly not obvious from the format of the exact symbolic 
solution.  For example, 

        First[sol]
        
                                    1/3
              20               730 2
        {x -> -- + --------------------------------- + 
              33                                 1/3
                   33 (-36074 + 66 I Sqrt[58479])
        
                                     1/3
          (-36074 + 66 I Sqrt[58479])
          ------------------------------}
                        1/3
                    33 2

How can this be simplified to a real expression?  From the general theory of 
cubic equations [see Numerical Recipes in C, 2nd Ed (1992), 183-5; American 
Journal of Physics 52 (3), 269 (1984)], a cubic of the form 
x^3 + a x^2 + b x + c, has three real roots when 

        q[a_,b_] := (a^2 - 3b)/9
and
        r[a_,b_,c_] := (2 a^3 - 9a b + 27 c)/54

are real and r^2 < q^3. Defining

        theta[r_,q_] := ArcCos[r/q^(3/2)]

the three roots are 

        roots[a_,b_,c_,n_] :=
                -a/3 - 2 Sqrt[q[a,b]] *
                        Cos[(theta[r[a,b,c],q[a,b]] + (2-n) 2 Pi)/3]

where n = 1, 2 and 3. 

>From the coefficients of the polynomial:

        {c,b,a} = Drop[CoefficientList[poly,x]/Coefficient[poly,x^3],-1]

              10     20
        {2, -(--), -(--)}
              11     11

it is seen that r and q are positive real:

        r[a,b,c]

        18037
        -----
        35937

        q[a,b]

        730
        ----
        1089

and also that 

        r[a,b,c]^2 - q[a,b]^3

          19493
        -(------)
          395307

is negative.  Hence, the three roots can be written exactly as:

        Table[roots[a,b,c,n],{n,3}]

                                                18037
                              2 Pi + ArcCos[-------------]
                                            730 Sqrt[730]
              2 Sqrt[730] Cos[----------------------------]
         20                                3
        {-- - ---------------------------------------------, 
         33                        33
 
                                         18037
                              ArcCos[-------------]
                                     730 Sqrt[730]
              2 Sqrt[730] Cos[---------------------]
         20                             3
         -- - --------------------------------------, 
         33                     33
 
                                                  18037
                              -2 Pi + ArcCos[-------------]
                                             730 Sqrt[730]
              2 Sqrt[730] Cos[-----------------------------]
         20                                 3
         -- - ----------------------------------------------}
         33                         33

This expression is simpler, more elegant and, because it does not involve 
complex numbers, much more suitable for subsequent algebraic manipulation.  As 
a check it is seen that the numerical values do tally:

        N[%]

        {1.22065, -1.01567, 1.61319}

Paul Abbott



--------------------------------------------------------------------------
| Department of Physics            |  Interests: Computer Algebra,       |
| University of Western Australia  |       Computational Physics,        |
| Nedlands  6009                   |       Exact atomic research         |
| Phone:        +61-9-380-2734     |                                     | 
| Fax:          +61-9-380-1014     |                                     | 
| email: paul at earwax.pd.uwa.edu.au |                                     |
--------------------------------------------------------------------------







  • Prev by Date: triple integral
  • Next by Date: AN NSF WORKSHOP FOR FACULTY WITH SYMBOLIC ALGEBRA EXPERIENCE
  • Previous by thread: triple integral
  • Next by thread: AN NSF WORKSHOP FOR FACULTY WITH SYMBOLIC ALGEBRA EXPERIENCE