General topology: metric space continuous function proof Let $f:X \to \mathbb{R}$ and $g:X \to \mathbb{R}$ be continuous functions where $X$ is a metric space. Prove that the function $h:X \to \mathbb{R}$ defined by
$h(x)$ = 
\begin{cases}
f(x),  & \text{if $f(x) \ge g(x)$} \\[2ex]
g(x), & \text{otherwise}
\end{cases}
is a continuous function.
This is my homework question, and isn't it obvious that this is true? How would you prove this? Thank you in advance..
 A: a composition of continuous functions is continuous so 
prove 
$$
Tx = (f(x),g(x))
$$
is continuous, and that the max function from $R^2$ to $R$ is continuous. For the latter express 
$$
\max(x,y) 
$$
in terms of $x,$ $y$ and $|x-y|$ and then it's obvious.
A: The result is valid for any topological space $X$. Continuity of a function $f$ has many consequences, and many of the consequences can be shown to imply continuity of $f$ and can be used as alternate, but equivalent, definitions of continuity. So there are often many ways to demonstrate continuity. 
(1). The usual start is to define continuity of $f:X\to Y$ to mean that whenever $V$ is an open set in the space $Y,$ then $f^{-1}V=\{x\in X:f(x)\in V\}$ is an open set in the space $X.$
(2).  We  define $f$ to be continuous at the point $p\in X$ to mean that whenever $f(p)\in V\subset Y,$ with $V$ open in $Y,$ then there exists open $U$ in $X$ with $p\in U,$ such that $f(U)=\{f(q):q\in U\}\subset V.$  ..... This is the topological generalization of the "$\epsilon$-$\delta$" def'n of continuity at $p$ when $f$ is a function on the reals. 
Then we can easily show that with respect to the def'n of continuity in (1), that $f:X\to Y$ is continuous iff $f$ is continuous at each point $p\in X.$
(3). Now for your Q.
For $p\in X$ let $V$ be an open subset of $\mathbb R$ such that $h(p)=\max (f(p),g(p))\in V.$ There exists $r>0$ such that $(-r+h(p),r+h(p))\subset V.$
Now, since $f$ and $g$ are continuous at $p,$ there exist open sets $U_f, U_g$ in $X ,$ each containing $p,$ such that $f(U_f)\subset (-r+f(p),r+f(p))$ and $g(U_g)\subset (-r+g(p),r+g(p)).$
So let $ U=U_f\cap U_g.$ Then $U$ is open in $X$ and $p\in U.$ We have $$q\in U\implies (f(q)<f(p)+r\land g(q)<g(p)+r)\implies h(q)<h(p)+r.$$ We have $$q\in U\implies f(q)>f(p)-r\land g(q)>g(p)-r\implies h(q)>h(p)-r.$$ So $q\in U\implies f(q)\in (-r+h(p),r+h(p))\subset V.$ That is, $h(U)\subset V.$ So $h$ is continuous at $p.$
A: One approach other than the $\epsilon$-$\delta$ proof is to view this as:
$$h(x)= \max(0, f(x)-g(x)) + g(x)$$
Since both $f,g$ continuous, so is $f-g$, and so is $\max(0, f-g)$, and so is $h$.
