I saw a thread (Find a function smooth at one isolated point) in which it is asked whether or not it is possible for a function to be smooth at a point, but not smooth on a deleted neighbourhood of said point. The thread is closed with an accepted answer despite the answer seeming to be incorrect, so I would like to re-ask the question here.
I have read (here: Example of a function continuous at only one point.) that $$f=\begin{cases}x\,\mathrm{if}\,x\in\mathbb{Q}\\ 0\,\mathrm{if}\,x\in\mathbb{R}\setminus\mathbb{Q} \end{cases}$$ is only continuous at $x=0$. If it is continuous at $x=0$, then maybe $$f=\begin{cases}\sum_{k=1}^{\infty}x^k\,\mathrm{if}\,x\in\mathbb{Q}\\ 0\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\mathrm{if}\,x\in\mathbb{R}\setminus\mathbb{Q} \end{cases}$$ is smooth at $x=0$ and nowhere else (does this work?).
As I suggested yesterday, I will try to fix the example Paul Sinclair made in this post.
Let $f_0$ be a continuous and nowhere differentiable function. We define recursively for $n\geq 0$ as follows: $$ f_{n+1}(x) = \begin{cases} f_n(x),& x\leq - \frac{1}{n+1}, \\ K_{n+1}(x) + \int_{-\frac{1}{n+1}}^x f_n(y)dy,& x\in \left( - \frac{1}{n+1}; 0 \right] \end{cases} $$ where $K_{n+1}$ is a polynomial of degree $n$ ensuring that $f_{n+1}$ is $C^n$ on $\left( - \frac{1}{n+1}; 0 \right)$. In fact, $$ K_{n+1}(x)= \sum_{j=0}^n a_j \left( x+ \frac{1}{n+1} \right)^j$$ with $$ a_0 = f_n\left( -\frac{1}{n+1} \right), \qquad a_k = \frac{f_n^{(k)}\left(-\frac{1}{n+1}\right) - f_n^{(k-1)}\left(-\frac{1}{n+1}\right)}{k!} \quad \text{for } 1\leq k \leq n $$ will do the job (we just have to compare the left and the right limits of the derivatives).
Next, we define $$ f(x) = f_n(x) \qquad \text{for } x\in \left( - \frac{1}{n}; - \frac{1}{n+1} \right] $$ By construction this yields a function which is $C^n$ on $\left( - \frac{1}{n}; 0 \right)$ and such that $f^{(n)}$ is continuous, but nowhere differentiable on $\left(-\frac{1}{n}; - \frac{1}{n+1} \right]$. Now we extend $f$ to $\mathbb{R}\setminus \{ 0\}$ by defining $ f(x) := f(-x) $ for $x>0$ and $f(0):=0$.
Then this $f$ is $C^n$ on $\left( - \frac{1}{n}; \frac{1}{n} \right) \setminus \{ 0\}$ and such that $f^{(n)}$ is continuous, but nowhere differentiable on $\left(-\frac{1}{n}; \frac{1}{n} \right) \setminus \left(-\frac{1}{n+1}; \frac{1}{n+1} \right)$.
This almost yields the desired example. We just need to modify $f$ in such a way that it is smooth in zero. Following the idea by Paul Sinclair we multiply with a smooth function which is positive except for the origin (so that we do not change the regularity away from the origin) and with enough decay s.t. the function becomes smooth in the origin. For this we need to estimate the derivatives of $f$.
For all the estimates I going to do, I will denote by $ \Vert \cdot \Vert_{I}$ the supremum norm on the interval $I$.
First we note that for every $k\in \mathbb{N}$ we have $$ \Vert K_{n+1} \Vert_{[-1;0]} \leq 2 \sum_{j=0}^n \left\vert f_n^{(j)} \left( -\frac{1}{n+1}\right) \right\vert \qquad (1)$$ and (this we can prove by induction) $$ f_{n+1}^{(k)}(x) = f_{n-k+1}(x) + \sum_{j=0}^{k-1} K_{n-j+1}^{(k-j+1)}(x) \qquad (2) $$ Combining $(1)$ and $(2)$ we get $$ \Vert f_{n+1}^{(k)} \Vert_{\left[- \frac{1}{n+1};0\right)} \leq \Vert f_{n-k+1} \Vert_{\left[- \frac{1}{n+1};0 \right)} + 2 \sum_{j=0}^{k-1} \sum_{l=0}^{n-j} \Vert f_{n-j}^{(l)} \Vert_{\left[- \frac{1}{n+1};0\right)} \leq 3 \cdot (n+1)^k \max_{\substack{0 \leq s \leq n,\\ 0 \leq t \leq \min\{s,k\}}} \Vert f_s^{(t)} \Vert_{\left[- \frac{1}{n+1};0\right)} $$ Using induction we get $$ \Vert f_{n+1}^{(k)} \Vert_{\left[- \frac{1}{n+1};0 \right)} \leq 3^{n+1} \cdot (n+1)^{(n+1)\cdot k} \cdot \underbrace{\Vert f_0 \Vert_{[-1;0]}}_{=:C} $$
Now we fix $k$. Let $n\geq k+1$, then we have for $x\in \left[ - \frac{1}{n+1}; - \frac{1}{n+2} \right]$ $$ \vert f^{(k)}(x) \vert = \vert f_{n+1}^{(k)}(x) \vert \leq C \cdot 3^{n+1} \cdot (n+1)^{(n+1)\cdot k}$$ From which we conclude for all $x\in (-1;1)\setminus \{ 0 \}$ (we get it on the positive axis as we previously extended $f$ such that $f(x) = f(-x)$, hence all the estimates still hold true) $$ \vert f^{(k)}(x) \vert \leq C \cdot 3^{\frac{1}{\vert x \vert}} \cdot \left( \frac{1}{\vert x \vert}\right)^{\left(\frac{1}{\vert x \vert}\right) \cdot k} $$
Finally we have that $$ g(x) = \begin{cases} \left(\left( \frac{1}{\vert x \vert}\right)^{\left(\frac{1}{\vert x \vert}\right)^{\left(\frac{1}{\vert x \vert}\right)}}\right)^{-1} f(x),& x\neq 0\\ 0,& x=0 \end{cases} $$ is an example of a function which is only smooth at the origin.