# Counter example for $\lim \limits_{x \to a}g(f(x))$ = $g(\lim \limits_{x \to a}(f(x))$

I have been trying to think about conterexample for $\lim \limits_{x \to a}g(f(x))$ = $g(\lim \limits_{x \to a}(f(x))$ for a while but every time I get an equality on both sides, I know that there should be a counter example, any help?

• $g(x)$ must be discontinous at $a$. – Rene Schipperus Feb 8 '15 at 16:55
• A counterexample cannot be built if you use $g$ as a continuous function. – Crostul Feb 8 '15 at 16:55
• @ReneSchipperus No: At $f(a)$. – k.stm Feb 8 '15 at 16:55
• @k.stm Yes your right, I had $f(x)=x$ in mind. – Rene Schipperus Feb 8 '15 at 16:57
• Try $g = \Theta(x)$ with $\Theta(x)$ is the Heaviside function with a jump at $x=0$. You can set for example $f(x) = x^2+3x+1$. What you will have for $x \rightarrow 0$? – kryomaxim Feb 8 '15 at 16:57

The equality $$\lim_{x \to a}g(f(x)) = g\left(\lim_{x \to a} f(x)\right)$$ holds only if one of the following conditions is satisfied:

• $g$ is continuous;
• $g$ never assumes the value $f(a)$ (for example when $f(a) \notin \operatorname{dom} g$).

Consider, for example: $$\lim_{x \to 0^+}\operatorname{sgn}(\sin x) = 1 \neq 0 = \operatorname{sgn}\left(\lim_{x \to 0^+} \sin x\right)$$ where $$\operatorname{sgn} x = \begin{cases} 1 & x > 0\\ 0 & x = 0\\ -1 & x < 0 \end{cases}$$

• the conditions that you posed , it was based on intuition or you proved them ? – avz2611 Feb 8 '15 at 17:47
• We proved them during a lesson, but the proof is not very simple. Intuition should be enough to get a grasp of why the conditions are there. – rubik Feb 8 '15 at 20:04
• Yeah by intuition it's clear, but the.fact that no condition exists other than the ones stated bugs me a little – avz2611 Feb 9 '15 at 1:31

Take the following functions:

$g(x)$:

if $x\in\mathbb{R}\setminus \{a\}$ then $g(x)=1$, if $x\notin\mathbb{R}\setminus\{a\}$, then $g(x)=0$.

and $f(x)=x$ for all $x\in\mathbb{R}$.

Then the left hand side becomes $1$ and the right hand side becomes $0$.

As noted in the comments, a counterexample requires $g$ to be discontinuous at $f(a)$.

define $f(x) = 0$ if $x$ is rational and $f(x) = 1$ if $x$ is irrational. And define $g(x) = 1$ if $x$ is rational, $g(x) = 0$ if $x$ is irrational. Check $\lim_{x\rightarrow 0}f(g(x)) = 0$, while $\lim_{x\rightarrow 0}g(f(x)) = 1$