Remember, we have already characterized the triples without coefficients.
u > v > 0, u and v coprime, and u and v of different parity:
x ← u2-v2
y ← 2uv
z ← u2+v2
If the coefficient on z2 contains a prime that is 3 mod 4, there is no solution. This because such a prime remains prime in the gaussian integers.
Set x+yi to an associate of (u+vi)2 times 1-2i or 1+2i. As before, the even component must be assigned to y, so the unit that assures equality cannot be i; it must be 1 or -1. If -1, the variables will come out negative, but the equation will still work. This gives the following two characterizations.
u > v ≥ 0, u and v coprime, u and v of different parity, disregard fives:
x ← u2-v2+4uv
y ← 2(v2-u2+uv)
z = u2+v2
x ← u2-v2-4uv
y ← 2(u2-v2+uv)
z ← u2+v2
Note that y = 2 mod 4.
The following changes leave x y and z alone, or they negate some of these variables, or they interchange the two solutions. If u and v are negative, negate them. If u and v have different signs, swap them and make the negative variable positive. If v > u, swap them, thus swapping the two solutions. Hence our constraint u > v.
Like the pythagorean triples, different values of u+vi cannot be associates, as they are all in the first quadrant, hence they consist of different primes, and lead to different primes in (u+vi)2. Multiply these distinct complex squares by 1+2i or 1-2i and get a different mix of primes, leading to distinct values of x and y.
Are x and y coprime? Any prime dividing x and y divides their sum, 5uv. The common prime is either 5, or it divides u or v, and if the latter it divides both u and v, which is a contradiction. So the only possible factor between x and y is 5, and that could happen if u+vi includes one of the primes lying over 5, and we brought in the other one. Oops. This is shown by the following example.
Set u = 2 and v = 1 to obtain the following.
112 + 22 = 5×52
52 + 102 = 5×52.
If a solution is divisible by 5, remove 1+2i from u+vi, then bring in 1+2i instead of 1-2i to find its coprime progenitor. In other words, the offending triple with the gcd overcounts a triple that was produced earlier; we can simply throw it away.
When u+vi = 1+2i, as above, the quotient is 1+0i, and that's why we allow v = 0. This is the only case where both characterizations build the same triple, 1+4 = 5×1.
Note that 3+0i does not cause trouble, because technically, 3 and 0 are not coprime. Letting v = 0 brings in just one more triple, and that's what we want.
Well that was unduely complicated; let's look at a solution that does not mess with fives. Set u = 3 and v = 2 to obtain the following.
292 + 22 = 5×132
192 + 222 = 5×132
Similar characterizations exist for x2 + y2 = kz2, where the primes of k are all 1 mod 4. Of course there may be many different characterizations, as we partition the conjugate primes of k between x+yi and x-yi. And there will be more exceptions, when u+vi happens to contain some of these complex primes lying over k.
This is a special case of the above, with k = 2, but we only need one formula, because the two primes lying over 2 are associates. Let x+yi = (u+vi)2×(1+i).
Let u and v be coprime, so that x and y are coprime. If 1+i divides u+vi then x and y come out even. Since 1+i generates a checkerboard of odd lattice points in the plane, u and v must have different parity.
u > v ≥ 0, u and v coprime, u and v of different parity:
x ← u2-2uv-v2.
y ← u2+2uv-v2
z ← u2 + v2
If u is negative then negate both u and v. If v is negative then negate v and swap x and y, giving the same solution. Finally if u < v, swap u and v, which swaps x and y. Now u > v ≥ 0. The ≥ is there to allow x = y = z = 1.
Set u = 2 and v = 1 to get 1 + 49 = 2×25.
u > 0, v > 0, u and v coprime, u is odd:
x ← u2-2v2
y ← 2uv
z ← u2+2v2
u > 0, v > 0, u and v coprime, u and v of different parity:
x ← u2-3v2
y ← 2uv
z ← u2+3v2
u > 0, v ≥ 0, u and v coprime, u and v of different parity:
x ← u2-3v2 - 6uv
y ← u2-3v2 + 2uv
z ← 2u2+6v2
u > 0, v ≥ 0, u and v coprime, u and v of different parity:
x ← u2-3v2 + 6uv
y ← u2-3v2 - 2uv
z ← 2u2+6v2
Factor in the ufd Z[q=sqrt(-2)], and note that 3 splits into (1+q)×(1-q). One of these two factors joins (u+vq)2 to build x+yq. This produces two characterizations, which are distinct, although one of the two solutions may have a common factor of 3, when 1+q divides u+vq, and this is handled by a smaller instance of u+vq. I know, I skated across that very quickly, but it's really the same reasoning as we saw above, when evaluating x2+y2 = 5z2.
u > 0, v ≥ 0, u and v coprime, u odd, disregard threes:
x ← u2-4uv-2v2
y ← u2+2uv-2v2
z ← u2+2v2
x ← u2+4uv-2v2
y ← -u2+2uv+2v2
z ← u2+2v2
As usual, changing the sign on u or v leaves things unchanged, or swaps the two solutions, perhaps negating x or y along the way. And as usual, u and v must be coprime. If u is odd then everything comes out even, so we rule that out. Solutions that produce threes are disregarded, as these are handled by earlier solutions. Allow v = 0 to facilitate x = y = z = 1.
For a same parity solution, set u = 3 and v = 1 to get the following.
52 + 2×132 = 3×112
192 + 2*12 = 3*112
Set q = sqrt(5), whence x2-5y2 becomes (x+yq)×(x-yq). Unfortunately q is no longer in the complex plane. This represents a significant departure from the theme of this topic, i.e. complex extensions. Adjoining q does not build a complex extension, and the resulting structure is more difficult to analyze. It isn't a grid of parallelograms in the plane. There is no geometric intuition to help us.
One thing hasn't changed; the conjugate and the norm. The conjugate of a+bq is a-bq, and the norm of a+bq is a+bq times its conjugate, or a2-5b2. Verify that this is a map into the integers that respects multiplication. (You can do this by expanding (a+bq)×(c+dq) and doing the algebra, or by realizing that conjugation is a ring automorphism that necessarily commutes with multiplication.)
Since 5 has no rational square root, you won't find an element with norm 0, except for 0. The units are those elements with norm ±1, and there are lots of them. This is different from the complex extensions, where there were only a few. When solving a2+5b2 = 1, you don't have far to go; but there are plenty of solutions to a2-5b2 = 1, such as 161+72q. That's a unit, with inverse 161-72q.
Here's something else that hasn't changed. We can adjoin ½+½q to Z, instead of q. We did something like this before, with the sixth roots of one. Those were the centers of rectangles in the complex plane, but as I say, we don't have the geometry to guide us. well - there's always algebra. If a+bq is an element of our ring, let a and b be integers or half integers (but not one of each). Show that (a+bq)×(c+dq) results in another element having integers or half integers (but not a mix). If you want to be general about it, let q2 = m, where m = 1 mod 4. That's the case when q = 5, and when q = -3, which led to the sixth roots of 1. Let's take it case by case.
When a b c and d are integers there's no trouble. So let a and b be integers and let c and d be half integers, or if you prefer, let c and d be odd integers with a common denominator of 2. Set the 1/2 aside for the moment and multiply. The first component is ac+mbd, and the second is ad+bc. With a c and m odd, the parity of each is the parity of b+d. both become even or odd, and after dividing by 2, both are integers or half integers.
Finally let both factors have denominators of 2, with a b c and d odd. Each component in the product is even, but are they 0 or 2 mod 4? That determines whether we get an integer or half integer. With m = 1 mod 4, the first component is ac+bd. The second is ad+bc. The difference is a(c-d)+b(d-c). Try various values of 1 or 3 mod 4 for a b c and d. When c = d we have 0, and when c ≠ d, c-d and d-c are both 2 mod 4, which is multiplied by a+b, giving 0 mod 4. The difference is 0 and the two components agree; either 0 or 2 mod 4. The product presents integers or half integers. Z[½+½q] is indeed a ring.
Here are the steps you would take to characterize the triples. I'm not going to supply any proofs, because this is really outside the current topic. You need algebraic number theory to fill in the details. So - here is the outline.
u > 0, v > 0, u and v coprime, u and v of different parity:
x ← u2+5v2,
y ← 2uv,
z ← u2-5v2
x ← u2+10uv+5v2
y ← u2+2uv+5v2
z ← 2u2-10v2
x ← -u2+10uv-5v2
y ← u2-2uv+5v2
z ← 2u2-10v2
x ← 7u2+30uv+35v2
y ← 3u2+14uv+15v2
z ← 2u2-10v2
x ← 3u2+10uv+15v2
y ← u2+6uv+5v2
z ← 2u2-10v2
This is a complicated case, and I'm not sure I got everything right. Some day I'll go over it again and fill in the details. For now, I think we've had quite enough of enhanced pythagorean triples. Let's move on.