determine continuity and differentiability of a composite function

Let

$$\ f(x) = \begin{cases} x^{2}\sin(\frac{1}{x}), & \text{if x \not = 0} \\ 0, & \text{if x = 0} \end{cases}$$

and $$g(x) = \begin{cases} 0, &\text{if } x\not \in \mathbb Q \\ \frac{1}{b}, &\text{if } x = \frac{a}{b} \ \text{ with } a \in \mathbb Z, \ b \in \mathbb Z^{+} \text{ and } \gcd(a,b) = 1 \end{cases}$$ Let $h(x) = f(g(x))$

Determine where $h(x)$ is continuous and differentiable.

Here is my trial.. firstly derive $$h(x) = \begin{cases} \frac{1}{b^{2}} \sin(b) & \text{where } x = \frac{a}{b}, \\ 0 & \text{where } x \not \in \mathbb Q \end{cases}$$

Then we can show $h(x)$ is not continuous at every $x \in \mathbb Q$ as following: Assume $p = \frac{a}{b}$ then $\ f(p) = f(\frac{a}{b}) = \frac{1}{b^{2}}\sin(b)$, but given any irrational sequence $x_{n}$ converging to p} \$we have$\lim_{n \to \infty}f(x_{n}) = 0$since$x_{n}$is irrational, then we proved the discontinuity in$\mathbb Q$. But how can I prove that$h$is continuos for$x \not \in \mathbb Q$? Hope someone can help... 1 Answer To prove$h$is continuous for irrational numbers we have to prove that $$\forall x \notin \Bbb Q\ \forall \epsilon > 0\ \exists \delta > 0 : |x-y| < \delta \Rightarrow f(y) < \epsilon$$ If we take an interval of length$1$around$x$, we see there are at most$3$fractions that can be written$\frac{a}{2}$in this interval (two such fractions have a distance of$\frac{1}{2}$between them). Similarly,$\forall n \in \Bbb N $, there is a finite number of fractions in this interval that can be written$\frac{a}{n}$. But we observe$h(\frac{a}{n}) \leqslant \frac{1}{n^2}$, which means if we take$n$large enough, we can assure$h(\frac{a}{b}) < \epsilon \ \forall b > n$. As there are only a finite amount of fractions where the denominator is smaller than n ( in the chosen interval), there is a minimum distance between$x$and such a fraction. If we take$\delta$smaller than this distance, the condition to be continuous is satisfied. I cannot completely prove there exists an irrtional number where$h$is not differentiable it exists, here is why: Take any rational point$a_1$.$h(a_1) \neq 0$(unless$a_1 = 0$). We now define the interval$I_1 = [a_1-h(a_1),a_1+h(a_1)]$. As$\Bbb Q$is dense in$\Bbb R$, we know there is another rational point in$I_1$, call it$a_2$.Now define the interval$I_2 = [a_2-h(a_2),a_2+h(a_2)]$.The intersection of$I_1$and$I_2$is non-empty, and we find another rational point,$a_3$, in this intersection.We continue, and as the length of these intervals tend to$0$, we know$\lim_{n\to \infty}a_n$exists. Call it$x$. Now$h$is clearly not differentiable in$x$, as the derivate would be$1$for any$a_1$and$0$for any irrational number. There is no reason$x$should be rational, that is why I think there exist irrational numbers where$h$is not differentiable. This does not exclude that in some places the function is differentiable (with derivative$0\$).

I hope this helps.