Basic Examples (3)
Expand a simple quadratic polynomial:
Expand a simple rational function:
Use the equivalent two arguments form:
Scope (5)
Complex-conjugate factorization of a real quadratic:
Verify that the expansion correctly represents the original function in the real line:
Branch-corrected expansion near a real root:
On the principal branch, when x>2 the factor 1-x/2 is negative real. PowerAffineExpand automatically inserts a compensating piecewise constant term -2π ⅈ/3 so the result is exactly equal to the original input on the principal branch. A similar branch correction for a simple rational function:
For a rational input, the expansion keeps the numerator's affine factors in the numerator and the denominator's as inverse powers, with necessary piecewise branch/sign corrections:
Verify that the result is correct:
Root objects may appear in the result:
Use ToRadicals to express using radicals:
Root objects in the expansion of a rational function:
Properties and Relations (3)
PowerExpand applies identities like Power(a b, n)=Power(a, n)*Power(b, n) under generic assumptions and without managing branches, so it may stop at non-affine factors and either omit necessary 2π ⅈ corrections or emit complex corrections:
PowerAffineExpand always expands into affine factors and simplified 2π ⅈ corrections:
Similarly for rational expressions:
Possible Issues (2)
For PowerAffineExpand to work all constants appearing in the expression should be real and numeric. It won't work for symbolic or complex parameters:
PowerAffineExpand gives an expansion which is guaranteed to be correct for real x only, and may not be valid for complex x:
Neat Examples (4)
Expansion of a high degree polynomial:
Build a polynomial with six factors. PowerAffineExpand reduces its power to an expression with one affine power per factor, inserting a piecewise 2π ⅈ term for principal-branch correctness:
For real quadratics with negative discriminant, the bases of the two affine-power terms are complex conjugates. Their imaginary parts cancel for real x, so the result is purely real with no branch correction needed:
On rationals like (x^2-1)/(x-1)=1+x, the expansion cancels the common factor and reduces to
(up to the usual constant/branch bookkeeping):