Complex curve integral $\frac{1}{1+z^2}$ I want to calculate $\int_\gamma\frac{1}{1+z^2}\,\mathrm dz$ where $\gamma = \delta B(i,1)$, circle with radius $1$ around $i$. So i have $\gamma(t) = i+\exp(it),\,t \in [0,2\pi]$ with
$$\int_\gamma \frac{1}{1+z^2} = \ldots = \left[ \arctan(i+\exp(it))\right]_{t = 0}^{2\pi} \overset{(*)}{=} \arctan(i+1)-\arctan(i+1) = 0.$$
However WolframAlpha returns $$\int_\gamma \frac{1}{1+z^2} = \pi.$$
I think it could be that $\arctan$ isn't continous so i cant conclude $(*)$. Would appreciate if somebody could explain it to me.
 A: In these cases is helpfull the Cauchy Forrmula
$$f(z_0)=\dfrac{1}{2\pi i}\int_\gamma\dfrac{f(z)}{z-z_0}dz.$$
Now it'enough note that $\dfrac{1}{z^2+1}=f(z)\dfrac{1}{z-i}$, where $f(z)=\dfrac{1}{z+i}$. At this point we have $\dfrac{1}{2i}=\dfrac{1}{2\pi i}\int_{B(i,1)}\dfrac{dz}{z^2+1}$, then $$\int_{B(i,1)}\dfrac{dz}{z^2+1}=\pi.$$
A: I would like to add a another alternative approach to solve this integral on top of Vincenzo's answer. It is fairly technical, by no means too easy to grasp and not intuitively as the Cauchy formula but it shows an interesting and very different approach to argument and is just more for the fun of it.
Claim. $$\int_{-\infty}^{\infty}\frac{1}{1+x^2}\,\mathrm dx = \oint_{\partial B_1(\mathrm i)}\frac{1}{1+z^2}\,\mathrm dz = \pi.$$

Proof. For the function $$f(z)=\frac{1}{1+z^2}$$ you can find two singularities $\pm\mathrm i$. You can then rewrite the function as $$f(z)=-\frac{\mathrm i}{2}\underbrace{\frac{1}{z-\mathrm i}}_{(1)}+\frac{\mathrm i}{2}\underbrace{\frac{1}{z+\mathrm i}}_{(2)}.$$ The expression $(1)$ is holomorphic at $z=-\mathrm i$ while $(2)$ is holomorphic at $z=\mathrm i$. Since our most beloved integral in complex analysis yields $$\oint_{\partial B_{\rho}(a)}\frac{1}{z-a}\,\mathrm dz=2\pi\mathrm i$$ it provides us with the residue $$\operatorname{Res}_{z=a}\left(\frac{1}{z-a}\right)=\frac{1}{2\pi\mathrm i}\oint_{\partial B_{\rho}(a)}\frac{1}{z-a}\,\mathrm dz=1.$$
This residue can be used to deduce that
$$
\begin{align*}
\operatorname{Res}_{\mathrm i}(f)&=-\frac{\mathrm i}{2}\cdot\operatorname{Res}_{z=\mathrm i}\left(\frac{1}{z-\mathrm i}\right)=-\frac{\mathrm i}{2}\\
\operatorname{Res}_{-\mathrm i}(f)&=\frac{\mathrm i}{2}\cdot\operatorname{Res}_{z=-\mathrm i}\left(\frac{1}{z+\mathrm i}\right)=\frac{\mathrm i}{2}.
\end{align*}
$$
Now I want to compute $$\int_{-\infty}^{\infty}f(x)\,\mathrm dx.$$ Since $z\cdot f(z)\to 0$ for $|z|\to \infty$ we can take the curve $[-R,R]$ along the real line and $\eta_R(t)=R\mathrm e^{\mathrm i\pi t}$ with $t\in[0,1]$ which is a counter-clockwise arc which encloses all singularities $z_j$ in the positive complex half-plane. Luckily $$\int_{\eta_R}f(z)\,\mathrm dz$$ vanishes for $R\to\infty$ which can be shown using the M-L inequality
$$
\left| \int_{\eta_R}f(z)\,\mathrm dz\right|
\leq \pi R\left(\sup_{z\in\operatorname{im}(\eta_R)}|f(z)|\right)\longrightarrow 0\,(R\to\infty)
$$
Now one can take $$\oint_{[-R,R]+\eta_R}f(z)\,\mathrm dz\overset{(*)}{=}2\pi\mathrm i\sum_{j=1}^n\operatorname{Res}_{z_j}(f).$$ At $(*)$ we can apply the residue theorem. This yields $$\int_{-\infty}^{\infty}f(x)\,\mathrm dx = 2\pi\mathrm i\cdot \operatorname{Res}_{\mathrm i}(f) = \pi.$$
Finally there is a homotopy between your circle $\partial B_1(\mathrm i)$ and my constructed path $[-R,R]+\eta_R$ since there are no other singularities in the upper half-plane thus implying our paths are equivalent and therefore the claim holds true.$$\tag*{$\blacksquare$}$$
