When is $x^2 + 4y$ a square?

Sorry if this is a duplicate. And I probably knew this at one point in my life. But I can't remember or seem to find this easily. Can anyone point me in the right diophantine direction?

For $x,y \in\mathbb{Z}$ when is $(x^2 + 4y)$ a square? In particular I am interested in generating all solutions to this Diophantine equation:$$x^2 + 4y = z^2$$ within some bounds for $x$ and $y$, say $|x| < 1000$ and something similar for $y$. Is there a quick way to do something like this (the generation of solutions)?

I know that $z^2 - x^2$ factors so I can, for example, factor $4y$ and list those out for $(z-x)$ and $(z+x)$ but I'm sure there is actually a parametrization of the solutions.

I used to have a great link to a great site that listed the best known ways of generating solutions to all sort of Diophantine equations. But nothing gold can stay, and I've lost the link. If anyone knows what I'm talking about and can provide that link I'd be very grateful as well.

Many thanks for any help.

• $x$ is any number, $y=n(x+n)$ where $n\in\mathbb Z$. – Ivan Neretin Nov 3 '15 at 14:18
• Given $x$, you can choose any $y=bx+b^2$, for $b$ any integer. – Thomas Andrews Nov 3 '15 at 14:19
• @ThomasAndrews are these the only solutions?? – amcalde Nov 3 '15 at 14:24
• @IvanNeretin Please write up the comment as an answer..It is pretty sweet. – Chinny84 Nov 3 '15 at 14:26

If $z=x+c$ then $4y=2cx+c^2$. Thus $c$ is divisible by $2$, say $c=2b$. Then you get: $$y=bx+b^2$$
• OK, I see that. I had got previously that $z$ and $x$ had to be the same parity so this make sense. – amcalde Nov 3 '15 at 14:30
• One more point, is that $b$ must be greater than or equal to $-x/2$ or else I don't think it works because you'd get a negative value for $x^2 + 4y$. Add that condition and I'll accept. – amcalde Nov 3 '15 at 14:37
• No, if $b<-x/2$ then it still works, just algebra. It is not possible fo4 $x^2+4(bx+b^2)=(x+2b)^2$ to be negative. @amcalde – Thomas Andrews Nov 3 '15 at 14:41