When trying to determine the limit of a composite function, \(\displaystyle \lim_{x\to a}\, f(g(x))\), knowing if (or where) the outer function \(f\) is continuous can greatly simplify the process:

We know in general that if the function \(f\) is continuous everywhere, then we can use Direct Substitution to evalute any limit for it, and in particular:

So in effect, we have “brought the limit inside”, and we can now focus on finding this “inner” limit.

If we’re extremely lucky, the inside function \(g\) will in fact also be continuous (or at least continuous at \(x=a\)), and we could therefore simply use Direct Substitution (“plugging in” \(x=a\)) - which would mean that we effectively did an overall Direct Substitution, but doing two steps in one.

But often, this doesn’t happen, and we will need extra care to determine the inner limit:

### Example 1:

Using Direct Substitution right away would give \(\sin(\frac{0}{0} )\), which is indeterminate, meaning we can’t decide yet what this is.

But we know that \(\sin(x)\) is continuous for all real values \(x\), so we can bring in the limit:

And using a side calculation, we can now determine this inside limit \(L\) (hoping that it exists):

So the limit we actually want is: \(\sin(L)=\boxed{\sin(5)}\).

## A small technical issue:

If \(f\) is **not** continuous everywhere, we actually need to know whether it
is continuous at \(x=L\) **before** we can “bring in the limit”! In practice, this
means that we use “wishful thinking” and simply first evaluate the “inner”
limit \(\displaystyle L=\lim_{x\to a} g(x)\), and (assuming this limit exists)
then double-check whether \(f(x)\) is continuous at \(x=L\): In the case it is, we
can then use Direct Substitution to write \(\displaystyle \lim_{x\to a} f(g(x)) = f(L)\).

### Example 2:

In this case, we know that \(\tan(x)\) is not continuous everywhere (in fact,
\(\tan(x)=\frac{\sin(x)}{\cos(x)}\) has vertical asymptotes whenever
\(\cos(x)=0\), which happens when \(x=\frac{\pi}{2}+k\pi\) where \(k\in
\mathbb{Z}\)) - so we can only “bring in the limit” if we know that we’re not
actually at any of those “bad” \(x\)-values. So, *hoping* that this won’t be the
case, we **first** find the “inner” limit (which is the same as what we had in the
previous example):

And now we can verify that \(x=5\) is not one of the “bad” values for the tangent function - and so we can in fact (as we hoped) bring in the limit:

\(\displaystyle \lim_{x\to 4} \ \tan\Bigl( \frac{x^2-3x-4}{x-4} \Bigr) = \tan\Bigl( \lim_{x\to 4}\ \frac{x^2-3x-4}{x-4} \Bigr) = \tan(L) = \boxed{\tan(5)}\)

### Example 3:

In this case, we again evalute the inner limit first, in the hope things will work out. In this case, \(g\) is actually continuous at \(x=-1\), so we can use Direct Substitution:

But now we have a problem: \(\cot(x)\) is **not** continuous at \(x=L=0\)! (In fact,
\(\cot(x)=\frac{\cos(x)}{\sin(x)}\) has vertical asymptotes whenever
\(\sin(x)=0\), which happens at all multiples of \(\pi\), i.e. when \(x=k\pi\) for
\(k\in \mathbb{Z}\).)

So we are in fact **not** allowed to bring in the limit in this case, and so
we need to use different techniques to determine what happens here!

(It turns out that this composite function does in fact have a *vertical
asymptote* at \(x=-1\), and in particular \(\lim_{x\to -1^{-}} f(g(x))=-\infty\)
and \(\lim_{x\to -1^{+}} f(g(x))=+\infty\). There are many ways to see this,
the easiest being to observe that away from \(x=4\), we actually have \(g(x)=
\frac{(x+1)(x-4)}{x-4}=x+1\), and so we are actually considering the much
simpler function \(\cot(x+1)\) (for \(x\neq 4\)). But the graph of \(y=\cot(x+1)\) is
simply the graph of \(y=\cot(x)\) shifted one unit to the left, so we get a
vertical asymptote at \(x=-1\). You could (and should) verify this by looking
at the graph of this function, for example on
Desmos.)