# What is the reason that $zz^*$ is not written as $|z|^2$ sometimes?

For a general (complex) number $z$ I sometimes get terms that explicitly writes (for instance)

$$2zz^*+|z|^2.$$ I should add that these expressions come from long calculations involving packages (FeynCalc). How come FullSimplify[] does not simply put this expression to $3|z|^2$ instead?

• ComplexExpand is intended for this sort of transformation. But it is a bit dull in this case and benefits from postprocessing by Simplify. Simplify[ComplexExpand[z*Conjugate[z], z, TargetFunctions->{Abs,Arg}]] gives the desired result. Nov 25, 2015 at 18:59
• @DanielLichtblau that was cool, thanks. Nov 27, 2015 at 10:30

Running FullSimplify I get

FullSimplify[z Conjugate[z] + 2 Abs[z]^2]

3 z Conjugate[z]


This is actually more simple than 3 Abs[z]^2 in the eyes of FullSimplify. See here for more info.

SimplifySimplifyCount[3 z Conjugate[z]]

5

SimplifySimplifyCount[3 Abs[z]^2]

6


Luckily there are many ways to guide FullSimplify. Here is one such way.

FullSimplify[z Conjugate[z] + 2 Abs[z]^2, ExcludedForms -> {_Abs}]

3 Abs[z]^2


## Edit

A more general way is to use a combination of ComplexityFunction and TransformationFunctions. Basically we'll assign a penalty whenever the unwanted pattern is present and teach FullSimplify the rule we want to use.

ToAbs[a_. z_ Conjugate[z_]] := a Abs[z]^2
ToAbs[e_] := e

FullSimplify[a1 Conjugate[a1] + a1 Conjugate[a1] + b1 Conjugate[b1],
ComplexityFunction -> (LeafCount[#] + 100 Count[#, _Conjugate, ∞] &),
TransformationFunctions -> {ToAbs, Automatic}
]

2 Abs[a1]^2 + Abs[b1]^2

• OK thanks. let me try that. Nov 25, 2015 at 16:48
• When I write FullSimplify[a1 Conjugate[a1] + a1 Conjugate[a1] + b1 Conjugate[b1], ExcludedForms -> {_Abs}] I get Abs[b1]^2 + 2 a1 Conjugate[a1] Nov 25, 2015 at 16:51
• Is there a simply way of telling Mathe to write everything in absolute bars? It just looks nicer that's all... Nov 25, 2015 at 16:52
• @Faq see my edit. Also you could try TraditionalForm to get the vertical bars. Nov 25, 2015 at 17:00
• It will only work when you explicitly pass these options and I don't think there's much of a slowdown. Nov 25, 2015 at 17:06