Why doesn't
FullSimplify[ Abs[a*Cos[x]]^2, Assumptions -> {{a, x} ∈ Reals}]
simplify to
(a*Cos[x])^2
but this query
Simplify[ (a*Cos[x])^2 == Abs[a*Cos[x]]^2, Assumptions -> {{a, x} ∈ Reals}]
yields True? I'm using Mathematica 8.0.
Why doesn't
FullSimplify[ Abs[a*Cos[x]]^2, Assumptions -> {{a, x} ∈ Reals}]
simplify to
(a*Cos[x])^2
but this query
Simplify[ (a*Cos[x])^2 == Abs[a*Cos[x]]^2, Assumptions -> {{a, x} ∈ Reals}]
yields True? I'm using Mathematica 8.0.
We need an appropriate complexity function. There were a few questions on this topic but in general, it is not obvious how to design an adequate function and it may appear quite difficult. Moreover there have been certain hidden changes of ComplexityFunction in Mathematica 9 (see: FullSimplify does not work on this expression with no unknowns.
By default we have:
OptionValue[ FullSimplify, ComplexityFunction]
Automatic
It is not just the LeafCount function, nevertheless we could regard it as close to LeafCount.
LeafCount /@ {Abs[a Cos[x]]^2, a^2 Cos[x]^2, (a Cos[x])^2}
{7, 8, 8}
Now the problem at hand is choosing a good candidate for ComplexityFunction, but since the given expression is quite simple, we can choose e.g.:
cf[k_][e_] := k Count[e, _Abs, {0, Infinity}] + LeafCount[e]
Now, FullSimplify as well as Simplify yield in ver.8 (similarly in ver. 9):
FullSimplify[ Abs[ a Cos[x]]^2, Assumptions -> {(a | x) ∈ Reals},
ComplexityFunction -> #]& /@ { cf[1], cf[2]}
{ Abs[a Cos[x]]^2, a^2 Cos[x]^2}
We can see that cf[2] appears to be sufficient to perform the desired simplification.
Warning
One should be careful since ComplexityFunction works a bit differently in Mathematica 9. The linked post points out quite straightforward differences between the recent versions of the system.
Absis considered simpler:LeafCount /@ {Abs[a Cos[x]]^2, (a*Cos[x])^2}Have a look at theComplexityFunctionoption for Simplify. (This is not posted as an answer because I think it is a duplicate question) – ssch Sep 10 '13 at 12:32