All possible values of a complex integral I'm struggling with the following task:
Find all possible values of the complex integral $\int_0^1 \frac{dz}{z^2 + 1}$ if we are integrating it along all possible curves from $0$ to $1$.
The official answer is $\frac{\pi}{4} + k\pi, k \in \mathbb{Z}$. I understand that if we integrate it along the line from $0$ to $1$, we get the answer $\frac{\pi}{4}$, but I don't understand how do we get all other possible values of the integral, so help would be much appreciated.
 A: To enlighten the solution, let me first state the residue formula:

Proposition. Let $f$ be holomorphic on $U \setminus \{a_1, \ldots, a_n\}$, where $U$ is a simply connected doamin and $a_1, \ldots, a_n$ are distinct. Then for any closed curve $\gamma$ in $U$,
$$ \int_{\gamma} f(z) \, \mathrm{d}z = 2\pi i \sum_{k=1}^{n} \operatorname{Ind}_{\gamma}(z_k) \mathop{\mathrm{Res}}_{z = a_k} f(z), \tag{1} $$
where $\operatorname{Ind}_{\gamma}(z_k)$ is the winding number of $a_k$ with respect to $\gamma$ defined by
$$ \operatorname{Ind}_{\gamma}(z_k) = \frac{1}{2\pi i} \int_{\gamma} \frac{\mathrm{d}z}{z - a_k} \in \mathbb{Z}. $$

Although the proof of the general statement requires some work, this hints how we may proceed in OP's case, assuming we know that winding numbers are always integers.
Indeed, let $\gamma$ be any contour from $0$ to $1$ that does not pass through $\pm i$. Also, let $\tilde{\gamma} = \gamma \cup [1, 0]$ denote the contour obtained by by appending the line segment from $1$ to $0$ to $\gamma$. Then
\begin{align*}
\int_{\gamma} \frac{\mathrm{d}z}{z^2+1}
&= \int_{\tilde{\gamma}}\frac{\mathrm{d}z}{z^2+1} + \int_{[0,1]}\frac{\mathrm{d}z}{z^2+1} \\
&= \frac{1}{2i} \int_{\tilde{\gamma}}\frac{\mathrm{d}z}{z - i} - \frac{1}{2i} \int_{\tilde{\gamma}}\frac{\mathrm{d}z}{z + i} + \frac{\pi}{4} \tag{by partial fractions} \\
&= \pi \operatorname{Ind}_{\tilde{\gamma}}(i) - \pi \operatorname{Ind}_{\tilde{\gamma}}(-i) + \frac{\pi}{4}.
\end{align*}
Since $\operatorname{Ind}_{\tilde{\gamma}}(i)$ and $\operatorname{Ind}_{\tilde{\gamma}}(-i)$ can assume any integer values, it follows that $\int_{\gamma} \frac{\mathrm{d}z}{z^2+1}$ can assume any values of the form $ k\pi + \frac{\pi}{4}$ for any $k \in \mathbb{Z}$.
