A bump function is a smooth function with compact support, especially one that is not zero on a space that it not compact.
One reason the category SmthMfd of smooth manifolds and smooth functions is important, hence one reason why differential geometry is special, is that a good supply of bump functions exists; this fact accounts for the great flexibility of smooth objects, in stark contrast to analytic geometry or algebraic varieties (since non-zero analytic or algebraic functions with compact support exist only on compact spaces). For instance, bump functions can be used to construct partitions of unity, which can in turn be used to smoothly patch together local structures into a global structure without obstruction, as for example Riemannian metrics.
A bump function is a function on Cartesian space $\mathbb{R}^n$, for some $n \in \mathbb{R}$ with values in the real numbers $\mathbb{R}$
such that
$b$ is smooth;
$b$ has compact support.
For every closed ball $B_{x_0}(\epsilon) = \{x \in \mathbb{R}^n \,\vert\, {\Vert x - x_0 \Vert} \leq \epsilon\} \subset \mathbb{R}^n$ there exists a bump function $b \colon \mathbb{R}^n \to \mathbb{R}$ (def. 1) with
Consider the function
given by
By construction the support of this function is the closed unit ball at the origin, $Supp(\phi) = B_0(1)$.
We claim that $\phi$ is smooth. That it is smooth away from $r \coloneqq {\Vert x \Vert} = 0$ is clear, hence smoothness only need to be checked at $r = 0$, where it amounts to demanding that all the derivatives of the exponential function vanish as $r \to 0$.
But that is the case since
This clearly tends to zero as $r \to 1$. The form of the higher derivatives is the same but with higher inverse powers of $(r^2 -1)$ and so this conclusion remains the same for all derivatives. Hence $\phi$ is smooth.
Now for arbitrary radii $\varepsilon \gt 0$ define
This is clearly still smooth and $Supp(\phi_{\varepsilon}) = B_0(\epsilon)$.
Finally the function $x \mapsto \phi_\varepsilon(x-x_0)$ has support the closed ball $B_{x_0}(\varepsilon)$.
Define
so that the family $(\psi_\varepsilon)_\varepsilon$ is a smooth approximation to the identity? (of convolution, the Dirac functional), compactly supported on the closed ball of radius $\varepsilon$ and having an $L^1$-norm equal to $1$. Then, it is standard that for any pair $K \subset V$ with $K$ compact and $V$ open in a cartesian space $\mathbb{R}^n$, we can choose an open $U$ containing $K$ and with compact closure contained in $V$, and then taking the convolution product
of $\psi_\varepsilon$ with the characteristic function $\chi_U$, for $\varepsilon$ sufficiently small, we obtain a smooth function equal to $1$ on $K$ and equal to $0$ outside $V$.
By performing the above construction in charts, we obtain, in any smooth manifold, a smooth function equal to $1$ on any compact subspace $K$ and equal to $0$ outside any neighbourhood $V$ of $K$. (This is a smooth regularity property.)
…
An different example is examined in detail in
One can also build bump functions that are nowhere analytic (as opposed to merely on the boundary of the support, as above) using, for instance, the Fabius function: