JOVANA
Explore Library Glossary Getting Started Three Levels Fields How it works Mission
Join the mission
All guides

Real Integrals I: Trigonometric Integrals

Here is the first and friendliest payoff of the residue theorem: a real integral of sines and cosines over a full period turns, by the single substitution z = e^(i theta), into a contour integral around the unit circle that you finish by summing residues. No vanishing arcs to worry about — the circle is already closed.

Why a real integral should ever leave the real line

You have just met the residue theorem, a machine that swallows a loop in the complex plane and spits out 2 pi i times a sum of residues. It is a beautiful statement about contours — but most integrals a physicist or engineer actually wants are stubbornly REAL: an honest integral of a real function over a real interval. This guide and the next two are about a single trick that turns those real integrals into complex contour integrals, so the residue machine can finish them. We start with the gentlest case of all.

The gentlest case is an integral of the form: integral from 0 to 2 pi of R(cos theta, sin theta) d theta, where R is a rational function of cosine and sine — a quotient of two polynomials in cos theta and sin theta, like 1/(2 + cos theta) or (1 + sin theta)/(5 - 4 cos theta). The variable theta runs once around a full period. The magic is that "once around a full period" is secretly already a closed loop; we just need to see the loop.

The substitution z = e^(i theta)

The whole method rests on one substitution. Set z = e^(i theta). As theta runs from 0 to 2 pi, z traces the unit circle |z| = 1 once counterclockwise — that is our closed contour, and we may call it C. Now everything in sight must be rewritten in terms of z. From Euler's formula e^(i theta) = cos theta + i sin theta and its conjugate, cosine and sine become simple combinations of z and 1/z, because on the unit circle 1/z is exactly z-bar = e^(-i theta).

z = e^(i theta)           (the unit circle, run once CCW)

cos theta = (z + 1/z) / 2
sin theta = (z - 1/z) / (2 i)

dz = i e^(i theta) d theta = i z d theta
  =>  d theta = dz / (i z)
The three replacements that convert a trig integral over [0, 2 pi] into a contour integral over |z| = 1.

The last line is the one beginners forget. The differential d theta is NOT just dz; differentiating z = e^(i theta) gives dz = i z d theta, so d theta = dz/(i z). After you substitute all three pieces, the real integral over theta becomes a contour integral of some rational function f(z) around the unit circle — a quotient of polynomials in z, with the factor 1/(i z) folded in. A rational function has only poles for singularities, and they sit at the zeros of its denominator. Everything is now set up for residues.

The recipe, step by step

Put the substitution and the residue theorem together and you get a clean, almost mechanical procedure. The only genuine judgement call is in step 4: deciding which poles of f(z) lie INSIDE the unit circle, because only those — the ones with |z| < 1 — contribute. A pole sitting outside (|z| > 1) is enclosed zero times and is silently ignored, exactly as the residue theorem demands.

  1. Write the integral as integral from 0 to 2 pi of R(cos theta, sin theta) d theta and confirm R is rational in cos theta, sin theta over a FULL period of length 2 pi.
  2. Substitute cos theta = (z + 1/z)/2, sin theta = (z - 1/z)/(2 i), and d theta = dz/(i z). The integral becomes a contour integral of f(z) over the unit circle C.
  3. Simplify f(z) into a single rational function: clear the 1/z terms by multiplying top and bottom, and gather the denominator into a product of factors (z - a)(z - b) ... to expose the poles.
  4. Locate the poles. Keep only those strictly inside the circle, |z| < 1; discard the ones with |z| > 1, and make sure none sit exactly on |z| = 1 (if one does, the integral is improper and needs the later principal-value methods).
  5. Compute the residue of f(z) at each interior pole, using the simple-pole or higher-order-pole formula you learned earlier in this rung.
  6. Apply the residue theorem: the answer is 2 pi i times the sum of those interior residues. It comes out real — a clean sanity check that you set the integrand up correctly.

A worked example

Let us evaluate I = integral from 0 to 2 pi of d theta / (2 + cos theta). This is a real, finite, perfectly ordinary integral; cosine never reaches -2, so the denominator stays positive and the answer is some positive number. Substitute. With cos theta = (z + 1/z)/2 and d theta = dz/(i z), the denominator 2 + cos theta becomes 2 + (z + 1/z)/2 = (z^2 + 4 z + 1) / (2 z). So the integrand d theta/(2 + cos theta) turns into [dz/(i z)] divided by [(z^2 + 4 z + 1)/(2 z)], and the z in the numerator cancels.

After the cancellation the integrand collapses to f(z) = 2/(i (z^2 + 4 z + 1)), and the integral I is the contour integral of f(z) around |z| = 1. The poles are the roots of z^2 + 4 z + 1 = 0, namely z = -2 +/- sqrt(3). One of them, z_+ = -2 + sqrt(3) which is about -0.27, has modulus less than 1 and so sits INSIDE the circle; the other, z_- = -2 - sqrt(3) which is about -3.73, has |z_-| > 1 and sits outside, contributing nothing.

Both roots are simple poles, so we use the simple-pole residue formula. Only z_+ = -2 + sqrt(3) is inside the circle, so only its residue counts. Write z^2 + 4 z + 1 = (z - z_+)(z - z_-); the residue of f at z_+ is 2/(i (z_+ - z_-)). The difference z_+ - z_- = (-2 + sqrt(3)) - (-2 - sqrt(3)) = 2 sqrt(3), so the residue is 2/(i * 2 sqrt(3)) = 1/(i sqrt(3)). By the residue theorem, I = 2 pi i times 1/(i sqrt(3)) = 2 pi / sqrt(3). The i cancels and the answer is real and positive, exactly as it had to be.

Watch your step: where this method does and does not apply

This trick is powerful precisely because it is narrow, and knowing its edges saves you from forcing it where it does not fit. The integrand must be rational in cos theta and sin theta — a quotient of polynomials. Bring in something like e^(cos theta) or a square root of cosine and z = e^(i theta) no longer turns the integral into a rational function of z, so the poles dissolve and the method breaks down. Those harder integrands belong to the techniques of the next guides, not this one.

Two more cautions. First, the interval must be a full period, length 2 pi (0 to 2 pi, or -pi to pi — same loop). Over half a period z only traces half the circle, the contour is not closed, and the residue theorem does not apply directly; you usually exploit symmetry to extend to a full period first. Second — and this is the honest fine print — the method needs every pole to lie strictly off the unit circle. If a denominator zero lands exactly ON |z| = 1, the original real integral is actually IMPROPER (its integrand blows up at some theta), and you must reach for the principal-value and indented-contour tools of the last guide in this rung.

When a pole inside the circle is not simple — say the denominator has a repeated factor (z - a)^2 — nothing about the strategy changes; you simply switch from the simple-pole formula to the higher-order-pole formula, which involves a derivative. The contour, the substitution, and the final 2 pi i are all the same. That uniformity is the quiet beauty of the residue method: once a real integral has been recast as residues on the unit circle, the rest is a turn of the same crank you have already learned.