Continuous function with infimum Let $A$ be a closed subset of a metric space $X$ and $f:A \rightarrow[1,2]$ a continuous function on it. Now I want to find out why the function
$$F(t):=\frac{\inf\{f(s)d(s,t);s \in A\}}{\inf \{d(s,t);s \in A\}}$$ for $t \notin A$ and $F(t):=f(t)$ for $t \in A$ is continuous? It is clear to me that $F:X \rightarrow [1,2]$ too, but I just have difficulties concerning the continuity. I am also aware of the fact that $d(t,A)$ is a continuous function with respect to $t$.
If anything is unclear, please let me know.
 A: Break it down into steps. First we show that for $0 < L \leqslant H$ and $g\colon A \to [L,H]$ continuous (where $A\neq \varnothing$), the function
$$G\colon t \mapsto \inf \left\{ g(s)\cdot d(s,t) : s \in A\right\}$$
is continuous on all of $X$. (The case $g \equiv 1$ gives the continuity of the distance $d(t,A)$ from $A$.)
Fix $t\in X$, and choose a sequence $(s_n)$ in $A$ with $G(t) = \lim\limits_{n\to\infty} g(s_n)\cdot d(s_n,t)$. Then for any $u\in X$ we have
$$G(u) \leqslant \liminf_{n\to\infty} g(s_n)\cdot d(s_n,u) \leqslant \liminf_{n\to\infty} g(s_n)\left(d(s_n,t)+d(t,u)\right) \leqslant G(t) + H\cdot d(t,u).$$
Changing the roles of $t$ and $u$, we obtain
$$\lvert G(t) - G(u)\rvert \leqslant H\cdot d(t,u),$$
so $G$ is even Lipschitz-continuous (with Lipschitz constant $H$).
That shows that $F$ is continuous on $X\setminus A$ - as the quotient of two positive continuous functions. $F$ is continuous on $\overset{\Large\circ}{A}$ by assumption, so it remains to check the continuity on $\partial A$ [which, of course, can be all of $A$]. Hence fix $t \in \partial A$ and $\varepsilon > 0$. By the continuity of $f$ on $A$, there is a $\delta_1 > 0$ such that $d(s,t) \leqslant \delta_1 \implies \lvert f(s)-f(t)\rvert \leqslant \varepsilon$ for $s\in A$. Now we must find a $\delta_2 > 0$ such that for all $u\in X\setminus A$ with $d(u,t) \leqslant \delta_2$ we have $\lvert F(u) - f(t)\rvert \leqslant \varepsilon$.
Define $\rho(u) := d(u,A)$. Then the $s$ in $A$ where $f(s)\cdot d(s,u)$ is close [which is left imprecise on purpose in this discussion] to $G(u) := \inf \{f(s)d(s,u) : s\in A\}$ all lie - for any fixed $\eta > 0$ - in the ball $B_{2\rho(u)+\eta}(u)$, since $d(s,u) \leqslant f(s)d(s,u) \leqslant 2d(s,u)$, and hence $\rho(u) \leqslant  G(u) \leqslant 2\rho(u)$ on the one hand, and $f(s)d(s,u) \geqslant d(s,u) \geqslant 2\rho(u)+\eta \geqslant G(u)+\eta$ for $s\in A\setminus B_{2\rho(u)+\eta}(u)$ on the other.
Now, if $u$ is close to $t$, then $f(s)$ is close to $f(t)$ for all $s\in A\cap B_{2\rho(u)+\eta}(u)$, and therefore we can replace the constants $1$ and $2$ in the above by $f(t)\mp\varepsilon$ if $s\in A\cap B_{2\rho(u)+\eta}(u)$ implies $d(s,t) \leqslant \delta_1$. Then we have $(f(t)-\varepsilon)d(s,u) \leqslant f(s)d(s,u) \leqslant (f(t)+\varepsilon)d(s,u)$ for the interesting $s$, and hence $(f(t)-\varepsilon)\rho(u) \leqslant G(u) \leqslant (f(t)+\varepsilon)\rho(u)$, so
$$f(t)-\varepsilon \leqslant F(u) \leqslant f(t)+\varepsilon$$
for these $u$. To finish it, we need to find a $\delta_2 > 0$ and an $\eta > 0$ such that $d(t,u) \leqslant \delta_2$ implies $A\cap B_{2\rho(u)+\eta}(u) \subset B_{\delta_1}(t)$. Now
$$B_{2\rho(u)+\eta}(u) \subset B_{2\rho(u) + \eta + d(t,u)}(t)$$
by the triangle inequality, and so $2\rho(u) +\eta + d(t,u) \leqslant \delta_1$ suffices. Since $\rho(u) \leqslant d(t,u)$, we can choose $\eta = \delta_2 = \delta_1/4$.
