I am trying to solve this diophantine equation: $x^2 + yx + y^2 = z^2$

In other words, I am trying to find integers $x$ and $y$ such that $x^2 + yx + y^2$ is a perfect square.

So far, the only methods to solve quadratic diophantine equations I am familiar with are Pythagorean triples and Pell equations. The $yx$ term has a coefficient of one, so I can't complete the square to reduce it to a Pell equation somehow, and I am wondering if there are other methods to solve this kind of equation.

Some insight would be highly appreciated.


Generally speaking, this equation has a lot of formulas for the solution. Because it is symmetrical.

Write the formula can someone come in handy. the equation:


Has a solution:
















For the particular case: $Y^2+XY+X^2=Z^2$ You can draw more formulas.








In the equation: $X^2+aXY+bY^2=Z^2$ there is always a solution and one of them is quite simple.




$p,s$ - integers asked us.

| cite | improve this answer | |
  • $\begingroup$ I was looking for something like this! Can all solutions be generated from each case? or should one use all of them together to generate all solutions? $\endgroup$ – Ashura Jul 7 '15 at 4:34
  • $\begingroup$ @Ashura formally, we need to use all the formulas. But it is enough to use only General. Some formulas are mapped to each other. $\endgroup$ – individ Jul 7 '15 at 4:38
  • $\begingroup$ Can you possibly direct me to some resource with more information about this? Just out of curiousity. Thanks! $\endgroup$ – Ashura Jul 7 '15 at 4:47
  • $\begingroup$ @Ashura these formulas are a special case of a more General formulas. For example of such. math.stackexchange.com/questions/738446/… math.stackexchange.com/questions/794510/… Better in my blog to see. Many decisions have collected. artofproblemsolving.com/community/c3046 $\endgroup$ – individ Jul 7 '15 at 4:52

We can generate solutions by a procedure similar to the one used to generate Pythagorean triples. Namely, it is equivalent to find rational points on the ellipse $a^2 + ab + b^2 = 1$. We do this by choosing a rational slope $m$, taking the line through $(1,-1)$ with slope $m$, and finding the other intersection of this line with the ellipse. This procedure gives the solution $a=-\frac{m^2+2m}{m^2+m+1}$, $b=\frac{2m+1}{m^2+m+1}$. Now, if $m=\frac{p}{q}$, we get a solution $a=-\frac{p^2+2pq}{p^2+pq+q^2}$, $b=\frac{2pq+q^2}{p^2+pq+q^2}$. Therefore, $x=-(p^2+2pq)$, $y=2pq+q^2$, $z=p^2+pq+q^2$ gives a solution to the original equation; and every solution in integers is a rational multiple of one of these solutions (since in reverse, the line through $(1,-1)$ and $(\frac{x}{z}, \frac{y}{z})$ has rational slope).

| cite | improve this answer | |

Let $z$ be a fixed integer. We have $x^2+y^2+xy=z^2$ is equivalent to $(x+y)^2-xy=z^2$ and $(x-y)^2+3xy=z^2.$ Therefore, $(x+y)^2=z^2+xy\geq 0$ and $(x-y)^2=z^2-3xy\geq 0.$ Then, we have $z^2+xy$ and $z^2-3xy$ are squares. So, $|x+y|=\sqrt{z^2+xy}$ and $|x-y|=\sqrt{z^2-3xy}.$ This implies that $x+y=\sqrt{z^2+xy}$ or $x+y=-\sqrt{z^2+xy}$ and $x-y=\sqrt{z^2-3xy}$ or $x-y=-\sqrt{z^2-3xy}.$ You use after that the basic tools of calculus to find $x$ and $y$ separatly.

| cite | improve this answer | |
  • $\begingroup$ I like what you did there, but it doesn't look like I can use those formulae to systematically generate all solutions to the equation above. Unless I'm missing something. $\endgroup$ – Ashura Jul 7 '15 at 4:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.