Find a function \(f: \mathbb{R} \to \mathbb{R}\) that is continuous at precisely one point.
Solution
Define \(f\colon\mathbb R\to\mathbb R\) by \(f(x)=x\) for \(x\in\mathbb Q\) and \(f(x)=0\) for \(x\notin\mathbb Q\).
1. \(f\) is continuous at \(0\).
For every \(x\), \(\abs{f(x)-f(0)}=\abs{f(x)}\le\abs x\). Given \(\varepsilon>0\), take \(\delta=\varepsilon\): if \(\abs x<\delta\), then \(\abs{f(x)-f(0)}<\varepsilon\).
2. \(f\) is not continuous at any \(x_0\ne0\).
If \(x_0\in\mathbb Q\), choose irrationals \(y_n\to x_0\); then \(f(y_n)=0\not\to x_0=f(x_0)\). If \(x_0\notin\mathbb Q\), choose rationals \(q_n\to x_0\); then \(f(q_n)=q_n\to x_0\ne0=f(x_0)\). In both cases a sequence converging to \(x_0\) has images not converging to \(f(x_0)\).
3. Q.E.D.
By steps 1 and 2, \(f\) is continuous at \(0\) and at no other point.