Prove that the derivative exists Let $g$ be differentiable on an open interval $I$ and let 
$f(x) = g(x)d(x)$,
where $d(x) = 1$ if $x$ is rational and $d(x)=0$ otherwise. Let $a\in I$ be a zero of $g$.
Then prove that $f'(a)$ exists if and only if $a$ is a zero of $g'$.
My professor gave a hint that I am supposed to use two sequences to solve this problem, but I am not sure how to use sequences to demonstrate differentiability. Am I supposed to create a sequence involving rational numbers and another involving irrationals?
Thanks!
 A: Your idea of considering a sequence of rationals and a sequence of irrationals is a good idea. The key is that the limit definition of the derivative should hold for any sequence of points approaching $a$.

Suppose $f'(a)$ exists. By considering the limit $\lim_{n \to \infty} \frac{f(q_n)-f(a)}{q_n-a}$ for a sequence of irrationals $q_n$ that converges to $a$, we see that $f'(a)=0$. This implies that $\lim_{n \to \infty} \frac{f(r_n)-f(a)}{r_n-a}$ is also $0$ for a sequence of rationals $r_n$ converging to $a$. But this latter limit equals $\lim_{n \to \infty} \frac{g(r_n) - g(a)}{r_n-a}$ which equals $g'(a)$.

Suppose $g'(a)=0$. Since $f(a)=g(a)=0$ and $|f(x)| \le |g(x)|$ for any $x$, we have
$$\left|\frac{f(x)-f(a)}{x-a}\right|
\le \frac{|f(x)|}{|x-a|}
\le \frac{|g(x)|}{|x-a|}.$$
Since the right-hand side converges to $g'(a)=0$ as $x \to a$, we see that $\lim_{x \to a}\frac{f(x)-f(a)}{x-a} = 0$ as well.
A: hint
Assume that $ g'(a)=0$.
$$(\forall x\in I) \;\; |d(x)| \le 1\implies$$
$$(\forall x\in I-\{a\})\;\; |\frac{f(x)}{x-a}|\le |\frac{g(x)}{x-a}|$$
So
$$g'(a)=0\implies$$
$$\lim_{x\to a}\frac{g(x)}{x-a}=0\implies$$
$$\lim_{x\to a}\frac{f(x)}{x-a}=0\implies$$
$$f'(a)=0$$
Conversely
$$f'(a) \text{ exists }\; \implies$$
$$\lim_{x\to a}\frac{g(x)d(x)}{x-a} \in \Bbb R \implies$$
$$\lim_{n\to+\infty}\frac{g(a_n)d(a_n)}{a_n-a}\in \Bbb R$$
choose $ a_n $ such that
$$a_n\in \Bbb Q \text{ and } \lim_{n\to+\infty}a_n=a$$
you can take
$$a_n=\frac{\lfloor 10^na\rfloor}{10^n}$$
A: Since $g(a)=0$, we have $f(a)=0$.

I. To prove: $g'(a)=0\Rightarrow$ $f'(a)$ exists.
Suppose that $g'(a)=0$. We have
that
\begin{eqnarray*}
\lim_{x\rightarrow a}\frac{f(x)-f(a)}{x-a} & = & \lim_{x\rightarrow a}\frac{g(x)d(x)}{x-a}=\lim_{x\rightarrow a}\frac{g(x)-g(a)}{x-a}d(x).
\end{eqnarray*}
However, for $x\neq a$,
\begin{eqnarray*}
\left|\frac{g(x)d(x)}{x-a}\right| & = & \left|\frac{g(x)-g(a)}{x-a}\right||d(x)|\\
 & \leq & \left|\frac{g(x)-g(a)}{x-a}\right|\\
 & \rightarrow & g'(a)\\
 & = & 0
\end{eqnarray*}
as $x\rightarrow a$. By sandwich rule, $\lim_{x\rightarrow a}\frac{g(x)d(x)}{x-a}$
exists and equals to $0$. Therefore, $f'(a)$ exists and equals to
zero.

II. To prove $f'(a)$ exists $\Rightarrow g'(a)=0$.
Conversely, suppose that $f'(a)$ exists. We have that
\begin{eqnarray*}
f'(a) & = & \lim_{x\rightarrow a}\frac{f(x)-f(a)}{x-a}\\
 & = & \lim_{x\rightarrow a}\frac{g(x)-g(a)}{x-a}d(x).
\end{eqnarray*}
Since $\mathbb{Q}$ is dense in $\mathbb{R}$, we can choose a sequence
$(x_{n})$ in $I\cap\mathbb{Q}$ such that $x_{n}\rightarrow a$ and
$x_{n}\neq a$ for all $n$. Observe that $d(x_{n})=1$ for all $n$.
We have that
\begin{eqnarray*}
f'(a) & = & \lim_{x\rightarrow a}\frac{g(x)-g(a)}{x-a}d(x)\\
 & = & \lim_{n\rightarrow\infty}\frac{g(x_{n})-g(a)}{x_{n}-a}d(x_{n})\\
 & = & \lim_{n\rightarrow\infty}\frac{g(x_{n})-g(a)}{x_{n}-a}\\
 & = & g'(a).
\end{eqnarray*}
Also notice that $\mathbb{Q}^{c}$ is dense in $\mathbb{R}$, so we can
choose another sequence $(y_{n})$ in $I\cap\mathbb{Q}^{c}$ such
that $y_{n}\rightarrow a$ and $y_{n}\neq a$. Observe that $d(y_{n})=0$
for all $n$. We have that
\begin{eqnarray*}
f'(a) & = & \lim_{x\rightarrow a}\frac{g(x)-g(a)}{x-a}d(x)\\
 & = & \lim_{n\rightarrow\infty}\frac{g(y_{n})-g(a)}{y_{n}-a}d(y_{n})\\
 & = & 0.
\end{eqnarray*}
This shows that $g'(a)=f'(a)=0$.
