Let \(f\) be a function on the closed interval \([0,1]\) defined by
\(f(x)=x \) if \(x\) is rational and \(f(x)=x^2\) if \(x\) is irrational.
Then \(f\) is continuous at 0 and 1.
Use the sequence criterion for continuity.
Let \(x_n\) be a sequence converging to \(0\). Then \(x_n^2\) also converges to \(0\). Since the value of \(f\) at \(x_n\) is either of the two, \(f(x_n)\to 0\) as \(n\to \infty \). If this seem confusing, think in terms of \(\epsilon \). For \(\epsilon >0 \), there exists \(n_1\) and \(n_2\) such that \(|x_n|< \epsilon \) and \(|x_n^2|< \epsilon \) for \(n>n_1\) and \(n>n_2\) respectively. Taking the maximum of \(n_1\) and \(n_2\) we get the N for which the condition in “epsilon definition” is satisfied.
The same argument applies for the continuity at 1.
The function is not continuous at any other point. Because if a rational sequence and an irrational sequence converge to \(x_0\) and the function is continuous at that point then by sequential criterion, \(f(x_0)=x_0\) due to the rational sequence and also \(f(x_0)=x_0^2\) due to the irrational sequence. Therefore, \(x_0^2=x_0\) and hence the only possible points of continuity is \(0\) or \(1\).