"Substitution" in limits I know there is a similar question about this topic on the site, but all the answers go on about the continuity of $f$, and in my case, $f$ is not continuous.
Indeed, I want to find
$$\lim_{x\to 0}\frac{\sin 2x}{x},$$
assuming I'm allowed to use the standard limit $\frac{\sin x}{x}\to 1$ as $x\to 0$.
Now informally, I have seen this computed this as follows:
$$\lim_{x\to0}\frac{\sin 2x}x=2\lim_{x\to0}\frac{\sin 2x}{2x}=2 \cdot 1,$$
as if to suggest the following theorem:

If $\lim\limits_{x\to a}g(x)=b$, then $$\lim_{x\to a}f(g(x))=\lim_{x\to b}f(x),$$
assuming that the latter exists.

I justified it to myself as follows: whether or not $f$ is continuous (or even defined) at $b$, we can let $$f^*(x)=\begin{cases}\hfil f(x)\hfil &\text{if $x\neq b$,}\\[5pt]\lim\limits_{x\to b}f(x)&\text{otherwise}\end{cases}$$
since the limit exists, and so $f^*$ is (by definition) continuous at $b$, and we can invoke the usual more restrictive theorem that says $\lim\limits_{x\to a} f(g(x))=f(\lim\limits_{x\to a} g(x))$ when $f$ is continuous at $\lim\limits_{x\to a} g(x)$, to get that
$$\lim_{x\to a}f(g(x)) = \lim_{x\to a}f^*(g(x))= f^*\Big(\lim_{x\to a}g(x)\Big)=f^*(b)=\lim_{x\to b}f(x),$$
as required.
So my question is: is this more general theorem correct, or is there a flaw in my argument?
I am sceptical because it feels like a nicer theorem than the usual one which insists that $f$ has to be continuous, and if it were true then my textbooks would probably include it in this form.
 A: Here is a simple sufficient condition in this type of situation:

If $\lim\limits_{x\to a}g(x) = b$ and if $g(x) \neq b$ for $x \neq a$ (at least in some deleted neighborhood of $a$), then
$$
\lim_{x\to a} f(g(x)) = \lim_{x\to b}f(x),
$$
assuming that the latter exists.

The proof is the standard manipulation of the formal definitions: Fix $\varepsilon > 0$ arbitrarily, and use existence of $L = \lim(f, b)$ to pick an $\eta > 0$ such that if $0 < |y - b| < \eta$, then $|f(y) - L| < \varepsilon$. Then use the hypotheses on $g$ to pick $\delta > 0$ such that if $0 < |x - a| < \delta$, then $0 < |g(x) - b| < \delta$. (The inequality $0 < |g(x) - b|$ expresses the guarantee that $g(x) \neq b$ for $0 < |x - a| < \delta$.)
By direct substitution, if $0 < |x - a| < \delta$, then $|f(g(x)) - L| < \varepsilon$. Since $\varepsilon > 0$ was arbitrary, $\lim(f \circ g, a) = L$.
Here, of course, $g(x) = 2x$, and $g(x) \neq b = 0$ if $x \neq a = 0$.

As Lorago notes in the comments, the hypothesis that $L = \lim(f, b)$ exists means $f$ has a continuous extension to $b$. If you're free to define $f(b)$, then set $f(b) = \lim(f, b) = L$. The argument above (with the extra condition on $g$) may be viewed as avoiding Matthew Towers' counterexample where $f$ has a removable discontinuity, i.e., where $f(b)$ is defined but not equal to $\lim(f, b)$.
A: In my calculus book (Calculus: A Rigorous First Course), I introduced notation to make it easier to explain what's going on here.  $\lim_{x \to a} g(x) = b$ means that if $x$ is close to $a$, but not equal to $a$, then $g(x)$ is close to $b$ (with the details of what "close" means being spelled out by the $\epsilon$-$\delta$ formalism).  This is sometimes expressed by writing "as $x \to a$, $g(x) \to b$."  But this notation leaves out the important fact that $x$ cannot be equal to $a$.  So in my book I changed the notation slightly to "as $x \to a^\ne$, $g(x) \to b$," with the superscript "$\ne$" indicating that $x$ cannot be equal to $a$.  The notation is modeled on other common notation like "as $x \to a^+$, $g(x) \to b$," which means that if $x$ is close to $a$ but larger than $a$, then $g(x)$ is close to $b$.
Using this notation, we can see more clearly what the issue is.  I will follow the suggestion, from Ryszard Szwarc's comment, that it is helpful to let $y = g(x)$.  Then $f(g(x)) = f(y)$, and the question is: if $\lim_{x \to a} g(x) = b$, does it follow that $\lim_{x \to a} f(g(x)) = \lim_{y \to b} f(y)$?  Rewriting the question using my modified arrow notation, the question is:  Suppose that as $x \to a^\ne$, $y = g(x) \to b$, and as $y \to b^\ne$, $f(y) \to L$.  Does it follow that as $x \to a^\ne$, $f(g(x)) = f(y) \to L$?  The notation now points out the issue: as $x \to a^\ne$, we have $y \to b$, but we need to have $y \to b^\ne$ to conclude that $f(g(x)) = f(y) \to L$.  It is the mismatch between $y \to b$ and $y \to b^\ne$ that is the problem.
There are multiple ways to fix the problem.  One is, as suggested by Andrew D. Hwang's answer, to assume that when $x$ is close to $a$, $g(x)$ is never equal to $b$.  That would allow us to say that as $x \to a^\ne$, $y = g(x) \to b^\ne$.  This could then be combined with the fact that as $y \to b^\ne$, $f(g(x)) = f(y) \to L$ to conclude that as $x \to a^\ne$, $f(g(x)) \to L$.  The justification for stringing together the arrow notations is given by the $\epsilon$-$\delta$ argument in Andrew D. Hwang's answer.
But another possibility is to assume that $f$ is continuous at $b$.  In
that case, if $\lim_{y \to b} f(y) = L$, then we can say that as $y \to b$, $f(y) \to L$; there is no need for the superscript "$\ne$" on $b$ because continuity tells us that when $y = b$, $f(y) = L$.  Now we can string together the facts that as $x \to a^\ne$, $y = g(x) \to b$ and as $y \to b$, $f(g(x)) = f(y) \to L$ to conclude that as $x \to a^\ne$, $f(g(x)) \to L$, or in other words, $\lim_{x \to a} f(g(x)) = L$.  Once again, it is easy to justify this with $\epsilon$-$\delta$ reasoning.
And there are lots of other possibilities that can be expressed with this notation.  For example, suppose we know that as $x \to a^\ne$, $y = g(x) \to b^-$ (that is, if $x$ is close to $a$ but not equal to $a$, then $g(x)$ is close to $b$ and less than $b$).  Then we can compute $\lim_{y \to b^-} f(y)$.  If the answer is $L$, then we can say that as $y \to b^-$, $f(y) \to L$, and we can string together the two limit statements to conclude that as $x \to a^\ne$, $f(g(x)) \to L$, and therefore $\lim_{x \to a} f(g(x)) = L$.
My conclusion is that the usual arrow notation for describing limits is misleading because it leaves out an important part of the meaning of limits.  But when this deficiency is fixed, the notation can become a reliable guide to how limits can be combined to compute limits of composite functions.
