Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm looking to solve the following cubic equation for x:

$\beta\, x^3 - \gamma \,x = c$. I have plugged in some sample values ($\beta = 2$, $\gamma = 5$ and $c = 2$). When I try to solve this equation using mathematica's Solve[] function, I get one real root and 2 complex roots. However, I have tried plotting the equation for these values, and can clearly see there should be 3 real roots. How can I obtain them. I am sure the roots are real, but mathematica gives me back complex roots.

Thanks.

share|improve this question
2  
Try Solve[2 x^3 - 5 x == 2, x] // N // Chop... If you want it in symbolic/exact form, do Simplify[x /. Solve[2 x^3 - 5 x == 2, x] // ComplexExpand] (I'm sure this has been asked before and probably answered by Artes) – R. M. Feb 2 '13 at 0:43
    
For the record, x/.Solve[2 x^3 - 5 x == 2, x] gives three REAL roots, which are expressed in terms of radicals and (of necessity) use the imaginary unit sqrt(-1). That is not the same thing as having two complex roots. – Daniel Lichtblau Feb 4 '13 at 16:10
    
I'm too late the hero, but: read up on casus irreducibilis. – J. M. May 7 '13 at 20:11
up vote 3 down vote accepted

Your original equation is in the form of a "depressed cubic" $x^3-(\gamma/\beta)x-c/\beta=0$. When the discriminant, $4 \beta \gamma^3 - 27 c^2 \beta^2$, is positive, the equation has three real roots. In this case, the roots may be written as follows:

$2\sqrt{-p/3}~{\rm Cos}[\frac{1}{3}{\rm ArcCos}[3q \sqrt{-3/p}~/~(2p)]-2\pi k/3]$,

where $p=-\gamma/\beta<0$, $q=-c/\beta$, and $k=0,1,2$. No complex square roots required.

share|improve this answer
    
Let p[x_] := β x^3 - γ x - c. Reduce[ Discriminant[ p[x], x] > 0, { β, γ, c}] yields (β < 0 && γ < 0 && -((2 Sqrt[ γ^3/β])/(3 Sqrt[3])) < c < ( 2 Sqrt[ γ^3/β])/(3 Sqrt[3])) || (β > 0 && γ > 0 && -((2 Sqrt[γ^3/β])/(3 Sqrt[3])) < c < (2 Sqrt[γ^3/β])/(3 Sqrt[3])). While Discriminant[p[x] /. {β -> 2, γ -> 5, c -> 2}, x] yields 568. – Artes Feb 2 '13 at 18:29
    
@kennyColnago can you explain what you are defining as the discriminant and how you arrived at 4βγ^3−27c^2β^2. The definition I found (mathworld.wolfram.com/PolynomialDiscriminant.html) appears to require that you already know what the roots are to calculate it (I'm probably wrong). If you could also supply a reference for the statement "When the discriminant, is positive, the equation has three real roots" that would be really helpful. – MHH Mar 1 at 8:37
1  
@MHH Equations 7 and 8 in the MathWorld link you mention show how to calculate the discriminant. In this case, $a_3=\beta$, $a_2=0$, $a_1=-\gamma$, and $a_0=-c$. The wikipedia article Discriminant gives a similar presentation at the top of the page, and section 6.2 discusses the "Nature of the roots". – KennyColnago Mar 2 at 17:36

The 3 roots only appear to be imaginary. If you enter N[Chop[sol]], you will see that the results are all real. If you are just looking for the values, then the function NSolve would be more appropriate here. The closed form solutions for the cubic contain nested square roots. This is why the solution has complex numbers.

share|improve this answer
    
ComplexExpand@ToRadicals@Table[Root[-2 - 5 #1 + 2 #1^3 &, k], {k, 3}] – Artes Feb 2 '13 at 1:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.