For irrational numbers, the value of f(x) is zero, and for rational numbers (other than 0), it's 1 over the denominator in reduced terms, so for instance f(1/5) = f(2/5) = f(3/5) = 1/5.
Between any two real numbers, there is a rational number, and between any two real numbers, there is an irrational number, so there are two things to notice here, to wit:
- the x-axis is extra black because there are infinite irrational points on this interval [0, 1] that are irrational so that f(x) = 0
- points below 0.1 on the y axis aren't shown, but would continue this sort of ever-thickening pyramid structure all the way down
When Newton and Leibniz invented caculus, they conceived of integration solely as using antiderivatives. That is, if you have two functions, F and f, such that the slope of F at a point x is the value of f(x) -- i.e., F'(x) = f(x) -- then f is the derivative of F, and F is the antiderivative of f. By the Fundamental Theorem of Calculus, you can use an antiderivative to calculate a definite integral of f - that is, to find the area under the f(x) curve between two points (the area of S in this picture):
Now, obviously, you can't conceive of integration in quite the same way for something like Thomae's function. It can't possibly have an antiderivative - even if you can make a function with that kind of infinitely discontinuous slope, which I can't imagine you could, it wouldn't have a derivative.
So in the 19th century, a different way of conceiving of integrals was conceived. In calculus, you learn about Riemann sums. Basically, if you divide the area under the curve into vertical boxes, and then calculate the area of each box, that's an approximation of the area under the curve. The more boxes you have, the closer your approximation gets to the actual value, and the limit of those approximations is the area under the curve, as in this picture:
It turns out that using a method similar to this, Thomae's function can be integrated on the interval [0, 1]. The method is called "Darboux Sums."
One question when you use Riemann sums is how to calculate the height of each box. An easy way to do it is to use the leftmost or rightmost edge of the box as the height. As long as you use some method, it actually doesn't really matter what it is -- the approximations will still get better and better -- but Darboux does it a particular way.
Specifically, for Darboux sums you get an upper sum and a lower sum. For the upper sum, you use, as the height of each box, the highest value inside of that box, and for the lower sum, you use the lowest value inside of each box. You then add up the areas of all of the boxes, and that gives you an upper sum and a lower sum for the integral.
What next? Darboux's Criterion for Integrability is a theorem that says that if, given an error amount (epsilon), there is a way to divide up the function (i.e., a placement of the boxes - they don't all have to be the same width) such that the difference between the upper and lower sums is less than epsilon, the function is integrable.
If we apply this method to Thomae's function, no matter how we partition the function, the lower Darboux sum will always be 0, because every interval will contain irrational numbers. Since, if it's integrable, the upper sum has be able to be made arbitrarily close to the lower sum, it's clear that, if we can integrate Thomae's function on [0, 1], the result (the area under the "curve," if you will) must be 0.
And it turns out that we can indeed get the upper sum to be as close as we want to 0 (though never actually 0 - but that is never required in calculus, which deals in limits). I won't go through the proof of that, but it relies on the fact that, basically, if you draw a horizontal line somewhere above 0 in this function, there will only be a finite number of points above that line. Then you can just make the boxes that contain those points skinny enough that their overall area is arbitrarily low, and there you go.