Let $\gamma=[-1, 1+i]+\beta+[-1+i,1]$, where $\beta(t)=i+e^{it}$ for $0\leq t\leq 3\pi.$ Compute: $\int_{\gamma}(z^2+1)^{-1}dz$ Let $\gamma=[-1, 1+i]+\beta+[-1+i,1]$, where $\beta(t)=i+e^{it}$ for $0\leq t\leq 3\pi.$ Compute: $\int_{\gamma}(z^2+1)^{-1}dz$
I have come to the following but I do not know what else to do:
$\int_{\gamma}\frac{1}{z^2+1}dz=\int_{[-1,1+i]}\frac{1}{2i(z-i)}dz+\int_{\beta}\frac{1}{2i(z-i)}dz+\int_{[-1+i, 1]}\frac{1}{2i(z-i)}dz-(\int_{[-1,1+i]}\frac{1}{2i(z+i)}dz+\int_{\beta}\frac{1}{2i(z+i)}dz+\int_{[-1+i, 1]}\frac{1}{2i(z+i)}dz)$
Could anyone help me, please? Thank you very much.
 A: Let's make this problem easier by deforming your contour $\gamma$ into $\gamma^*$ where $\gamma^*=[-1,0]+\beta^*+[0,1]$ and $\beta^*=i+e^{it}$ for $-\frac{\pi}{2}\leq t \leq \frac{7\pi}{2}$ (draw a picture!).  We can do this because our integrand is analytic everywhere besides $z=\pm i$.  Now we have 
\begin{align}
\int_\gamma\frac{dz}{1+z^2}&=\int_{\gamma^*}\frac{dz}{1+z^2} \\
&=\int_{-1}^1\frac{dz}{1+z^2}+\int_{\beta^*}\frac{dz}{1+z^2}
\end{align}
Our first integral above can be evaluated via fundamental theorem of calculus.  The second integral above can be evaluated via residue theorem (https://en.wikipedia.org/wiki/Residue_theorem).
\begin{align}
\int_\gamma\frac{dz}{1+z^2}&=\int_{-1}^1\frac{dz}{1+z^2}+\int_{\beta^*}\frac{dz}{1+z^2} \\
&=\tan^{-1}(z)\bigg|_{-1}^1+2\cdot2\pi i\cdot\text{Res}\left((1+z^2)^{-1},i\right) \\
&=\tan^{-1}(1)-\tan^{-1}(-1)+4\pi i\cdot\text{Res}\left(\frac{1}{2i(z-i)}-\frac{1}{2i(z+i)},i\right) \\
&=\frac{\pi}{2}-\frac{-\pi}{2}+4\pi i\cdot\frac{1}{2i} \\
&=3\pi
\end{align}
