Suppose that $f$ is infinitely differentiable on $\mathbb{R}$ and suppose that for all $x\in\mathbb{R}$, $f^{(k)}(x)=0$ for some $k\geq0$. Is it necessarily true that $f$ is a polynomial?
This question was posed to me with $f$ being holomorphic on $\mathbb{C}$ in which case the result follows from basic complex analysis (some derivative vanishes infinitely often in the unit disc and so is identically zero by the identity theorem).
The sets $S_k=\{x\in\mathbb{R}\colon f^{(k)}(x)=0\}$ are closed and cover $\mathbb{R}$ so the Baire Category Theorem applies and gives that the union $\bigcup_{k=0}^\infty S_k^{\text{int}}$ is dense in $\mathbb{R}$ where the interiors of the $S_k$ form an increasing chain $S_0^{\text{int}}\subseteq S_1^{\text{int}}\subseteq\ldots$. In particular, this shows that inside every open ball, there is a smaller open ball on which $f$ is a polynomial. However, this falls short of showing that $f$ is globally a polynomial.
Additionally, I cannot see how to construct a counterexample as it is impossible to glue different polynomials together in a smooth way.
If the question ends up being true, I would also be interested in knowing if an analogous result holds for $\mathbb{R}^n$, although one would have to be careful with the statement of the problem since $e^x$ as a function on $\mathbb{R}^2$ has the property that some derivative is zero at every point.