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

Glued along the rationals and the irrationals

#continuity#density#sequences#pathological functions

Statement

Let f,g:R→Rf,g:\mathbb{R}\to\mathbb{R} be continuous, and define h(x)=f(x)h(x)=f(x) if xx is rational, h(x)=g(x)h(x)=g(x) if xx is irrational. Prove that hh is continuous at a point x0x_0 if and only if f(x0)=g(x0)f(x_0)=g(x_0).

Hint

(⇒\Rightarrow) Approach x0x_0 along rationals and along irrationals. (⇐\Leftarrow) Use the definition with ε\varepsilon and take the smaller of two δ\delta.

Show solutionHide solution

Solution

(⇒\Rightarrow) Suppose hh is continuous at x0x_0. Take rationals rn→x0r_n\to x_0 and irrationals sn→x0s_n\to x_0 (possible by density). Then h(rn)=f(rn)→f(x0)h(r_n)=f(r_n)\to f(x_0) and h(sn)=g(sn)→g(x0)h(s_n)=g(s_n)\to g(x_0). By continuity of hh at x0x_0, both sequences h(rn)h(r_n) and h(sn)h(s_n) tend to h(x0)h(x_0). So f(x0)=h(x0)=g(x0)f(x_0)=h(x_0)=g(x_0).

(⇐\Leftarrow) Suppose f(x0)=g(x0)=:ℓf(x_0)=g(x_0)=:\ell. Then h(x0)=ℓh(x_0)=\ell whichever kind of number x0x_0 is. Let ε>0\varepsilon>0. By continuity of ff and gg at x0x_0 there exist δ1,δ2>0\delta_1,\delta_2>0 with ∣f(x)−ℓ∣<ε|f(x)-\ell|<\varepsilon when ∣x−x0∣<δ1|x-x_0|<\delta_1, and ∣g(x)−ℓ∣<ε|g(x)-\ell|<\varepsilon when ∣x−x0∣<δ2|x-x_0|<\delta_2. With δ=min⁡(δ1,δ2)\delta=\min(\delta_1,\delta_2), for ∣x−x0∣<δ|x-x_0|<\delta the value h(x)h(x) is either f(x)f(x) or g(x)g(x), so ∣h(x)−ℓ∣<ε|h(x)-\ell|<\varepsilon.

Example. If f(x)=xf(x)=x and g(x)=x2g(x)=x^2, then hh is continuous exactly at 00 and 11, where x=x2x=x^2.