Silence is a source of great strength, Lao Tzu

A complex function $f(z)$ maps $z = x + iy \in \mathbb{C}$ to another complex number. For example: $f(z) = z^2 = (x + iy)^2 = x^2 - y^2 + 2ixy, f(z) = \frac{1}{z}, f(z) = \sqrt{z^2 + 7}$.
A contour is a continuous, piecewise-smooth curve defined parametrically as: $z(t) = x(t) + iy(t), \quad a \leq t \leq b$.
Definition (Smooth Contour Integral). Let ᵞ be a smooth contour (a continuously differentiable path in the complex plane), $\gamma: [a, b] \to \mathbb{C}$. Let $f: \gamma^* \to \mathbb{C}$ be a continuous complex-valued function defined on the trace $\gamma^*$ of the contour (i.e. along the image of $\gamma$). Then, the contour integral of f along $\gamma$ is defined as $\int_{\gamma} f(z)dz := \int_{a}^{b} f(\gamma(t)) \gamma^{'}(t)dt$.

Deformation of Contours. If two contours $\gamma_1$ and $\gamma_2 $ are homotopic (i.e., one can be continuously deformed into the other without crossing any singularities of f) in a domain where f(z) is analytic, then: $\int_{\gamma_1} f(z)dz = \int_{\gamma_2} f(z)dz.$
Fundamental Theorem of Calculus for Contours. Suppose $\gamma$ is a contour (piecewise smooth path) from a to b, f is defined on a domain D containing $\gamma^*$ (the image of $\gamma$) and admits a primitive (antiderivative) F on D (i.e., $F'(z) = f(z)$), then $\int_{\gamma} f(z)dz = F(\gamma(b)) - F(\gamma(a))$. In particular, if $\gamma$ is a closed contour (i.e., $\gamma(a)=\gamma(b)$), this integral evaluates to zero, $\int_{\gamma} f(z)dz = 0.$
Estimation Theorem or the Triangle Inequality for Integrals. The triangle inequality for integrals in complex analysis states thatfor any continuous complex function $f:[a,b] \to \mathbb{C}$ on a closed real interval [a,b] (f(t) = u(t) + iv(t), t a real parameter), the following holds: $∣\int_a^b f(t)dt| \leq \int_a^b |f(t)|dt$.
Estimation Lemma (ML Inequality) for contour integrals. For any continuous complex function $f:[a,b] \to \mathbb{C}$ on a closed real interval [a,b] (f(z) = u(x, y) + iv(x, y)) with f bounded by some constant M along the entire contour, |f(z)| ≤ M for all $z \in \gamma^*$ (the image/trace of the contour in the complex plane), the following holds: $∣\int_\gamma f(z)dz| \leq M \cdot l(\gamma)$ where l(γ) is the arc length of the contour γ given by $\int_a^b |\gamma^{'}(t)|dt = \int_a^b \sqrt{x'(t)^2 + y'(t)^2} \text{ where } \gamma(t) = x(t) + iy(t)$.
Jordan’s curve theorem. Any simple closed curve (a continuous loop in the plane that does not intersect itself) separates the plane into two disjoint connected regions: one interior (bounded) and one exterior (unbounded). The curve itself is the boundary of both regions. In other words, it partitions the plane into exactly three disjoint sets:
Lemma. If γ is a piecewise differentiable closed curve that does not pass through a point a in the complex plane, then the value of the integral $\oint_{\gamma} \frac{dz}{z-a}$ is an integer multiple of 2πi.
This Lemma proves that the integral $\oint_{\gamma} \frac{dz}{z-a}$ can only take on a discrete set of values: $\{ \dots, -2\pi i, 0, 2\pi i, 4\pi i, \dots \}$.
Proof.
Let the closed contour $\gamma$ be parameterized by $z = \gamma(t)$ for $t \in [\alpha, \beta]$. Since $\gamma$ is closed, the starting point $\gamma(\alpha)$ equals the final point $\gamma(\beta), \gamma(\alpha) = \gamma(\beta)$.
We define the function $h(t)$ as the value of the integral along the path $\gamma$ from the starting time $\alpha$ up to t: $h(t) = \int_{\alpha}^t \frac{\gamma'(u) du}{\gamma(u)-a} \text{ for } t \in [\alpha, \beta]$.
$h(t) = \int_{\alpha}^t f(u) du \quad \text{where } f(u) = \frac{\gamma'(u)}{\gamma(u)-a}$. A fundamental theorem of calculus states that if $f(u)$ is piecewise continuous on a closed interval $[\alpha, \beta]$, then the integral function $h(t)$ is continuous on that entire interval. Notice that h(t) represents the accumulated area as t increases. A piecewise continuous function f(u) can have a finite number of jumps. Integrating a finite jump results in a corner in the graph of the integral function h(t), but it does not result in a break or jump in h(t). For h(t) to be discontinuous, the integrand f(u) would have to contain an infinite singularity (which is ruled out because $\gamma(u) \neq a$).
Consider the auxiliary function $G(t) = e^{-h(t)} (\gamma(t)-a)$. We compute the derivative of $G(t)$ with respect to t.
$$ \begin{aligned} \frac{d}{dt}(e^{-h(t)} (\gamma(t)-a)) = & [\text{ Product rule: } \frac{d}{dt}(uv) = u'v + uv'] \\[2pt] &=e^{-h(t)}(-h'(t))(\gamma(t)-a) + e^{-h(t)}(\gamma'(t)) \\[2pt] &= [\text{Now, we substitute the expression for $h'(t)$ from (3)}] \\[2pt] &=e^{-h(t)}(-\frac{\gamma'(t)}{\gamma(t)-a})(\gamma(t)-a) + e^{-h(t)}(\gamma'(t)) \\[2pt] &=e^{-h(t)}(-\gamma'(t))+ e^{-h(t)}(\gamma'(t))\\[2pt] &=0. \end{aligned} $$Since the derivative of the function $G(t)$ is identically zero on the interval $[\alpha, \beta]$, the function itself must be a constant, $e^{-h(t)} (\gamma(t)-a) = c$ where c is a constant.
This can be rearranged to express the path $\gamma(t)$ in terms of h(t): $\gamma(t)-a = ce^{h(t)}$. In particular, we evaluate the expression at $t = \beta, ce^{h(\beta)} = \gamma(\beta)-a = \gamma(\alpha) - a =[\text{Evaluating the expression at } t = \alpha] ce^{h(\alpha)} =[(2)] ce^0 = c$.
Since we know $h(\alpha) = 0$ (2), and $e^0 = 1:c(1) = \gamma(\alpha) - a \implies c = \gamma(\alpha) - a$. Since the curve does not pass through a, $c = \gamma(\alpha) - a \neq 0$.
Therefore, $ce^{h(\beta)} = c \leadsto[c \neq 0, \text{ we can divide both sides by c}] e^{h(\beta)} = 1 \leadsto h(\beta) = 2\pi i n$ for some integer n.
The solution to the equation $e^w = 1$ in the complex plane is $w = 2\pi i n$, where n is any integer ($\dots, -2, -1, 0, 1, 2, \dots$).
Finally, we observe that the value $h(\beta)$ is the desired integral: $\oint_{\gamma} \frac{dz}{z-a} = \int_{\alpha}^{\beta} \frac{\gamma'(t) dt}{\gamma(t)-a} = h(\beta) = 2\pi i n$
Definition. Suppose we are given a closed, oriented curve in the xy plane. Then, the winding number of the curve is equal to the total number of counterclockwise turns that the object makes around the origin.
When counting the total number of turns, counterclockwise motion counts as positive (it contributes +1 per full loop), while clockwise motion counts as negative (it contributes −1 per full loo).
Formal definition. Let $\gamma: [α, β] → \mathbb{C}$ be a piecewise smooth, closed curve (so γ(α) = γ(β)), the winding number of γ about $z_0$, a complex point not on the curve $z_0$ ∉ γ([α, β]), also known as the index of $z_0$ with respect to γ, is defined as $n(\gamma, z_0) = Ind_{\gamma}(z_0) = \frac{1}{2\pi i} \oint_{\gamma} \frac{dz}{z - z_0} = \frac{1}{2\pi i} \int_{\alpha}^{\beta} \frac{\gamma'(t)}{\gamma(t) - z_0}dt$.
Figure 4 illustrates indices −2, −1, 0, 1, 2, 3 for concentric loops with various orientations; the multi-loop picture shows different points $z_0, z_1, z_2$ with different winding counts. 
To understand why this formula works, consider the polar representation. Write: $z-z_0 = re^{i\theta} \leadsto dz = e^{i\theta}dr + ire^{i\theta}d\theta \leadsto \frac{dz}{z-z_0} = \frac{e^{i\theta}dr + ire^{i\theta}d\theta}{re^{i\theta}} = \frac{dr}{r}+id\theta$
$\oint_{\gamma} \frac{dz}{z - z_0} = \int_a^b \frac{dr}{r}+id\theta = ln(r)\bigg|_{a}^{b} + i×\text{total change in θ}$
The term $\frac{dr}{r}$ integrates to zero because ln(r) returns to its initial value (closed curve).
$\oint_{\gamma} \frac{dz}{z - z_0} = i×\text{total change in θ} = i(2\pi k)$ where k is the net number of revolutions. Dividing by 2πi gives k, the winding number.
For a simple closed curve γ:
This is intuitive: if you are standing far away from a loop, your total change of argument θ as someone walks around it is zero —they return to their starting position without ever circling you.
This means you can replace a complicated curve with a simple one (like a circle) for calculation purposes, provided the new curve encloses the same points.
$n(\gamma, 0) = \frac{1}{2\pi i} \int_{0}^{1} \frac{1}{e^{i2\pi t}} \cdot \frac{d}{dt}(e^{i2\pi t}) dt = \frac{1}{2\pi i} \int_{0}^{1} \frac{i2\pi e^{i2\pi t}}{e^{i2\pi t}} dt = \frac{1}{2\pi i} \cdot i2\pi = 1$
A circle centered at the origin with a point inside has a winding number of +1 (counterclockwise) or -1 (clockwise).
For any $z_0$ with $|z_0| \lt R, \mathbb{n}(\gamma; z_0) = 1.$ This can be quickly verified using Cauchy’s Integral Formula. Let f(z)=1. The formula states: $\oint_\gamma \frac{f(z)}{z-z_0} dz = 2\pi i \cdot f(z_0)$. Substituting into the winding number definition: $\mathbb{n}(\gamma;z_0) = \frac{1}{2\pi i}\oint_\gamma \frac{f(z)}{z-z_0} dz = \frac{1}{2\pi i} (2\pi i \cdot f(z_0)) = f(z_0) = 1.$
For any $z_0$ with $|z_0| > R, \mathbb{n}(\gamma;z_0) = 0.$ This follows from Cauchy’s Theorem. If $z_0$ is outside the circle, the function f(z) = $\frac{1}{z-z_0}$ is analytic at all points inside and on the contour γ. Therefore, its integral over the closed contour is zero: $\mathbb{n}(\gamma;z_0) = \frac{1}{2\pi i}\oint_\gamma \frac{f(z)}{z-z_0} dz = \frac{1}{2\pi i} \cdot 0 = 0.$
Hence, $\mathbb{Int}(\gamma) = \{ z \in \mathbb{C} | \mathbb{n}(\gamma; z_0) = 1 \} = \{ z \in \mathbb{C} | |z| < R \} \text{ and } \mathbb{Ext}(\gamma) = = \{ z \in \mathbb{C} | \mathbb{n}(\gamma; z_0) = 0 \} = \{ z \in \mathbb{C} | |z| > R \}.$
Simple polygon (one that does not self-intersect). Let γ be its boundary traversed counterclockwise. This is a perfect example of a Jordan curve. As such, the Jordan Curve Theorem guarantees that it cleanly separates the complex plane into two distinct regions: A bounded interior, which is the area inside the polygon $Int(\gamma^∘)$; an unbounded exterior, which is the area outside. For any $z_0 \in Int(\gamma^∘), n(\gamma; z_0) = 1$ (γ will encircle the point exactly once in the positive direction); for $z_0 \notin \bar{\mathbb{P}}, n(\gamma; z_0) = 0$ (the boundary does not wrap around it at all).
Figure-Eight Curve. Let $ \gamma(t) = e^{i\pi t} + e^{i2\pi t} $, $ t \in [0, 2] $. This traces a figure-eight. The winding number around $ z_0 = 0 $ is undefined because the winding number is only defined for points that are not on the contour.
Example of Cancellation. Consider a path made of two parts: γ₁, the unit circle traversed counter-clockwise, $e^{i2\pi t}$ for $ t \in [0, 1]$. The winding number around the origin is n(γ₁, 0) = 1, a full positive (counter-clockwise) loop around the origin; The unit circle traversed clockwise, $e^{-i2\pi t}$ for $ t \in [1, 2]$. The winding number around the origin is n(γ₂, 0) = -1, a full negative (clockwise) loop around the origin.
The total winding number of the combined path γ = γ₁+γ₂ is the sum of the individual winding numbers: n(γ, 0) = n(γ₁, 0) + n(γ₂, 0) = 1 + (-1) = 0.
The two loops cancel each other out. The combined path γ winds around the origin zero times
Case 1. $z_0 \in Int(\gamma)$
Approximate the Curve with a Polygon. A Jordan curve γ can be approximated arbitrarily well by a simple polygon P that lies entirely within its interior. We can construct P to be positively oriented and “close enough” to γ so that it also contains $z_0$. Because the winding number integral is continuous with respect to the path, this approximation doesn’t change the result: $n(\gamma, z_0) = n(P, z_0)$
Triangulate the Polygon. Any simple polygon can be divided into a finite number of triangles ($T_1, T_2, \cdots T_k$). The integral over the boundary of the polygon is the sum of the integrals over the boundaries of these triangles. This is because all the internal edges are traversed twice in opposite directions, and their integrals cancel each other out, leaving only the integral over the exterior boundary: $n(P, z_0) = \sum_{j=1}^k n(∂T_j,z_0)$.
Isolate the Key Triangle. The point $z_0$ must lie in the interior of exactly one of these triangles, let’s call it $T_1$. For any other triangle $T_j, j \ne 1$, the point $z_0$ is in its exterior. The function $\frac{1}{z-z_0}$ is analytic inside and on the boundary of $T_j$. By Cauchy’s Integral Theorem, the integral is zero. Thus, $n(∂T_j,z_0) = 0$ for j ≠ 1.
This means our sum collapses to a single term: $n(P, z_0) = \sum_{j=1}^k n(∂T_j,z_0) = n(∂T_1,z_0)$
Deform the Triangle to a Circle (Homotopy). Let C be a small, positively oriented circle centered at $z_0$ that lies completely inside the triangle $T_1$. The function $\frac{1}{z-z_0}$ is analytic in the region between the triangle’s boundary and the circle. By the Deformation Principle (homotopy invariance), we can continuously deform the triangular path $∂T_1$ into the circular path C without changing the value of the integral: $n(∂T_1,z_0) = n(C, z_0)$. The winding number of a positively oriented circle around its center is known to be 1, so $n(\gamma, z_0) = n(P, z_0) = \sum_{j=1}^k n(∂T_j,z_0) = n(∂T_1,z_0) = n(C, z_0) = 1.$
Case 2. $z_0 \in Ext(\gamma)$
If $z_0$ is in the unbounded exterior region, the function $f(z) = \frac{1}{z-z_0}$ is analytic at all points inside and on the contour γ. The singularity at $z_0$ is outside the domain enclosed by the curve. By Cauchy’s Integral Theorem, the integral of an analytic function over a simple closed contour is zero: $\oint_{\gamma} \frac{1}{z-z_0} = 0$. Therefore, the winding number is: $n(\gamma; z_0) = \frac{1}{2\pi i} \oint_{\gamma} \frac{1}{z-z_0} = \frac{1}{2\pi i} \cdot 0 = 0.$