Do, or do not. There is no try, Yoda.

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:
Cauchy’s theorem (Classical “Green’s theorem” version). Let $\Omega \subset \mathbb{C}$ be an open domain. Suppose f = u + iv is analytic in $\Omega$ and its partial derivatives ( $u_x,u_y,v_x,v_y$) are continuous in $\Omega$. If $\gamma$ is a positively oriented, piecewise-smooth $C^1$, simple closed contour with $\gamma^* \cup \operatorname{Int}(\gamma) \subset \Omega$ (its path and interior both lie inside Ω), then $\oint_{\gamma} f(z)dz = 0.$
Cauchy’s Theorem (Cauchy–Goursat). This is the more powerful version, as it removes the need for continuous partial derivatives. If f is analytic in an open set containing a simple closed contour γ and its interior $\gamma^*\cup\operatorname{Int}(\gamma)$, then $\oint_{\gamma} f(z)dz = 0$.
Cauchy’s Theorem for simply connected domains. If a function f is analytic (a function that is complex-differentiable at every point within a domain, i.e., well-behaved and smooth, with no sharp corners, breaks, or singularities like division by zero) throughout a simply simple connected domain D then $\oint_C f(z)dz = 0$ for every closed contour C lying in D.
General Cauchy Theorem for Multiply Connected Domains. Let $R$ be the multiply connected region (with n holes) inside $C$ but outside of every $C_k$ (each $C_k$ surrounds only one hole in the domain), $R = Int(C) \setminus \bigcup_{k=1}^n \overline{Int(C_k)}$, and let $f(z)$ be analytic on $R$. Now, let $\Gamma$ be any general closed contour (not necessarily simple) that lies entirely in R. This $\Gamma$ can wind around the “holes” (the regions inside each $C_k$) in any way it likes (this is the winding number or index of $\Gamma$ around each hole), the integral over $\Gamma$ is: $\oint_{\Gamma} f(z)dz = \sum_{k=1}^n m_k \oint_{C_k} f(z)dz$.
The Anti-Derivative Theorem. Let f be a continuous function on a region G (a region is an open, connected set). Then, the following statements are equivalent:
Proof.
(1) ⇒ (2)
Let $\gamma$ be any closed contour in G. Let’s parameterize it by z(t) for t in an interval $[\alpha, \beta]$. Since the loop is closed, it starts and ends at the same point, let’s call it a, $z(\alpha) = z(\beta) = a$.
Now, let’s write out the integral using the definition of the complex line integral:
$$ \begin{aligned} \oint_\gamma f(z)dz &=\int_\alpha^\beta f(z(t)) \cdot z'(t) dt \\[2pt] &=[\text{Since we assumed F'(z) = f(z)}] \int_\alpha^\beta F'(z(t)) \cdot z'(t) dt \\[2pt] & [\text{By the chain rule, }] \frac{d}{dt} \left( F(z(t)) \right) = F'(z(t)) \cdot z'(t) \\[2pt] &=\int_\alpha^\beta \frac{d}{dt} \left( F(z(t)) \right) dt \\[2pt] &= [\text{By the Fundamental Theorem of Calculus, }] \left[ F(z(t)) \right]_\alpha^\beta = F(z(\beta)) - F(z(\alpha)) \\[2pt] &= [z(\alpha) = z(\beta) = a] F(a) - F(a) = 0. \end{aligned} $$The proof for $(1) \implies (3)$ is almost identical. The integral from $a$ to $b$ would be $F(z(\beta)) - F(z(\alpha)) = F(b) - F(a)$, which depends only on the endpoints, not on the path taken between them.
(2) ⇒ (3). Let $\gamma_1 \text{ and } \gamma_2$ be two distinct contours in G that both start at a and end at b.
Consider the new contour $\Gamma = \gamma_1 - \gamma_2$ where $-\gamma_2$ is the path $\gamma_2$ but traversed in reversed (from b back to a). This path starts at a, goes to b (via $\gamma_1$), and then returns to a (via $-\gamma_2$). Therefore, it is a closed contour.
By our assumption 2, $\oint_{\gamma_1 - \gamma_2} f(z)dz = 0$. Using the linearity of integrals, we can split the integral over $\Gamma, \int_{\gamma_1} f(z)dz + \int_{-\gamma_2} f(z)dz = 0.$
A key property of contour integrals is that reversing the path negates the value, $\oint_{\gamma_1}f(z)dz - \oint_{\gamma_2}f(z)dz = 0 \leadsto \oint_{\gamma_1}f(z)dz = \oint_{\gamma_2}f(z)dz$.
This shows that the integral’s value only depends on the endpoints (a and b), not the path taken. This is the definition of path independence.
3 ⇒ 1
Suppose the integral $\oint_{\gamma}f(z)dz$ depends only on the initial and final points of a contour γ lying in G. Since $G$ is a region (connected), we can fix a starting point $z_0$ anywhere in G. Let’s define a function F(z) for any other point z in G as follows: $F(z) = \oint_{\gamma}f(z)dz$ where γ is any contour lying in G from $z_0$ to z.
F is well-defined (meaning it gives a single, unambiguous value) because we are assuming path independence (3). It doesn’t matter which path we take from $z_0$ to z, the integral’s value will be the same, $F(z) = \oint_{\gamma}f(z)dz = \int_{z_0}^z f(z)dz$.
We aim to prove that F’(z) = f(z). Let z ∈ G and consider the difference quotient for a small displacement h:
$$|\frac{F(z+h) - F(z)}{h} - f(z)| = |\frac{\int_{z_0}^{z+h} f(ξ)dξ - \int_{z_0}^z f(ξ)dξ}{h} - f(z)|$$Because of path independence (F is well defined), we can choose our integration paths to be convenient. Let’s consider a path from $z_0$ to z + h to be a path from $z_0$ to z, followed by a straight line segment from z to z + h.
This is allowed because G is an open set, so for a small enough h, the straight line segment from z to z + h will be entirely contained within G. Formally, there exists a radius $\delta_0 \gt 0$ such that if $∣h∣ \lt \delta_0$, the entire straight line segment [z, z + h] lies entirely within G.
Now we can split the first integral: $\int_{z_0}^{z+h} f(ξ)dξ - \int_{z_0}^z f(ξ)dξ = (\int_{z_0}^{z} f(ξ)dξ + \int_{z}^{z+h} f(ξ)dξ) - \int_{z_0}^z f(ξ)dξ = \int_{z}^{z+h} f(ξ)dξ$ (the integral from $z_0$ to z, $\int_{z_0}^{z} f(ξ)dξ$ cancel out perfectly) where the integral is over the straight line from z to z + h.
Hence, $|\frac{\int_{z_0}^{z+h} f(ξ)dξ - \int_{z_0}^z f(ξ)dξ}{h} - f(z)| = |\frac{\int_{z}^{z+h} f(ξ)dξ}{h} - f(z)|$.
Since G is open and z ∈ G, there is a $\delta_0 \gt 0$ such that $B(z; \delta_0) \subseteq G$. When $|h| \lt \frac{\delta_0}{2}$, the straight line joining z and z + h is contained in G. Therefore, we choose the straight line (contour) from z to z + h for the above integral when $|h| \lt \frac{\delta_0}{2}$.
Then, $\frac{\int_{z}^{z+h} f(ξ)dξ}{h} - f(z) = \frac{\int_{[z, z+h]} (f(ξ) - f(z))dξ}{h}$ where $\int_{[z, z+h]}$ indicates the integral over the straight line (contour) from z to z + h, and we can write the constant f(z) as an integral over the straight line $[z, z+h]$. The path has length $L = |(z+h) - z| = |h|$, integrating a constant f(z) over it gives $f(z) \cdot h$.
We can parameterize the path as $\gamma(t) = z + th$ for $t \in [0, 1], \gamma'(t) = h$, Then, $\int_{[z, z+h]} f(z)dξ = \int_0^1 f(z) \cdot \gamma'(t) dt = \int_0^1 f(z) \cdot h dt = f(z) \cdot h \cdot t\bigg|_{0}^{1} = f(z)\cdot h$.
Therefore, we can write $f(z) = \frac{1}{h} \int_z^{z+h} f(z)d\xi$ and $\frac{\int_{z}^{z+h} f(ξ)dξ}{h} - f(z) = \frac{\int_{[z, z+h]} (f(ξ) - f(z))dξ}{h}$.
By the standard Estimation Theorem (ML-inequality) for complex integrals: $|\frac{\int_{[z, z+h]} (f(ξ) - f(z))dξ}{h}| \le \frac{1}{|h|} \int_{[z, z+h]} |f(ξ) - f(z)| dξ$
Analicity implies continuity and by continuity of f, given $\epsilon \gt 0$, there is a $\delta \gt 0$ such that whenever $|ξ -z| \lt \delta, |f(ξ) - f(z)| \lt \epsilon$ (as $\xi$ gets closer to $z, f(\xi)$ gets closer to $f(z)$).
So given $\epsilon \gt 0$, choose $\delta_1 = min(\delta, \delta_0)$ so that whenever $|ξ -z| \lt \delta_1, |f(ξ) - f(z)| \lt \epsilon \text{ and } \frac{1}{|h|} \int_{[z, z+h]} |f(ξ) - f(z)| dξ \lt \epsilon \frac{1}{|h|} \cdot \int_{[z, z+h]} dξ = \epsilon$.
Therefore, given $\epsilon \gt 0$, we have found a $\delta_1$ so that whenever $|ξ -z| \lt \delta_1, |\frac{F(z+h) - F(z)}{h} - f(z)| \lt \epsilon$. So F is differentiable at every point z ∈ G and F’(z) = f(z).
The Antiderivative Theorem and Cauchy’s Theorem are complementary results that interact as follows.
Cauchy’s Theorem $\Rightarrow$ Antiderivative (in simply connected domains). If $f$ is analytic on a simply connected domain $D$, Cauchy’s Theorem guarantees condition (2): $\oint_\gamma f = 0$ for all closed contours in $D$. By the Antiderivative Theorem, $(2) \Rightarrow (1)$: $f$ has an antiderivative on $D$.
Corollary. Every analytic function on a simply connected domain has a global antiderivative on that domain.
Let $f(z) = 3z^2 + 2z$ and let $\gamma$ be any contour from $z = 1$ to $z = i$ in $\mathbb{C}$.
The function $f$ is entire, and an antiderivative is $F(z) = z^3 + z^2$ (since $F'(z) = 3z^2 + 2z = f(z)$). By condition $(1) \Rightarrow (3)$, the integral is path-independent and equals:
$$\int_\gamma (3z^2 + 2z)\,dz = F(i) - F(1) = \bigl(i^3 + i^2\bigr) - \bigl(1^3 + 1^2\bigr) = (-i - 1) - 2 = -3 - i.$$This is the same regardless of whether $\gamma$ is a straight line, a semicircle, or any other path from $1$ to $i$.
Let $f(z) = e^z$ and let $\gamma$ be any closed contour in $\mathbb{C}$. Since $f$ has the antiderivative $F(z) = e^z$ (entire), condition $(1) \Rightarrow (2)$ gives:
$$\oint_\gamma e^z\,dz = 0.$$No more computation is needed — the existence of an antiderivative settles the matter immediately.
Let $f(z) = \frac{1}{z}$ on $G = \mathbb{C} \setminus \{0\}$. Consider the unit circle $\gamma: z(t) = e^{it}$, $t \in [0, 2\pi]$:
$$\oint_\gamma \frac{dz}{z} = 2\pi i \neq 0.$$Since condition (2) fails, the Antiderivative Theorem tells us that $f(z) = 1/z$ has no antiderivative on $\mathbb{C} \setminus \{0\}$. Any attempt to define $\log z$ on this domain inevitably becomes multi-valued.
However, the reader should observe that in the slit plane $G' = \mathbb{C} \setminus (-\infty, 0]$, no closed contour can wind around the origin (the slit blocks it), so $\oint_\gamma \frac{dz}{z} = 0$ for every closed contour $\gamma$ in $G'$. By $(2) \Rightarrow (1)$, an antiderivative exists: it is the principal logarithm $\operatorname{Log} z$.
Let $f(z) = \cos z$, which has the antiderivative $F(z) = \sin z$.
For any contour $\gamma$ from $0$ to $\pi + i$: $\int_\gamma \cos z\,dz = \sin(\pi + i) - \sin(0) = \sin(\pi + i).$
Using the identity $\sin(\pi + i) = -\sin(i) =[\text{Using exponentials}] -\frac{e^{i \cdot i} - e^{-i\cdot i}}{2i} = -\frac{e^{-1} - e}{2i} = \frac{e - e^{-1}}{2i} = -i\sinh(1)$:
Therefore, $\int_\gamma \cos z\,dz = -i\sinh(1)$ regardless of the path.
Let $f(z) = \overline{z}$ (the complex conjugate). This function is not analytic (it fails the Cauchy–Riemann equations). Consider two paths from $0$ to $1 + i$:
The two integrals are different ($1 \neq 1 + i$), confirming path dependence. By the Antiderivative Theorem (contrapositively), $\overline{z}$ has no antiderivative on $\mathbb{C}$. This is consistent: $\overline{z}$ is not analytic, so there is no reason to expect an analytic antiderivative.
The Antiderivative Theorem applies only to continuous functions that might or might not have antiderivatives. Non-analytic functions like $\overline{z}$ can never satisfy conditions (1)–(3), because an analytic antiderivative $F$ would force $f = F'$ to be analytic as well.
In other words, the Antiderivative Theorem lives in the analytic world.
Let $f(z) = \frac{1}{1+z^2}$ on the simply connected domain $G = \{z : \operatorname{Re}(z) > 0\}$ (the right half-plane). Since $f$ is analytic on $G$ (the poles at $z = \pm i$ are not in $G$) and $G$ is simply connected, Cauchy’s Theorem gives condition (2). By $(2) \Rightarrow (1)$, an antiderivative exists.
Following the constructive proof, fix $z_0 = 1$ so we can define the function $F(z) = \int_1^z \frac{d\zeta}{1+\zeta^2}$, the integral is path-independent, so F is well defined and analytic on G.
On the real axis, for x > 0, $F(x)=\int _1^x\frac{dt}{1+t^2}=\arctan x-\arctan 1=\arctan x-\frac{\pi }{4}.$ So on $(0, \infty)$, F coincides with a real branch of $\arctan x$ shifted by a constant.