Conditions for $ax^2+ax+1$ to be a perfect square. I look for the conditions for $ax^2+ax+1$ to be a perfect square, like some sort of recursive algorithm. I have a fixed $a$ and I would like to express $x$ in terms of $a$ or any other form. (My peculiar case is $52x^2+52x+1$). Any help would be appreciated! 
 A: Take $v=2x+1,$ your question becomes the Pell type
$$ w^2 - av^2 = 4-a  $$
This always has solutions using $w=2, v=1,$ which is just $x=0.$
You also need to solve $w^2 - a v^2 = 1,$ which is the original Pell equation. For example, $ \; 649^2 - 52 \cdot 90^2 = 1 $
A: if $a=4$, $x$ is any integer.
Assume $a \ne 0$,
$ax^2+ax+1 = 1$,   solution $x = 0, -1$
$ax^2+ax+1 = 4$,   solution $x = \frac{1}{2}\left(\frac{1}{\sqrt{\frac{a}{a+12}}}-1\right)$
$ax^2+ax+1 = 9$,   solution $x = \frac{1}{2}\left(\frac{1}{\sqrt{\frac{a}{a+32}}}-1\right)$
$ax^2+ax+1 = 16$,  solution $x = \frac{1}{2}\left(\frac{1}{\sqrt{\frac{a}{a+60}}}-1\right)$
$ax^2+ax+1 = 25$,  solution $x = \frac{1}{2}\left(\frac{1}{\sqrt{\frac{a}{a+96}}}-1\right)$
$ax^2+ax+1 = 36$,  solution $x = \frac{1}{2}\left(\frac{1}{\sqrt{\frac{a}{a+140}}}-1\right)$
$ax^2+ax+1 = 49$,  solution $x = \frac{1}{2}\left(\frac{1}{\sqrt{\frac{a}{a+192}}}-1\right)$ 
Any pattern ? 12, 32, 60, 96, 140, 192,...

12 - 0 = 10 + 2
32 - 12 = 20 - 0
60 - 32 = 30 - 2
96 - 60 = 40 - 4
140 - 96 = 50 - 6
192 - 140 = 60 - 8  
Seems there is a pattern. 
$$x =  \frac{1}{2}\left(\frac{1}{\sqrt{\frac{a}{a+\sum_{i=1}^{z}(8i+4)}}}-1\right)$$
where, $z \in \mathbb{N}$
A: You can find many things. Some include:


*

*$x\equiv 1\bmod 3 \implies a\not\equiv 2 \bmod 3$

*$x\equiv 1,2 \bmod 4 \implies a\equiv 0 \bmod 2$

*$2a+1\equiv z^2 \pmod {x-1}$ or mod any of $x-1$'s factors. 

*$x^2+x+1\equiv c^2\pmod{a-1}$ or mod any of $a-1$'s factors. 

*etc.


most of this is modular arithmetic 101. Basic case attempts, and quadratic residues. Polynomial remainder theorem thrown in at the end cases.  You can continue locking it down mod a-y and x-y. 
