6

Consider this simple example:

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 Ω, Sqrt[-Δ^2 - Ω1^2]} *)

Isn't the last assumption equivalent to the first four? Why doesn't it work? Or why does it work in the first four cases?

xslittlegrass
  • 27,549
  • 9
  • 97
  • 186

1 Answers1

3

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 Ω} *)
wuyingddg
  • 1,943
  • 10
  • 14
  • Why does it work if we have assumptions like a>0 b>0? For example, this works:mytrans[expr_] := expr /. a + b :> c FullSimplify[Sqrt[-a - b], TransformationFunctions -> {Automatic, mytrans}, Assumptions -> {c > 0, a > 0, b > 0}] – xslittlegrass Sep 05 '14 at 04:10
  • 1
    Because FullSimplify[Sqrt[-a - b], Assumptions -> { a > 0, b > 0}] give the result $i \sqrt{a+b}$, so mytrans can work. But I don't know why it will give different result with Assumptions -> {a, b} ∈ Reals, even Assumptions -> {a >=0 , b>= 0} can't give $i \sqrt{a+b}$. That really confuse me a lont – wuyingddg Sep 05 '14 at 08:08