Continuity of the following function Let $f:[a,b] \to \Bbb R$ be continuous . Define $g:[a,b] \to \Bbb R$ by $$g(x) = \sup[f(t) | t \in [a,x]].$$
Then is $g$ continuous? I tried to show the inequality $$|g(x)-g(y)| \le \sup(f(t) | t \in [x,y])$$ but wasn’t able to. Any hints or suggestions will be appreciated.
 A: Let $a\leqslant x\lt y$. Then 
$$
g(y)=\max\left\{\sup_{a\leqslant t\leqslant x}\left\lvert f(t)\right\rvert,\sup_{x\leqslant t\leqslant y}\left\lvert f(t)\right\rvert\right\}= \max\left\{g(x),\sup_{x\leqslant t\leqslant y}\left\lvert f(t)\right\rvert\right\}.
$$
We use the bound 
$$
\sup_{x\leqslant t\leqslant y}\left\lvert f(t)\right\rvert \leqslant \sup_{x\leqslant t\leqslant y}\left\lvert f(t)-f(x)\right\rvert+ \left\lvert f(x)\right\rvert\leqslant \sup_{x\leqslant t\leqslant y}\left\lvert f(t)-f(x)\right\rvert+g(x)
$$
in order to get 
$$
g(y)\leqslant \max\left\{g(x),g(x)+\sup_{x\leqslant t\leqslant y}\left\lvert f(t)-f(x)\right\rvert\right\}=g(x)+\max\left\{0,\sup_{x\leqslant t\leqslant y}\left\lvert f(t)-f(x)\right\rvert\right\}
$$
and since $g$ is non-decreasing, it follows that 
$$
\left\lvert g(y)-g(x)\right\rvert\leqslant \sup_{x\leqslant t\leqslant y}\left\lvert f(t)-f(x)\right\rvert.
$$
Now the continuity of $g$ follows from the uniform continuity of $f$: fix a positive $\varepsilon$ and choose $\delta$ such that if $a\leqslant t_1,t_2\leqslant b$ are such that $\left\lvert t_2-t_1\right\rvert\lt \delta$, then $\left\lvert f(t_2)-f(t_1)\right\rvert\lt \varepsilon$. 
If $a\leqslant x\lt y\leqslant b$ and $y-x\leqslant \delta$, the previous inequality shows that $\left\lvert g(y)-g(x)\right\rvert\leqslant\varepsilon$.
A: Your inequality is false. Suppose that $f:[0,1]\rightarrow \mathbf{R}$ is given by 
$$f(x) = 2x-1.$$
then $g(x) = 2x-1$. What is $|g(1/4)-g(3/4)|$ and what is $\sup\{f(t)\mid t\in [1/4,3/4]\}$?
For a given $x>0$ consider that $\exists \xi_x$ such that $f(\xi_x) = g(x)$ for every $x$ (why is that?). Suppose that $f(x)<f(\xi_x)$ then $f(x+\delta)<f(\xi_x)$ for $|\delta|<d$ where $d$ is sufficiently small (why is that?). Then $g$ is constant on $(x-d,x+d)$ and hence continuous.
Suppose now that $f(x) = f(\xi_x) = g(x)$, given $\varepsilon>0$ pick $\delta>0$ such that $|y-x|<\delta$ implies that $|f(x)-f(y)|<\varepsilon$. What can then be said about $\sup\{f(t)\mid t\in [0,x+\delta]\}$?
