Function Repository Resource:

ArgAffineExpand

Source Notebook

Compute branch-correct expansions of Arg for real univariate polynomial and rational functions

Contributed by: Jayanta Phadikar

ResourceFunction["ArgAffineExpand"][Arg[p], x]

rewrites the argument of a univariate polynomial or rational function p with real coefficients, for real x, as a sum of arguments of affine factors.

Details

An affine factor is a degree-one polynomial of the form ax+b with a != 0. In this function we use the normalized affine form 1+αx.
An affine arg expansion is a representation of Arg of a polynomial/rational function that replaces the original expression by a constant plus a sum of args of normalized affine factors, together with a piecewise integer multiple of 2π so that the result coincides exactly with the principal branch value of the original expression on the real line.
Works for univariate polynomials or rational functions in x.
The coefficients must be real-valued and numeric. Inputs with complex or symbolic coefficients are left unevaluated.
For a rational function ℛ(x)=κΠi(1-x/ri)mi/Πj(1-x/pj)nj, the expansion is: Arg[ℛ(x)]=Arg[κ]+ΣimiArg[(1-x/ri)]-ΣjnjArg[(1-x/pj)] plus a piecewise multiples of 2π ensuring equality on the principal branch.
The correctness of the expansion using ResourceFunction["ArgAffineExpand"] is guaranteed for real x only, where branch jumps occur only when real affine factors become negative. For complex x, the current implementation may miss 2π adjustments when non-real affine factors map x onto the negative real axis; in such cases the result can differ from Arg[expr] by integer multiples of 2π.

Examples

Basic Examples (2) 

Expand a simple quadratic polynomial:

In[1]:=
ResourceFunction["ArgAffineExpand"][Arg[1 - x^2], x]
Out[1]=

Expand a simple rational function:

In[2]:=
ResourceFunction["ArgAffineExpand"][Arg[(1 - x)/(1 + x)], x]
Out[2]=

Scope (5) 

Complex-conjugate factorization of a real quadratic:

In[3]:=
res = ResourceFunction["ArgAffineExpand"][Arg[x^2 + x + 1], x]
Out[3]=

Verify that the expansion correctly represents the original function in the real line:

In[4]:=
Table[Chop[N@Arg[x^2 + x + 1] - res], {x, -100, 100, 10}]
Out[4]=

Branch-corrected expansion near a real root:

In[5]:=
ResourceFunction["ArgAffineExpand"][Arg[(x - 2)^2], x]
Out[5]=

On the principal branch, when x>2 the factor 1-x/2 is negative real, each Arg contributes π. ArgAffineExpand automatically inserts a compensating piecewise constant term 2π so the result is exactly equal to the original input on the principal branch. A similar branch correction for a simple rational function:

In[6]:=
ResourceFunction["ArgAffineExpand"][Arg[1/x], x]
Out[6]=

Expansion for a rational input - zeros minus poles, with sign and branch corrections:

In[7]:=
res = ResourceFunction["ArgAffineExpand"][Arg[(x^2 - 1)/(x^2)], x]
Out[7]=

Verify that the result is correct:

In[8]:=
Plot[Chop[Arg[(x^2 - 1)/(x^2)] - res], {x, -100, 100}]
Out[8]=

Root objects may appear in the result:

In[9]:=
ResourceFunction["ArgAffineExpand"][Arg[x^3 - 3 x + 10], x]
Out[9]=

Use ToRadicals to express using radicals (may not work always):

In[10]:=
ResourceFunction["ArgAffineExpand"][Arg[x^3 - 3 x + 10], x] // ToRadicals
Out[10]=

Root objects in the expansion of a rational function:

In[11]:=
ResourceFunction["ArgAffineExpand"][Arg[(x^6 - 3 x + 10)/(x - 2)], x]
Out[11]=

Properties and Relations (3) 

PowerExpand applies identities like Arg(ab)=Arg(a)+Arg(b) 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:

In[12]:=
PowerExpand[Arg[x (x^2 - 1)]]
Out[12]=
In[13]:=
PowerExpand[Arg[x (x^2 - 1)], Assumptions -> x \[Element] Reals]
Out[13]=

ArgAffineExpand always expands into affine factors and simplified 2π corrections:

In[14]:=
ResourceFunction["ArgAffineExpand"][Arg[x (x^2 - 1)], x]
Out[14]=

Similarly for rational expressions:

In[15]:=
PowerExpand[Arg[(x^2 - 1)/(x^4 + x^3 - 10)]]
Out[15]=
In[16]:=
PowerExpand[Arg[(x^2 - 1)/(x^4 + x^3 - 10)], Assumptions -> x \[Element] Reals]
Out[16]=
In[17]:=
ResourceFunction["ArgAffineExpand"][Arg[(x^2 - 1)/(x^4 + x^3 - 10)],
  x]
Out[17]=

Possible Issues (2) 

For ArgAffineExpand to work, all constants appearing in the expression should be real and numeric. It won't work for symbolic or complex parameters:

In[18]:=
ResourceFunction["ArgAffineExpand"][Arg[(k x^2 - 1)], x]
Out[18]=
In[19]:=
ResourceFunction["ArgAffineExpand"][Arg[(I x^2 - 1)], x]
Out[19]=

ArgAffineExpand gives an expansion which is guaranteed to be correct for real x only. It may not be valid for complex x:

In[20]:=
Arg[1 + 2 x + 2 x^2] /. x -> -1 + I // N
Out[20]=
In[21]:=
ResourceFunction["ArgAffineExpand"][Arg[1 + 2 x + 2 x^2], x] /. x -> -1 + I // N
Out[21]=

Neat Examples (5) 

Expansion of a high degree polynomial:

In[22]:=
ResourceFunction["ArgAffineExpand"][Arg[x^8 - 8 x^3 + 2 x^2 + 5 x - 1],
  x]
Out[22]=

Build a polynomial as six factors:

In[23]:=
poly = 10*Times @@ Table[1 - x/k, {k, 1, 6}]
Out[23]=

ArgAffineExpand reduces its Arg to a constant plus one affine Arg per factor, inserting a piecewise 2π term for principal-branch correctness:

In[24]:=
ResourceFunction["ArgAffineExpand"][Arg[poly], x]
Out[24]=

For a polynomial with repeated roots, the multiplicities reflect in the coefficients of the affine-Arg factors:

In[25]:=
ResourceFunction["ArgAffineExpand"][Arg[(x - 2)^5 (x + 5)^8], x]
Out[25]=

For real quadratics with negative discriminant, the two affine-Arg terms are complex conjugates. Their imaginary parts cancel for real x, so the result is purely real with no branch correction needed:

In[26]:=
ResourceFunction["ArgAffineExpand"][Arg[x^2 + 2 x + 2], x]
Out[26]=

On rationals like (x^2-1)/(x-1)=1+x, the expansion cancels the common factor and reduces to Arg[1+x] (up to the usual constant/branch bookkeeping):

In[27]:=
ResourceFunction["ArgAffineExpand"][Arg[(x^2 - 1)/(x - 1)], x]
Out[27]=

Publisher

Jayanta Kumar Phadikar

Requirements

Wolfram Language 13.0 (December 2021) or above

Version History

  • 1.0.0 – 17 October 2025

Related Resources

License Information