# How to integrate this oscillatory function with apparent singularities

I want to integrate the following function with respect to x,between 0 and +Infinity:

-1/Pi Exp[-2 Pi x] Abs[w^3] (Abs[w])^(-x) Gamma[1 - x] Gamma[x - 3] (Sin[Pi x/2])^2 Cos[Pi x/2]


w is a parameter that ranges from - Infinity to Infinity, but you can set it to 2 if you want. As you can see, it has oscillatory factors and apparent singularities( since the Gamma function diverges but the Sin is zero, and the overall result is finite) at the positive integers.

As I try to integrate, i get the error

NIntegrate::ncvb: NIntegrate failed to converge to prescribed accuracy after 9 recursive bisections in x near {x} = {0.996132}. NIntegrate obtained 0.008228086311816908and 7.945116181892624*^-6 for the integral and error estimates.

I have tried setting Method -> "LevinRule", setting workprecision to higher values, but nothing worked.... any ideas?

The integral exists only in the principal value sense. You may try this:

NIntegrate[
-1/Pi Exp[-2 Pi x] Abs[w^3] (Abs[w])^(-x) Gamma[1 - x] Gamma[x - 3] (Sin[Pi x/2])^2 Cos[Pi x/2],
{x, 0, 1, 3, ∞},
PrincipalValue -> True
]


0.0441333

The integration range {x, 0, 1, 3, ∞} mean "integrate from 0 to ∞ but expect singularities at 1 and 3.

Surprisingly, this use of PrincipalValue for NIntegrate is scarcely documented. In fact, PrincipalValue appears red in my notebook because the syntax highlighter does not know it as an option tp NIntegrate ... oO

• Thanks for your answer! This is weird, since the function is not singular at 1 and 3, the gamma function blows up but the sin is zero, and the product is finite. Also, the same sort of behaviour is present for all other positive integers, so I don't understand why specifying only these two apparent singularities should be enough – Fisher Aug 9 '19 at 11:14
• "Surprisingly, this use of PrincipalValue for NIntegrate is scarcely documented." The advanced NIntegrate documentation has a section "Cauchy Principal Value Integration" discussing these kind of PrincipalValue computation specifications. (+1 BTW.) – Anton Antonov Aug 9 '19 at 12:42
• Thank you Anton. I knew I mist have rea somewhere about PrincipalValue... =) – Henrik Schumacher Aug 9 '19 at 12:53