Functions – Function Defined Everywhere but Continuous Nowhere

continuityfunctions

I have been recently reading about the Weierstrass function, a function that is continuous everywhere but differentiable nowhere. It made me think of a similar puzzle involving functions: find $f: \mathbb R \to \mathbb R$ such that $f$ can be computed anywhere, is well defined, but is continuous nowhere.

I first thought of maybe mapping the reals on to a fractal and doing something with that point but that’s just a fuzzy idea and I doubt one could compute it everywhere. In my research I could find no such function that is defined for all real numbers, both rational and irrational. If anyone has a proof this is impossible (or even just an idea of how you might prove that), or an example of a function that has those properties, that would be great.

Best Answer

First off, the "majority" of functions (where majority is defined properly) have this property, but are insanely hard to describe. An easy example, though, of a function $f:\mathbb R\to\mathbb R$ with the aforementioned property is $$f(x)=\begin{cases}x&x\in\mathbb Q\\x+1&x\notin\mathbb Q\end{cases}$$This example has the added benefit of being a bijection!

Related Question