There is a small formula for finding definite integral by complex analysis method : If $f(x)$ containes cosine and sine functions along with polynomial functions then $f(x)$ can be treated as a real or imaginary part of $f(z)$.Then find the singular points of $f(z)$ and check which point lies in upper half plane.
CASE(a):If the singular point does not lie on real axis in this case we apply Cauchy residue theorem and may use Jordan's lemma and everything is claear to me .
CASE(b):If the singular points lie on real axis ,then:
Method 1: by using cauchy residue thm and taking a semicircular contour which leaves the points of singularity on real axis.
Method 2:(short one)
$\int_{-\infty}^\infty f(z)dz$ = $\pi i$ [$\sum$ residue at poles within C] ,if jordan's lemma applied.
now my question is what is proof for this short method .I thought of many things for why is there a factor of $\pi i$ in place of $2\pi i$ but they don't look right.
The answer will be $\pm i \pi\, \text{Residuum}$ depending on how you "regularize" the singularity -- by pushing it up or down away from the real axis. It is equivalent to integration over a half-circle above or under the singularity and shrinking the radius to zero. The factor $i \pi$ comes from the half-circle integration exactly as the factor $2 \pi i$ comes from the full-circle integration.
There is also a prescrption called principal value in which one effectively takes half of the upper and half of the lower half-circle values. It depends on the problem at hand which prescription should be used.
Of course, assuming also that you can close the integration contour by a semicircle at infinity.