Skip to content
The Lumenary
Advanced undergraduateUndergraduate 120 min

Complex analysis

Ask a function of a complex variable for one derivative and it gives you infinitely many, a power series, and Cauchy's integral formula — and from there real integrals, the fundamental theorem of algebra and maps that preserve every angle.

Formally verified · 14 LeanComputationally tested · 1 PythonAI-drafted · awaiting human reviewMathematically reviewed: Awaiting human review
MotivationH

One derivative, and everything follows

Here is a real integral that resists every technique of first-year calculus:

∫−∞∞cos⁡x1+x2 dx=πe.\int_{-\infty}^{\infty} \frac{\cos x}{1 + x^2}\,dx = \frac{\pi}{e}.

The integrand has no elementary antiderivative. Yet a complex analyst evaluates it in three lines, by walking around a semicircle in the complex plane and computing one number at the point z=iz = i. The same method counts the zeros of a polynomial inside a circle without finding them. It proves that every polynomial has a complex root, and it is the engine behind the prime number theorem.

All of this comes from a definition that looks harmless: a function ff of a complex variable is holomorphic if the limit

f′(z)=lim⁡h→0f(z+h)−f(z)hf'(z) = \lim_{h \to 0} \frac{f(z + h) - f(z)}{h}

exists, where now hh is a complex number that may approach 00 from any direction. That one requirement is far stronger than it looks. A real function can be differentiable once and not twice. A holomorphic function is automatically differentiable infinitely often and equal to its Taylor series. It is determined everywhere by its values on a tiny segment, and inside a disc it is determined by its values on the boundary circle. Engineers use the same functions to map the flow of air around a circle onto the flow around an aeroplane wing.

This lesson builds the theory from the definition: the Cauchy–Riemann equations, contour integrals, Cauchy's theorem and integral formula, power series, Liouville's theorem, the fundamental theorem of algebra, and the residue theorem.

IntuitionH

Derivatives that rotate and stretch

A real-differentiable map of the plane looks, near a point, like a linear map R2→R2\R^2 \to \R^2 — any 2×22 \times 2 matrix. A complex derivative f′(z0)=reiθf'(z_0) = re^{i\theta} says much more: near z0z_0, ff acts like multiplication by f′(z0)f'(z_0), that is, a rotation by θ\theta combined with scaling by rr. Rotations-with-scaling are the matrices

(a−bba),a+ib=f′(z0).\begin{pmatrix} a & -b \\ b & a \end{pmatrix}, \qquad a + ib = f'(z_0).

So a holomorphic map, wherever f′≠0f' \ne 0, turns tiny squares into tiny squares. It may rotate and resize them, but it never shears them or flips them over. It preserves angles and orientation: it is conformal. Complex conjugation z↦zˉz \mapsto \bar z is a reflection, the matrix diag(1,−1)\mathrm{diag}(1, -1). It is perfectly smooth as a map of the plane, but it reverses orientation, so it is not complex-differentiable anywhere.

The second picture is the contour integral. Walking once around the origin, ∮dz/z=2πi\oint dz/z = 2\pi i measures how far the argument of zz turns: one full turn, 2π2\pi. For a function holomorphic inside the loop, the corresponding integral is 00. Cauchy's theorem says that integrals of holomorphic functions only notice the holes the path goes around. That is why complex analysis is secretly topology.

DefinitionsH

Definitions

Definition— complex derivative, holomorphic, entire

Let U⊆CU \subseteq \C be open and f:U→Cf : U \to \C. ff is complex-differentiable at z0∈Uz_0 \in U if f′(z0)=lim⁡h→0, h∈Cf(z0+h)−f(z0)hf'(z_0) = \lim_{h \to 0,\ h \in \C} \frac{f(z_0 + h) - f(z_0)}{h} exists. ff is holomorphic on UU if it is complex-differentiable at every point of UU, and entire if it is holomorphic on C\C.

Sums, products, quotients (where the denominator is non-zero) and composites of holomorphic functions are holomorphic, with the usual rules, by the same proofs as in real calculus. Polynomials are entire, and so are ez=∑zn/n!e^z = \sum z^n/n!, sin⁡z\sin z and cos⁡z\cos z.

Definition— contour integral

A path is a piecewise continuously differentiable map γ:[a,b]→C\gamma : [a, b] \to \C; it is closed if γ(a)=γ(b)\gamma(a) = \gamma(b). For ff continuous on the image of γ\gamma,

∫γf(z) dz=∫abf(γ(t)) γ′(t) dt.\int_\gamma f(z)\,dz = \int_a^b f(\gamma(t))\,\gamma'(t)\,dt.

The circle ∣z−c∣=R|z - c| = R traversed once anticlockwise, γ(t)=c+Reit\gamma(t) = c + Re^{it} for t∈[0,2π]t \in [0, 2\pi], gives ∮∣z−c∣=Rf(z) dz\oint_{|z - c| = R} f(z)\,dz.

Two facts are used constantly. The ML-inequality: if ∣f∣≤M|f| \le M on the image of γ\gamma and γ\gamma has length LL, then ∣∫γf∣≤ML\left|\int_\gamma f\right| \le ML. And primitives kill closed integrals: if F′=fF' = f on an open set containing the image of γ\gamma, then ∫γf=F(γ(b))−F(γ(a))\int_\gamma f = F(\gamma(b)) - F(\gamma(a)), which is 00 for closed γ\gamma (chain rule plus the real fundamental theorem of calculus).

Definition— isolated singularity, pole, residue

If ff is holomorphic on a punctured disc 0<∣z−a∣<r0 < |z - a| < r, then aa is an isolated singularity. It is removable if ff extends holomorphically to aa. It is a pole of order m≥1m \ge 1 if f(z)=g(z)/(z−a)mf(z) = g(z)/(z - a)^m with gg holomorphic near aa and g(a)≠0g(a) \ne 0. Otherwise it is essential. The residue Res⁡af\operatorname{Res}_a f is the coefficient c−1c_{-1} of (z−a)−1(z - a)^{-1} in the Laurent expansion f(z)=∑n∈Zcn(z−a)nf(z) = \sum_{n \in \Z} c_n (z - a)^n about aa.

Definition— winding number

For a closed path γ\gamma and a point ww not on it, the winding number is n(γ,w)=12πi∫γdzz−wn(\gamma, w) = \frac{1}{2\pi i} \int_\gamma \frac{dz}{z - w}. It is an integer, and it counts the number of times γ\gamma travels anticlockwise around ww.

Worked examplesH

Examples and non-examples

Example— The integral of (z − c) to the power n

Parametrise z=c+Reitz = c + Re^{it}, so dz=iReit dtdz = iRe^{it}\,dt. For every integer nn,

∮∣z−c∣=R(z−c)n dz=∫02πRneint iReit dt=iRn+1∫02πei(n+1)t dt={2πin=−1,0n≠−1.\oint_{|z - c| = R} (z - c)^n\,dz = \int_0^{2\pi} R^n e^{int}\, iRe^{it}\,dt = iR^{n+1} \int_0^{2\pi} e^{i(n+1)t}\,dt = \begin{cases} 2\pi i & n = -1, \\ 0 & n \ne -1. \end{cases}

For n≠−1n \ne -1 this also follows from the primitive (z−c)n+1/(n+1)(z - c)^{n+1}/(n+1). For n=−1n = -1 there is no primitive on C∖{c}\C \setminus \{c\}: a "logarithm" would have to increase by 2πi2\pi i every time it goes around cc. This single computation is the seed of the residue theorem.

Example— Real-differentiable is not enough

Write z=x+iyz = x + iy. The map f(z)=zˉ=x−iyf(z) = \bar z = x - iy is linear over R\R, hence real-differentiable. But along a real increment h=th = t the difference quotient is tˉ/t=1\bar t/t = 1, and along an imaginary increment h=ith = it it is it‾/(it)=−1\overline{it}/(it) = -1. The limit does not exist, so zˉ\bar z is complex-differentiable nowhere. Similarly ∣z∣2=zzˉ|z|^2 = z\bar z is complex-differentiable only at 00, and Re⁡z\operatorname{Re} z nowhere. Consistently, ∮∣z∣=1zˉ dz=∮dz/z=2πi≠0\oint_{|z| = 1} \bar z\,dz = \oint dz/z = 2\pi i \ne 0, since zˉ=1/z\bar z = 1/z on the unit circle.

Example— Three kinds of isolated singularity

  • sin⁡zz\frac{\sin z}{z} at 00: removable, since sin⁡zz=1−z23!+z45!−⋯\frac{\sin z}{z} = 1 - \frac{z^2}{3!} + \frac{z^4}{5!} - \cdots extends with value 11.
  • 1z2+1\frac{1}{z^2 + 1} at ii: a simple pole, 1(z−i)(z+i)\frac{1}{(z - i)(z + i)}, with residue 12i\frac{1}{2i}.
  • e1/z=∑n≥01n! zne^{1/z} = \sum_{n \ge 0} \frac{1}{n!\,z^n} at 00: essential, with infinitely many negative powers and residue 11. Near 00 it takes every non-zero value infinitely often (a theorem of Picard).
ProofH

The Cauchy–Riemann equations

Theorem— Theorem 1 (Cauchy–Riemann)

Write f=u+ivf = u + iv with u,vu, v real-valued functions of (x,y)(x, y). If ff is complex-differentiable at z0=x0+iy0z_0 = x_0 + iy_0, then the partial derivatives of uu and vv exist at (x0,y0)(x_0, y_0) and

ux=vy,uy=−vx,f′(z0)=ux+ivx.u_x = v_y, \qquad u_y = -v_x, \qquad f'(z_0) = u_x + iv_x.

Conversely, if uu and vv have continuous partial derivatives near (x0,y0)(x_0, y_0) satisfying these equations there, then ff is holomorphic near z0z_0.

Proof

Let h→0h \to 0 along the real axis, h=t∈Rh = t \in \R: the difference quotient tends to ux+ivxu_x + iv_x, which must equal f′(z0)f'(z_0). Along the imaginary axis, h=ith = it:

f(z0+it)−f(z0)it=1i(u(x0,y0+t)−u(x0,y0)t+i v(x0,y0+t)−v(x0,y0)t)→−iuy+vy.\frac{f(z_0 + it) - f(z_0)}{it} = \frac{1}{i}\left( \frac{u(x_0, y_0 + t) - u(x_0, y_0)}{t} + i\,\frac{v(x_0, y_0 + t) - v(x_0, y_0)}{t} \right) \to -iu_y + v_y.

Equating real and imaginary parts of ux+ivx=vy−iuyu_x + iv_x = v_y - iu_y gives the equations.

Conversely, continuous partial derivatives make (u,v)(u, v) real-differentiable: f(z0+h)−f(z0)=Ah+o(∣h∣)f(z_0 + h) - f(z_0) = A h + o(|h|), where AA is the Jacobian matrix acting on h=(h1,h2)h = (h_1, h_2). The equations say A=(a−bba)A = \begin{pmatrix} a & -b \\ b & a \end{pmatrix} with a=uxa = u_x, b=vxb = v_x, and this matrix acts on h1+ih2h_1 + ih_2 as multiplication by a+iba + ib. So f(z0+h)−f(z0)h=(a+ib)+o(1)\frac{f(z_0 + h) - f(z_0)}{h} = (a + ib) + o(1).

∎

The equations have a striking consequence. If u,vu, v are twice continuously differentiable (we shall see that they always are), then uxx+uyy=vyx−vxy=0u_{xx} + u_{yy} = v_{yx} - v_{xy} = 0. The real and imaginary parts of a holomorphic function are harmonic. For example, z2=(x2−y2)+i(2xy)z^2 = (x^2 - y^2) + i(2xy), and both x2−y2x^2 - y^2 and 2xy2xy satisfy Laplace's equation.

ProofH

Cauchy's theorem and the integral formula

Theorem— Theorem 2 (Goursat)

If ff is holomorphic on an open set containing a closed triangle TT (with its inside), then ∮∂Tf(z) dz=0\oint_{\partial T} f(z)\,dz = 0.

Proof

Let I=∣∮∂Tf∣I = \left|\oint_{\partial T} f\right|, and let pp and dd be the perimeter and diameter of TT. Join the midpoints of the sides to cut TT into four similar triangles. The integrals over their boundaries add up to the integral over ∂T\partial T, because the inner edges are traversed twice in opposite directions. So one of them, T1T_1, has ∣∮∂T1f∣≥I/4\left|\oint_{\partial T_1} f\right| \ge I/4. Repeating gives nested triangles T⊃T1⊃T2⊃⋯T \supset T_1 \supset T_2 \supset \cdots with

∣∮∂Tnf∣≥4−nI,perimeter 2−np,diameter 2−nd.\left|\oint_{\partial T_n} f\right| \ge 4^{-n} I, \qquad \text{perimeter } 2^{-n} p, \qquad \text{diameter } 2^{-n} d.

By completeness (the nested compact sets have a common point) there is z0∈⋂Tnz_0 \in \bigcap T_n. Since ff is differentiable at z0z_0, f(z)=f(z0)+f′(z0)(z−z0)+ψ(z)(z−z0)f(z) = f(z_0) + f'(z_0)(z - z_0) + \psi(z)(z - z_0) with ψ(z)→0\psi(z) \to 0 as z→z0z \to z_0. The linear part has a primitive, so its integral over ∂Tn\partial T_n vanishes. Let εn=sup⁡Tn∣ψ∣\varepsilon_n = \sup_{T_n} |\psi|, so εn→0\varepsilon_n \to 0. By the ML-inequality,

4−nI≤∣∮∂Tnψ(z)(z−z0) dz∣≤εn⋅2−nd⋅2−np.4^{-n} I \le \left|\oint_{\partial T_n} \psi(z)(z - z_0)\,dz\right| \le \varepsilon_n \cdot 2^{-n} d \cdot 2^{-n} p.

So I≤εn dp→0I \le \varepsilon_n\, dp \to 0, and I=0I = 0.

∎

Theorem— Lemma 3 (one exceptional point)

Goursat's theorem still holds if ff is continuous on the open set and holomorphic except at one point ww.

Proof

If ww is a vertex of TT, cut off a tiny triangle at ww of perimeter η\eta. The rest of TT splits into triangles not containing ww, whose integrals vanish by Theorem 2. The tiny triangle contributes at most η⋅sup⁡T∣f∣\eta \cdot \sup_T |f|, which tends to 00 with η\eta. If ww lies elsewhere in TT, split TT into triangles that have ww as a vertex.

∎

Theorem— Theorem 4 (Cauchy's theorem in a disc)

Let ff be continuous on an open disc DD and holomorphic on DD except possibly at one point. Then ff has a primitive on DD, and ∫γf dz=0\int_\gamma f\,dz = 0 for every closed path γ\gamma in DD.

Proof

Let cc be the centre and set F(z)=∫[c,z]fF(z) = \int_{[c, z]} f, the integral along the segment from cc to zz. For z,z+h∈Dz, z + h \in D, Lemma 3 for the triangle with vertices c,z,z+hc, z, z + h gives F(z+h)−F(z)=∫[z,z+h]fF(z + h) - F(z) = \int_{[z, z + h]} f. Since ∫[z,z+h]f(z) dζ=hf(z)\int_{[z, z + h]} f(z)\,d\zeta = h f(z),

∣F(z+h)−F(z)h−f(z)∣=∣1h∫[z,z+h](f(ζ)−f(z)) dζ∣≤sup⁡ζ∈[z,z+h]∣f(ζ)−f(z)∣→0\left| \frac{F(z + h) - F(z)}{h} - f(z) \right| = \left| \frac{1}{h} \int_{[z, z + h]} \big(f(\zeta) - f(z)\big)\,d\zeta \right| \le \sup_{\zeta \in [z, z + h]} |f(\zeta) - f(z)| \to 0

by continuity. So F′=fF' = f, and integrals of ff over closed paths vanish because ff has a primitive.

∎

Note

Cauchy's theorem holds far beyond discs. General form (stated, not proved here): if ff is holomorphic on an open set UU and the closed path γ\gamma in UU is null-homotopic in UU — or more generally has winding number 00 about every point outside UU — then ∫γf=0\int_\gamma f = 0. In particular this holds for every closed path in a simply connected domain. See Ahlfors (1979), chapter 4, or Stein and Shakarchi (2003), chapter 3. In this lesson we use only discs and circles.

Theorem— Lemma 5

If ∣w−c∣<R|w - c| < R, then ∮∣z−c∣=Rdzz−w=2πi\displaystyle \oint_{|z - c| = R} \frac{dz}{z - w} = 2\pi i.

Proof

On the circle ∣w−c∣/∣z−c∣=∣w−c∣/R=:q<1|w - c| / |z - c| = |w - c|/R =: q < 1, so the geometric series

1z−w=1(z−c)(1−w−cz−c)=∑n≥0(w−c)n(z−c)n+1\frac{1}{z - w} = \frac{1}{(z - c)\big(1 - \frac{w - c}{z - c}\big)} = \sum_{n \ge 0} \frac{(w - c)^n}{(z - c)^{n+1}}

converges uniformly on the circle (M-test with Mn=qn/RM_n = q^n/R). Integrate term by term: by the first example, only n=0n = 0 survives, giving 2πi2\pi i.

∎

Theorem— Theorem 6 (Cauchy's integral formula)

Let ff be holomorphic on an open set containing the closed disc ∣z−c∣≤R|z - c| \le R. Then for every ww with ∣w−c∣<R|w - c| < R,

f(w)=12πi∮∣z−c∣=Rf(z)z−w dz.f(w) = \frac{1}{2\pi i} \oint_{|z - c| = R} \frac{f(z)}{z - w}\,dz.

Proof

ff is holomorphic on a slightly larger disc DD. Define g(z)=f(z)−f(w)z−wg(z) = \frac{f(z) - f(w)}{z - w} for z≠wz \ne w and g(w)=f′(w)g(w) = f'(w). Then gg is continuous on DD and holomorphic except at ww, so ∮g=0\oint g = 0 by Theorem 4. Hence

∮f(z)z−w dz=f(w)∮dzz−w=2πi f(w)\oint \frac{f(z)}{z - w}\,dz = f(w) \oint \frac{dz}{z - w} = 2\pi i\, f(w)

by Lemma 5.

∎

The values of a holomorphic function inside a disc are determined by its values on the boundary. Nothing like this is true for real-differentiable functions.

ProofH

Power series, Liouville and the fundamental theorem of algebra

Theorem— Theorem 7 (holomorphic functions are analytic)

Let ff be holomorphic on the open disc ∣z−c∣<ρ|z - c| < \rho. Then f(w)=∑n≥0an(w−c)nf(w) = \sum_{n \ge 0} a_n (w - c)^n for all ∣w−c∣<ρ|w - c| < \rho, where, for any 0<R<ρ0 < R < \rho,

an=12πi∮∣z−c∣=Rf(z)(z−c)n+1 dz.a_n = \frac{1}{2\pi i} \oint_{|z - c| = R} \frac{f(z)}{(z - c)^{n+1}}\,dz.

Consequently ff is infinitely complex-differentiable, with f(n)(c)=n! anf^{(n)}(c) = n!\,a_n.

Proof

Fix ww and choose RR with ∣w−c∣<R<ρ|w - c| < R < \rho. Substitute the uniformly convergent geometric series of Lemma 5 into Cauchy's formula. Uniform convergence allows term-by-term integration (the ML-inequality bounds the tail by 2πR⋅sup⁡∣f∣⋅∑n>Nqn/R2\pi R \cdot \sup|f| \cdot \sum_{n > N} q^n/R), and this gives the series. A power series is infinitely differentiable inside its disc of convergence, with derivatives computed term by term, so f(n)(c)=n! anf^{(n)}(c) = n!\,a_n. The coefficients do not depend on RR, because they are determined by the derivatives at cc.

∎

So the Taylor series of a holomorphic function converges on the largest disc on which the function is holomorphic. That explains a real-analysis puzzle. The Taylor series of 11+x2\frac{1}{1 + x^2} about 00 has radius 11, although the function is perfectly smooth on all of R\R. Over C\C it has poles at ±i\pm i, at distance 11.

Theorem— Corollary 8 (Cauchy's estimates)

If ff is holomorphic on a neighbourhood of ∣z−c∣≤R|z - c| \le R and ∣f∣≤M|f| \le M on the circle ∣z−c∣=R|z - c| = R, then ∣f(n)(c)∣≤n! M/Rn|f^{(n)}(c)| \le n!\,M / R^n.

Proof

ML-inequality in the formula for ana_n: ∣an∣≤12π⋅2πR⋅MRn+1=MRn|a_n| \le \frac{1}{2\pi} \cdot 2\pi R \cdot \frac{M}{R^{n+1}} = \frac{M}{R^n}.

∎

Theorem— Theorem 9 (Liouville)

Every bounded entire function is constant.

Proof

If ∣f∣≤M|f| \le M on C\C, Corollary 8 with n=1n = 1 gives ∣f′(c)∣≤M/R|f'(c)| \le M/R for every R>0R > 0, so f′(c)=0f'(c) = 0 for every cc. A function with zero derivative on the connected set C\C is constant (integrate along segments from 00).

∎

Theorem— Theorem 10 (fundamental theorem of algebra)

Every non-constant polynomial pp with complex coefficients has a complex root. Hence pp factors as c∏k=1n(z−zk)c\prod_{k=1}^n (z - z_k).

Proof

Write p(z)=anzn+⋯+a0p(z) = a_n z^n + \cdots + a_0 with n≥1n \ge 1 and an≠0a_n \ne 0. For ∣z∣≥R0:=max⁡(1,2∑k<n∣ak∣/∣an∣)|z| \ge R_0 := \max\big(1, 2\sum_{k < n} |a_k| / |a_n|\big) we have ∣p(z)∣≥∣an∣∣z∣n−∑k<n∣ak∣∣z∣n−1≥12∣an∣∣z∣n|p(z)| \ge |a_n||z|^n - \sum_{k<n} |a_k||z|^{n-1} \ge \tfrac12 |a_n| |z|^n, so ∣p(z)∣→∞|p(z)| \to \infty. Suppose pp had no root. Then 1/p1/p is entire. It is bounded by 2/∣an∣2/|a_n| for ∣z∣≥R0|z| \ge R_0, and bounded on the compact disc ∣z∣≤R0|z| \le R_0 by continuity. By Liouville, 1/p1/p is constant, so pp is constant — a contradiction. The factorisation follows by induction on the degree, dividing by z−z1z - z_1.

∎

ProofH

Laurent series and the residue theorem

Theorem— Proposition 11 (principal parts)

Let ff have a pole of order mm at aa: f(z)=g(z)/(z−a)mf(z) = g(z)/(z - a)^m with gg holomorphic near aa, g(a)≠0g(a) \ne 0. Expanding g(z)=∑k≥0bk(z−a)kg(z) = \sum_{k \ge 0} b_k (z - a)^k (Theorem 7) gives

f(z)=b0(z−a)m+⋯+bm−1z−a⏟principal part Pa(z)+∑k≥0bm+k(z−a)k,f(z) = \underbrace{\frac{b_0}{(z - a)^m} + \cdots + \frac{b_{m-1}}{z - a}}_{\text{principal part } P_a(z)} + \sum_{k \ge 0} b_{m + k}(z - a)^k,

so f−Paf - P_a is holomorphic near aa (after removing the singularity), and Res⁡af=bm−1=g(m−1)(a)(m−1)!\operatorname{Res}_a f = b_{m-1} = \frac{g^{(m-1)}(a)}{(m-1)!}. For a simple pole of a quotient f=ϕ/ψf = \phi/\psi with ψ(a)=0≠ψ′(a)\psi(a) = 0 \ne \psi'(a) and ϕ(a)≠0\phi(a) \ne 0: Res⁡af=ϕ(a)/ψ′(a)\operatorname{Res}_a f = \phi(a)/\psi'(a).

(Every isolated singularity, including essential ones, has a two-sided Laurent expansion ∑n∈Zcn(z−a)n\sum_{n \in \Z} c_n (z - a)^n on a punctured disc, proved like Theorem 7 on an annulus. We will only need poles.)

Theorem— Theorem 12 (residue theorem for a disc)

Let ff be holomorphic on an open set containing the closed disc ∣z−c∣≤R|z - c| \le R, except at finitely many poles a1,…,aka_1, \dots, a_k, all with ∣aj−c∣<R|a_j - c| < R. Then

∮∣z−c∣=Rf(z) dz=2πi∑j=1kRes⁡ajf.\oint_{|z - c| = R} f(z)\,dz = 2\pi i \sum_{j=1}^k \operatorname{Res}_{a_j} f.

Proof

Let PjP_j be the principal part at aja_j. The function h=f−∑jPjh = f - \sum_j P_j has only removable singularities in the disc. Each PℓP_\ell is holomorphic away from aℓa_\ell, and f−Pjf - P_j is holomorphic near aja_j by Proposition 11. After removing those singularities, hh is holomorphic on a disc slightly larger than ∣z−c∣≤R|z - c| \le R. By Theorem 4, ∮h=0\oint h = 0. And ∮Pj=∑nbn(j)∮(z−aj)−n dz\oint P_j = \sum_n b^{(j)}_n \oint (z - a_j)^{-n}\,dz, where only the term (z−aj)−1(z - a_j)^{-1} survives, by the computation ∮(z−a)−ndz=0\oint (z - a)^{-n} dz = 0 for n≥2n \ge 2 and Lemma 5 for n=1n = 1. That term contributes 2πiRes⁡ajf2\pi i \operatorname{Res}_{a_j} f.

∎

The same proof works for any simple closed contour on which Cauchy's theorem is available (for example a semicircle, using its convexity and Theorem 4 on a slightly larger convex region). We use a semicircle now.

Example— Two real integrals by residues

(a) ∫−∞∞dx1+x2=π\int_{-\infty}^\infty \frac{dx}{1 + x^2} = \pi. Let ΓR\Gamma_R be the segment [−R,R][-R, R] followed by the upper semicircle CRC_R of radius R>1R > 1. Inside lies one simple pole of 11+z2\frac{1}{1 + z^2}, at ii, with residue 12i\frac{1}{2i}. So ∮ΓRdz1+z2=2πi⋅12i=π\oint_{\Gamma_R} \frac{dz}{1 + z^2} = 2\pi i \cdot \frac{1}{2i} = \pi. On CRC_R, ∣1+z2∣≥R2−1|1 + z^2| \ge R^2 - 1, so the ML-inequality bounds that part by πRR2−1→0\frac{\pi R}{R^2 - 1} \to 0. Letting R→∞R \to \infty gives π\pi.

(b) ∫−∞∞cos⁡x1+x2 dx=πe\int_{-\infty}^\infty \frac{\cos x}{1 + x^2}\,dx = \frac{\pi}{e}. Use f(z)=eiz1+z2f(z) = \frac{e^{iz}}{1 + z^2} instead. On the upper half-plane ∣eiz∣=e−Im⁡z≤1|e^{iz}| = e^{-\operatorname{Im} z} \le 1, so the same estimate kills CRC_R. The residue at ii is ei⋅i2i=e−12i\frac{e^{i \cdot i}}{2i} = \frac{e^{-1}}{2i}. Hence ∫−∞∞eix1+x2 dx=2πi⋅e−12i=πe\int_{-\infty}^\infty \frac{e^{ix}}{1 + x^2}\,dx = 2\pi i \cdot \frac{e^{-1}}{2i} = \frac{\pi}{e}. Taking real parts gives the result, and the imaginary part, ∫sin⁡x1+x2 dx=0\int \frac{\sin x}{1 + x^2}\,dx = 0, is consistent with the integrand being odd. (Using cos⁡z\cos z directly would fail: ∣cos⁡z∣|\cos z| grows like e∣Im⁡z∣e^{|\operatorname{Im} z|} on the semicircle.)

Applied to f′/ff'/f, the residue theorem counts zeros. Argument principle: if ff is holomorphic on a neighbourhood of ∣z−c∣≤R|z - c| \le R with no zeros on the circle, then 12πi∮f′(z)f(z) dz\frac{1}{2\pi i}\oint \frac{f'(z)}{f(z)}\,dz is the number of zeros inside, counted with multiplicity. (At a zero of order mm, f′/ff'/f has a simple pole with residue mm.) Its corollary, Rouché's theorem, says: if ∣g∣<∣f∣|g| < |f| on the circle, then ff and f+gf + g have the same number of zeros inside. For example z5−3z+1z^5 - 3z + 1 has exactly one zero in ∣z∣<1|z| < 1, since ∣z5+1∣≤2<3=∣−3z∣|z^5 + 1| \le 2 < 3 = |{-3z}| there.

Theorem— Proposition 13 (1/z has no holomorphic extension)

There is no entire function gg with g(z)=1/zg(z) = 1/z for all z≠0z \ne 0. More generally, 1/z1/z has no primitive on C∖{0}\C \setminus \{0\}.

Proof

If gg were entire, Cauchy's theorem would give ∮∣z∣=1g=0\oint_{|z|=1} g = 0. But g=1/zg = 1/z on the circle, and ∮dz/z=2πi\oint dz/z = 2\pi i. A primitive FF of 1/z1/z on C∖{0}\C \setminus \{0\} would also force ∮dz/z=0\oint dz/z = 0.

∎

The obstruction is exactly that 1/z1/z is unbounded near 00. Riemann's removable singularity theorem says that a function holomorphic on a punctured disc and bounded near the puncture extends holomorphically to it. (Apply Theorem 7 to (z−a)2f(z)(z - a)^2 f(z), which is complex-differentiable at aa with derivative 00.)

ExplanationH

Conformal maps

Theorem— Proposition 14 (holomorphic maps preserve angles)

If ff is holomorphic near z0z_0 and f′(z0)≠0f'(z_0) \ne 0, then ff preserves the oriented angle between any two smooth curves crossing at z0z_0.

Proof

A curve γ\gamma with γ(0)=z0\gamma(0) = z_0 and γ′(0)≠0\gamma'(0) \ne 0 is mapped to f∘γf \circ \gamma, with tangent (f∘γ)′(0)=f′(z0)γ′(0)(f \circ \gamma)'(0) = f'(z_0)\gamma'(0) by the chain rule. Every tangent vector is multiplied by the same non-zero complex number f′(z0)=reiθf'(z_0) = re^{i\theta}, which rotates all of them by θ\theta. So the angle between any two of them is unchanged.

∎

Where f′(z0)=0f'(z_0) = 0 angles are multiplied: z↦z2z \mapsto z^2 doubles every angle at 00. The Möbius transformations z↦az+bcz+dz \mapsto \frac{az + b}{cz + d} (ad−bc≠0ad - bc \ne 0) are conformal bijections of the Riemann sphere C∪{∞}\C \cup \{\infty\} that send circles and lines to circles and lines. For example z↦z−iz+iz \mapsto \frac{z - i}{z + i} maps the upper half-plane onto the unit disc. Riemann mapping theorem (stated, not proved here): every simply connected open set U⊊CU \subsetneq \C is conformally equivalent to the open unit disc. Riemann stated it in 1851. Rigorous proofs came around 1900–1912 (Osgood, Carathéodory, Koebe), and the standard textbook proof is due to Fejér and Riesz (1922).

Formal mathematicsF

Complex analysis in Lean and Mathlib

Mathlib's complex analysis is extensive. Holomorphic functions are DifferentiableOn ℂ f U, and contour integrals over circles are circleIntegral, written ∮ z in C(c, R), f z. Mathlib proves Cauchy's theorem for rectangles by a version of Green's theorem (not by Goursat subdivision), and deduces from it the disc theorem, Cauchy's integral formula, analyticity, the Cauchy estimates and Liouville's theorem. We name the notion of the lesson:

HolomorphicOnLean 4Formally verified
/-- `HolomorphicOn f U`: `f` is complex-differentiable at every point of `U` (the lesson's
definition, for open `U`). This is just a name for Mathlib's `DifferentiableOn ℂ f U`. -/
abbrev HolomorphicOn (f : ℂ → ℂ) (U : Set ℂ) : Prop :=
  DifferentiableOn ℂ f U
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/ComplexAnalysis.leanTry it in the Lean web editor

The Cauchy–Riemann equations in derivative form: a complex derivative f′f' gives rate f′f' in the real direction and f′⋅if' \cdot i in the imaginary direction. Applied to conjugation, whose rates are 11 and −i-i, it proves that zˉ\bar z is nowhere complex-differentiable:

directional_derivativesLean 4Proved here from basic factsFormally verified
/-- **The Cauchy–Riemann equations, in derivative form.** If `f` has complex derivative `f'` at
`z`, then moving from `z` in the real direction, `t ↦ f(z + t)`, has derivative `f'`, and moving
in the imaginary direction, `t ↦ f(z + t i)`, has derivative `f' · i` (chain rule: the inner map
`t ↦ z + t i` has derivative `i`). Writing `f = u + i v`, comparing the two gives
`u_y = -v_x` and `v_y = u_x`. -/
theorem directional_derivatives {f : ℂ → ℂ} {f' z : ℂ} (h : HasDerivAt f f' z) :
    HasDerivAt (fun t : ℝ => f (z + t)) f' 0 ∧
      HasDerivAt (fun t : ℝ => f (z + t * I)) (f' * I) 0 := by
  constructor
  · have h0 : HasDerivAt f f' (z + ((0 : ℝ) : ℂ)) := by simpa using h
    exact (HasDerivAt.comp_const_add z ((0 : ℝ) : ℂ) h0).comp_ofReal
  · have hin : HasDerivAt (fun w : ℂ => z + w * I) I ((0 : ℝ) : ℂ) := by
      simpa using ((hasDerivAt_id ((0 : ℝ) : ℂ)).mul_const I).const_add z
    have h0 : HasDerivAt f f' (z + ((0 : ℝ) : ℂ) * I) := by simpa using h
    exact (h0.comp ((0 : ℝ) : ℂ) hin).comp_ofReal
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/ComplexAnalysis.leanTry it in the Lean web editor
conj_not_differentiableAtLean 4Proved here from basic factsFormally verified
/-- **`z ↦ z̄` is complex-differentiable nowhere.** In the real direction `conj (z + t) = z̄ + t`
changes at rate `1`; in the imaginary direction `conj (z + t i) = z̄ - t i` changes at rate `-i`.
A complex derivative `f'` would need `f' = 1` and `f' i = -i` (`directional_derivatives`), so
`i = -i` — impossible. Yet conjugation is real-linear, so as a map `ℝ² → ℝ²` it is as smooth as
can be: it fails the Cauchy–Riemann equations (`u = x`, `v = -y`, so `u_x = 1 ≠ -1 = v_y`). -/
theorem conj_not_differentiableAt (z : ℂ) : ¬ DifferentiableAt ℂ (starRingEnd ℂ) z := by
  intro hd
  obtain ⟨h1, h2⟩ := directional_derivatives hd.hasDerivAt
  have e1 : HasDerivAt (fun t : ℝ => (starRingEnd ℂ) (z + t)) 1 0 := by
    have hfun : (fun t : ℝ => (starRingEnd ℂ) (z + t)) = fun t : ℝ => (starRingEnd ℂ) z + (t : ℂ) := by
      funext t; simp
    rw [hfun]
    simpa using ((hasDerivAt_id (0 : ℝ)).ofReal_comp).const_add ((starRingEnd ℂ) z)
  have e2 : HasDerivAt (fun t : ℝ => (starRingEnd ℂ) (z + t * I)) (-I) 0 := by
    have hfun : (fun t : ℝ => (starRingEnd ℂ) (z + t * I))
        = fun t : ℝ => (starRingEnd ℂ) z + (t : ℂ) * (-I) := by
      funext t; simp
    rw [hfun]
    simpa using (((hasDerivAt_id (0 : ℝ)).ofReal_comp).mul_const (-I)).const_add ((starRingEnd ℂ) z)
  have u1 := h1.unique e1
  have u2 := h2.unique e2
  rw [u1, one_mul] at u2
  have : (2 : ℂ) * I = 0 := by rw [two_mul]; nth_rewrite 1 [u2]; ring
  simp at this
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/ComplexAnalysis.leanTry it in the Lean web editor

Cauchy's theorem on a disc, the basic integral of Lemma 5, Cauchy's integral formula (Theorem 6) and analyticity (Theorem 7), cited from Mathlib:

cauchy_theorem_discLean 4Applies a library theoremFormally verified
/-- **Cauchy's theorem for a disc.** If `f` is holomorphic on a neighbourhood of the closed disc
`|z - c| ≤ R`, then `∮_{|z - c| = R} f(z) dz = 0`. This applies Mathlib's
`DiffContOnCl.circleIntegral_eq_zero` (Mathlib proves it from Cauchy's theorem for rectangles). -/
theorem cauchy_theorem_disc {f : ℂ → ℂ} {c : ℂ} {R : ℝ} (hR : 0 ≤ R)
    (hf : DifferentiableOn ℂ f (closedBall c R)) : (∮ z in C(c, R), f z) = 0 :=
  (hf.mono closure_ball_subset_closedBall).diffContOnCl.circleIntegral_eq_zero hR
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/ComplexAnalysis.leanTry it in the Lean web editor
circle_integral_invLean 4Applies a library theoremFormally verified
/-- **The basic integral:** `∮_{|z - c| = R} dz / (z - w) = 2πi` for every `w` inside the circle.
This applies Mathlib's `circleIntegral.integral_sub_inv_of_mem_ball`. It is not `0`, so
`1/(z - w)` has no primitive on the punctured plane. -/
theorem circle_integral_inv {c w : ℂ} {R : ℝ} (hw : w ∈ ball c R) :
    (∮ z in C(c, R), (z - w)⁻¹) = 2 * (Real.pi : ℂ) * I :=
  circleIntegral.integral_sub_inv_of_mem_ball hw
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/ComplexAnalysis.leanTry it in the Lean web editor
cauchy_integral_formulaLean 4Applies a library theoremFormally verified
/-- **Cauchy's integral formula.** If `f` is holomorphic on the closed disc `|z - c| ≤ R` and
`|w - c| < R`, then `∮_{|z - c| = R} f(z)/(z - w) dz = 2πi f(w)`: the values of `f` inside the
disc are determined by its values on the boundary circle. This applies Mathlib's
`DifferentiableOn.circleIntegral_sub_inv_smul`. -/
theorem cauchy_integral_formula {f : ℂ → ℂ} {c w : ℂ} {R : ℝ}
    (hf : DifferentiableOn ℂ f (closedBall c R)) (hw : w ∈ ball c R) :
    (∮ z in C(c, R), (z - w)⁻¹ * f z) = 2 * (Real.pi : ℂ) * I * f w := by
  simpa [smul_eq_mul] using hf.circleIntegral_sub_inv_smul hw
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/ComplexAnalysis.leanTry it in the Lean web editor
holomorphic_is_analyticLean 4Applies a library theoremFormally verified
/-- **Holomorphic functions are analytic.** If `f` is complex-differentiable on a neighbourhood of
`z`, then `f` equals the sum of its Taylor series near `z`. This applies Mathlib's
`DifferentiableOn.analyticAt`, which expands the Cauchy kernel `1/(ζ - w)` in a geometric series,
exactly as in the lesson's proof. -/
theorem holomorphic_is_analytic {f : ℂ → ℂ} {U : Set ℂ} {z : ℂ} (hf : HolomorphicOn f U)
    (hU : U ∈ 𝓝 z) : AnalyticAt ℂ f z :=
  DifferentiableOn.analyticAt hf hU
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/ComplexAnalysis.leanTry it in the Lean web editor

Proposition 13 — no entire extension of 1/z1/z — proved from those two facts exactly as on paper:

inv_no_entire_extensionLean 4Proved here from basic factsFormally verified
/-- **`1/z` does not extend to an entire function.** If an entire `g` agreed with `1/z` away from
`0`, then on the unit circle `g = 1/z`, so `∮ g = ∮ dz/z = 2πi`; but Cauchy's theorem says
`∮ g = 0`. (In fact no holomorphic function on any punctured disc around `0` with a
non-removable singularity extends: Riemann's removable singularity theorem says boundedness near
the point is exactly what is needed, and `1/z` is unbounded.) -/
theorem inv_no_entire_extension :
    ¬ ∃ g : ℂ → ℂ, Differentiable ℂ g ∧ ∀ z ≠ 0, g z = z⁻¹ := by
  rintro ⟨g, hg, hgz⟩
  have h0 : (∮ z in C(0, 1), g z) = 0 := cauchy_theorem_disc zero_le_one hg.differentiableOn
  have hcongr : (∮ z in C(0, 1), g z) = ∮ z in C(0, 1), (z - 0)⁻¹ := by
    apply circleIntegral.integral_congr zero_le_one
    intro z hz
    have hz0 : z ≠ 0 := by
      intro h
      rw [h, mem_sphere, dist_self] at hz
      exact zero_ne_one hz
    simp [hgz z hz0]
  have h1 : (∮ z in C(0, 1), (z - 0)⁻¹) = 2 * (Real.pi : ℂ) * I :=
    circle_integral_inv (by simp)
  rw [hcongr, h1] at h0
  simp [I_ne_zero] at h0
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/ComplexAnalysis.leanTry it in the Lean web editor

Liouville's theorem, proved from the Cauchy estimate as in Theorem 9, next to Mathlib's own statement:

cauchy_estimateLean 4Applies a library theoremFormally verified
/-- **Cauchy's estimate.** If `f` is holomorphic on the disc `|z - c| < R`, continuous up to the
boundary, and `|f| ≤ C` on the circle `|z - c| = R`, then `|f'(c)| ≤ C / R`. This applies
Mathlib's `Complex.norm_deriv_le_of_forall_mem_sphere_norm_le`; on paper it is one line from the
Cauchy integral formula for `f'`. -/
theorem cauchy_estimate {f : ℂ → ℂ} {c : ℂ} {R C : ℝ} (hR : 0 < R)
    (hf : DiffContOnCl ℂ f (ball c R)) (hC : ∀ z ∈ sphere c R, ‖f z‖ ≤ C) :
    ‖deriv f c‖ ≤ C / R :=
  norm_deriv_le_of_forall_mem_sphere_norm_le hR hf hC
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/ComplexAnalysis.leanTry it in the Lean web editor
liouville_from_cauchy_estimateLean 4Proved here from basic factsFormally verified
/-- **Liouville's theorem, from the Cauchy estimate.** A bounded entire function is constant. If
`|f| ≤ M` everywhere, the Cauchy estimate on a circle of radius `R` around any `c` gives
`|f'(c)| ≤ M / R`; letting `R → ∞` forces `f'(c) = 0`. A function with zero derivative
everywhere on the connected set `ℂ` is constant. (Concretely: if `d = |f'(c)| > 0`, the radius
`R = (M + 1)/d` gives `d ≤ M d /(M + 1) < d`.) -/
theorem liouville_from_cauchy_estimate {f : ℂ → ℂ} (hf : Differentiable ℂ f) {M : ℝ}
    (hM : ∀ z, ‖f z‖ ≤ M) (z w : ℂ) : f z = f w := by
  have hM0 : 0 ≤ M := (norm_nonneg _).trans (hM 0)
  have hderiv : ∀ c, deriv f c = 0 := by
    intro c
    by_contra hne
    set d := ‖deriv f c‖ with hd
    have hdpos : 0 < d := norm_pos_iff.mpr hne
    have hR : 0 < (M + 1) / d := by positivity
    have key : d ≤ M / ((M + 1) / d) :=
      cauchy_estimate hR hf.diffContOnCl (fun z _ => hM z)
    rw [div_div_eq_mul_div, le_div_iff₀ (by linarith)] at key
    nlinarith
  exact is_const_of_deriv_eq_zero hf hderiv z w
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/ComplexAnalysis.leanTry it in the Lean web editor
liouville_libraryLean 4Applies a library theoremFormally verified
/-- Liouville's theorem as stated in Mathlib: a complex-differentiable function with bounded range
is constant. This applies `Differentiable.apply_eq_apply_of_bounded` (which allows any complex
normed spaces as domain and target). -/
theorem liouville_library {f : ℂ → ℂ} (hf : Differentiable ℂ f)
    (hb : Bornology.IsBounded (range f)) (z w : ℂ) : f z = f w :=
  hf.apply_eq_apply_of_bounded hb z w
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/ComplexAnalysis.leanTry it in the Lean web editor

The fundamental theorem of algebra, by the argument of Theorem 10. Here the Liouville step uses Mathlib's variant "an entire function with a limit at infinity is constant", and the growth ∣p(z)∣→∞|p(z)| \to \infty is Mathlib's Polynomial.tendsto_norm_atTop.

fta_from_liouvilleLean 4Proved here from basic factsFormally verified
/-- **The fundamental theorem of algebra, from Liouville's theorem.** Let `p` be a non-constant
complex polynomial and suppose it has no root. Then `1/p` is entire, and `|p(z)| → ∞` as
`|z| → ∞`, so `1/p(z) → 0`. An entire function with limit `0` at infinity is bounded, hence
constant (Liouville), hence identically `0` — but `1/p(z)` is never `0`. Contradiction. -/
theorem fta_from_liouville (p : Polynomial ℂ) (hp : 0 < p.degree) : ∃ z, p.eval z = 0 := by
  by_contra hroot
  push Not at hroot
  -- `1/p` is entire, because `p` never vanishes.
  have hdiff : Differentiable ℂ (fun z => (p.eval z)⁻¹) := p.differentiable.inv hroot
  -- `|p(z)| → ∞` as `|z| → ∞`, so `1/p(z) → 0` at infinity.
  have htend : Tendsto (fun z => (p.eval z)⁻¹) (cocompact ℂ) (𝓝 0) :=
    Metric.cobounded_eq_cocompact (α := ℂ) ▸ (Filter.tendsto_inv₀_cobounded.comp <| by
      simpa only [tendsto_norm_atTop_iff_cobounded]
        using p.tendsto_norm_atTop hp tendsto_norm_cobounded_atTop)
  -- Liouville: an entire function tending to `0` at infinity is identically `0`.
  have hzero : (p.eval 0)⁻¹ = 0 := hdiff.apply_eq_of_tendsto_cocompact 0 htend
  exact inv_ne_zero (hroot 0) hzero
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/ComplexAnalysis.leanTry it in the Lean web editor
fta_libraryLean 4Applies a library theoremFormally verified
/-- The fundamental theorem of algebra in Mathlib: `Complex.exists_root`. Mathlib also records
the consequence that `ℂ` is algebraically closed (`Complex.isAlgClosed`), so every complex
polynomial splits into linear factors. -/
theorem fta_library {p : Polynomial ℂ} (hp : 0 < p.degree) : ∃ z, p.IsRoot z :=
  Complex.exists_root hp
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/ComplexAnalysis.leanTry it in the Lean web editor

Finally, the real integral of Example (a), which Mathlib evaluates with arctan⁡\arctan rather than residues:

integral_inv_one_add_sqLean 4Applies a library theoremFormally verified
/-- `∫_{-∞}^{∞} dx / (1 + x²) = π`. The lesson evaluates this by residues (`2πi` times the residue
`1/(2i)` of `1/(1 + z²)` at `i`); Mathlib proves it with the real antiderivative `arctan`, in
`integral_univ_inv_one_add_sq`. Two proofs of one fact. -/
theorem integral_inv_one_add_sq : ∫ x : ℝ, (1 + x ^ 2)⁻¹ = Real.pi :=
  _root_.integral_univ_inv_one_add_sq
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/ComplexAnalysis.leanTry it in the Lean web editor

What is and is not formalised. Proved here: the Cauchy–Riemann equations in directional form (the necessity half of Theorem 1), the nowhere-differentiability of zˉ\bar z, Proposition 13, Liouville's theorem from the Cauchy estimate, and the fundamental theorem of algebra from Liouville. Cited from Mathlib: Cauchy's theorem and integral formula on discs, Lemma 5, analyticity, the Cauchy estimates and the integral ∫dx/(1+x2)=π\int dx/(1 + x^2) = \pi. Not formalised: Goursat's subdivision proof (Mathlib takes a different route to Cauchy's theorem), the converse half of Theorem 1, Laurent series, the residue theorem and the argument principle — Mathlib has no general residue theorem at this version — and the Riemann mapping theorem.

ComputationC

Contour integrals by computer

On a circle, z=c+Reitz = c + Re^{it} makes every contour integral an integral of a periodic function of tt. For periodic integrands that are analytic near the circle, the plain trapezoid rule with nn equally spaced points converges geometrically in nn, far faster than for general integrands. The program uses this to check the theory: ∮dz/z=2πi\oint dz/z = 2\pi i, ∮zˉ dz=2πi\oint \bar z\,dz = 2\pi i (so Cauchy's theorem fails for zˉ\bar z), ∮z2 dz=0\oint z^2\,dz = 0, the derivative formula ∮ez/z3 dz=2πi⋅12!\oint e^z/z^3\,dz = 2\pi i \cdot \frac{1}{2!}, Cauchy's formula for e1/2e^{1/2}, the two residue integrals of the lesson, and the argument principle counting the zeros of z5−3z+1z^5 - 3z + 1.

Contour integrals by computer: Cauchy, residues, zerosPythonNumerical approximationComputationally tested
"""Contour integrals by computer: Cauchy, residues and counting zeros.

On a circle z = c + r e^(it) the integrand of a contour integral is periodic
in t, and for such integrands the plain trapezoid rule converges extremely
fast (geometrically, when the integrand is analytic near the circle). We use
it to check: the integral of 1/z is 2 pi i; the integral of conj(z) over the
unit circle is also 2 pi i (so conj is not holomorphic); Cauchy's integral
formula; the residue evaluations of two real integrals; and the argument
principle, which counts the zeros of a polynomial inside a circle.

Evidence: numerical. Every printed number is an approximation with an error
estimate or a comparison with an exact value; none of it proves a theorem.
"""

import cmath
import math

def circle_integral(f, center=0j, radius=1.0, n=64):
    """Trapezoid rule for the integral of f(z) dz over |z - center| = radius."""
    if n < 1:
        raise ValueError("n must be positive")
    total = 0j
    for k in range(n):
        w = cmath.exp(2j * math.pi * k / n)
        z = center + radius * w
        total += f(z) * 1j * radius * w
    return total * 2 * math.pi / n

def simpson(f, a, b, n):
    """Composite Simpson rule with n (even) subintervals."""
    if n % 2:
        raise ValueError("n must be even")
    h = (b - a) / n
    s = f(a) + f(b)
    s += 4 * sum(f(a + (2 * i - 1) * h) for i in range(1, n // 2 + 1))
    s += 2 * sum(f(a + 2 * i * h) for i in range(1, n // 2))
    return s * h / 3

def count_zeros(p, dp, radius=1.0, n=2048):
    """Argument principle: (1/2 pi i) times the integral of p'/p."""
    value = circle_integral(lambda z: dp(z) / p(z), 0j, radius, n)
    return value / (2j * math.pi)

def fmt(z):
    """Complex number as a short string."""
    return f"{z.real:+.6f} {z.imag:+.6f}i"

def main():
    two_pi_i = 2j * math.pi
    print("Integrals over the unit circle (trapezoid rule, n = 64):")
    rows = [("1/z", lambda z: 1 / z), ("conj(z)", lambda z: z.conjugate()),
            ("z^2", lambda z: z * z), ("exp(z)/z^3", lambda z: cmath.exp(z) / z ** 3)]
    for name, f in rows:
        print(f"  {name:<11} {fmt(circle_integral(f))}")
    print(f"  2 pi i    = {fmt(two_pi_i)};  pi i = {fmt(two_pi_i / 2)}")
    print()
    print("Cauchy's formula: (1/2 pi i) * integral of e^z/(z - 0.5) = e^0.5")
    for n in [4, 8, 16, 32]:
        v = circle_integral(lambda z: cmath.exp(z) / (z - 0.5), n=n) / two_pi_i
        print(f"  n = {n:2d}: error {abs(v - math.exp(0.5)):.2e}")
    print()
    print("Real integrals over [-R, R], R = 400, against residue values:")
    a = simpson(lambda x: 1 / (1 + x * x), -400, 400, 80000)
    b = simpson(lambda x: math.cos(x) / (1 + x * x), -400, 400, 80000)
    print(f"  1/(1+x^2):      {a:.6f}  residue value pi   = {math.pi:.6f}")
    print(f"  cos x/(1+x^2):  {b:.6f}  residue value pi/e = {math.pi / math.e:.6f}")
    print("  (the first misses its tails, about 2/400; the second's")
    print("  oscillating tails are only about 1e-5.)")
    print()
    p = lambda z: z ** 5 - 3 * z + 1
    dp = lambda z: 5 * z ** 4 - 3
    print("Zeros of z^5 - 3z + 1 counted by the argument principle:")
    for r in [0.5, 1.0, 2.0]:
        print(f"  inside |z| = {r}: {fmt(count_zeros(p, dp, r))}")
    print()
    print("Epistemic status: numerical. The trapezoid rule on a circle is")
    print("spectrally accurate for analytic integrands, and the errors shown")
    print("are measured against exact values; the zero counts are near-integers")
    print("that Rouche's theorem confirms (1 zero in |z| < 1, all 5 in |z| < 2).")
    print("None of this replaces the proofs of Cauchy's and the residue theorem.")

if __name__ == "__main__":
    main()
Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.

Look at the error column for Cauchy's formula: it falls from 10−110^{-1} to 10−1010^{-10} as nn goes from 44 to 3232. That geometric decay is itself a theorem of complex analysis: the error is controlled by how far the integrand can be continued holomorphically off the circle. The zero counts come out as near-integers 1,1,51, 1, 5, which Rouché's theorem confirms exactly. All of this is numerical evidence: it checks the theorems on examples to many digits, but proves nothing about other functions or circles.

Explore

Explore: conformal maps and winding numbers

Conformality. The left panel is a grid in the zz-plane; the right is its image under w=z2w = z^2. Drag the probe. The little right-angled cross stays right-angled everywhere, except at z=0z = 0, where f′(0)=0f'(0) = 0 and the angle doubles to 180°180°. Then try eze^z, which turns horizontal lines into rays and vertical lines into circles.

w = z²: angles are preserved where f′ ≠ 0

See a grid in the z-plane carried to the w-plane. Wherever f′(z) ≠ 0, small right angles stay right angles.

Function
Grid
z-plane
z₀
w-plane · w = z²
f(z₀)
  • horizontal lines and their images
  • vertical lines and their images
  • small cross at z₀ and its image

Drag the points, or focus one with Tab and use the arrow keys (hold Shift for small steps).

z₀ =+i
z₀
1 + 0.5i
w₀ = f(z₀)
0.75 + i
f′(z₀)
2 + i
Local scale factor |f′(z₀)|
2.236
Local rotation arg f′(z₀)
26.6°
Angle between the image curves
90°

Conformal at z₀: the little right angle is turned by 26.6° and scaled by 2.236, and it stays a right angle.

Squaring doubles every argument: the right half-plane opens out to the whole plane, and the grid lines become parabolas that still cross at right angles.

The Joukowski map w=z+1/zw = z + 1/z sends circles through −1-1 and enclosing 11 to wing-shaped curves. Because it is conformal away from ±1\pm 1, it carries the flow of air around a cylinder, which is easy to write down, to the flow around an aerofoil.

The Joukowski map z + 1/z

See a grid in the z-plane carried to the w-plane. Wherever f′(z) ≠ 0, small right angles stay right angles.

Function
Grid
z-plane
×z₀
w-plane · w = z + 1/z
f(z₀)
  • circles around 0 and their images
  • rays from 0 and their images
  • small cross at z₀ and its image

Drag the points, or focus one with Tab and use the arrow keys (hold Shift for small steps).

z₀ =+i
z₀
1.5 + 0.75i
w₀ = f(z₀)
2.033 + 0.483i
f′(z₀)
0.787 + 0.284i
Local scale factor |f′(z₀)|
0.837
Local rotation arg f′(z₀)
19.9°
Angle between the image curves
90°

Conformal at z₀: the little right angle is turned by 19.9° and scaled by 0.837, and it stays a right angle.

Circles |z| = r > 1 become ellipses and rays become hyperbolas; the unit circle is flattened onto the segment from −2 to 2. Used to model airflow around wings.

Winding numbers. Send a point around the loop and watch the angle accumulate. The widget computes 12πi∮dzz−a\frac{1}{2\pi i}\oint \frac{dz}{z - a} numerically and it agrees with the count of turns. Drag the hole outside the loop: the integral becomes 00, as Cauchy's theorem predicts, because 1/(z−a)1/(z - a) is then holomorphic inside the loop.

Winding number and ∮ dz/(z − a)

The integral counts how many times the loop winds around a.

p₁

Drag a hole to move it. Press Play to send the point around the loop, or use the slider. The small square marks the start.

Winding number around p₁2

(1/2πi)∮ dz/(z − p₁) ≈ 2.000 + 0.000i

Turns swept so far by each dashed arrow:

p₁: 0.00

The winding number is found by adding up the small changes in direction of the arrow from the hole to the moving point, and dividing the total by 360°. Counter-clockwise counts as positive.

Two loops in the plane with one hole can be deformed into each other, without ever crossing the hole, exactly when they have the same winding number. In the language of topology: the fundamental group of the punctured plane — like that of a circle — is the integers, π₁ = ℤ.

A link to complex analysis: think of the plane as the complex numbers and of a hole as a point a. Then (1/2πi)∮ dz/(z − a) equals the winding number around a. The values above are computed numerically along the loop.

Winding numbers

Move p from one lobe to the other: the winding number changes sign.

Curve
−1p
  • winding number -1
  • winding number 1

Drag the points, or focus one with Tab and use the arrow keys (hold Shift for small steps).

p =+i

Winding number around p: -1

By the angle: as the gold point goes once around the curve, the arrow from p turns -1 full turns (counter-clockwise counts as positive).

By the ray: signed crossings (−1) = −1

Each crossing of the dashed ray counts +1 where the curve passes upwards (counter-clockwise around p) and −1 where it passes downwards (clockwise).

Both counts are computed on the curve sampled at 720 points.

Exercises

Exercises

1. Complex analysis

Warm-upHuman

Write z=x+iyz = x + iy. Which of these functions are holomorphic on all of C\C (entire)? Choose all that apply.

Choose all that apply

2. Complex analysis

Warm-upHuman

Compute 12πi∮∣z∣=23z2+5z−1 dz\displaystyle \frac{1}{2\pi i} \oint_{|z| = 2} \frac{3z^2 + 5}{z - 1}\,dz (circle traversed once anticlockwise).

3. Complex analysis

CoreHuman

For which real constants a,ba, b is f(x+iy)=x2+ay2+i bxyf(x + iy) = x^2 + a y^2 + i\,bxy holomorphic on C\C?

Choose one

4. Complex analysis

CoreHuman

How many zeros (counted with multiplicity) does p(z)=z7−5z3+1p(z) = z^7 - 5z^3 + 1 have in the open unit disc ∣z∣<1|z| < 1?

5. Complex analysis

CoreHuman

Liouville's theorem: a bounded holomorphic function on all of C\C is constant. Which example shows that "on all of C\C" cannot be weakened?

Choose one

6. Complex analysis

CoreFormal

Which Lean statement says that complex conjugation is nowhere complex-differentiable?

Choose one

7. Complex analysis

CoreHuman

Use the residue theorem on the upper semicircle to evaluate ∫−∞∞cos⁡2x1+x2 dx\displaystyle \int_{-\infty}^{\infty} \frac{\cos 2x}{1 + x^2}\,dx.

Choose one

8. Complex analysis

CoreComputational

Write winding_number(points, p) for a closed polygon given by the list points of complex vertices (the last vertex joins back to the first) and a complex point p not on it. Add up the change in the argument of z−pz - p along each edge — the angle cmath.phase((b - p) / (a - p)) from vertex a to vertex b, which lies in (−π,π](-\pi, \pi] — and divide the total by 2π2\pi. Return the nearest integer. (This is 12πi∮dzz−p\frac{1}{2\pi i}\oint \frac{dz}{z - p}, computed exactly edge by edge.)

Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.

9. Complex analysis

StretchHuman

A student argues: "ddzlog⁡z=1z\frac{d}{dz}\log z = \frac1z, so log⁡z\log z is a primitive of 1z\frac1z on C∖{0}\C \setminus \{0\}, and therefore ∮∣z∣=1dzz=log⁡(1)−log⁡(1)=0\oint_{|z|=1} \frac{dz}{z} = \log(1) - \log(1) = 0." But the integral is 2πi2\pi i. What is wrong?

Choose one

10. Complex analysis

StretchHuman

Which statements are true? Choose all that apply.

Choose all that apply
Common misconceptionsH

Common misconceptions

Misconception

"A function of two real variables that is differentiable is holomorphic." Real differentiability allows any 2×22 \times 2 Jacobian. Complex differentiability demands that the Jacobian be a rotation-with-scaling, which is exactly the Cauchy–Riemann equations. The map z↦zˉz \mapsto \bar z is real-linear — as smooth as possible — and complex-differentiable nowhere. ∣z∣2|z|^2 is complex-differentiable only at 00, and holomorphic nowhere, since holomorphy requires differentiability on an open set.

Misconception

"If ff is holomorphic except at one point, it extends holomorphically to that point." Only if ff is bounded near the point (Riemann's removable singularity theorem). 1/z1/z is holomorphic on C∖{0}\C \setminus \{0\} and has no holomorphic extension: ∮∣z∣=1dz/z=2πi\oint_{|z| = 1} dz/z = 2\pi i, while the integral of any entire function over that circle is 00. Poles and essential singularities such as e1/ze^{1/z} cannot be removed.

Misconception

"∮dzz=0\oint \frac{dz}{z} = 0, because log⁡z\log z is a primitive of 1/z1/z." There is no holomorphic logarithm on all of C∖{0}\C \setminus \{0\}. Any branch must jump by 2πi2\pi i somewhere around the origin, and that jump is precisely the value of the integral. Cauchy's theorem needs the path to avoid winding around points where ff fails to be holomorphic.

Misconception

"Liouville's theorem says bounded holomorphic functions are constant." Only entire ones. On the unit disc, f(z)=zf(z) = z is bounded and holomorphic. The domain matters, and the theorem distinguishes C\C from the disc: there is no conformal bijection between them, although they are homeomorphic.

Misconception

"The residue theorem lets you compute any real integral." It needs a closed contour on which the extra pieces can be estimated. That is why the example used eize^{iz} (bounded in the upper half-plane) and not cos⁡z\cos z (which grows exponentially there). For ∫0∞sin⁡xx dx\int_0^\infty \frac{\sin x}{x}\,dx one needs a contour indented around 00: the singularity of sin⁡xx\frac{\sin x}{x} there is removable, but that of eiz/ze^{iz}/z is a pole. For some integrals no convenient contour is known.

ViewpointsH

Many ways of seeing

Topology— Integrals that only see holes

Cauchy's theorem says that ∫γf\int_\gamma f depends only on the homotopy class of γ\gamma in the domain of holomorphy: deforming the path without crossing a singularity changes nothing. On C∖{0}\C \setminus \{0\} the integral γ↦12πi∫γdzz\gamma \mapsto \frac{1}{2\pi i}\int_\gamma \frac{dz}{z} is the winding number, an isomorphism from the fundamental group π1(C∖{0})≅Z\pi_1(\C \setminus \{0\}) \cong \Z onto Z\Z. The argument principle is a theorem about the degree of the map θ↦f(c+Reiθ)/∣f(c+Reiθ)∣\theta \mapsto f(c + Re^{i\theta})/|f(c + Re^{i\theta})| from the circle to itself. It gives a topological proof of the fundamental theorem of algebra: for large RR the loop p(Reiθ)p(Re^{i\theta}) winds nn times around 00, for RR near 00 it winds 00 times (if p(0)≠0p(0) \ne 0), so somewhere in between it must pass through 00. In de Rham's language, dzz\frac{dz}{z} is a closed but not exact 11-form on the punctured plane, a generator of its first cohomology.

Geometry— Conformal geometry and the hyperbolic disc

A holomorphic map with non-vanishing derivative is a conformal map, so complex analysis in one variable is conformal geometry of surfaces. The Riemann sphere C∪{∞}\C \cup \{\infty\} has the Möbius transformations as its conformal automorphisms, a group isomorphic to PSL(2,C)\mathrm{PSL}(2, \C). The unit disc's conformal automorphisms are the maps eiθz−a1−aˉze^{i\theta}\frac{z - a}{1 - \bar a z}, and the Schwarz–Pick lemma says every holomorphic self-map of the disc is a contraction for the Poincaré metric 2∣dz∣1−∣z∣2\frac{2|dz|}{1 - |z|^2}. That metric has constant curvature −1-1: it is the hyperbolic plane of non-Euclidean geometry. The uniformisation theorem extends Riemann's mapping theorem: every simply connected Riemann surface is conformally the sphere, the plane or the disc. See Riemann surfaces.

Physics— Potential flow, electrostatics and the mean value property

For an ideal fluid in the plane (incompressible, irrotational) the velocity field is the gradient of a harmonic potential ϕ\phi, and the streamlines are level curves of a harmonic conjugate ψ\psi. Together they form a holomorphic complex potential Φ=ϕ+iψ\Phi = \phi + i\psi, with complex velocity Φ′‾\overline{\Phi'}. The flow past a cylinder has Φ(z)=U(z+1/z)\Phi(z) = U(z + 1/z), and the Joukowski map carries it to flow past an aerofoil. That was Kutta's and Joukowski's route, between 1902 and 1910, to the lift on a wing. The same mathematics describes electrostatic fields and steady heat flow. Cauchy's integral formula, specialised to a circle centred at ww, gives the mean value property f(w)=12π∫02πf(w+reit) dtf(w) = \frac{1}{2\pi}\int_0^{2\pi} f(w + re^{it})\,dt, which harmonic functions inherit. These ideas return in partial differential equations.

Number theory— Primes from contour integrals

Riemann's 1859 paper continued ζ(s)=∑n−s\zeta(s) = \sum n^{-s} holomorphically from Re⁡s>1\operatorname{Re} s > 1 to C∖{1}\C \setminus \{1\}, and related the primes to its zeros by a contour integral. The prime number theorem — the number of primes up to xx is asymptotic to x/ln⁡xx/\ln x — was proved in 1896 by Hadamard and de la Vallée Poussin. The key complex-analytic input is that ζ(s)≠0\zeta(s) \ne 0 on the line Re⁡s=1\operatorname{Re} s = 1. The Riemann hypothesis, that the non-trivial zeros lie on Re⁡s=12\operatorname{Re} s = \tfrac12, is open. In 1918 Hardy and Ramanujan invented the circle method, which integrates a generating function around circles approaching its natural boundary, and obtained an asymptotic formula for the number of partitions of nn. See analytic number theory.

Algebra— Algebraically closed, and algebraic curves

The fundamental theorem of algebra says that C\C is algebraically closed. It is one of the rare facts of algebra whose standard proofs all use analysis or topology, since some completeness of R\R is unavoidable. The Artin–Schreier route needs only that odd-degree real polynomials have roots (the intermediate value theorem) and Galois theory. Much further, a compact Riemann surface is the same thing as a smooth projective complex algebraic curve, with meromorphic functions corresponding to rational functions on the curve. Riemann's existence theorem and Chow's theorem link the analytic and algebraic worlds, the starting point of algebraic geometry over C\C.

History & global context

History and global context

  • Complex numbers. Rafael Bombelli's L'Algebra (1572) calculated with square roots of negative numbers to solve cubics. The plane picture was given by Caspar Wessel (1799, in Danish), Jean-Robert Argand (1806) and Gauss.
  • Hydrodynamics and the Cauchy–Riemann equations. The equations appear in Jean le Rond d'Alembert's work on fluid resistance (1752) and in Leonhard Euler's work in the 1770s, long before Cauchy and Riemann.
  • Cauchy. Augustin-Louis Cauchy's memoir on definite integrals (1814, published 1827) and his 1825 memoir on integrals between imaginary limits contain the integral theorem; he developed the residue calculus from 1826 and the integral formula in 1831. Liouville stated his theorem in 1844 for elliptic functions; Cauchy gave the general version the same year.
  • Riemann and Weierstrass. Bernhard Riemann's 1851 dissertation took the Cauchy–Riemann equations as the definition, introduced Riemann surfaces and stated the mapping theorem. Karl Weierstrass built the theory from power series instead. Édouard Goursat (1900) removed the assumption that f′f' is continuous from Cauchy's theorem.
  • Number theory. Riemann's 1859 paper on ζ\zeta, the prime number theorem of Hadamard and de la Vallée Poussin (1896), and the circle method of G. H. Hardy and Srinivasa Ramanujan (1918) made complex analysis a central tool of arithmetic.
  • Applications. Martin Kutta and Nikolai Joukowski used conformal maps to compute the lift of aerofoils (between 1902 and 1910), and conformal mapping remains a standard tool in fluid dynamics and electrostatics.
Further reading

Further reading

  • Elias M. Stein and Rami Shakarchi, Complex Analysis (2003) — the modern standard course; Goursat-based proofs as in this lesson, with applications to number theory.
  • Lars V. Ahlfors, Complex Analysis (1953; 3rd edition 1979) — the classic, with the general homology form of Cauchy's theorem.
  • Tristan Needham, Visual Complex Analysis (1997) — geometric intuition for everything in this lesson.
  • John B. Conway, Functions of One Complex Variable I (1973; 2nd edition 1978) — careful and complete, including the Riemann mapping theorem.