Upper and lower sums (Spivak) I'm trying to solve one exercise from this book, and even though is simple to understand the idea, I don't know how to 'formalize' the proof. The exercise is:
$$f(x)=x$$ if $x$ is rational and $$f(x)=0$$ if $x$ is irrational. Prove that $f$ is non integrable in $[0,1]$
I'm sorry if it's unclear, I had to translate it from Spanish, and I'm not sure if I did a very good job.
I tried to calculate the upper and lower sums of the function. It's quite obvious that the lower sum is always zero, and it's easily deductible that the infimum of all the upper sums is $1/2$, but I don't know how to prove it. 
Thank you!
 A: To calculate the upper sum take the partition $P$ on $[0,1]$. $P = \{0, h, 2h, \dots, kh, (k+1)h, \dots nh\}$, where $h$ is a rational number.
Our function is $f(x) = x$ when $x$ is a rational number. So in the interval $[kh, (k+1)h]$ the upper bound of the function will be $(k+1)h$.
So $U(P,f) = \sum_{k = 1}^n (k+1)h. h$. Calculate the sum.
For getting the upper sum that $\lim_{n\rightarrow \infty} U(P,f)$. If all is true you shall get the answer you have claimed.
A: Given any partition $P = \{x_0, x_1, ... x_n\}$ of $[0,1]$, since the rationals are dense in $\mathbb{R}$, the upper value of a subinterval, i.e. $\sup\{f(x):x \in [x_{i-1},x_i]\} = f(x_i) = x_i$ Therefore, the upper sum $U(f,P)$ can be computed as follows (the motivation comes from a picture of an upper sum of $f(x) = x$ on $[0,1]$: split each interval into a triangle and trapezoid 'cut' by the function):
$$
U(f,P) = \sum^n_{i=1}f(x_i)(x_i - x_{i-1}) = \sum^n_{i=1}x_i^2 - x_i\cdot x_{i-1} = \sum^n_{i=1}\frac{(x_i - x_{i-1})^2}{2} + \sum^n_{i=1}\frac{x_i^2-x_{i-1}^2}{2}
$$
In the rightmost expression, we see a telescoping sum and a strictly positive value. Therefore, we may conclude that for all $P$, $U(f,P)>1/2$. So, since the infimum of all upper sums is at least 1/2 and the supremum of lower sums is clearly 0, the lower and upper integrals cannot be the same. Hence, $f$ is not integrable on $[0,1]$.
Note that you do not need to compute the upper integral to prove the claim. All you need to do is show that if it exists, it is positive (i.e. not $0$).
