# How to check whether this function is continuous or not..?

Let A and B be two disjoint closed sets of any Metric space X.I have to construct a continuous function such that
$f(x):= 0$ if x belongs to $A$
$f(x) = 1$ if x belongs to $B$

My idea is to use the concept of distance between a point and a set.So I tried like this..
$f(x):= 0$ if $d(x,A) = 0$ and
$f(x) = 1$ if $d(x,A) \neq 0$

I am able to prove $f$ is continuous if both $x$ and $y$ belongs to $A$ or Both belongs to $B$.. But how to prove if $d(x,y)$ less than $\delta$ ($x$ belongs to $A$ and $y$ belongs to $B$) $\Rightarrow d(f(x),f(y))$ less than $\epsilon$.

• Something like $d(x,A)/(d(x,A)+d(x,B))$ should work, no? – Forever Mozart Jun 22 '14 at 8:28
• how.. if u consider that then f(x)= 0 if x belongs to A and if x belongs to B WHAT HAPPENED..can u explain me that.. because since A is closed, d(x,A)=0 if x belongs to A. – user157562 Jun 22 '14 at 8:33
• See also: math.stackexchange.com/questions/47360/… (Not sure whether this should be considered duplicate.) – Martin Sleziak Jun 22 '14 at 9:07

The problem with your approach is that your function may have a jump discontinuity at the boundary of $A$. Consider for instance what would happen at $x=1/3$ if $X=\mathbb [0,1]$, $A=[0,1/3]$, and $B=[2/3,1]$.

For $K\subseteq X$ define $d(x,K)=$inf{$d(x,y):x\in K$}. Show that this function is continuous.Then define $f:X\to\mathbb R$ by $f(x)=d(x,A)/(d(x,A)+d(x,B))$. Using the fact that $A$ and $B$ are closed, you should be able to show $f(x)=0$ iff $x\in A$ and $f(x)=1$ iff $x\in B$. Now you can also show $f$ is defined on all of $X$. It will be continuous as sums and quotients of continuous real-valued functions are continuous everywhere they're defined.

• thank you..i can understand now. – user157562 Jun 22 '14 at 9:11
• no problem, glad I could help – Forever Mozart Jun 22 '14 at 9:16