TITLE: Asymptotic expansion of $ I_n = \int_0^{\pi/4} \tan(x)^n \mathrm dx $
QUESTION [5 upvotes]: I'm trying to compute the asymptotic expansion of
$$ I_n = \int_0^{\pi/4} \tan(x)^n \mathrm dx $$
Here is what I've done:
Change of variable $$ t= \tan x $$
$$ I_n = \int_0^1 \frac{t^n \mathrm dt}{1+t^2} = \int_0^1 \frac{(1-t)^n \mathrm dt}{t^2-2t+2} $$
Change of variable
$$ t=\frac{x}{n}$$
$$ I_n = \frac{1}{2n}\int_0^n \frac{\left(1-\frac{x}{n}\right)^n \mathrm dx}{1-\left(\frac{x}{n}-\frac{x^2}{2n^2} \right)}$$
Taylor expansions:
$$ \left(1-\frac{x}{n}\right)^n = e^{-x} \left(1-\frac{x^2}{2n}+\frac{3x^4-8x^3}{24n^2}+\mathcal{O} \left(\frac{1}{n^3} \right) \right)$$
$$ \frac{1}{1-\left(\frac{x}{n}-\frac{x^2}{2n^2} \right)} = 1+\frac{x}{n}+\frac{x^2}{2n^2} + \mathcal{O} \left(\frac{1}{n^3} \right) $$
$$ \frac{\left(1-\frac{x}{n}\right)^n }{1-\left(\frac{x}{n}-\frac{x^2}{2n^2} \right)}=e^{-x} \left( 1+\frac{x}{n}+\frac{x^2}{2n^2}-\frac{x^2}{2n}-\frac{x^3}{2n^2}+\frac{3x^4-8x^3}{24n^2} + \mathcal{O} \left(\frac{1}{n^3} \right) \right)$$
So 
$$ I_n = \frac{1}{2n} \int_0^n e^{-x} \left( 1+\frac{x}{n}+\frac{x^2}{2n^2}-\frac{x^2}{2n}-\frac{x^3}{2n^2}+\frac{3x^4-8x^3}{24n^2} + \mathcal{O} \left(\frac{1}{n^3} \right) \right) \mathrm dx $$
$$ I_n = \frac{1}{2n} \left(1+\frac{1}{n}+\frac{1}{2n^2}\times 2-\frac{1}{2n}\times 2 - \frac{1}{2n^2} \times 6 + \frac{1}{8n^2} \times 24 - \frac{1}{3n^2} \times 6+ \mathcal{O} \left(\frac{1}{n^3} \right) \right) $$
$$ I_n = \frac{1}{2n}-\frac{1}{2n^3}+\mathcal{O} \left(\frac{1}{n^4} \right)$$
For example Wolfram gives:
$$ 1-1000^2+ 2\times1000^3\int_0^{\pi/4} \tan(x)^{1000} \mathrm dx \approx 4.9\times 10^{-6}$$
I'm quite sure of my work, I would just like to know if everything is correct!

REPLY [4 votes]: I figured I'd throw my hat into the ring as well.
We can appeal to Watson's lemma to find a full asymptotic expansion of the integral.
After your substitution $t=\tan x$, make another substitution $t = e^{-s}$.  This gives
$$
\int_0^1 t^n \frac{dt}{1+t^2} = \int_0^\infty e^{-ns} \frac{ds}{e^s+e^{-s}}.
$$
By Watson's lemma we have
$$
\int_0^\infty e^{-ns} \frac{ds}{e^s+e^{-s}} \approx \frac{1}{2} \sum_{k=0}^{\infty} \frac{E_k}{n^{k+1}}
$$
as $n \to \infty$, where $E_k$ is the $k^{\text{th}}$ Euler number.