# Example of an infinitely differentiable function with a given property

What is an example of an infinitely differentiable function $f$ such that $f(x) = 1$ on $[-1, 1]$ and $f(x) = 0$ on $(-\infty, -2] \cup [2, \infty)$?

-

Define $\Psi:\mathbb{R}\to\mathbb{R}$ by $$\Psi(x) = \begin{cases} e^{-1/(1-x^2)} & \mbox{ for } |x| < 1,\\ 0 & \mbox{ otherwise.} \end{cases}$$ This is a $C^\infty$ function. Here is its graph (from Wikipedia):
$\hskip 0.6in$

Let $a=\int_{-\infty}^\infty \Psi(x)\,dx$. Define $\phi:\mathbb{R}\to\mathbb{R}$ by $$\phi(x)=\frac{1}{a}\int_{-\infty}^{2x-1}\Psi(x)\,dx.$$ Then $\phi$ is a $C^\infty$ function which satisfies $\phi(x)=0$ for $x\leq 0$ and $\phi(x)=1$ for $x\geq 1$.

Now define $f:\mathbb{R}\to\mathbb{R}$ by $$f(x)=\begin{cases}\phi(x+2)&\text{ if }x\leq -1,\\1&\text{ if }-1\leq x\leq 1,\\ \phi(-x+2)&\text{ if }x\geq 1.\end{cases}$$ Then $f$ is a $C^\infty$ function that meets your requirements.

-
+1, very nice and complete. –  Alex Becker Mar 30 '12 at 23:35
Thanks! +1 to your answer as well. –  Zev Chonoles Mar 30 '12 at 23:36

We can modify the bump function to fit your requirements. Let $f(x)=e^{\frac{1}{x^2-1}}$ for $x\in [-1,1]$ and $f(x)=0$ otherwise, and define $g(x)$ such that $g(x)=1$ for $x\in [-1,1]$ and $g(x)=ef(|x|-1)$ for $x\in (-\infty,-1]\cup [1,\infty)$. You should be able to verify that this is infinitely differentiable and satisfies your requirements.

-