Maths WorkshopMaths problems with full solutions
Exercise 354Calculus › Single-variable calculus › Continuity › Continuous and discontinuous functionsL1Added 2 Nov 2026

A continuous function that vanishes on the rationals

#density#continuity#sequences

Statement

  1. Let f:R→Rf:\mathbb{R}\to\mathbb{R} be continuous with f(q)=0f(q)=0 for every rational qq. Prove that f=0f=0.
  2. Deduce that two continuous functions f,gf,g which agree on Q\mathbb{Q} are equal.
Hint

Every real number is a limit of rational numbers (for instance its decimal truncations). Use the sequential characterisation of continuity.

Show solutionHide solution

Solution

1. Let x∈Rx\in\mathbb{R}. Take qn=⌊10nx⌋10nq_n=\dfrac{\lfloor 10^nx\rfloor}{10^n}, a rational number with x−10−n<qn≤xx-10^{-n}<q_n\le x, so qn→xq_n\to x. Since ff is continuous at xx, f(qn)→f(x)f(q_n)\to f(x). But f(qn)=0f(q_n)=0 for all nn, so f(x)=0f(x)=0.

2. Apply part 1 to the continuous function f−gf-g, which vanishes on Q\mathbb{Q}.

Remark. A continuous function is entirely determined by its values on a dense set. This is the principle used to define axa^x for real xx: we know aqa^q for rational qq, and there is only one continuous way to fill the gaps. Without continuity the statement is false: the Dirichlet-type function 1R∖Q\mathbf 1_{\mathbb{R}\setminus\mathbb{Q}} vanishes on Q\mathbb{Q} without being 00.