Prove $f$ is discontinuous on $r_n$? 
Let $r_n$ be a sequence of all of the rational numbers and $$f(x)=\sum_{n:r_n<x}\frac{1}{2^n}.$$ Prove that 
  $f$ is continuous on the irrationals;$f$ is discontinuous on the rational; Calculate $\int_0^1 f(x)dx$?

I thought of writing $f=\sum \frac{1}{2^n} \chi_{(r_n,\infty)}.$ Then it is uniformly convergent as $n\to \infty$. 
Then how to proceed? Thanks for help!
 A: If none of $r_1,\ldots,r_m$ is between $x$ and $y$, then $$|f(x)-f(y)|\le\sum_{n>m}\frac1{2^n}=\frac1{2^m}\tag1$$
Let $x$ be irrational and $\epsilon>0$ given. Then according to $(1)$ we pick $m$ such that $\frac1{2^m}<\epsilon$ and then $\delta=\min\{|x-r_1|,\ldots,|x-r_m|\}$. This shows continuity at the irrationals.
On the other hand, if $x$ is rational, say $x=r_N$, then for any $\delta>0$ and $x-\delta<x_1<x<x_2<x+\delta$, we find $f(x_2)-f(x_1)\ge \frac1{2^N}$. Hence with $\epsilon<\frac1{2^{N+1}}$ we see that $f$ is not continuous at $x$.
The contribution of $r_n$ to $\int_0^1f(x)\,\mathrm dx$ is $0$ if $r_n\ge 1$, $\frac1{2^n}$ if $r_n\le 0$ and $(1-r_n)\frac1{2^n}$ if $0<r_n<1$. Hence
$$\int_0^1f(x)\,\mathrm dx =f(0)+\sum_{r_n\in[0,1]}(1-r_n)\frac1{2^n}.  $$
A: Hints
Let $x$ be a rational number, and let $n$ be so that $x=r_n$.
Show that for all $y >x$ we have $f(y) \geq f(x) +\frac{1}{2^n}$. Conclude that $f$ is discontinuous at $x$.
Let $x$ be an irrational number. 
Let $\epsilon >0$. Pick an $n$ such that $\sum_{k=n}^\infty \frac{1}{2^k} < \epsilon$.
Now pick $\delta$ such that
$$ 0 < \delta < \min_{k=1}^n \{ | x-r_k| \}$$
Note that $\delta$ exists by the irrationality of $x$.
Now show that 
$$|x-y| < \delta \Rightarrow |f(x) -f(y)| <  \sum_{k=n+1}^\infty \frac{1}{2^k} < \epsilon$$
A: Well, to show that $f$ is discontinuous at each rational, start by taking any rational $r_n$. Observe that for $x>r_n,$ $2^{-n}$ will be one of the summands of $f(x),$ but it will not be for $x\le r_n,$ and in particular, not for $x=r_n.$ What can you conclude, then, about $\lim_{x\searrow r_n}\bigl(f(x)-f(r_n)\bigr)?$
To show continuity at each irrational, a classic $\epsilon$-$\delta$ proof will do. Observe that for an irrational $x_0$ and any positive integer $N$, we can find $\delta>0$ sufficiently small so that $r_n\in(x_0-\delta,x_0+\delta)$ only if $n>N.$ This will help limit the variation in $f$ over the interval, and you can bound it using geometric series arguments.
A: Let $g(x) = 0, x\le 0, g(x) = 1, x >0.$ Then
$$f(x) = \sum_{n=1}^{\infty} \frac{g(x-r_n)}{2^n}.$$
By the Weierstrass M-test, the series is unformly convergent on $\mathbb {R}.$ If $x$ is irrational, then each summand is continuous at $x,$ hence so is $f$ by the standard continuity/uniform-convergence result. If $x=r_{n_0},$ then write
$$ f(x) = \frac{g(x-r_{n_0})}{2^{n_0}} + \sum_{n\ne n_0}^{\infty} \frac{g(x-r_n)}{2^n}.$$
By the reasoning above, the infinite sum on the right is continuous at $r_{n_0},$ while the first term has a jump discontinuity at $r_{n_0}.$ It follows that $f$has a jump discontinuity at $r_{n_0}.$
As for $\int_0^1f,$ we should first observe $f$ is Riemann integrable on $[0,1]$ because $f$ is the uniform limit of RI functions (or just note that $f$ is increasing). By the standard result on integration/uniform-convergence, we get
$$\int_0^1f(x)\,dx = \sum_{n=1}^{\infty} \int _0^1 \frac{g(x-r_n)}{2^n} = \sum_{r_n<0}\frac{1}{2^n}+ \sum_{0\le r_n<1}\frac{1-r_n}{2^n}.$$
