# Is there such a function: $f = \{0 \text{ when } x=0, 1 \text{ when } x ≠0 \}$?

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

-
$|\mathrm{sign}(x)|$. –  Guess who it is. Sep 15 '11 at 15:00
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]$. :-) –  Srivatsan Sep 15 '11 at 15:02
|sign(x)| was what I was looking for. I got it confused with x/sqrt(x^2) which isn't defined for x=0. –  moevi Sep 15 '11 at 15:16
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)? –  Guess who it is. Sep 15 '11 at 15:22

## 4 Answers

Yes, there certainly is such a function! The notion that a function has to be defined by some sort of 'formula' is thoroughly out of date -- you can define a function to be anything you like, as long as it has an unambiguous value for each of its arguments.

You forgot to specify what the possible arguments of this function are, so -- to be complete -- you need to do that. Do you want your function to be defined on the set of real numbers? Then you should say so.

-
+1 is thoroughly out of date: More precisely, that occured around 1750-1800 (Euler still had it not entirely clear) gap-system.org/~history/HistTopics/Functions.html –  leonbloy Sep 15 '11 at 15:12
@leonbloy: I would say that your link misses the point entirely: that a function from $D$ to $R$ is a subset of $D\times R$ that satisfies some simple conditions. This is obviously (with the benefit of hindsight!) a much better definition than any of those given there. The set-theoretic definition of Patrick Suppes that is given at the end is in the spirit of "gosh, look at this!", and no attempt is made to make sense of it. So the page gets a B- from me. –  TonyK Sep 15 '11 at 15:27

You had just defined it :-)

What about $f(x) = C \cdot \mathrm{sign}(|x|)$?

-

You can define your function $f: \Bbb R \longrightarrow \{0, 1\}$ as follows: $f(0) = 0$ and $f(x) = 1$ for $x \neq 0$.

-

You can write it as $C\cdot(1-\delta_0)$ where $\delta_0(x)=1$ if $x=0$ and otherwise $\delta_0(x)=0$.

Generally speaking, though, functions do not need to be defined by a formula. Most functions, in fact, cannot be defined by formulas. Function is some sort of a machine which is designed to result in a particular output when entered a particular input. What's inside? Magic!

-