# Counter example with limit of functions

Let's say we have $f$, $g$ such that $\lim_{x\to a}f(x) = b$ and $\lim_{x\to b} g(x) = c$.

I would like to see an example when $g(f(x))$ does not tend to $c$ as $x \to a$.

A friend of mine suggested the following, but we are curious if we can find something simpler.

$$f(x) = \begin{cases} 0 & x \in \mathbb{Q}\\ \frac{1}{n} & x \in A_n \end{cases}$$

where $A_n = (\mathbb{R}\setminus\mathbb{Q})\cap\left(\frac{-1}{n}, \frac{1}{n}\right)\setminus\left[\frac{-1}{n+1}, \frac{1}{n+1}\right]$ and

$$g(x) = \begin{cases} 1 & x = 0\\ x & \textrm{otherwise} \end{cases}.$$

-

Take $$f(x)=2012\ \forall x\in \mathbb{R}$$ and $$g(x)=\begin{cases}x&\mbox{if, } x\neq 2012\\ 2013&\mbox{if, } x=2012\end{cases}$$ Then $\lim_{x\to 2012}f(x)=2012$, $\lim_{x\to 2012}g(x)=2012$ while $$g(f(x))=2013\ \forall x\in \mathbb{R}$$ and so $\lim_{x\to 2012}g(f(x))=2013$ (I hope you like the choice of numbers)