How do I plot the following multi case function in wolfram or geogebra?

$$ \begin{eqnarray*} f(x) = \begin{cases} 1, &\text{if }x \text{ is an integer}, \\ 0, &\text{if }x \text{ is not an integer}. \end{cases} \end{eqnarray*} $$

The graph would be dots and underscores?

  • 2
    $\begingroup$ Here's a piecewise defined function (but the graph isn't what you want -- I'd like to know how to do that as well): "Piecewise[{{1, x == Floor[x]}}, 0]" Link: wolframalpha.com/input/?i=Piecewise[{{1%2C+x+%3D%3D+Floor[x]}}%2C+0] $\endgroup$
    – Bill Cook
    Commented Oct 18, 2011 at 13:26

1 Answer 1


I can't quite do that with a nice picture, but the reverse works more or less with ceiling(x)-floor(x) and looks like

enter image description here

  • $\begingroup$ I am amused that Alpha claims a numercal root at $x=1.1$ $\endgroup$ Commented Oct 17, 2011 at 20:54
  • $\begingroup$ This is supposed to be equivalent, but somehow the expected gaps don't show up... $\endgroup$ Commented Oct 17, 2011 at 23:48

Not the answer you're looking for? Browse other questions tagged .