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.
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:
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)$):
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:
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.