# If composition of two functions $f,g$ is continuous, does that imply continuity of both $f$ and $g$? [closed]

If the composition $$f\circ g$$ of $$f$$ and $$g$$ is well defined and is continuous, does that necessarily imply that $$f$$ is continuous and $$g$$ is continuous?

## closed as off-topic by Lee David Chung Lin, Paul Frost, RRL, clathratus, mrtaurhoFeb 11 at 23:31

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question is missing context or other details: Please provide additional context, which ideally explains why the question is relevant to you and our community. Some forms of context include: background and motivation, relevant definitions, source, possible strategies, your current progress, why the question is interesting or important, etc." – Lee David Chung Lin, Paul Frost, RRL, clathratus, mrtaurho
If this question can be reworded to fit the rules in the help center, please edit the question.

No

Counterexample: $$f$$= every discontinuous bijection, $$g=f^{-1}$$

• Some more surprising counterexample? That almost works? – kjetil b halvorsen Feb 10 at 11:43
• How do you define "almost"? – YuiTo Cheng Feb 10 at 11:45
• Maybe something which is continuous in all but a few points? – kjetil b halvorsen Feb 10 at 11:57
• Then you just plug in your function as $f$ and its inverse as $g$, as long as it's a bijection. – YuiTo Cheng Feb 10 at 11:59

No. Let$$\begin{array}{rccc}f\colon&\mathbb R&\longrightarrow&\mathbb R\\&x&\mapsto&\begin{cases}1&\text{ if }x=0\\0&\text{ otherwise}\end{cases}\end{array}$$and let $$g\colon\mathbb{R}\longrightarrow\mathbb R$$ by any discontinuous function such that $$0$$ doesn't belong to its range. Then $$f\circ g$$ is continuous (it is constant, actually), but both $$f$$ and $$g$$ are discontinuous.

If you use the Dirichlet function for both $$f$$ and $$g$$:

$$f \circ g$$ is continuous (it's actually constant, $$x \rightarrow 1$$), but both $$f$$ and $$g$$ are nowhere continuous.