1
$\begingroup$

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?

$\endgroup$
  • $\begingroup$ What is your criterion for simplicity? $\endgroup$ – Rob Arthan Aug 25 '16 at 23:01
  • $\begingroup$ @RobArthan I would imagine something convenient to use. $\endgroup$ – The Great Duck Dec 2 '16 at 22:45
  • $\begingroup$ 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). $$ $\endgroup$ – Sangchul Lee Dec 8 '16 at 1:47
0
$\begingroup$

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$."

$\endgroup$
  • $\begingroup$ If it is not quite the same, then you should delete your answer or find a logical way to express it fully. $\endgroup$ – The Great Duck Dec 4 '16 at 22:53
0
$\begingroup$

Modification of my answer here:

$$U_a(x)=\left\lfloor4\dfrac{\tan^{-1}(x+1-a)+\pi}{5\pi}\right\rfloor$$

edit: Here's another

$$U'_a(x)=\left\lfloor \dfrac{2^{x-a}-2^{-x+a}}{2^{x-a}+2^{-x+a}}+1\right\rfloor $$

$\endgroup$
  • $\begingroup$ I wouldn't really consider arctan to be a simple function... Perhaps you could try to get rid of arctan to make it more convenient? $\endgroup$ – The Great Duck Dec 4 '16 at 22:55
  • $\begingroup$ It is an elementary function, by definition. A synonym for elementary is simple. $\endgroup$ – David Peterson Dec 7 '16 at 5:33
  • $\begingroup$ arctan is by no means a simple function to deal with in my opinion. elementary just means that the function results from precalculus rather than resulting from integrals/sums having no closed form. $\endgroup$ – The Great Duck Dec 7 '16 at 6:10
  • 1
    $\begingroup$ I'm not sure I agree that arctan is not simple. However I've posted an alternative. $\endgroup$ – David Peterson Dec 8 '16 at 1:28
-1
$\begingroup$

This is a simple form that be expressed as the following:

$$U(X) = \left\lfloor \frac {x-a}{\sqrt{(x-a)^2 +1}} \right\rfloor + 1$$

It is easy enough to see why if you know the graph of $\frac{x}{\sqrt{x^2 + 1}}$ and you know how to apply a translation to a function.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.