Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This is a homework question in my analysis class:

Let $A$ and $B$ be two nonempty closed subsets of a metric space $X$ that do no intersect. Show that there is a continuous function $f:X\rightarrow [a,b]$ such that $f(x)=a$ for all $x\in A$ and $f(x)=b$ for all $x\in B$.

Can someone give me a hint?

share|cite|improve this question
Use functions of the form $f_S(x):=\inf_{x\in S} d(x,y)$. – Davide Giraudo Feb 25 '12 at 15:40

Why don't you start by defining $g\in [0,1]^X$ by $g(x)\equiv \frac{d(x,A)}{d(x,A)+d(x,B)}$. This function is well defined since $A$ and $B$ are closed and the two sets do not intersect. Constructing your function is now trivial.

share|cite|improve this answer

Well you have to deal with this function $g(x)=\frac{d(x,A)}{d(x,A)+d(x,B)}$ now you consider


share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.