2
$\begingroup$

Doing FullSimplify[ToRadicals[res, Assumptions -> assum], assum] is taking too much time for a simple expression. Am I doing something wrong? Is there anything I can do to make it finish?

Here's the full code, everything runs fast until the FullSimplify:

assum = 0 < v < c && L > 0 && t > 0 && x > 0 && a > 0 && 
   0 < cmedium < c && c > 2 v && 1 <= n < c && n >= 1;

b = v/c
g = 1/Sqrt[(1 - b^2)]
cmedium = c/n + v (1 - 1/n^2);

t1s = Solve[t == Sqrt[(L/g + v*t)^2 + (x - a)^2]/cmedium && assum, t]
res = Normal[t /. First@t1s]

FullSimplify[ToRadicals[res, Assumptions -> assum], assum]
$\endgroup$
2
  • 3
    $\begingroup$ Why do you need the output in radicals instead of a Root object? And what's wrong with using Solve without assumptions, e.g., Simplify[Solve[t == Sqrt[(L/g + v*t)^2 + (x - a)^2]/cmedium, t], assum] $\endgroup$
    – Carl Woll
    Commented Dec 28, 2017 at 1:23
  • 1
    $\begingroup$ Without assumptions I get two roots, I need only the positive one (t>0). If I use the assumption I get the positive, but I get the Root object... To share and better visualize the result I don't understand why can't Mathematica show the result without the Root object, when it apparently obviously exists... (the Root object is unnecessarily complex). I know I can Solve and choose the second solution manually, that I know is the positive one. But I was looking forward to Mathematica doing this. $\endgroup$
    – arod
    Commented Dec 28, 2017 at 2:25

3 Answers 3

3
$\begingroup$

I won't address why Solve returns a Root object when given assumptions. Instead, I will suggest that you can instead programmatically determine which solution returned by Solve without assumptions is positive. First, the solution from a simple Solve:

b = v/c;
g = 1/Sqrt[(1-b^2)];
cmedium = c/n + v (1-1/n^2);
sol = t /. Solve[t == Sqrt[(L/g + v*t)^2 + x^2]/cmedium, t];

Then, use Reduce to check which solution is positive:

Reduce[sol[[1]] > 0 && 0<v<c && a>0 && x>0 && L>0 && n>0]

False

So, the second solution is the only one that can be positive. After simplification:

FullSimplify[sol[[2]], 0<v<c && a>0 && x>0 && L>0 && n>0]

$\frac{n^2 \left(L n^2 v \sqrt{1-\frac{v^2}{c^2}}+\sqrt{\frac{(c-v) (c+v) \left(c L n+L \left(n^2-1\right) v\right)^2}{c^2}+x^2 (c n-v) (n (c+2 n v)-v)}\right)}{(c n-v) (n (c+2 n v)-v)}$

the same as your answer.

$\endgroup$
1
  • $\begingroup$ +1. Somehow, when I see your answers and it's also something I know how to do, I think, yep, that's kinda the way I'd do it. I give a variant in my answer. If you simplify the reduction of sol[[2]] > 0 as in your answer, it will simplify to True as well. $\endgroup$
    – Michael E2
    Commented Dec 28, 2017 at 4:11
1
$\begingroup$

One way (Simplify[Reduce[assum \[Implies] cond,...], assum] seems to often work for me):

sol = Solve[t == Sqrt[(L/g + v*t)^2 + (x - a)^2]/cmedium, t];
Simplify[
 Hold@Reduce[Implies[assum, t > 0], {}, Reals] /. sol // ReleaseHold,
 assum]
{pos} = Pick[sol, %]
(*
  {False, True}   <-- nonpositive, positive

  {{t -> (2 L n^4 v Sqrt[((c - v) (c + v))/c^2] +
      √((4 L^2 n^8 (c - v) v^2 (c + v))/c^2 + 
         4 n^4 (c^2 n^2 - 2 c n v + 2 c n^3 v + v^2 - 
            2 n^2 v^2) (a^2 + L^2 - (L^2 v^2)/c^2 - 2 a x + 
            x^2)))/(2 (c^2 n^2 - 2 c n v + 2 c n^3 v + v^2 - 2 n^2 v^2))}}
*)
$\endgroup$
0
$\begingroup$

This is a workaround. Because I know the 2nd solution is the positive, I can choose

assum = 0 < v < c && L > 0 && t > 0 && x > 0 && a > 0 && 
   0 < cmedium < c && c > 2 v && 1 <= n < c && n >= 1 && c > 1;

b = v/c;
g = 1/Sqrt[(1 - b^2)];
cmedium = c/n + v (1 - 1/n^2);

t1s = Solve[t == Sqrt[(L/g + v*t)^2 + (x)^2]/cmedium, t]
t1 = FullSimplify[t /. t1s[[2]], assume]

which outputs

$$ \left\{\left\{t\to \frac{2 L n^4 v \sqrt{\frac{(c-v) (c+v)}{c^2}}-\sqrt{\frac{4 L^2 n^8 v^2 (c-v) (c+v)}{c^2}+4 n^4 \left(c^2 n^2+2 c n^3 v-2 c n v-2 n^2 v^2+v^2\right) \left(-\frac{L^2 v^2}{c^2}+L^2+x^2\right)}}{2 \left(c^2 n^2+2 c n^3 v-2 c n v-2 n^2 v^2+v^2\right)}\right\},\left\{t\to \frac{\sqrt{\frac{4 L^2 n^8 v^2 (c-v) (c+v)}{c^2}+4 n^4 \left(c^2 n^2+2 c n^3 v-2 c n v-2 n^2 v^2+v^2\right) \left(-\frac{L^2 v^2}{c^2}+L^2+x^2\right)}+2 L n^4 v \sqrt{\frac{(c-v) (c+v)}{c^2}}}{2 \left(c^2 n^2+2 c n^3 v-2 c n v-2 n^2 v^2+v^2\right)}\right\}\right\} $$

choosing the 2nd solution and simplifying:

$$ \frac{L n^4 v \sqrt{1-\frac{v^2}{c^2}}+\sqrt{n^4 \left(\frac{(c-v) (c+v) \left(c L n+L \left(n^2-1\right) v\right)^2}{c^2}+x^2 (c n-v) (n (c+2 n v)-v)\right)}}{(c n-v) (n (c+2 n v)-v)} $$

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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