5
$\begingroup$

In the following code I wonder how I can force Mathematica to do the squareroots:

In[190]:= ClearAll["`*"] In[191]:= kappaW = (W^2 - M^2)/(2 W); kappaWR = (WR^2 - M^2)/(2 WR); fpiN = Sqrt[1/(2 Pi )* kappaW/q * M/WR* GammapiN/Gammatot^2]; fgammaN = kappaW/kappaWR; Gammagamma = (M/W)^2 Eg^2/Pi M/WR AHel^2; Ampl = A0quer fgammaN * (Gammatot*WR)/(WR^2 - W^2 - I*WR*Gammatot)* fpiN*CpiN; In[197]:= Ampl2 = ComplexExpand[Abs[Ampl]]^2 Out[197]= (A0quer^2 CpiN^2 Sqrt[GammapiN^2] Sqrt[M^2] ((-M^2 + W^2)^2)^(3/2) WR^4)/(4 \[Pi] Sqrt[q^2] (W^2)^( 3/2) Sqrt[WR^2] (-M^2 + WR^2)^2 (Gammatot^2 WR^2 + (-W^2 + WR^2)^2)) 

I am wondering why in the last statement terms such as Sqrt[M^2] appear? Why does it not evaluate the square root to give M instead? After all, ComplexExpand assumes that all variables are real. Does it have something to do with the sign of the Sqrt ? If so, how can I force it to always use the positive root?

$\endgroup$
2
  • 5
    $\begingroup$ Assuming[M > 0, Simplify@Sqrt[M^2]]. $\endgroup$ Commented May 20 at 14:08
  • 1
    $\begingroup$ If you want to know why Mathematica doesn't return M, ask for counter-examples, e.g., FindInstance[Sqrt[M^2] != M, M, Integers, 3] which should lead you to conclude that Sqrt[M^2] == Abs[M]. Or evaluate Reduce[{M \[Element] Reals, Sqrt[M^2] == M}] to see that M must be nonnegative. $\endgroup$ Commented May 20 at 18:38

2 Answers 2

2
$\begingroup$

Since I feel that you are still confused, let me try to explain it in more detail. ComplexExpand assumes the variables to be real, but this alone does not guarantee the simplification of terms like (as mentioned in the comment): WR^4/Sqrt[WR^2] to WR^3. Sqrt[WR^2] is infact both WR and -WR. To force it to use the positive root only, you will have to give it a condition that WR>0. It has no way to do this automatically.

For your problem, here are two ways to approach this:

  1. You can use PowerExpand.
Ampl2 = ComplexExpand[Abs[Ampl]]^2 // PowerExpand (*(A0quer^2 CpiN^2 GammapiN M (-M^2 + W^2)^3 WR^3)/(4 \[Pi] q W^3 (-M^2 + WR^2)^2 (Gammatot^2 WR^2 + (-W^2 + WR^2)^2))*) 
  1. Give the Assumptions and Simplify.
Ampl2 = Simplify[ComplexExpand[Abs[Ampl]]^2, M > 0 && WR > 0 && W > 0] (* (A0quer^2 CpiN^2 GammapiN M (M^2 - W^2)^3 WR^3)/(4 \[Pi] q W^3 (M^2 - WR^2)^2 (W^4 + Gammatot^2 WR^2 - 2 W^2 WR^2 + WR^4))*) 

You will notice that the result is slightly different in this case. Instead of (-M^2 + WR^2)^2 in the previous case you have (M^2 - WR^2)^2. Which one is correct, you may ask. Both of them. It depends on which of M^2 and WR^2 is larger.

The problem boils down to the fact that when doing calculations done by hand we assume (without thinking) a lot of things. But when working with Mathematica, which is made to work for the most general case (the initial assumption being that everything is complex), you will have to give it more details so that it can understand what you really want. I hope it helps.

$\endgroup$
2
  • $\begingroup$ Thanks a lot. this helps. But: it would still be helpful if Mathematica had a way to declare all variables to be real so that a simple absolute value of a complex number could be done easily, such as Abs[x + iy]^2 = x^2 + y^2. $\endgroup$ Commented May 21 at 14:48
  • 1
    $\begingroup$ $Assumptions = Element[x_, Reals] && x_ >= 0 use this. Then if you now do Simplify[ComplexExpand[Abs[Ampl]]^2] , then all the variables will be treated as real and greater than 0. (But it comes with a caution that it will make all the variables in the notebookReal so use it with care) $\endgroup$ Commented May 21 at 15:10
3
$\begingroup$

You could use Composition[PowerExpand, ComplexExpand] instead of just ComplexExpand. PowerExpand assumes that all variables are positive real numbers.

$\endgroup$
1
  • $\begingroup$ I am still at a loss: In the example given all I want to do is getting the absolute square of the complex expression for Ampl in the example given. I was first wondering why Abs alone would not do it. And then: in the result of ComplexExpand I see, for example, a combination WR^4/Sqrt[WR^2]. Why doesn't this simply evaluate to WR^3? $\endgroup$ Commented May 21 at 10:28

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.