questions about a theorem regarding the limit of a composition of functions Here is a theorem from my analysis textbook: Let $(a, b)$ be a (possibly infinite) interval and let $u$ equal  $a^+$ or $b^-$ .
If $g$ is defined on $(a, b)$ and $\lim_{x\to u }g(x) = L$, $f$ is defined on an interval containing
$L$ and the image of $g$, and $f$ is continuous at $L$, then
$\lim f (g ( x)) = f ( L)$.
This theorem appears to only cover the case of right and left hand limits. Am I correct in believing that theorem can be extended to say: "Let $(a, b)$ be a (possibly infinite) interval and let $u$ equal  $a^+$ or $b^-$ or a point $c$ contained in $(a,b)$.
Also,  the theorem requires that "$f$ is defined on an interval containing
$L$ and the image of $g$." I think we can actually weaken this hypothesis. All we actually need to say is the following: let "$f$ is defined on an interval containing
$L$" and let this interval also be a subset of the image of $g$." I don't think it is necesary to have $f$ defined on the entire image of $g$, we only need $f$ to be defined on some interval that is a subset of the image of $g$ and contains $L$. Do you agree?
Lastly, I am having trouble building intuition on why we need $f$ to be continuous at $L$. Can you give an intuitive(ideally visual) explanation for this?
 A: Your first intuition is broadly correct, and it's a consequence of the original theorem since if $c \in (a, b)$ then you can just apply the theorem on the interval $(a, c)$ or $(c, b)$ instead.
Your second thought is not actually describing a weaker condition for the theorem, since you require that $L$ be within the range of $g$ and the original theorem does not. However, with some adjustment you can again prove things as a corollary - if $L$ is not on the boundary of $f$, you should be able to define a subinterval $(a', b')$ such that the image $g((a', b'))$ is contained in some arbitrarily small neighbourhood of $L$ on which $f$ is defined, and where either $u = a'^+$ or $u = b'^-$ so that the theorem applies.
As for requiring $f$ be continuous, the problem is the same as any continuity problem - if $f(L) \neq \lim_{x \rightarrow L} f(x)$, then it doesn't matter how $x$ approaches $L$ you'll still get the wrong answer. For example, let $f(x) = 0$ everywhere except $f(0) = 1$. Then let $g(x)$ be defined so that $g(x) \neq 0$ when $x \in (a, b)$, and $\lim_{x \rightarrow u} g(x) = 0$. So then for any $x \in (a, b)$, you'll have $f(g(x)) = 0$, and hence $\lim_{x \rightarrow u} f(g(x)) = 0 \neq f(0) = 1$.
