Are those functions Riemann integrable? Let $f,g:[0,1]\to \mathbb{R}$ defined as:
$$f(x)=\begin{cases}0 , \text{ if } x \in (\mathbb{R} \setminus \mathbb{Q}) \\ \frac{1}{q}, \text{ if } x =\frac{p}{q} \text{ irreductible fraction with }q>0 \end{cases}$$
$$g(x)=\begin{cases}0, \text{ if } x=0 \\ 1, \text{ if } 0 < x \leq 1\end{cases}$$
Are those functions Riemann integrable? What about the composite $g\circ f$?
I couldn't think of anything that shows that, but i think that $f$ and $g$ are integrable, but $g \circ f$ isn't. Can anyone explain how I start to think in that question? Thanks.
 A: As mentioned in one of the comments, how you should go about proving this depends on the machinery you are familiar with.
I believe that the most common approach in undergraduate courses is to use upper and lower sums. I have therefore sketched a solution which uses this definition of the Riemann integral.
Let $\mathcal{P}$ be a partition of $I = [0,1]$.
Notice that,
$$
 L_\alpha(f; \mathcal{P}) = \sum_{k=1}^n \left(\inf_{x \in [x_{k-1}, x_k]} f(x)\right)\cdot\left[(x_k) - (x_{k-1})\right] = 0.
 $$
Since this is valid for any partition of the unit interval, it follows that the lower integral is $0$.
In order to show that $f$ is integrable, fix $\varepsilon > 0$ and find a partition $\mathcal{P}$ of $I$ such that
$$
  U_\alpha(f; \mathcal{P}) - L_\alpha(f; \mathcal{P}) = U_\alpha(f; \mathcal{P}) < \varepsilon.
 $$
To do this, pick $q\in \mathbb{N}$ such that
$$
  \frac{1}{q} < \frac{\varepsilon}{2}
 $$
and notice that the set of point
$$
  S_q:=\left\{x\in [0,1] : f(x)\geq \frac{1}{q}\right\}
 $$
is finite of cardinality $M$.
Then explain why you can pick partition $\mathcal{P} = \{x_0, \dots, x_n\}$ such that

*

*$x_k\not\in S_q$ for each $k$, except possibly $k=0$ and $k=n$.

*There holds: $$
  (x_k) - (x_{k-1}) < \frac{\varepsilon}{2M}.
 $$
You can now bound the upper $U_\alpha(f; \mathcal{P})$ by $\varepsilon$. To do this, you will have to split your sum into two parts (the subintervals that contain elements of $S_q$ and those that do not).
The composition $g\circ f$ is the Dirichlet function. Using that the rationals (and the irrationals) are dense, you should be able to show that the upper integral evaluates to $1$ while the lower integral evaluates to $0$. In particular, the function is not Riemann integrable.
NOTE: The goal of this problem is to show you that the composition of Riemann integral functions need not be Riemann integrable.
