Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|cite|improve this question
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:[{{1%2C+x+%3D%3D+Floor[x]}}%2C+0] – Bill Cook Oct 18 '11 at 13:26

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

share|cite|improve this answer
I am amused that Alpha claims a numercal root at $x=1.1$ – Ross Millikan Oct 17 '11 at 20:54
This is supposed to be equivalent, but somehow the expected gaps don't show up... – J. M. Oct 17 '11 at 23:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.