TITLE: Showing two ring homomorphisms that agree on the integers must agree on the rationals
QUESTION [17 upvotes]: I have two ring homomorphisms $f,g\colon \mathbb{Q}\to X$. I know that $f=g$ on the integers. How can I show that $f$ and $g$ agree on the rationals?

My attempt:
let $x,y \in \mathbb{Z}$, $y\neq 0$. 
$$\begin{align*}
f(x/y)&=f(x)f(1/y) &&\text{because }f\text{ is a ring homomorphism}\\
 &=g(x)f(1/y) &&\text{because }f\text{ and }g\text{ agree on the integers}
\end{align*}$$
I do not know how to rewrite $f(1/y)$ so that I can replace it with $g(1/y)$. Any hints will be much appreciated. Thanks.

REPLY [2 votes]: There is an exercise (Exercise III.1.18) in Hungerford's Algebra which is the same as this question. 

Let $\Bbb{Q}$ be the field of rational numbers and $R$ any ring.
  If $f, g:\Bbb{Q}\to R$ are homomorphisms of rings such that $f|\Bbb{Z}=g|\Bbb{Z}$, 
  then $f=g$.
  [Hint: show that for $n\in \Bbb{Z}$ ($n\neq 0$), 
  $f(1/n)g(n)=g(1)$, 
  whence $f(1/n)=g(1/n)$.]

My solution:
Since $\Bbb{Q}$ is a field (the only ideals are $0$ and $\Bbb{Q}$) and $\ker{f}, \ker{g}$ are ideals of $\Bbb{Q}$, 
we have $\ker{f}$ and $\ker{g}$ are in $\{0, \Bbb{Q}\}$. 
Note that $\ker{f}=\Bbb{Q}\Leftrightarrow \ker{g}=\Bbb{Q}$.
In this case, $f(q)=g(q)=0$ for all $q\in \Bbb{Q}$.
Now, we assume $\ker{g}=0$. Then by the First Isomorphism Theorem for Rings, 
$$\Bbb{Q}\cong \Bbb{Q}/0=\Bbb{Q}/\ker{g}\cong \text{Im }g=g(\Bbb{Q}).$$
Thus, $g(n)$ has an inverse in $g(\Bbb{Q})$.
On the other hand, by the hint, 
$$f(1/n)g(n)=f(1/n)f(n)=f(1/n\cdot n)=f(1)=g(1)=g(1/n\cdot n)=g(1/n)g(n).$$
It follows that $f(1/n)g(n)-g(1/n)g(n)=0$ 
and $[f(1/n)-g(1/n)]g(n)=0$.
We get $f(1/n)-g(1/n)=0$ by multiplying $g(n)^{-1}$ on both sides.