One derivative, and everything follows
Here is a real integral that resists every technique of first-year calculus:
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 . 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 of a complex variable is holomorphic if the limit
exists, where now is a complex number that may approach 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.
Derivatives that rotate and stretch
A real-differentiable map of the plane looks, near a point, like a linear map — any matrix. A complex derivative says much more: near , acts like multiplication by , that is, a rotation by combined with scaling by . Rotations-with-scaling are the matrices
So a holomorphic map, wherever , 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 is a reflection, the matrix . 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, measures how far the argument of turns: one full turn, . For a function holomorphic inside the loop, the corresponding integral is . 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.
Definitions
Definition— complex derivative, holomorphic, entire
Let be open and . is complex-differentiable at if exists. is holomorphic on if it is complex-differentiable at every point of , and entire if it is holomorphic on .
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 , and .
Definition— contour integral
A path is a piecewise continuously differentiable map ; it is closed if . For continuous on the image of ,
The circle traversed once anticlockwise, for , gives .
Two facts are used constantly. The ML-inequality: if on the image of and has length , then . And primitives kill closed integrals: if on an open set containing the image of , then , which is for closed (chain rule plus the real fundamental theorem of calculus).
Definition— isolated singularity, pole, residue
If is holomorphic on a punctured disc , then is an isolated singularity. It is removable if extends holomorphically to . It is a pole of order if with holomorphic near and . Otherwise it is essential. The residue is the coefficient of in the Laurent expansion about .
Definition— winding number
For a closed path and a point not on it, the winding number is . It is an integer, and it counts the number of times travels anticlockwise around .
Examples and non-examples
Example— The integral of (z − c) to the power n
Parametrise , so . For every integer ,
For this also follows from the primitive . For there is no primitive on : a "logarithm" would have to increase by every time it goes around . This single computation is the seed of the residue theorem.
Example— Real-differentiable is not enough
Write . The map is linear over , hence real-differentiable. But along a real increment the difference quotient is , and along an imaginary increment it is . The limit does not exist, so is complex-differentiable nowhere. Similarly is complex-differentiable only at , and nowhere. Consistently, , since on the unit circle.
Example— Three kinds of isolated singularity
- at : removable, since extends with value .
- at : a simple pole, , with residue .
- at : essential, with infinitely many negative powers and residue . Near it takes every non-zero value infinitely often (a theorem of Picard).
The Cauchy–Riemann equations
Theorem— Theorem 1 (Cauchy–Riemann)
Write with real-valued functions of . If is complex-differentiable at , then the partial derivatives of and exist at and
Conversely, if and have continuous partial derivatives near satisfying these equations there, then is holomorphic near .
Proof
Let along the real axis, : the difference quotient tends to , which must equal . Along the imaginary axis, :
Equating real and imaginary parts of gives the equations.
Conversely, continuous partial derivatives make real-differentiable: , where is the Jacobian matrix acting on . The equations say with , , and this matrix acts on as multiplication by . So .
∎
The equations have a striking consequence. If are twice continuously differentiable (we shall see that they always are), then . The real and imaginary parts of a holomorphic function are harmonic. For example, , and both and satisfy Laplace's equation.
Cauchy's theorem and the integral formula
Theorem— Theorem 2 (Goursat)
If is holomorphic on an open set containing a closed triangle (with its inside), then .
Proof
Let , and let and be the perimeter and diameter of . Join the midpoints of the sides to cut into four similar triangles. The integrals over their boundaries add up to the integral over , because the inner edges are traversed twice in opposite directions. So one of them, , has . Repeating gives nested triangles with
By completeness (the nested compact sets have a common point) there is . Since is differentiable at , with as . The linear part has a primitive, so its integral over vanishes. Let , so . By the ML-inequality,
So , and .
∎
Theorem— Lemma 3 (one exceptional point)
Goursat's theorem still holds if is continuous on the open set and holomorphic except at one point .
Proof
If is a vertex of , cut off a tiny triangle at of perimeter . The rest of splits into triangles not containing , whose integrals vanish by Theorem 2. The tiny triangle contributes at most , which tends to with . If lies elsewhere in , split into triangles that have as a vertex.
∎
Theorem— Theorem 4 (Cauchy's theorem in a disc)
Let be continuous on an open disc and holomorphic on except possibly at one point. Then has a primitive on , and for every closed path in .
Proof
Let be the centre and set , the integral along the segment from to . For , Lemma 3 for the triangle with vertices gives . Since ,
by continuity. So , and integrals of over closed paths vanish because has a primitive.
∎
Note
Cauchy's theorem holds far beyond discs. General form (stated, not proved here): if is holomorphic on an open set and the closed path in is null-homotopic in — or more generally has winding number about every point outside — then . 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 , then .
Proof
On the circle , so the geometric series
converges uniformly on the circle (M-test with ). Integrate term by term: by the first example, only survives, giving .
∎
Theorem— Theorem 6 (Cauchy's integral formula)
Let be holomorphic on an open set containing the closed disc . Then for every with ,
Proof
is holomorphic on a slightly larger disc . Define for and . Then is continuous on and holomorphic except at , so by Theorem 4. Hence
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.
Power series, Liouville and the fundamental theorem of algebra
Theorem— Theorem 7 (holomorphic functions are analytic)
Let be holomorphic on the open disc . Then for all , where, for any ,
Consequently is infinitely complex-differentiable, with .
Proof
Fix and choose with . 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 ), and this gives the series. A power series is infinitely differentiable inside its disc of convergence, with derivatives computed term by term, so . The coefficients do not depend on , because they are determined by the derivatives at .
∎
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 about has radius , although the function is perfectly smooth on all of . Over it has poles at , at distance .
Theorem— Corollary 8 (Cauchy's estimates)
If is holomorphic on a neighbourhood of and on the circle , then .
Proof
ML-inequality in the formula for : .
∎
Theorem— Theorem 9 (Liouville)
Every bounded entire function is constant.
Proof
If on , Corollary 8 with gives for every , so for every . A function with zero derivative on the connected set is constant (integrate along segments from ).
∎
Theorem— Theorem 10 (fundamental theorem of algebra)
Every non-constant polynomial with complex coefficients has a complex root. Hence factors as .
Proof
Write with and . For we have , so . Suppose had no root. Then is entire. It is bounded by for , and bounded on the compact disc by continuity. By Liouville, is constant, so is constant — a contradiction. The factorisation follows by induction on the degree, dividing by .
∎
Laurent series and the residue theorem
Theorem— Proposition 11 (principal parts)
Let have a pole of order at : with holomorphic near , . Expanding (Theorem 7) gives
so is holomorphic near (after removing the singularity), and . For a simple pole of a quotient with and : .
(Every isolated singularity, including essential ones, has a two-sided Laurent expansion 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 be holomorphic on an open set containing the closed disc , except at finitely many poles , all with . Then
Proof
Let be the principal part at . The function has only removable singularities in the disc. Each is holomorphic away from , and is holomorphic near by Proposition 11. After removing those singularities, is holomorphic on a disc slightly larger than . By Theorem 4, . And , where only the term survives, by the computation for and Lemma 5 for . That term contributes .
∎
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) . Let be the segment followed by the upper semicircle of radius . Inside lies one simple pole of , at , with residue . So . On , , so the ML-inequality bounds that part by . Letting gives .
(b) . Use instead. On the upper half-plane , so the same estimate kills . The residue at is . Hence . Taking real parts gives the result, and the imaginary part, , is consistent with the integrand being odd. (Using directly would fail: grows like on the semicircle.)
Applied to , the residue theorem counts zeros. Argument principle: if is holomorphic on a neighbourhood of with no zeros on the circle, then is the number of zeros inside, counted with multiplicity. (At a zero of order , has a simple pole with residue .) Its corollary, Rouché's theorem, says: if on the circle, then and have the same number of zeros inside. For example has exactly one zero in , since there.
Theorem— Proposition 13 (1/z has no holomorphic extension)
There is no entire function with for all . More generally, has no primitive on .
Proof
If were entire, Cauchy's theorem would give . But on the circle, and . A primitive of on would also force .
∎
The obstruction is exactly that is unbounded near . 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 , which is complex-differentiable at with derivative .)
Conformal maps
Theorem— Proposition 14 (holomorphic maps preserve angles)
If is holomorphic near and , then preserves the oriented angle between any two smooth curves crossing at .
Proof
A curve with and is mapped to , with tangent by the chain rule. Every tangent vector is multiplied by the same non-zero complex number , which rotates all of them by . So the angle between any two of them is unchanged.
∎
Where angles are multiplied: doubles every angle at . The Möbius transformations () are conformal bijections of the Riemann sphere that send circles and lines to circles and lines. For example maps the upper half-plane onto the unit disc. Riemann mapping theorem (stated, not proved here): every simply connected open set 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).
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:
/-- `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 UThe Cauchy–Riemann equations in derivative form: a complex derivative gives rate in the real direction and in the imaginary direction. Applied to conjugation, whose rates are and , it proves that is nowhere complex-differentiable:
/-- **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/-- **`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 thisCauchy'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'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/-- **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/-- **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/-- **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 hUProposition 13 — no entire extension of — proved from those two facts exactly as on paper:
/-- **`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 h0Liouville's theorem, proved from the Cauchy estimate as in Theorem 9, next to Mathlib's own statement:
/-- **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/-- **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/-- 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 wThe 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 is Mathlib's Polynomial.tendsto_norm_atTop.
/-- **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/-- 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 hpFinally, the real integral of Example (a), which Mathlib evaluates with rather than residues:
/-- `∫_{-∞}^{∞} 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_sqWhat is and is not formalised. Proved here: the Cauchy–Riemann equations in directional form (the necessity half of Theorem 1), the nowhere-differentiability of , 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 . 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.
Contour integrals by computer
On a circle, makes every contour integral an integral of a periodic function of . For periodic integrands that are analytic near the circle, the plain trapezoid rule with equally spaced points converges geometrically in , far faster than for general integrands. The program uses this to check the theory: , (so Cauchy's theorem fails for ), , the derivative formula , Cauchy's formula for , the two residue integrals of the lesson, and the argument principle counting the zeros of .
"""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()Look at the error column for Cauchy's formula: it falls from to as goes from to . 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 , 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: conformal maps and winding numbers
Conformality. The left panel is a grid in the -plane; the right is its image under . Drag the probe. The little right-angled cross stays right-angled everywhere, except at , where and the angle doubles to . Then try , 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.
- 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₀
- 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 sends circles through and enclosing to wing-shaped curves. Because it is conformal away from , 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.
- 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₀
- 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 numerically and it agrees with the count of turns. Drag the hole outside the loop: the integral becomes , as Cauchy's theorem predicts, because is then holomorphic inside the loop.
Winding number and ∮ dz/(z − a)
The integral counts how many times the loop winds around a.
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.
- winding number -1
- winding number 1
Drag the points, or focus one with Tab and use the arrow keys (hold Shift for small steps).
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
1. Complex analysis
Warm-upHumanWrite . Which of these functions are holomorphic on all of (entire)? Choose all that apply.
2. Complex analysis
Warm-upHumanCompute (circle traversed once anticlockwise).
3. Complex analysis
CoreHumanFor which real constants is holomorphic on ?
4. Complex analysis
CoreHumanHow many zeros (counted with multiplicity) does have in the open unit disc ?
5. Complex analysis
CoreHumanLiouville's theorem: a bounded holomorphic function on all of is constant. Which example shows that "on all of " cannot be weakened?
6. Complex analysis
CoreFormalWhich Lean statement says that complex conjugation is nowhere complex-differentiable?
7. Complex analysis
CoreHumanUse the residue theorem on the upper semicircle to evaluate .
8. Complex analysis
CoreComputationalWrite 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 along each edge — the angle cmath.phase((b - p) / (a - p)) from vertex a to vertex b, which lies in — and divide the total by . Return the nearest integer. (This is , computed exactly edge by edge.)
9. Complex analysis
StretchHumanA student argues: ", so is a primitive of on , and therefore ." But the integral is . What is wrong?
10. Complex analysis
StretchHumanWhich statements are true? Choose all that apply.
Common misconceptions
Misconception
"A function of two real variables that is differentiable is holomorphic." Real differentiability allows any Jacobian. Complex differentiability demands that the Jacobian be a rotation-with-scaling, which is exactly the Cauchy–Riemann equations. The map is real-linear — as smooth as possible — and complex-differentiable nowhere. is complex-differentiable only at , and holomorphic nowhere, since holomorphy requires differentiability on an open set.
Misconception
"If is holomorphic except at one point, it extends holomorphically to that point." Only if is bounded near the point (Riemann's removable singularity theorem). is holomorphic on and has no holomorphic extension: , while the integral of any entire function over that circle is . Poles and essential singularities such as cannot be removed.
Misconception
", because is a primitive of ." There is no holomorphic logarithm on all of . Any branch must jump by 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 fails to be holomorphic.
Misconception
"Liouville's theorem says bounded holomorphic functions are constant." Only entire ones. On the unit disc, is bounded and holomorphic. The domain matters, and the theorem distinguishes 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 (bounded in the upper half-plane) and not (which grows exponentially there). For one needs a contour indented around : the singularity of there is removable, but that of is a pole. For some integrals no convenient contour is known.
Many ways of seeing
Topology— Integrals that only see holes
Cauchy's theorem says that depends only on the homotopy class of in the domain of holomorphy: deforming the path without crossing a singularity changes nothing. On the integral is the winding number, an isomorphism from the fundamental group onto . The argument principle is a theorem about the degree of the map from the circle to itself. It gives a topological proof of the fundamental theorem of algebra: for large the loop winds times around , for near it winds times (if ), so somewhere in between it must pass through . In de Rham's language, is a closed but not exact -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 has the Möbius transformations as its conformal automorphisms, a group isomorphic to . The unit disc's conformal automorphisms are the maps , and the Schwarz–Pick lemma says every holomorphic self-map of the disc is a contraction for the Poincaré metric . That metric has constant curvature : 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 , and the streamlines are level curves of a harmonic conjugate . Together they form a holomorphic complex potential , with complex velocity . The flow past a cylinder has , 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 , gives the mean value property , which harmonic functions inherit. These ideas return in partial differential equations.
Number theory— Primes from contour integrals
Riemann's 1859 paper continued holomorphically from to , and related the primes to its zeros by a contour integral. The prime number theorem — the number of primes up to is asymptotic to — was proved in 1896 by Hadamard and de la Vallée Poussin. The key complex-analytic input is that on the line . The Riemann hypothesis, that the non-trivial zeros lie on , 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 . See analytic number theory.
Algebra— Algebraically closed, and algebraic curves
The fundamental theorem of algebra says that is algebraically closed. It is one of the rare facts of algebra whose standard proofs all use analysis or topology, since some completeness of 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 .
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 is continuous from Cauchy's theorem.
- Number theory. Riemann's 1859 paper on , 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
- 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.