2
$\begingroup$

I found this exercise in Demidovich's "Problems in Mathematical Analysis", and found it quite interesting.

Write the function $$ f(x) = \begin{cases} 0, & \text{if $x \leq 0$} \\ x, & \text{if $x > 0$} \end{cases} $$ as a single formula using the absolute value sign.

I've posted my solution below.

2 Answers 2

3

Answer

$$f(x) = \frac{x + \lvert x \rvert}{2}$$


Explanation

When $x \leq 0$, $x + \lvert x\rvert = 0$, rendering the $\text{RHS} = 0$.

When $x > 0$, $x + \lvert x \rvert = 2x$. So, it must be divided by $2$ for $\text{RHS} = x$.

2

It seems natural to generalize this problem to:

Write the function $$ f_{ab}(x) = \begin{cases} ax, & \text{if $x \leq 0$} \\ bx, & \text{if $x > 0$} \end{cases} $$ as a single formula using the absolute value sign.

Having done so:

  • Notice that the slope of $f_{ab}$ jumps by $(b-a)$ at $0$; $f_{ab}$ is smooth elsewhere. The slope of the absolute value function changes by $2$ at $0$, suggesting that we consider the function $$ g_{ab}(x)=f_{ab}(x)-\frac{b-a}{2}|x| $$ which will "smooth out" $f$ at $0$.

  • Having noticed this, it's not too hard to check by case analysis that in fact $$ g_{ab}(x)=\frac{b+a}{2}x $$ and so $$ f_{ab}(x)=\frac{b+a}{2}x + \frac{b-a}{2}|x| $$

When $a=0$ and $b=1$ as in the original problem, this reduces to the solution in the other answer.