# A function that is smooth, analytic on $[0, \infty]$, but not analytic on $\mathbb{R}$

I want to find a function that is smooth (i.e. $C^{\infty}$), that is furthermore real analytic on $[0,\infty]$ but not real analytic in all of $\mathbb{R}$. I guess I could shift the standard example $e^{-\frac{1}{|x|}}$ to the left by using $e^{-\frac{1}{|x+1|}}$ for example and I would fulfill the desired specs, but is there a genuinely different example? Maybe involving some version of a geometric series?

• take any analytic function on $\mathbb{R}$ and multiply it with a cutoff function which is smooth, identically $=1$ on $[-\varepsilon,\infty)$ and $=0$ for $x\le -1$, say. Commented Apr 14, 2017 at 14:52

define $f(x)=\begin{cases} g\in [0,\infty)\\ D(x) \in (-\infty, 0) \end{cases}$
where $g\in C^{\omega}$ ($g$ is real analytic, and hence smooth), and $D(x)%$ is the Dirichlet function, which is nowhere continuous, and hence nowhere analytic. Now if you wanted to have a smooth function which is also nowhere analytic, just take $f(x)=g(x)\mathbf{1}_{x\geq0}+\mathbf{1}_{x<0}h(x)$ where $g$ is smooth and $h(x)$ is smooth but nowhere analytic (such functions are dense in the space of smooth functions).