Let $f: \mathbb R \to \mathbb R$ such that for any open interval $I$ containing zero, there exists $x \in I, x \neq 0$ with $f(x) = 0$. Show that $f^{(n)}(0)$ (the nth-derivative of $f$ at zero), if defined, is zero.
Please help me fix this proof; see Equation (1) and its error.
Proof: Let $(x_n)$ be a sequence converging to zero such that $x_n \neq 0, f(x_n) = 0$ for all $n \in \mathbb N$. Such a sequence always exists, for example, by picking appropriate $x_n$ in $(-1/n, 1/n)$. If $f'(0)$ is defined, $f$ is continuous at zero, and $f(0) = f(\lim x_n) = \lim f(x_n) = 0$.
Likewise, since for all $n \in \mathbb N, x_n \neq 0$ and $\frac {f(x_n)}{x_n} - 0$, if $f'(0)$ is defined, $$\begin{align*}f'(0) &= \lim_{h \to 0} \frac {f(h) - f(0)}h \\ &= \lim \frac {f(x_n)}{x_n} \\ &= 0.\end{align*}$$
For all $p \in \mathbb N$, if $f^{(p)}(0) = 0$ and $f^{(p+1)}(0)$ is defined, then $f^{(p)}$ is continuous at zero and defined on an open interval $I_p$ including zero. Restrict $(x_n)$ to the subsequence in $I_p$. Then $f^{(p+1)}(0) = 0$, since $$\begin{align*}f^{(p+1)}(0) &= \lim_n \frac {f^{(p)}(0 + x_n) - f^{(p)}(0)}{x_n} \\ &= \lim_n \frac {f^{(p)}(x_n)}{x_n} \tag{1} \\ &= 0.\end{align*}$$
I'm unable to justify Line 1 unless $f^{(p)}$ is zero on an interval containing zero, not just a point. I tried expanding $f^{(p)}$ to the limit definition, and using double limits, but this seemed to complicate things without getting anywhere. Can you guide me here?
By definition of derivative, if $f^{(p+1)}(0)$ is defined, then $f^{(p)}(0)$ must also be defined. Therefore, we have by induction that if $f^{(p)}(0)$ is defined, it equals zero.
Discussion:
Intuitively, this means that if a function that is arbitrarily close to flat at a point, to the extent that it is smooth at that point, its derivatives must vanish. This holds for both functions that flatten out simply, such as $x \mapsto x^n$ as well as for functions with never ending small ripples, such as $x \mapsto 0$ if $x = 0$ otherwise $x^n \sin(1/x)$. (This comment is not meant to convey rigor, but to give an intuitive sense of the result.)
If $n$th derivative exists at $x=0$, then all derivatives up to $n-1$st exist in some neighbourhood of zero. Let's restrict ourselves to that neighbourhood.
Per the conditions of the problem, one can find the sequence $x_1,x_2,x_3,\ldots$ converging to $0$ such that $f(x_i)=0$. WLOG we can assume $x_1>x_2>x_3>\ldots>0$.
As per Rolle's theorem, this gives rise to a sequence $x_1'>x_2'>x_3'>\ldots>0$ converging to $0$ such that $f'(x_i')=0$. ($x_i'$ is between $x_i$ and $x_{i+1}$). Repeating the same argument $n-1$ times, we find a sequence $x_1^{(n-1)}>x_2^{(n-1)}>\ldots>0$ converging to $0$ such that $f^{(n-1)}(x_i^{(n-1)})=0$. This implies that $f^{(n-1)}(0)=0$ and, ultimately, that $f^{(n)}(0)=\lim_{i\to\infty}\frac{f^{(n-1)}(x_i^{(n-1)})-f^{(n-1)}(0)}{x_i^{(n-1)}}=\lim_{i\to\infty}\frac{0-0}{x_i^{(n-1)}}=0$.