Proof of $f(x)\geq 0$ for all $x\in A$ with $f$ continuous and $f(x)\geq0$ for all $x\in A$

metric-spacesreal-analysis

Let $f:V\to\mathbb{R}$ be a continuous function and assume that $f(x)\geq 0$ for all $x\in A$. I want to prove that $f(x)\geq 0$ for all $x\in\overline{A}$ (the closure of $A$).

I thought doing this with a contradiction: Assume to the contrary that $f(x)< 0$ for a certain $x\in\overline{A}$. Then we know that for all $\delta>0 :B(x;\delta)\cap A\neq \emptyset$. So there must exist a $p\in A$ where for $f(p)\geq 0$.

We also know that $f$ is continuous, so for all $a\in V$ there exists a $\delta>0$ such that for all $x\in V$ with $|x-a|<\delta$: $|f(x)-f(a)|<\epsilon$.

So, i thought that, if i choose the right epsilon and use the things stated above, maybe i can get a contradiction using the triangle inequality. Someone have a tip / confirm my "strategy"? Thanks.

Best Answer

If $f(x)<0$ for some $x\in\overline A$, take $\delta>0$ such that$$y\in B(x;\delta)\implies |f(y)-f(x)|<-f(x).$$Note that\begin{align}|f(y)-f(x)|<-f(x)&\implies f(y)\in\bigl(2f(x),0\bigr)\\&\implies f(y)<0.\end{align}But this is impossible, since $x\in\overline A$ and therefore $B(x;\delta)$ contains elements of $A$.