1
$\begingroup$

This question is very similar to my previous one. I have: $s \in [0;100]$ and $s \in Z$. The piece-wise definition is as follows: $20 \le s \le 100 \to 0\\ 10 \le s \lt 20 \to 1\\ s \le 9 \to 2\\ $

Following the previous question's answers my best try was this:

$\displaystyle f(s) = 2 - \left \lfloor \frac{s}{10} \right \rfloor + H \left (\left \lfloor \frac{s}{10} \right \rfloor - 3 \right ) \cdot \left ( \left \lfloor \frac{s}{10} \right \rfloor - 2 \right )$

where $H(x)$ is the Heaviside Step Function. That involves too many calculations. There must be something simpler, I'm just too blind to see it

  • 0
    @copper.hat: Well I didn't even know such characteristic functions existed! I'd have called that definition piece-wise as well.2012-10-11

2 Answers 2

3

With this definition of the Heaviside step function you may use for example : $f(s)=\left(2-\left \lfloor \frac s{10}\right \rfloor\right)\operatorname{H}(19-s)$ or the simple : $f(s)=\operatorname{H}(9-s)+\operatorname{H}(19-s)$

  • 0
    @rubik: Agreed (I was influenced by your divisions by $10$ first and had to get out of the attractor :-))2019-01-19
2

$f(s)=1-\text{sgn}(\lfloor s/10-1 \rfloor)$

  • 1
    Interesing idea with the sign function!2012-10-10