Let $f:\left[0,1\right]\times\left[0,1\right]\to \mathbb{R}$ be defined by
$$f\left ( x,y \right )=\begin{cases}
0& ,x\in\mathbb{I} \\
0& ,x\in\mathbb{Q},\hspace{2mm} y\in\mathbb{I}\\
\frac{1}{q}& ,x\in \mathbb{Q},\hspace{2mm} y=\frac{p}{q}\hspace{2mm} \text{in lowest terms}
\end{cases}$$
Show that $f$ is integrable and
$$\int_{\left[0,1\right]\times\left[0,1\right]}f=0$$
That was my tried. We know that $L(f,P)=0$ for any partition of $[0,1]\times[0,1]$ (This is easy to proof since the density of $\mathbb{I}$ on $\mathbb{R}$). Therefore, is enough to proof that given $\varepsilon$ there exist a partition $P$ such that $U(f,P)<\varepsilon$. Then for any $\varepsilon$ there exist $n\in \mathbb{N}$ st $\frac{1}{n}<\frac{\varepsilon}{2}$. Let $P$ the following partition
$$P=(\{0,\frac{1}{n},\dots, \frac{n-1}{n},1\},\{0,1\})$$. The volume $v(S)$ of each rectangle $S$ of the partition $P$ is $\frac{1}{n}$, but i don't how to calculate $M_S(f)=\sup\{f(x,y):(x,y)\in S\}$.
This exercise was taken from Calculus on Manifolds - Michael Spivak, Chapter 3. Integration, exercise 3-7.
For any $\epsilon > 0$, choose $N \in \mathbb{N}$ such that $1/N < \epsilon/2$.
The set $A_N = \left\{1,\frac{1}{2},\frac{1}{3},\frac{2}{3}, \ldots, \frac{1}{N}, \ldots, \frac{N-1}{N} \right\}$ contains a finite number of elements $m = \#(A_N)$. If $x\in \mathbb{Q} $ and $y \in A_N$ then $f(x,y)\geqslant 1/N$, and if $x\in \mathbb{Q} $ and $y \not\in A_N$ then $f(x,y)< 1/N < \epsilon/2$
Take a partition $P$ of $[0,1] \times [0,1]$ with subrectangles $R_{jk} = [x_{j-1},x_j]\times [y_{k-1},y_k]$ $(j,k = 1,\ldots ,n)$ and $\max_{1 \leqslant k\leqslant n}(y_k - y_{k-1}) < \frac{\epsilon}{4m}$. Denote $M_{jk} = \sup_{(x,y) \in R_{jk}} f(x,y)$.
We have
$$U(f,P) = \sum_{R_{jk}}M_{jk}\,vol(R_{jk}) = \sum_{[y_{k-1},y_k]\cap A_N = \emptyset}M_{jk}\,vol(R_{jk})+ \sum_{[y_{k-1},y_k]\cap A_N \neq \emptyset}M_{jk}\,vol(R_{jk})$$
For the first sum on the RHS, we have $M_{jk} < 1/N < \epsilon/2$ and
$$\sum_{[y_{k-1},y_k]\cap A_N = \emptyset}M_{jk}\,vol(R_{jk}) \leqslant \frac{\epsilon}{2}\sum_{[y_{k-1},y_k]\cap A_N = \emptyset}\,vol(R_{jk}) < \frac{\epsilon}{2} \cdot 1 = \frac{\epsilon}{2}$$
For the second sum, there are at most $n \cdot 2m$ subrectangles that contribute because no more than $2m$ intervals $[y_{k-1},y_k]$ can contain the $m$ points in $A_N$. As $M_{jk} \leqslant 1$ on any subrectangle, we have
$$\sum_{[y_{k-1},y_k]\cap A_N \neq \emptyset}M_{jk}\,vol(R_{jk}) \leqslant \sum_{[y_{k-1},y_k]\cap A_N \neq \emptyset}\,vol(R_{jk}) \leqslant 2m \cdot \max_{1\leqslant k \leqslant n}(y_{k} - y_{k-1}) \sum_{j=1}^n (x_j- x_{j-1}) \\ < 2m \cdot \frac{\epsilon}{4m} \cdot 1 = \frac{\epsilon}{2}$$
Therefore, $U(f,P) < \epsilon$ and $f$ is integrable.