# Solving an Algebraic Equation with Constraints on Multiple Parameters

Suppose we have the following equation to solve (with respect to $$x$$):

$$\frac{m\omega^2x^2}{2} + \frac{m\alpha x^3}{3} = E,\quad\text{where }m,\omega,\alpha,E>0\text{ and } E < \frac{m\omega^6}{6\alpha^2}.$$

Now, theoretically speaking, along with these constraints, we should have derived 3 real roots for this equation. But when I tried to actually solve it on Mathematica, whether I had added these constraints in the Assumptions field, it kept giving me the complex roots. What am I supposed to do to let Mathematica derive the desired real roots? Any of your help will be greatly appreciated! :)

• Reduce[(m*ω^2*x^2)/2 + (m*α*x^3)/3 == e && m > 0 && ω > 0 && α > 0 && e > 0 && e < (m*ω^6)/(6 α^2), Reals]  Oct 10, 2020 at 9:02
• Solve[(m*ω^2*x^2)/2 + (m*α*x^3)/3 == e && m > 0 && ω > 0 && α > 0 && e > 0 && e < (m*ω^6)/(6 α^2), Reals]  Oct 10, 2020 at 9:03

(An applied mathematician's take, too long for a comment.)

In problems like these it helps to do scaling (also called non-dimensionalisation) to reduce the number of parameters.

Dividing through by the maximum energy $$m \omega^6 / (6 \alpha^2)$$, we have $$\frac{3 \alpha^2 x^2}{\omega^4} + \frac{2 \alpha^3 x^3}{\omega^6} = \hat{E} \tag{1}$$ where $$\hat{E} = \left. E \middle/ \frac{m \omega^6}{6 \alpha^2} \right.$$ is the dimensionsless energy. Inspecting $$(1)$$, we see that it is sensible to define the dimensionless position $$\hat{x} = \frac{\alpha x}{\omega^2},$$ so that the problem reduces to $$3 \hat{x}^2 + 2 \hat{x}^3 = \hat{E}, \qquad 0 < \hat{E} < 1.$$

After this simplification, Mathematica is able to return a result with radicals, even without specifying any assumptions. Note that we have casus irreducibilis; all three roots are real, but a pair of them can only be expressed in terms of radicals using complex numbers.

Solve[3 xHat^2 + 2 xHat^3 == eHat, xHat]


$$\small \left\{\left\{\hat{x}\to \frac{1}{2} \left(\sqrt[3]{2 \sqrt{\hat{E}^2-\hat{E}}+2 \hat{E}-1}+\frac{1}{\sqrt[3]{2 \sqrt{\hat{E}^2-\hat{E}}+2 \hat{E}-1}}-1\right)\right\},\left\{\hat{x}\to -\frac{1}{4} \left(1-i \sqrt{3}\right) \sqrt[3]{2 \sqrt{\hat{E}^2-\hat{E}}+2 \hat{E}-1}-\frac{1+i \sqrt{3}}{4 \sqrt[3]{2 \sqrt{\hat{E}^2-\hat{E}}+2 \hat{E}-1}}-\frac{1}{2}\right\},\left\{\hat{x}\to -\frac{1}{4} \left(1+i \sqrt{3}\right) \sqrt[3]{2 \sqrt{\hat{E}^2-\hat{E}}+2 \hat{E}-1}-\frac{1-i \sqrt{3}}{4 \sqrt[3]{2 \sqrt{\hat{E}^2-\hat{E}}+2 \hat{E}-1}}-\frac{1}{2}\right\}\right\}$$

Also of note is that the three roots lie in the interval $$-3/2 < \hat{x} < 1/2$$:

Manipulate[
Plot[{3 xHat^2 + 2 xHat^3, eHat}, {xHat, -3/2, 1/2}]
, {{eHat, 1/2}, 0, 1}
]


• Express xHat without complex numbers: Solve[3 xHat^2 + 2 xHat^3 == eHat, xHat] // ComplexExpand[#, TargetFunctions -> {Re, Im}] & // Simplify[#, 0 < eHat < 1] &  . Yields {{xHat -> -(1/2) + Cos[1/3 ArcTan[-1 + 2 eHat, 2 Sqrt[(1 - eHat) eHat]]]}, {xHat -> 1/2 (-1 - Cos[1/3 ArcTan[-1 + 2 eHat, 2 Sqrt[(1 - eHat) eHat]]] - Sqrt[3] Sin[ 1/3 ArcTan[-1 + 2 eHat, 2 Sqrt[(1 - eHat) eHat]]])}, {xHat -> 1/2 (-1 - Cos[1/3 ArcTan[-1 + 2 eHat, 2 Sqrt[(1 - eHat) eHat]]] + Sqrt[3] Sin[1/3 ArcTan[-1 + 2 eHat, 2 Sqrt[(1 - eHat) eHat]]])}}  . Oct 11, 2020 at 3:59
• @Akku14 Ah yes, complex radicals can be eliminated in favour of trig functions. Oct 11, 2020 at 4:33

A cubic equation has exactly 3 roots. There are not 3 real and 3 complex roots! Could it be, that there is a misunderstanding in the interpretation of what MMA gives you? If you use Solve and apply the restrictions of the solution, you will get real numbers (note that the may have multiplicity >1). Let's make an example:

sol = Solve[(m*ω^2*x^2)/2 + (m*α*x^3)/3 == e &&
m > 0 && ω > 0 && α > 0 && e > 0 &&
e < (m*ω^6)/(6 α^2), x, Reals]


This gives the following result:

{{x -> ConditionalExpression[
Root[-6 e + 3 m ω^2 #1^2 + 2 m α #1^3 &, 1],
e > 0 &&
m > (6 e α^2)/ω^6 && α > 0 && ω >
0]}, {x ->
ConditionalExpression[
Root[-6 e + 3 m ω^2 #1^2 + 2 m α #1^3 &, 2],
e > 0 &&
m > (6 e α^2)/ω^6 && α > 0 && ω >
0]}, {x ->
ConditionalExpression[
Root[-6 e + 3 m ω^2 #1^2 + 2 m α #1^3 &, 3],
e > 0 &&
m > (6 e α^2)/ω^6 && α > 0 && ω >
0]}}


Could it be that you are not happy with Root objects and call them "complex"? Well, a root object simply means a root of the given polynomial. You may always evaluate roots to approximate machine numbers by using N.

We now choose some numerical values, taking care of the conditions. E.g.:

sol /. {m -> 7, α -> 1, ω -> 1, e -> 1} // N
*{{x -> -1.2047}, {x -> -0.762103}, {x -> 0.466801}}*)


You see, we get 3 real solutions for x.

• Maybe you can try out this for mathematica code : steampiano.net/msc Oct 10, 2020 at 12:56
• @wuyudi Thanks for the hint Oct 10, 2020 at 13:35