Non-trivial continuous function from $\mathbb R$ to $\mathbb R_{\geq 0}$ with support on some finite interval? I'm trying to gain an intuition for supports of smooth functions, so I can arrive at perhaps an easier technique of constructing partitions of unity. When I began thinking about this, I realize I know no examples of examples $f: \mathbb R \rightarrow \mathbb R_{\geq 0}$ that satisfy all of the criteria below:

*

*Bounded, so I can renormalize them.

*Non-negative, so I can form convex combinations of them.

*Smooth, so I can get a smooth partition of unity.

*Support in the subset of some finite region of $\mathbb R$: that is, there are reals $l, r$ such that the support  $\{ x : f(x) \neq 0 \}$ is a subset of the open interval $(l, r)$. More formally, $\{ x \in \mathbb R : f(x) \neq 0 \} \subseteq (l, r)$.

An obvious example is the constant function $f(x) = 0$. Let us disbar such a function by adding a condition:


*Non-zero: The function cannot be the constant zero function $f(x) = 0$.

The classic "examples" of smooth bounded functions such as the gaussian $g(x) \equiv e^{-x^2}$ and its variants all have their support as $\mathbb R$. So I now suspect that such a smooth bounded function with "finite interval" support [what is this property called?] does not exist. A proof sketch I have goes as follows:
Proof sketch
We show that the set $f^{-1}(0)$ is clopen, and is not equal to either $\mathbb \emptyset$
or $\mathbb R$. This is absurd since $\mathbb R$ is connected, and has clopen sets
as only $\emptyset$ and $\mathbb R$.
Assume such a function $f: \mathbb R \rightarrow \mathbb R_{\geq 0}$ exists.
Since $f$ is continuous, we have that $Z \equiv f^{-1}(0)$ is a closed subset of $\mathbb R$ since it is the inverse image of a closed set $\{0\}$, and inverse image continuous functions preserve closed subsets.
We have that $Z \neq \emptyset$ since $f$ must be zero at some points as $f$ has finite support and it is smooth.
We also have that $Z \neq \mathbb R$ since the function $f$ is assumed to not be the constant zero function.
Next we show that $Z^\complement$ is closed, hence $Z$ is open.
This leads to contradiction.
For space $\mathbb R_{\geq 0}$, we have the subspace topology.
Thus the set $(\mathbb R\setminus\{0\}) \cap \mathbb R_{\geq 0} = (0, \infty)$ is closed, as it is the intersection of two closed sets.
So $Z^\complement \equiv f^{-1}((0, \infty))$ is closed. So $Z$ is open.
This gives us an absurd clopen set $Z$. Hence such a function $f$ cannot
exist.
Questions

*

*Is the above proof corret?

*How should one think of the fact that we cannot have a  continuous function with "localized" support?

*This shows that $\mathbb R$ does not have a "localized" partitions
of unity; Are there spaces other than $\mathbb R$ which admit localized paritions of unity?

 A: There actually exist infinitely many functions with those properties (these are the basic functions involved in constructing a partition of unity).

with "finite interval" support [what is this property called?]

You probably mean "with compact support", which in $\Bbb{R}^n$ because of Heine-Borel theorem simply means that the support is bounded.
Anyway, if we cheat slightly, then we know instantly that your proof is incorrect somewhere. Why? Because you seem to know about the existence of partitions of unity. In particular $\Bbb{R}$ admits a partition of unity (which is smooth, has compact support and is subordinate to the trivial open cover $\{\Bbb{R}\}$). And any function in a partition of unity satisfies all the conditions you're asking for (amongst other things).

Here's one possible explicit construction. Let $h:\Bbb{R} \to \Bbb{R}$ be defined by
\begin{align}
h(x) :=
\begin{cases}
e^{-1/x} & \text{if $x>0$}\\
0 & \text{if $x \leq 0$}
\end{cases}
\end{align}
Verify for yourself that $h$ is $C^{\infty}$, $0 \leq h(\cdot) < 1$, and $h(x) > 0$ if and only if $x>0$. Next, For any $a,b \in \Bbb{R}$ with $a<b$, define $H_{a,b}: \Bbb{R} \to \Bbb{R}$ by
\begin{align}
H_{a,b}(x) := h(x-a) \cdot h(b-x)
\end{align}
Then, $H_{a,b}$ is $C^{\infty}$, $0 \leq H_{a,b}(\cdot) < 1$, and $H_{a,b}(x) > 0$ if and only if $a<x<b$. In particular, we have that $\text{support}(H_{a,b}) = [a,b]$ is compact.

This is one of those situations where a picture is worth a thousand words. Simply sketch the graph of $h$ using your knowledge of the exponential function, and prove the somewhat technical part that $h$ is smooth at the origin. Once you prove this, the rest is really a matter of messing around with various translations and reflections, and if you have the right picture in mind, you'll be able to reconstruct such a function anytime you want.
A: *

*Here's a desmos link to the function peek-a-boo showed me


*Here's a drawing. The bump function is in purple, the function $h(x)$ is in red.

