# Examine if a piecewise-defined function is Riemann integrable

I'm learning about Riemann integrable function and need help with the following problem:

Consider the function

$$f(x) = \begin{cases} x, & 0 \leq x \leq 1 \, \text{and} \, x \in \mathbb Q; \\ x^2, & 0 \leq x \leq 1 \, \text{and} \, x \notin \mathbb Q. \end{cases}$$

Examine if $$f$$ is Riemann integrable.

The definition the author is using for Riemann integrable function is the one comparing the upper/lower sums, i.e. a function $$f$$ is Riemann integrable if and only if

$$\inf_P\{U(f, P)\} = \sup_P\{L(f, P)\}.$$

This exercise follows from the classic example of the Dirichlet function which is not Riemann integrable on any closed interval. I was able to follow and understand the latter example very well by I'm having difficulties applying a similar method of resolution for this newer function. My intuition tells me that the considered function is not Riemann integrable given that $$f(x)$$ is analogous to $$\chi_{\mathbb Q}$$, the Dirichlet function.

Consider $L(f,P)$ for an arbitrary partition $P$ and note that $x^2 \leq x$ in the interval and hence when considering the lower sums, we only need to worry about $x \in \mathbb{R} \setminus \mathbb{Q}$. In any given subinterval $[t_{i-1}, t_i]$ of the partition, the $\inf$ of $f$ is precisely equal to the $\inf$ of $g:[t_{i-1}, t_i] \to \mathbb{R}$ given by $g(x) = x^2$. The reason is because $g$ is continuous and increasing and there exist irrationals arbitrarily close to $t_{i-1}$. It thus follows that the $\sup$ of the lower sums is equal to $\int_0^1 x^2 \ dx = \frac 13$.
Analogously, we can show that the $\inf$ of the upper sums is $\int_0^1 x \ dx = \frac 12$.
Alternatively, simply note that $f$ is discontinuous everywhere in $(0,1)$ and use Lebesgue's criterion.
• @VonKar This is the Lebesgue Criterion for Riemann integrability. Basically, a function is Riemann integrable if and only if it is bounded and continuous almost everywhere (formally, its set of discontinuities has measure $0$). This function is discontinuous on $(0,1)$ so it cannot be Riemann integrable. Jun 2, 2016 at 14:23