The following are problems and solutions from Spivak's Calculus that I have difficulty understanding.
(1) $f(x)= 0$ if $x$ is irrational, $1/q$ if $x=p/q$ in lowest terms.
(2) $f(x)= 1$, if the decimal expansion of $x$ contains a $5$, $0$ otherwise.
The solution from the text says that for (1), all irrational $x$ are local minimum points, and all rational $x$ are local maximum points. However, in order to be a local max or minimum, the point needs to have the greatest or smallest value in some interval, yet by density of rationals and irrationals, every interval contains infinitely many rationals, so I don't see how any rational point is a local maximum.
Meanwhile, for (2), the text says that $x$ is a local minimum point if its decimal expansion does not contain a $5$. It is a local maximum point if its decimal expansion contains exactly one $5$ that is followed by an infinite string of $9's$. In all other cases, $x$ is both a local maximum point and a local minimum point.
In this case, I don't understand the reasoning behind choosing a point that contains exactly one $5$ that is followed by an infinite string of $9's$ and how this point actually is a local maximum. Also, why would all other points, for instance a number with two $5's$ in its decimal expansion, be both a local maximum and minimum.
I would appreciate any explanations to these questions.