Contour Integration

Draw paths and integrate along them - Cauchy's theorems come alive

Contour Integration

One of the most powerful tools in complex analysis is the ability to integrate functions along contours (paths) in the complex plane. Unlike real integration, complex integrals depend on the path taken - unless the function is analytic!

The fundamental results - Cauchy's Integral Theorem and Cauchy's Integral Formula - connect analyticity to path independence and allow us to evaluate integrals that would be impossible in real analysis.

1. Interactive Contour Integrator

The contour integral of f(z) along a path γ is defined as:

γ f(z) dz = ab f(γ(t)) · γ'(t) dt

Click on the canvas to draw a custom contour, or select a preset shape. Then choose a function to integrate along your path.

💡 Observations:

  • For closed contours (start = end), try integrating f(z) = z - notice it gives 0!
  • Now try f(z) = 1/z around a circle containing the origin - you get 2πi (non-zero!)
  • The rectangle and circle give different results for most functions, showing path dependence
  • Custom paths let you explore more complex contours - try drawing a figure-eight or spiral!

2. Cauchy's Integral Theorem

One of the most important theorems in complex analysis:

Cauchy's Integral Theorem
If f is analytic in a simply connected domain D, and γ is any closed contour in D, then:
γ f(z) dz = 0

This means that for analytic functions, closed path integrals always equal zero! This is not true for non-analytic functions.

Square: f(z) = z²
Analyticity: Everywhere (entire function)

Domain Coloring Visualization:

The selected contour encloses the plotted region. Zeros appear black, poles appear white.

Contour Integral Result:

γ dz =
-0.0003 - 0.0106i
Magnitude: 0.0106
Expected Result:
0 (Cauchy's Theorem applies)

🔍 Cauchy's Integral Theorem Explained:

  • If f is analytic everywhere inside and on a closed contour γ, then ∮γ f(z) dz = 0
  • This is why z, z², e^z, and sin(z) all give 0 - they're analytic everywhere (entire functions)
  • f(z) = 1/z is NOT analytic at z = 0. If the contour encloses the origin, the integral is 2πi (non-zero!)
  • If the pole is outside the contour, the function is analytic inside, so the integral is 0
  • Non-analytic functions like z̄ violate Cauchy's theorem - integrals are generally non-zero

3. Cauchy's Integral Formula

An even more remarkable result - we can recover the value of an analytic function at any point from its values on a surrounding contour:

Cauchy's Integral Formula
If f is analytic inside and on a simple closed contour γ, and a is inside γ, then:
f(a) = (1/2πi) γ f(z)/(z-a) dz

This formula is extraordinary: knowing f on the boundary completely determines f inside! This has no analog in real analysis.

Test Point: a = 0.50 + 0.30i

✓ Point is inside the contour (formula applies)

Circular contour centered at origin with radius 1.5

Verification of Cauchy's Integral Formula:

Direct Evaluation
f(a) = f(0.50+0.30i) = z²
0.1600 + 0.3000i
Cauchy's Formula
(1/2πi) ∮ f(z)/(z-a) dz
0.1584 + 0.2996i
✓ Formula Verified!
Absolute Error: -0.001563 - 0.000417i
Error Magnitude: 0.001618
Relative Error: 0.48%
The formula accurately recovers f(a) from the contour integral!

🎯 Cauchy's Integral Formula Explained:

  • This formula is remarkable: it says the value of f at any interior point is completely determined by its values on the boundary
  • No such result exists in real analysis! This is unique to complex analytic functions.
  • The formula implies that analytic functions are infinitely differentiable (you can differentiate under the integral)
  • Generalized form: f(n)(a) = (n!/2πi) ∮ f(z)/(z-a)n+1 dz gives all derivatives!
  • This leads to power series representations (Taylor series) for all analytic functions

4. Path Independence

For analytic functions, the integral between two points is path independent - it doesn't matter which path you take! This is similar to conservative vector fields in real analysis.

If f is analytic in D, and γ₁, γ₂ are any two paths from a to b in D, then:
γ f(z) dz = γ f(z) dz

For non-analytic functions, this is false - different paths give different integrals.

Adjust how much the curved path (purple dashed) deviates from the straight path (blue solid)

Path 1 (Straight Line)
Direct path from start to end
Path 1 dz =
-0.7478 + 3.8219i
Path 2 (Curved Path)
Curved path with curvature 1.0
Path 2 dz =
-0.7603 + 3.8194i
✗ PATH DEPENDENT
Difference between paths:
0.0125 + 0.0025i
Magnitude: 0.012740
⚠ Small numerical error - analytically these should be equal

🔄 Path Independence Explained:

  • For analytic functions (z, z², e^z, sin(z)), the integral between two points is the same regardless of the path taken
  • This is similar to conservative vector fields in real calculus (∇f has path-independent line integrals)
  • For non-analytic functions (z̄) or functions with singularities between paths (1/z), different paths give different integrals
  • Path independence is equivalent to saying ∮ f(z) dz = 0 for all closed curves (Cauchy's theorem)
  • Try increasing curvature to make paths more different - analytic functions still give same result!

Key Takeaways

1. Contour Integrals: Complex integrals are path integrals in the complex plane. They generalize real line integrals to 2D.

2. Cauchy's Theorem: For analytic functions, all closed path integrals equal zero. This is the foundation of complex integration theory.

3. Cauchy's Formula: We can compute f(a) from values on any surrounding contour. This leads to the fact that analytic functions have derivatives of all orders!

4. Path Independence: For analytic functions, integrals between fixed endpoints don't depend on the path - a profound simplification not found in real analysis.

5. Connection to Analyticity: All these results require analyticity. Non-analytic functions (like z̄ or |z|²) don't have these properties.