Consider the following integral
$$\lim_{n\rightarrow \infty} \int_0^\infty n^3\ln(1+x^2)e^{-nx} dx$$
and the substitution $u=nx$.
We get the integral
$$\lim_{n\rightarrow \infty} \int_0^\infty n^2\ln\left(1+\frac{u^2}{n^2}\right)e^{-u}du$$
We can use the Dominated Convergence Theorem to pass the limit through the integral and we get that the integral is equal to
$$ \int_0^\infty u^2e^{-u}du$$
This integral can be integrated by parts and shown to be equal to 2.
What is the legality and rigor of this substitution? In particular, it seems that we have smuggled a $n$ into a variable substitution and swept it under the rug when we took the limit and evaluated the integral. Am I missing something? Does this have something to do with a change of coordinates?
Lastly, are there conditions in which we can and cannot do this substitution?
The integrand $\ln(1+x^{2})e^{-nx}$ is nonnegative and continuous on $[0,\infty)$, so the first integral is in fact an improper Riemann integral and can be written as \begin{align*} \int_{0}^{\infty}\ln(1+x^{2})e^{-nx}dx=\lim_{M\rightarrow\infty}\int_{0}^{M}\ln(1+x^{2})e^{-nx}dx. \end{align*} Now the usual substitution works for the interval $[0,M]$ to get \begin{align*} \int_{0}^{M}\ln(1+x^{2})e^{-nx}=n^{-1}\int_{0}^{nM}\ln(1+(u/n)^{2})e^{-u}du. \end{align*} The point is that, \begin{align*} \lim_{M\rightarrow\infty}\int_{0}^{nM}\ln(1+(u/n)^{2})e^{-u}du=\lim_{L\rightarrow\infty}\int_{0}^{L}\ln(1+(u/n)^{2})e^{-u}du, \end{align*} this can be seen by the usual $\epsilon$-argument, keep in mind that $n>0$ is fixed.
To be more specific, let \begin{align*} F(x)=\int_{0}^{x}\ln(1+(u/n)^{2})e^{-u}du, \end{align*} and $g(M)=F(nM)$, let the left-sided limit as $L_{1}$ and the right-sided one as $L_{2}$.
Given $\epsilon>0$, there is a $\delta_{1}>0$ such that \begin{align*} |g(M)-L_{1}|<\epsilon,~~~~M\geq\delta_{1}. \end{align*} For all $L\geq n\delta_{1}$, let $L=nM$, then $M\geq\delta_{1}$, and hence \begin{align*} |F(L)-L_{1}|=|F(nM)-L_{1}|=|g(M)-L_{1}|<\epsilon, \end{align*} this shows that $\lim_{L\rightarrow\infty}F(L)=L_{1}$. By the uniqueness of limit, we must have $L_{1}=L_{2}$.