Suppose $g\colon \mathbb{R}\to \mathbb{R}$ is differentiable and $f \colon \mathbb{R} \to \mathbb{R}$ is defined by:
$ f(x) = \begin{cases} g(x) & \text{if $x \in \mathbb{Q}$} \\ -g(x) & \text{if $x \notin \mathbb{Q}$} \end{cases} $
For each $x$ with $g(x)=0$ show that $f'(x)=0$ iff $g'(x)=0$.
This is what I have tried:
Let $x \in \mathbb{R}$ with $g(x)=0$.
Let $\{x_{n}\}$ be a sequence in $\mathbb{R}-\{x\}$ with $\{x_{n}\} \to x$.
(1) Assume $g'(x)=0$. Show $f'(x)=0$.
Case I: $x_{n} \in \mathbb{Q}$.
Let $\epsilon \gt 0$. Since $g$ is differentiable we can choose $N \in \mathbb{N}$ so that $\forall n \gt N$ we have $\mid\frac{g(x_{n})-0}{x_{n}-x}-0\mid \lt \epsilon$.
Then $\mid{\frac{f(x_{n})-f(x)}{x_{n}-x}}-0\mid=\mid\frac{g(x_{n})-0}{x_{n}-x}-0\mid \lt \epsilon$.
Case II: $x_{n} \notin \mathbb{Q}$.
Let $\epsilon \gt 0$. Since $g$ is differentiable we can choose $N \in \mathbb{N}$ so that $\forall n \gt N$ we have $\mid\frac{g(x_{n})-0}{x_{n}-x}-0\mid \lt \epsilon$.
Then $\mid{\frac{f(x_{n})-f(x)}{x_{n}-x}}-0\mid=\mid\frac{-g(x_{n})+0}{x_{n}-x}-0\mid=\mid\frac{g(x_{n})-0}{x_{n}-x}-0\mid \lt \epsilon$.
Both cases imply that $f'(x)=0$.
(2) Assume $f'(x)=0.$ Show $g'(x)=0.$
Since $f$ is differentiable at those $x$ with $f(x)=0$, $\{\frac{g(x_{n})-0}{x_{n}-x}\}=\{\frac{f(x_{n})-0}{x_{n}-x}\} \to f'(x)=0$.
I've tried to show all my steps so it was clear what I was thinking. I'm not too confident with what I did and was hoping I could get some feedback. Does it look all right? Is there any way to tidy it up a bit or a shorter way to do it? Thanks =)
$-|g(x)| \le f(x) \le |g(x)|$
If it exists, $f'(x) = \lim_\limits{h\to 0}\frac {f(x+h)-f(x)}{h}$
When $g(x) = 0$
$f'(x) = \lim_\limits{h\to 0}\frac {f(x+h)}{h}$
$-\frac {|g(x+h)|}{h} \le \frac {f(x+h)}{h} \le \frac {|g(x+h)|}{h}$
and if $g'(x) = 0$ then $\lim_\limits{h\to 0}\frac {g(x+h)}{h} = \lim_\limits{h\to 0}\frac {|g(x+h)|}{h}= \lim_\limits{h\to 0}\frac {-|g(x+h)|}{h} = 0$
$f'(x) = 0$ by the squeeze theroem.