4

I have the following equation:

$$D=\frac{1}{64} \pi A ^3 B \sin \left(C\right)-\frac{1}{2} \pi A B \sin \left(C\right)$$

which I want to solve for $A$. The equation is cubic in $A$ so this should give me 3 answers and, potentially, imaginary parts to the answers. I know, from the physical meaning of the parameters, that all parameters ($A$,$B$,$C$ and $D$) are positive and real.

My question is: how can I use Solve on this equation and make sure that there will be no imaginary parts popping up in the solution?

I have used the suggestion by Chris and tried:

Solve[d == 1/64 π a^3 b Sin[c] - 1/2 π a b Sin[c], a, Reals]

but I still see that there is a $\imath\sqrt{3}$ term in the answer. Why does this still appear?

rm -rf
  • 88,781
  • 21
  • 293
  • 472
Michiel
  • 355
  • 2
  • 12
  • related? http://mathematica.stackexchange.com/questions/3369/presenting-a-real-number-as-real-instead-of-imaginary – chris Feb 26 '13 at 20:34
  • Not exactly. I found this post but I would like Solve to work with the assumptions already 'in mind'. Not `change' the answer afterwards – Michiel Feb 26 '13 at 20:37
  • 3
    Solve[F[x],x,Reals] as suggested in http://reference.wolfram.com/mathematica/ref/Solve.html ? e.g. 'Solve[x^3 + 2 x^2 + 3 x + 4 == 0, x, Reals] // N' – chris Feb 26 '13 at 20:38
  • That is actually a good point. I didn't know that Solve had that option. I tried using $Assumptions, but that didn't help. Thanks! – Michiel Feb 26 '13 at 20:41
  • `Solve[x^3 + 2 x^2 + 3 x + 4 == 0, x, Reals] // ToRadicals // First // First' gives you the formal unique real root – chris Feb 26 '13 at 20:44
  • Never mind this comment..... Too quick to respond while you where still explaining – Michiel Feb 26 '13 at 20:46
  • Use ToRadicals as in my answer below – chris Feb 26 '13 at 20:47
  • Not all solutions for A can be positive; they must sum to zero (the coefficient of the quadratic term). Also it would be helpful to post Mathematica notation so it can be cut/pasted rather than keyed in from scratch by all concerned. – Daniel Lichtblau Feb 26 '13 at 20:57
  • The i sqrt(3) appears of necessity in radical solutions to cubic equations. Check this Wikipedia note. If you want something that avoids it, maybe use the Solve option Cubics->False. – Daniel Lichtblau Feb 26 '13 at 21:07
  • In future, please post Mathematica input so that we (the folks trying to answer your question) can easily copy paste into a notebook. – rm -rf Feb 26 '13 at 23:00
  • @DanielLichtblau thanks for the explanation, I was not aware of that phenomenon. The Cubics->False option doesn't solve it however – Michiel Feb 27 '13 at 06:29
  • Allow me to welcome you to StackOverflow and remind three things we usually do here: 1) As you receive help, try to give it too answering questions in your area of expertise 2) Read the FAQs 3) When you see good Q&A, vote them upusing the gray triangles, as the credibility of the system is based on the reputation that users gain by sharing their knowledge. Also remember to accept the answer that better solves your problem, if any, by pressing the checkmark sign – – chris Feb 27 '13 at 09:14
  • By setting Cubics->False one gets explicit Root[] functions as solutions. When you plug in numeric values for the parameters they will numericize to reals if they are indeed real valued. To see what I mean, try this. ss = a /. Solve[d == 1/64 \[Pi] a^3 b Sin[c] - 1/2 \[Pi] a b Sin[c], a, Cubics -> False]; sseval = ss /. {d -> 1/2, b -> 3/4, c -> 7}; N[sseval] Out[1765]= {-5.30097556376, -0.654772200975, 5.95574776474} Then repeat with ssrad = a /. Solve[d == 1/64 \[Pi] a^3 b Sin[c] - 1/2 \[Pi] a b Sin[c], a, Cubics -> True]; etc. – Daniel Lichtblau Feb 27 '13 at 15:01

1 Answers1

5

You can use the Reals Domain option in Solve as in

 Solve[x^3 + 2 a x^2 + 4 == 0, x, Reals] // ToRadicals // First // First

Mathematica graphics

For the example above, calling d=2D/Pi/B/Sin[C]

 Solve[d == 1/32  A^3  -  A , A, Reals] // ToRadicals // First //First // FullSimplify

Mathematica graphics

chris
  • 22,860
  • 5
  • 60
  • 149
  • I have done what you mentioned, except for the //First//First part, because that will give me the wrong 1 of the 3 answers. – Michiel Feb 26 '13 at 20:56