# Prove that $f$ is continuous if and only if $f_+$ and $f_-$ are continuous

I am stuck with this problem for a while and can't seem to go any further:

Let $D \subset \Bbb R$ and $f:D \to \Bbb R$. Prove that $f$ is a continuous function if and only if $f_+: D \to \Bbb R$ and $f_-: D \to \Bbb R$ are continuous functions with:

$f_+(x):=\begin{cases}f(x), & \text{if } f(x)\ge0,\\0, &otherwise,\end{cases}$

$f_-(x):=\begin{cases}-f(x), & \text{if } f(x)\le0,\\0, &otherwise.\end{cases}$

My answer so far: I know that if two functions $f_+$ and $f_-$ are continuous, so are

• $f(x)=(f_+\pm f_-)$ and
• $f(x)=\max\{f_+,f_-\}$.

So I can say:

$f(x)=f_+(x)-f_-(x)$

• $f(x)\geq 0\begin{cases}f_+(x)=f(x)\\f_-(x)=0\end{cases}$
• $f(x)\leq 0\begin{cases}f_-(x)=-f(x)\\f_+(x)=0\end{cases}$
• $f(x)= 0\begin{cases}f_-(x)=0\\f_+(x)=0\Rightarrow|f(x)|=0=f(x)\end{cases}$

Any help to prove this is highly appreciated :)

Notice that $f^+=\max\{f,0\}$ and $f^-=\max\{-f,0\}$. If $g$ and $h$ are continuous functions, so is $$\max\{g,h\}=\frac{g+h+|g-h|}{2}.$$