Can one modify $1 - e^{-\frac{1}{x^2}}$ so that all derivatives at $x=0$ are $1$ and support is $[-1,1]?$ It is well-known that $f(x) = 1 - e^{-\frac{1}{x^2}}$ satisfies $f^{(i)}(0) = 1$ for all natural numbers $i.$
However, its support $\{x\in \mathbb{R}:f(x)\neq 0\} = \mathbb{R}.$

Question: Can one modify $1 - e^{-\frac{1}{x^2}}$ so that all derivatives at $x=0$ are $1$  and support is $[-1,1]?$

I tried $1 - e^{1-\frac{1}{x^2}}$ because it has value $0$ at both $x=-1$ and $x=1.$
However, it is not differentiable at those points.
 A: How about
$$
f(x) = \exp\left[-\frac{1}{x^2(1-x^2)}\right]\mathbf{1}_{(-1,1)},
$$
where $\mathbf{1}_A$ is the indicator function of the set $A$. This function is smooth, has support $[-1,1]$, and has all derivatives vanish at $x = 0$.
EDIT:
For your second question, this function
$$
f(x) = \frac{\exp(x)}{1+\exp\left(\frac{1}{1-x^2}-\frac{1}{x^2}\right)}\mathbf{1}_{(-1,1)}
$$
is smooth, has support $[-1,1]$, and has all derivatives equal to $1$ at zero. To show this, let $g(x) = (1+\exp[(1-x^2)^{-1}-x^{-2}])^{-1}$. Note that $g(0)=1$, $g^{(n)}(0) = 0^n$, and $f(x) = e^x g(x)$. Then
$$
f^{(n)}(0) = \sum_{i=0}^n\binom{n}{i}e^0g^{(i)}(0) = 1+\sum_{i=1}^n\binom{n}{i}g^{(i)}(0) = 1.
$$
Note that $f$ is not analytic at $0$ here, although it's pretty close.
A: With the new requirements, it looks like you might want to define your function as:


*

*infinitely smooth step function (this one will do) times $e^x$ on $[-1,0]$;

*decreasing step function times $e^x$ on $[0,1]$
This way you'll have all derivatives equal to 0 at both ends, and all derivatives equal to 1 at $x=0$.

All right, if you want an explicit formula, you may have it.
$$f(x)=\begin{cases}\dfrac{e^{-{1\over1+x}}}{e^{-{1\over1+x}}+e^{{1\over x}}}\cdot e^x, & -1<x<0
\\[10pt]
\dfrac{e^{-{1\over1-x}}}{e^{-{1\over x}}+e^{-{1\over1-x}}}\cdot e^x, & \phantom{-}0<x<1\end{cases}$$
A: Following the advice of Ivan Neretin and his comment on my former answer, a possible example of the function you are searching for is the following one
$$
f(x)=
\begin{cases}
e^x \cdot e^{-\dfrac{e^{-\frac{1}{x^2}}}{1-x^2}} & x\in]-1,+1[\\
\\
0 & x\notin]-1,+1[
\end{cases}
$$
You have that
$$
\begin{split}
\frac{\mathrm{d}f}{\mathrm{d}x}&=e^x\cdot e^{-\dfrac{e^{-\frac{1}{x^2}}}{1-x^2}}+e^x\cdot\frac{\mathrm{d}}{\mathrm{d}x} e^{-\dfrac{e^{-\frac{1}{x^2}}}{1-x^2}}\\
&=e^x\cdot e^{-\dfrac{e^{-\frac{1}{x^2}}}{1-x^2}}- e^x\cdot e^{-\dfrac{e^{-\frac{1}{x^2}}}{1-x^2}}\cdot\frac{\mathrm{d}}{\mathrm{d}x}\frac{e^{-\frac{1}{x^2}}}{1-x^2}\\
\end{split}
$$
For $x=0$, the second term of the right side of the equation is $0$ since it is a product of functions one of which is the (infinitely) flat function, while the first one is $1$: proceeding by induction you can prove that 
$$
f^{(i)}(0)=1\quad\forall i\in\Bbb N,
$$
again by the properties of the flat function.
