Infinitely differentiable function with given zero set?
In fact it's true for an closed subset $A$ of $\mathbb R^d$. If $A=\complement_{\mathbb R^d}B(x_0,r)$, then we put $f(x)=\mathbf 1_{B(x_0,r)}\exp\left(\frac 1{||x-x_0||^2-r^2}\right)$. For the general case, $A$ is a countable intersection of complement of open balls, namely $A=\bigcap_{n\in\mathbb N}A_n$. Let $f_n$ which works for all $n$. Since $f_n\geq 0$, putting $f=\sum_{n\in\mathbb N}a_nf_n$ we just have to choose $a_n>0$ such that the series (and its derivatives) converges for the topology of $C^{\infty}(\mathbb R^d)$. We put $$a_n=\begin{cases} \frac 1{2^k}\left(\sum_{|\alpha|\leq n}\sup_{|x|\leq n}|\partial^{\alpha}f_n(x)|\right)^{-1}&\mbox{ if }\sum_{|\alpha|\leq n}\sup_{|x|\leq n}|\partial^{\alpha}f_n(x)|\neq 0;\\\ \frac 1{2^k}&\mbox{otherwise.}\end{cases}$$ We can check that for all compact $K$ of $\mathbb R^d$ and $\alpha\in\mathbb N^d$ the sequence $\sum_n a_nf_n$ is convergent. Take $N$ such that $K\subset B(0,N)$ and $|\alpha|\leq N$ \begin{align*} \sup_{x\in K}\left|\partial^{\alpha}\left(\sum_{j=0}^{n+m}a_jf_j-\sum_{j=0}^na_jf_j\right)\right|&=\sup_{x\in K}\left|\sum_{j=n+1}^{n+m}a_j\partial^{\alpha}f_j\right|\\ &\leq \sum_{j=n+1}^{n+m}a_j\sup_{|x|\leq N}|\partial^{\alpha}f_j|, \end{align*} and $a_j\sup_{|x|\leq N}|\partial^{\alpha}f_j|\leq 2^{-j}$ so we can conclude.
The open set ${\mathbb R} \backslash A$ is the union of at most countably many intervals $J_k$, of which at most two are unbounded. Let $f_k$ be a $C^\infty$ "bump" function that is positive on $J_k$ and $0$ everywhere else. If $J_k$ is unbounded, I'll require also that $f_k$ is constant outside some bounded interval. Take $f(x) = \sum_k c_k f_k(x)$ where $c_k > 0$ is small enough so that $|c_k f_k^{(j)}(x)| < 2^{-k}$ for $0 \le j \le k$ and all $x$. Then each series $\sum_k c_k f_k^{(j)}(x)$ converges absolutely and uniformly for all $x$, so that its sum is $f^{(j)}(x)$ and $f$ is $C^\infty$.
Yes, you can read a proof on page 43 of these notes: http://www.math.ru.nl/~mueger/diff_notes.pdf (Lemma IV.1.2).
However, that proof is for the more general case of a smooth function $f:\mathbb{R}^n\to \mathbb{R}$, so maybe someone can suggest a more elementary proof for $n=1$.