# differentiable functions

Let $E$ be a closed subset of $\mathbb R$. I proved that there is a real continuous function $f$ on $\mathbb R$ whose zero set is $E$. Is it possible, for each closed set $E$, to find such an $f$ which is differentiable on $\mathbb R$, or one which is $n$ times differentiable, or even one which has derivatives of all orders?

-
The answer is yes! I've given an example below. –  Fly by Night Aug 30 '12 at 20:01

Let's say your interval is $[p,q]$ where $p \le q$. Would the following function do?

$$f(x) := \left\{ \begin{array}{ccc} e^{-1/(x-p)^2} & : & x < p \\ 0 & : & p \le x \le q \\ e^{-1/(x-q)^2} & : & x > q \end{array}\right.$$

We have $f(x) = 0$ for all $p \le x \le q$ and

$$\lim_{h\to 0^{\pm}} \frac{f(p+h)-f(p)}{h} = \lim_{h\to 0^{\pm}} \frac{f(q+h)-f(q)}{h} = 0 \, .$$

In fact this function is infinitely differentiable over all of $\mathbb{R}$.

-

Yes, we can find a function which is infinitely differentiable with $E$ as its zero set. Since $E$ is closed, we know that $E^c$ is open, so $E^c$ is an at most countable union of disjoint open intervals $I_j$, at most two of which are unbounded. Then for each interval $I_j$ we define the associated function $f_j$ which is infinitely differentiable and vanishes outside of $I_j$, while being positive on $I_j$. Then we choose our function to be $$f(x) := \begin{cases} f_j(x) & x\in I_j, \\ 0 & x \in E, \end{cases}$$ Then we note that this is well defined since each $I_j$ are disjoint, and infinitely continuous at all points in $E^c$ by construction. It is also infinitely differentiable at all points in $E$ since for each $x\in E$ we assign the same value that any $f_i$ would assign. Moreover, this function is $0$ exactly on $E$.

Thus all we need to do is create these $f_i's$. So we begin with the function $$g(x) := \begin{cases} e^{-\frac{1}{x^2}} & x > 0, \\ 0 & x \leq 0, \end{cases};$$

Claim : $g(x) \in C^{\infty}$. Certainly the only problem point is $x = 0$, so we consider $g^{(n)}(0)$. \ To do this we first show that for $x > 0$, $g^{(n)}(x) = p(x)e^{-\frac{1}{x^2}}$ where $p(x)$ is a polynomial with negative powers. We see that $g'(x) = 2x^{-3}e^{-\frac{1}{x^2}}$ so certainly this holds here, and now we suppose inductively that $g^{(n)}(x) = p(x)e^{-\frac{1}{x^2}}$ and consider $g^{(n+1)}$:

by the product rule $$g^{(n+1)}(x) = p'(x)e^{-\frac{1}{x^2}} + p(x)( 2x^{-3}e^{-\frac{1}{x^2}}) = e^{-\frac{1}{x^2}}(p'(x) + p(x)2x^{-3})$$ but since $p(x)$ was a polynomial with negative powers by assumption, we have $$p'(x) + p(x)2x^{-3}$$ is a polynomial with negative powers, and hence the induction is complete.

So now we consider $$g^{(n)}(0) = \lim_{x\rightarrow 0}\frac{g^{(n-1)}(x) - g^{(n-1)}(0)}{x-0}$$ but $$\lim_{x\rightarrow 0^{-}}\frac{g^{(n-1)}(x) - g^{(n-1)}(0)}{x - 0} = \lim_{x\rightarrow 0^{-}} 0 = 0$$ and $$\lim_{x\rightarrow 0^{+}}\frac{g^{(n-1)}(x) - g^{(n-1)}(0)}{x - 0} = \lim_{x\rightarrow 0^{+}}\frac{p(x)e^{-\frac{1}{x^2}} - 0}{x - 0} = \lim_{x\rightarrow 0^{+}}p(x)x^{-1}e^{-\frac{1}{x^2}} = 0$$ Thus we have $$\lim_{x\rightarrow 0^{-}}\frac{g^{(n-1)}(x) - g^{(n-1)}(0)}{x - 0} = \lim_{x\rightarrow 0^{+}}\frac{g^{(n-1)}(x) - g^{(n-1)}(0)}{x - 0} = 0 = g^{(n)}(0)$$ Therefore we have $g^{(n)}$ exists for every $n$ and hence, $g(x) \in C^{\infty}$ as desired.

Now that we have $g(x) \in C^{\infty}$ we can manipulate it to give us the functions we need on any interval.

If we have $I_k = (-\infty , a)$ we can define $$f_k := g(a - x)$$ and if $I_k = (a, \infty)$ we can define $$f_k := g(x-a)$$. These functions give us what we need for the two unbounded intervals, since if $x \geq a$, $g(a - x) = 0$ and if $x \leq a$, $g(x - a) = 0$ while both are positive otherwise.

Next let $I_k = (a,b)$ be an interval, then we will consider the function $$f_k := g(x - a)g(b - x)$$. Then clearly for $x \leq a$ we have $g(x - a) = 0$ so $f_k (x) = 0$ and for $x \geq b$ we have $g(b-x) = 0$ so $f_k(x) = 0$, and moreover for $x\in (a,b)$, we know $g(x - a) > 0$ and $g(b - x) > 0$ so $f_k > 0$. Finally this is infinitely differentiable since it is the product of two infinitely differentiable functions. Thus for every possible interval $I_k$ we have the associated $f_k$ we need, and hence we are done.

-