FullSimplify[c Conjugate[c]]
returns
Abs[c]^2
while
FullSimplify[2 c Conjugate[c]]
returns
2 c Conjugate[c]
This seems strange to me. For some reason, a third entry in the Times[] precludes the simplification with Abs[]. Is this just a shortcoming of the way FullSimplify[] is implemented, or is there some good reason for this?
It's quite annoying when I have a complicated expression and some terms are real and positive definite, but this is not immediately obvious, because FullSimplify[] is failing to combine variables with their complex conjugates.
Answer
Well, FullSimplify[ ]
has its own creed about what transformations should try and how to measure the complexity of its output.
You can coerce it to perform in some crazy ways, though:
exp = 2 c Conjugate[c];
SimplifyCount[p_] := First@ImageDimensions@Rasterize[p]
f[e_] := e /. Times[x___, a_, y___, Conjugate[a_], z__] :> Times[Abs[a]^2, x, y, z]
FullSimplify[exp, TransformationFunctions -> f, ComplexityFunction -> SimplifyCount]
(* 2 Abs[c]^2 *)
Comments
Post a Comment