Pulling the limit inside the integral for Real Analysis. $$\lim_{n\to\infty}\int_1^2 \cos\sqrt\frac{{2xn+2}}{xn+1}\,dx$$
I just saw this on an exam, and I wondered if I did it right. 
I said that since $\cos x$ is continuous and bounded, I could pull the limit inside the integral. Am I also allowed to then pull the limit inside the cos and square root? I got an answer of $\cos\sqrt2$. 
 A: There is no need to switch any limit with any integral. 
Notice that
$$2xn + 2 = 2(xn + 1)$$
Hence your integral is simply
$$\int_1^2 \cos\sqrt{2}\ dx = \cos\sqrt{2} + C$$
The limit becomes irrelevant.
A: Regarding your question about pulling the limit inside being allowed in general.
The answer is: sometimes.
In particular, if the sequence of integrands converges UNIFORMLY, then you can. In general, you cannot. This is considered by many to be the single most frustrating weakness of the Riemann integral, and is a strong motivation for the construction of the Lebesgue integral, which is better behaved with limits.
For the purposes of the Riemann integral, continuous and bounded is not sufficient to justify moving the limit inside.
You will likely cover this, although it seems unrelated, when you study infinite series.
Please see Turing's answer below for why this approach is unnecessary in this particular instance.
A: If you want to exchange the limit and the integral here, although it is not necessary as you see, dominated convergence works,
$$
\left|\cos\left ( \sqrt{\frac{2xn+2}{xn+1}}\right)\right |\leq 1
$$
and $g=1$ is integrable on $[1,2]$, then
$$
\lim_{n\to \infty}\int_1^2 \cos\left ( \sqrt{\frac{2xn+2}{xn+1}}\right)\mathrm dx\\
=
\int_1^2\lim_{n\to \infty} \cos\left ( \sqrt{\frac{2xn+2}{xn+1}}\right)\mathrm dx\\
=
\int_1^2 \cos\left (\lim_{n\to \infty} \sqrt{\frac{2xn+2}{xn+1}}\right)\mathrm dx\\
=\cos\sqrt{2}\int_1^2\mathrm dx=\cos\sqrt{2}
$$
