TITLE: If $f,g$ are continuous at $a$, show that $h(x)=\max\{f(x),g(x)\}$ and $k(x)=\min\{f(x),g(x)\}$ are also continuous at $a$
QUESTION [11 upvotes]: If $f,g$ are continuous at $a$, show that $h(x)=\max\{f(x),g(x)\}$ and $k(x)=\min\{f(x),g(x)\}$ are also continuous at $a$. Here is my attempt at a proof. It feels very elaborate and I am not sure if it is correct. Can someone please point out any mistakes or places where I may improve. Thanks!
By the definition of continuity at $a$ of $f,g$ we have that $\lim\limits_{x\to a}f(x)=f(a)$ and $\lim\limits_{x\to a}g(x)=g(a)$. Suppose that $f(a)>g(a)$. Then there exists a $\delta>0$ such that $f>g$ for all $x$ satisfying $|x-a|<\delta$. Then for $x$ satisfying $|x-a|<\delta$ we have $h(x)=f(x)$ and $k(x)=g(x)$ and thus $h$ and $k$ are continuous at $a$ because $f$ and $g$ are continuous at $a$. Now if $f(a)<g(a)$ we simply relabel $f=\tilde{g}$ and $g=\tilde{f}$, so that $\tilde{f}(a)>\tilde{g}(a)$ and we apply the previous result to show that again $h$ and $k$ are continuous at $a$.\
Now if $f(a)=g(a)$ then we can distinguish three cases. $f\geq g$ in a small neighborhood about $a$, $f\leq g$  in a small neighborhood about $a$ or $f\geq g$ on one side of $a$ and $f\leq g$ on the other side. In the first case we assume that $f\geq g$ in some small neighborhood about $a$. Then, since $f(a)=g(a)$ we have $h(x) = f(x)$ in this neighborhood and $k(x) = g(x)$ and again we see that $h$ and $k$ are continuous at $a$ due to the continuity of $f$ and $g$ at $a$. Similarly if $f\leq g$ in a neighborhood around $a$ then $h(x)=g(x)$ and $k(x)=f(x)$ in this neighborhood and $h$ and $k$ are continuous at $a$. 
Suppose that just to the left of $a$ we have $f\geq g$ and just to the right of $a$ we have $f\leq g$. Then $\lim\limits_{x\to a^-}h(x)=\lim\limits_{x\to a^-}f(x)=f(a)=h(a)=g(a)=\lim\limits_{x\to a^+}g(x)=\lim\limits_{x\to a^+}h(x)$. Similarly $\lim\limits_{x\to a^-}k(x)=\lim\limits_{x\to a^-}g(x)=g(a)=k(a)=f(a)=\lim\limits_{x\to a^+}f(x)=\lim\limits_{x\to a^+}k(x)$. So $\lim\limits_{x\to a}h(x)=h(a)$ and $\lim\limits_{x\to a}k(x)=k(a)$ which means that $h$ and $k$ are continuous at $a$. Lastly if $f\leq g$ just to the left of $a$ and $f\geq g$ just to the right of $a$ we can relabel $f=\tilde{g}$ and $g=\tilde{f}$ and apply the last result to show $h$ and $k$ are continuous at $a$. 
Again, please point out any mistakes I may have made. Thanks!!

REPLY [3 votes]: In general: if a function $h$ can be written as a composition
$h=u\circ v$ of continuous functions $u$ and $v$ then it is continuous. 
In general: if $Y\times Z$ is equipped with the producttopology then a function $v=\left(v_{1},v_{2}\right):X\rightarrow Y\times Z$
is continuous if $v_{1}$ and $v_{2}$ are continuous.
Here you can
take $u=\max:\mathbb{R}^{2}\rightarrow\mathbb{R}$ and $v:\mathbb{R}\rightarrow\mathbb{\mathbb{R}}^{2}$
defined by $x\mapsto\left(f\left(x\right),g\left(x\right)\right)$.
It appears to be enough to prove $u=\max:\mathbb{R}^{2}\rightarrow\mathbb{R}$ is continuous, and the same procedure works for $\min:\mathbb{R}^{2}\rightarrow\mathbb{R}$.
This makes
things less complicated.