Spivak, Ch 10 Differentiation, Problem *33: Very tricky proof that $f'(0),...,f^{(n)}(0)$ exist if $f(x)=x^{2n}\sin(1/x)$. 


*Let $f(x)=x^{2n}\sin(1/x)$ if $x \neq 0$, and let $f(0)=0$. Prove that $f'(0),...,f^{(n)}(0)$ exist, and that $f^{(n)}$ is not continuous at
$0$.


The strategy to prove this can be split into the following steps:

*

*prove a conjecture about what the terms of $f^{(k)}$ look like, using induction on $k$

*using another induction, prove that for $k<n$, each of the terms of $f^{(k)}$ are a product of x raised to at least the second power, times a sinusoid, which we know is bounded.

*use yet another induction to show that $f^{(k)}(0)=0$, for $k \leq n$, by calculating the limit that defines each derivative. These calculations are quite easy given step 2.

*in the case of $f^{(n)}$ not all terms will have an $x$ raised to at least the second power, so when we calculate the limit it will not be 0. Therefore, $f^{(n)}$ is not continuous at $0$.

My question is about step 1.
If we write out, say, the first, second, and third derivatives of $f$ we start to notice a pattern, and so we conjecture that $f^{(k)}(x)$ is composed only of the following types of terms:
$$a \cdot \sin(1/x)x^{2n-k}\tag{1}$$
$$\pm \sin(1/x)x^{2n-2k}, \text{ if k even}\tag{2}$$
$$\pm \cos(1/x)x^{2n-2k}, \text{ if k odd}\tag{3}$$
$$\sum_{i=k+1}^{2k-1} [a_ix^{2n-i}\sin(1/x)+b_ix^{2n-i}\cos(1/x)]\tag{4}$$
We can try to prove that this is true by using induction on $k$.
$$f'(x)=\sin(1/x) \cdot 2nx^{2n-1}+\cos(1/x)(-x^{2n-2})$$
The first term is a term like in $(1)$, and the second term is like in $(4)$.
Now assume that the conjecture is true for some $k$. Then we should only see the following terms in $f^{(k+1)}(x)$
$$\sin(1/x)x^{2n-(k+1)}\tag{5}$$
$$\pm \sin(1/x)x^{2n-2(k+1)}, \text{ if k is even}\tag{6}$$
$$\pm \cos(1/x) x^{2n-2(k+1)}, \text{ if k is odd}\tag{7}$$
$$\sum_{i=(k+1)+1}^{2(k+1)-1} [a_ix^{2n-i}\sin(1/x)+b_ix^{2n-i}\cos(1/x)]\tag{8}$$
To check this, we can differentiate $(1)$, $(2)$, $(3)$, and $(4)$ and check if the results only contain terms as in $(5)$, $(6)$, $(7)$, and $(8)$.
Differentiation of $(1)$, $(2)$, and $(3)$ produces the correct results.
My question regards the differentiation of $(4)$.
$$\frac{d}{dx}(\sum_{i=k+1}^{2k-1} [a_ix^{2n-i}\sin(1/x)+b_ix^{2n-i}\cos(1/x)])$$
$$=\sum_{i=k+1}^{2k-1} [a_i(2n-1)x^{2n-i-1}\sin(1/x)-a_i x^{2n-i-2}\cos(1/x)+b_i(2n-1)x^{2n-i-1}\cos(1/x)+b_ix^{2n-i-2}\sin(1/x)]$$
$$=\sum_{i=k+1}^{2k-1} [a_i(2n-1)x^{2n-(i+1)}\sin(1/x)+b_i(2n-1)x^{2n-(i+1)}\cos(1/x)-a_i x^{2n-(i+1)-1}\cos(1/x)+b_ix^{2n-(i+1)-1}\sin(1/x)]$$
$$=\sum_{i=(k+1)+1}^{2(k+1)-1} [a_i(2n-1)x^{2n-i}\sin(1/x)+b_i(2n-1)x^{2n-i}\cos(1/x)-a_i x^{2n-i-1}\cos(1/x)+b_ix^{2n-i-1}\sin(1/x)]\tag{9}$$
The first two terms in the sum are like the terms in $(8)$, but the last two terms in the sum are problematic. They don't seem to fit.
This problem is clearly quite tricky and I've spent a couple hours on it. I believe the reasoning is correct (and it is in the solution manual as well), but the solution manual does not go through every step of every differentiation (and specifically the differentiation of $(4)$ as I showed above).
I am wondering if there is a mistake or if there is some algebraic manipulation of $(9)$ that I am missing.
 A: Your strategy is wildly overcomplicated. There is no need to come up with an explicit formula for the derivatives.
Instead, we show that for all $n$, for all $n$-times continuously differentiable functions $h, g$, the function
$$f(x) = \begin{cases}
  0 & x = 0 \\
  x^{2n} (h(x) \sin \frac{1}{x} + g(x) \cos \frac{1}{x}) & x \neq 0
\end{cases}$$
is $n$-times differentiable and, moreover, if either $g(0) \neq 0$ or $h(0) \neq 0$, the $n$th derivative is discontinuous at $0$.
Proof outline (you should flesh this out): we proceed by induction on $n$.
In the base case, $f^{(0)} = f$ clearly exists. If either $g(0)$ or $h(0)$ is nonzero, prove the function is not continuous at $0$.
In the inductive step, let $n = k + 1$. Find some $k$-times continuously differentiable functions $i, j$ such that
$$f’(x) = \begin{cases}
  0 & x = 0 \\
  x^{2k} (i(x) \sin \frac{1}{x} + j(x) \cos \frac{1}{x}) & x \neq 0
\end{cases}$$
Moreover, show that $i(0) = -g(0)$ and $j(0) = h(0)$. Apply the inductive hypothesis to $i, j$. $\square$
Moral of the story: figure out the right induction. Don’t look for an explicit formula unless said formula is simple; instead, look for properties and a general form.
A: Here is my attempt at the proof proposed by Mark Saving.
Proposition:
$\forall n, n \in \mathbb{N}$
$$h,g \text{ n times differentiable } \implies \begin{array}{l} f(x) = \begin{cases} 0, x=0 \\ x^{2n}(h(x)\sin(1/x)+g(x)\cos(1/x), x \neq 0  \end{cases} \text{ n times diff} \\ (g(0) \neq 0 \text{ or } h(0) \neq 0) \implies f^{(n)} \text{discontinuous at }0 \end{array}$$
Proof
We use induction on $n$.
For $n=1$
$$f(x) = \begin{cases} 0, x=0 \\ x^{2}(h(x)\sin(1/x)+g(x)\cos(1/x), x \neq 0  \end{cases}$$
$$f'(0)=\lim\limits_{m \to 0} \frac{m^2(h(m)\sin(1/m)+g(m)\cos(1/m))}{m}=0$$
because $\sin(1/m)$, $h(m)$, and $g(m)$ are bounded near zero.
For $x \neq 0$
$$f'(x)=(...)+h(x)cos(1/x)+ g(x)sin(1/x)$$
$\lim\limits_{x \to 0} f'(x)$ doesn't exist because $\lim\limits_{x \to 0} h(x)\cos(1/x)$ and $\lim\limits_{x \to 0} g(x)\sin(1/x)$ don't exist.
Now assume that for some $n$ the inductive hypothesis holds, ie the proposition holds for this general $n$.
Let $h(x)$ and $g(x)$ be n times differentiable.
If for some function $f$ we have
$$f'(x)= \begin{cases} 0, x=0 \\ x^{2n}(h(x)\sin(1/x)+g(x)\cos(1/x), x \neq 0  \end{cases}$$
then by applying the inductive hypothesis to $f'(x)$ we conclude that

*

*$f'$ is n-times differentiable, so $f$ is n+1 times differentiable

*$f^{(n+1)}$ is discontinuous at $0$ if $g(0 \neq 0$ or $h(0) \neq 0$
Somehow this inductive step seems slightly weird in that I didn't specify $f$, I specified its derivative. How do we know that $f$ looks like the function in the proposition?
