Evaluate a limit involving definite integral Evaluate the following limit:
$$\lim_{n \to \infty} \left[n - n^2 \int_{0}^{\pi/4}(\cos x - \sin x)^n dx\right]$$
I've tried to rewrite the expression as follows:
$$\lim_{n \to \infty} \left[n - n^2 \sqrt{2}^n \int_{0}^{\pi/4}\sin^n \left( \frac{\pi}{4} - x \right) dx\right]$$
However, this doesn't seem to help too much. Thank you!

Writing
$$ (\cos x - \sin x)^n = \color{blue}{\frac{\cos x - \sin x}{\cos x + \sin x}} \cdot \color{red}{ (\cos x + \sin x)(\cos x - \sin x)^{n-1}} $$
and applying integrating by parts, we have
$$ \int_{0}^{\frac{\pi}{4}} (\cos x - \sin x)^n \, dx
= \frac{1}{n} - \frac{2}{n} \int_{0}^{\frac{\pi}{4}}  \frac{(\cos x - \sin x)^n}{(\sin x + \cos x)^2} \, dx. $$
Plugging this back,
$$ n - n^2 \int_{0}^{\frac{\pi}{4}} (\cos x - \sin x)^n \, dx = 2n \int_{0}^{\frac{\pi}{4}}  \frac{(\cos x - \sin x)^n}{(\sin x + \cos x)^2} \, dx. $$
Now from the observation
$$ n \int_{0}^{\frac{\pi}{4}} (\sin x + \cos x)(\cos x - \sin x)^n \, dx
= \frac{n}{n+1}, $$
we can apply the usual approximation-to-the-identity argument to obtain
\begin{align*}
\lim_{n\to\infty} \left[ n - n^2 \int_{0}^{\frac{\pi}{4}} (\cos x - \sin x)^n \, dx \right]
&= \lim_{n\to\infty} 2n \int_{0}^{\frac{\pi}{4}}  \frac{(\cos x - \sin x)^n}{(\sin x + \cos x)^2} \, dx \\
&= \lim_{x \to 0^+} \frac{2}{(\sin x + \cos x)^3} \\
&= \color{red}{\boxed{2}}.
\end{align*}
