If two continuous maps coincide in dense set, then they are the same Suppose $f,g : R \to R $ are continuous and $D \subset \mathbb{R}$ is dense. Suppose $f(x) = g(x) $ for all $x \in D$. Does it follow that $f(x) = g(x) $ for all $x \in \mathbb{R}$??
My answer is affirmative. Suppose $h(x) = f(x) - g(x) $. By hypothesis, 
$$ D = \{ x : h(x) = 0 \} $$
but we know $\{ x : h(x) = 0 \} $ is closed since $h$ is continuous. and so $\{ x : h = 0 \} = \overline{ \{ x : h = 0 \} } = \overline{D} = \mathbb{R} $ as desired. 
Is this right? thanks for any feedback.

An other way 
Let $x\in \mathbb R\backslash D$.
By density of $D$ in $\mathbb R$, there is a sequence $(x_n)\subset D$ such that $\lim_{n\to\infty }x_n=x$. By continuity of $f$ and $g$ on $\mathbb R$ and by the fact that $f(x_n)=g(x_n)$ for all $n$,
$$f(x)=\lim_{n\to\infty }f(x_n)=\lim_{n\to\infty }g(x_n)=g(x),$$
what prove the claim.
