# numerical integration error for heavily oscillatory integrands

Let $$n$$ be a positive integer and $$p>0$$. Define $$f_{n,p}(t) = \frac{(p \ln t - 1) (\sin^{2n} t)}{t^{p+1}},$$ and I was trying to look at the behaviour of $$\sqrt{n}\lim_{p\to 0^+}\int_0^\infty f_{n,p}(t)dt$$ when $$n\to\infty$$.

I evaluated the following three integrals: $$\sqrt{n}\int_\pi^\infty f_{n,p}(t)dt,\quad \sqrt{n}\int_0^\infty f_{n,p}(t)dt,\quad \sqrt{n}\int_0^\pi f_{n,p}(t)dt$$ for some specific value of large $$n$$ and small $$p>0$$ and got the following results in MMA 12.1.1 (version June 9, 2020):

With[{n = 20000, p = 0.0000001}, NIntegrate[Sqrt[n] (p Log[t] - 1) Sin[t]^(2 n)/t^(p + 1),
{t, Pi, Infinity}, MaxRecursion -> 40]]

-0.376124345064075

With[{n = 20000, p = 0.0000001}, NIntegrate[Sqrt[n] (p Log[t] - 1) Sin[t]^(2 n)/t^(p + 1),
{t, 0, Infinity}, MaxRecursion -> 40]]

-1.12838344570119

With[{n = 20000, p = 0.0000001}, NIntegrate[Sqrt[n] (p Log[t] - 1) Sin[t]^(2 n)/t^(p + 1),
{t, 0, Pi}, MaxRecursion -> 40]]

-1.12838344570105


The sum of the first and the third integral should be the second, so something is wrong here.

The third integral looks correct because I can manually calculate that $$\lim_{n\to\infty} \lim_{p\to 0^+} \sqrt{n}\int_0^\pi f_{n,p}(t)dt = -\frac{2}{\sqrt{\pi}} = -1.128379\cdots,$$ which agrees with the numerical integration result. The second integral is probably wrong and I have no idea of what the correct value of the first integral should look like but I think it should be positive.

Is there some workaround to obtain at least consistent results for the three integrals?

===

Background of the problem. The problem is related to https://math.stackexchange.com/questions/2827591/alternate-proof-for-weighted-alternating-shifted-central-binomial-sum-relation Instead of $$k^s$$ in the sum, it is $$\ln k$$ in my problem, that is, I was looking at the sum $$S_n = \sum_{k=1}^n (-1)^k \binom{2n}{n+k}\ln k.$$ I wish to show that $$S_n / 2^{2n} >c/\sqrt{n}$$ for some constant $$c>0$$ and all sufficiently large $$n$$. Following a similar approach to the answer in the link above, this boils down to showing that $$\lim_{p\to 0^+} p \int_0^\infty f_{n,p}(t) dt > -\frac{c}{\sqrt n}$$ for some positive constant $$c < \frac{1}{\sqrt{\pi}}(\gamma+\ln 2)\approx 0.7167$$. I have managed to prove this analytically.

===

For a given value of $$n$$, Mathematica is able to evaluate the integral analytically (the answer is complicated, involving gamma and polygamma functions). So I did

N[Table[Sqrt[n]
Limit[Integrate[
Sin[t]^(2 n)/t^(1 + p) (p Log[t] - 1), {t, 0, Infinity},
Assumptions -> 0 < p < 1], p -> 0], {n, 10}]]

{-0.635181422730739, -0.551179369011369, -0.521962044454548, \
-0.507143476307785, -0.498189412540769, -0.492195004661885, \
-0.487901432379977, -0.484674935869789, -0.482161769590284, \
-0.480148962175569}


which makes me think what I wanted to show is true.

• Also look at "Advanced Numerical Integration" under the NIntegrate help and search this forum for "highly oscillating integrals" for more help. Jan 6 '21 at 12:13
• I believe your integrand becomes positive here: With[{n = 20000, p = 0.0000001}, Solve[(p Log[t] - 1) == 0, t]]. You might ponder the size of the that abscissa and how to integrate the spikes that occur every Pi along the t axis. You'd need millions of digits of precision. Jan 6 '21 at 17:26

• Your claim that S[n]/2^(2n) > c/Sqrt[n] already fails for n==1, because Log[1]==0 Jan 6 '21 at 12:22
• Sorry, I mean for sufficiently large $n$ Jan 6 '21 at 12:49