# Diophantine equation: $x^2+y^2+z^2=n(xy+yz+zx)$

Let $x,y,z\in \mathbb{Z}$. Find all naturals $n$ such that the equation $x^2+y^2+z^2=n(xy+yz+zx)$ has nontrivial solution(s) (i.e. other than $(0,0,0)$), or prove there exist none.

Note: I have proved it for these cases: - when $n$ is divisible by a prime - when $n=4k+3$ for any nonnegative integer $k$.

It seems that there are no nontrivial solutions for $n>1$, but I cannot prove this.

• if $z=0$ then you are left with $x^2+y^2=nxy$ which has solutions for $n=2$. – Beni Bogosel Dec 26 '13 at 11:10
• It is possible to prove that $x^2+y^2=nxy$ has solutions only if $n=2$. If it has solutions, pick the one with $|x|+|y|$ minimal. Then if there exists $p$ prime which divides $x$ it follows immediately that $p$ divides $y$ so we can factor out a $p^2$ and obtain a solution with smaller $|x|+|y|$. Therefore there does not exist $p$ prime which divides $x$ or $y$ and so $x=y=1$ and $n=2$. – Beni Bogosel Dec 26 '13 at 11:19
• $n=2$ and $(2, 8, 18)$ suffices. As a matter of fact, $(11, 44, 99)$, $(12, 3, 27)$, etc. Lots of them. – Balarka Sen Dec 26 '13 at 11:26
• My solution is a bit lengthy, here is a summary: there are infinitely many solutions $n>0$. One such family is $n=a^2+1$. For each $n$ that has a solution, there are infinitely many integer points. This is by the parametrization method. A generating set for all $n=a^2+1$ is $(x,y,z)=(((1+a)t),(t-at),((1+a^2)t))$. – Yong Hao Ng Dec 26 '13 at 21:34

1. Solutions for the general case:
First, an non-trivial point for $n=5$: $$(-5)^2+(-3)^2+(1)^2=35=5((-5)(-3)+(-5)(1)+(-3)(1))$$ Other examples: $$n=10, P=(5,-1,2)$$ $$n=14, P=(11,-1,2)$$ $$n=17, P=(17,-3,5)$$ This can be found using Sage (free):

R.< x,y,z >=QQ[]
for i in range(30):
C = Curve(x^2 + y^2 + z^2 - ixy - ixz - iyz)
print(i,C.has_rational_point(point = True));

Which you can find a sequence of possible $n$: $$1,2,5,10,14,17,26,29,37,50,62,65,74,77,82,98,101,109,110,122,125,145,\dots$$

In general, the existence of a rational point for a conic is related to Legendre's theorem. If you can form the equations as shown in the link, then it suffices to solve the equation prime by prime using Chinese remainder theorem, which is a finite procedure. You need to adapt the method for your problem since it is not readily expressible in $$aX^2+bY^2+cZ^2=0$$ This does not quite answer your question on how to classify the $n$'s, but it does show that there are (I am guessing infinitely) many $n$ that works.

Edit_3
2. Solving using Legendre's theorem
We want to transform the conic into the form $$aX^2+bY^2+cZ^2=0$$ By completing squares, we change $$x^2+y^2+z^2-nxy-nxz-nyz=0$$ into (via multiplying $4 (-2 + n) (2 + n)$) $$(-1 + n) (4 z + 2 n z)^2 - ((2 + n) (-2 y + n y + n z))^2 - (4 - n^2) (2 x - n y - n z)^2=0$$ which we identify with $$C:(n-1) X^2 + (-1)Y^2 + (n^2-4)Z^2=0,$$ i.e. $a=(n-1),b=-1,c=n^2-4$. If indeed our curve has a solution, certainly this will yield a solution in $C$ by simple substitution. Conversely, a solution of $C$ allows us to find $(x,y,z)$ in terms of rationals. But we can simply scale it up to integers by clearing denominators, so the problems are equivalent.

We are almost done, by we need $a,b,c$ to be pairwise coprime. The only possibility is $p|(n-1)$ and $p|(n^2-4)$. Then $p|n^2-n$, so $p|(n^2-4)-(n^2-n)=n-4$. Hence $p|(n-1)-(n-4)=3$. i.e. when $3|n-1\Longleftrightarrow n=3k+1$. For that case, let $d=(n-1,n^2-4)$, then we can change equation to $$\dfrac{n-1}{d}(dX)^2+(-d)Y^2+\dfrac{n^2-4}{d}(dZ)^2=0$$
(May need to repeat)

Ignoring this case, Legendre's theorem says that $C$ has a solution if and only if the following equations have solutions (here $X$'s can be different): $$X^2\equiv -bc \pmod{|a|}\equiv n^2-4\pmod {n-1}$$ $$X^2\equiv -ca \pmod{|b|}\equiv -(n^2-4)(n-1)\equiv 0\pmod {1}$$ $$X^2\equiv -ab \pmod{|c|}\equiv n-1\pmod{n^2-4}$$ of which the second equation is trivially satisfied. (note: assume $n>2$, since $n=1,2$ will be resolved separately.) So we really want $$X^2\equiv n^2-4\equiv -3\pmod{n-1}$$ $$X^2\equiv n-1\pmod{(n-2)(n+2)}$$ which appears to be not quite straight forward if you want all the solutions.
End_Edit_3

Edit_4!: We are now in a position to prove the infinitude of $n$. Let $a\in \mathbb Z, a>3$ and $3\nmid a$. Set $n=a^2+1$. Since $3\nmid n-1=a^2$, we have $(n-1,n^2-4)=1$ so we can use Legendre's Theorem as above. By our choice of $n$, we can solve equation 2 easily by setting $X=a$: $$X^2=a^2=(a^2+1)-1\equiv n-1\pmod{(n-2)(n+2)}$$ Hence it all comes down to having a solution for $$X^2\equiv-3\pmod{n-1}\Longleftrightarrow X^2\equiv -3\pmod{a^2}$$ I believe quadratic reciprocity will be sufficient to find all such $a$ and I am guessing there should be infinitely many.

3. Infinitude of solutions $n>0$
Alternatively, simply set $Z=0$ and observe: $$(n-1)X^2+(-1)Y^2+(n^2-4)Z^2=(aX)^2-Y^2=(aX+Y)(aX-Y)$$ and we have an infinite family of solutions $(t,\pm at,0)$.
i.e. all $n=a^2+1$ are solutions. With some work we can even find explicit solutions for each $n$ in our original equation: $$((1 + a) t)^2 + (t - a t)^2 + ((1 + a^2) t)^2 = (a^2 + 1) (((1 + a) t) (t - a t) + ((1 + a) t) ((1 + a^2) t) + (t - a t) ((1 + a^2) t))$$ Where $n=a^2+1$, $x=((1+a)t),y=(t-at),z=((1+a^2)t)$.
End_Edit_4

4. Classification of points on fixed $n$
The idea here is once you can find one rational point, there will be infinitely many. In fact, you can list an infinite family using the idea of parametrization. The following is an example for $n=2$.

For $z=0$: $$x^2+y^2-2xy=0\Longleftrightarrow (x-y)^2=0$$ which is trivial, just $x\in \mathbb Z, y=x$.

If $z\neq 0$, then dividing by $z^2$ we can consider the curve as $$C:\left(\dfrac{x}{z}\right)^2+\left(\dfrac{y}{z}\right)^2+1-2\left(\dfrac{x}{z}\dfrac{y}{z}+\dfrac{x}{z}+\dfrac{y}{z}\right)=0$$ or simply $$C:X^2+Y^2+1-2XY-2X-2Y=0$$ We can check that $C$ is irreducible and has genus 0. Therefore there must be a rational parametrization to $\Bbb P^1$. Using scientific softwares like MAPLE or Sage, you can find one such parametrization $\phi$: $$\phi:\mathbb P^1\to \mathbb C$$ $$t\mapsto \left(\dfrac{(t-1)^2}{(t+1)^2},\dfrac{(2t)^2}{(t+1)^2}\right)$$ This can be visualized as $$\left(\dfrac{t-1}{t+1}\right)^4+\left(\dfrac{2t}{t+1}\right)^4+1 -2\left(\dfrac{t-1}{t+1}\right)^2\left(\dfrac{2t}{t+1}\right)^2-2\left(\dfrac{t-1}{t+1}\right)^2-2\left(\dfrac{2t}{t+1}\right)^2=0$$ Then clearing denominators $(t+1)^4$ we get $$(t-1)^4+(2t)^4+(t+1)^4=2((t-1)^2(2t)^2+(t-1)^2(t+1)^2+(2t)^2(t+1)^2)$$ which we can identify as $$x=(t-1)^2, y=(2t)^2, z=(t+1)^2$$ This shows that there are infinitely many solutions by varying $t$. In particular, since we want integer solutions, we must pick $t\in \mathbb Z$. Otherwise either $x$ or $y\not\in \mathbb Z$. I believe this does not cover all the possible points, although I am not certain.

Edit_2: Does not find $(1,1,0)$ for any $t$. However, since $t=\dfrac{A}{B}$ for $A,B\in \mathbb Z$, I should have given the parametrization as: $$x=(A-B)^2, y=(2B)^2, z=(A+B)^2$$ Now this covers all the points in $C$ if we consider all $(A,B)\in \mathbb Z^2$.
End_Edit_2

More generally, given a rational point, we can draw an arbitrary line through it. If we are working in projective plane, then Bezout's theorem tells us that there will be 2 points of intersection with the curve. Now as long as our curve and line have integer coordinates, then the points will also have integer coordinates. The arbitrary line can then be parametrized using one parameter $t$, so that we can express all points in terms of $t$.

• @ArkanMegraoui No problem! Please feel free to ask any questions. =D – Yong Hao Ng Dec 27 '13 at 15:01
• @YongHaoNg Your completion of squares is a known technique, but here it looks magic. I checked term by term, and it is correct. Can you show us in detail how you obtained it? – Paolo Leonetti Dec 28 '13 at 14:29
• @PaoloLeonetti I have added the details as a new answer as it is very lengthy. – Yong Hao Ng Dec 28 '13 at 17:08
• I prefer this approach. mathoverflow.net/questions/225781/… – individ Apr 28 '16 at 16:26

Responding to Paolo Leonetti, here are the steps to complete the square. I am not adding to the main answer as the post is already rather lengthy.

1.1 Factor $x$ variables
Group the $x$ variables: \begin{align*} (x^2-nxy-nxz)+y^2-nyz+z^2=0\\ (x^2-n(y+z)x)+y^2-nyz+z^2=0 \end{align*} Complete the square (and clear denominators) \begin{align*} (x^2-n(y+z)x+\left(\dfrac{n(y+z)}{2}\right)^2-\left(\dfrac{n(y+z)}{2}\right)^2)+y^2-nyz+z^2=0\\ 4(x^2-n(y+z)x+\left(\dfrac{n(y+z)}{2}\right)^2-\left(\dfrac{n(y+z)}{2}\right)^2)+4y^2-4nyz+4z^2=0\\ (4x^2-4n(y+z)x+(n(y+z))^2)-(n(y+z))^2+4y^2-4nyz+4z^2=0\\ (2x-n(y+z))^2-(n^2(y^2+2yz+z^2))+4y^2-4nyz+4z^2=0 \end{align*} Let $Z=2x-n(y+z)\Leftrightarrow x=\dfrac{Z+n(y+z)}{2}$, then $$Z^2-n^2y^2-2n^2yz-n^2z^2+4y^2-4nyz+4z^2=0$$

Note: So I chose to use $Z$ here when getting rid of $x$. I don't even know why. It just... happened.

1.2 Factor $y$ variables
Group $y$ variables: \begin{align*} Z^2+(4y^2-n^2y^2-2n^2yz-4nyz)+(4z^2-n^2z^2)=0\\ Z^2+((4-n^2)y^2-(2n^2+4n)yz)+(4-n^2)z^2=0 \end{align*} Make coefficients of $y^2$ a square: \begin{align*} (4-n^2)Z^2+(4-n^2)((4-n^2)y^2-2(n^2+2n)yz)+(4-n^2)^2z^2=0\\ (4-n^2)Z^2+((4-n^2)^2y^2-2(n^2+2n)(4-n^2)yz)+(4-n^2)^2z^2=0 \end{align*} Complete the square: \begin{align*} (4-n^2)Z^2+((4-n^2)^2y^2-2(n^2+2n)(4-n^2)yz+(n^2+2n)^2z^2-(n^2+2n)^2z^2)+(4-n^2)^2z^2=0\\ (4-n^2)Z^2+((4-n^2)y-(n^2+2n)z)^2-(n^2+2n)^2z^2+(4-n^2)^2z^2=0\\ (4-n^2)Z^2+((4-n^2)y-(n^2+2n)z)^2+((4-n^2)^2-(n^2+2n)^2)z^2=0 \end{align*} Let $Y=(4-n^2)y-(n^2+2n)z\Leftrightarrow y=\dfrac{Y+(n^2+2n)z}{4-n^2}$, then $$(4-n^2)Z^2+Y^2+((4-n^2)^2-(n^2+2n)^2)z^2=0$$

1.3 Factor $z$ variables
\begin{align*} (4-n^2)Z^2+Y^2+((4-n^2)^2-(n^2+2n)^2)z^2=0\\ (4-n^2)Z^2+Y^2+(((2-n)(2+n))^2-(n(n+2))^2)z^2=0\\ (4-n^2)Z^2+Y^2+((2-n)^2(n+2)^2-n^2(n+2)^2)z^2=0\\ (4-n^2)Z^2+Y^2+((2-n)^2-n^2)(n+2)^2z^2=0\\ (4-n^2)Z^2+Y^2+(4-4n+n^2-n^2)(n+2)^2z^2=0\\ (4-n^2)Z^2+Y^2+(4-4n)(n+2)^2z^2=0\\ (4-n^2)Z^2+Y^2+(1-n)(4(n+2)^2z^2)=0\\ (4-n^2)Z^2+Y^2+(1-n)(2(n+2)z)^2=0 \end{align*} Let $X=2(n+2)z\Leftrightarrow z=\dfrac{X}{2(n+2)}$, then $$(4-n^2)Z^2+Y^2+(1-n)X^2=0$$ $$(n^2-4)Z^2-Y^2+(n-1)X^2=0$$

2. Birational isomorphism
Let $$C: x^2+y^2+z^2-n(xy+xz+yz)=0$$ and $$F: (n-1)X^2-Y^2+(n^2-4)Z^2=0$$ We have shown that there is a rational map $\phi$: $$\phi: C\to F$$ $$(x,y,z)\mapsto \left(2(n+2)z,(4-n^2)y-(n^2+2n)z,2x-n(y+z)\right)$$ We can also find an inverse: $$z=\dfrac{X}{2(n+2)}$$ $$y=\dfrac{Y+(n^2+2n)z}{4-n^2}=\dfrac{2Y+2n(n+2)z}{2(4-n^2)}=\dfrac{2Y+nX}{2(4-n^2)}$$ $$x=\dfrac{Z+n(y+z)}{2}=\dfrac{2(n+2)(Z+ny+nz)}{4(n+2)}=\dfrac{2(n+2)Z+2n(n+2)y+2n(n+2)z}{4(n+2)}=\dfrac{(2-n)2(n+2)Z+(2-n)2n(n+2)y+(2-n)nX}{(2-n)4(n+2)}=\dfrac{2(4-n^2)Z+2n(4-n^2)y+n(2-n)X}{4(4-n^2)}=\dfrac{2(4-n^2)Z+n(2Y+nX)+n(2-n)X}{4(4-n^2)}=\dfrac{2(4-n^2)Z+2nY+2nX}{4(4-n^2)}=\dfrac{(4-n^2)Z+nY+nX}{2(4-n^2)}$$ so that the inverse rational map is $$\psi: F\to C$$ $$(X,Y,Z)\mapsto \left(\dfrac{(4-n^2)Z+nY+nX}{2(4-n^2)},\dfrac{2Y+nX}{2(4-n^2)},\dfrac{X}{2(n+2)}\right)$$

The important thing here is to note that this is only undefined at $n=\pm 2$, which suggests that we handle these cases separately.

• Oh, wow. I cannot add more than a vote for your time and patience, thank you! – Paolo Leonetti Dec 28 '13 at 19:47
• @PaoloLeonetti As long as it's useful that's good enough. =D – Yong Hao Ng Dec 28 '13 at 19:49