$f'(x) = g(f(x)) $ where $g: \mathbb{R} \rightarrow \mathbb{R}$ is smooth. Show $f$ is smooth. 
Suppose $f: \mathbb{R} \rightarrow \mathbb{R} $ is differentiable and $g: \mathbb{R} \rightarrow \mathbb{R} $ is infinitely differentiable, i.e. $ g \in C^{\infty}(\mathbb{R})$, where we know $f'(x) = g(f(x)) $ on $\mathbb{R}$. Show that $ f \in C^{\infty}(\mathbb{R})$.

Thus I have to show that $f$ is infinitely differentiable, that is, derivatives of all orders exist. I can assume by induction that all derivatives of order less than, say $n$, exist, and have to show that the $nth$ derivative exists for $f$. 
I came up with this:
$f^{n}(x) = (g \circ  f)^{n-1}(x)$. I somehow have to show that the $(n-1)th$ derivative for this composite function exists. I tried using the chain rule, but it just seems to become more ugly as I continue taking more derivatives. Obviously, I have to use the fact that $g$ is infinitely differentiable as well as the inductive assumption, although I'm not sure how to complete this line of reasoning. Maybe induction isn't even the right way to proceed. 
Ideas? 
 A: Notation: For any function $h$ let $h^{(0)}=h$, and let $h^{(n)}$ be the $n$th derivative of $h$ for $n\geq 1.$
Suppose for some $n\geq 0,$ there is a polynomial $ P_n$ in $(2 n+2)$ variables such that $$f^{(n+1)}=P_n(g^{(0)}(f),...,g^{(n)}(f),\;f^{(0))},...,f^{(n)}).$$ Then every term occurring in the polynomial on the RHS is differentiable (because $g$ is smooth and $f^{(j)}$ exists for $j\leq n+1$), so the RHS is differentiable, so $f^{(n+2)}$ exists. The result of differentiating  is $$ f^{(n+2)}=P_{n+1}(g^{(0)}(f),...,g^{(n+1)}(f),\;f^{(0)},..., f^{(n+1)})$$ where $P_{n+1}$ is a polynomial in $(2(n+1)+2)$ variables. 
A: Suppose $f \in C^k$, then $f^{(k+1)} = f'^{(k)} = (g \circ f)^{(k)}$. Since $g \in C^\infty$ and $f \in C^k$, we have that $g \circ f \in C^k$, and thus that $f^{(k+1)} = (g \circ f)^{(k)} \in C^0$, so it follows that $f \in C^{k+1}$.  QED
Or even more succinctly as John Ma pointed out below:
Suppose $f \in C^k$, then since $g \in C^\infty$, we have that $g \circ f \in C^k$, and thus that $f' = g \circ f \in C^k$. But $f' \in C^k \Longleftrightarrow f \in C^{k+1}$.  QED
A: Note that this is a differential equation. The equivalent Picard integral equation is
$$
f(x)=f(0)+\int_0^x g(f(t))\,dt
$$
From here it is trivial to observe that if $f$ is $C^n$ or better, then the composition $g\circ f$ is also at least $C^n$ and thus the anti-derivative $C^{n+1}$. Which gives that $f$ is also $C^{n+1}$ and so on.
