$f(x) = 0$ when $x$ is $0$, and $1$ otherwise

You've already defined your function (assuming you've also chosen its domain).

One of the main ways to "create" a function is simply by specifying its values at all points, and your description has done so.

Typical notation for a function created by the sort of description you give is a definition by cases:

$$ f(x) := \begin{cases} 0 & x = 0 \\ 1 & x \neq 0 \end{cases} $$

For many applications — most applications, I expect — this is one of the best descriptions of said function. If need be, name it with a letter, and continue on with whatever you're doing.


The complementary function

$$ g(x) := \begin{cases} 1 & x = 0 \\ 0 & x \neq 0 \end{cases} $$

which is related to your function by $f(x) = 1 - g(x)$ comes up often enough in some contexts to have been given a name and notation: e.g.

  • The Kronecker delta. A few different notations exist depending on the setting; e.g. $\delta_x$, $\delta[x]$, or $\delta_{x,0}$.
  • The Iverson bracket. This would be notated $[x = 0]$. This notation is, IMO, indispensable for doing complicated calculations with summations.
  • x == 0 computes this function in C and C++, and many other programming languages allow similar.

Some applications might want to represent such a function in particular ways. For example, if one only cares about the value of $g(x)$ when $x$ is an integer, but strongly prefers to work with analytic functions (e.g. because you're studying a sequence using complex analysis), one has the fact that

$$ g(x) = \mathop{\mathrm{sinc}}(\pi x) $$

holds whenever $x$ is an integer.

(if you're unfamiliar with it, $\mathop{\mathrm{sinc}}(z)$ is the continuous extension of $\sin(z) / z$)


How about $f(x)=\left\lceil\frac{x^2}{x^2+1}\right\rceil$

*Works for real numbers, with imaginary numbers you may divide by 0.


How about $f(x)= 1-\delta_{x,0}$ (using the Kronecker Delta function, in Mathematica/WolframAlpha can write the $\delta_{x,0}$ as

kroneckerdelta(x,0)

)