Integral with singularity on the real axis with complex integration I don't understand how to solve an integral like this with singularities in the real axis
$$\int_{-\infty}^{\infty}\frac{1}{x^2-1} \, dx$$
From what I know, the integrand should vanishes when we have large $|x|$, but  what contour should I take? I saw a solution with the contour circling below the singularity in $-1$ and circling above the singularity at $+1$ but I didn't understand why should we take this kind of contour. Do the answers differ from different contours we take? 
I think I need a careful explanation of how to evaluate this integral because maybe I am missing something. Thank you for the attention.
 A: $$\int_{-\infty}^{\infty}\frac{1}{x^2-1}dx$$
This integral has undefined points within the boundaries at: $-1,1$
Note that, if exist $b,a<b<c,f(b)=$undefined, $\int_{a}^{c}f(x)dx=\int_{a}^{b}f(x)dx+\int_{b}^{c}f(x)dx$ 
So,
$$\int_{-\infty}^{\infty}\frac{1}{x^2-1}dx=\int _{ -\infty }^{ -1  }{ \frac { 1 }{ x^ 2-1 }  }dx +\int _{ -1 }^{ 1  }{ \frac { 1 }{ x^ 2-1 }  } dx+\int _{ 1 }^{ \infty  }{ \frac { 1 }{ x^ 2-1 }  } dx$$
$$\int { \frac { 1 }{ x^ 2-1 }  }dx=-\frac12ln|x+1|+\frac12ln|x-1|+C$$
But when we compute the boundaries:
$$\int _{ -\infty }^{ -1  }{ \frac { 1 }{ x^ 2-1 }  }dx=diverges$$
$$\int _{ -1 }^{ 1  }{ \frac { 1 }{ x^ 2-1 }  }dx=diverges$$
$$\int _{ 1 }^{ \infty  }{ \frac { 1 }{ x^ 2-1 }  } dx=diverges$$
So, $$\int_{-\infty}^{\infty}\frac{1}{x^2-1}dx=diverges$$
A: Why this contour works: To give you an outline of why this contour was chosen in the first place, it will be easier to think about it by partitioning the entire contour $C$ into six continuous curves:


*

*The upper semicircle $\Gamma$ of radius $R$ centered at the origin.

*The interval of the real line $[-R, -1 - \varepsilon]$.

*The lower semicircle $\gamma_{-1}$ of radius $\varepsilon$ centered at $-1$.

*The interval of the real line $[-1 + \varepsilon, 1 - \varepsilon]$.

*The upper semicircle $\gamma_1$ of radius $\varepsilon$ centered at $1$.

*The interval of the real line $[1 + \varepsilon, R]$.


Note that these are listed in order when traversing around the contour counterclockwise. $C$ is just the union of these six pieces. A general outline of one approach to this problem consists of four main steps (letting $f(z) = 1/(z^2 - 1)$):


*

*Use the Residue Theorem (or Cauchy's Theorem, if there are no singularities inside the contour) to obtain the value of $\int_C f(z) dz$.

*Use the ML estimate (or other method) to show that $\int_\Gamma f(z) dz \rightarrow 0$ as $R \rightarrow \infty$. While $\Gamma$ does not need to be a semicircle for the math to work out, it is easier to reason about an upper bound on $f(z)$ over simple curves, and the semicircle is relatively simple to work with in many cases. Also, the length of $\Gamma$ is simply $\pi R$.

*Use either the ML estimate or the Fractional Residue Theorem to evaluate the integrals over the small semicircles (in this case we have two: one over $\gamma_{-1}$, and one over $\gamma_1$).

*Take the limit as $R \rightarrow \infty$ and $\varepsilon \rightarrow 0$, to obtain $$\text{PV} \int_{-\infty}^\infty f(z) dz = \lim_{R \rightarrow \infty,\varepsilon \rightarrow 0} \left(\int_{-R}^{-1 - \varepsilon} f(z) dz + \int_{-1 + \varepsilon}^{1 - \varepsilon} f(z) dz + \int_{1 + \varepsilon}^{R} f(z) dz \right) = \lim_{R \rightarrow \infty,\varepsilon \rightarrow 0} \left(\int_C f(z) dz - \int_\Gamma f(z) dz - \int_{\gamma_{-1}} f(z) dz - \int_{\gamma_{1}} f(z) dz \right).$$


The quantity you are trying to compute is on the left side of this equation, and from the steps above, you can compute each of the limits on the right side. Thus, this method gives you the answer you want. The final equation comes from the fact that the integral of $f(z)$ over $C$ is equal to the sum of the integrals of $f(z)$ over each of the six parts.
Other contours: The contour you mentioned is not the only contour applicable. For instance, you could have two upper semicircles around the singularities instead of one lower semicircle and one upper semicircle; call this contour $C'$. This will get you the same answer, for two subtle reasons:


*

*The singularity $-1$ is now not on the interior of the contour, so the value of the integral over $C'$ now differs from that of the integral over $C$.

*When traversing $C'$ counterclockwise, we now traverse the semicircle around $-1$ in the clockwise direction, whereas in $C$, we would traverse the lower semicircle in a counterclockwise direction. This affects the value of the fractional residue, since a clockwise direction corresponds to a negative angle.


As mentioned earlier, the choice of $\Gamma$ being a semicircle is that it make the argument in the second step simpler. Additionally, the choice of $\gamma_{-1}$ and $\gamma_1$ being semicircles allows us to apply the Fractional Residue Theorem. Finally, we use a half disk whose boundary contains part of the real line, since the original integral we are trying to evaluate is over the reals, from $-\infty$ to $\infty$.
Let me know if there is anything you are still unclear about.
