TITLE: composition of continuous functions
QUESTION [9 upvotes]: I was wondering if a function $f:[a,b]\rightarrow[c,d]$ is continuous, $g:[c,d]\rightarrow\mathbb{R}$ is continuous, does it necessarily imply that $g\circ f$ is continuous? Are there counterexamples? What is the necessary and sufficient condition for $g\circ f$ to be continuous?
This is not HWQ. I am just wondering if that is possible.

REPLY [5 votes]: Here's the proof using the $ \varepsilon - \delta$ definition :
Fix $ \varepsilon > 0$. By the continuity of $g$ in $[c,d]$ which contains some points of $f([a,b])$ there exits $\gamma$ such that $d(g(y),g(f(q))) <  \varepsilon $ when $d(y,f(q)) < \gamma $ for some point $q\in[a,b]$ where $y\in f([a,b])$
Now since $f$ is continuous there exists $\delta > 0$ such that $d(f(x),f(q))< \gamma$ when $d(x,q)< \delta$ where $x\in [a,b]$ 
Let $h= f \circ g$ then from the above it follows that $d(h(x),h(q))=d(g(f(x)),g(f(q))) <\varepsilon$ when $d(x,q)< \delta$ . Hence $h=f \circ g$ is continuous

REPLY [4 votes]: One definition of continuity says $f$ is everywhere continuous if and only if for every open set $G$, the set
$$
\{ x\in\text{domain} : f(x) \in G\}
$$
is open.  So look at
$$
\{x : g(f(x))\in G\} = \{ x : f(x) \in \{ w : g(w)\in G\} \} = \{ x : f(x) \in H\},
$$
where $H=\{ w : g(w)\in G\}$.  The set $H$ is open because $g$ is continuous, and the last set mentioned above is open because $H$ is open.  Therefore the first set mentioned on the line above is open; therefore $g\circ f$ is continuous.
There's also the $\varepsilon$-$\delta$ definition of continuity, which readily defines the notion of continuity at a point $x$ in the domain.  Given $\varepsilon>0$, we seek $\delta>0$ so small that if the distance from $x$ to $y$ is less than $\delta$, then the distance from $g(f(x))$ to $g(f(y))$ is less than $\varepsilon$.  Given $\varepsilon>0$, the continuity of $f$ at $f(x)$ entails that there exists $\eta>0$ such that whenever the distance from $f(x)$ to $w$ is less than $\eta$, then the distance from $g(f(x))$ to $g(w)$ is less than $\varepsilon$.  Next, the continuity of $f$ at $x$ entails that there exists $\delta>0$ such that if the distance from $x$ to $y$ is less than $\delta$, then the distance from $f(x)$ to $f(y)$ is less than $\eta$.  The desired conclusion follows.  So if $f$ is continuous at $x$ and $g$ is continuous at $f(x)$, then $g\circ f$ is continuous at $x$.