TITLE: What's an example of a function whose Taylor series converges to the wrong thing?
QUESTION [24 upvotes]: Can anyone provide an example of a real-valued function f with a convergent Taylor series that converges to a function that is not equal to f (not even locally)?

REPLY [24 votes]: Another thing to note is that there are smooth functions whose Taylor series do not converge to the function in a neighborhood of ANY point!  An easy example of this can be found here:
http://web.archive.org/web/20141230224759/http://www.math.niu.edu/~rusin/known-math/99/nowhere_analy
The example looks as follows:
$$F(x) = \sum_{n=0}^{\infty} \frac {\exp(2^n i x)} {n!},
\quad F^{(k)}(x) = \sum_{n=0}^{\infty} (2^n i)^k \frac {\exp(2^n i x)} {n!}$$
For every $k$, the above series converges absolutely for real $x$, so the function $F$ is smooth.
On the other hand, if $x=a/2^N$ for some integers $a$ and natural number $N$, then for $k\in 4\mathbb{Z}$ we have
$$|F^{(k)}(x)| \geq \frac {2^{Nk}} {N!} - \sum_{n<N} \frac {2^{nk}} {n!} > \frac {2^{Nk-1}} {N!}$$
provided that $2^k > 2N$. Therefore, the Taylor series of $F$ has convergence radius $0$ at $x$. Since the set on which $F$ is analytic is open, this means that $F$ is nowhere analytic on $\mathbb{R}$.