0
$\begingroup$

I need some help for solving a cubic equation. In this thread there is a solution of how a cubic equation can be solved with Mathematica

The exact real solutions of a cubic polynomial?

I tried this solution but I don't get any output.

Only th is a variable. The rest are constants.

roots = Solve[
     s2 + 
       1/(96 jmax^2 (b1 - b2 + jmax tf)) (b1^4 + b2^4 - 
          b2^3 jmax (4 tf + 3 th) + 
          b1^3 (-4 b2 + 4 jmax tf + 3 jmax th) + 
          3 b2^2 jmax^2 (2 tf^2 + 3 tf th + th^2) + 
          3 b1^2 (2 b2^2 - b2 jmax (4 tf + 3 th) + 
             jmax^2 (2 tf^2 + 3 tf th + th^2)) + 
          3 b2 jmax^2 (32 s1 + 
             jmax (4 tf^3 - 3 tf^2 th - 2 tf th^2 + th^3) + 
             32 tf v1) - 
          b1 (4 b2^3 - 3 b2^2 jmax (4 tf + 3 th) + 
             6 b2 jmax^2 (-6 tf^2 + 3 tf th + th^2) + 
             3 jmax^2 (32 s1 + 
                jmax (4 tf^3 - 3 tf^2 th - 2 tf th^2 + th^3) + 
                32 tf v2)) - 
          3 jmax^2 (jmax^2 tf (tf - th)^2 (tf + th) - 
             16 (v1 - v2)^2 + 16 jmax tf (2 s1 + tf (v1 + v2)))) == 0
     , th
     , Reals
     ] // ToRadicals // ComplexExpand // FullSimplify

Hope that somebody can help me Thanks in advance !

$\endgroup$
  • 2
    $\begingroup$ What exactly is your question though? The Solve expression works and returns results as conditional expressions containing Root objects. The rest might take a very long time to execute, but do you need the ToRadicals etc? What do you need to do with the results? $\endgroup$ – MarcoB Jun 20 '18 at 17:06
  • $\begingroup$ @MarcoB As Result i want an exact Solution. If i just use Solve i get 3 Solutions for th. These 3 Solutions are really long--> it seems that its an approximation... So i found this Solve Command with Roots. I ran this command but now its running for 20 min ... and i don't think that i will get an solution.... I need the Exact Solution to use it in another Matlab skript to calculate this variable th for different constants... Hope that you understand what i mean $\endgroup$ – IlPad Jun 20 '18 at 17:14
  • $\begingroup$ The Root object result is not an approximation. $\endgroup$ – Daniel Lichtblau Jun 20 '18 at 17:25
  • 2
    $\begingroup$ ...Moreover any solution in terms of parametrized radicals will either require a conditional to switch between three values, or else will be incorrect for some values of the parameters (because when there is only one real valued solution, it need not always be in the same radical solution). $\endgroup$ – Daniel Lichtblau Jun 20 '18 at 17:28
  • 2
    $\begingroup$ Actually the Wolfram Language also has that built in (with multiple methods). $\endgroup$ – Daniel Lichtblau Jun 21 '18 at 14:16
1
$\begingroup$

If I understand you correctly, you can do the following.

First solve for the generic cubic in terms of radicals and then substitute.

subs=Thread[{a0, a1, a2, a3} -> 
   CoefficientList[
    s2 + 1/(96 jmax^2 (b1 - b2 + jmax tf)) (b1^4 + b2^4 - 
        b2^3 jmax (4 tf + 3 th) + 
        b1^3 (-4 b2 + 4 jmax tf + 3 jmax th) + 
        3 b2^2 jmax^2 (2 tf^2 + 3 tf th + th^2) + 
        3 b1^2 (2 b2^2 - b2 jmax (4 tf + 3 th) + 
           jmax^2 (2 tf^2 + 3 tf th + th^2)) + 
        3 b2 jmax^2 (32 s1 + 
           jmax (4 tf^3 - 3 tf^2 th - 2 tf th^2 + th^3) + 32 tf v1) - 
        b1 (4 b2^3 - 3 b2^2 jmax (4 tf + 3 th) + 
           6 b2 jmax^2 (-6 tf^2 + 3 tf th + th^2) + 
           3 jmax^2 (32 s1 + 
              jmax (4 tf^3 - 3 tf^2 th - 2 tf th^2 + th^3) + 
              32 tf v2)) - 
        3 jmax^2 (jmax^2 tf (tf - th)^2 (tf + th) - 16 (v1 - v2)^2 + 
           16 jmax tf (2 s1 + tf (v1 + v2)))), th] // FullSimplify]
  ToRadicals[Root[a3 #^3 + a2 #^2 + a1 # + a0 &, #]] & /@ {1, 2,3} /. subs
$\endgroup$
  • $\begingroup$ Thanks for the answer and Help :) Are the three Solutions which i get as output the 3 Solutions for th ? $\endgroup$ – IlPad Jun 20 '18 at 17:47
  • $\begingroup$ Yes. And happy to help. $\endgroup$ – Subho Jun 20 '18 at 17:48
  • $\begingroup$ One Last Question: This Solution which you have generated is the same as the solution if you just use the solve command... only that the Equations are smaller is that right ? $\endgroup$ – IlPad Jun 20 '18 at 19:39
  • $\begingroup$ @IlPad Yes. This is just a way to bypass too much of simplification that Mathematica would otherwise want to do if you had entered the complicated expression all at once. $\endgroup$ – Subho Jun 21 '18 at 3:46
  • $\begingroup$ Ok Thanks! and if i change the cubic function to an quadric i just have to add an a4 or ? $\endgroup$ – IlPad Jun 21 '18 at 9:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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