Residue theorem and real integrals

Some real definite integrals resist every trick of ordinary calculus — no substitution, no integration by parts, no partial fractions will crack ∫02πdθ/(2+cos⁡θ)\int_0^{2\pi} d\theta/(2+\cos\theta) cleanly. Complex analysis supplies a shortcut that feels almost like a magic trick: wrap the real interval into a closed loop in the complex plane, evaluate the loop integral by reading off residues at a handful of singular points, and the answer to the real problem falls out. The Residue Theorem is the engine. It says a contour integral equals 2πi2\pi i times the sum of residues enclosed — full stop, no further integration needed. This capstone topic of Unit 5 turns that single algebraic fact into two standard recipes: rational functions of cos⁡θ,sin⁡θ\cos\theta,\sin\theta over a full period, and rational functions integrated over the whole real line. Both recipes are drilled below with numbers that check against elementary answers.

The core insight

Converting a hard real integral into a closed contour integral lets the Residue Theorem replace calculus with algebra: sum 2πi2\pi i times the residues at the poles that lie inside the chosen contour.

The core idea

Residue Theorem. Let ff be analytic inside and on a simple closed contour CC, except for finitely many isolated singularities z1,…,zkz_1,\dots,z_k enclosed by CC. Then

∮Cf(z) dz=2πi∑j=1kRes⁡z=zjf(z).\oint_C f(z)\, dz = 2\pi i \sum_{j=1}^{k} \operatorname{Res}_{z=z_j} f(z).

where: Res⁡z=zjf(z)\operatorname{Res}_{z=z_j} f(z) is the coefficient c−1c_{-1} of (z−zj)−1(z-z_j)^{-1} in the Laurent expansion of ff about zjz_j. The proof is a one-line deformation: shrink CC down onto kk tiny disjoint circles, one around each zjz_j; each tiny circle contributes exactly 2πiRes⁡zjf2\pi i\operatorname{Res}_{z_j}f by the definition of the residue, and summing the pieces reconstructs the whole. Nothing about the shape of CC matters — only which singularities it happens to enclose. The trick for turning a real integral into a contour integral is choosing CC so that part of it is the real-axis segment you actually want, and the rest is an auxiliary piece that either vanishes or closes the loop conveniently. Two standard choices cover the syllabus.

Type 1 — trigonometric integrals over a full period. For I=∫02πR(cos⁡θ,sin⁡θ) dθ\displaystyle I=\int_0^{2\pi}R(\cos\theta,\sin\theta)\,d\theta with RR rational, the substitution

z=eiθ,dθ=dziz,cos⁡θ=12(z+1z),sin⁡θ=12i(z−1z)z=e^{i\theta},\qquad d\theta=\frac{dz}{iz},\qquad \cos\theta=\frac12\Big(z+\frac1z\Big),\qquad \sin\theta=\frac{1}{2i}\Big(z-\frac1z\Big)

turns θ\theta running once around [0,2π][0,2\pi] into zz running once around the unit circle ∣z∣=1|z|=1. So II becomes ∮∣z∣=1f(z) dz\oint_{|z|=1}f(z)\,dz for a rational f(z)f(z), and the Residue Theorem needs only the poles strictly inside the unit circle.

Type 2 — improper integrals over the whole real line. For f(x)=p(x)/q(x)f(x)=p(x)/q(x) rational, with deg⁡q≥deg⁡p+2\deg q \ge \deg p+2 and no poles on the real axis, close the real segment [−R,R][-R,R] with a large semicircular arc ΓR\Gamma_R in the upper half-plane. As R→∞R\to\infty the arc's contribution vanishes (the ML-inequality: arc length πR\pi R times a bound ∣f∣=O(1/R2)|f|=O(1/R^2) on the arc gives O(1/R)→0O(1/R)\to0), leaving

∫−∞∞f(x) dx=2πi∑(residues of f at poles in the upper half-plane).\int_{-\infty}^{\infty} f(x)\,dx = 2\pi i \sum(\text{residues of }f\text{ at poles in the upper half-plane}).
Figure
Diagram of the closed semicircular contour in the upper half plane with two crosses marking poles, one enclosed above the real axis and one excluded below it, and the arc radius R growing to infinity
Semicircular contour: enclose only the upper-half-plane poles Re z Im z arc Γ_R, radius R → ∞ -R R 0 pole inside, upper half plane — counted pole below axis — excluded

Why the arc vanishes: proving the Type 2 formula

The claim that letting R→∞R\to\infty collapses a closed-contour identity into the real-axis integral we actually want deserves its own justification, since dropping the arc term without proof is exactly the kind of shortcut an exam expects you to defend.

Step 1. Write the closed contour as two pieces: the real segment [−R,R][-R,R] and the semicircular arc ΓR\Gamma_R of radius RR in the upper half-plane, so C=[−R,R]∪ΓRC=[-R,R]\cup\Gamma_R. For RR large enough to enclose every upper-half-plane pole of ff, the Residue Theorem gives ∫−RRf(x) dx+∫ΓRf(z) dz=2πi∑(residues in the upper half-plane)\displaystyle\int_{-R}^{R}f(x)\,dx + \int_{\Gamma_R}f(z)\,dz = 2\pi i\sum(\text{residues in the upper half-plane}), a fixed right-hand side independent of RR once RR is large enough.

Step 2. Bound the arc term using the ML-inequality, ∣∫ΓRf(z) dz∣≤MR⋅LR\left|\int_{\Gamma_R}f(z)\,dz\right|\le M_R\cdot L_R, where LR=πRL_R=\pi R is the arc length and MR=max⁡z∈ΓR∣f(z)∣M_R=\max_{z\in\Gamma_R}|f(z)|. Since f=p/qf=p/q with deg⁡q≥deg⁡p+2\deg q\ge\deg p+2, for large ∣z∣|z| the ratio behaves like ∣f(z)∣≤K/∣z∣2|f(z)|\le K/|z|^2 for some constant KK, so MR≤K/R2M_R\le K/R^2 on ΓR\Gamma_R.

Step 3. Combine the bounds: ∣∫ΓRf(z) dz∣≤KR2⋅πR=πKR→0\left|\int_{\Gamma_R}f(z)\,dz\right|\le \dfrac{K}{R^2}\cdot \pi R=\dfrac{\pi K}{R}\to 0 as R→∞R\to\infty. The degree gap of at least 22 is exactly what forces the 1/R1/R decay; a gap of only 11 would leave a bounded, non-vanishing arc contribution.

Step 4. Take the limit in Step 1's identity. Since the arc term vanishes and the right-hand side is already independent of RR, lim⁡R→∞∫−RRf(x) dx=∫−∞∞f(x) dx=2πi∑(residues at poles in the upper half-plane)\displaystyle\lim_{R\to\infty}\int_{-R}^{R}f(x)\,dx=\int_{-\infty}^{\infty}f(x)\,dx = 2\pi i\sum(\text{residues at poles in the upper half-plane}), which is exactly the Type 2 formula. The same ML-inequality argument, applied on a shrinking or growing arc rather than a straight segment, is the standard tool whenever a contour piece needs to be shown negligible.

Worked example

Problem. Evaluate I=∫02πdθ2+cos⁡θ\displaystyle I=\int_0^{2\pi}\frac{d\theta}{2+\cos\theta}.

Step 1. Substitute z=eiθz=e^{i\theta}, so cos⁡θ=12(z+1/z)\cos\theta=\tfrac12(z+1/z) and dθ=dz/(iz)d\theta=dz/(iz). Multiplying through by 2z2z turns the denominator 2+12(z+1/z)2+\tfrac12(z+1/z) into z2+4z+12z\tfrac{z^2+4z+1}{2z}, so the integral becomes I=∮∣z∣=12 dzi(z2+4z+1)\displaystyle I=\oint_{|z|=1}\frac{2\,dz}{i(z^2+4z+1)}.

Step 2. Find the poles: z2+4z+1=0z^2+4z+1=0 gives z=−2±3z=-2\pm\sqrt3. Only z1=−2+3≈−0.27z_1=-2+\sqrt3\approx-0.27 lies inside ∣z∣=1|z|=1; z2=−2−3≈−3.73z_2=-2-\sqrt3\approx-3.73 is outside and contributes nothing.

Step 3. Compute the residue at the simple pole z1z_1. With g(z)=z2+4z+1g(z)=z^2+4z+1 and g′(z)=2z+4g'(z)=2z+4, Res⁡z=z12i(z2+4z+1)=2/i2z1+4=2/i23=1i3\operatorname{Res}_{z=z_1}\dfrac{2}{i(z^2+4z+1)}=\dfrac{2/i}{2z_1+4}=\dfrac{2/i}{2\sqrt3}=\dfrac{1}{i\sqrt3}.

Step 4. Apply the Residue Theorem: I=2πi⋅1i3=2π3I=2\pi i\cdot\dfrac{1}{i\sqrt3}=\dfrac{2\pi}{\sqrt3}. Final answer: I=2π3≈3.628I=\dfrac{2\pi}{\sqrt3}\approx3.628.

Competitive stretch

Problem. Evaluate J=∫−∞∞dxx2+1\displaystyle J=\int_{-\infty}^{\infty}\frac{dx}{x^2+1} by residues, as a Type 2 check.

Step 1. Here f(z)=1/(z2+1)f(z)=1/(z^2+1) has degree gap 2−0=22-0=2, satisfying the arc-vanishing condition, and its poles z=±iz=\pm i are off the real axis, so the semicircular method applies. Only z=iz=i lies in the upper half-plane.

Step 2. Since z2+1=(z−i)(z+i)z^2+1=(z-i)(z+i), the residue at the simple pole z=iz=i is Res⁡z=i1(z−i)(z+i)=12i\operatorname{Res}_{z=i}\dfrac{1}{(z-i)(z+i)}=\dfrac{1}{2i}.

Step 3. By the Type 2 formula proved above, J=2πi⋅12i=πJ=2\pi i\cdot\dfrac{1}{2i}=\pi. Final answer: J=πJ=\pi, matching the elementary check ∫−∞∞dx/(x2+1)=[arctan⁡x]−∞∞=π\int_{-\infty}^{\infty}dx/(x^2+1)=[\arctan x]_{-\infty}^{\infty}=\pi exactly, which confirms the residue machinery is sound. Both recipes share the same discipline: first decide which contour to close, then find every singularity of the integrand, then discard whichever ones fall outside the chosen region, and only then sum the residues that remain. Skipping the sorting step — summing every pole instead of only the enclosed ones — is the fastest way to get a plausible-looking but wrong number, since the arithmetic of finding residues gives no warning that a pole was on the wrong side.

Common traps

  • Counting poles on the wrong side. For Type 1, only poles strictly inside ∣z∣=1|z|=1 count; for Type 2, only poles in the upper half-plane count when the arc closes upward — a pole on the wrong side is the single most common slip.
  • Skipping the degree check for Type 2. The vanishing-arc argument needs deg⁡q≥deg⁡p+2\deg q\ge\deg p+2; applying the method where the gap is only 11 gives a wrong, often divergent, answer because the arc term does not decay.
  • Algebra slips in the z=eiθz=e^{i\theta} substitution. Dropping the dz/(iz)dz/(iz) factor, or mis-substituting cos⁡θ\cos\theta or sin⁡θ\sin\theta, is a frequent Type 1 error — always confirm the substituted integrand is genuinely rational in zz before hunting poles.
  • Ignoring poles exactly on the real axis. The basic semicircular method assumes no real poles; such cases need an indented contour, a refinement beyond this topic's scope.

Ask the tutor: If picking the right contour type or tracking which poles fall inside it still feels shaky, ask the AI tutor to run through two or three more integrals of each type with you, step by step.

Why does only the upper half plane matter in Type 2, could I close downward instead

You can close downward with a lower semicircle, but then you must sum residues at poles in the lower half-plane instead, and the orientation of that contour is clockwise, which flips the sign to −2πi∑(residues)-2\pi i\sum(\text{residues}). Closing upward with a counterclockwise arc is simply the conventional, tidier choice when the integrand decays fast enough on either side; the physics of the answer does not depend on which half you pick, as long as you match poles, orientation and sign consistently.

What if the degree gap is exactly 1 instead of 2, does Type 2 just fail

The basic ML bound used here needs the gap of 22 to force the arc contribution to O(1/R)→0O(1/R)\to0; with a gap of only 11 the arc's contribution stays bounded and generally nonzero, so the naive formula breaks. Such integrals still often converge and can be evaluated with a more careful choice of contour or an added trick (for example symmetry arguments), but that machinery is beyond this topic's scope — recognize the gap-of-1 case and flag it rather than blindly applying the formula.

How do I know which poles fall inside the unit circle without solving a nasty quadratic every time

For a quadratic z2+bz+c=0z^2+bz+c=0 arising from the cos⁡θ\cos\theta substitution, the two roots always multiply to the constant term by Vieta's formulas, z1z2=cz_1z_2=c; check whether ∣c∣|c| tells you the roots straddle ∣z∣=1|z|=1 (product of magnitudes equals ∣c∣|c|), then just test each root numerically against 11. In the worked example, z1z2=1z_1z_2=1 and one root is small (≈−0.27\approx-0.27) while the other is large (≈−3.73\approx-3.73), a pattern typical of this construction — one root inside, one outside, product equal to 11.

Before this

Where this leads