# What rational numbers have rational square roots?

All rational numbers have the fraction form $$\frac a b,$$ where a and b are integers($b\neq0$).

My question is: for what $a$ and $b$ does the fraction have rational square root? The simple answer would be when both are perfect squares, but if two perfect squares are multiplied by a common integer $n$, the result may not be two perfect squares. Like:$$\frac49 \to \frac 8 {18}$$

And intuitively, without factoring, $a=8$ and $b=18$ must qualify by some standard to have a rational square root.

Once this is solved, can this be extended to any degree of roots? Like for what $a$ and $b$ does the fraction have rational $n$th root?

• 1. Sorry for the disturbing grammar mistake. 2. Sorry for this elementary question. – user2386986 Jul 20 '13 at 16:47
• math.stackexchange.com/questions/324724/… is a related question. – Baby Dragon Jul 20 '13 at 17:26
• $8/18$ is not in the "lowest terms", which means $gcd(a, b) = 1$ – Kaz Jul 21 '13 at 5:56
• possible duplicate of $\sqrt a$ is either an integer or an irrational number. – Bart Michels Aug 25 '15 at 12:20
• $\frac ab$ is a square rational iff $ab$ is a square integer, as several people pointed out. The natural question is, is there a similar test for cube rationals? Here it is: $\frac ab$ is a cube rational iff $ab^2$ is a cube integer. – Akiva Weinberger Nov 10 '15 at 17:20

A nice generalization of the fundamental theorem of arithmetic is that every rational number is uniquely represented as a product of primes raised to integer powers. For example:

$$\frac{4}{9} = 2^{2}*3^{-2}$$

This is the natural generalization of factoring integers to rational numbers. Positive powers are part of the numerator, negative powers part of the denominator (since $a^{-b} = \frac{1}{a^b}$).

When you take the $n$th root, you divide each power by $n$:

$$\sqrt[n]{2^{p_2}*3^{p_3}*5^{p_5}...} = 2^{p_2/n}*3^{p_3/n}*5^{p_5/n}...$$

For example:

$$\sqrt{\frac{4}{9}} = 2^{2/2}*3^{-2/2} = \frac{2}{3}$$

In order for the powers to continue being integers when we divide (and thus the result a rational number), they must be multiples of $n$. In the case where $n$ is $2$, that means the numerator and denominator, in their reduced form, are squares. (And for $n=3$, cubes, and so on...)

In your example, when you multiply the numerator and denominator by the same number, they continue to be the same rational number, just represented differently.

$$\frac{2*4}{2*9} = 2^{2+1-1}*3^{-2} = 2^{2}*3^{-2}$$

You correctly recognize the important of factoring, though you don't really want to use it in your answer. But the most natural way to test if the fraction produced by dividing $a$ by $b$ has a rational $n$th root, is to factor $a/b$ and look at the powers. Or, equivalently, reduce the fraction and determine if the numerator and denominator are integers raised to the power of $n$.

• Good answer. They should teach this stuff in school. – goblin GONE Jul 20 '13 at 17:11
• Very useful to switch to prime product representation. – mvw Jul 21 '13 at 11:06

We give a fairly formal statement and proof of the result described in the post.

Theorem: Let $a$ and $b$ be integers, with $b\ne 0$. Suppose that $\frac{a}{b}$ has a rational square root. Then there exists an integer $e$, and integers $m$ and $n$, such that $a=em^2$ and $b=en^2$,

Proof: It is enough to prove the result for positive $b$. For if $b$ is negative and $\frac{a}{b}$ has a square root, then we must have $a\le 0$. Thus $\frac{a}{b}=\frac{|a|}{|b|}$. If we know that there are integers $e$, $m$, $n$ such that $|a|=em^2$ and $|b|=en^2$, then $a=(-e)m^2$ and $b=(-e)n^2$.

So suppose that $b\gt 0$, and $a\ge 0$. Let $d$ be the greatest common divisor of $a$ and $b$. Then $a=da^\ast$, and $b=db^\ast$, for some relatively prime $a^\ast$ and $b^\ast$.

It will be sufficient to prove that each of $a^\ast$ and $b^\ast$ is a perfect square.

Since $\frac{a^\ast}{b^\ast}$ is a square, there exist relatively prime integers $m$ and $n$ such that $\frac{a^\ast}{b^\ast}=\left(\frac{m}{n}\right)^2$.

With some algebra we reach $$a^\ast n^2=b^\ast m^2.$$

By Euclid's Lemma, since $b^\ast$ divides the product on the left, and is relatively prime to $a^\ast$, we have that $b^\ast$ divides $n^2$. Also, because $n^2$ divides the expression on the right, and $n^2$ is relatively prime to $m^2$, we have $n^2$ divides $b^\ast$. Since $b^\ast$ is positive, we conclude that $b^\ast=n^2$. Now it is easy to show that $a^\ast=m^2$.

A similar theorem can be stated and proved for $k$-th roots.

Trivially, a rational number has a rational square root if and only if it's the square of some rational number.

As the other answers note, various other characterizations can be given, e.g. that $\frac ab$ has a rational square root if and only if:

• $a = ec^2$ and $b = ed^2$ for some integers $c$, $d$ and $e$,
• the numerator and denominator of the reduced form of $\frac ab$ are both squares, or
• the unique prime factorization of $\frac ab$ has only even exponents.

Yet another "cute" characterization is that $\frac ab$ has a rational square root if and only if $ab$ is a square of an integer. I've sketched a proof of this below.

Proof. To show that this rule works, first note that, if $a = ec^2$ and $b = ed^2$, then $ab = c^2d^2e^2 = (cde)^2$. Showing the converse is a bit trickier, but it follows easily enough from prime factorization. Specifically, let $$ab = x^2 = y = \prod_{i=1}^\infty p_i^{y_i} ,\quad a = \prod_{i=1}^\infty p_i^{a_i} \quad\text{and}\quad b = \prod_{i=1}^\infty p_i^{b_i}$$ where $p_i$ denotes the $i$-th prime. Since $y = x^2$ is a square, we know that $y_i$ must be even for all $i$; from $y = ab$, we know that $y_i = a_i + b_i$ for all $i$. Together, these imply that, if $a_i$ is odd for some $i$, so is $b_i$, and the converse also holds. Now let $$e = \prod_{i=0}^\infty p_i^{e_i},$$ where $e_i = 1$ if $a_i$ and $b_i$ are odd, and let $e_i = 0$ if they are even. Since $e_i \le a_i$ and $e_i \le b_i$ for all $i$, $e$ divides both $a$ and $b$. Furthermore, since $a_i - e_i$ and $b_i - e_i$ are both even for all $i$, it follows that $a/e = c^2$ and $b/e = d^2$ are both squares, and so we can write $a = ec^2$ and $b = ed^2$. $\square$

Ps. As Akiva Weinberger notes in the comments below, this "trick" can also be generalized to higher powers. Specifically, $\frac ab$ has a rational $n$-th root if and only if $a^{n-1} b$ (or, equivalently, $b^{n-1} a$) is an $n$-th power of an integer.

• "Yet another "cute" characterization is that ab has a rational square root if and only if ab is a square of an integer." This is the answer I actually want, because it disregards whether a and b are in lowest term. But it fails to hold for higher degree of roots... – user2386986 Jul 20 '13 at 21:02
• Yes, it only works for square roots. Essentially, that's because the additive ring of integers modulo 2 has characteristic 2, and thus addition and subtraction modulo 2 are the exact same operation. The prime factorization of $ab$ is given by adding the exponents of the factorizations of $a$ and $b$, whereas that of $a/b$ is given by subtracting them. But for determining whether a number is a square, we only need to look at the exponents modulo 2, and thus addition and subtraction give the same result. – Ilmari Karonen Jul 20 '13 at 21:13
• "Alas, this trick does not generalize to higher powers." Sure it does, you just need a slight modification. $\frac ab$ has a rational cube root if and only if $a^2b$ is a cube. (Equivalently, if $ab^2$ is a cube.) For $n$th powers, check $a^{n-1}b$. @user2386986 – Akiva Weinberger Nov 10 '15 at 17:18

Just reduce the rational number $\frac{a}{b}$ to $\frac{c}{d}$, where $\gcd(c,d)=1$. For instance with Euclid's algorithm.

A ration number $\frac{a}{b}$ has a ration square root, if and only if the $c$ and $d$ have integer square roots.

Of course this can be expanded also for other roots.

You seem to confuse between a representation of the number as a ratio of two particular integers, and the number itself. This is similar to the confusion between $2$ and $10_b$ (binary base). Numbers represent some abstract quantity, not a numerical value.

The rational number $\frac49$ and the rational number $\frac8{18}$ are equal, and therefore they are the same number. You can't argue that something is true for the number $\frac49$ and not true for the number $\frac8{18}$. You could argue that it's easier to see that $\frac49$ has a square root by inspecting its representation as the ratio $\frac49$ rather than the ratio $\frac8{18}$, but that is not the same thing.

So when does a rational number $x$ has a square root? If and only if $x$ can be written as $\frac pq$ where both $p$ and $q$ have a square root.

It follows that whenever $m$ is a non-zero integer, $\frac{mp}{mq}$ will also have a square root, because that number is the same number as $\frac pq$.

First, $$\sqrt{\frac ab}\in\mathbb{Q}\implies\sqrt{ab}=b\,\sqrt{\frac ab}\in\mathbb{Q}\tag{1}$$ According to this answer, since $\left(\sqrt{ab}\right)^2=ab\in\mathbb{Z}$, if $\sqrt{ab}\in\mathbb{Q}$, then $\sqrt{ab}\in\mathbb{Z}$. Thus, there is a $c\in\mathbb{Z}$ so that $$ab=c^2\tag{2}$$ If $\gcd(a,b)=1$, then, by the Fundamental Theorem of Arithmetic, $(2)$ implies that both $a$ and $b$ are perfect squares.

We can avoid the Fundamental Theorem of Arithmetic by showing that if $\gcd(a,b)=1$, then Bezout's Identity says that because \begin{align} 1 &=(ax+by)^3\\ &=a^2\left(ax^3+3bx^2y\right)+b^2\left(3axy^2+by^3\right)\tag{3} \end{align} we have $\gcd\left(a^2,b^2\right)=1$. Substituting $a\mapsto\frac{a}{\gcd(a,b)}$ and $b\mapsto\frac{b}{\gcd(a,b)}$ into $(3)$ shows that $$\gcd\left(a^2,b^2\right)=\gcd(a,b)^2\tag{4}$$ Thus, $$a=a\gcd(a,b)=\gcd\left(a^2,ab\right)=\gcd\left(a^2,c^2\right)=\gcd(a,c)^2\tag{5}$$ and $$b=b\gcd(a,b)=\gcd\left(ab,b^2\right)=\gcd\left(c^2,b^2\right)=\gcd(c,b)^2\tag{6}$$ Therefore, $a$ and $b$ are perfect squares.

Suppose $(a/b)^{1/n}=c/d$ in its lowest terms. Then $c^n/d^n$ is in its lowest terms. Hence you need $a,b$ to be equivalent to a ratio of $n$th powers.

If and only if $ab$ is a perfect square (integer). For example, $\frac49$ is a square rational, and $4\times9=6^2$; $\frac8{18}$ is a square rational, and $8\times18=12^2$.