Can any functions be expressed in one formula? (without conditions)

124 Views Asked by At

This is the extension of my previous inquiry:

Is it possible to describe the Collatz function in one formula?


Can each of all functions be expressed in one formula? That is, can any function expressed with conditions(e.g. modular or interval conditions) be expressed without conditions or sub-functions?

For example, conditional function f(x) which $$f\left(n\right) = \begin{cases} 0 &\text{if } x<-1\\ 1 & \text{if } -1≤x<0 \\ 2 & \text{if } 0≤x<1 \\ 3 & \text{if } 1≤x \end{cases}$$ Can be described by

$$f\left(x\right)=\left[\arctan \left(x\tan \left(1\right)\right)\right]+2$$

2

There are 2 best solutions below

4
On

You can probably find a clever formula to express the step function $H(x)=[x\ge0]$. $H(x)=\dfrac{x+|x|}{2x}$ almost does it. See also Iverson bracket.

Given that, then:

  • $H(x-a)$ is the characteristic function of $[a,\infty)$
  • $H(a-x)$ is the characteristic function of $(-\infty,a]$
  • $H(x-a)(b-x)$ is the characteristic function of $[a,b]$

and so any function that is defined piecewise can be written using a linear combination of suitable $H$: if your function is equal to $h(x)$ in an interval $[a,b]$, just add $H(x-a)(b-x)h(x)$.

For instance, your function is $$ H(-1-x)\cdot 0+ H(x+1)H(0-x)\cdot 1+ H(x-0)H(1-x)\cdot 2+ H(x-1)\cdot 3 $$

But it does not seem worth the trouble when the piecewise definition is so much clearer.

2
On

If you allow the floor function (as you do in your example), one can easily express indicator fucntions of intervals: $${\bf 1}_{[0,\infty)}(x) =\begin{cases}1&\text{if $x\ge0$}\\0&\text{if $x<0$}\end{cases}=1+\left\lfloor\frac{x}{2+x^2}\right\rfloor$$ and then $$\begin{align} {\bf 1}_{[a,\infty)}(x)&={\bf 1}_{[0,\infty)}(x-a)\\ {\bf 1}_{(-\infty,a)}(x)&=1-{\bf 1}_{[a,\infty)}(x)\\ {\bf 1}_{(a,\infty)}(x)&={\bf 1}_{(-\infty,-a)}(-x)\\ {\bf 1}_{(-\infty,a]}(x)&={\bf 1}_{[-a,\infty)}(-x)\\ {\bf 1}_{[a,b]}(x)&={\bf 1}_{[a,\infty)}(x)\cdot{\bf 1}_{(-\infty,b]}(x)\\ {\bf 1}_{(a,b]}(x)&={\bf 1}_{(a,\infty)}(x)\cdot{\bf 1}_{(-\infty,b]}(x)\\ {\bf 1}_{[a,b)}(x)&={\bf 1}_{[a,\infty)}(x)\cdot{\bf 1}_{(-\infty,b)}(x)\\ {\bf 1}_{(a,b)}(x)&={\bf 1}_{(a,\infty)}(x)\cdot{\bf 1}_{(-\infty,b)}(x)\\ \end{align}$$ so that we can express indicator functions of arbitrary intervals. Then in principle you can build your function by multiplying with such indicator functions. However, you may need to be careful with psrts that areundefined in points outside the interval they are used in.