# Why $f(x)$ is Riemann integrable?

If somebody can explain to me why the following function is Riemann Integrable on $[0,1]$ and how to find $\int_0^1 f(x)~dx$ $$f(x)= \begin{cases}1 &\text{ if } x=0\\ 0 &\text{ if } x \in [0,1] \setminus \Bbb{Q}, \\ \frac 1n &\text{ if } x=\frac mn \in [0,1] \cap \Bbb{Q} \text{ with } \gcd(n,m)=1\end{cases}$$

• At $x=0.5$ $f(x)=$ both $0$ and $0.2$ – Qwerty Jun 16 '16 at 13:56
• what's the value of $f$ for $x$ irrational of $(0,1)$ ? – Smilia Jun 16 '16 at 13:58
• Do you mean $f(x)=0$ if $x\in[0,1]\setminus\mathbb Q$? – Hirshy Jun 16 '16 at 13:59
• As a side note, the $\LaTeX$ treatment of piecewise "case" definitions is covered in this part of the homegrown MathJax quick tutorial. – hardmath Jun 16 '16 at 14:03
• – Hetebrij Jun 16 '16 at 14:03

$$f(x)=\begin{cases}1,&x=0, \\ 0, & x\in [0,1]\setminus\mathbb Q, \\ \frac{1}{n},&x=\frac{m}{n}\in [0,1]\cap\mathbb Q,~\operatorname{gcd}(m,n)=1\\ \end{cases}$$
We first note that $0\leq f\leq 1$ and therefor $$0\leq\int\limits_{0^*}^{1}\!f(x)\,\mathrm{d}x \leq \int\limits_{0}^{1^*}\!f(x)\,\mathrm{d}x.$$ Let $\varepsilon>0$, then the set $M:=\{\frac{p}{q}~|~1\leq q\leq \frac{1}{\varepsilon},~0\leq p\leq q\}$ is finite and we can define a step function $$\psi:[0,1]\rightarrow\mathbb R,~\psi(x)=\begin{cases} f(x),&x\in M \\ \varepsilon,&x\notin M\end{cases}.$$ It is obvious that we have $f\leq\psi$ and therefor $\int\limits_{0}^{1^*}\!f(x)\,\mathrm{d}x\leq\int\limits_{0}^{1}\!\psi(x)\,\mathrm{d}x=\varepsilon$. This yields that $f$ is riemann-integrable with $$\int\limits_{0}^{1}\!f(x)\,\mathrm{d}x=0.$$
• $\int\limits_{a^*}^{b}\!f(x) \, \mathrm{d}x=\sup\{\int\limits_{a}^{b}\!\varphi(x)\,\mathrm{d}x~|~\varphi~\text{is a step-function},~\varphi\leq f\}$ and $\int\limits_{a}^{b^*}\!f(x)\,\mathrm{d}x=\inf\{\int\limits_{a}^{b}\!\psi(x) \, \mathrm{d}x~|~\psi~\text{is a step-function},~f\leq\psi\}$ denote the lower integral and the upper integral of $f$. $f$ is riemann-integrable if it is bounded and $\int\limits_{a^*}^{b}\!f(x)\,\mathrm{d}x=\int\limits_{a}^{b^*}\!f(x) \, \mathrm{d}x.$ – Hirshy Jun 16 '16 at 14:15