# Pythagorean Type Equation

$4a^2+b^2=2c^2$ where $a$, $b$ and $c$ are positive integers. I have to find all primitive triplets such that $c \le N$. $N$ can be as high as $10^7$. Can we get a tree like solutions like that of pythagorean triplets, which efficiently generate only the primitive solutions?

If $(p,q,r)$ is a primitive solution, then $(p,3q+4r,2q+3r)$ is also a primitive solution.

EDIT: In this case the whole square triplet form arithmetic progression. What if this is not the case? For example how to solve $a^2+3b^2=c^2$?

• For $a^2+3b^2=c^2$, Euler's $6n+1$ Theorem (mathworld.wolfram.com/Eulers6nPlus1Theorem.html) should help. – Adam Bailey Jan 23 '18 at 11:38
• It looks like all prime factors of $a$ must be of the form $12k+1$ or $12k-1$. And $c$ can be expressed as $x^2+xy+y^2$ where $(x,y)=1$. But it doesn't help much to find the solutions. – Asif Jan 23 '18 at 12:46

This answer addresses the question as originally posted, relating to the equation $4a^2+b^2=2c^2$ only.

Putting $d=2a$ we have $d^2+b^2=2c^2$, implying that $b^2,c^2,d^2$ are in arithmetic progression.

Formulae for generating sets of three squares in arithmetic progression with no common divisor (due to Leonardo of Pisa (Fibonacci)) may be found here. The formulae are in terms of parameters $m,n$ which must be coprime yielding two cases: a) one even, one odd; b) both odd.

For case (a) the formulae are: $m^2+2mn-n^2, m^2+n^2, n^2+2mn-m^2$. This yields odd values so would produce a non-integer value for $a = d/2$.

For case (b) the above formulae yield even values so they must be divided by $2$ to yield coprime values. For our purposes, however, we do not need $b,c,d$ to be coprime; the requirement is for $a,b,c$ to be coprime. So the formulae we require are:

$$a=\frac{d}{2}=\frac{m^2+2mn-n^2}{2}$$

$$c=m^2+n^2$$

$$b=n^2+2mn-m^2$$

Note that $a$ must be odd since $m^2+2mn-n^2\equiv1+2-1 \equiv 2$ mod $4$.

For some values of $m,n$, these formulae will yield a negative value for $a$ or $b$. To ensure positive values therefore the complete solution is:

$$a=\Bigg\lvert\frac{m^2+2mn-n^2}{2}\Bigg\rvert$$

$$b=\lvert n^2+2mn-m^2\rvert$$

$$c=m^2+n^2$$

• Thanks @Adam Bailey. I can generate all solutions efficiently. We have to remove $n < m$ condition to get all the solutions. Otherwise we have to count carefully to include those extra solutions. For example, $(7,2,10)$ is a valid solution which is generated by $(m,n)=(2,1)$. – Asif Jan 23 '18 at 4:02
• Edited to address negative values. For $(7,2,10)$ we have $(m,n)=(3,1)$. – Adam Bailey Jan 23 '18 at 9:26