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 ComplexExpand
ed 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.
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.
Abs
is produced for me if I runSimplify@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$Abs
inexpr
andSimplify
works fine with it. Perhaps you need to add the optionTargetFunctions->{Re, Im}
to yourComplexExpand
$\endgroup$Abs
on MMA 10.4.1, Linux Mint 17.3. $\endgroup$