Prove that for the given enumeration of rationals and a sequence of positive reals that sum to $1$, $h$ is Riemann integrable and determine integral

Here is the question:

Let $$\left\{q_1, q_2, \ldots\right\}$$ be an enumeration of all rational numbers in the interval $$[0,1]$$. This means that $$q_k$$'s are rational numbers in $$[0,1]$$ and that every rational number $$q$$ in $$[0,1]$$ is equal to exactly one $$q_k$$. Now for any $$x \in[0,1]$$, let $$S_x=\left\{k: q_k \leq x\right\}$$. Fix a sequence $$\left\{p_n\right\}_{n \geq 1}$$ of strictly positive real numbers such that $$\sum_n p_n=1$$. Define a function $$h:[0,1] \rightarrow[0,1]$$ by $$h(x)=\sum_{k \in S_x} p_k$$. In other words, $$h(x)$$ is the sum of $$p_k$$ 's where corresponding $$q_k$$ 's are in $$[0, x]$$.

(a) Show that $$h$$ is continuous at all irrational points and is discontinuous at all rational points. In particular, $$h$$ has infinitely many discontinuity points.

(b) Show that $$h$$ is Riemann integrable.

(c) Compute $$\int_0^1 h$$.

I'm done with the first two parts, the first one following from a jump at rationals and second one following from monotonous nature of the function $$h$$. I need hints for the third part. I'm unable to come up with a proper argument in order to restrict the integral to a value. I would appreciate some help.

• Did you mean $\int _0 ^1 h$ in part (c)? Commented Feb 14 at 8:10
– BDS
Commented Feb 14 at 8:10
• From Probabilistic considerations the integral seems to be $1-\sum_k q_kp_k$ Commented Feb 14 at 8:12
• @geetha290krm Can you please elaborate?
– BDS
Commented Feb 14 at 8:13
• If $X$ is a random variable taking the value $q_k$ with probability $p_k$ for $k=1,2...$ then $\int_0^{1}h=\int_0^{1}P(X\le x)dx=1-\int_0^{1} P(X>x)dx=1-\int_0^{\infty} P(X>x)dx=1-EX=1-\sum q_kp_k$. Commented Feb 14 at 8:16

Let $$P_n$$ be the partition including $$0,1$$ and $$q_1,...,q_n$$. We denote this partition by $$P_n=\{t_0=0,t_1,...t_n,t_{n+1}=1\}$$. Moreover, let $$s_i$$ be the term in $$\sum p_k$$ corresponding to $$t_i$$ for $$1\leq i\leq n$$.

Observe that

$$h(t_i)\geq \sum_{j=1}^is_j$$ and

$$h(t_i)+\sum_{j=i}^ns_j\leq 1$$ $$\implies h(t_i) \leq 1-\sum_{j=i}^ns_j$$

We can now bound the upper and lower Riemann sums.

$$L(f,P_n)\geq \sum_{i=1}^nh(t_i)(t_{i+1}-t_i)$$$$\geq \sum_{i=1}^n\left((t_{i+1}-t_i)\sum_{j=1}^i s_j\right)=\sum_{i=1}^n(s_i-t_is_i)$$

This last sum is just a rearrangement of $$\sum_{k=1}^np_k-p_kq_k$$.

$$U(f,P_n)\leq \sum_{i=0}^nh(t_{i+1})(t_{i+1}-t_i)$$$$\leq \sum_{i=0}^n(t_{i+1}-t_i)(1-\sum_{j=i+1}^ns_j)$$$$=1- \sum_{i=0}^n\left((t_{i+1}-t_i)\sum_{j=i+1}^ns_j\right)$$$$= 1-\sum_{i=1}^ns_it_i=1-\sum_{k=1}^np_kq_k.$$

Taking limits as $$n\to\infty$$, we find the desired integral to be $$\fbox{1-\sum p_kq_k}.$$