I want to obtain an asymptotic expansion for $\int_0^\pi \frac{\cos(kn)}{1+k^2}dk$ in which $n\to \infty$.
Per Gary's suggestion, examine https://dlmf.nist.gov/2.11#i
I do not understand where the trigonmetric terms go when $m\to \infty$ yielding their $(2.11.2)$ series. How is that series obtained?
Integrating by parts $4$ times: $$ \begin{align} &\int_0^\pi\frac{\cos(nx)}{1+x^2}\,\mathrm{d}x\tag{1a}\\ &=\frac1n\int_0^\pi\frac1{1+x^2}\,\mathrm{d}\sin(nx)\tag{1b}\\ &=\frac1n\frac{\sin(n\pi)}{1+\pi^2}+\frac2n\int_0^\pi\frac{x\sin(nx)}{\left(1+x^2\right)^2}\,\mathrm{d}x\tag{1c}\\ &=\frac1n\frac{\sin(n\pi)}{1+\pi^2}-\frac2{n^2}\int_0^\pi\frac{x}{\left(1+x^2\right)^2}\,\mathrm{d}\cos(nx)\tag{1d}\\ &=\frac1n\frac{\sin(n\pi)}{1+\pi^2}-\frac2{n^2}\frac{\pi\cos(n\pi)}{\left(1+\pi^2\right)^2}+\frac2{n^2}\int_0^\pi\frac{1-3x^2}{\left(1+x^2\right)^3}\cos(nx)\,\mathrm{d}x\tag{1e}\\ &=\frac1n\frac{\sin(n\pi)}{1+\pi^2}-\frac2{n^2}\frac{\pi\cos(n\pi)}{\left(1+\pi^2\right)^2}+\frac2{n^3}\int_0^\pi\frac{1-3x^2}{\left(1+x^2\right)^3}\,\mathrm{d}\sin(nx)\tag{1f}\\ &=\scriptsize\frac1n\frac{\sin(n\pi)}{1+\pi^2}-\frac2{n^2}\frac{\pi\cos(n\pi)}{\left(1+\pi^2\right)^2}+\frac2{n^3}\frac{1-3\pi^2}{\left(1+\pi^2\right)^3}\sin(n\pi)+\frac{24}{n^3}\int_0^\pi\frac{x\left(1-x^2\right)}{\left(1+x^2\right)^4}\sin(nx)\,\mathrm{d}x\tag{1g}\\ &=\scriptsize\frac1n\frac{\sin(n\pi)}{1+\pi^2}-\frac2{n^2}\frac{\pi\cos(n\pi)}{\left(1+\pi^2\right)^2}+\frac2{n^3}\frac{1-3\pi^2}{\left(1+\pi^2\right)^3}\sin(n\pi)-\frac{24}{n^4}\int_0^\pi\frac{x\left(1-x^2\right)}{\left(1+x^2\right)^4}\,\mathrm{d}\cos(nx)\tag{1h}\\ &=\scriptsize\frac1n\frac{\sin(n\pi)}{1+\pi^2}-\frac2{n^2}\frac{\pi\cos(n\pi)}{\left(1+\pi^2\right)^2}+\frac2{n^3}\frac{1-3\pi^2}{\left(1+\pi^2\right)^3}\sin(n\pi)-\frac{24}{n^4}\frac{\pi\left(1-\pi^2\right)}{\left(1+\pi^2\right)^4}\cos(n\pi)\\ &+\frac{24}{n^4}\int_0^\pi\frac{1-10 x^2+5x^4}{\left(1+x^2\right)^5}\cos(nx)\,\mathrm{d}x\tag{1i}\\ \end{align} $$ The total variation of $\frac{1-10 x^2+5x^4}{\left(1+x^2\right)^5}$ on $[0,\pi]$ is bounded by $\frac{59}{32}$; $f(0)=1,f\!\left(\frac1{\sqrt3}\right)=-\frac{27}{64},f(\pi)\approx0$. Therefore, $$ \begin{align} &\left|\,\frac{24}{n^4}\int_0^\pi\frac{1-10 x^2+5x^4}{\left(1+x^2\right)^5}\cos(nx)\,\mathrm{d}x\,\right|\tag{2a}\\ &=\left|\,\frac{24}{n^5}\int_0^\pi\frac{1-10 x^2+5x^4}{\left(1+x^2\right)^5}\,\mathrm{d}\sin(nx)\,\right|\tag{2b}\\ &=\left|\,\frac{24}{n^5}\frac{1-10\pi^2+5\pi^4}{\left(1+\pi^2\right)^5}-\frac{24}{n^5}\int_0^\pi\sin(nx)\,\mathrm{d}\frac{1-10 x^2+5x^4}{\left(1+x^2\right)^5}\,\right|\tag{2c}\\ &\le\frac{24}{n^5}\left(\frac{1-10\pi^2+5\pi^4}{\left(1+\pi^2\right)^5}+\frac{59}{32}\right)\tag{2d}\\ &\lt\frac{45}{n^5}\tag{2e} \end{align} $$ Thus, we get the asymptotic expansion of $\int_0^\pi\frac{\cos(nx)}{1+x^2}\,\mathrm{d}x$ to be $$ \frac1n\frac{\sin(n\pi)}{1+\pi^2}-\frac2{n^2}\frac{\pi\cos(n\pi)}{\left(1+\pi^2\right)^2}+\frac2{n^3}\frac{1-3\pi^2}{\left(1+\pi^2\right)^3}\sin(n\pi)-\frac{24}{n^4}\frac{\pi\left(1-\pi^2\right)}{\left(1+\pi^2\right)^4}\cos(n\pi)\tag3 $$ with an error smaller than $\frac{45}{n^5}$.
If $n$ is an integer, then $\sin(n\pi)=0$ and $\cos(n\pi)=(-1)^n$, which accounts for any missing $\sin$’s and $\cos$’s.