Alternative method for contour integration (along a non-closed curve) I'm given the function $\frac{1}{z^2-4}$ and asked to evaluate it along the  following contour:

To do so, I did a partial fractions decomposition:
$$\frac{1}{z^2-4}=\frac{1}{4}\left(\frac{1}{z-2}-\frac{1}{z+2} \right)$$
and added the oriented line segment starting at $-2i$ and ending at $2i$. From here, I calculated this integral by taking the antiderivative, since the curve is in a domain:
$$\log(2i-2)-\log(2i+2)-\log(-2i-2)+\log(2-2i)$$
which gave a total of $\pi i$, so dividing by $4$ gives $i \pi/4$.
Applying the residue theorem, it looks like the total integral should be $-i \pi$, since we go around one pole counterclockwise, and the other clockwise, so we add them, and subtracting the difference gives $-i\pi \pi i -i \pi/4=-3 i \pi/4$.
However, I don't like this for two reasons:


*

*It took a long time, and due to the number of steps, I think I'm prone to mistakes.

*It doesn't help with slightly different functions such as $\frac{1}{z^2+1}$ which I also asked to solve
Is there a faster, and more methodological way to approach these types of problems?
 A: There's a problem with your approach. Every non-zero complex number has infinitely many logarithms.
Consider the first half of the path (from $2i$ to $0$), Turn it into a loop going in straight line from $0$ to $2i$. You can compute the integral along this loop using Cauchy's integral theorem. And the integral along the line segment that you've added is easily computed directly from the definition. So, this gives you the integral along the first half of the path.
Now, do the same thing with second half.
A: $\newcommand{\bbx}[1]{\,\bbox[15px,border:1px groove navy]{\displaystyle{#1}}\,}
 \newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack}
 \newcommand{\dd}{\mathrm{d}}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,}
 \newcommand{\ic}{\mathrm{i}}
 \newcommand{\mc}[1]{\mathcal{#1}}
 \newcommand{\mrm}[1]{\mathrm{#1}}
 \newcommand{\pars}[1]{\left(\,{#1}\,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,}
 \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}}
 \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$
\begin{align}
\mbox{Above}:\,\,\,\,\, & \phantom{-\,\,\,\,}2\pi\ic\,\mrm{Res}\pars{{1 \over z^{2} - 4},z = - 2} - \int_{0}^{2}{\ic\,\dd y \over -y^{2} - 4}
\\[5mm]
\mbox{Bellow}:\,\,\,\,\, & -2\pi\ic\,\mrm{Res}\pars{{1 \over z^{2} - 4},z = \phantom{-}2} - \int_{-2}^{0}{\ic\,\dd y \over -y^{2} - 4}
\\[5mm]
\mbox{Result}:\,\,\,\,\, & 2\pi\ic\,{1 \over 2\pars{-2}} - 2\pi\ic\,{1 \over 2\pars{2}}  + 2\ic\int_{0}^{2}{\dd y \over y^{2} + 4}= \bbx{-\,{3\pi \over 4}\,\ic}
\end{align}
