we know, the Dirichlet function as: $$ f(x) = \begin{cases} 1, &\text{if } x \text{ is irrational; and } \\ 0, &\text{if }x \text{ is rational}. \end{cases} $$ R.A. Silverman in his book Modern Calculus says that this wild function cannot be plotted at all while M.R.Spiegel in the book Advanced Calculus constructed a graph of $f(x)$ as two parallel lines with $x$-axe, gone via $1$ and $0$. The second athour says: The graph is shown in the adjoining Fig. 2-3. From its appearence it would seem that there are two functional values $0$ and $1$ corresponding to each value of $x$, i.e. that $f(x)$ is multiple-valued, whereas it is actually single-valued. What happens in these two point of views?
[Math] Graph of the Dirichlet Function
calculus
Related Solutions
We only need to check this for irrational numbers (since they are continuity points).
So let $x_0\notin\mathbb Q$. We ask whether the limit $$\lim_{x\to x_0} \frac{f(x)-f(x_0)}{x-x_0}$$ exists.
Now, if $x\notin\mathbb Q$ then $\frac{f(x)-f(x_0)}{x-x_0}=0$.
For rationals we use Dirichlet's approximation theorem: For a given irrational $x_0$, the inequality $$\left| x_0 -\frac{p}{q} \right| < \frac{1}{q^2}$$ is satisfied by infinitely many integers p and q.
Now, for given $\varepsilon>0$ we can choose q such that $\frac1{q^2}<\varepsilon$ and thus $\left| x_0 -\frac{p}{q} \right| < \frac{1}{q^2} < \varepsilon$.
For $x=\frac pq$ we get $$\left|\frac{f(x)-f(x_0)}{x-x_0}\right| = \frac{\frac1q}{\left|x_0 -\frac{p}{q}\right|} > \frac{\frac1q}{\frac1{q^2}} = q.$$
This shows that $\frac{f(x)-f(x_0)}{x-x_0}$ is unbounded in any neighborhood of $x_0$ (since $q$ can be chosen arbitrarily high).
After answering the question I tried to google for differentiable "thomae function". Already the first result provides the following article - containing a much simpler proof:
- Kevin Beanland, James W. Roberts and Craig Stevenson: Modifications of Thomae's Function and Differentiability, The American Mathematical Monthly, Vol. 116, No. 6 (Jun. - Jul., 2009), pp. 531-535. link at author's blog, jstor.
(I saw that I need large denominators, which reminded me of Dirichlet and I overlooked the simple way.)
A little later I've noticed that the simple proof was already suggested in one of joriki's comments - which I've overlooked too.
I think it's worth mentioning different names used for this function (personally, I like popcorn function) - I quote from Wikipedia:
Thomae's function, named after Carl Johannes Thomae, also known as the popcorn function, the raindrop function, the ruler function, the Riemann function or the Stars over Babylon (by John Horton Conway) is a modification of the Dirichlet function.
As other answers have Henning's answer has explained already, your teacher is wrong. However, my guess is that s/he was confusing your function with this related one:
$$
f(x) = \begin{cases}
0, &\text{ if $x$ is irrational},
\\\\
1/b, &\text{ if $x = a/b$ with $\gcd(a,b)=1$}.
\end{cases}
$$
This function does have the property that it is continuous at all irrational points, and discontinuous at the rationals.
Source: Look at the "modified Dirichlet function" $D_M(x)$ in the Mathworld article on the Dirichlet function.
Edit: It turns out that @lhf posted the same answer independently, but he links to the Wikipedia page of the function: click here.
Terminology: I just learned1 that this function is usually called Thomae's function, and not the modified Dirichlet function. I have known this example for some time, but not by any specific name. Wikipedia lists a number of other interesting names as well: the Riemann function, the popcorn function, the Stars over Babylon, the raindrop function, and the ruler function.
1In the post what functions or classes of functions are Riemann non-integrable but Lebesgue integrable, Hans Lundmark's comment (under Jonas Meyer's answer) gives the name of the function and the wikipedia link. Thanks to Theo Buehler for sharing the post.
Best Answer
Silverman would deny that this picture counts as "plotting" the function. What look like two solid lines are actually not solid at all: the top line contains only points whose $x$ coordinate is irrational, and the bottom line contains only points whose $x$ coordinate is rational. These facts are impossible to show in a picture.