Change of Variables in Limits (Part 1) After answering this question, I was wondering if the following generalization holds true:

Claim: If $\lim \limits_{x\to a}g(x)=b$, then $\lim \limits_{x\to a}f(g(x))=\lim \limits_{y\to b}f(y)$.

I've seen some people use this change of variables before when evaluating difficult limits, but I haven't seen this presented as a theorem in a textbook. Is this claim true? If not, is the claim salvageable with additional hypotheses? For example, must $f$ be continuous for the claim to hold?
 A: A counterexample.  Let $a=b=0$, $g(x)=x^2$, and let
$$f(x)=\begin{cases}1&x\ge 0\\0&x<0\end{cases}$$
Then $\lim_{y\to 0}f(y)$ does not exist, but $\lim_{x\to 0}f(g(x))=1$.
If we suppose that $\lim_{y\to b}f(y)$ exists, then the result holds.
First suppose that the limit is finite and equal to $L$.  Fix $\epsilon>0$, and let $\delta$ be such that
$$|y-b|<\delta\Longrightarrow |f(y)-L|<\epsilon$$
Now, choose $\delta'$ such that
$$|x-a|<\delta'\Longrightarrow|g(x)-b|<\delta$$
Notice now that we have
$$|x-a|<\delta'\Longrightarrow|f(g(x))-L|<\epsilon$$
which shows that $\lim_{x\to a}f(g(x))=L$.  The case of an infinite limit is shown similarly.
A: You certainly need some assumptions on $f,g$, as Jared shows.

THM Suppose that $f(y)\to \ell$ as $ y\to b$. Suppose that ${\rm im}\, g\subseteq {\rm dom}\, f$, and suppose that $g(x)\to b$ as $x\to a$, yet $g$ does not attain the value $b$ in a neighborhood $B(x,\eta)-\{x\}$. Then $$f\circ g(x)\to \ell \;\;\text{ as } x\to a$$

P Let $\epsilon >0$ be given. Since $f\to\ell $ as $y\to b$ there exists $\delta >0$ such that $0<|y-b|<\delta$ implies $|f(y)-\ell|<\epsilon$. Since $g\to b$ as $x\to a$, there exists $\eta >\delta'>0$ such that $0<|x-a|<\delta'$ implies $0<|g(x)-b|<\delta$. But then we will have $|f(g(x))- \ell|<\epsilon$ whenever $0<|x-a|<\delta'$, so the claim follows. $\blacktriangle$
This then gives the standard

COR Suppose that $f$ is continuous at $g(a)$ and $g$ is continuous at $a$. Then $f\circ g$ is continuous at $a$.

