# Is it possible to generate a solution for this? $p^2 + q^2 + r^2 = pqr$

I have seen this problem in a local magazine.

I want to Generate an formula for this for the solutions of this problem Oh and it's given that

$$p,q,r \in\mathbb{N}$$ and they can be equal.

• Do you want all solutions? Or just prove that they are infinitely many ones? Apr 28, 2015 at 9:20
• I want forumla for solutions like Apr 28, 2015 at 9:24
• You didn't answer my question xd Apr 28, 2015 at 9:24
• Got some solutions by trail and error like (3,3,3) and (3,3,6) Apr 28, 2015 at 9:24
• I want solutions lol like in general term formula maybe Apr 28, 2015 at 9:25

There is no formula. All solutions result from taking a triple that solves the Markov equation $$x^2 + y^2 + z^2 = 3xyz$$ and replacing the triple $(x,y,z)$ by $(3x,3y,3z),$ so $p=3x,$ $q=3y,$ $r=3z.$ There is a simple method for moving from one triple in the Markov tree and reaching a neighboring solution. See tree diagram at http://en.wikipedia.org/wiki/Markov_number

Hmmm. I don't see the description of travel to neighboring triples.

Beginning with $$(x,y,z)$$ the (usually three) neighbors are $$(3yz-x,y,z),$$ $$(x,3xz-y,z)$$ $$(x,y,3xy-z).$$ In all three cases, the three entries are traditionally put into increasing order.

Note that people on this site generally call the movement step as an example of Vieta Jumping, http://en.wikipedia.org/wiki/Vieta_jumping In particular, repeating the exact same jump (before putting the entries in order!) gets you back to where you were.

This was all worked out for an arbitrary number of values, A. Huwitz (1907) solving $$x_1^2 + x_2^2 + \cdots x_n^2 = a x_1 x_2 \cdots x_n$$ with all positive integers. For $n=3$ the possible values of my letter $a$ are $a=3,$ the Markov triples, and $a=1,$ answers are $3$ times the Markov triples.

Let's try working backwards. Assume the values of p and q are given then:

$$p^2+q^2+r^2=pqr$$

is a quadratic equation in r with solutions:

$$r=\frac{pq\pm\sqrt{p^2q^2-4\left(p^2+q^2\right)}}{2}$$

Notice that the numerator will always be even and positive, if it is an integer. Thus there are two integer solutions for $r$ iff $p^2q^2-4(p^2+q^2)$ is a perfect square. Rewriting gives:

$$p^2q^2-4\left(p^2+q^2\right)=\frac{\left(p^2+q^2\right)^2}{2}-\frac{9}{2}\left(p^2+q^2\right) = k^2$$

Applying the quadratic formula again gives:

$$p^2+q^2=\frac{9\pm\sqrt{81+8k^2}}{2}$$

So we need to find another perfect square:

$$81+8k^2=m^2$$

This is the point where I cheated and used Dario Alpern's solver to find that one solution to this is $k=0,m=9$, and for any k and m that solves the equation, so does $k:=3k+m,\ m:=8k+3m$.

It would be easy to write a computer program, that generates such ks and spews out solutions for $(p, q, r)$ when applicable (when $\frac{9\pm\sqrt{81+8k^2}}{2}$ can be expressed as the sum of two squares).

• You can actually observe that $9\mid m,k$, divide both sides by $81$ and fully finish the problem by solving the Pell equation. Apr 28, 2015 at 11:18
• And where is the next part lol Apr 28, 2015 at 15:46
• @CuriousSciDude besides what user31415 said, there is not much more to do. Generate ks, then ps and qs and then two different values for r will be given. Of course this is not on closed form (I doubt that is possible), but it is sufficient to generate all solutions. Apr 28, 2015 at 16:26
• @CuriousSciDude As I said, it's just a Pell equation. You generate all the possible $k,m$. Then $p^2q^2-4(p^2+q^2)=k^2\Leftrightarrow (p^2-4)(q^2-4)=k^2+16$, so $p^2-4$ is a divisor of $k^2+16$ and $q^2-4=\frac{k^2+16}{p^2-4}$. Apr 28, 2015 at 18:24
• @user31415, the pretty solution of this is by taking the triples that solve the Markov equation and multiply through by 3. Answer posted. An article that focused on the tree aspect (and allowed arbitrary number of variables) was published by A. Hurwitz in 1907. Apr 28, 2015 at 18:28

Partial results:

1) Suppose two of them are equal, wlog $q=r$ then we have $p^2=(p-2)q^2$. In particular $p-2$ divides $p^2$ but $$\text{gcd}(p^2,p-2) \le \text{gcd}(p,p-2)^2 \le 2^2$$ therefore $p-2\le 4$. Moreover $p^2>0 \implies p-2>0$, so that $p \in \{3,4,5,6\}$. If $p=3$ we get $q=r=3$. If $p=4$ or $5$ we have no solutions. If $p=6$ then $q=r=3$.

2) Suppose $r=kq$ for some integer $k \ge 2$. Then $p^2+q^2+k^2q^2=kpq^2$ can be rewritten as $$(2p-kq)^2+q^2=0,$$ which is impossible.

3) From now on we can assume wlog $p>q>r>0$, and $r\nmid q \nmid p$. Moreover, rewrite the equation as $$(2p-qr)^2=q^2r^2-4q^2-4r^2.$$ so that $(qr)^2-4(q^2+r^2)$ and the two other cyclic relations have to be perfect squares.