I would like to find a $C^2$ function $g:\mathbb{R}\rightarrow[0,1]$ such that
$g|_{[-1,1]}=1$ and $g(x)=0$ for $|x|>2.$
I know that being $C^2$ means that the second derivative of $g$ must exist and be continuous, but I find it hard to find one that satisfies the condition. I think a polynomial wouldn't work here but something with a cosine might, although I'm not sure how.