TITLE: Snags when discovering the asymptotic behavior of an integral
QUESTION [7 upvotes]: I have trouble in discovering the asymptotic behavior (i.e, the asymptotic expansion) of the following integral:
$$\newcommand\abs[1]{\left\lvert#1\right\rvert}
\int_0^{\pi/2}\frac{dx}{1+(n\pi+x)\sin x}\tag1$$
The motivation is about the convergence of such improper integral:
$$I=\int_0^\infty\frac{x^\beta dx}{1+x^\alpha\abs{\sin x}}\qquad\alpha,\beta>0$$
The preceding integral is due to G.Hardy, which could be solved in such a way:
$$I_n=\int_{n\pi}^{(n+1)\pi}\frac{x^\beta dx}{1+x^\alpha\abs{\sin x}}=\int_0^\pi\frac{(n\pi+x)^\beta dx}{1+(n\pi+x)^\alpha\sin x}$$
Therefore $I=\sum_n I_n$ and we only need to estimate the asymptotic behavior of $I_n$.
In fact, it could be estimate roughly, which is sufficient to determine the convergence of $I$:
$$\frac{(n\pi)^\beta}{1+((n+1)\pi)^\alpha\sin x}\le\frac{(n\pi+x)^\beta}{1+(n\pi+x)^\alpha\sin x}\le\frac{((n+1)\pi)^\beta}{1+(n\pi)^\alpha\sin x}\qquad 0\le x\le\pi$$
Both the leftest side and the rightest side could be integrated over the closed interval $[0,\pi]$ elementarily and they are asymptotically equivalent (approximately $Cn^{-1}\log n$ where $C$ is a constant).
I want to see closer to the preceding integral. Can we obtain the asymptotic expansion of $I_n$? Out of simplicity, take $\alpha=1$ and $\beta=0$, and with a slight modification, we'll deal with the simpler version (1).
I have tried Laplace's method but failed after some efforts. It seems that Laplace method could estimate $\int_0^{\pi/n}$ well, but $\int_{\pi/n}^{\pi/2}$ is not a negligible tail.

REPLY [6 votes]: We write the integrand as
$$
\begin{align}
\frac{1}{1+n\pi\sin x + x\sin x} &= \frac{1}{1+n\pi\sin x} \cdot \frac{1}{1+\frac{x\sin x}{1+n\pi\sin x}} \\
&=\frac{1}{1+n\pi\sin x} \left[1 + O\left(\frac{x\sin x}{1+n\pi\sin x}\right)\right],
\end{align}
$$
where the $O(\cdots)$ holds uniformly for $n\geq 1$ and $x \in [0,\pi/2]$, so that
$$
\begin{align}
&\int_0^{\pi/2} \frac{dx}{1+n\pi\sin x + x\sin x} \\
&\qquad= \int_0^{\pi/2} \frac{dx}{1+n\pi\sin x} + O\left(\int_0^{\pi/2} \frac{x\sin x}{(1+n\pi\sin x)^2}\,dx\right).
\tag{1}
\end{align}
$$
We can estimate the integral in the $O(\cdots)$ by observing that
$$
\begin{align}
\int_0^{\pi/2} \frac{x\sin x}{(1+n\pi\sin x)^2}\,dx &= \frac{1}{n^2 \pi^2} \int_0^{\pi/2} \frac{x\sin x}{\left(\frac{1}{n\pi}+\sin x\right)^2}\,dx \\
&\sim \frac{1}{n^2 \pi^2} \int_0^{\pi/2} \frac{x}{\sin x}\,dx
\end{align}
$$
by the dominated convergence theorem.
In light of this, $(1)$ becomes
$$
\int_0^{\pi/2} \frac{dx}{1+n\pi\sin x + x\sin x} = \int_0^{\pi/2} \frac{dx}{1+n\pi\sin x} + O\left(\frac{1}{n^2}\right).
\tag{2}
$$
Now courtesy of Mathematica we have
$$
\int_0^{\pi/2} \frac{dx}{1+n\pi\sin x} = \frac{\log\left(n\pi+\sqrt{n^2\pi^2-1}\right)}{\sqrt{n^2\pi^2-1}},
$$
which allows us to conclude from $(2)$ that

$$
\int_0^{\pi/2} \frac{dx}{1+n\pi\sin x + x\sin x} = \frac{\log\left(n\pi+\sqrt{n^2\pi^2-1}\right)}{\sqrt{n^2\pi^2-1}} + O\left(\frac{1}{n^2}\right).
\tag{3}
$$

Here's a plot showing the numerical value of the integral in blue and the asymptotic in purple for $1 \leq n \leq 10$.

As discussed in the comments, we can estimate the error term precisely by noting that the integrand of the error is
$$
\begin{align}
\frac{1}{1+n\pi\sin x+x\sin x} - \frac{1}{1+n\pi\sin x} &= \frac{1+n\pi\sin x - 1 - n\pi\sin x - x\sin x}{(1+n\pi\sin x+x\sin x)(1+n\pi\sin x)} \\
&= \frac{1}{n^2\pi^2} \cdot \frac{-x\sin x}{\left(\sin x + \frac{1+x\sin x}{n\pi}\right)\left(\sin x + \frac{1}{n\pi}\right)},
\end{align}
$$
so that, by the dominated convergence theorem, the error is asymptotic to
$$
- \frac{1}{n^2\pi^2} \int_0^{\pi/2} \frac{x}{\sin x}\,dx = - \frac{2G}{n^2\pi^2},
$$
where $G$ is Catalan's constant.  Thus

$$
\begin{align}
&\int_0^{\pi/2} \frac{dx}{1+n\pi\sin x + x\sin x} \\
&\qquad = \frac{\log\left(n\pi+\sqrt{n^2\pi^2-1}\right)}{\sqrt{n^2\pi^2-1}} - \frac{2G}{n^2\pi^2} + o\left(\frac{1}{n^2}\right).
\tag{4}
\end{align}
$$

Here's a plot of the numerical integral in blue and this new asymptotic in purple.