# $V$ is open , then $V=\{x\in \mathbb R:f(x)>0\}$ for some continuous function $f$

Let $V$ be a non-empty open set of real numbers , then how to prove that there is a continuous function $f:\mathbb R\to \mathbb R$ such that $V=\{x\in \mathbb R:f(x)>0\}$

• Take $f(x)$ to be the distance of $x$ to the complement of $V$. – Etienne May 31 '14 at 8:16
• @Etienne Would it also work to take the convolution of the characteristic function of $V$ with a bump function? – Rudy the Reindeer May 31 '14 at 19:43
• @MattN. I'm afraid your convolution will be positive at some points outside $V$. – Etienne May 31 '14 at 21:53
• @Etienne Too bad : ) Thank you for your comment! – Rudy the Reindeer Jun 1 '14 at 5:26

Etienne's comment is a canonical construction of such a function: $$f(x) = \inf\{ |x-y| : y\in \mathbb R\setminus V\}$$ The key points are:
1. $f(x)=0$ when $x\notin V$ (easy)
2. $f(x)>0$ when $x\in V$ (use the fact that $V$ contains a neighborhood of $x$ to give a lower bound for the set $\{ |x-y| : y\in \mathbb R\setminus V\}$
3. $f(x) \le f(x')+ |x-x'|$ for all $x,x'\in \mathbb R$ (use the triangle inequality)
4. $|f(x) - f(x')| \le |x-x'|$ (use item 3 twice)
As an aside: it is also possible to construct a smooth function $f$ with this property, see Every closed subset $E\subseteq \mathbb{R}^n$ is the zero point set of a smooth function.