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?


1 Answer 1


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

 -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


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

  • $\begingroup$ 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 $\endgroup$
    – Fisher
    Commented Aug 9, 2019 at 11:14
  • 2
    $\begingroup$ "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.) $\endgroup$ Commented Aug 9, 2019 at 12:42
  • $\begingroup$ Thank you Anton. I knew I mist have rea somewhere about PrincipalValue... =) $\endgroup$ Commented Aug 9, 2019 at 12:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.