Why $\lim$ of $\cos(f)$ equals to $\cos$ of $\lim(f)$? Let
$$\lim_{n\rightarrow \infty}\left(\cos\left(\frac{n\pi}{n+1}\right) \right) = \cos\left(\lim_{n\rightarrow \infty}\left(\frac{n\pi}{n+1} \right)\right)$$
Why the $\cos(x)$ function can be extracted outside of the limit equation? I know it has something to do with $\cos(x)$ being continuous, but not sure of the formal proof for that.
 A: If you don't remember what continuity is or how $\cos$ satisfies its definition, you can use the definition of $\cos(\theta)$ in which it is equal to the value of the $x$-coordinate of the endpoint of an arc of length $\theta$ traced counter-clockwise from $(1,0)$ along a unit circle centered at the origin, to prove geometrically that $$|\cos(\theta_2) - \cos(\theta_1)| \le |\theta_2 - \theta_1|.\tag{i}\label{i}$$ This is because a line segment is necessarily smaller or equal in length to any curve sharing the same endpoints, and each of the legs of a right triangle are necessarily smaller or equal to the hypotenuse.

This makes $\cos$ an example of a Lipschitz continuous function. 
Furthermore, since $$\lim_{n\rightarrow\infty} \frac{n\pi}{n+1} = \pi$$ this means that for any $\epsilon>0$ there exists $N$ such that if $n \ge N$ then $$\left|\frac{n\pi}{n+1} - \pi\right| < \epsilon.$$ Consequently, due to $\eqref{i}$, $$\left|\cos\left(\frac{n\pi}{n+1}\right) - \cos(\pi)\right| < \left|\frac{n\pi}{n+1} - \pi\right| < \epsilon.$$ Thus $$\lim_{n\rightarrow\infty} \cos\left(\frac{n\pi}{n+1}\right) = \cos(\pi) = -1$$
A: For any continuous function $f$, if $\lim_{n\to\infty} a_n = L$ and $L$ is in the domain of $f$, then
$$\lim_{n\to\infty} f(a_n) = f(L)$$
(Added) proof:
Given $\epsilon > 0$ there is by continuity of $f$ an $\epsilon_1  = \delta$ such that $$|x - L| < \delta = \epsilon_1 \Rightarrow |f(x) - f(L)| < \epsilon$$ Then given $\epsilon_1$ there is by convergence of $a_n$ to $L$ an $N = N(\epsilon_1)$ such that $$n > N \Rightarrow |a_n - L| < \epsilon_1$$
In other words, given an arbitrary $\epsilon > 0$, it is possible to find an $N$ (and an $\epsilon_1$) such that 
$$n > N \Rightarrow |a_n - L| < \epsilon_1 \Rightarrow |f(a_n) - f(L)| < \epsilon$$
