Let $a>0$ be a real number, $f\colon \mathbb R \to \mathbb R$ a continuous function and $g\colon \mathbb R \to \mathbb R$ the function given by $$g(x)=\begin{cases} -a & if & f(x)<-a\\ f(x) & if & |f(x)|\le a\\ a & if & f(x)>a\\ \end{cases}.$$
Prove that $g$ is also a continuous function.
I managed to solve it with new function I assembled but maybe you will have better ideas.
thanks.
What's your try?
I would go to prove for arbitrary $x_0 \in \mathbb R$ that $g$ is continuous in $x_0$, that ir: $\lim_{x\to x_0} g(x) = g(x_0)$.
But what the value of $g(x_0)$ is depends on $f(x_0)$. In any case, the continuity of $f$ will be central.
If $|f(x_0)|<a$ (note that I said strictly smaller), then $g(x_0)=f(x_0)$, but what about the limit? Well, since $|f(x_0)|<a$, there has to be an open interval around $x_0$ for which this condition still holds, more precisely: $$ \exists \delta>0 \colon \qquad |f(x)|<a \quad \forall x\in (x_0-\delta,x_0+\delta).^*$$
But then $$ \exists \delta>0 \colon \qquad g(x)=f(x) \quad \forall x\in (x_0-\delta,x_0+\delta).$$ and so $g$ is continuous as $f$ is (they are the same function in an open interval, so their limits coincide in every points of it).
To complete the proof you have to say that if $f(x_0)>a$ or $f(x_0)<a$, there is an open interval on which that inequality holds and so $g(x)=\pm a$ on that open interval and so the limit is that same constant. And finally, you should work over the cases $|f(x)|=a$ combining ideas.
$^*$ This would be a more generic use of the so-called sign conservation property, which states that if $f$ is continuous at $x_0$ and $f(x_0)>0$, then $f(x)>0$ over an open interval containing $x_0$ too. The same is true for $f(x_0)<0$, of course, but is obviously false for $f(x_0)=0$. But the $0$ is arbitrary, and we could state the same property for any $a\neq 0$.