0
$\begingroup$

Now I'm trying to use Mathematica to simplify an expression like this:

$P \sqrt{-P + \sqrt{M^2 + P^2}} + \sqrt{(M^2 + P^2) (-P + \sqrt{M^2 + P^2})} - M \sqrt{P + \sqrt{M^2 + P^2}}$

where $P,M>0$

It should be zero, obviously. But Mathematica cannot do this simplification. Is there any technique that will help Mathematica to deal with this kind of expression?

$\endgroup$
  • $\begingroup$ There are three left brackets in your formulate but just two right brackets.Also "It should be zero" is not correct,for example P=1, M=-2. $\endgroup$ – Apple Jun 15 '14 at 0:35
3
$\begingroup$

I always find that I need to give Mathematica some help when manipulating this sort of expression, but the reason is (invariably?) that I have to make some assumptions in order to make progress through the simplification. For instance, you have to be careful with "simplifying" expressions such as Sqrt[M^2] to M (i.e. using PowerExpand), because this introduces the assumption M > 0.

Here is a sequence of steps that you could use to simplify your expression (evaluate it to see the intermediate outputs):

P Sqrt[\[Minus]P + Sqrt[M^2 + P^2]] + Sqrt[(M^2 + P^2) (\[Minus]P + Sqrt[M^2 + P^2])] \[Minus] M Sqrt[P + Sqrt[M^2 + P^2]]

% // PowerExpand

% // FullSimplify

% /. Sqrt[a_] b_ + a_ c_ :> Sqrt[a] (b + Sqrt[a] c)

% /. Sqrt[a_ + b_] Sqrt[a_ - b_] :> Sqrt[a^2 - b^2]

% // PowerExpand

(* 0 *)

M >= 0 is implicit in the final step of the derivation.

$\endgroup$
  • $\begingroup$ Great answer. So why isn't this stuff already in MMa functions??? $\endgroup$ – Jerry Guern Sep 6 '16 at 2:46
1
$\begingroup$

I like such questions, and like very much the answer of Stephen Luttrell. Such questions are fun by themselves, and for this reason I am giving my version of the answer too. I propose to first multiply the result by Sqrt[p + Sqrt[m^2 + p^2]] and then to transform. This is the expression:

 expr1 = p*Sqrt[-p + Sqrt[m^2 + p^2]] + 
   Sqrt[(m^2 + p^2)*(Sqrt[m^2 + p^2] - p)] - 
   m*Sqrt[p + Sqrt[m^2 + p^2]];

now let us multiply and Expand:

 expr2 = expr1*Sqrt[p + Sqrt[m^2 + p^2]] // Expand

It gives this:

(*   -m p - m Sqrt[m^2 + p^2] + 
 p Sqrt[-p + Sqrt[m^2 + p^2]] Sqrt[p + Sqrt[m^2 + p^2]] + 
 Sqrt[(m^2 + p^2) (-p + Sqrt[m^2 + p^2])] Sqrt[p + Sqrt[m^2 + p^2]]  *)

Let us now teach Mma to fuse the square roots:

expr3 = Map[ReplaceAll[#, Sqrt[a_]*Sqrt[b_] -> Sqrt[a*b]] &, expr2]

yielding the following:

(*    -m p - m Sqrt[m^2 + p^2] + 
 p Sqrt[(-p + Sqrt[m^2 + p^2]) (p + Sqrt[m^2 + p^2])] + Sqrt[(m^2 + 
    p^2) (-p + Sqrt[m^2 + p^2]) (p + Sqrt[m^2 + p^2])]                *)

And as the final stroke let us open parentheses under the radicals:

Map[Expand, expr3, 4] // Simplify[#, {m > 0, p > 0}] &

giving

(* 0 *)

as you expected.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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