Given

Is there an easy way to define the condition as "rational" and "irrational" using PGF/TikZ? A minimal example would be greatly appreciated.
This is one of the rational/irrational graphs in Calculus by Michael Spivak book, page 97.

|
There is no way to represent graphically this function. Your drawing tool has a thickness. If you try representing the point (1/2,0) that belongs to the graph of the Dirichlet function and Apart from this, for this kind of drawings you need numbers in floating point representation, which are all rational; but not even all rational numbers in the interval [0,1] are representable in the computer as floating point numbers. Thus the best representation of this function you'd get would be two segments, which is useless. |
|||||||||||
|
Code
Output
|
|||
|
Since others have given their graphs, here is mine, and the rational behind it./ Given that
I would argue that a better representation of the given function is:
If you are concerned that you do not see the discontinuities, that just means that you have not zoomed in enough. :-) Keep zooming in and you will see the discontinuities. Code:
|
|||||||||||
|
|
Here's an option using
|
||||
|
|
It is the highest resolution I can achieve for you!
|
|||||||||||||||
|
=)– Jake Oct 29 '12 at 23:09