# The set of points of discontinuity is precisely an open set $U\subset \mathbb{R}^n$

For every open subset $U\subset \mathbb{R}^n$ does there exists a function $f :\mathbb{R}^n \to \mathbb{R}$ such that $f$ is discontinuous at each point of $U$ and continuous on $\mathbb{R}^n\setminus U$?

As I know, given any open set $U\subset \mathbb{R}^n$ there exists a function $f :\mathbb{R}^n\to \mathbb{R}$ such that $f$ is continuous at each point of $U$ and discontinuous on $\mathbb{R}^n\setminus U.$

• If $f : U \to \mathbb R^n$ then $f$ is not defined on $\mathbb{R}^n\setminus U$. Can you clarify your intent? – user4894 Sep 17 '17 at 2:34
• That was typos. I changed it. Thanks :) – Sachchidanand Prasad Sep 17 '17 at 2:39

Let $g(x)$ be the distance from $x$ to $\mathbb R^n\setminus U$. Let $h$ be the characteristic function of $\mathbb Q^n$. Then $f(x)=g(x)h(x)$ has this property. (This is assuming $U\neq \mathbb R^n$; otherwise take $f=h$.)