Skip to main content
3 of 3
added 134 characters in body
Roland Bacher
  • 17.9k
  • 3
  • 45
  • 113

André Henriques answer for a closed set $C$ can easily be improved to $C^\infty$ by considering $e^{1/(\alpha-x)+1/(x-\beta)}$ if $x\not\in C$ where $\alpha$ is the supremum of all elements $< x$ in $C$ (and $\alpha=-\infty$ if $C$ contains no elements which are $< x$) and where similarly $\beta$ is the infimum of all elements $> x$ in $C$ (respectively $\beta=\infty$ if $C$ contains no elements $> x$).

Roland Bacher
  • 17.9k
  • 3
  • 45
  • 113