TLDR: This article is about splitting Log, powers and Arg of real one-variable polynomial or rational expressions into normalized affine factors without losing the principal-branch corrections. The three functions here are Wolfram Function Repository resource functions: LogAffineExpand, PowerAffineExpand and ArgAffineExpand.
Introduction
Introduction
Symbolic computation becomes much more effective when expressions are written in a form that exposes their elementary building blocks. A polynomial may look like a single opaque object, but from the point of view of integration, summation, analytic continuation, asymptotic expansion and special-function recognition, its most useful form is often a product of linear factors. For a univariate polynomial or rational function, those linear factors can be normalized as affine factors of the form:
1+αx
where α is independent of x. Once an expression has been decomposed into such factors, logarithms become sums of logarithms, powers become products of powers, and arguments become sums of arguments. This is the simple algebraic idea behind affine expansion.
The subtle part is that the elementary identities involved are not globally true on the principal branches of complex functions. In general,
Log[ab]Log[a]+Log[b]
and
r
(ab)
r
a
r
b
need branch information. A factor that crosses the negative real axis changes the principal value of Log, Power or Arg. If we split a product into affine factors without accounting for those jumps, the result may be algebraically elegant but analytically wrong.
The three resource functions discussed here automate this careful version of expansion:
1. LogAffineExpand rewrites Log[p] or Log[p/q] (p and q are polynomials) as a sum of logarithms of affine factors, plus piecewise multiples of 2 π for principal-branch correctness.
2. PowerAffineExpand rewrites powers of polynomial or rational functions as products of affine powers, with the required exponential phase correction.
3. ArgAffineExpand rewrites arguments of polynomial or rational functions as sums of arguments of affine factors, plus piecewise multiples of 2 π.
Together they provide a branch-correct analogue of the transformations one is tempted to do by hand with PowerExpand, but specialized to real univariate polynomial and rational functions and normalized all the way down to affine factors.
The Affine Viewpoint
The Affine Viewpoint
For a polynomial with real coefficients, a normalized factorization has the schematic form:
P[x]κ
m
x
n
∏
i1
m
i
(1+x)
α
i
where is a constant, the are the reciprocals of the nonzero roots up to sign, and repeated roots appear through multiplicities. A rational function is the same idea applied to a numerator and denominator:
κ
α
i
R[x]
P[x]
Q[x]
The affine expansion functions use this representation as a computational normal form. They do not merely factor the input. They also keep track of the principal-branch correction required when real factors change sign.
For real x, the only branch jumps that need to be tracked occur when a real affine factor becomes negative. The term
π(1-UnitStep[1+αx])
records the contribution to the argument of the affine factor on the real line. The same idea applies to a zero root, where the factor is simply :
1+αx
x
π(1-UnitStep[x])
The total argument contribution determines the branch correction. In simplified form, the three corrections for LogAffineExpand, PowerAffineExpand and ArgAffineExpand, respectively, are:
2πFloor-,Exp2πrFloor-,2πFloor-
1
2
θ
2π
1
2
θ
2π
1
2
θ
2π
Here θ denotes the argument that would be obtained by adding the arguments of all affine factors before reducing back to the principal branch. In other words, θ is the raw accumulated phase of the factorized expression on the real line. It includes the phase of the constant factor, the phase jumps from real affine factors that have become negative, and the corresponding numerator-minus-denominator contribution for rational functions.
The principal branches of Log, Power and Arg do not use an unrestricted angle. They use a representative angle modulo 2 π. Therefore, after the affine factors are added, the result may differ from the original principal-branch expression by an integer multiple of 2 π. The integer
Floor-
1
2
θ
2π
is the wrapping number. It tells how many full turns must be added or subtracted so that the accumulated phase is brought back to the principal branch interval. This is the same bookkeeping one performs when replacing an angle by an equivalent angle modulo 2 π.
The three displayed corrections are the same wrapping number applied in three different ways. For Log, a change of argument by 2 π changes the logarithm by 2 π , so the correction is additive. For Power with exponent r, the same logarithmic correction appears inside Exp and is multiplied by r, so it becomes a multiplicative phase factor. For Arg, the correction is again additive, but real-valued: it is a multiple of 2 π.
So the displayed list should be read as follows: first entry for LogAffineExpand, second entry for PowerAffineExpand and third entry for ArgAffineExpand.
For rational functions, the numerator contribution is added and the denominator contribution is subtracted. This is the essential mechanism that turns a formal factorization into a principal-branch-correct identity on the real line.
LogAffineExpand
LogAffineExpand
The resource function LogAffineExpand rewrites the logarithm of a real univariate polynomial or rational function as a sum of logarithms of normalized affine factors. It also inserts the piecewise constant terms needed to preserve equality on the principal branch.
The simplest examples look exactly like the identity one would expect:
In[]:=
ResourceFunction["LogAffineExpand"]Log[1-],x
2
x
Out[]=
Log[1-x]+Log[1+x]
For a rational expression, zeros contribute positively and poles contribute negatively:
In[]:=
res=ResourceFunction["LogAffineExpand"]Log,x
1-x
1+x
Out[]=
Log[1-x]-Log[1+x]+
|
|
First compare the principal logarithm of the quotient with the naive split into a difference of principal logarithms. The real parts agree, but the imaginary parts differ on , where the split expression misses a 2 π branch contribution:
x<-1
In[]:=
exact=Log[(1-x)/(1+x)];naive=Log[1-x]-Log[1+x];PlotEvaluate[{Re[exact],Im[exact],Re[naive],Im[naive]}],{x,-10,10},
Out[]=
The difference is not identically zero everywhere: the real part cancels, but the imaginary part records the missing branch contribution on :
x<-1
In[]:=
PlotEvaluate[{Re[exact-naive],Im[exact-naive]}],{x,-10,10},
Out[]=
After adding the missing 2 π correction on , the affine split has the same principal-branch values as the original logarithm of the quotient; the two real-imaginary plots now overlap:
x<-1
In[]:=
corrected=naive+Piecewise[{{2IPi,x<-1}},0];PlotEvaluate[{Re[exact],Im[exact],Re[corrected],Im[corrected]}],{x,-10,10},
Out[]=
The difference is zero everywhere:
In[]:=
PlotEvaluate[{Re[exact-corrected],Im[exact-corrected]}],{x,-10,10},
Out[]=
The additional piecewise term is the important part. It says that for x < -1, the principal value of the logarithm of the quotient differs from the naive difference of principal logarithms by 2 π .
A repeated real root shows the same phenomenon even more directly:
When x > 2, the affine factor 1 - x/2 is negative real. Each logarithm contributes π , so the sum 2 Log[1 - x/2] has picked up 2 π . The original expression (x - 2)^2 is positive on that interval, so its logarithm should be real. The compensating -2 π restores the principal value.
Rational functions can combine several branch effects:
This is often the canonical form one wants: constants, affine logarithms, and explicit branch intervals. It gives a transparent description of where the real-line behavior changes.
Complex-conjugate factors also appear naturally. For example:
The two affine factors are conjugates. For real x, their combined value represents the real quadratic correctly. Since the quadratic has no real root and is positive on the real line, no piecewise correction is needed.
For higher-degree polynomials, exact algebraic roots may appear as Root objects. This is a feature of exact symbolic computation, not a failure. When possible, ToRadicals can be used to display the same result with radicals:
The output is long, but structurally it is simple: one constant term and one affine logarithm for each root.
PowerAffineExpand
PowerAffineExpand
The resource function PowerAffineExpand performs the analogous transformation for powers. Its output is a product of affine powers, multiplied by an exponential phase correction when the principal branch requires it.
The basic polynomial case is familiar:
For a rational expression with a fractional exponent, branch correction becomes visible:
The exponential term is the power analogue of the logarithmic 2 π correction. Since raising to the 1/3 power divides the logarithmic jump by 3, the correction appears as an exponential phase.
A repeated root near a real branch point shows the same idea:
For x > 2, the affine base 1 - x/2 lies on the negative real axis. The expression (1 - x/2)^(2/3) alone is not the same principal value as ((x - 2)^2)^(1/3). The exponential correction supplies exactly the missing phase.
Rational expressions again combine zeros and poles:
For powers, the correction is not only a matter of adding a constant. It changes the multiplicative phase of the expression. This is precisely why a branch-aware expansion is useful: it allows one to work factor by factor while retaining the same principal value as the original expression.
Real quadratics with negative discriminant produce conjugate affine factors:
The bases are complex conjugates, and for real x their product recovers the real quadratic. No real affine factor crosses the negative real axis, so no real-line branch correction is required.
Common factors in rational inputs are canceled before expansion:
This makes the function useful as a “canonicalizer”, not merely a “factorizer”.
ArgAffineExpand
ArgAffineExpand
The resource function ArgAffineExpand is the argument-level companion to the logarithm and power functions. It rewrites the argument of a polynomial or rational function as a sum of arguments of affine factors, plus piecewise multiples of 2 π.
For a simple quadratic:
For a rational expression:
The correction is now real, because Arg records the phase directly. A repeated root gives:
When x > 2, the affine factor has argument π. Twice that gives 2 π, but the original square is positive real and should have argument 0 on the principal branch. The piecewise -2 π term performs the correction.
For a rational expression with zeros and poles:
This output is the phase portrait of the expression on the real line. It tells us which affine factors contribute to the argument and where the principal value must be wrapped back into range.
For a real quadratic with no real roots:
The conjugate terms cancel for real x, matching the fact that x^2 + 2*x + 2 is positive for all real x.
Why This Is Not Just PowerExpand
Why This Is Not Just PowerExpand
PowerExpand deliberately applies transformations under generic assumptions. That can be useful, but it is not designed to provide a real-line branch-correct affine factorization.
For example:
This has split part of the expression, but it has stopped at a quadratic factor. With assumptions, PowerExpand exposes a branch correction, but the result is still not normalized into affine factors:
By contrast:
This is fully affine and the branch correction has been simplified into real-line intervals.
The same comparison works for powers:
while
And for arguments:
whereas
The affine form exposes the roots, the branch intervals and the algebraic letters that later computations may need.
A Six-Factor Example
A Six-Factor Example
A useful way to see the branch bookkeeping is to expand a product of several real affine factors:
The correction is easier to read as a staircase: every pair of additional negative affine factors contributes another -2 π to the logarithmic correction.
As x moves to the right, more affine factors become negative. The piecewise correction counts how many of those negative factors have accumulated enough total phase to move the principal value. The result is a compact real-line description of the branch behavior.
The corresponding power expansion is:
And the corresponding argument expansion is:
The three outputs are different projections of the same branch structure: additive logarithmic jumps, multiplicative power phases and direct argument wrapping.
Applications
Applications
Affine expansion is useful because many symbolic algorithms prefer simple factors. A logarithm of a complicated rational function may be hard to sum or integrate directly, while a sum of affine logarithms may be handled term by term.
The following example compares direct summation with summation after affine expansion:
Using the affine expansion term by term:
The same pattern appears in integration:
Term-wise after affine expansion:
Timings are system dependent, but the structural lesson is stable: once the logarithm is decomposed into affine letters, many downstream computations have a simpler job.
This also connects directly to generalized polylogarithms. A logarithm of an affine factor is the first layer of an iterated-integral alphabet. For example:
The roots of the quadratic have become letters in the generalized-polylogarithm alphabet. This is exactly the kind of transformation that appears in rational integration, iterated integrals, differential-equation methods and Feynman-integral calculations.
There is also a spectral interpretation. If A is a matrix, then
is a logarithm of a characteristic polynomial in x. Applying LogAffineExpand rewrites it as one affine logarithm per eigenvalue, with branch corrections on the real line. This makes the connection between determinants, eigenvalues and trace expansions explicit.
How the Implementation Thinks
How the Implementation Thinks
All three functions share the same internal structure.
First, the input is checked. The current functions work for univariate polynomial or rational expressions in x with exact real coefficients. Symbolic or complex coefficients are left unevaluated.
Second, rational functions are converted to numerator and denominator form with Together and NumeratorDenominator. Polynomial contributions are computed separately and then combined.
Third, the polynomial is normalized. The constant factor is separated, zero roots are recorded as powers of x, and nonzero roots are converted to affine coefficients:
so that each nonzero root contributes a factor of the form:
Fourth, the real-line argument contribution is computed. Real affine factors contribute π when they become negative; zero roots contribute according to the sign of x; the constant factor contributes its own argument.
Finally, the function-specific output is assembled:
1. LogAffineExpand builds a sum of logarithms plus a 2 π correction.
2. PowerAffineExpand builds a product of powers times an exponential phase correction.
3. ArgAffineExpand builds a sum of arguments plus a 2 π correction.
2. PowerAffineExpand builds a product of powers times an exponential phase correction.
3. ArgAffineExpand builds a sum of arguments plus a 2 π correction.
The shared design is what makes the three functions feel like a family rather than three unrelated utilities.
Possible Issues
Possible Issues
The most important limitation is intentional: the branch correctness is guaranteed for real x. For complex x, a nonreal affine factor can map a point onto the negative real axis, and the current implementation may miss the corresponding correction. In those cases, the result can differ from the original expression by an integer multiple of 2 π for logarithms and powers, or by an integer multiple of 2 π for arguments.
For example:
but
The real parts agree, while the imaginary parts differ by 2 π. This is exactly the kind of issue one expects when extending a real-line branch correction into the complex plane without tracking all complex pre-images of the branch cut.
The second limitation is coefficient type. Inputs with symbolic parameters or complex coefficients are not expanded:
and
So if the coefficient domain is unknown, then the branch-cut geometry is unknown as well.
Concluding Remarks
Concluding Remarks
Affine expansion replaces a polynomial or rational expression by the simplest factors visible to one-variable algebra, and it does so without forgetting the principal branch. That combination is what makes the three functions valuable.
LogAffineExpand is useful when logarithms of polynomial or rational expressions need to be integrated, summed, converted to poly-logarithmic letters or compared across branch intervals. PowerAffineExpand is useful when fractional powers must be split into simpler factors without losing their phase. ArgAffineExpand gives a direct real-line phase decomposition, exposing where the argument changes and how it must be wrapped.
The common theme is that symbolic transformations should preserve mathematical meaning. A naive expansion may be attractive, but branch cuts are part of the expression. These functions make the branch information explicit, computable and visible, while still giving the clean affine factorization that downstream algorithms want.
In that sense, the affine expansion functions are not just convenience wrappers around factorization. They are branch-aware normal forms for a common class of expressions, and they provide a practical bridge from polynomial algebra to logarithms, powers, arguments, iterated-integral letters and real-line analytic structure.
CITE THIS NOTEBOOK
CITE THIS NOTEBOOK
Branch-correct affine expansions for log, power and arg
by Jayanta Phadikar
Wolfram Community, STAFF PICKS, July 13, 2026
https://community.wolfram.com/groups/-/m/t/3757477
by Jayanta Phadikar
Wolfram Community, STAFF PICKS, July 13, 2026
https://community.wolfram.com/groups/-/m/t/3757477