PowerExpand¶
Status: Stable
documented, exercised by the test suite and/or worked examples, with no known limitations recorded.
Description¶
PowerExpand[expr]
expands (a b)^c to a^c b^c and (a^b)^c to a^(b c), and expands Log and Arg of products and powers.
PowerExpand[expr, {x1, x2, ...}]
expands only with respect to the listed variables.
Notes
The transformations are correct in general only when c is an integer or a and b are positive reals; PowerExpand otherwise disregards branch cuts. With the Assumptions option, Assumptions-\>True gives a universally-correct result and Assumptions-\>assum a result valid under assum. PowerExpand threads over lists, equations, inequalities, and logic functions.Examples (10)¶
Every input below was run against the current Mathilda build and its output recorded.
Basic examples (3)¶
In[1]:= PowerExpand[Sqrt[x y]]
Out[1]= Sqrt[x] Sqrt[y]
In[2]:= PowerExpand[Log[(a b)^c]]
Out[2]= (Log[a] + Log[b]) c
In[3]:= PowerExpand[Sqrt[a b] + Sqrt[c d], {a, b}]
Out[3]= Sqrt[a] Sqrt[b] + Sqrt[c d]
Options (2)¶
In[4]:= PowerExpand[Sqrt[z^2], Assumptions -> z < 0]
Out[4]= -z
In[5]:= PowerExpand[Log[x y], Assumptions -> True]
Out[5]= Log[x] + Log[y] + (2*I) Pi Floor[1/2 - (Arg[x] + Arg[y])/(2 Pi)]
Applications (5)¶
In[6]:= PowerExpand[Sqrt[a^2 b^2]]
Out[6]= a b
In[7]:= PowerExpand[Log[a b c]]
Out[7]= Log[a] + Log[b] + Log[c]
In[8]:= PowerExpand[Log[x^n]]
Out[8]= n Log[x]
In[9]:= PowerExpand[Sqrt[x^2], {x}]
Out[9]= x
In[10]:= PowerExpand[(a b)^n, Assumptions -> True]
Out[10]= a^n b^n E^((2*I) Pi Floor[1/2 - (Arg[a] + Arg[b])/(2 Pi)] n)
Options & behaviour¶
Limitations: in Assumptions -> True mode the nested-power correction is left
in Im[...] form rather than rewritten to Arg[...] (mathematically equal).
Algorithm¶
expand_power.c -- PowerExpand.
PowerExpand distributes powers over products and collapses nested powers and logarithms:
(a b)^c -> a^c b^c
(a^b)^c -> a^(b c)
Log[a b] -> Log[a] + Log[b]
Log[a^b] -> b Log[a]
Arg[a b] -> Arg[a] + Arg[b]
Sqrt is stored as Power[x, 1/2] and Log[1/z] as Log[Power[z, -1]], so the rules above cover Sqrt[x y] -> Sqrt[x] Sqrt[y], Sqrt[z^2] -> z and Log[1/z] -> -Log[z] without any special-casing.
The rewrites are applied top-down to a fixed point (mirroring Mathematica's ReplaceRepeated semantics): a rule fires at the outermost
Log[(a b)^c] becomes c (Log[a] + Log[b]) rather than expanding the inner power first.
Three modes, selected by the Assumptions option:
- Automatic (default): the textbook transforms above. Correct when the
bases are positive reals (or the exponents integers); branch issues are
ignored.
- Assumptions -> True: emit the universally-correct formulas, attaching a
branch-correction term built from Floor / Arg / Im / E / I / Pi.
- Assumptions -> assum: emit the True-mode formula and then refine the
correction terms under the assumptions (Arg / Im of known-sign reals,
Floor over assumption-bounded intervals). Faithful on the documented
examples; where the assumptions fall outside this reasoning it degrades
gracefully to the symbolic True-mode form rather than a wrong value.
PowerExpand threads over List, equations, inequalities and logic functions, and supports the variable-restricted form PowerExpand[expr, {x1, ...}].
Implementation notes¶
Algorithm. builtin_powerexpand distributes powers over products and collapses nested
powers and logarithms, applying the rewrites (a b)^c -> a^c b^c, (a^b)^c -> a^(b c),
Log[a b] -> Log[a] + Log[b], Log[a^b] -> b Log[a], and Arg[a b] -> Arg[a] + Arg[b]. Since
Sqrt[x] is stored as Power[x, 1/2] and Log[1/z] as Log[Power[z, -1]], these cover
Sqrt[x y], Sqrt[z^2] -> z, Log[1/z] -> -Log[z] with no special-casing. The transform
(pe_rec) is applied top-down to a fixed point, so an outermost rule fires first and the result
is reprocessed. Three modes are selected by the Assumptions option: Automatic (default,
the textbook transforms, valid for positive-real bases / integer exponents), -> True (emit
universally-correct formulas with a branch-correction term built from Floor/Arg/Im/E/
I/Pi), and -> assum (emit the True-mode formula then refine the correction terms under
the assumptions via pe_refine, degrading gracefully to the symbolic form where the reasoning
runs out). It threads over List, equations, inequalities, and logic heads, and supports the
variable-restricted form PowerExpand[expr, {x1, …}].
Protected.- Applies
(a b)^c -> a^c b^c,(a^b)^c -> a^(b c),Log[a b] -> Log[a] + Log[b],Log[a^b] -> b Log[a], andArg[a b] -> Arg[a] + Arg[b]. BecauseSqrt[x]isPower[x, 1/2]andLog[1/z]isLog[z^-1], these also giveSqrt[x y] -> Sqrt[x] Sqrt[y],Sqrt[z^2] -> z, andLog[1/z] -> -Log[z]. - Rules are applied top-down to a fixed point, so
Log[(a b)^c]becomesc (Log[a] + Log[b])rather than expanding the inner power first. - When a product raised to a non-integer (root) exponent carries a negative
numeric coefficient together with a
Plusfactor, the sign is folded into that factor so the root stays real, e.g.Sqrt[-4 Dt[u]^2 (-1 + u)] -> 2 Dt[u] Sqrt[1 - u]rather than2 I Dt[u] Sqrt[-1 + u]. This is value-preserving since(-1)^c p^c = (-p)^c. f^-1[f[x]] -> xfor the inverse-trig / inverse-hyperbolic pairs (ArcTan[Tan[x]] -> x,ArcSin[Sin[x]] -> x, …).- The default
Assumptions -> Automaticmakes the textbook transforms, which are correct when the bases are positive reals or the exponents are integers; branch cuts are otherwise ignored. Assumptions -> Trueemits the universally-correct result, attaching a branch-correction term built fromFloor,Arg,Im,E,I, andPi.Assumptions -> assumemits theTrue-mode formula and then refines the correction terms underassum(resolvingArg/Imof known-sign reals and evaluatingFloorover assumption-bounded intervals). This is faithful on the documented examples; for assumptions outside this reasoning it degrades to the symbolicTrue-mode form.PowerExpand[expr, {x1, ...}]expands only subexpressions that mention one of the listed variables.- Threads over
List, equations, inequalities, and logic functions.
Attributes: Protected.
References¶
See also: Plus, Floor, Arg, Im, E, I, Pi, List
- Source:
src/expand_power.c - Specification:
docs/spec/builtins/structural-manipulation.md - Tests:
tests/test_cherry_dilog.c - Tests:
tests/test_cherry_dilog_exp.c - Tests:
tests/test_cherry_li.c - Tests:
tests/test_cherry_polylog_exp.c
Notes & additional examples¶
Notes¶
PowerExpand[expr] rewrites (a b)^c as a^c b^c, (a^b)^c as a^(b c), and
expands Log and Arg of products and powers. These transformations are valid
in general only when c is an integer or a, b are positive reals; by default
PowerExpand disregards branch cuts. Use the variable-list form
PowerExpand[expr, {x1, ...}] to expand selectively, or
Assumptions -> True to obtain a branch-cut-correct result in which the
discarded E^(2 Pi I Floor[...]) factor is made explicit.