# $x^2+y^2=z(4z+1)$ solutions

For a small project I am working on, I wish to find the solutions for $$x^2+y^2=z(4z+1)$$ in natural numbers $x,y,z$. I wish to automate finding solutions for $z$ up to a maximum value as efficient as possible, running through $z$ values from 1 and then try to find possible $x$ and $y$.

One thing that I found is that I can disregard $z \equiv 3,6,7 \mod 8$, as the sum of two squares can only be $\equiv 0,1,2,4,5 \mod 8$. But I wonder which other criteria I can use to exclude $z$ values. I also wonder whether for given $z$, which $x$ I can ignore, so that I only test those $x$ values that could give a solution.

• Can you use this... math.stackexchange.com/questions/794510/… Apr 2, 2017 at 10:57
• The general rule is that $x^2+y^2=M$ has solutions with $x,y$ relatively prime if and only if $M$ has no prime $p\equiv 3\pmod {4}$ as a divisor. This really can be checked only by factoring. Apr 2, 2017 at 10:58
• For example, your equation has no solutions when $z=21$. Nor $z=5$. Apr 2, 2017 at 11:00
• We have $(8z+1)^2-(4x)^2-(4y)^2=1$, and The diophantine equation X^2 - Y^2 - Z^2 = +- 1 should help. Apr 2, 2017 at 11:04

For the solution of the equation. $$X^2+Y^2=Z(4Z+1)$$

You must use the solutions of the equation. $$k^2+t^2=4s^2+1$$

You can use solutions which are recorded in the subject. Integral solutions of hyperboloid $x^2+y^2-z^2=1$

Then using the solutions of this equation can be substituted into the formula and find us.

$$X=k^2+4s^2-t^2+(4t+9s)k$$

$$Y=2t^2+8s^2-2k^2+(2k+9s)t$$

$$Z=k^2+t^2+5s^2+2(2t+k)s$$

• ~individ Nice but two questions: (1) how did you derive these formulas (2) will this get all solutions? Apr 5, 2017 at 17:35

The numbers that are a sum of two squares are exactly the ones of this form: $$2^rp_1\ldots p_s m^2$$ where $r$ and $s$ are non negative integers, $m$ is natural and $p_1,\ldots,p_s$ are primes congruent to $1$ mod $4$ (not necessarily different).

Since $z$ and $4z+1$ are coprime, the number $z(4z+1)$ is a sum of two squares if and only if both $z$ and $4z+1$ are sums of squares.

Not the answer but

$${{x}^{2}}+{{y}^{2}}=z\,\left( 4z+1\right)$$

$$x=\frac{2{{s}^{2}}-2{{h}^{2}}-h}{4h+1},\ y=s,\ z=\frac{{{s}^{2}}+{{h}^{2}}}{4h+1}$$