Defining a piecewise function using restricted operations

Question

Can the piecewise function

$$f(x) = \begin{cases} 0 & \text{if $x > 0$} \\ 1 & \text{if $x = 0$} \\ 0 & \text{if $x < 0$} \\ \end{cases}$$

be defined using only the operations $+ , -, *, /, |\cdots|, \max$, and $\min$?


What I have tried

I can define the first and last pieces: $0$ if $x > 0$ or $x < 0$ with

$$1 - \frac{x}{x}$$

But this will fail with a division by $0$ in the case where $x = 0$

$$1 - \frac{0}{0}$$

I can fix the division error by forcing a 1 on the bottom.

$$a(x) = 1 - \frac{x}{\max(1, x) \min(-1, x)}$$

This works for most negatives and $0$ and fails when $-1 < x < 0$ and $x > 0$. When $x > 0$, $a(x) = 2$. Fixing this requires another max to check a number is positive. Defining $b(x)$ to be $2$ when $x > 0$ and $0$ when $x = 0$ or $x <= -1$

$$b(x) = 2\frac{\max(0, x)}{\max(1, x) \min(-1, x)}$$

Combining them to get

$$c(x) = a(x) - b(x) = 1 - \frac{x - 2\max(0, x)}{\max(1, x) \min(-1, x)}$$

This mess is what I want except when $-1 < x < 0$ and $0 < x < 1$. This is as far as I have gotten.


Solution 1:

Let's do algebra on functions, by defining for functions $f$ and $g$, $(f+g)(x) = f(x) + g(x)$, and so on with other operators.

Note that $f$ is not a continuous function. However, $+$, $-$, $\times$, $|\dots|$, $\max$ and $\min$ all produces continuous function if you provide them continuous function. Since all you base functions, $x \mapsto x$ and the constant functions $x \mapsto c$, are continuous on $\mathbb R$, you won't be able to create a non-continous function with finitely many operators.

That leaves only the division $\frac{\dots}{\dots}$, which is continuous on $\mathbb R \setminus \{ 0 \}$. However it is undefined on $0$, which means that either you would be left with undefined values, which you cannot since $f$ is defined everywhere, or your denominator is guaranteed to be all positive (or all negative) and the division will operate only on a fully continuous component and your result will again be continuous.

On $\mathbb R$, your problem cannot be solved with finitely many operations of $+$, $-$, $\times$, $\frac{\dots}{\dots}$, $|\dots|$, $\max$ and $\min$.

Solution 2:

Following Lærne's answer, I would like to elucubrate on how the problem coould be solved with infinite operations.

Let then define $$ g(x) = \max (0, - \vert x \vert +1)$$ This is a "tent" function, that equals $0$ if $\vert x \vert > 1$, and equals $1$ for $x = 0$, being continuous and piecewise linear.

An approximation to the function $f$ indicated by the OP can be built to any degree of accuracy as $$f(x) \approx g(x)^n $$ (intuitively speaking, where $f(x) = 0$ or $f(x) = 1$ nothing happens upon multypling, while for any $x : 1 < g(x) < 1 , \,\,\, g(x)^k < g(x)^j $ when $ k > j$)

Fellow Mathstackexchangers more versed on convergence issues could maybe formalise the limiting operation. I believe $g^n \to f$ pointwise as $n \to \infty$.