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 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.

• I'm not sure if I understand the proof of why $x=0$ is not a local maximum or minimum..how does that fact you provided prove it? Could you add some more detail please? – Daniel Cook Oct 30 '13 at 18:46
• @extremez: Since $f(\frac{1}{n}) = \frac{1}{n}$ and $f(-\frac{1}{n}) = -\frac{1}{n}$, then in any neighborhood of $x=0$, there are points with value greater than and less than $f(0) = 0$. – copper.hat Oct 30 '13 at 18:49
• Alright thank you. I understand it now..but I have a feeling this might have something to do with first derivatives.. – Daniel Cook Oct 30 '13 at 18:57
• Well, this function is only continuous at $x=0$, and it is not differentiable there, so we can't use derivatives for this one... – copper.hat Oct 30 '13 at 18:59
• Glad to be able to help! – copper.hat Oct 30 '13 at 19:03

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$.

• Does this mean there are no local extreme points? – Daniel Cook Oct 29 '13 at 14:59
• Yes, indeed, that's what it means. – Ahaan S. Rungta Oct 29 '13 at 15:00
• Does a local minimum (or maximum) need to be strictly less (more) than its closest neighbours? – Henry Oct 29 '13 at 15:00
• If not then all the irrational values of $x$ correspond to local minima: the rely to "Are there values $z$ , as close as you like to $x$ , with $f(z) \lt f(x)$?" is "no" for irrational $x$ – Henry Oct 29 '13 at 15:03
• Some irrational $x$ – Empy2 Oct 29 '13 at 15:05