Contour integral of $\frac{|x|^{\frac{1}{2}}}{(x-4i)(x+2i)}$ I am trying to solve the following integral:
$$
\int_{-\infty}^{\infty}\frac{|x|^{\frac{1}{2}}}{(x-4i)(x+2i)}\,\mathrm dx.
$$
There are poles at $4i$, $-2i$, and a semi-circle in upper half plane contour of radius $R$ will enclose $4i$. However, the function is non-analytic in $x=0$, so I assumed I needed to evade this point with my contour, by using a small semi-circle of radius r around $x=0$ in the upper half plane.

Residue theorem then gives us:
$$
I+I_r+I_R = 2\pi i \operatorname{Res}\left(4i,\frac{|x|^{\frac{1}{2}}}{(x-4i)(x+2i)}\right).
$$
When taking the limit $R\rightarrow \infty$, $I_R \rightarrow 0$, and $I$ becomes the integral of interest. I am unsure if $I_r\rightarrow 0$  when $r\rightarrow 0$, but I assumed this was the case. Calculating the residue gave me the result $-\frac{i}{3}$, giving me the final result:
$$
I = \int_{-\infty}^{\infty}\frac{|x|^{\frac{1}{2}}}{(x-4i)(x+2i)} dx = \frac{2\pi}{3}.
$$
According to online calculators, this result is wrong, and would like any suggestions as to how this integral can be solved. Thanks in advance!
 A: Note that in order to apply the residue theorem, it is not enough that the function is analytic on the original contour, it has to be analytic on the full contour and its interior, except possibly at a finite number of points.
If we restrict to $x > 0$ we have an analytic function, which can be extended to a meromorphic function
$$f_+(z) = \frac{z^{1/2}}{(z - 4i)(z + 2i)}$$
on the whole plane, but it doesn't coincide with the integrand on the negative real axis. There the integrand can also be extended to a meromorphic function, namely
$$f_-(z) = \frac{(-z)^{1/2}}{(z - 4i)(z + 2i)}.$$
The integral we are interested in, is the sum of the integral of $f_+$ over the positive real axis, and $f_-$ over the negative real axis. We will compute these in two steps.
We turn the positive real axis and the negative real axis into two different closed contours as in these images:

The red line indicates a branch cut, and the branch of the functions has to be fixed in such a way that it coincides with the integrand on the upper edge of the branch cut.
It is not hard to see that in both cases, the integral over the lower edge is equal to that over the upper edge: the square root picks up a minus sign, but the integral is taken in the opposite direction. It is not hard to see either that the integrals over both the small and the big circle segments vanish in the limit, and it follows that the integral over each of the contours is exactly twice the value of the integral we're interested in.
We compute these integrals using the residue theorem: the main thing we have to be careful with is the exact argument of the function values. For $f_+$ we see that the argument of $z$ at the positive imaginary axis is $\pi/2$, and for the negative imaginary axis it is $3\pi/2$, while for $f_-$ the argument of $-z$ (not $z$) at the positive real axis is $-\pi/2$ and at the negative real axis it is $-3\pi/2$.
Now we can compute the residues at the simple poles $4i$ and $-2i$, and we find
$$\operatorname{Res}(f_+, 4i) = \frac{(4i)^{1/2}}{6i} = \frac{2e^{\pi i/4}}{6i}$$
$$\operatorname{Res}(f_-, 4i) = \frac{(-4i)^{1/2}}{6i} = \frac{2e^{-\pi i/4}}{6i}$$
$$\operatorname{Res}(f_+, -2i) = \frac{(-2i)^{1/2}}{-6i} = \frac{\sqrt2 e^{3\pi i/4}}{-6i}$$
$$\operatorname{Res}(f_-, -2i) = \frac{(2i)^{1/2}}{-6i} = \frac{\sqrt2 e^{-3\pi i/4}}{-6i}$$
$2\pi i$ times their sum is the sum of the contour integrals, so half that quantity is your integral:
$$\int_{-\infty}^\infty\frac{|x|^{1/2}}{(x - 4i)(x + 2i)} = \pi\left(\frac23\cos\frac\pi4 - \frac{\sqrt2}3\cos\frac{3\pi}4\right) = \pi\frac{\sqrt2 + 1}3.$$
