Lecture 22: applications of the residue theorem

Complex analysis, lecture 2
(April 15, 2026)

Today we continue with applications of the residue theorem to real integrals. Last time, we saw how to use it to compute integrals of rational functions over the real line, with the example of

1x2+1𝑑x=π.

To start with today, let’s complicated this integral a little bit: what about something like

cosxx2+1𝑑x?

This is no longer amenable to calculus techniques: cosxx2+1 does not have an elementary antiderivative. We can try the residue method from last time: let D be the upper half-disk of radius N, with boundary consisting of the interval [N,N] and the arc γ from N to N, of radius N. Then

Dcoszz2+1𝑑z=NNcosxx2+1𝑑x+γcoszz2+1𝑑z.

We can evaluate the integral on the left via the residue theorem; the first integral on the right is the one we want to find, and then we can try to bound the second integral by the ML bound. Here however we encounter a problem: it is not clear that cosz should have a reasonable bound for zγ. Indeed, for example at z=Ni, which is on γ, we have

cosz=12(eiz+eiz)=12(eN+eN),

which for N large becomes extremely large, much larger than the denominator of order N2!

However, there is a trick we can use. For x real, cosx is the real part of eix. Therefore if we could compute the integral

eixx2+1𝑑x,

then we could determine our desired integral by taking the real part.

This is more amenable to our approach above because eiz is actually nicely bounded on D: for z=x+iyDD, we must have y0, so eiz=eixy=eyeix has absolute value ey1. Therefore, since for z on γ we have |z|=N and so |1z2+1|1N2 and γ has length πN, by the ML bound we find

|γeizz2+1𝑑z|πN1N2=πN,

so this integral vanishes as N. Therefore to compute our integral it suffices to evaluate

Deizz2+1𝑑z.

Since eiz is entire and nonzero, the only singularity of eizz2+1 in D is at z=i, where it has residue eiz2z|z=i=12ei. Therefore by the residue theorem the integral is

2πi2ei=πe.

Since this is real, taking the real part gives πe again and so we conclude that

cosxx2+1𝑑x=πe.

For another example, let’s try to compute an integral only along the positive real axis:

0xx4+1𝑑x=limN0Nxx4+1𝑑x.

To apply the residue theorem, we need to connect N back to 0; let’s do so via a quarter-circle, so we now have three components to the path: the line 0 from 0 to N, the quarter-circle arc γ of radius N from N to iN, and the line 1 from iN back to 0. These together form the boundary of a region D, giving

Dzz4+1𝑑z=0zz4+1𝑑z+γzz4+1𝑑z+1zz4+1𝑑z.

We can compute the left-hand side via the residue formula. The singularities of zz4+1 are at z4=1, namely at z=eπi4(2k+1) for integers k; the only one of these which is inside our region D is eπi/4=12(1+i). The residue at a point z is z+14z3, so at z=eπi/4 this is

eπi/44e3πi/4=14i.

Therefore the integral is 2πi14i=π2.

On the other side, the integral of γ will go to zero by the usual ML bound argument: the arc has length πN2, while the absolute value of the integrand is bounded by NN311N2, so the product goes to 0. The integral over 0 is what we want to compute; what we’re left with is the integral over 1.

Let’s parametrize. Since 1 is the straight line from iN to 0, we could set z=it and have t go from N to 0, or multiply by 1 to flip the endpoints. Thus, since dz=idt,

1zz4+1𝑑z=i0Nit(it)4+1𝑑t=0Ntt4+1𝑑t.

But this is exactly the original integral we wanted to compute: that is,

1zz4+1𝑑z=0zz4+1𝑑z=0Nxx4+1𝑑x!

Therefore our equation above becomes, in the limit as N,

π2=20Nxx4+1𝑑x,

so the integral is π4.

A different kind of example is for the integration of trigonometric functions. If θ ranges from 0 to 2π (or π to π, or any other interval of length 2π, then the usual mapping θz=eiθ lets us translated between integrals over θ and integrals around the unit circle. We have often used this method to turn complex line integrals into usual one-variable integrals over θ. Now though we have very powerful tools to evaluate complex line integrals, and we would rather go the other way to use these tools to evaluate real integrals.

The reason this is especially useful for trigonometric functions is that we can naturally write cosθ and sinθ in terms of z: we have z=eiθ=cosθ+isinθ, and since |z|=1 we also have 1z=eiθ=cosθisinθ=z¯, so

cosθ=Re(z)=12(z+1/z),sinθ=Im(z)=12i(z1/z).

Let’s work out an example. Fix a real number a>1, and consider

02π1a+cosθ𝑑θ.

Writing z=eiθ, we have dz=ieiθdθ=izdθ, so dθ=1izdz. Combining this with the above, we see that this integral is the same thing as

|z|=11a+12(z+1/z)1iz𝑑z=2i|z|=111+2az+z2𝑑z.

The integrand is a rational function, with poles at the zeros of 1+2az+z2; by the quadratic formula, these are at z=a±a21. Since a>1, we have a21 a positive real number, and aa21<1 so it is not contained in the unit circle; however a1<a21<a since a>1, so 1<a+a21<0 and so a+a21 is contained in the unit circle, and the integrand has a simple pole there, with residue

12z+2a|z=a+a21=12a21.

Therefore by the residue theorem this is

2i2πi12a21=2πa21.

We could consider both sides of the equation

02π1a+cosθ𝑑θ=2πa21

as a function of the variable a. Above, we have shown that the two sides are equal for a(1,). If we wanted to take a a complex number, we need to specify a branch of the square root on the right: we take the principal branch. Recall that the function z21 can be defined on [1,1], taking the branch cut from 1 to 1 along the real axis; away from this branch cut, it is continuous, and in fact analytic. This might lead us to guess that the equation above holds for a[1,1]. (If a[1,1], then both sides are ill-defined: on the right because of the branch cut, and on the left because then there exists θ[0,2π] with a+cosθ=0.)

Indeed, both sides define an analytic function of a on [1,1], after fixing the branch on the right as above; and we showed above that these functions agree on (1,), a subset containing non-isolated points. Hence they must be equal everywhere on [1,1].

This brings us to the more general question of applying the residue theorem to functions with branch cuts. As above, one can do this, but we need to be careful not to cross the branch cuts, and to keep track of our branches.

Let 1<a<1 be a real number, and consider the function

f(z)=za(1+z)2.

For nonnegative real numbers z, there is a unique branch of f with positive real values, so we can define the integral

0xa(1+x)2𝑑x.

To use the residue theorem, though, we will need to specify a branch of f. We take the branch cut along the positive real line, and define f on [0,) by

f(reiθ)=raeiaθ(1+reiθ)2

for 0<θ<2π. Note that this has phase factor e2πia, as can be seen by comparing the value of f at θ=0 and at θ=2π.

Fix real numbers 0<r<R, where we will eventually want to take R and r0. Let D be the slit annulus D={z[0,):r<|z|<R}. We think of the slit in [0,) as having a top edge, at θ=0, and a bottom edge, at θ=2π; so the boundary of D consists of a line from r to R along θ=0, on the top edge of the slit, the circle of radius R in the positive direction, the line from R to r along the bottom edge θ=2π, and the circle of radius r in the negative direction. (This is sometimes called the keyhole contour.) We call these pieces respectively +, γR, , and γr. In particular, when we take r0 and R, the limit of +f(z)𝑑z will recover our desired real integral.

First, let’s compute the integral

Df(z)𝑑z

using the residue theorem. The only singularity of f in D is at z=1, where it has a double pole with residue

ddz(z+1)2f(z)|z=1=ddzza|z=1=a(1)a1=aeπai.

Therefore by the residue theorem this integral is

2πiaeπia.

Next, we’ll study the components

Df(z)𝑑z=+f(z)𝑑z+γRf(z)𝑑z+f(z)𝑑z+γrf(z)𝑑z.

For the circular integrals, we use the ML bound: on γR, we have L=2πR and |f(z)|Ra(R1)2, so ML=2πRa+1/(R1)22πRa1, which tends to 0 as R since a<1, and on γr we have L=2πr and |f(z)|ra(r1)2ra, so ML2πra+10 as r0 since a>1. Therefore both circular integrals vanish in the limit.

For the line integrals, we know that f on is e2πia times the value of f on +, since this is the definition of the phase factor. In addition, is oriented in the opposite direction to +. Therefore

+f(z)𝑑z+f(z)𝑑z=(1e2πia)+f(z)𝑑z,

which in the limit is then equal to 2πiaeπia as above. Therefore for a0

limRlimr0+f(z)𝑑z=xa(1+x)2𝑑x=2πiaeπia1e2πia=2πiaeπiaeπia=πasin(πa).

(To cover the case a=0 as well, the left-hand side can be seen by direct integration to be 1, and the limit of the right-hand side as a0 is also 1, so we can say that this holds at a=0 as well after removing a removable singularity.)

We can again extend this to complex values of a as above, but now we have obstructions at a=±1, where both sides now fail to be analytic (the left-hand side diverges and the right-hand side has a zero in the denominator). On the strip 1<Re(a)<1 however both sides are analytic, so since they agree on (1,1), which contains non-isolated points, it follows that they agree everywhere on the strip.

The right-hand side extends to a{,3,2,1,1,2,3,}, but the left-hand side does not converge outside this strip. Therefore we could view the right-hand side as providing an analytic continuation of this integral to a meromorphic function on .