Prove that a function is continuous in a metric space Here is the problem :
Let $(X,d)$ be a metric space, and let $A$ be a non-empty closed subset of $X$ $($$\varnothing\neq$$A$$\subset$$X)$ , and let $f:A\to\mathbb{R}$ be a bounded continuous function . I want to prove that function $g:X\!\smallsetminus\!A\to \mathbb{R}$ that is defined by 
$$g(x)=\inf\{\,f(y)d(x,y):y\in A\}$$ 
is continuous .
I am thinking that since we have $\inf\{d(x,y):y\in A\}$ and $A$ is a non-empty closed subset of $X$ we should use the fact that $\text{dist}(x,A)$ metric is continuous if $A$ is a closed nonempty subset of $X$. Also since $f:A\to\mathbb{R}$ is a bounded continuous function and $A$ is closed its infimum should be its minimum. So in a way the product of $\inf\{f(A)\}\text{dist}(x,A)$ is continuous. I am not really sure if I am on the right path here. I could use some help. Thank you.
 A: Let $M=\sup\lvert\,f(x)\rvert$. Then
$$
\lvert\,f(y)d(x_1,y)-f(y)d(x_2,y)\rvert \le \lvert\,f(y)\rvert \lvert d(x_1,y)-d(x_2,y) \lvert
\le M \lvert d(x_1,y)-d(x_2,y) \lvert\le M d(x_1,x_2),
$$
since $\lvert d(x_1,y)-d(x_2,y)\rvert \le d(x_1,x_2)$, and hence
$$
f(y)d(x_2,y)-M d(x_1,x_2)\le f(y)d(x_1,y)\le f(y)d(x_2,y)+M d(x_1,x_2).
$$
Thus
$$
g(x_1)=\inf_y f(y)d(x_1,y)\le f(y)d(x_2,y)+M d(x_1,x_2),
$$
and hence for every $y$
$$
g(x_1)-Md(x_1,x_2)\le f(y)d(x_2,y),
$$
and thus
$$
g(x_1)-Md(x_1,x_2)\le \inf_y f(y)d(x_2,y)=g(x_2)
$$
or
$$
g(x_1)-g(x_2)\le Md(x_1,x_2).
$$
Interchanging $x_1$ and $x_2$ we obtain
$$
g(x_2)-g(x_1)\le Md(x_1,x_2),
$$
and thus
$$
\lvert g(x_2)-g(x_1)\rvert \le Md(x_1,x_2).
$$
A: Hint. It is not clear whether this approach works, because the fact that you are looking for an infimum makes it hard to use the continuity of $d$ directly. You might be better off proving an inequality instead. (Also, you are mistaken about the infimum being a minimum - $A$ may be closed but not compact.)
Namely, if $f$ is bounded in absolute value by $M$, then I would suggest proving that $|g(x_2) - g(x_1)| \leq Md(x_2,x_1)$.
Edit: Since a complete answer has now been given, I will also give my own. Let $x_1, x_2 \in X$ and $\epsilon > 0$ be given. Pick $a \in A$ such that $f(a)d(x_1,a) \leq g(x_1) + \epsilon$. Then 
$$g(x_2) \leq f(a)d(x_2,a) = f(a)d(x_1,a) + f(a)[d(x_2,a) - d(x_1,a)] \leq g(x_1) + \epsilon + Md(x_2,x_1).$$
Letting $\epsilon \to 0$, we find $g(x_2) - g(x_1) \leq Md(x_2,x_1)$. Reversing the roles of $x_1$ and $x_2$ then yields the desired inequality.
