Problem with simplification in Mathematica

  • Context: Mathematica 
  • Thread starter Thread starter physics_nil
  • Start date Start date
  • Tags Tags
    Mathematica
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
6 replies · 4K views
physics_nil
Messages
4
Reaction score
0
Assuming[a>0 && b>0 && c>0, FullSimplify[a+Sqrt[b+c]-Sqrt[a^2+b+c+2 a Sqrt[b+c]]]] does not simplify it to zero. Although output of FullSimplify[a+Sqrt[b+c]-Sqrt[a^2+b+c+2 a Sqrt[b+c]]==0] is true, even without any assumptions. Can anyone please resolve this puzzle...Thanks
 
Physics news on Phys.org
The reason it doesn't simplify to zero is that this would throw away one possibility. Basically you are asking it to simplify (x-Sqrt(x^2)). Since Sqrt(x^2) can be either x or -x, (x-Sqrt(x^2)) can be either 0 or 2x. By simplifying this to zero, you are throwing away the second possibility. Mathematica will keep all possibilities unless you explicitly tell it otherwise.
 
Your statement is not true as i have specified a>0,b>0,c>0
If you ask mathematica to simplify x-Sqrt[x^2] with assumption x>0, it indeed gives zero!
 
I used the simplified example with x to illustrate the problem. In your problem, just because a,b,c>0 doesn't mean that Sqrt[b+c]>0, or that Sqrt[a^2+b+c+2 a Sqrt[b+c]]>0. Even if you tell it that both of these are >0, that still isn't enough. You have to either explicitly tell it to use the positive square root, like this:

FullSimplify[ a + Sqrt[b + c] - Sqrt[a^2 + b + c + 2 a Sqrt[b + c]] /.
Sqrt[a^2 + b + c + 2 a Sqrt[b + c]] -> a + Sqrt[b + c]]

or else square both terms to eliminate the sign ambiguity, like this:

FullSimplify[(a + Sqrt[b + c])^2 - (Sqrt[
a^2 + b + c + 2 a Sqrt[b + c]])^2, {a > 0, b > 0, c > 0}]

It's only a computer program, after all, so it does have its limitations.
 
If you're only interested a, b and c being real, then you could use something like:

In[1]:= Reduce[a+Sqrt[b+c]-Sqrt[a^2+b+c+2 a Sqrt[b+c]]==0,{a,b,c},Reals]
Out[1]= (a<=0&&c>=a^2-b)||(a>0&&c>=-b)

In[2]:= Simplify[%,a>0&&b>0&&c>0]
Out[2]= True
 
@phyzguy
Then why Assuming[x>0,Sqrt[x^2] //Simplify] is x? I think mathematica only considers positive sqrt.
 
@Simon_Tyler
The step comes in a intermediate step of a long program. Unless the answer in simplification is zero, the final answer is too complicated to read. Any suggestion?