Just as in the title, suppose $f \in C^\infty ((a,b),\mathbb{R})$ such that $f^{(n)}=0$ for some $n\in\mathbb{N}$. Prove that $f$ is a polynomial.
My solution to this is to use the Taylor expansion about some $a\in\mathbb{R}$, so that $f(x) = f(a) + \sum_{k=1}^{n-1} \frac{f'(a)}{k!}(x-a)^k + \frac{f^{(n)}(\xi)}{n!}(x-a)^n$, but since $f^{(n)}$ is identically zero, we simply have that $f(x) = f(a) + \sum_{k=1}^{n-1} \frac{f'(a)}{k!}(x-a)^k$.
I'm pretty sure this solution is incorrect, however, since this question has been asked on this site and the solution involves the Baire Category Theorem and other subtle analysis/topology arguments. I'm sure if someone had seen this solution, the question would not have gotten 100+ upvotes on mathoverflow. So what's wrong with this argument? Or is it correct?
Also does it make a difference if $f\in C^\infty([a,b];\mathbb{R})$ as opposed to $C^\infty((a,b);\mathbb{R})$?
The question you mention has a different hypothesis, where $f^{(n)}(x)=0$, but $n$ may vary with $x$.
If you only require $f^{(n)}=0$ (for all $x$), then you can easily prove by induction that if $f^{(k+1)}$ is a polynomial, then so is $f^{(k)}$, with the degree increased by one. For starters, if $f^{(n)}=0$, then $f^{(n-1)}$ is constant. And so on.
Your argument does work. It is just more complex than what is needed here.