# Looking for a differentiable function which behaves somewhat like $\min(x,1)$

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!

-
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

First, let

$$f(x)=\begin{cases}e^{\frac{-1}{x}}&x>0\\0&x\le0\end{cases}$$

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

$$g(x)=\frac{f(x)}{f(x)+f(1-x)}$$

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.

-
Thank you for the sophisticated (to me) answer! – Nick Thomas May 8 '13 at 1:54

$$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:

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:

-
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}$$

-