Firstly, let's see this case:
In[45]:= (FullSimplify[Sqrt[-a^2 - b^2],
Assumptions -> #] &) /@ {{a > 0, b > 0, c > 0}, {a > 0, b < 0,
c > 0}, {a < 0, b > 0, c > 0}, {a < 0, b < 0,
c > 0}, {a ∈ Reals, b ∈ Reals, c > 0}}
Out[45]= {I Sqrt[a^2 + b^2], I Sqrt[a^2 + b^2], I Sqrt[a^2 + b^2],
I Sqrt[a^2 + b^2], Sqrt[-a^2 - b^2]}
In the last assumption, $\sqrt{-a^2-b^2}$ isn't simplified. It seems that for some unknown reasons, FullSimplify
doesn't work in this case, though Resolve
can give the correct answer.
In[76]:= FullSimplify[Sqrt[-(a^2 + b^2)] == I Sqrt[a^2 + b^2],
Assumptions -> {a, b} ∈ Reals]
Out[76]= Sqrt[-a^2 - b^2] == I Sqrt[a^2 + b^2]
In[77]:= Resolve[
ForAll[{a, b}, {a, b} ∈ Reals,
Sqrt[-a^2 - b^2] == I Sqrt[a^2 + b^2]]]
Out[77]= True
Then let's see this
In[88]:= Sqrt[-a-b]/.a+b:>c
Out[88]= Sqrt[-a-b]
In[89]:= HoldForm[Sqrt[-a-b]/.a+b:>c]//FullForm
Out[89]//FullForm= HoldForm[ReplaceAll[Power[Plus[Times[-1,a],Times[-1,b]],Rational[1,2]],RuleDelayed[Plus[a,b],c]]]
The FullForm shows that $\sqrt{-a-b}$ is Plus[Times[-1,a],Times[-1,b]], while $\sqrt{a+b}$ is Plus[a,b], they don't match, so the ReplaceAll
doesn't work
To avoid this case, we can use a->c-b
as the rule, and it will be OK
In[81]:= Sqrt[-a - b] /. a :> c - b
Out[81]= Sqrt[-c]
Now we can return you problem, change mytrans
in this way, and the answer will be correct
mytrans[expr_] :=
expr /. Ω1^2 :> Ω^2 - Δ^2
f =
FullSimplify[Sqrt[-Δ^2 - Ω1^2],
TransformationFunctions -> {Automatic, mytrans}, Assumptions -> #] &;
f /@ {{Δ > 0, Ω1 > 0, Ω > 0},
{Δ > 0, Ω1 < 0, Ω > 0},
{Δ < 0, Ω1 > 0, Ω > 0},
{Δ < 0, Ω1 < 0, Ω > 0},
{Δ ∈ Reals, Ω1 ∈ Reals, Ω > 0}}
(* {I Ω, I Ω, I Ω, I Ω, I Ω} *)