TITLE: Extending continuous functions from $\mathbb Q$ to $\mathbb R$
QUESTION [6 upvotes]: Definitions:
Let $E$ be a subset of $X$. By an extension of a function $f: E \to \mathbb R$, I mean a function $\bar f: X \to \mathbb R$ such that $f = \bar f$ on $E$.

Question: For every continuous function $f: \mathbb Q \to \mathbb R$, does there exist an extension $\bar f: \mathbb R \to \mathbb R$ that is continuous at each $q \in \mathbb Q$?

In other words, can every continuous function on the rationals be extended to a function on the reals that is continuous at every rational point?

REPLY [13 votes]: You may extend by upper limit.
Details.
Denote $g(y)=\limsup_{x\to y, x\in \mathbb{Q}} f(x)$ for all real $y$. So, possibly $g$ takes the value $+\infty$ or $-\infty$ at some points. But we have $g(x)=f(x)$ for rational $x$, and for each rational $x$ and each $\varepsilon>0$ there exists $\delta>0$ such that $|g(y)-f(x)|<\varepsilon$ whenever $|y-x|<\delta$, in particular $g(y)\ne \pm \infty$ if $|y-x|<\delta$. Thus if we replace all infinite values of $g$ to 0, $g$ remains continuous at rational points.