Continuous function and dense set

Solution 1:

The first part is perfect. The second part needs a little more help. To prove the second part, let $\epsilon > 0$ and $x\in X$. Since $f$ and $g$ are continuous, there exist $\delta_1, \delta_2 > 0$ such that for all $p\in X$, $d_X(x,p) < \delta_1$ implies $d_Y(f(x),f(p)) < \epsilon/2$ and $d_X(x,p) < \delta_2$ implies $d_Y(g(x), g(p)) < \epsilon/2$. Since $E$ is dense in $X$, there is point $e\in E$ such that $d_Y(x,e) < \min\{\delta_1, \delta_2\}$. Thus

\begin{align}d_Y(f(x),g(x)) &\le d_Y(f(x),f(e)) + d_Y(f(e),g(x))\\ & = d_Y(f(x),f(e)) + d_Y(g(e),g(x)) \\ &< \frac{\epsilon}{2} + \frac{\epsilon}{2} \\ &= \epsilon.\end{align}

Since $\epsilon$ was arbitrary, $f(x) = g(x)$. Finally, since $x$ was arbitrary, $f = g$.

Solution 2:

For the second part I think 'sequence argument' looks better. For this, take $x\in X$. Since $E$ is dense in $X$, there exists a sequence $\{x_n\}\subseteq E$ such that $x_n\to x$ in $X$. Since both $f$ and $g$ are continuous, it follows that $f(x_n)\to f(x)$ and $g(x_n)\to g(x)$. Also $f(x_n)=g(x_n)$ as $x_n\in E$, for all $n$. Hence by the uniqueness of limit (since we are in the metric space, a convergent sequence has a unique limit) we have $f(x)=g(x)$. As $x\in X$ is arbitrarily chosen, $f(x)=g(x)$ on $X$ as desired.