Solutions of Diophantine equations in general form.

Prior to that solved a similar equation. Solutions like wrote. Then I thought to solve a similar equation.

Diophantine equation: $X^2+XY+Y^2=Z^2+1$

Some solutions are unpretentious parameterization.

$X=3k^2-4k$

$Y=2k-1$

$Z=3k^2-3k$

And more:

$X=6k^2-2k-1$

$Y=4k$

$Z=6k^2$

Solutions can be written using the solutions of Pell's equation: $p^2-(3k^2-6k+1)s^2=\pm1$

And the solutions are of the form:

$X=p^2+2ps+(4k-7)s^2$

$Y=-4ps+(3k^2-8k+4)s^2$

$Z=-(3k-2)ps+3(k-2)s^2$

more:

$X=\frac{1}{2}(p^2+(6k-14)ps+(9k^2-26k+17)s^2)$

$Y=\frac{1}{2}(3p^2+(6k-2)ps+(3k^2-2k-5)s^2)$

$Z=\frac{1}{2}(3p^2+(12k-14)ps+(9k^2-24k+15)s^2)$

But quickly found out that you can draw more formula. Therefore, so as not to draw every time different formulas. Thought can draw right formula in general?

That is, draw the solution of equation: $X^2+XY+Y^2=Z^2+q$

$q$ - what some given integer.

So what can be interesting ideas to solve this equation in general form?

For the equation: $X^2+XY+Y^2=Z^2+q$

Write down the solution when the number can be factored as follows. $q=(a-b)(a+b)$

Then use the solution of Pell's equation: $p^2-ns^2=1$

Where the coefficient is given by: $n=3k^2-6kt+t^2$

$k,t$ - integers asked us.

Then the solution can be written:

$X=2(2at-bk)ps+(3ak^2-2(3b+2a)kt+8bt^2)s^2$

$Y=ap^2+2((2b-a)t-bk)ps+((a-4b)t^2+2(3b-2a)kt)s^2$

$Z=bp^2+(4at-3ak)ps+(3bk^2-3(2b+a)kt+7bt^2)s^2$

And more.

$X=\frac{2b-3a}{2}p^2-((3a-4b)k+(6b-5a)t)ps$$+\frac{1}{2}((18b-3a)t^2+2(5a-12b)kt+3(2b-a)k^2)s^2 Y=\frac{2b-a}{2}p^2-((3a-4b)k+(2b+a)t)ps+$$\frac{1}{2}(-(6b+a)t^2+10akt+3(2b-3a)k^2)s^2$

$Z=\frac{4b-3a}{2}p^2-(6(a-b)k+(6b-5a)t)ps+$$\frac{1}{2}((16b-3a)t^2+12(a-2b)kt+3(4b-3a)k^2)s^2$