Maths WorkshopMaths problems with full solutions
Exercise 720Calculus › Single-variable calculus › Continuity › Intermediate Value TheoremL1Added 2 Nov 2026

A continuous function with rational values is constant

#intermediate value theorem#rational numbers#proof by contradiction

Statement

Let f:[0,1]→Rf:[0,1]\to\mathbb{R} be continuous and suppose f(x)f(x) is rational for every xx. Prove that ff is constant.

Hint

Argue by contradiction. If f(a)≠f(b)f(a)\ne f(b), what does the intermediate value theorem say about the values between them?

Show solutionHide solution

Solution

Idea. A continuous function cannot skip any value between two of its values. But the rational numbers have gaps: between two rationals there are irrational numbers.

Proof. Suppose f(a)≠f(b)f(a)\neq f(b) for some a,b∈[0,1]a,b\in[0,1], say f(a)<f(b)f(a)<f(b). The interval (f(a),f(b))\bigl(f(a),f(b)\bigr) contains an irrational number yy (for example f(a)+22 (f(b)−f(a))f(a)+\frac{\sqrt2}{2}\,\bigl(f(b)-f(a)\bigr), which lies strictly between since 0<22<10<\frac{\sqrt2}2<1, and is irrational because f(b)−f(a)f(b)-f(a) is a non-zero rational).

By the intermediate value theorem on the interval between aa and bb, there is cc with f(c)=yf(c)=y. But f(c)f(c) is rational and yy is not. Contradiction.

Conclusion. f(a)=f(b)f(a)=f(b) for all a,ba,b, so ff is constant.

Remark. The same argument shows that a continuous function with values in Z\mathbb{Z} is constant, and more generally that a continuous function on an interval cannot take only values in a countable set unless it is constant.