Spivak Calculus $13-33$ This question is from Spivak's Calculus Chapter $ 13$ Integrals Problem $33$ (it deals with upper and lower sums which is what the $L$ and $U$ denote):

I can't seem to do part (b).  I tried just defining the $U(f,P)$ but can't get anything that will lead to the answer which is $1/2$.  I know that we effectively try to find the integral but I don't how you'd do that with this kind of piecewise function.
 A: If $P$ is a partition of $[0,1]$:
$$P:\enspace 0=x_0<x_1<x_2<\dots <x_n=1$$
then the supremum of $f$ on each interval $[x_{i-1},x_i]$ is $x_i$, so
$$U(f,P)=\sum_{i=1}^n(x_i-x_{i-1})x_i.$$
The point is that this upper sum is also an upper sum for the function $g(x)=x$, and so: 
$$\frac{1}{2}=\int_0^1g(x)\,dx=\inf\{U(g,P): \hbox{$P$ is a partition of $[0,1]$}\}=\inf\{U(f,P):\hbox{$P$ is a partition of $[0,1]$}\}$$
It is also possible to point out a "generic" partition for which $U(f,P)$ comes arbitrarily close to $\frac{1}{2}$, namely, the partition into $n$ equal parts. Let $\Pi_n$ denote the partition: $0<1/n<2/n<\cdots <(n-1)/n<1$, then:
$$U(f,\Pi_n)=\frac{1}{n}\sum_{i=1}^n\frac{i}{n}=\frac{n(n+1)}{2n^2}\to \frac{1}{2}$$
as $n\to\infty$.
A: Note the following theorem (proof):

Let $f$ be bounded on $[a, b] $ and let $$S=\inf\, \{U(f, P) \mid P\text{ is a partition of }[a, b]\}$$ Then corresponding to every $\epsilon>0$ there exists a $\delta>0$ such that $|U(f, P) - S|<\epsilon $ for all partitions $P$ of $[a, b] $ with norm (mesh) $||P||<\delta$.

Thus the infimum of all upper sums can also be obtained as limit of upper sums when the norm of partition tends to $0$. This helps us to work with uniform partitions with points $x_{i} =i/n$. And the upper sum is clearly $\sum_{i=1}^{n}i/n^{2}=(n+1)/2n$ which tends to $1/2$ as $n\to\infty$.
