Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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)$?

share|cite|improve this question
up vote 4 down vote accepted

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$ enter image description here

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.

share|cite|improve this answer
+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.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.