# FullSimplify does not distribute Abs over multiplication

FullSimplify[Abs[x]^2, x \[Element] Reals]


reasonably returns x^2, but the barely-more-complicated expression

FullSimplify[Abs[x y]^2, {x, y} \[Element] Reals]


returns Abs[x y]^2 unsimplified. Any ideas why? I can just do the replacement rule

{Abs[x_]^2 -> x^2}


at the end of a complicated expression if I know that x is real, but now I'm worried that FullSimplify[] is missing other obvious places to remove Abs[].

• FWIW, FullSimplify[FunctionExpand[Abs[x y]^2], {x, y} ∈ Reals] does yield x^2y^2. – Ruslan Nov 20 '15 at 9:45
• ComplexExpand is another way to get your desired result. – Michael E2 Nov 20 '15 at 11:24

FullSimplify returns the simpler expression:

SimplifySimplifyCount[Abs[x y]^2]

(* 6 *)

SimplifySimplifyCount[x^2 y^2]

(* 7 *)


See also the documentation for ComplexityFunction, in particular the Scope section.

• Mathematica considers Abs[x y]^2 to be simpler than (x y)^2, even though the Abs[] requires an extra operation? Bizarre. I suppose in the latter case, it first distributes the square and so has to perform two squaring operations, which is more computationally intensive than taking an absolute value and then performing a single squaring operation. – tparker Nov 20 '15 at 6:16
• @tparker Look at FullForm for each expression. – bbgodfrey Nov 20 '15 at 6:22
• @tparker Simplicity is in the eye of the beholder: FullForm[(x y)^2] is not simpler than FullForm[Abs[x y]^2]. Yes, (x y)^2 does autoevaluate to x^2 y^2. One can always define a custom ComplexityFunction. – ilian Nov 20 '15 at 6:22