# If $f$ and $g$ are continuous on $\Bbb R$ and $f\left(\frac{p}{q}\right)=g\left(\frac{p}{q}\right)$ then is it true that $f(x)=g(x)$?

If $f$ and $g$ are continuous on $\mathbb R$ and $f\left(\frac{p}{q}\right)=g\left(\frac{p}{q}\right)$ for all non-zero integers, $p$ and $q$, then is it true that $f(x)=g(x),\forall x \in \mathbb R$?

• Define $h(x)=f(x)-g(x)$ for all $x\in \mathbb{R}$. We Know that for every nonzero rational $r\in \mathbb{Q} / \{0\}$, there is nonzero intgers $p$ and $q$ such that $r=\frac{p}{q}$, and so $f(r)=g(r)=0$ i.e., $$h(x)=0$$ for all $x\in \mathbb{Q} / \{0\}$. Now $\frac{1}{n}\rightarrow 0$ and so $0=h(\frac{1}{n})\rightarrow h(0)$ i.e., $h(0)=0$. Therefore $h$ is continuous function and $h(x)=0$ on $\mathbb{Q}$. Now you can get the result from the answer that posted. – Deliasaghi Sep 20 '15 at 19:12
So you mean $f(x)=g(x)$ for all $x\in\mathbb Q$? Then we have $f=g$ since $\mathbb Q$ is dense in $\mathbb R$: Each $x\in \mathbb R$ is the limit of a sequence of rational numbers. Continuity of $f$ and $g$ gives you $f(x)=g(x)$.