<s>[INST] How to find all integer solutions of $p^2+q^2=((2q+1)^2+q+1)^2+1$ $$p^2+q^2=((2q+1)^2+q+1)^2+1$$
How do I find integer solutions to this equation? I've already found $(p,q)=(11,1)$. How do I go about finding new ones? 
 [/INST] $$\begin{align}p^2+q^2&=((2q+1)^2+q+1)^2+1\\\implies p^2+q^2&=16q^4+40q^3+41q^2+20q+5 \\\implies p^2&=16q^4+40q^3+40q^2+20q+5\end{align}$$
So for an integer $q$ if $16q^4+40q^3+40q^2+20q+5$ is a perfect square, then you will get integer solutions for your equation.


*

*$q=1\implies16q^4+40q^3+40q^2+20q+5=121=11^2$

*$q=-1\implies16q^4+40q^3+40q^2+20q+5=1=1^2$


So $(11,1)$ and $(1,-1)$ are solutions, others may exist.
</s>