Why $\max\{f,g\}$ is continuous if $f$ and $g$ are continuous? Let $f,g:\mathbb{R}\to \mathbb{R}$ be continuous functions. I need to prove that $x\mapsto \max\{f(x),g(x)\}$ is continuous without using the fact that $\max\{a,b\}=\frac{a+b+|a-b|}{2}$.
Let $\varepsilon >0$ and $a\in\mathbb{R}$. Suppose, without loss of generality, that $f(a)\leq g(a)$. There is $\delta >0$ such that $|f(x)-f(a)|<\varepsilon $ and $|g(x)-g(a)|<\varepsilon $ when $|x-a|<\delta $. I'm trying to prove that $$\lvert\max\{f(x),g(x)\}-g(a)\rvert<\varepsilon,$$
but I really have problems. I know that $\max\{f(x),g(x)\}=f(x)$ or $g(x)$, and thus $$\lvert\max\{f(x),g(x)\}-g(a)\rvert=\begin{cases}|f(x)-g(a)|\\ \text{or} \\ |g(x)-g(a)|\end{cases},$$
but I can't write it down rigorously since the fact that $\max\{f(x),g(x)\}=f(x)$ or $g(x)$ depend on $x$.
 A: Suppose that $f(a)>g(a)$. Then there exists $\delta>0$ such that, for $a-\delta<x<a+\delta$, $f(x)>g(x)$ (can you prove it?). Therefore $\max\{f(x),g(x)\}$ is the same as $f$ in a neighborhood of $a$, so it is continuous at $a$. The same if $g(a)>f(a)$.
Thus we're left with the case $f(a)=g(a)=b$. Fix $\varepsilon>0$; then there exists $\delta>0$ such that, for $a-\delta<x<a+\delta$,
$$
|f(x)-b|<\varepsilon,\qquad |g(x)-b|<\varepsilon
$$
or
$$
b-\varepsilon<f(x)<b+\varepsilon,\qquad b-\varepsilon<g(x)<b+\varepsilon
$$
Can you finish?
A: Try considering two cases: $f(a)=g(a)$ and (WLOG) $f(a)<g(a)$. In the first case, use the same reasoning until your bracket, where you won't have problems to finish the work since $|f(x)-g(a)|$ becomes $|f(x)-f(a)|$. In the second case, try to prove that there is a $\delta$ such that $\max\{f,g\}(x)=g(x)$ on $|x-a|<\delta$, then conclude by continuity of $g$.
A: Rather straightforward:
Let $\epsilon$ be given
For $\epsilon/2$  there are  $\delta_{1,2}$ s.t.
$|x-x_0| < \delta = \min \delta_{1,2}$ implies
$|f(x)-f(x_0)| < \epsilon/2$ , and $|g(x)-g(x_0)| < \epsilon/2$.
Then 
$|x-x_0| \lt \delta$ implies
$(1/2)|f(x)+g(x)+|f(x)-g(x)|- f(x_0)-g(x_0)-|f(x_0-g(x_0)|| $
$\le (1/2)|f(x)-f(x_0)| +$
$(1/2)|g(x)-g(x_0)| +$
$(1/2)||f(x)-g(x)| -$
$|f(x_0)-g(x_0)||$
$\le (1/2)(\epsilon/2) +(1/2)(\epsilon/2) + (1/2)|(f(x)-g(x))-(f(x_0)-g(x_0))| $
$\le \epsilon/2 + (1/2)|f(x)-f(x_0)| +(1/2)|g(x)-g(x_0)| \lt  \epsilon.$
Used: Continuity of $f,g$; triangle inequality, reverse triangle inequality.
