# An example of an infinitely differentiable function with compact support

Could anyone give me a function infinitely differentiable on the real line and having a compact support? And the function must be nonnegative and normalized, i.e. the integration of the function on the real line must be one.

I tried to think of one myself, but it seems trickier than expected.

• You need to construct such a function out of a function such as $$f(x)=\begin{cases} e^{-1/x}, & x>0 \\ 0, & x\le 0\end{cases}.$$ May 15, 2015 at 16:56
• I tried, but couldn't satisfy the compact support condition. May 15, 2015 at 16:57
• Ah, build another one, $g$, that dies smoothly at $x=1$, say, and then what can you do with the two of them? May 15, 2015 at 16:58
• What about the function $f(x)=0$ for all $x$? May 15, 2015 at 16:58
• @Merideth: Everyone is doing the problem for you, but if you want to try to solve by thinking through what I said, do so, and then worry about normalizing the integral once you're done. May 15, 2015 at 17:06

The classic bump function is nice: $$f(x)=\begin{cases} e^{-\frac{1}{1-x^2}} & \textrm{if }|x|<1 \\ 0 & \textrm{otherwise}\\ \end{cases}$$
I doubt it's normalized, but you just need to divide it by $\int_{-1}^{1}f(t)\;dt$ to normalize.
Let $a, r\ (r>0)$ be numbers. The function: $$f(x)=\begin{cases}\mathrm e^{\tfrac1{(x-a)^2-r^2}}&\text{if}\enspace \lvert x-a\rvert <r\\ 0&\text{if}\enspace \lvert x-a\rvert\ge r\end{cases},$$ is an example of a $\mathcal C^\infty$ function with support in $[a-r,a+r]$.
Fix $\varepsilon>0$ as small as you want and take $\frac{f}{\|f\|_{L^1}}$ with $$f(x)=\begin{cases}1&-\varepsilon\leq x\leq \varepsilon\\ \exp\left(-\frac{(|x|-\varepsilon)^2}{4\varepsilon^2-x^2}\right)&\varepsilon\leq |x|\leq 2\varepsilon\\ 0&|x|\geq 2\varepsilon \end{cases}.$$
Here an example for $\varepsilon=1/2$ ($f$ is not normalized):