Find a sequence of functions such that $f_n(x) = f(x)$ for all $n$ if $d(x, p) \le r$ and $f_n(x) \rightarrow 0$ for all other $x$ I am trying to find an explicit function that satisfies this condition. The question given is:
Let $(M, d)$ be a metric space, $f:M \rightarrow \mathbb{R}$ continuous on $M$. Show that for every $p \in M$ and all real numbers $r > 0$ there exists a sequence of continuous functions $\{f_n\}$ such that $f_n(x) = f(x)$ for all $n$ if $d(x, p) \le r$ and $f_n(x) \rightarrow 0$ for all other $x$.
I've been trying to construct such function that satisfies the condition but with no luck. Is there any hint I could get? I am thinking that maybe we want $r$ to be dependent on $n$, say $d(x, p) \le r = n \cdot f(x)$, then $f_n(x) = nx = f(x) $ for all $n$ is satisfied. But if we choose $x = \frac{1}{n^2}$, we get $f_n(x) \rightarrow 0$. But I am not sure if we can just pick any $x$ like that since its a point of $M$, and it could be any metric space. And I didn't even abuse the condition that $f$ is continuous at $p$.
 A: Hint: If you could find a continuous $g:M\to [0,\infty)$ such that $g =0$ on $\overline {B(p,r)}$ and $g>0$ elsewhere, you could define
$$f_n(x) = f(x)\left (\frac{1}{1+g(x)}\right)^n.$$
A: Note that per the question you have to show something for all $p\in M$ and $r > 0$. So you cannot argue "maybe we want r to be dependent on n". $r$ is given to you. The only thing you can do is define the $f_n$, which can of course depend on the data given to you, like $f$ and $r$.
Hint: Consider $g_n: \{x \in \mathbb R: x \ge 0\} \rightarrow \mathbb R$
$$
g_n(x)=\begin{cases}
1,                & \text { if } x \le r+\frac1n \\
1-n(x-r-\frac1n), & \text { if } r+\frac1n < x < r+\frac2n \\
0,                & \text { if } x \ge r+\frac2n \\
\end{cases}
$$
Draw that function for maybe $n=2,3$ and some example $r$. Understand how it looks like, where it is continuous and what $\lim_{n \to \infty} g_n(x)$ is for each $x$ in the non-negative reals.
Then notice that the domain of $g_n$ are the non-negative reals, something the distance function of a metric space maps into. Maybe you can finally combine $f$ and $g_n$ to get your $f_n$.
