Function Repository Resource:

NResidue

Source Notebook

Find a numerical approximation of a residue of an expression around the specified point

Contributed by: Wolfram Research

ResourceFunction["NResidue"][expr,{z,z0}]

numerically finds the residue of expr near the point z=z0.

Details and Options

The expression expr must be numeric when its argument x is numeric.
The residue is defined as the coefficient of (z-z0)-1 in the Laurent expansion of expr.
ResourceFunction["NResidue"] numerically integrates around a small circle centered at the point z0 in the complex plane. ResourceFunction["NResidue"] will return an incorrect result when the punctured disk is not analytic.
ResourceFunction["NResidue"] is unable to recognize small numbers that should in fact be zero. Chop is often needed to eliminate these spurious residuals.
Although Residue usually needs to be able to evaluate power series at a point, ResourceFunction["NResidue"] can find residues even if the power series cannot be computed.
ResourceFunction["NResidue"] has the same options as NIntegrate, with the following additions and changes:
"Radius"1/100radius of contour on which integral is evaluated
MethodTrapezoidalintegration method to use

Examples

Basic Examples (1) 

Residue of the function about the origin:

In[1]:=
ResourceFunction["NResidue"][1/x, {x, 0}]
Out[1]=

Scope (2) 

NResidue can find residues of functions with essential singularities:

In[2]:=
ResourceFunction["NResidue"][Sin[1/(10 x)], {x, 0}] // Chop
Out[2]=

Since Series is unable to handle essential singularities, Residue returns unevaluated:

In[3]:=
Residue[Sin[1/(10 x)], {x, 0}]
Out[3]=

NResidue allows for some error in the location of the pole:

In[4]:=
ResourceFunction["NResidue"][1/(1.7 - 2.7 z + z^2), {z, 1.}] // Chop
Out[4]=

Due to machine-precision arithmetic, z1 is not a pole:

In[5]:=
1/(1.7 - 2.7 z + z^2) /. z -> 1.
Out[5]=

With Residue, the error in the location of the pole yields a result of zero:

In[6]:=
Residue[1/(1.7 - 2.7 z + z^2), {z, 1.}]
Out[6]=

Generalizations & Extensions (1) 

NResidue threads element-wise over lists:

In[7]:=
ResourceFunction["NResidue"][{Exp[1/x], Sin[1/x], Cos[1/x]}, {x, 0}, "Radius" -> 1] // Chop
Out[7]=

Options (3) 

Radius (2) 

Use "Radius" to shrink the radius of the contour of integration to isolate a single pole:

In[8]:=
ResourceFunction["NResidue"][1/x + 1/(x + 0.005), {x, 0}] // Chop
Out[8]=
In[9]:=
ResourceFunction["NResidue"][1/x + 1/(x + .005), {x, 0}, "Radius" -> .001] // Chop
Out[9]=

Increase the radius to improve convergence of the integration if no other poles are nearby:

In[10]:=
ResourceFunction["NResidue"][Exp[1/x], {x, 0}] // Chop
Out[10]=
In[11]:=
ResourceFunction["NResidue"][Exp[1/x], {x, 0}, "Radius" -> 1] // Chop
Out[11]=

WorkingPrecision (1) 

NResidue accepts options for NIntegrate, which are sometimes necessary to get an accurate result:

In[12]:=
ResourceFunction["NResidue"][Exp[1/x] + Exp[1/(x - 1/100)], {x, 0}, "Radius" -> 1/200, MaxRecursion -> 10, WorkingPrecision -> 100, PrecisionGoal -> 10] // Chop
Out[12]=

Applications (2) 

Use NResidue to evaluate derivatives of a function evaluated at a point:

In[13]:=
Derivative[10][Zeta][0] // N[#, {30, 30}] &
Out[13]=
In[14]:=
10! ResourceFunction["NResidue"][Zeta[x]/x^11, {x, 0}, "Radius" -> 1/2, WorkingPrecision -> 30]
Out[14]=

Residues of numerical functions:

In[15]:=
f[a_?NumericQ] := NIntegrate[Exp[t^2/a] 1/(10 + a t), {t, 0, 1}]
In[16]:=
ResourceFunction["NResidue"][f[a], {a, 0}, "Radius" -> 1] // Chop
Out[16]=

Properties & Relations (2) 

NSeries can also compute residues of numerical functions:

In[17]:=
f[x_?NumericQ] := Exp[1/x]
In[18]:=
ResourceFunction["NResidue"][f[x], {x, 0}, "Radius" -> 1] // Chop
Out[18]=

Using NSeries:

In[19]:=
SeriesCoefficient[
  ResourceFunction["NSeries"][f[x], {x, 0, 5}], -1] // Chop
Out[19]=

Possible Issues (1) 

NResidue will return an incorrect result when the integration contour contains branch cuts:

In[20]:=
Residue[Sqrt[x - 1] Sqrt[x + 1], {x, 0}]
Out[5]=
In[21]:=
ResourceFunction["NResidue"][Sqrt[x - 1] Sqrt[x + 1], {x, 0}, "Radius" -> 2]
Out[21]=

Requirements

Wolfram Language 11.3 (March 2018) or above

Version History

  • 1.0.0 – 13 March 2019

Related Resources

License Information