Upper and Lower Darboux integral of a piecewise function $f(x)=x$ and $f(x)=0$. Let $0<a<b$. Find the upper and lower Darboux integrals for the function $$f(x)=x$$ if $x\in[a,b]\cap\mathbb{Q}$ and $$f(x)=0$$ if $x\in[a,b]-\mathbb{Q}$.
I am so lost on this problem. Any hints or solutions are greatly appreciated.
 A: Any interval in any subdivision of $[a,b]$ must contain a rational and irrational point, since the intervals are not singletons nor empty. This is because the irrationals and rationals are both dense in $\mathbb{R}$. We then have that the supremum of $f$ on any non-empty, non-singleton closed interval $[x,y]$ is $\sup[x,y] = y$ and the infimum of $f$ on any interval is $0$.
So the upper sum of any uniform partition $P_n:a=t_0< t_1< ...<t_n=b$, with $t_k = a+\frac{k(b-a)}{n}$ must be $$U(f,P_n) =\sum_{k=1}^{n} (t_k-t_{k-1}) t_k=\sum^{n}_{k=1} (\frac{b-a}{n}) (t_k)=\sum^{n}_{k=1} (\frac{b-a}{n})(a+\frac{k(b-a)}{n}) = \sum^{n}_{k=1} (a(\frac{b-a}{n})+(\frac{b-a}{n})\frac{k(b-a)}{n}) = a(b-a) + \frac{(b-a)^2}{n^2}\sum^{n}_{k=1} k $$
$$= a(b-a) + \frac{(b-a)^2}{n^2}\frac{1}{2} (n)(n+1)= a(b-a) + \frac{1}{2} (b-a)^2(1+\frac{1}{n})  $$
since the supremum of any interval must be on the right hand side.
Now take the infimum of all the upper sums of the uniform partitions, and you'll note that it is, $$a(b-a) + \frac{1}{2} (b-a)^2(1) = ab-a^2 + \frac{1}{2}b^2-ab+\frac{1}{2}a^2 = \frac{1}{2}b^2-\frac{1}{2}a^2$$
So the upper integral is at most $$\frac{1}{2}b^2-\frac{1}{2}a^2$$.
If $Q = \{q_0,...,q_N\}$ is any partition of $[a,b]$, then 
$$U(f, Q) = \sum_{i=1}^N q_i (q_i-q_{i-1}) =  \sum_{i=1}^N q_i^2 -\sum_{i=1}^Nq_i q_{i-1} \geq \sum_{i=1}^N q_i^2 - \frac{1}{2} \sum_{i=1}^N (q_i^2 + q_{i-1}^2) $$$$= \frac{1}{2} \sum_{i=1}^N (q_i^2 - q_{i-1}^2) =\frac{1}{2}(\sum_{i=1}^N q_i^2 - \sum_{i=1}^N q_{i-1}^2) = \frac{1}{2}(b^2-a^2)$$
The inequality is because:
$$(x-y)^2 \geq 0 \implies x^2-2xy+y^2 \geq 0 \implies -2xy \geq -x^2-y^2 $$$$\implies 2xy \leq x^2 +y^2 \implies xy \leq \frac{1}{2}(x^2+y^2)$$
The last equality is because the squares cancel (telescoping sum) for all $q_i \neq a,b$.
So the upper integral is at least $\frac{1}{2}(b^2-a^2)$ since it is the greatest lower bound of the upper sums of all the partitions.
Hence the upper integral is  $\frac{1}{2}(b^2-a^2)$.
The lower sum of any partition of $[a,b]$ must be $0$ as the infimum on any of the subintervals is $0$.
So the supremum of the lower sums over any partition must be $0$. Hence the lower integral is $0$.
Does that get you started?
A: Let us analyse the upper sum: $U_{f,P} = \sum_{i=1}^n(x_i - x_{i-1})M_i$ where $M_i = \sup_{x\in[x_{i-1}, x_i]} f(x)$. So, we have to look for a $\sup$ for any interval $[x_{i-1}, x_i]$. Since $\mathbb{Q}$ is dense in $\mathbb{R}$, any interval contains rational numbers, and hence, $\sup f(x)$ is equal to $x_i$ (even if $x_i$ is irrational, there is a sequence of rational numbers with $x_i$ as its limit). Looks a lot like a Riemann sum for a function $f(x) = x$. So, your upper integral should look like $\frac{b^2 - a^2}{2}$.
With the same reasoning, you find out that the lower integral would be $0$.
