# Why is this condition for the limit of a composite function necessary?

I'm trying to learn calculus from a textbook I picked up on Amazon. The book is Modern Calculus and Analytic Geometry by Richard A. Silverman and covers calculus 1 through 3 or 4. I like the style of the book in that it gives proofs for all the theorems, but this level of rigor is completely new to me so it has been a bit of a struggle. I want to get better at constructing proofs so I've been focusing on these types of exercises.

Theorem 4.9 states that if a function g has the limit a at $x_{0}$, and a function f has the limit A at a and g(x)$\neq$a in some deleted neighborhood of $x_{0}$, then the composite function f(g(x)) has the limit A at $x_{0}$.

Show that the theorem fails if we drop the condition that g(x)$\neq$a in some deleted neighborhood of $x_{0}$.

When reading the statement of the theorem before I even got to this exercise, I didn't understand why this condition was necessary. If g(x)=a in some deleted neighborhood of $x_{0}$, how does this affect the limit of f(g(x)) at $x_{0}$?

For example, say g is just a constant function taking the value a for every x in it's domain. If g is constant then f(g) would be constant as well, say with a value of A. Certainly g(x)=a in some deleted neighborhood of $x_{0}$. I don't see why f(g($x_{0}$))=f(a)=A wouldn't imply a limit of A at $x_{0}$

I'm guessing that while the theorem seems to hold for the example above, there are certain other cases where it does not hold. If so, could you please provide an example? More generally, is there a way to know that the theorem may not hold without this condition without the need to find a counterexample?

Consider the function $f(x)$ given by $f(0)=1$ and $f(x) = 0$ for $x \neq 0$. Then as $x \to 0$, the limit $\lim_{x \to 0} f(x) = 0$.
Now let $g$ be the constant function $g(x) = 0$. Then $$\lim_{x \to 0} f(g(x)) = f(0) = 1 \neq 0 = \lim_{x \to 0} f(x).$$