May a compactly supported real-valued function cross $0$ in its support finitely many times?

50 Views Asked by At

This may be an obvious question for many, but I'm not sure if my reasoning is right.

Let $f : \mathbb{R} \to \mathbb{R}$ be a compact supported function, here, this means that the set $supp(f):= \overline{\{x \in \mathbb{R} : f(x) \neq 0\}}$ is compact on $\mathbb{R}$.

Every example I've seen for a compact supported function is a bump function, but I think it could be a function also like the one in this image.

enter image description here

So, $$f(x) = \left\{\begin{matrix} sin\left(2\pi x\right) & \text{if} & x \in (0,2)\\ 0 & \text{if} & x \in (-\infty,0]\\ 0 & \text{if} & x \in [2,\infty)\\\end{matrix} \right.$$

We have that \begin{align} supp(f)& := \overline{\{x \in \mathbb{R} : f(x) \neq 0\}}\\ & = \overline{(0,0.5) \cup (0.5,1) \cup (1,1.5) \cup (1.5,2)}\\ & = \overline{(0,0.5)} \cup \overline{(0.5,1)} \cup \overline{(1,1.5)} \cup \overline{(1.5,2)}\\ & = [0,0.5] \cup [0.5,1] \cup [1,1.5] \cup [1.5,2] \end{align}

Which is compact.

Is my reasoning right or am I missing something important?

Thanks in advance, and sorry if this question is duped.