Skip to content

Computing Real Integrals with Residues

In this lesson you’ll learn the four standard contour techniques for real integrals: the semicircle for rational functions, the semicircle with Jordan’s lemma for oscillatory integrands, the unit circle for trigonometric integrals over a full period, and the keyhole for branch cuts.

Every method in this lesson follows the same four steps.

  1. Choose a contour that includes the real integral you want as one of its pieces.
  2. Apply the residue theorem to get the total around the closed contour.
  3. Show the unwanted pieces vanish, usually by the ML inequality.
  4. Solve for the piece you wanted.

The art is entirely in step 1. Steps 2 to 4 are mechanical.

Type 1: rational functions over R\mathbb{R}

Section titled “Type 1: rational functions over R\mathbb{R}R”

For p(x)q(x)dx\int_{-\infty}^\infty \frac{p(x)}{q(x)}dx with qq having no real zeros and degqdegp+2\deg q \ge \deg p + 2, use the semicircular contour in the upper half plane:

pqdx=2πipoles in UHPRespq\int_{-\infty}^{\infty}\frac{p}{q}\,dx = 2\pi i\sum_{\text{poles in UHP}}\operatorname{Res}\frac{p}{q}

The degree condition is what makes the arc vanish. On z=R|z|=R the integrand is O(R2)O(R^{-2}) while the arc length is πR\pi R, so the ML bound is O(R1)0O(R^{-1})\to0. With only one degree of decay the bound would be O(1)O(1) and the method fails.

The figure carries out the whole argument for dx1+x4\int\frac{dx}{1+x^4}, computing the residues, the numerical value of the real integral, and the ML bound on the arc at two radii. All three agree on π2\frac{\pi}{\sqrt2}.

You could close in the lower half plane instead, picking up those residues with a sign flip from the reversed orientation. The answer is the same, which is a good consistency check.

Type 2: oscillatory integrands, with Jordan’s lemma

Section titled “Type 2: oscillatory integrands, with Jordan’s lemma”

For f(x)cos(ax)dx\int_{-\infty}^\infty f(x)\cos(ax)\,dx or with sin\sin, replace the trigonometric factor by eiaze^{iaz} and take the appropriate part at the end. The tool that makes the arc vanish is stronger than ML alone:

Jordan’s lemma. If f(z)0|f(z)|\to0 uniformly as z|z|\to\infty in the upper half plane, and a>0a>0, then

ΓRf(z)eiazdz0\int_{\Gamma_R}f(z)e^{iaz}\,dz \to 0

on the semicircular arc ΓR\Gamma_R in the upper half plane.

The reason is that eiaz=eaImz|e^{iaz}| = e^{-a\operatorname{Im}z} is exponentially small over most of the upper arc. This buys you a full degree: only f0f\to0 is needed, rather than O(R2)O(R^{-2}) decay.

The sign of aa decides the half plane. For a>0a>0 close upward, for a<0a<0 close downward, because that is where eiaze^{iaz} decays.

Type 3: trigonometric integrals over a period

Section titled “Type 3: trigonometric integrals over a period”

For 02πR(cosθ,sinθ)dθ\int_0^{2\pi}R(\cos\theta,\sin\theta)\,d\theta, substitute z=eiθz=e^{i\theta} so the interval becomes the unit circle:

cosθ=z+z12,sinθ=zz12i,dθ=dziz\cos\theta = \frac{z+z^{-1}}{2}, \qquad \sin\theta = \frac{z-z^{-1}}{2i}, \qquad d\theta = \frac{dz}{iz}

The integral becomes a contour integral of a rational function around z=1|z|=1, evaluated by residues at whichever poles land inside. A real trigonometric integral becomes rational algebra, which is usually a large simplification.

Integrals like 0xa11+xdx\int_0^\infty \frac{x^{a-1}}{1+x}dx involve a non-integer power, so the integrand has a branch point at 0. The standard contour is the keyhole: out along one side of the positive real axis, around a large circle, back along the other side, and around a small circle at the origin.

Because the two straight pieces sit on opposite sides of the cut, the multi-valued factor differs between them by e2πiae^{2\pi ia}, and they do not cancel. Instead they combine to give a multiple of the integral you want. That deliberate use of the branch jump is the whole trick.

If the integrand has a pole on the real axis, the integral only exists as a Cauchy principal value, and the contour is indented with a small semicircle around the pole. A small semicircle over a simple pole contributes exactly πi\pi i times the residue - half of the full 2πi2\pi i, as the half-turn suggests. This is how 0sinxxdx=π2\int_0^\infty\frac{\sin x}{x}dx = \frac{\pi}{2} is evaluated, and the 12\frac12 in the answer comes from precisely that half-loop.

Example 1: Evaluate dx1+x2\displaystyle\int_{-\infty}^{\infty}\frac{dx}{1+x^2}.

Solution. Poles at ±i\pm i; only ii is in the upper half plane. With q=1+z2q = 1+z^2 and q=2zq'=2z,

Resz=i=12i\operatorname{Res}_{z=i} = \frac{1}{2i} dx1+x2=2πi12i=π\int_{-\infty}^\infty\frac{dx}{1+x^2} = 2\pi i\cdot\frac{1}{2i} = \pi

✓ Consistent with arctanx\arctan x evaluated from -\infty to \infty.

The degree condition holds since degq=2=degp+2\deg q = 2 = \deg p + 2.

Example 2: Evaluate dx1+x4\displaystyle\int_{-\infty}^{\infty}\frac{dx}{1+x^4}.

Solution. The poles are the fourth roots of 1-1, namely eiπ/4e^{i\pi/4}, e3iπ/4e^{3i\pi/4}, e5iπ/4e^{5i\pi/4}, e7iπ/4e^{7i\pi/4}. The first two are in the upper half plane.

Since q=1+z4q = 1+z^4 has q=4z3q'=4z^3, and z4=1z^4=-1 at each pole,

Res=14z3=z4z4=z4=z4\operatorname{Res} = \frac{1}{4z^3} = \frac{z}{4z^4} = \frac{z}{-4} = -\frac{z}{4}

Summing over the two upper poles:

14(eiπ/4+e3iπ/4)=14(22+22i22+22i)=i24-\frac14\left(e^{i\pi/4}+e^{3i\pi/4}\right) = -\frac14\left(\frac{\sqrt2}{2}+\frac{\sqrt2}{2}i-\frac{\sqrt2}{2}+\frac{\sqrt2}{2}i\right) = -\frac{i\sqrt2}{4} dx1+x4=2πi(i24)=π22=π22.2214\int_{-\infty}^{\infty}\frac{dx}{1+x^4} = 2\pi i\left(-\frac{i\sqrt2}{4}\right) = \frac{\pi\sqrt2}{2} = \frac{\pi}{\sqrt2}\approx2.2214

Try this with real methods. Partial fractions over R\mathbb{R} requires factoring 1+x41+x^4 into two irreducible quadratics with irrational coefficients, and the resulting integrals are unpleasant. The contour method does not care about the degree.

Example 3: Evaluate cosx1+x2dx\displaystyle\int_{-\infty}^{\infty}\frac{\cos x}{1+x^2}dx.

Solution. Consider eiz1+z2\frac{e^{iz}}{1+z^2} on the upper semicircle. Since a=1>0a = 1 > 0, Jordan’s lemma applies and the arc vanishes.

The only pole in the upper half plane is z=iz=i, with

Resz=ieiz1+z2=eii2i=e12i\operatorname{Res}_{z=i}\frac{e^{iz}}{1+z^2} = \frac{e^{i\cdot i}}{2i} = \frac{e^{-1}}{2i}

So

eix1+x2dx=2πie12i=πe\int_{-\infty}^\infty\frac{e^{ix}}{1+x^2}dx = 2\pi i\cdot\frac{e^{-1}}{2i} = \frac{\pi}{e}

The result is real, so taking real parts,

cosx1+x2dx=πe1.1557\int_{-\infty}^{\infty}\frac{\cos x}{1+x^2}dx = \frac{\pi}{e}\approx1.1557

And as a bonus, the imaginary part gives sinx1+x2dx=0\int\frac{\sin x}{1+x^2}dx = 0, which is also obvious by oddness. Two integrals for the price of one is typical of this method.

Example 4: Evaluate 02πdθ2+cosθ\displaystyle\int_0^{2\pi}\frac{d\theta}{2+\cos\theta}.

Solution. Substitute z=eiθz=e^{i\theta}, so cosθ=z+z12\cos\theta = \frac{z+z^{-1}}{2} and dθ=dzizd\theta = \frac{dz}{iz}:

z=112+z+z12dziz=24z+z2+1dzi\oint_{|z|=1}\frac{1}{2+\frac{z+z^{-1}}{2}}\cdot\frac{dz}{iz} = \oint\frac{2}{4z+z^2+1}\cdot\frac{dz}{i}

The denominator z2+4z+1z^2+4z+1 has roots z=2±3z=-2\pm\sqrt3. Only 2+30.268-2+\sqrt3\approx-0.268 is inside the unit circle.

Res=2i12z+4z=2+3=2i123=1i3\operatorname{Res} = \frac{2}{i}\cdot\frac{1}{2z+4}\bigg|_{z=-2+\sqrt3} = \frac{2}{i}\cdot\frac{1}{2\sqrt3} = \frac{1}{i\sqrt3} 02πdθ2+cosθ=2πi1i3=2π33.6276\int_0^{2\pi}\frac{d\theta}{2+\cos\theta} = 2\pi i\cdot\frac{1}{i\sqrt3} = \frac{2\pi}{\sqrt3}\approx3.6276

Checking which root is inside is the crucial step, and it is where most errors in this type occur.

Example 5: Evaluate 0sinxxdx\displaystyle\int_0^\infty\frac{\sin x}{x}dx.

Solution. Consider eizz\frac{e^{iz}}{z} on a contour indented by a small semicircle above the pole at 0. There are no poles enclosed, so the total is 0.

The large arc vanishes by Jordan’s lemma. The small semicircle above a simple pole, traversed clockwise, contributes πiRes=πi-\pi i\operatorname{Res} = -\pi i.

So the two straight pieces sum to πi\pi i, giving

P.V.eixxdx=πi\text{P.V.}\int_{-\infty}^{\infty}\frac{e^{ix}}{x}dx = \pi i

Taking imaginary parts, sinxxdx=π\int_{-\infty}^\infty\frac{\sin x}{x}dx = \pi, and by evenness of sinxx\frac{\sin x}{x},

0sinxxdx=π2\int_0^\infty\frac{\sin x}{x}dx = \frac{\pi}{2}

The 12\frac12 comes from the half-loop around the pole. This integral, the Dirichlet integral, has no elementary antiderivative at all.

Example 6: Evaluate 0dx1+x3\displaystyle\int_0^\infty\frac{dx}{1+x^3}.

Solution. The integrand is not even, so a full-line contour will not work directly. Instead use a sector contour of angle 2π3\frac{2\pi}{3}, since e2πi/3e^{2\pi i/3} maps the positive real axis to the other ray and multiplies the integrand in a controlled way.

On the returning ray, substituting z=e2πi/3tz = e^{2\pi i/3}t gives z3=t3z^3=t^3, so the integrand is unchanged while dzdz picks up a factor e2πi/3e^{2\pi i/3}. The sector encloses the single pole z=eiπ/3z=e^{i\pi/3}, with residue 13z2\frac{1}{3z^2} evaluated there.

Carrying this out gives

0dx1+x3=2π331.2092\int_0^\infty\frac{dx}{1+x^3} = \frac{2\pi}{3\sqrt3}\approx1.2092

Match the contour to the symmetry of the integrand. A cube in the denominator suggests a 120°120° sector, just as a fourth power suggests 90°90°.

Example 7: A keyhole integral.

Set up 0x1/21+xdx\displaystyle\int_0^\infty\frac{x^{-1/2}}{1+x}dx.

Solution. The integrand has a branch point at 0 and a pole at 1-1. Use a keyhole around the positive real axis with the branch cut there.

On the lower edge of the cut, z1/2z^{-1/2} has picked up a factor eiπ=1e^{-i\pi}= -1 relative to the upper edge, so the two straight contributions add rather than cancel, giving 2I2I where II is the wanted integral. The residue at z=1z=-1, with the branch chosen so argz(0,2π)\arg z\in(0,2\pi), is eiπ/2=ie^{-i\pi/2} = -i.

2I=2πi(i)=2πI=π2I = 2\pi i(-i) = 2\pi \quad\Longrightarrow\quad I = \pi

Verification by real methods: substituting x=u2x=u^2 turns it into 20du1+u42\int_0^\infty\frac{du}{1+u^4}… which is Example 2’s cousin, and indeed gives π\pi. ✓

Fourier transforms. Most transforms in a table were computed by contour integration, and the transform of 11+x2\frac{1}{1+x^2} being πek\pi e^{-|k|} is Example 3 with a parameter. Every filter design that uses a closed-form transform relies on this.

Inverse Laplace transforms. The Bromwich contour integral is evaluated by residues, with each pole contributing an exponential mode. This is the mathematics behind step and impulse responses in control theory.

Diffraction and scattering. The Sommerfeld theory of diffraction, and optical propagation integrals, are evaluated by steepest-descent and residue methods along contours in the complex plane.

Dispersion relations. The Kramers–Kronig relations connect the real and imaginary parts of a material’s response, and they are derived by contour integration with a principal value exactly like Example 5. They are used to check the consistency of measured optical data.

Statistical mechanics. Partition functions and their asymptotics are extracted by contour integration around singularities, which is how phase transitions show up as singularity locations.

Signal processing. The sinc\operatorname{sinc} function’s integral, Example 5, is the reason ideal low-pass filters have the impulse response they do, and its slow decay is why real filters must be windowed.

What are the four steps of the contour method?
For a rational function, what degree condition makes the semicircular arc vanish?
What is ∫_{−∞}^{∞} dx/(1 + x⁴)?
What does Jordan's lemma provide?
For ∫₀^{2π} R(cos θ, sin θ) dθ, what substitution is used?
What is ∫₀^{2π} dθ/(2 + cos θ)?
A small semicircle indenting around a simple pole on the real axis contributes what?
Why is a keyhole contour used for ∫₀^∞ x^(a−1)/(1 + x) dx?