Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

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

Is there a differentiable function $f : [0,2] \rightarrow [0,1]$ such that $f(x) = 0$ iff $x=0$ and $f(x) = 1$ iff $x \in [1,2]$? What about $n$ times differentiable for any $n$, or infinitely differentiable? Thank you!

share|cite|improve this question
The usual function one considers to get smooth (infinitely differentiable) things like that is $f(x)=e^{-1/x}$ on $(0,+\infty)$, $f(x)=0$ on $(-\infty,0]$. Then you can build your function with this one. – 1015 May 8 '13 at 1:48
up vote 6 down vote accepted

First, let


It can be shown that $f$ is smooth. Then one such desired function is


Since $f$ is smooth, and $f(x)+f(1-x)$ is never $0$, $g$ is also smooth. $g$ takes values $0$ for $x<0$, and values $1$ for $x>1$. It's called a smooth transition function.

share|cite|improve this answer
Thank you for the sophisticated (to me) answer! – Nick Thomas May 8 '13 at 1:54

How about

$$f_n(x) = \left\{ \begin{array}{ll} 1-(-1)^n(x-1)^n & 0\leq x \leq 1 \\ 1 & 1\leq x\leq 2. \end{array} \right. $$

This will be $n-1$-times differentiable for any integer $n\geq 2$. The graphs of these functions for $n=1$ through $10$ look like so:

enter image description here

As Jared has already shown, we can make the function infinitely differentiable at $x=1$. A minor variation of his example is

$$f(x) = \left\{ \begin{array}{ll} 1 - e^{1 - 1/(1 - x)} & 0\leq x \leq 1 \\ 1 & 1\leq x\leq 2, \end{array} \right. $$

which looks like so:

enter image description here

share|cite|improve this answer
This doesn't work for n odd. – anonymous May 8 '13 at 1:48
Thank you! I feel a bit silly for not thinking of this! – Nick Thomas May 8 '13 at 1:52
To clarify: I believe this is once differentiable -- correct? – Nick Thomas May 8 '13 at 1:57
@NickThomas I believe it should be $n$ times differentiable. – Mark McClure May 8 '13 at 2:00
@NickThomas Upon further review, I'd say $n-1$ times differentiable. – Mark McClure May 8 '13 at 2:09

This just addresses the "does there exist such a function" with only one differentiation.

We want $f'(x) = 0$ for $x \in [1, 2]$ so that the function is constantly $1$. We could define such a function piecewise:

$$f(x) = \begin{cases} \sin^2\frac{\pi x}{2} & 0\le x \lt 1 \\ 1 & 1 \le x \le 2 \end{cases}$$

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.