# For a given closed set E of real numbers, there exists a continuous function such that the set of zeros of the function is precisely the given set E

I would like to prove the following proposition: "For a given closed set $E$ of real numbers, there exists a continuous function $f$ such that the set of zeros of the function is precisely the given set $E$".

I understand that the set of zeroes of a continuous function is closed, but as far as I understand, a continuous function is given in this statement. However, in the proposition I want to prove, a closed set $E$ is given, so it seems that the proof will be different from the proof of "the set of zeroes of a continuous function is closed".

Also, I have learned that a function $f$ is continuous iff the inverse image of any closed set under $f$ is closed. I think this might be useful, but I don't have any clue how to use it to prove the proposition.

Thanks.

• Take $$f(x)= \inf \{ |x-y|: y \in E \}$$ i.e. $f(x)=\mathrm{distance}(x,E)$. Commented Nov 17, 2016 at 10:44
• Which is one of the subparts of the Tietze extension theorem, a far more general theorem than the one above. Commented Nov 17, 2016 at 10:44
• How can I prove that $f(x)=distance(x,E)$ is continuous? Commented Nov 17, 2016 at 13:34
• @JeongHwanOh: Use the fact that $E$ is closed to show that for each $x\in X$ there is a $y\in E$ such that $f(x)=|x-y|$. Then show that if $x_n\to x$, then $f(x_n)\to f(x)$; this argument makes extensive use of the triangle inequality. Commented Nov 17, 2016 at 14:41