Let $f:[a,b]\to\Bbb R$ be a continuous function and$g:[a,b]\to\Bbb R, g(x)=\sup\{f(t):a\le t\le x\}.$ Show $g$ is a continuous function over $[a,b]$ I am a 31-year-old college student trying to study from some practice exam materials that my professor has given me. I will include an example of one of the problems I am struggling with.

Let $f: [a,b] \rightarrow  \Bbb R$ be a continuous function and define $$g: [a,b] \rightarrow \Bbb R, \quad g(x)= \sup\{f(t): a\leq t\leq x\}.$$

I am supposed to show that $g$ is a continuous function over $[a,b]$. I recall doing this by showing that $g$ is a monotone function or something along those lines but I am not quite sure how to proceed with this.
I am stuck with what it is exactly that I need to show to prove that g is continuous.
 A: We need for all $\epsilon$ a $\delta$
$$|g(x)-g(x+h)|<\epsilon, |\delta|<h$$
$$\Leftrightarrow |\sup\{f(t): a\leq t\leq x\}-\sup\{f(t): a\leq t\leq x+h\}|<\epsilon, h<|\delta|$$
Immediately by continuity we have a $\delta$ such that $$|f(x)-f(x+h)|<\epsilon/2, h<|\delta|$$
$$...\leq|\sup\{f(t): a\leq t\leq x\}-\sup\{f(t): a\leq t\leq x\}|+|\epsilon/2|<\epsilon, h<|\delta|$$
A: Clearly $g$ is monotonic increasing. Therefore, for any $x\in(a,b)$,
the left-hand limit $g(x-)=\lim_{y\rightarrow x-}g(y)$ and right-hand
limit $\lim_{y\rightarrow x+}g(y)$ exist. Moreover, $g(x-)\leq g(x)\leq g(x+)$
and $g$ is continuous at $x$ iff $g(x-)=g(x+)$.
Let $x_{0}\in(a,b)$. We go to prove that $g$ is continuous at $x_{0}$.
Prove by contradiction. Suppose that $g$ is not continuous at $x_{0}$,
then $l:=g(x_{0}+)-g(x_{0}-)>0$. Since $f$ is continuous at $x_{0}$,
we may choose $\delta>0$ such that $|f(x)-f(x_{0})|<\frac{l}{4}$
whenever $x\in(x_{0}-\delta,x_{0}+\delta)$. For any $x\in[a,x_{0}+\frac{\delta}{2}]$,
if $x\in[a,x_{0}]$, we clearly have $f(x)\leq g(x_{0})$. If $x\in(x_{0},x_{0}+\frac{\delta}{2}]$,
then $f(x)\leq f(x_{0})+\frac{l}{4}\leq g(x_{0})+\frac{l}{4}$. Hence,
$f(x)\leq g(x_{0})+\frac{l}{4}$ for all $x\in[a,x_{0}+\frac{\delta}{2}]$.
That is, $g(x_{0}+\frac{\delta}{2})\leq g(x_{0})+\frac{l}{4}$.
For any $x\in[a,x_{0}]$, if $x\in[a,x_{0}-\frac{\delta}{2}]$, then
$f(x)\leq g(x_{0}-\frac{\delta}{2})$. If $x\in(x_{0}-\frac{\delta}{2},x_{0}]$,
then
\begin{eqnarray*}
|f(x)-f(x_{0}-\frac{\delta}{2})| & \leq & |f(x)-f(x_{0})|+|f(x_{0})-f(x_{0}-\frac{\delta}{2})|\\
 & < & \frac{l}{2}.
\end{eqnarray*}
Therefore, $f(x)\leq f(x_{0}-\frac{\delta}{2})+\frac{l}{2}\leq g(x_{0}-\frac{\delta}{2})+\frac{l}{2}$. Hence $f(x) \leq g(x_{0}-\frac{\delta}{2})+\frac{l}{2}$ for all $x\in[a,x_{0}]$. It follows that $g(x_{0})\leq g(x_{0}-\frac{\delta}{2})+\frac{l}{2}$.
Finally,
\begin{eqnarray*}
l & = & g(x_{0}+)-g(x_{0}-)\\
 & \leq & g(x_{0}+\frac{\delta}{2})-g(x_{0}-\frac{\delta}{2})\\
 & = & [g(x_{0}+\frac{\delta}{2})-g(x_{0})]+[g(x_{0})-g(x_{0}-\frac{\delta}{2})]\\
 & \leq & \frac{l}{4}+\frac{l}{2}\\
 & < & l,
\end{eqnarray*}
which is a contradiction.
The proof for the case that $x_{0}=a$ or $x_{0}=b$ can be modified
accordingly.
