For the expression $\sqrt{\frac{x}{y}}$ to be rational, is it necessary for both to be squares?

QUESTION: Let $x,y$ be positive integers such that the expression $\sqrt{\frac{x}{y}}$ is rational. Is it necessary that $x$ and $y$ have to be perfect squares?

So I've tried some numbers and the fraction is rational only when they are both perfect squares. Is there some kind of rule, law, or is there a proof that is needed?

• For $\frac xy$ to be a perfect square, it is not necessary that both $x$ and $y$ must be perfect squares. In particular, consider $x = y$! – астон вілла олоф мэллбэрг May 19 '18 at 5:23
• It is nescessary if $x,y$ are relatively prime and $\frac xy$ is "in lowest terms". But obviously if $x$ and $y$ aren't relatively prime then we can just have two perfect squares both times a same non-square constant. – fleablood May 19 '18 at 5:47

If they are relatively prime, they have to be perfect squares--but not if they have a common factor! For example, $\sqrt{\frac{8}{2}}$ is rational.

To see that they need to be perfect squares if they are relatively prime, keep in mind that each positive rational can be uniquely factored into primes where some of the powers are negative and no prime is repeated. And when the numerator and denominator have no common factor, they are simply the products of the primes appearing with positive and negative exponents, respectively.

I'm going to assume you are assuming $x$ and $y$ are relatively prime. Otherwise $x = km^2; y =km^2$ is an obvious counterexample.

Yes, If $\sqrt {\frac xy} = \frac mn$ then $\frac {m^2}{n^2} = \frac xy$. As $m$ and $n$ are relatively prime and $x$ and $y$ are relatively prime then $m^2 = x$ and $n^2 = y$.

No. Let $x=8,y=2$ for example. You need to divide out the odd powers, but both $x$ and $y$ can have them.

$p/q=\sqrt{x/y}$. $x,y,p,q, \in \mathbb{Z^+}$,

$p^2=q^2×(x/y)$, implies $x/y$ must be a square .

1)Example: $x/y=2^2$, or $x=4y$.

2)Example: $x/y=3^2$, or $x=9y$.