bernd
(Bernd Sprenger)
January 30, 2020, 1:32pm
1
Hello,
I try to solve some equations and automatically select the right solution when assuming certain parameter properties.
How can I automatically select the right of those three solutions when assuming the result must always be a Real number and that the parameters a & b are both Reals and both are bigger than 0.
Thanks a lot for your help,
Bernd
[1]: https://community.wolfram.com//c/portal/getImageAttachment?filename=Test.png&userId=1869958
Test.nb (2.65 KB)
Hi Bernd,
Try
Solve[a*t^3 == b && a > 0 && b > 0, t, Reals]
rnachbar
(Robert Nachbar)
January 30, 2020, 3:43pm
3
Rohit’s solution gives a Root object, which may not be desirable.
To do the selection after the fact, use
In[1]:= soln = Solve[a t^3 == b, t]
Out[1]= {{t -> b^(1/3)/a^(
1/3)}, {t -> -(((-1)^(1/3) b^(1/3))/a^(1/3))}, {t -> ((-1)^(2/3)
b^(1/3))/a^(1/3)}}
In[2]:= Select[soln,
Simplify[Element[(t /. #), Reals], Assumptions -> {a > 0, b > 0}] &]
Out[2]= {{t -> b^(1/3)/a^(1/3)}}
Another option
Solve[a*t^3 == b && a > 0 && b > 0, t, Reals] // ToRadicals // Normal
(* {{t -> ((-1)^(2/3) b^(1/3))/a^(1/3)}} *)