I have yet to see any problem, however complicated, which, when looked at in the right way did not become still more complicated, Paul Anderson.

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$, e.g., a straight line between two points $z_0$ and $z_1$, $\gamma(t) = z_0 + t(z_1 - z_0), t \in [0, 1]$; the Unit Circle, $\gamma(t) = e^{it} = \cos t + i \sin t, t \in [0, 2\pi]$.
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$.
Theorem. Cauchy Integral Formula. Let $f$ be holomorphic (analytic) in a simply connected domain $D$, and let $\gamma$ be a simple closed contour in $D$, oriented counterclockwise. For any point $z_0$ inside $\gamma$: $f(z_0) = \frac{1}{2\pi i}\cdot \int_{\gamma} \frac{f(z)}{z-z_0}dz$ (Figure D).

It states that the value of an analytic function at any interior point z₀ is completely determined by the values the function takes on any simple closed curve that encircles the point. If you know the function’s values on the boundary, you know everything about the function’s behavior inside that boundary. This is quite unlike anything you’ve probably encountered with functions of real variables.
A more generalized version is as follows: $\boxed{f^{(n)}(z_0) = \frac{n!}{2\pi i}\cdot \int_{\gamma} \frac{f(z)}{(z-z_0)^{(n+1)}}dz}, \qquad n = 0, 1, 2, \ldots$.
For contours that are not necessarily simple or that wind multiple times around a point, the formula generalizes using the winding number.
The winding number of a closed curve $\gamma$ around a point $a \notin \gamma^*$ is: $n(\gamma, a) = \frac{1}{2\pi i}\oint_\gamma \frac{dz}{z - a}.$
This integer counts the net number of times $\gamma$ winds around $a$ counterclockwise.
For simple closed curves with positive orientation n(γ, a) = 1 if a is inside γ, 0 if outside.
For multiple windings n(γ, a) counts the net winding (e.g., 2 for two counterclockwise loops, -1 for one clockwise loop).
Cauchy Integral Formula (Winding Number Lemma). Let $\gamma$ be a closed rectifiable curve in $\mathbb{C}$, f analytic on an open set containing $\gamma$ and its interior. For any point a not on $\gamma$, the Cauchy Integral Formula states: $\oint_{\gamma} \frac{f(z)}{z-a}dz = 2\pi i \cdot n(\gamma, a) \cdot f(a)$.
The formula reduces to the basic Cauchy Integral Formula when n(γ, a) = 1.
The formula can be used to calculate integrals: $\int_{\gamma} \frac{f(z)}{z-z_0}dz = 2\pi i \cdot f(z_0), \int_{\gamma} \frac{f(z)}{(z-z_0)^{(n+1)}}dz = \frac{2\pi i}{n!} \cdot f^{(n)}(z_0)$
Key Conditions:
Analyticity: $ f(z) $ must be analytic (holomorphic) inside and on $\gamma$.
Contour $ C $: $\gamma$ is a simple closed curve (e.g., a circle, ellipse). A simple closed curve is a curve that both has no self-intersections and is closed, meaning it starts and ends at the same point.
However, the winding number form handles non-simple curves.
Point $z_0$: $z_0$ must lie inside $\gamma$. If $z_0$ is outside $\gamma$, the integrand $f(z)/(z-z_0)$ is analytic inside and on $\gamma$, so by Cauchy’s theorem the integral is zero.
For any f analytic on $|z| \leq 1: \oint_{|z|=1} \frac{f(z)}{z}dz = 2\pi i \cdot 1 \cdot f(0) = 2\pi i f(0)$.
Therefore, $\oint_{\gamma} \frac{f(z)}{z-a}dz = \begin{cases} 2\pi i f(a) & \text{if a in right loop, enclosed positively by } \gamma_{right} \\ -2\pi i f(a) & \text{if a in left loop, enclosed negatively by } \gamma_{left} \\ 0 & \text{if a outside both loops} \end{cases}$
Double Winding Let $\gamma(t) = e^{it}$, $t \in [0, 4\pi]$ be the unit circle |z| = 1 traversed twice counterclockwise, and a = 0, $\gamma(t) = e^{it}, t \in [0, 4\pi]$. Then, $n(\gamma, 0) = \frac{1}{2\pi i}\int_0^{4\pi} \frac{ie^{it}}{e^{it}}dt = \frac{1}{2\pi i} \cdot 4\pi i = 2$, the curve wraps around a = 0 twice in the positive direction. For any $f$ analytic on $|z| \leq 1$: $\oint_{\gamma} \frac{f(z)}{z}dz = 2\pi i \cdot 2 \cdot f(0) = 4\pi i f(0).$
Point Outside Contour If a is outside $\gamma$ (e.g., $\gamma$ is unit circle, |z| = 1, a = 2, a point outside the contour): $n(\gamma, 2) = 0$ since the contour does not enclose the point a = 2, the net number of times it winds around a is zero. Result: For any f(z) analytic on $|z| \leq 2$, the entire integrand $g(z) = \frac{f(z)}{z-2}$ is analytic inside and on the unit circle, then $\oint_{|z|=1} \frac{f(z)}{z-2}dz = 2\pi i \cdot 0 \cdot f(2) = 0$.
The Cauchy Integral Formula is a special case of the Residue Theorem.
Residue Theorem: $\oint_{\gamma} g(z) \, dz = 2\pi i \sum \operatorname{Res}(g, z_k)$
For the integral $\oint_{\gamma} \frac{f(z)}{z-z_0} \, dz$, the integrand $g(z) = \frac{f(z)}{z-z_0}$ has only one sigularity inside $\gamma$, a simple pole at $z_0$. For a single pole, the residue is: $\operatorname{Res}\left( \frac{f(z)}{z-z_0}, z_0 \right) = \lim_{z \to z_0} (z-z_0) \frac{f(z)}{z-z_0} = f(z_0)$
Thus, the integral is $2\pi i \cdot f(z_0)$, matching Cauchy’s formula.
Similarly, for the generalized formula, the integrand $\frac{f(z)}{(z-z_0)^{n+1}}$ has a pole of order $n+1$ at $z_0$.
The residue of a pole of order m is: $\operatorname{Res} (g,z_0)=\frac{1}{(m-1)!}\lim _{z\rightarrow z_0}\frac{d^{m-1}}{dz^{m-1}}\left[ (z-z_0)^mg(z)\right].$
Here m = n + 1, so: $\operatorname{Res} \left( \frac{f(z)}{(z-z_0)^{n+1}},z_0\right) =\frac{1}{n!}f^{(n)}(z_0).$ Thus, $\oint _{\gamma }\frac{f(z)}{(z-z_0)^{n+1}}\, dz=2\pi i\cdot \frac{f^{(n)}(z_0)}{n!},$ which is the generalized Cauchy Integral Formula.
The integral over the large contour $\gamma$ equals the integral over the small circle $C_r$ enclosing the same singularity, because the integrand is analytic in the region between them.
Unit Circle, Standard Winding. Let $\gamma$ be the unit circle $|z| = 1$, and let $f(z) = 1$ (the constant function, which is clearly analytic everywhere). Let $z_0 = 0$, the center of the circle. $\oint_\gamma \frac{1}{z - 0} \, dz =[\text{Rearranging the Cauchy Integral Formula to solve for the integral:}] \oint_\gamma \frac{1}{z} dz = 2\pi i \cdot f(0) = 2\pi i \cdot 1 = 2\pi i$
$n(\gamma, 0) = \frac{1}{2\pi i}\oint_{|z|=1}\frac{dz}{z} = \frac{2\pi i}{2\pi i} = 1.$
The Generalization. For any function $f$ analytic on $|z| \leq 1$. By the Cauchy Integral Formula with $z_0=0$: $\oint_{|z|=1}\frac{f(z)}{z}\,dz = 2\pi i\,f(0).$
This is remarkable! Even though f(z) might be complicated, this integral depends only on f(0) —the value at the center.
$\oint_{|z|=1}\frac{f(z)}{z}\,dz = 2\pi i \cdot n(\gamma, 0) \cdot f(0) = 2\pi i \cdot 1 \cdot f(0) = 2\pi i\,f(0).$
Double Winding. Let $\gamma(t) = e^{it}$, $t \in [0, 4\pi]$ — the unit circle traversed twice counterclockwise.
Then, $n(\gamma, 0) = \frac{1}{2\pi i}\int_{\gamma} \frac{1}{z}dz = \frac{1}{2\pi i}\int_0^{4\pi}\frac{ie^{it}}{e^{it}}\,dt = \frac{4\pi i}{2\pi i} = 2.$
The curve winds around the origin twice. The winding number counts how many times we loop around.
For any $f$ analytic on $|z| \leq 1$: $\oint_\gamma \frac{f(z)}{z}\,dz = 2\pi i \cdot n(\gamma, 0) \cdot f(0) = 2\pi i \cdot 2 \cdot f(0) = 4\pi i\,f(0).$
You can think of this as doing the integral twice, or equivalently, the “strength” of the singularity is amplified by how many times we circle it.
Let $f(z) = z^2$ (it is analytic everywhere), $\gamma$ be the circle $ |z| = 2 $, and $z_0 = 1$ (it lies inside the circle ∣z∣ = 2), $\oint_\gamma \frac{z^2}{z - 1} dz =[\text{ Cauchy Integral Formula }] 2\pi i \cdot f(1) = 2\pi i (1^2) = 2\pi i$
Here, even though $f(z)/(z - 1)$ has a singularity at $z = 1$, the contour $\gamma$ encloses the point $z_0 = 1$, so the formula applies.
Cauchy’s formula tells us that only the value of f at $z_0$ matters. The singularity of $f(z)/(z - 1)$ is captured by the contour, and its contribution is exactly $2πi\cdot df(z_0)$.
Let f(z) = z + 1, f is entire, i.e., analytic everywhere because polynomials are entire functions.
$\oint_{\gamma(2; 3)} \frac{z + 1}{z - 2} dz = \oint_{\gamma(2; 3)} \frac{f(z)}{z - 2} dz =[\text{ Cauchy Integral Formula }, 2 \in \mathcal{I}(\gamma(2; 3))] 2\pi i \cdot f(2) = 2\pi i \cdot 3 = 6\pi i$
$\oint_\gamma \frac{e^{2z}}{z - 1} dz = 2\pi i \cdot f(1) = 2\pi i \cdot e^{2\cdot 1} = 2\pi ie^2$
The integrand has a singularity at $z_0 = 2$ (it lies outside the unit circle), but is analytic on and inside the contour $\gamma$, so the integral vanishes (Cauchy’s Theorem).
Let $f(z) = e^z$, $z_0 = 0$, and $\gamma$ be the unit circle |z| = 1. $\oint_C \frac{e^z}{z^2} dz =[\text{Generalized formula, n = 1}] \frac{2\pi i}{1!} f'(0) = 2\pi i \cdot e^0 = 2\pi i$
Compute $\oint_\gamma \frac{e^{z^2}}{z-2}dz$ where $\gamma$ is the curve shown in Figure A. Since f(z) = $e^{z^2}$ is entire, $\gamma$ is a simple closed curve (counterclockwise), and z = 2 lies inside $\gamma, \oint_\gamma \frac{e^{z^2}}{z-2}dz = 2\pi i f(2) = 2\pi i e^4$.

Compute $\oint_\gamma \frac{cos(z)}{z-1}dz$ where $\gamma$ is the curve shown in Figure F. f(z) = $cos(z)$ is entire, $\gamma$ is a positively oriented simple closed curve, and z = 1 lies inside $\gamma$, $\oint_\gamma \frac{cos(z)}{z-1}dz = 2\pi i \cdot f(1) = 2\pi i \cdot cos(1) \approx 1.08\pi i$.
Extracting a Constant Factor. Compute $\oint_\gamma \frac{cos(z)}{3z-1}dz$ where $\gamma$ is the curve shown in Figure F. f(z) = $cos(z)$ is entire, $\gamma$ is a positively oriented simple closed curve, and z = 1/3 lies inside $\gamma$, $\oint_\gamma \frac{cos(z)}{3z-1}dz = \oint_\gamma \frac{cos(z)}{3(z-\frac{1}{3})}dz = \frac{1}{3}\oint_\gamma \frac{cos(z)}{z-\frac{1}{3}}dz = \frac{2\pi i}{3} \cdot f(\frac{1}{3}) = \frac{2\pi i}{3} \cdot cos(\frac{1}{3}) \approx 0.63\pi i$.
Only One Pole Inside. Compute $\oint_\gamma \frac{cos(z)}{(z-1)(z-2)}dz$ where $\gamma$ is the curve shown in Figure F. f(z) = $\frac{cos(z)}{z-2}$ is analytic inside $\gamma$, $\gamma$ is a positively oriented simple closed curve, and z = 1 lies inside $\gamma$ (it encloses z = 1, but not z = 2), $\oint_\gamma \frac{cos(z)}{(z-1)(z-2)}dz = \oint_\gamma \frac{\frac{cos(z)}{z-2}}{(z-1)}dz = 2\pi i \cdot \frac{cos(1)}{(1-2)} = 2\pi i \cdot -cos(1) \approx -1.08\pi i$.
Compute $\oint_\gamma \frac{2z^2-1}{(z-1)^2}dz$ where $\gamma$ is the curve shown in Figure F. f(z) = $2z^2-1$ is analytic on and inside $\gamma$, $\gamma$ is a positively oriented simple closed curve, and z = 1 lies inside $\gamma$, $\oint_\gamma \frac{2z^2-1}{(z-1)^2}dz =[\text{Generalized formula, n = 1}] \frac{2\pi i}{1!} \cdot f'(1) = 2\pi i \cdot 4 \cdot 1 = 8\pi i$.
Compute $\oint_\gamma \frac{e^{z^2}}{z-2}dz$ where $\gamma$ is the curve shown in Figure B. f(z) = $e^{z^2}$ is entire, $\gamma$ goes around 2 twice in the clockwise direction, so we break $\gamma$ into $\gamma_1$ and $\gamma_2$ as shown in Figure C.
$\oint_\gamma \frac{e^{z^2}}{z-2}dz = \oint_{\gamma_1} \frac{e^{z^2}}{z-2}dz + \oint_{\gamma_2} \frac{e^{z^2}}{z-2}dz = -2\pi i f(2) -2\pi i f(2) = -4\pi i e^4$.
The negative signs are because they go clockwise around $z_0$ = 2.
The singularities occur where the denominator is zero: $z^2 + z + 1 = 0$. Using the quadratic formula: $z = \frac{-1 \plusmn \sqrt{(-1)^2 - 4}}{2} = \frac{-1 \plusmn \sqrt{3}i}{2}$. Let the singularities be $\alpha$ and $\beta, \alpha = -\frac{1}{2} + i\frac{\sqrt{3}}{2} = e^{i 2\pi/3}, \beta = -\frac{1}{2} - i\frac{\sqrt{3}}{2} = e^{-i 2\pi/3}$.
The magnitude of both singularities is: $|\alpha| = |\beta| = \sqrt{\left(-\frac{1}{2}\right)^2 + \left(\frac{\sqrt{3}}{2}\right)^2} = \sqrt{\frac{1}{4} + \frac{3}{4}} = 1$. Since the contour has radius R = 2, and 1 < 2, both singularities $\alpha$ and $\beta$ lie inside the contour $\gamma(0; 2)$.
We decompose the integrand using partial fractions. $\frac{1}{z^2+z+1} = \frac{A}{z-\alpha} + \frac{B}{z-\beta}$. We find A and B: $1 = A(z-\beta) + B(z-\alpha)$.
Set $z = \alpha$: $1 = A(\alpha - \beta) \implies A = \frac{1}{\alpha - \beta}$
Set $z = \beta$: $1 = B(\beta - \alpha) \implies B = \frac{1}{\beta - \alpha} = -\frac{1}{\alpha - \beta}$
Substituting $A$ and $B$ back and using the linearity of contour integrals, $\oint_{\gamma(0; 2)} \frac{1}{z^2+z+1}dz = \oint_{\gamma(0; 2)} \frac{1}{\alpha - \beta [\frac{1}{z-\alpha} - \frac{1}{z-\beta}]dz} = \frac{1}{\alpha - \beta} [\oint_{\gamma(0; 2)}\frac{1}{z-\alpha} - \oint_{\gamma(0; 2)}\frac{1}{z-\beta}]$
Now, we apply the Cauchy Integral Formula (or Winding Number Lemma) to each integral. The general form of the CIF is $\oint_{\gamma} \frac{f(z)}{z-a}dz = 2\pi i \cdot n(\gamma, a) \cdot f(a)$.
Here, in both integrals, the numerator is simply $f(z) = 1$. The contour $\gamma(0; 2)$ is a simple closed curve, positively oriented, and encloses both $\alpha$ and $\beta$. Thus, the winding numbers are $n(\gamma, \alpha) = 1$ and $n(\gamma, \beta) = 1$ respectively.
= $\frac{1}{\alpha - \beta}[2\pi i\cdot n(\gamma, \alpha)\cdot f(\alpha) - 2\pi i\cdot n(\gamma, \beta)\cdot f(\beta)] = \frac{1}{\alpha - \beta}[2\pi i\cdot 1 \cdot 1 - 2\pi i\cdot 1 \cdot 1] = 0$.