# How to elegantly tell mathematica where are the poles of an integrand¿

Consider the function

Gamma[1/2-x]


it is a well-known fact that this function has simple poles at half integer values of the argument x=1/2,3/2,5/2,7/2... Say I want to numerically integrate this function from zero to infinity. I am aware that the Principal Value method is appropriate to handle numerical integrals whose integrands blow up at certain points. In this case I have an infinity of poles, and I want to know if there is an elegant way of telling Mathematica where they are instead of doing it by hand like I do it in the next line

NIntegrate[Gamma[1/2-x],{x,0,1/2,3/2,5/2,7/2,9/2,Infinity},Method->PrincipalValue]


So, how can I implement this more elegantly?

Maybe you can just evaluate the principal value by hand, by choosing a contour above and below the line of poles:

(
NIntegrate[Gamma[1/2-x], {x, 0, I, Infinity}] +
NIntegrate[Gamma[1/2-x], {x, 0, -I, Infinity}]
)/2


-0.792706 + 0. I

Related

Just for fun, we can use the above approach to compute the sum of the residues of Gamma[1/2-x]:

(
NIntegrate[Gamma[1/2-x], {x, 0, -I, Infinity}] -
NIntegrate[Gamma[1/2-x], {x, 0, I, Infinity}]
) / (2 Pi I)


-0.367879 + 0. I

or the equivalent:

NIntegrate[Gamma[1/2-x], {x, 0, -I, Infinity, I, 0}] / (2Pi I)


-0.367879 + 0. I

Now, the residues of Gamma[1/2-x] can be computed using SeriesCoefficient:

res[n_] = SeriesCoefficient[
Gamma[1/2-x],
{x,n+1/2,-1},
Assumptions->Element[n,Integers]&&n>0
]


(-1)^(1 - n)/n!

The sum is then given by:

Sum[res[n], {n, 0, Infinity}] //N


-0.367879

in agreement with the NIntegrate approach.