<s>[INST] The convergence speed of $ \int_0^{\frac{\pi}{2}} \sin ^n(x) \operatorname{d}x $? I have already known how to prove
\begin{equation*}
        \lim _{n \rightarrow \infty} \int_0^{\frac{\pi}{2}} \sin ^n(x) \operatorname{d}x = \sqrt{\frac{\pi}{2n}}
    \end{equation*}
with Wallis's formula
\begin{equation*}
 \quad \frac{\pi}{2}=\frac{2 \cdot 2 \cdot 4 \cdot 4 \cdot 6 \cdot 6 \cdot 8 \cdot 8 \cdots}{1 \cdot 3 \cdot 3 \cdot 5 \cdot 5 \cdot 7 \cdot 7 \cdot 9 \cdots} 
\end{equation*}
But the method I used was considered not to be universal.
How to prove that
\begin{equation*}
        \lim _{n \rightarrow \infty} \int_0^{\frac{\pi}{2}} \sin ^n(x) \operatorname{d}x = \frac{\sqrt{2 \pi}}{2} \cdot \frac{1}{n^{\frac{1}{2}}}-\frac{\sqrt{2 \pi}}{8} \cdot \frac{1}{n^{\frac{3}{2}}}+\frac{\sqrt{2 \pi}}{64} \cdot \frac{1}{n^{\frac{5}{2}}}
    \end{equation*}
And is
\begin{equation*}
         \lim _{n \rightarrow \infty} \int_0^{\frac{\pi}{2}} \sin ^n(x) \operatorname{d}x = \frac{\sqrt{2 \pi}}{2} \cdot \frac{1}{n^{\frac{1}{2}}}-\frac{\sqrt{2 \pi}}{8} \cdot \frac{1}{n^{\frac{3}{2}}}+ \dots +
         (-1)^{k}\cdot\frac{\sqrt{2 \pi}}{2^{\frac {k(k+1)}{2}}} \cdot \frac{1}{n^{\frac{2k+1}{2}}}
    \end{equation*}
true? Are there any more powerful tools, like numerical methods to calculate the integration?
 [/INST] If you are familiar with the Gaussian hypergeometric function, if $0 \leq x \leq \frac \pi 2$
$$\int \sin^n(x)\,dx=-\cos (x) \, _2F_1\left(\frac{1}{2},\frac{1-n}{2};\frac{3}{2};\cos^2(x)\right)$$ and the definite integral just becomes
$$I_n=\int_0^{\frac \pi 2}\sin^n(x)\,dx=\frac{\sqrt{\pi }} 2\,\,\frac{ \Gamma \left(\frac{n+1}{2}\right)}{ \Gamma
   \left(\frac{n+2}{2}\right)}$$ Using Stirling approximation, then
$$\frac{ \Gamma \left(\frac{n+1}{2}\right)}{ \Gamma
   \left(\frac{n+2}{2}\right)}=\sqrt{\frac{2}{n}}\left(1-\frac{1}{4 n}+\frac{1}{32 n^2}+\frac{5}{128
   n^3}+O\left(\frac{1}{n^4}\right) \right)$$
$$I_n= \sqrt{\frac{\pi}{2n}}\left(1-\frac{1}{4 n}+\frac{1}{32 n^2}+\frac{5}{128
   n^3}+O\left(\frac{1}{n^4}\right) \right)$$
If you want an even more accurate formula, use more terms in the expansion and make it a $[n,n]$ Padé approximant to get
$$I_n \sim \sqrt{\frac{\pi}{2n}}\,\,\,\frac{64 n^2-8 n+11}{64 n^2+8 n+11}$$ whose error is $\frac{709}{16384 n^5}$.
Using it, the relative error is $0.0035$% for $n=4$
</s>