# Do there exist pairs of distinct real numbers whose arithmetic, geometric and harmonic means are all integers?

I self-realized an interesting property today that all numbers $(a,b)$ belonging to the infinite set $$\{(a,b): a=(2l+1)^2, b=(2k+1)^2;\ l,k \in N;\ l,k\geq1\}$$ have their AM and GM both integers.

Now I wonder if there exist distinct real numbers $(a,b)$ such that their arithmetic mean, geometric mean and harmonic mean (AM, GM, HM) all three are integers. Also, I wonder if a stronger result for $(a,b)$ both being integers exists.

I tried proving it, but I did not find it easy. For the AM, it is easy to assume a real $a$ and an AM $m_1$ such that the second real $b$ equals $2m_1-a$. For the GM, we get a condition that $m_2=\sqrt{(2m_1-a)a}$. If $m_2$ is an integer, then… what? I am not sure exactly how we can restrict the possible values of $a$ and $m_1$ in this manner.

Here's how you can work out the answer from scratch, without needing any clever leaps of insight of the form "let's try a solution like this!".

It does require a few "tricks of the trade", which I will point out as they come up. But those are general-purpose tricks rather than specific insights into this problem. Aside from that, we'll just do the easiest thing available at each step :-).

When I first answered this, I misinterpreted the question as requiring our numbers to be integers. It seems like an interesting question either way, so here first of all is my original answer, followed by a version that (as the OP intended) doesn't make that assumption.

When our numbers are required to be integers

So, suppose our two numbers are $a,b$. Their geometric mean is $\sqrt{ab}$; that's an integer, so $ab$ is a square. So [TRICK 1] we must have $a=pq^2$ and $b=pr^2$ for some integers $p,q,r$.

That takes care of the geometric mean. The arithmetic mean just needs $a,b$ to have the same parity, which is going to be easy. So what about the harmonic mean? That's $\frac{2ab}{a+b}$. It has to be an integer, so let's give it a name, $h$ say. So $2ab=h(a+b)$ or, in terms of the new variables we introduced above, $2p^2q^2r^2=ph(q^2+r^2)$. Let's lose a factor of $p$: $2pq^2r^2=h(q^2+r^2)$. And, remember, this equation is the only thing we need other than making sure $a,b$ are both odd or both even.

The next thing to notice is that the LHS is a multiple of both $q^2$ and $r^2$. Wouldn't it be nice if that factor of $q^2+r^2$ on the right weren't getting in the way? Aha! [TRICK 2] We can get rid of it, because we can assume that $q$ and $r$ are coprime. Why? Because all we need is $a=pq^2$ and $b=pr^2$, and if $q,r$ have a common factor we can move its square into $p$.

So, we have $q,r$ coprime. Now $q^2\mathrel|2pq^2r^2=h(q^2+r^2)$. Since clearly $q^2\mathrel|hq^2$ this yields $q^2\mathrel|hr^2$ and now since $q,r$ have no common factor we must have $q^2\mathrel|h$. Similarly $r^2\mathrel|h$. Even better, since $q,r$ have no common factor these two give us $q^2r^2\mathrel|h$.

Just as with the original HM, we have one thing dividing another so let's name the quotient. Say $h=tq^2r^2$. What happens to the equation we were looking at? It becomes $2pq^2r^2=tq^2r^2(q^2+r^2)$ or, dividing out the junk, $2p=t(q^2+r^2)$.

But now we're done, because we can just (again, aside from a little bit of caution about parity) take $q,r,t$ to be anything we like and define $p$ by this equation! We will then get $p=t(q^2+r^2)/2$ and then $a=pq^2$ and $b=pr^2$.

Let's figure out those parity constraints. If $q,r$ have the same parity (i.e., are both odd or both even) then $q^2+r^2$ is even, so $p$ is automatically an integer, and $a,b$ automatically have the same parity, so everything is good. If $q,r$ have opposite parity then we will need $p$ to be not only an integer but an even integer, and since $q^2+r^2$ will be odd this requires $t$ to be a multiple of 4.

Putting the bits together, the following procedure (1) always yields $a,b$ with AM,GM,HM all integers and (2) produces every possible such $a,b$:

Choose positive integers $q,r,t$. If $q,r$ are of opposite parity, $t$ must be a multiple of 4; otherwise $t$ is unrestricted. Now write $p=t(q^2+r^2)/2$ and then $a=pq^2$ and $b=pr^2$. (This gives $a\neq b$ provided $q\neq r$.)

Let's look at a couple of simple examples, trying to make our numbers small. First, with $q,r$ of the same parity. Let's try $q=1,r=3$. Then $t$ can be anything; let's set it to 1. We get $p=5$ and then $a,b=5,45$. The AM is 25, the GM is 15, and the HM is 9.

Next, with $p,q$ of opposite parity. Let's try $q=1,r=2$. Then $t$ has to be a multiple of 4; let's make it 4. We get $p=10$ and then $a,b=10,40$. The AM is 25, the GM is 20, and the HM is 16.

When our numbers are not required to be integers

As I confessed above, all of that assumes that you specifically want your numbers $a,b$ to be integers. What if you are happy for them to be any real numbers at all? How much extra freedom does that give you? Perhaps less than you might think; let's see. Once again, so far as possible I'm just going to do easy things and see where they lead.

First of all, their AM is an integer. Call it $n$; so our numbers are $a=n+d$ and $b=n-d$ for some (not necessarily integral) $d$. Now the GM $\sqrt{ab}$ is an integer too, so its square $ab$ certainly is, so $(n+d)(n-d)=n^2-d^2$ is an integer. So $d$ is the square root of an integer; let's say it's $\sqrt{m}$. Finally, the HM is $\frac{2ab}{a+b}=\frac{ab}n=\frac{n^2-m}n$, so $m$ is an integer multiple of $n$, say $kn$.

So far, we have figured out that we have $a,b=n\pm\sqrt{kn}$ for some integers $n,k$. The only thing we haven't used yet is the fact that the GM itself (and not only its square) is an integer; that is, that $n^2-kn=n(n-k)$ is a square; the conditions we've established above are enough to make the AM and HM squares, and the GM the square root of an integer. So, the only further condition is that $n(n-k)$ be a square. Well, by TRICK 1 above this is the same as having $n=pq^2$ and $n-k=pr^2$ for integers $p,q,r$.

So here's the general solution when $a,b$ don't have to be integers:

Choose positive integers $p,q,r$ with $r<q$. Write $n=pq^2$ and $k=p(q^2-r^2)$. Set $a,b=n\pm\sqrt{kn}$.

Let's once again look at a simple example where the integers involved are small and $a,b$ aren't themselves integers. First, take $p=1,q=2,r=1$. Then $n=4$ and $k=3$ so our numbers are $4\pm\sqrt{12}$. The AM is 4; the GM is 2; the HM is 1.

• This is amazing! I am definitely putting a +200 bounty on this question once it gets off the HNQ list! This intuition you derive is amazingly simple and fluid. Also, this is the most generalized of all the answers till now. The result you yield is roughly the same as that of Peter's answer, but he didn't delineate the two cases for the parities of $p$ and $q$, so his results are limited. Thanks again! – Gaurang Tandon Apr 17 '18 at 12:03
• How does Trick 1 follow? Take $a = 2\sqrt{2}$ and $b = \sqrt{2}$ so that $ab = 4$ which is square, but neither numbers are of the form $pq^2$ or $pr^2$ for integers $p,q,r$. [These won't work out because you can derive rationality and integer constraints from AM and HM being integers, but you seem to assume that $a$ and $b$ are integers without any discussion or statement] – Zain Patel Apr 18 '18 at 3:06
• @ZainPatel I think that's the point -- Gareth is assuming that $a$ and $b$ are integers. If you want to go through the analysis for the general case, go ahead! – Charles Apr 18 '18 at 4:06
• The question explicitly states that $a$ and $b$ are real numbers. The answer definitely answers the question, and does so in a great way (+1), however the claim that it generates all solutions is wrong. – celtschk Apr 18 '18 at 7:01
• Nice, it seems to be fixed now :-) @celtschk have a look, I think this is perfect now! – Gaurang Tandon Apr 21 '18 at 4:49

There are a few key points.

• The arithmetic mean of two rational numbers is always rational.
• The harmonic mean of two non-zero rational numbers is always rational.
• The geometric mean of two squared positive integers is always an integer.
• For all three types of mean if we multiply every input by a positive real value we also multiply the result by that same value.

These key points lead to a strategy for finding numbers whose am, gm and hm are all integers.

• pick a pair of integers whose GM is an integer.
• calculate the AM and HM
• multiply through by the denominators of the AM and HM.

Now to work this through, pick any two distinct positive integers $x$ and $y$.

$$\mathrm{GM}(x^2,y^2) = xy$$ $$\mathrm{AM}(x^2,y^2) = \frac{x^2+y^2}{2}$$ $$\mathrm{HM}(x^2,y^2) = \frac{2x^2y^2}{x^2+y^2}$$

Let $t = 2(x^2 + y^2)$ Let $a=tx^2$ Let $b=ty^2$. Since only addition, multiplication and squaring of positive integers is involved it is clear that $t$, $a$ and $b$ are all positive integers. It is also clear that a and b are distinct.

$$\mathrm{GM}(a,b) = txy$$ $$\mathrm{AM}(a,b) = t\frac{x^2+y^2}{2} = (x^2+y^2)^2$$ $$\mathrm{HM}(a,b) = t\frac{2x^2y^2}{x^2+y^2} = 4x^2y^2$$

Again since all these values can be calculated merely by adding, multiplying and squaring positive integers they are all positive integers.

Lets plug in some numbers, for example $x=1$ and $y=2$

$$t = 10$$ $$a = 10$$ $$b = 40$$ $$\mathrm{GM}(10,40) = 20$$ $$\mathrm{AM}(10,40) = 25$$ $$\mathrm{HM}(10,40) = 16$$

Indeed we can extend this techiquie to find an arbitary size list of integers the AM, GM, and HM of any subset of which are integers. Just start with integers of the form $x^{n!}$ so the GMs are all integers. Then work out the AMs and HMs and multiply through.

• Bravo, +1, but the answer would be even better if you make the expressions for $a$ and for $b$ in terms of only $x$ and $y$ and highlight them, and also make the formula for $\mathrm{GM}(a,b)$ in terms of only $x$ and $y$. – Rory Daulton Apr 17 '18 at 0:04

Take $1$ and any square $>1$. Multiply both of them with the smallest common denominator of their AM and HM.

• I worked it out for curiosity: The smallest example this yields is $(10, 40)$, with AM $25$, GM $20$, and HM $16$. – user856 Apr 16 '18 at 11:02

For any $$(a, b) = (km^2(m^2 + n^2), kn^2(m^2 + n^2)),$$ where $k, m, n \in \mathbb{N}_+$ and $2 \mid a - b$, there is$$\frac{a + b}{2} \in \mathbb{Z}, \quad \sqrt{ab} = kmn(m^2 + n^2) \in \mathbb{Z}, \quad \frac{2ab}{a + b} = 2km^2 n^2 \in \mathbb{Z}.$$

• For the lazy, the smallest nontrivial pair is (40,10). – svavil Apr 16 '18 at 16:41
• However, $(45,5)$ gives the smallest (AM,GM,HM) of $(25,15,9)$. – robjohn Apr 25 '18 at 5:25
• The parametrization given here math.stackexchange.com/questions/1971809/… is wrong. I edited it to reflect the correct parametrization, why did you reject it? – Alex D Nov 23 '18 at 4:41

Commonly, an easy way to solve problems like these is to turn it around:

Pick three integers. Are there real numbers such that GM, AM, and HM are those three integers?

and you simply solve for the two real numbers.

This probably doesn't work here, because you have three equations in two unknowns. But you could pick two of the integers to be, for example, the GM and AM. From there you can solve for the numbers and then compute the HM, and the question is how to make the HM an integer too.

Working through the definitions and assuming $\mathrm{AM}(x,y) \neq 0$ you can ultimately determine

$$x,y = \mathrm{AM}(x,y) \pm \sqrt{\mathrm{AM}(x,y)^2 - \mathrm{GM}(x,y)^2}$$ $$\mathrm{HM}(x,y) = \frac{\mathrm{GM}(x,y)^2}{\mathrm{AM}(x,y)}$$

It's now easy to determine all solutions to the original problem. They are obtained by selecting integers $g$ and $a$ satisfying:

• $|a| > |g|$
• $a$ divides $g^2$
• $a \neq 0$

and then you can set

• $x,y = a \pm \sqrt{a^2 - g^2}$
• $\mathrm{AM}(x,y) = a$
• $\mathrm{GM}(x,y) = g$
• $\mathrm{HM}(x,y) = \frac{g^2}{a}$

To further solve the problem of asking for $x,y$ to be integers, you need to arrange to have $a^2 - g^2$ be a perfect square. This is a bit more complicated, and related to pythagorean triples.

To work out the integer case, we need to better understand solutions to the $a \mid g^2$ condition.

I will boldly assert that, by chasing through the divisibility conditions and using the fact $a \neq 0$, the general case comes from:

• Select integers $u,v,w$ such that $\gcd(v,w) = 1$, $v > 0$, and $u \neq 0$
• Set $a = uv^2$
• Set $g = uvw$

The radicand $a^2 - g^2$ we need to be a perfect square then simplifies:

$$a^2 - g^2 = u^2 v^2 (v^2 - w^2)$$

This has a square root if and only if $|v|$ and $|w|$ are two components of a primitive pythagorean triple, with $|v|$ the hypotenuse.

The $|a| > |g|$ condition simplifies to requiring $|v| \neq |w|$. Given the other constraints, this simplifies to $v > 1$.

• I think that is the best answer, as it is the only answer that systematically derives a complete solution, and moreover it explains it nicely. Moreover it is based on a general principle that can be used to solve other problems, so its usefulness goes beyond answering the specific question. – celtschk Apr 18 '18 at 7:08
• Great answer. This also shows that all soloutions are either integer or irrational. – Peter Green Apr 18 '18 at 9:27
• Case $a=g$ leads to the integer $x, y.$ – Yuri Negometyanov Apr 22 '18 at 3:36
• a = g leads to x=y which violates the question requirements of distinct integers. – Peter Green Apr 23 '18 at 19:18

Integer Case

If we start out with $$a=\frac{x+y}2,\quad g=\sqrt{xy},\quad h=\frac{2xy}{x+y}\tag1$$ we have that $$ah=g^2\tag2$$ Furthermore, note that $$a^2-g^2=\left(\frac{x-y}2\right)^2=d^2\tag3$$ that is, $$a^2=g^2+d^2\tag4$$ So this is related to Pythagorean Triples.

Furthermore, if $a\mid g^2$, then $h=\frac{g^2}a$ is an integer.

Given any Pythagorean Triple, $k^2+m^2=n^2$ with $(n,m)=1$ (this answer shows how to generate all primitive Pythagorean Triples), we need to multiply by $n$ to ensure that $a\mid g^2$. That is, let $$a=n^2,\quad d=mn,\quad g=kn\tag5$$ then $$h=k^2,\quad x=n(n+m),\quad y=n(n-m)\tag6$$ and $(6)$ gives all $x,y\in\mathbb{Z}$ where $\frac{x+y}2,\sqrt{xy},\frac{2xy}{x+y}\in\mathbb{Z}$ and $\left(\frac{x+y}2,\frac{2xy}{x+y}\right)=1$.

Examples

The smallest Pythagorean Triple is $(3,4,5)$. This gives two pairs:

$(5(5+3),5(5-3))=(40,10)$ whose (AM, GM, HM) are $(25,20,16)$.

$(5(5+4),5(5-4))=(45,5)$ whose (AM, GM, HM) are $(25,15,9)$.

Real Case

If we let $x,y\in\mathbb{R}$, then the important restriction is $(2)$ above. That is, $ah=g^2$. That is, if we have $$a=\prod_k p_k^{e_k}\tag7$$ Then if we have $g\lt a$ so that $$\left.\prod_k p_k^{\left\lceil e_k/2\right\rceil}\,\middle|\,g\right.\tag8$$ where $\lceil x\rceil$ is the ceiling function, the least integer not less than $x$.

Then $a\mid g^2$ and $h=\frac{g^2}a$ is an integer. Note that to have $a\ne g$, we need some $e_k\ge2$. For such $a$ and $g$, we have $$x=a+\sqrt{a^2-g^2},\quad y=a-\sqrt{a^2-g^2}\tag9$$

Examples

Extending the example above, let's consider $a=25$. In that case, we are looking for $g\lt25$ so that $5\mid g$. $g=20$ and $g=15$ are given above; however, there are two other cases:

$g=10$: which gives $x=25+5\sqrt{21}$ and $y=25-5\sqrt{21}$ and $h=4$.

$g=5$: which gives $x=25+10\sqrt6$ and $y=25-10\sqrt6$ and $h=1$.

We can even have non-square $a$. For example, $a=12$. In this case we are looking for $g\lt12$ so that $6\mid g$. That is,

$g=6$: which gives $x=12+6\sqrt3$ and $y=12-6\sqrt3$ and $h=3$.

Let $a+b=2n$ and $ab=m^2$ (so that the arithmetic and geometric means are the arbitray integers $n$ and $m$).

The harmonic mean is $$\dfrac{2ab}{a+b}=\frac{m^2}n,$$ so, yes, you can certainly obtain three integers.

• I downvoted this post, because I fail to see how this adds anything new to what has already been covered by Hurkyl's answer. – Gaurang Tandon Apr 22 '18 at 2:56
• @GaurangTandon: thanks for the feedback. – Yves Daoust Apr 22 '18 at 15:35