<s>[INST] Finding Pythagorean triple where the squares of sides are weighted Suppose $a, b, c \in \mathbb{Z}_{>0}$. The following is a variation of a Pythagorean triple, but with weighted squares:
$$a^2 + 3 b^2 = 4 c^2$$
Can I find something like Euclid's formula that can generate all solutions for this formula? I'm not sure how to approach this problem.
 [/INST] After discovering Find all integers satisfying $m^2=n_1^2+n_1n_2+n_2^2$, the paper Abdelalim, S., & Dyani, H. (2014). The Solution of the Diophantine Equation x2+ 3y2= z2. International Journal of Algebra, 8(15), 729–732. gives an easy answer:
Theorem 2.1 Let $E : x^2 + 3 y^2 = z^2$ diophantine equation and $(x, y, z) \in \mathbb{Z}^3$ with $x \wedge y = 1$, $y$ is even and $x z \wedge 3 = 1$. Then the following properties are equivalent:

*

*$(x, y, z)$ is the solution of $E$.

*$| z | = 3 y_1^2 + y_2^2, | x | = 3 y_1^2 - y_2^2, | y | = 2 y_1 y_2$ with $y_1 \wedge y_2 = 1$.

Theorem 2.2 Let $E : x^2 + 3 y^2 = z^2$ diophantine equation and $(x, y, z) \in \mathbb{Z}^3$ with $x \wedge y = 1$, $y$ is odd and $x z \wedge 3 = 1$. Then the following properties are equivalent:

*

*$(x, y, z)$ is the solution of $E$.

*$| z | = \frac{3 y_1^2 + y_2^2}{2}, | x | = \frac{3 y_1^2 - y_2^2}{2},
  | y | = y_1 y_2$ with $y_1 \wedge y_2 = 1$.

Scaling the above primitive solutions $(x, y, z)$, and in our case restricting to $2 \mid z$, gives all solutions.

The following is a method that is less explicit, as it requires dividing by a $\gcd$.
Thanks to Daniel Hast's comment, I arrived at the following:
Finding such $(a, b)$ is equivalent to finding a single rational point on the ellipse $x^2 + 3 y^2 = 4$, then finding all rational lines through it. A rational point is $(1, 1)$, and a rational line through that is $t y = s x - s + t$ where $\gcd (s, t) = 1$. The other intersection with the ellipse is at:
$$ (x, y) = \left( \frac{3 s^2 - 6 s t - t^2}{3 s^2 + t^2}, - \frac{3 s^2 + 2 s t - t^2}{3 s^2 + t^2} \right) $$
So:
$$ \begin{array}{rll}
 \left( \frac{3 s^2 - 6 s t - t^2}{3 s^2 + t^2} \right)^2 + 3 \left(
 \frac{3 s^2 + 2 s t - t^2}{3 s^2 + t^2} \right)^2 & = & 4\\
 (3 s^2 - 6 s t - t^2)^2 + 3 (3 s^2 + 2 s t - t^2)^2 & = & 4 (3 s^2 +
 t^2)^2\\
 4 (3 s^2 + t^2)^2 - 3 (3 s^2 + 2 s t - t^2)^2 & = & (3 s^2 - 6 s t -
 t^2)^2
\end{array} $$
Note that the numerator and denominators of $x, y$ can be scaled while the
rational point stays the same. Let $d
= \gcd (3 s^2 + t^2, 3 s^2 + 2 s t - t^2)$. For $k \in \mathbb{Z}$, our
solutions are then:
$$ a = \frac{k}{d} \cdot (3 s^2 + 2 s t - t^2) \quad b = \frac{k}{d} \cdot (3 s^2 + t^2) $$
</s>