# Complex Analysis/Contour integrals
## Integrals of complex-valued functions on real intervals

In calculus, we learned how to integrate (say, continuous) functions $f:\mathbb {R} \to \mathbb {R}$ on a finite interval $[a,b]$. What happens now if the function $f$ we wish to integrate has values in the complex numbers (that is, $f:\mathbb {R} \to \mathbb {C}$)? The answer is straightforward. We decompose $f$ by the formula $f(x)=\operatorname {Re} f(x)+i\operatorname {Im} f(x)$ and define the integral as follows:
Definition 4.1:
Let $f:\mathbb {R} \to \mathbb {C}$ continuous and complex-valued (or, alternatively, such that both $\operatorname {Re} f(x)$ and $\operatorname {Im} f(x)$ are integrable). Then we set
    $\int _{a}^{b}f(x)dx:=\int _{a}^{b}\operatorname {Re} f(x)dx+i\int _{a}^{b}\operatorname {Im} f(x)dx$.

## The idea behind contour integrals

In this chapter, given a function $f:O\to \mathbb {C}$, we want to integrate $f$ along a differentiable curve; roughly speaking, we want to determine the measure of the area under the graph which arises when flattening out the curve as indicated in the following animation:
We now want to figure out which formula could make sense for obtaining this measure (note that as in normal integration, we want the area where the function is negative to be subtracted from the value of the integral, instead of being added to it). The idea is to approximate the desired integral. Let a differentiable curve $\gamma :[0,1]\to O$ be given. We choose a certain decomposition
    $[0,1]=[0=t_{0},t_{1}]\cup [t_{1},t_{2}]\cup \cdots \cup [t_{n-1},t_{n}=1]$
where $t_{0}<t_{1}<\cdots <t_{n}$. Then we approximate the desired integral, which we denote by $\int _{\gamma }f(z)dz$, by a finite sum as follows:
    $\int _{\gamma }f(z)dz\approx \sum _{j=0}^{n-1}(\gamma (t_{j})-\gamma (t_{j+1}))f(\gamma (t_{j}))$.
This sum sums small squares which approximate the integral, just like Riemann sums. As the maximum distance between consecutive $t_{j}$ gets smaller, we obtain better and better approximations. On the other hand,
    $\sum _{j=0}^{n-1}(\gamma (t_{j})-\gamma (t_{j+1}))f(\gamma (t_{j}))=\sum _{j=0}^{n-1}f(\gamma (t_{j}))\int _{t_{j}}^{t_{j+1}}\gamma '(t)dt$,
where the latter integral converges to
    $\int _{0}^{1}f(\gamma (t))\gamma '(t)dt$
as $n\to \infty$. This is why we define:
Definition 4.2:
Let a ${\mathcal {C}}^{1}$ (in the real sense) curve $\gamma :[a,b]\to \mathbb {C}$ (which we shall also call contour) be given. Then we define the integral of $f$ along the contour $\gamma$ to be
    $\int _{\gamma }f(z)dz:=\int _{a}^{b}f(\gamma (t))\gamma '(t)dt$.
In fact, even before talking about cycles (chapter 10) and related things we need a more general, but not much more difficult, definition of contour integrals, namely one which also holds for piecewise ${\mathcal {C}}^{1}$ curves.
Definition 4.3:
A function $\gamma :[a,b]\to \mathbb {C}$ is called a piecewise ${\mathcal {C}}^{1}$ contour if and only if there exists a decomposition $[a,b]=[t_{0},t_{1}]\cup [t_{1},t_{2}]\cup \cdots \cup [t_{n-1},t_{n}]$, $a=t_{0}<t_{1}<t_{2}<\cdots <t_{n-1}<t_{n}=b$ such that for all $j\in \{0,\ldots ,n-1\}$ the restriction
    $\gamma \upharpoonright _{[t_{j},t_{j+1}]}$
is ${\mathcal {C}}^{1}$.

## Rules for contour integrals

In this section, we state and prove some formulas which hold for contour integrals and which we shall extensively use throughout the subsequent chapters.
Theorem 4.4:
Assume that $f:O\to \mathbb {C}$ has a primitive, that is a function $F:O\to \mathbb {C}$ such that $F$ is holomorphic and $F'(z)=f(z)$ for all $z\in O$. Then for all piecewise ${\mathcal {C}}^{1}$ contours $\gamma :[a,b]\to O$ we have
    $\int _{\gamma }f(z)dz=F(\gamma (b))-F(\gamma (a))$.
Theorem 4.5:
The contour integral is linear, that is for $f,g:O\to \mathbb {C}$ holomorphic, $\lambda \in \mathbb {C}$ and $\gamma :[a,b]\to O$ piecewise ${\mathcal {C}}^{1}$ we have
    $\int _{\gamma }(f(z)+\lambda g(z))dz=\int _{\gamma }f(z)dz+\lambda \int _{\gamma }g(z)dz$.