<s>[INST] How to find the upper Riemann integral of following function? $f(x)$ is defined on $[a,b]$ as -
$= 0$ if $x ∈ [a, b] ∩ Q$
$= x$ otherwise
Lower integral is $0$ and i think that upper integral should be $(b^2 - a^2)/2$(i may be wrong also) but i am not able to prove it.
 [/INST] Since the irrationals are dense, we have $\sup_{x \in [x_{j-1},x_j]}f(x) = x_j$.
Hence, for any partition, $a = x_0 < x_1 < \ldots < x_n = b$, the upper Darboux sum is
$$U(P,f) = \sum_{j=1}^n x_j(x_j - x_{j-1})  = \frac{1}{2} \sum_{j=1}^n(x_j+x_{j-1})(x_j - x_{j-1}) + \frac{1}{2}\sum_{j=1}^n(x_j-x_{j-1})(x_j - x_{j-1}) \\ = \frac{1}{2} \sum_{j=1}^n(x_j^2 - x_{j-1}^2) + \frac{1}{2}\sum_{j=1}^n(x_j-x_{j-1})^2 = \frac{b^2-a^2}{2} +  \frac{1}{2}\sum_{j=1}^n(x_j-x_{j-1})^2,  $$
Since the last term on the RHS is nonnegative we have, for the upper integral,
$$\overline{\int_a^b} f(x) \, dx = \inf_{P}U(P,f) \geqslant \frac{b^2 - a^2}{2}$$
To prove we actually have  $\inf_{P}U(P,f) = \frac{b^2 - a^2}{2}$, we show that for any $\epsilon > 0$ there exists a partition such that 
$$U(P,f) < \frac{b^2 - a^2}{2} + \epsilon$$
For a uniform partition where $x_j - x_{j-1} = \frac{b-a}{n}$ for $j=1,2, \ldots, n$ we have
$$\frac{1}{2}\sum_{j=1}^n(x_j-x_{j-1})^2 = \frac{1}{2} n\frac{(b-a)^2}{n^2} = \frac{(b-a)^2}{2n}$$
Now choose $n > \frac{(b-a)^2}{2\epsilon}$ and we have
$$\begin{align}U(P,f) &=\frac{b^2 - a^2}{2} +  \frac{1}{2}\sum_{j=1}^n(x_j-x_{j-1})^2\\ &= \frac{b^2 - a^2}{2}+ \frac{(b-a)^2}{2n}  \\&< \frac{b^2 - a^2}{2} + \epsilon\end{align}$$
Therefore,
$$\overline{\int_a^b} f(x) \, dx = \inf_{P}U(P,f) = \frac{b^2 - a^2}{2}$$
</s>