# Is composition of surjective continuous function with discontinuous function discontinuous?

Let $$I_1,I_2,I_3$$ be intervals $$\subset \mathbb{R}$$. Suppose $$f:I_1 \to I_2$$ is a surjective continuous function and $$g: I_2 \to I_3$$ is a discontinuous function. Must the composition $$g \circ f$$ be discontinuous?

There are some easy counter-examples if $$f$$ is not assumed to be surjective, e.g. taking $$f$$ to be a constant function, or in a way that "dodges" the discontinuous point(s) of $$g$$.

However if such "dodging" is prohibited, I fail to construct such functions nor find an answer from many similar questions on this site. So I am interested to know whether counter-examples exist? If not, is there a proof? Does it have something to do with intermediate value theorem?

Here is a proof without compactness of the intervals.

Suppose that $$f$$ and $$g\circ f$$ are continuous, $$f$$ is surjective. I want to show that $$g$$ is continuous.

Take $$x\in I_2$$ and a sequence $$(x_n)$$ in $$I_2$$ with $$x_n\to x$$. Since $$I_2$$ is an interval, there are $$x' in $$I_2$$ such that $$x\in [x',x'']\subset I_2$$ and $$x_n\in[x',x'']$$ for all $$n$$. (If this would not be possible, then $$I_2$$ would be a singleton.)

Since $$f$$ is surjective, there are $$y,y',y''$$ in $$I_1$$ such that $$f(y)=x$$, $$f(y')=x''$$, $$f(y'')=x''$$. Define the interval $$J:=[\min(y,y',y''),\ \max(y,y',y'')]$$. Due to the intermediate value theorem $$f(J) \supset [x',x'']$$.

Now for every $$n$$ there is $$y_n\in J$$ with $$f(y_n)=x_n$$. Since $$J$$ is compact, there is a converging subsequence $$(y_{n_k})$$ with limit $$z$$. By continuity of $$f$$, $$f(z)=x$$. Then by continuity of $$g\circ f$$ $$g(x_{n_k}) = g(f(y_{n_k})) \to g(f(z)) = g(x).$$ Now, we can repeat this argument for each subsequence of $$(x_n)$$. The limit $$g(x)$$ does not depend on the chosen subsequence, so $$g(x_n)\to g(x)$$, and $$g$$ is continuous.

Can this proof be generalized to higher dimensions?

If $$g$$ is discontinuous at $$x=a$$, then $$gf$$ cannot be continuous. Suppose $$gf$$ is continuous. For any sequence $$\{x_n\}\in I_2, x_n\to a$$, due to the surjectivity of $$f$$, $$\exists \{y_n\}\in I_1, f(y_n)=x_n,\forall n$$.

$$y_n\in I_2$$ which is compact, so there must be a subsequesce $$y_{n_k}$$ that converges. Let $$\lim_{k\to \infty}y_{n_k}=L$$.

Since $$f$$ is continuous, $$f(L)=\lim_{k\to \infty} f(y_{n_k})=\lim_{k\to \infty}x_{n_k}=\lim x_n=a$$. Also, $$gf(L)=g(a)$$.

So, $$\lim g(x_n)=\lim gf(y_{n_k})=gf(L)=g(a)$$, thanks to the continuity of $$gf$$.

The result is that we establish the continuity of $$g$$ from the continuity of $$f$$ and $$gf$$. So $$gf$$ cannot be continuous.

• $y_n$ has to be in $I_1$. Also compactness of $I_1$ is required.
– daw
May 23, 2019 at 7:47
• @daw But everybody knows it, so no need to write that down.... May 23, 2019 at 10:25
• @daw Ok I will add it. Please tell me anything else that is inaccurate in my answer. May 23, 2019 at 14:38

Given that $$g$$ is discontinuous there exists $$x_0 \in I_2$$ and a sequence $$(x_n)_{n \in \mathbb{N}} \subseteq I_2$$ such that $$\lim\limits_{n \to \infty}x_n = x_0$$ and $$g(x_0) \neq \lim\limits_{n \to \infty}g(x_n)$$. Now let $$y_0 \in f^{-1}(x_0)$$ and for any $$n \in \mathbb{N}$$ let $$y_n \in f^{-1}(x_n)$$ be given. It follows \begin{align*} (g \circ f)(y) = g(x_0) \neq \lim\limits_{n \to \infty} g(x_n) = \lim\limits_{n \to \infty} (g \circ f)(y_n). \end{align*} We have therefore shown that $$g\circ f$$ is discontinuous at $$y$$.

• Who says $\lim_{n\to\infty}y_n$ has anything to do with $y$ (or $y_0$, you used both names for the same variable)? May 22, 2019 at 12:51
• Without showing that $\lim_{n\to\infty} y_n=y_0$, this doesn't prove that $g\circ f$ is not continuous.
– 5xum
May 22, 2019 at 13:07
• I guess @neca has choosen the preimages wiseley and just forgot to tell us.
– Jupp
May 22, 2019 at 15:15