Let $f$ be a $C^\infty$ function on $(c,d)$ ,and
let $O=\cup\_{n\in \mathbb{Z}^+} (a\_n,b\_n)$ where $(a\_n,b\_n)$ are disjoint open interval in $(c,d)$ and $O$ is dense in $(c,d)$.
Suppose for each $n\in \mathbb{Z}^+$ ,$f$ coincides with a polynomial on $(a\_n,b\_n)$.
Is it necessary that $f$ coincide with a polynomial on $(c,d)$?



is f a polynomial provided that it is "partially" smooth?
I believe the answer is "no". The key lemma is:


**Lemma.** Let $f: [c,d] \to {\bf R}$ be smooth, let $I$ be a compact subinterval of $(c,d)$, $q$ be an interior point of $I$, let $n \geq 1$, and let $\varepsilon > 0$. Then there exists a smooth perturbation $g: [c,d] \to {\bf R}$ of $f$ which agrees with $f$ outside of $I$, is a polynomial on a neighbourhood of $q$ of degree at least $n$, but is not a polynomial on all of $I$, and differs from $f$ by at most $\varepsilon$ in $C^n[c,d]$ norm.


If we apply this lemma iteratively for $n=1,2,\ldots$ with $\varepsilon = \varepsilon\_n := 2^{-n}$ and $n=0,1,2,\ldots$, starting with $f\_0 = 0$, and setting $q = q\_n$ to be the first rational (in some enumeration of the rationals) on which $f\_n$ is not locally polynomial, 
one obtains a sequence $f\_1, f\_2, f\_3,\ldots$ of smooth functions on $[c,d]$ which form a Cauchy sequence in $C^k$ for each $k$, and thus converge in the smooth topology to a limit $f$ which is equal to a polynomial on degree at least $n$ on an interval $I\_n$, with the $I\_n$ disjoint and covering all the rationals, thus dense in $[c,d]$, giving the claim.


To prove the lemma, recall from the Weierstrass approximation theorem that the polynomials are dense in $C^0[c,d]$; integrating this fact repeatedly we see that they are dense in $C^n[c,d]$ as well. So we can approximate $f$ to arbitrary accuracy by a polynomial $h$ in the $C^n$ norm; by a small perturbation one can ensure that $h$ has degree at least $n$. Now using a smooth partition of unity, one can create a merged function $g$ that equals $h$ near $q$ and equals $f$, which can be made arbitrarily close in $C^n$. By modifying $g$ a little bit in $I$ away from $q$ one can ensure that $q$ is not polynomial on all of $I$.


The problem here is superficially similar to that in the previous question [If $f$ is infinitely differentiable then $f$ coincides with a polynomial](https://mathoverflow.net/questions/34059/if-f-is-infinitely-differentiable-then-f-coincides-with-a-polynomial) , but the latter has qualitative control at every single point (allowing the powerful Baire category theorem to come into play), whereas here one only has qualitative control on a dense set, which is a far weaker statement, and one which allows for a great deal of flexibility.


