# Solving cubic equation for real roots

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.

• 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)
– rm -rf
Commented Feb 2, 2013 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. Commented Feb 4, 2013 at 16:10
• I'm too late the hero, but: read up on casus irreducibilis. Commented May 7, 2013 at 20:11

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.

• 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. Commented Feb 2, 2013 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. Commented Mar 1, 2016 at 8:37
• @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". Commented Mar 2, 2016 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.

• ComplexExpand@ToRadicals@Table[Root[-2 - 5 #1 + 2 #1^3 &, k], {k, 3}] Commented Feb 2, 2013 at 1:39