I would expect the following:
FullSimplify[(a*b)^i, a > 0 && b > 0 && i > 0]
to give me a^i * b^i
as output. Much like (a*b)^2
is immediately reduced to a^2 * b^2
.
How can I achieve this?
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communityAs mentioned in the comments, the default ComplexityFunction
considers a^i b^i
to be more complex than (a b)^i
, hence your desired form will not be returned.
Besides using PowerExpand
, you could also use a ComplexityFunction
that penalizes complex expressions in the base of Power
objects:
cf[expr_] := LeafCount[expr] + Total @ Cases[expr, Power[a_, _] :> 10 LeafCount[a], All]
FullSimplify[
(a b)^i,
a>0 && b>0 && i>0,
ComplexityFunction -> cf
]
a^i b^i
(a*b)^i // PowerExpand
a^i b^i
As @MarcoB points out, there are many assumptions here, detailed in the documentation: in this case, it is assumed that i
is an integer and a
and b
are positive real numbers.
PowerExpand
makes some assumptions (real values of variables), which happen to be upheld in this particular case.
$\endgroup$
The simple ComplexityFunction
cf[e_] := LeafCount[e] + 10 Count[e, _Times]
also works:
FullSimplify[(a b)^i, a > 0 && b > 0 && i > 0, ComplexityFunction -> cf]
(* a^i b^i *)
If (a b)^i
lies lower in the expression, then its level must be specified. For instance,
cf2[e_] := LeafCount[e] + 10 Count[e, _Times, {2}]
FullSimplify[1 + (a b)^i, a > 0 && b > 0 && i > 0, ComplexityFunction -> cf2]
(* 1 + a^i b^i *)
LeafCount[(a b)^i] < LeafCount[a^i b^i]
, so it would require some special simplification rule forSimplify
to give you what you want. As I understand it, the(a b)^2
case is not being simplified, but simply processed that way by the parser before evaluation. $\endgroup$Distribute[(a*b)^i,Times, Power]
$\endgroup$