Cauchy principal value: methods I don't understand yet the logic in the Cauchy Principale Value (P.V.) calculations. Let the resideu theorem:
$$\color{red}{\oint_Cf(z) \ dz = 2\pi i \sum_{k=1}^n \underset{z=z_k}{Res}\{f(z)\}}$$
(we supposed that $C$ was a "nice" closed curb and $f(z)$ analytical $\forall z \in \mathrm{int} \ C$ except in $z_k$ ($1 \le k \le n$))
I've got 2 poorly justified examples in my exercice book (forgive me for non-mathjaxing all of that follows) :

Apparently, the corrector found a nice closed curb, but don't want to share how he did it. Usually, when $f(z)$ is pair, we can define such a $C$ curb:

but it doesn't explain why the 2 factor is missing in the answer. Why $\pi i$ instead of $2\pi i$ ?

Second example:
$$P.V. \int_{-\infty}^{+\infty} \frac{\exp(-4ix)}{(x+i)^2} \ dx$$
Here, we have a reversed cup (why reversed ?) $\gamma (R)$ with the segment $C(R)$:

Again, I don't understand what has been done. Is there a general methode I can understand to solve those 2 exercices ?

EDIT: corrected one error pointed out in the comments ($(x+i)^2$ instead of $(x+1)^2$)

$\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{\on}[1]{\operatorname{#1}}
 \newcommand{\pars}[1]{\left(\,{#1}\,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,}
 \newcommand{\sr}[2]{\,\,\,\stackrel{{#1}}{{#2}}\,\,\,}
 \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}}
 \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$

Contour: Semi-circle in the upper complex half plane with an indent around $\ds{x = -1}$.
Integration along the upper arc vanishes out as $\ds{R \to \infty}$.
\begin{align}
& \color{#44f}{\lim_{\epsilon \to 0^{+}}\ \left\{%
\int_{-\infty}^{-1 - \epsilon}{\dd x \over \pars{x + 1}\pars{x^{2} + 2}} +
\int_{\pi}^{0}{\epsilon\expo{\ic\theta}\ic\,\dd\theta \over
\pars{\epsilon\expo{\ic\theta}}\bracks{\pars{-1 + \epsilon\expo{\ic\theta}}^{2} + 2}}\right.}
\\ & \color{#44f}{\left.\phantom{\lim_{\epsilon \to 0^{+}}\,\,\,}\int_{-1 + \epsilon}^{\infty}\,\,
{\dd x \over \pars{x + 1}\pars{x^{2} + 2}}\right\}} =
2\pi\ic\on{Res}\bracks{{1 \over \pars{x + 1}\pars{x^{2} + 2}}, x = \root{2}\ic}
\\[5mm] & \implies
\mbox{P.V.}\int_{-\infty}^{\infty}{\dd x \over \pars{x + 1}\pars{x^{2} + 2}} - {\pi\ic \over 3} = 2\pi\ic\bracks{-\,{1 \over 2\root{2}\pars{\root{2} - \ic}}}
\\ - & -----------------------------------
\\[5mm] & \implies
\mbox{P.V.}\int_{-\infty}^{\infty}{\dd x \over \pars{x + 1}\pars{x^{2} + 2}}  = 2\pi\ic\bracks{-\,{1 \over 2\root{2}\pars{\root{2} - \ic}}} + {\pi \ic \over 3}
\\[5mm] = & \ \bbx{\color{#44f}{{\root{2} \over 6}\,\pi}} \approx 0.7405
\\ &
\end{align}
