Let $f:R \to R$ be a continuous function that $\lim_{x\to +\infty}f(x)=\lim_{x \to -\infty}f(x)=0$. for every $\epsilon>0$ . show that ther is function $g:\mathbb{R}\to \mathbb{R}$ continuous with $\{x \in \mathbb{R}| g(x) \neq 0\}$ compact and $\sup_{x \in \mathbb{R}} |f(x)-g(x)|< \epsilon$
can you one help me with this question i have no idea to where to start
Well. Fix $\varepsilon>0$. Since \begin{align} \lim_{|x|\rightarrow \infty} f(x) = 0 \end{align} then there exists $M>0$ such that when $|x|>M$ we have that $|f(x)|<\varepsilon$.
Let us now choose $g$ continuous such that $g\equiv f$ on $[-M, M]$, $g\equiv 0$ for all $|x|>2M$, and $|g|\leq |f|$ for all $ x \in [-2M, -M]\cup[M, 2M]$.
Then we see that \begin{align} \sup_{x \in \mathbb{R}}| f(x)-g(x)| \leq &\ \sup_{x \in (-\infty, -M]}|f(x)-g(x)| + \sup_{x \in [-M, M]} |f(x)-g(x)|+\sup_{x \in [M, \infty)}|f(x)-g(x)|\\ \leq&\ \sup_{x \in (-\infty, -M]}|f(x)-g(x)|+\sup_{x \in [M, \infty)}|f(x)-g(x)|\\ \leq&\ 4\varepsilon. \end{align}