# Singular integral: NIntegrate fails to converge

I need to calculate the following singular integral:

NIntegrate[Log[1 + y^2]/Cos[Pi y], {y, 0, 1}]


However, it is failing to converge. I have tried to specify MaxRecursion, PrecisionGoal, and Exclusions but neither helped. How does one calculate singular integrals in Mathematica?

-

As it stands the integral does not converge! To see that note that

Series[Log[1 + y^2]/Cos[Pi y], {y, 1/2, 0}]

returns $$-\frac{\log \left(\frac{5}{4}\right)}{\pi \left(y-\frac{1}{2}\right)}-\frac{4}{5 \pi }+O\left(y-\frac{1}{2}\right)$$

and a simple pole is not integrable.

What you maybe want to know is Cauchy's principle value of the integral (which is finite). For that evaluate

NIntegrate[Log[1 + y^2]/Cos[Pi y], {y, 0, 1/2, 1}, Method -> "PrincipalValue"]

which returns -0.281589.

-
Same with NIntegrate[Log[1 + y^2]/Cos[Pi y], {y, 0, 1}, Method -> "PrincipalValue", Exclusions -> {1/2}] –  b.gatessucks Dec 13 '12 at 12:51