Is f Riemann Integrable A function $f$ is defined in the interval $(a,b)$ as follows:
$$f(x)=  \left\{
\begin{array}{ll}
      \frac{1}{q^2} & x = \frac{p}{q}\\
      \frac{1}{q^3} & x = \sqrt\frac{p}{q}\\
      0 & \text{otherwise}\\
\end{array} 
\right. $$
where $p.q$ are coprime.Is $f$ Riemann-integrable? 
My Attempt- I think it is Riemann integrable with integral being zero. It is similar to the function which is continuous at all irrationals but discontinuous at rationals. Therefore, countable many discontinuities. Hence it must be Riemann-integrable. But can someone please show how $U_n(f)\to0$, where $U_n$ is upper Riemann integral?
 A: Let me try to answer myself, I am not sure about the correctness of the solution.
$$f(x)=  \left\{
\begin{array}{ll}
      \frac{1}{q^2} & x = \frac{p}{q}\\
      \frac{1}{q^3} & x = \sqrt\frac{p}{q}\\
      0 & \text{otherwise}\\
\end{array} 
\right. $$
First I will prove that $f(x)$ is discontinuous at $S=S_1\cup S_2$ where $$S_1=\{x:x=\frac{p}{q}, p,q \text{ coprime integers}\}$$
$$S_2=\{x:x=\sqrt\frac{p}{q}, p,q \text{ coprime integers}\}$$
Since irrationals are dense in $\mathbf{R}$, therefore given any rational $r_0>0$ from the set $S_1$ we can always find a sequence of positive irrationals, $\{x_n\} \to r_0$ and therefore $f(x_n) \to 0 $ but $f(r_0)=1/q^3$. Therefore discontinuous. Similarly for any $s_1 \in S_2; \exists r_1 \in S_1$ such that $s_1^2=r_1$. Also by same argument there exists a sequence of positive irrationals converging to $r_1$. Also the square root sequence of such sequence would converge to $s_1$. Also none of the element of this sequence will lie in $S_2$ else its square would become rational, a contradiction. Thus, $f$ is discontinuous at $S$. But $S$ is union of countable sets, therefore is itself countable.
Now, if we can prove that $f$ is continuous at $\mathbf{R}-S$, then $f$ has only countable discontinuities and thus its Riemann integrable.
Continuity at $x_0\in\mathbf{R}-S$
If $$|f(x)-f(x_0)|<\epsilon , \epsilon>0, \forall x\in (x_0-\delta, x_0+\delta) , \exists\delta>0$$
$$\text{or} |f(x)|<\epsilon$$
Choose $q_0\in \mathbf{N}$ such that, $\frac{1}{q_0^2}< \epsilon$
Now take the set $R_0=\bigcup\limits_{k=1}^{q_0}\Big((x_0-\frac{1}{2},x_0+\frac{1}{2})\cap\{\frac{a}{k} | a\in \mathbf{Z}\}\Big)$
Each set of above finite union has finite elements as $\{\frac{a}{k} | a\in \mathbf{Z}\}$ can have maximum $k$ and minimum $k-1$ elements in any open interval of unit length. Therefore $R_0$ is a non empty and well ordered set, hence we can find $\delta_1=\min{\{|x_0-R_0(i)|\forall R_0(i) \in R_0\}}$. $\delta_1 >0$ as $x_0\notin R_0$. Therefore,
$$|f(x)|<\frac{1}{q_0^2}<\epsilon, \forall x \in (x_0^2-\delta_1, x_0^2+\delta_1)-S_2$$
Now consider $x_0^2$, which is also irrational as $x_0\in\mathbf{R}-S$. And use similar argument to find $\delta_2$ such that 
$$|f(x^2)|<\epsilon, \forall x\in(x_0^2-\delta_2, x_0^2+\delta_2)-S_2$$
$$\implies |f(x)|<\epsilon, \forall x\in(\sqrt{x_0^2-\delta_2}, \sqrt{x_0^2+\delta_2})-S_1$$
Define $\delta_3 = \min\{|x_0-\sqrt{x_0^2-\delta_2}|,|x_0-\sqrt{x_0^2+\delta_2}|\}$. Again by same argument $\delta_3>0$
Let $\delta=\min{\{\delta_1, \delta_3\}}$, then for all $x \in (x_0-\delta, x_0+\delta)$, by construction, we have $|f(x)|< \epsilon $. Hence $f(x)$ is continuous in $\mathbf{R}-S$.
Thus $f$ has only countably many discontinuities and is thus Riemann Integrable.
