0
$\begingroup$

I am working with analytical expressions that, as you will see from expr below, stem from certain expressions involving Abs[]. However, for further calculus I do not want Abs[] to appear in my expressions, so that I use ComplexExpand[] to get rid of it. Yet, there are terms in the ComplexExpanded expressions that are certainly zero, but Mathematica does not realize this immediately during the evaluation...

ClearAll["Global`*"];
$Assumptions = Element[{f1, f2, th, gb, wb, eb, deg, dwe, dwg}, Reals];

(* shorthand notation *)
sx = PauliMatrix[1];
sy = PauliMatrix[2];
sz = PauliMatrix[3];
id = PauliMatrix[0];

(* define some stuff *)
a1 = 2*Sqrt[wb^2 + gb^2 + dwg^2];
n1 = {gb, dwg, wb}/(a1/2);
u1 = Cos[a1/2]*id - I*n1.{sx, sy, sz}*Sin[a1/2];
unitaryD = {{Exp[-I*f1]*Cos[th], -Exp[I*f2]*Sin[th]}, {Exp[-I*f2]*Sin[th], Exp[I*f1]*Cos[th]}};

Now evaluate expr = ComplexExpand[Abs[Tr[u1.unitaryD]]] and observe that Simplify@expr[[1, 1]] is zero. So expr could actually be written much shorter... However, a naive Simplify@expr returns an expression involving Abs again. How can I avoid this? I am pretty sure the most obvious method is the TransformationFunctions option of Simplify, but I am absolutely clueless about how to use it.

enter image description here

For reference: happens on Mathematica 10.0.1 on Gentoo Linux 64bit

Edit: While replacing greek symbols for readability reasons, I forgot to replace one \[Alpha] which caused the Abs not to appear. Sorry for that.

$\endgroup$
  • 2
    $\begingroup$ no expression with Abs is produced for me if I run Simplify@expr. This is what I get: 2 \[Sqrt](( 1/(\[Alpha]1^2))((\[Alpha]1 Cos[f1] Cos[th] Cos[Sqrt[ dwg^2 + gb^2 + wb^2]] - 2 (wb Cos[th] Sin[f1] + (dwg Cos[f2] + gb Sin[f2]) Sin[th]) Sin[ Sqrt[dwg^2 + gb^2 + wb^2]])^2)) $\endgroup$ – glS Sep 13 '16 at 14:54
  • $\begingroup$ @glS Hm that's weird. I have already left office but will try on my desktop machine at home. Issue happens on Linux 64bit, MMA 10.0.1 $\endgroup$ – Lukas Sep 13 '16 at 15:26
  • $\begingroup$ I get the same expression as glS on a Linux 64 bit MMA 10.2.0.0 $\endgroup$ – andy269 Sep 13 '16 at 15:31
  • $\begingroup$ The closest version I have is v10.0.2.0 on a Mac. I do not see an Abs in expr and Simplify works fine with it. Perhaps you need to add the option TargetFunctions->{Re, Im} to your ComplexExpand $\endgroup$ – Bob Hanlon Sep 13 '16 at 15:48
  • $\begingroup$ No Abs on MMA 10.4.1, Linux Mint 17.3. $\endgroup$ – corey979 Sep 13 '16 at 17:21
1
$\begingroup$

When I provide the same input as you, my result is the same. Now when we look at expr[[1,1]]:

enter image description here

I notice that this has already been simplified to 0 when we simplify expr. Compare the expressions:

enter image description here

So it seems to me that Simplify@expr can't be written any shorter as you say. I can only surmise that your problem with the output of Simplify@expr then is just that there's an Abs in there. Well that can be removed quite easily by another application of ComplexExpand:

enter image description here

$\endgroup$
  • $\begingroup$ You're right. That must've been some instance of symbol-blindness or the like... Stared too much at longish expressions and couldn't realize that the disturbing Abs does not lead to any longer expressions if expanded... Thank you! $\endgroup$ – Lukas Sep 14 '16 at 12:56

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.