Solutions to a quadratic diophantine equation $x^2 + xy + y^2 = 3r^2$. Let $k,i,r \in\Bbb Z$, $r$ constant. How to compute the number of solutions to $3(k^2+ki+i^2)=r^2$, perhaps by generating all of them?
 A: There are infinitely many solutions to this Diophantine equation.
I change your variables. We have the Diophantine equation$$3(a^2+ab+b^2)=c^2$$Let's assume $c$ is not constant and find all possible solutions! $c=0$ gives $a=b=0$. W.L.O.G. suppose $c>0$. It's easy to see that $c=3d$ for some positive integer $d$. Equation becomes$$a^2+ab+b^2=3d^2$$For $a=b$ we get $a=b=\pm d$. W.L.O.G. suppose that $a>b$. Notice that$$a^2+ab+b^2 \equiv 0 \pmod 3$$It follows that $a^3 \equiv b^3 \pmod 3$ and $a \equiv b \pmod 3$. Let $a-b=3e$ for some positive integer $e$. Equation turns into$$b^2+3be+3e^2=d^2$$In order to get integer values for $b$ discriminant of this quadratic must be a perfect square, that is$$\Delta_{b}=-3e^2+4d^2=f^2$$For some integer $f$. 
$f=0$ gives $\sqrt{3}=2\frac{d}{e}$, which is impossible. W.L.O.G. suppose that $f>0$. Therefore, we need to solve$$f^2+3e^2=4d^2$$In positive integers. Now this is of the form of extended Pythagorean equation $Ax^2+By^2=Cz^2$, which is widely studied. Even there are some questions here and here, which exactly discuss your particular case!
Once you find parametric forms of $f$, $e$ and $d$, you can substitute backwards and find parametric form of your original variables $a$, $b$ and $c$.  
A: Generally, you can use the General formula.   Solving a Diophantine equation of the form $x^2 = ay^2 + byz + cz^2$ with the constants $a, b, c$ given and $x,y,z$ positive integers
$$ax^2+bxy+cy^2=jz^2$$
For our case.
$$x^2+xy+y^2=3z^2$$
$$\sqrt{b^2+4a(j-c)}=3$$
$$\sqrt{j(a+b+c)}=3$$
There is a solution. The formula remains only to substitute.
A: $$c\,{{x}^{2}}+dyx+g\,{{y}^{2}}=ab$$
$$\downarrow$$
$$g\,{{\left( psc+hkc+dks\right) }^{2}}+c\,{{\left( hpc-gks\right) }^{2}}+d\,\left( hpc-gks\right) \,\left( psc+hkc+dks\right) =$$
$$=c\,\left( {{h}^{2}}c+g\,{{s}^{2}}+dhs\right) \,\left( {{p}^{2}}c+dkp+g\,{{k}^{2}}\right) $$
$$\downarrow$$
$$c\,{{x}^{2}}+dyx+g\,{{y}^{2}}=a\,{{z}^{2}}$$
$$\downarrow$$
$$c\,{{\left( -cgp\,{{s}^{2}}-dgk\,{{s}^{2}}-2cghks+{{c}^{2}}\,{{h}^{2}}p\right) }^{2}}+$$
$$+g\,{{\left( cdp\,{{s}^{2}}-cgk\,{{s}^{2}}+{{d}^{2}}k\,{{s}^{2}}+2{{c}^{2}}hps+2cdhks+{{c}^{2}}\,{{h}^{2}}k\right) }^{2}}+$$
$$+d\,\left( cdp\,{{s}^{2}}-cgk\,{{s}^{2}}+{{d}^{2}}k\,{{s}^{2}}+2{{c}^{2}}hps+2cdhks+{{c}^{2}}\,{{h}^{2}}k\right)\cdot $$
$$\cdot\left( -cgp\,{{s}^{2}}-dgk\,{{s}^{2}}-2cghks+{{c}^{2}}\,{{h}^{2}}p\right)= $$
$$={{c}^{2}}\,\left( c\,{{p}^{2}}+dkp+g\,{{k}^{2}}\right) \,{{\left( g\,{{s}^{2}}+dhs+c\,{{h}^{2}}\right) }^{2}}$$
$$------------------------------$$
For $\;\;{{x}^{2}}+yx+{{y}^{2}}=3{{r}^{2}},\;\;$
$c=1,\;d=1,\;g=1,\;{{p}^{2}}+kp+{{k}^{2}}=3$
Two solutions:
$$r={{s}^{2}}+hs+{{h}^{2}},\;\;x=-{{s}^{2}}+2hs+2{{h}^{2}},\;\;y=2{{s}^{2}}+2hs-{{h}^{2}}$$
$$r={{s}^{2}}+hs+{{h}^{2}},\;\;x={{s}^{2}}-2hs-2{{h}^{2}},\;\;y={{s}^{2}}+4hs+{{h}^{2}}$$
