Finding all local maximum and minimum points of function If $$f(x) = \left\{\begin{array}{lr} x, \ \text {if x is rational}, \\ 0, \ \text {if x is irrational}, \end{array}\right. $$
Find all local maximum and minimum points of $f(x)$.
How can I go about doing this, since it's not a normal kind of function where I can differentiate and find the critical points? 
 A: If $x$ is rational, so $f(x)=x$, are there values $y$, as close as you like to $x$, with $f(y)>f(x)$?  Are there values $z$, as close as you like to $x$, with $f(z)<f(x)$?.
Then ask the same questions for irrational $x$.
A: A local minimizer is a point $\hat{x}$ for which there exists some neighbourhood $U$ of $\hat{x}$ in which $f(x) \ge f(\hat{x})$ for all $x \in U$. Similarly for a local maximizer. This characterization holds regardless of how smooth $f$ is.
It would help to visualize the function:

We have $f(0) = 0$, $0 \le f(x) \le x$ for all $x >0$ and $x \le f(x) \le 0$ for all $x <0$. In addition, in any neighbourhood, $f$ attains these values. 
From the picture, we see that $x=0$ is neither a local minimizer or maximizer, and for $x>0$, $f$ has no local maximizers and for $x<0$, $f$ has no local minimizers. However, for $x>0$, any irrational $x$ is a local minimizer and similarly, for $x<0$, any irrational $x$ is a local maximizer.
To prove this, we note that $f(\pm \frac{1}{n}) = \pm \frac{1}{n}$, and $f(0) = 0$, which shows that $x=0$ is neither a local minimizer or maximizer.
For $x>0$, we have $f(x) \ge 0$. If $x$ is irrational, then $f(x) = 0$, and hence $x$ is a local minimizer. Since any rational $y$ in the neighbourhood of $x$ has $f(y) >0$, we see that $x$ is not a local maximizer. If $x$ is rational, then $f(x) = x$, and since $f(x+\frac{1}{2}) = x+\frac{1}{2} > f(x)$, we see that $x$ is not a local maximizer. Similarly, at any irrational $y$ in a neighbourhood of $x$, we have $f(y)= 0 < f(x)$, we see that $x$ is not a local minimizer.
Since $f(-x) = -f(x)$, the same reasoning above applies, mutatis mutandis.
