$a^m=b^m$ and $a^n=b^n$ imply $a=b$ Let $D$ be an integral domain and let $a^m=b^m$ and $a^n=b^n$ where $m$ and $n$ are relatively prime integers, $a,b \in D$. 

How do I show $a=b$?
I came across a similar problem but with the condition that $m$ and $n$ are positive coprime integers. The following is my solution. 

If $a=0$, then $b^m=a^m=0$. It follows that $b=0=a$ since $D$ is an integral domain.

If $a \ne 0$, since gcd(m,n)=1, $\exists s, t\in \mathbb z $ such that $1=sm+tn$. Because $ m, n&gt;1$, $s,t \in \mathbb z$ and $1 = sm + tn$, we have either $s&gt;0, t&lt;0$ or $t&gt;0, s&lt;0$ (Otherwise we cannot have $1=sm+tn$). 

Let's assume $s&gt;0, t&lt;0$. Then $-t&gt;0$. From $a^m = b^m$, we have $(a^m)^s=(b^m)^s$. From $a^n=b^n$, we have $(a^n)^{-t}=(b^n)^{-t}$. We can factor out as follows.

$$a^{-tn}(a^{sm+tn})=b^{-tn}(b^{sm+tn})$$ 

$$a^{-tn}(a^{sm+tn})=a^{-tn}(b^{sm+tn})$$
$a^{-tn} \ne 0$ since $a \ne 0$ and $a$ is in an integral domain. We can cancel $a^{-tn}$ on both sides.Then we get $a^{sm+tn}=b^{sm+tn}$, i.e. $a^1=b^1$.

The proof for the case where $s&lt;0, t&gt;0$ is similar.
What's the necessity of $D$ to be a domain?
As $(m,n) = 1$ we have two integers $x$ and $y$ such that $mx+ny = 1$

so, $a^{mx} = b^{mx}$ and $a^{ny} = b^{ny}$ which implies, $a^{mx+ny} = b^{mx+ny} = a = b$