1
$\begingroup$

I'm looking for a simple function defined as: $$ f(x) = \begin{cases} 0, & \text{ when } x = 0, \\ C, & \text{ when }x \neq 0. \end{cases} $$

Basically, I only want the constant to matter if $x \neq 0$.

  • 0
    $|\mathrm{sign}(x)|$.2011-09-15
  • 14
    Of course, there is such a function; in fact, you just defined it! If you want a notation, I would suggest the straightforward one $\mathbf 1_{x \neq 0}$ or the Iverson bracket $[x \neq 0]$. :-)2011-09-15
  • 0
    |sign(x)| was what I was looking for. I got it confused with x/sqrt(x^2) which isn't defined for x=0.2011-09-15
  • 3
    Presumably you have a system that supports the $\mathrm{sign}$ function. But if you're doing this for programming purposes, what's wrong with `(x == 0 ? 0 : 1)`?2011-09-15

4 Answers 4