# Compute integral using residue theorem

I am trying to follow an example, and I have a few questions. I hope it's alright that I make one post regarding all of my questions. In the example, we compute the integral

$$\int_{-\infty}^{\infty} \frac{x+2}{x^3+x} dx,$$

using the residue theorem.

First we note that the function $f(z) = \frac{z+2}{z^3+z}$ has one simple pole at $z = 0$ and one at $z=i$. Then we integrate around a path (denoted $\gamma_{R,\epsilon}$ which consists of the interval $[-R, -\epsilon]$, the semicircle $S_{\epsilon}$ in the upper half-plane with radius $\epsilon$ around $0$ in the negative direction, the interval $[\epsilon, R]$ and the semicircle $S_R$ in the upper half-plane with radius $R$ in the positive direction.

My first question is: Why this particular path? What should I keep in mind when choosing the path along which I am supposed to integrate?

We then go on to integrate using the residue theorem, I'll leave out the details, so

$$\int_{\gamma_{R,\epsilon}}f(z) dz = 2\pi i\space \mathrm{Res}\left[f(z), i\right] = (1-2i)\pi.$$

I can follow the computations just fine, but I'm not completely sure why we use the pole $z=i$. Could we have used $z=0$ as well? Is it related to the chosen path, so that we "leave $0$ out" of the path and include only the singularity $z=i$?

We then go on to compute $\lim_{R \to \infty} \int_{S_R} f(z) dz = 0$ and $\lim_{\epsilon \to 0} f(z) dz = 2\pi i$. In the second limit, it says that $$\lim_{\epsilon \to 0} \int_{S_{\epsilon}} f(z) dz = \pi i \space \mathrm{Res}\left[f(z),0\right] ,$$ and I'm unsure about the $\pi i$. Shouldn't it be $2\pi i \space \mathrm{Res}\left[f(z),0\right]$? Or is it divided by $2$ because $S_{\epsilon}$ is a semicircle?

Lastly, it says that

$$\int_{\infty}^{\infty} \frac{x+2}{x^3+x} dx = \lim_{R\to\infty, \space \epsilon\to 0} \int_{-R}^{-\epsilon} \frac{x+2}{x^3+x} + \int_{\epsilon}^R \frac{x+2}{x^3+x} dx = \lim_{R\to\infty,\space \epsilon\to 0} \int_{\gamma_{R,\epsilon}}f(z)dz - \int_{S_R}f(z)dz + \int_{S_{\epsilon}}f(z)dz.$$ I'm thinking that the last inequality can be explained by the negative and positive direction of the semicircles. That since we integrated along $S_R$ in the positive direction, we subtract that one, and since we integrated along $S_{\epsilon}$ in the negative direction, we add that one? Does that make sense?

2. I'm not completely sure why we use the pole $z=i$. Could we have used $z=0$ as well? Is it related to the chosen path, so that we "leave $0$ out" of the path and include only the singularity $z=i$? YES! The residue theorem counts exactly the poles that are inside the path.
3. Shouldn't it be $2\pi i \space \mathrm{Res}\left[f(z),0\right]$? Or is it divided by $2$ because $S_{\epsilon}$ is a semicircle? YES! You can prove that the difference between the two semi-circles tends to zero when $\epsilon\rightarrow 0$, so the sum is equal to the residue and equal to two times the integral over the semi-circle.