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

  • 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

7

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.

  • 0
    @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.2011-09-15
3

You had just defined it :-)

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

1

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

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!