# Can you have the harmonic, geometric, arithmetic and quadratic mean of 2 numbers all being integers? [closed]

I created this problem looking at the hm-gm-am-qm inequality (hm = $$\frac{2xy}{x + y}$$, gm = $$\sqrt{xy}$$, am = $$\frac{x + y}{2}$$, qm = $$\sqrt{\frac{x^2 + y^2}{2}}$$ and hm $$\le$$ gm $$\le$$ am $$\le$$ qm).

If we set $$x$$ and $$y$$ without $$x$$ and $$y$$ being equal, can the hm, gm, am and qm of $$x$$ and $$y$$ all have integer values?

It turns out that this is

possible.

As it happens, a closely related question -- requiring integer values for HM, GM, AM only -- was asked on math.stackexchange.com a while ago and I answered it: https://math.stackexchange.com/questions/2739592/do-there-exist-pairs-of-distinct-real-numbers-whose-arithmetic-geometric-and-ha/2741216#2741216

The solution turns out to be this (quoted from that answer with a change of variable names to match this question):

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

Now, when do we get an integer quadratic mean as well?

The quadratic mean is $$\sqrt{\frac{x^2+y^2}2}=\sqrt{\frac{(n+\sqrt{kn})^2+(n-\sqrt{kn})^2}2}=\sqrt{n^2+kn}$$ so what we need is for $$n(n+k)$$ to be a square. This equals $$pq^2(2pq^2-pr^2)$$, which is a square iff $$2q^2-r^2$$ is. So we need $$2q^2=r^2+s^2$$, say. Obviously and boringly this holds if $$q=r=s$$, but there are indeed other solutions; for instance, if we take $$q=5$$ then we can have $$r=1,s=7$$ yielding (with $$p=1$$) $$n=25$$, $$k=24$$, and $$x,y=25\pm\sqrt{600}$$. These have harmonic mean 1, geometric mean 5, arithmetic mean 25, and quadratic mean 35.

A related question we might ask, with the above known:

What do all the solutions look like? First rewrite that key equation $$2q^2=r^2+s^2$$ as $$q^2=(r+s)^2+(r-s)^2$$; we are looking for solutions to this that don't have $$r\pm s=0$$. It turns out that there are such solutions iff every prime number that divides $$q$$ an odd number of times is 1 (mod 4); the "right" way to think about this stuff involves working in the so-called Gaussian integers $$a+ib$$ where $$a,b$$ are ordinary integers and $$i$$ is a square root of -1. For details, consult an undergraduate or early-graduate textbook on number theory :-). So, anyway, this means there are plenty of solutions.

whether it can be done with $$x,y$$ both integers. The link above answers this question without the quadratic mean; I think the answer is that with the quadratic mean requirement it can't be done.

To begin with,

here is the solution from the math.stackexchange.com question: 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 $$x=pq^2$$ and $$y=pr^2$$. (This gives $$x\neq y$$ provided $$q\neq r$$.) Now, we need $$\frac{x^2+y^2}2$$ to be a square; that is, we need $$\frac{q^4+r^4}2$$ to be a square; that is, we need $$q^4+r^4=2s^2$$. Well, here is a link to (hidden among a bunch of other calculations) a proof that the only solution to this with $$q,r,s$$ coprime is $$(1,1,2)$$; any solution with $$q,r,s$$ not coprime can easily be transformed into one where they are coprime simply by dividing through by common factors; so there are no solutions with $$q\neq r$$.

Partial answer - three out of four

It's possible to make the HM, GM, and AM all integers: you just have to choose integers $$x,y$$ such that

1. $$x,y$$ have the same parity (so that the AM is an integer);

2. $$xy$$ is a square (so that the GM is an integer);

3. $$xy$$ is a multiple of $$x+y$$ (so that the HM is an integer).

Given any $$x,y$$ satisfying the first two conditions, we can ensure the third condition too by

multiplying both $$x$$ and $$y$$ by the current value of $$x+y$$. This won't affect their equal parity, and will keep $$xy$$ as a square, but it will also ensure $$xy$$ is a multiple of $$x+y$$.

Thus, we start with the following simple pair which satisfy the first condition:

$$x=2,y=4$$.

Square them both to satisfy the second condition:

$$x=4,y=16$$.

Now $$x+y=20$$, so we can multiple both by $$5$$ to satisfy the third condition:

$$x=20,y=80$$.

Check:

HM is $$\frac{20\times80}{20+80}=16$$, GM is $$\sqrt{20\times80}=40$$, AM is $$\frac{20+80}{2}=50$$. All are integers.

In order to make the QM an integer as well, we just need to find $$x$$ and $$y$$ solutions to the Diophantine equation $$x^2+y^2=2z^2$$.