# Step function without piece wise definition

Usually I would think of a step function in terms of a piece wise definition:

$$U(x) = \begin{cases} 1 & x \ge a\\ 0 & x < a\end{cases}$$

Can I write it in a way that does not require a piece wise definition or logic statements? For example, you could write the absolute value function in a way that does not require conditional statements by defining $|x| = \sqrt{x^2}$. Similarly, you can get the min or max of two numbers without using logic operations by following: How to calculate Maximum or Minimum of two numbers without using if? I'm looking for the same idea but for the step function. Wikipedia has some continuous approximations, and also alternative definitions like the integral of a Dirac delta function: https://en.wikipedia.org/wiki/Heaviside_step_function, but I'm wondering if there is anything simpler?

• What is your criterion for simplicity? Aug 25, 2016 at 23:01
• If you do not care about the value at $x = 0$, then you can simply use the expression $$\frac{1}{2}(1 + \operatorname{sign}(x)) = \frac{1}{2}\left(1 + \frac{x}{\sqrt{x^2}} \right).$$ Dec 8, 2016 at 1:47

$$U_a(x)=\left\lfloor4\dfrac{\tan^{-1}(x+1-a)+\pi}{5\pi}\right\rfloor$$
$$U'_a(x)=\left\lfloor \dfrac{2^{x-a}-2^{-x+a}}{2^{x-a}+2^{-x+a}}+1\right\rfloor$$
If you are ok with using derivatives, you can write $$U_a(x) = \frac{1}{2}+\frac{1}{2}\frac{d}{dx}|x-a|,$$ and, as you noted, $|x-a| = \sqrt{(x-a)^2}$. Of course, this fails to be defined at $x=a$, so is not quite the same as your "$U_a(x) = 1 \text{ if } x\geq a$."