Proving a function is continuous on all irrational numbers

This is a part of my answer here, but it should completely answer your questions too.

I use the notation $$\lim_{y\to x^{+}}f(y)=f(x^+)$$ $$\lim_{y\to x^{-}}f(y)=f(x^-)$$


There is a very nice way of constructing, given a sequence $\{x_n\}$ of real numbers, a function which is continuous everywhere except the elements of $\{x_n\}$ [That is, discontinuous on a countable set $A\in\Bbb R$]. Let $\{c_n\}$ by any nonnegative summable sequence [that is $\sum\limits_{n\geq 0} c_n$ exists finitely], and let $$s(x)=\sum_{x_n<x} c_n$$

What we do is sum through the indices that satisfy the said inequality. Because of absolute convergence, order is irrelevant. The function is monotone increasing because the terms are nonnegative, and $s$ is discontinuous at each $x_n$ because $$s(x_n^+)-s(x_n^-)=c_n$$

However, it is continuous at any other $x$: see xzyzyz's proof with the particular case $c_n=n^{-2}$. In fact, this function is lower continous, in the sense $\lim\limits_{y\to x^{-}}f(y)=f(x^-)=f(x)$ for any value of $x$. If we had used $x_n\leq x$, it would be upper continuous, but still discontinuous at the $x_n$.

To see the function has the said jumps, note that for $h>0$, we have $$\begin{align} s(x_n^+)-s(x_n^-)&=\\ \lim_{h\to 0^+} s(x_k+h)-s(x_k-h)&=\lim_{h\to 0^+}\sum_{x_n<x_k+h} c_n-\sum_{x_n<x_k-h}c_n\\&=\lim_{h\to 0^+}\sum_{x_k-h\leq x_n<x_k+h} c_n\end{align}$$

and we can take $\delta$ so small that whenever $0<h<\delta$, for any given $x_m\neq x_k$, $x_m\notin [x_k-\delta,x_k+\delta)$, so the only term that will remain will be $c_k$, as desired.


Here's an easy reason why this is true: look at the interval from 0 to 1. there are only finitely many fractions with a given base between 0 and 1. There is only one with base 2, (I.e, 1/2), two with base 3, etc. so as you approach any irrational number by a sequence , that sequence is going to run out of all the fractions with small bases.

The same thing is true as you approach any rational number; so in either case, the limit as you approach a number is 0. Since that agrees with the function for irrationals, it's continuous there. Since it disagrees at a rational, it's discontinuous.