TITLE: Spivak - Chapter 7 Question 5 - Could f(x) be a function other than a constant function?
QUESTION [8 upvotes]: I'm self studying, and I was wondering if there were anything else that could be said about the following:
Suppose that $f$ is continuous on $[a,b]$ and that $f(x)$ is always rational. What can be said about $f$?
I said that $f$ could be a constant function, where $f$ equals a rational number $c$. From this, I said that it is then bounded above and below, and achieves a maximum and minimum value.
I was wondering if $f(x)$ could be a function that is not constant and is still continuous?

REPLY [10 votes]: If $f$ is not constant, then it has values $f(x_1)\ne f(x_2)$.  The intermediate value theorem then says it attains all values between $f(x_1)$ and $f(x_2)$.  So the problem is only to show that there must be some irrational number between $f(x_1)$ and $f(x_2)$.  Has Spivak posed an earlier exercise asking you to prove that between any two real numbers there is some irrational number?