structural:expansion
Greatest common divisor

As for any unique factorization domain, a greatest common divisor (gcd) of two Gaussian integers a, b is a Gaussian integer d that is a common divisor of a and b, which has all common divisors of a and b as divisor. That is (where | denotes the divisibility relation),

Thus, greatest is meant relatively to the divisibility relation, and not for an ordering of the ring (for integers, both meanings of greatest coincide).

More technically, a greatest common divisor of a and b is a generator of the ideal generated by a and b (this characterization is valid for principal ideal domains, but not, in general, for unique factorization domains).

The greatest common divisor of two Gaussian integers is not unique, but is defined up to the multiplication by a unit. That is, given a greatest common divisor d of a and b, the greatest common divisors of a and b are d, – d, id, and – id.

There are several ways for computing a greatest common divisor of two Gaussian integers a and b. When one knows the prime factorizations of a and b,

where the primes p are pairwise non associated, and the exponents μ non-associated, a greatest common divisor is

with

Unfortunately, except in simple cases, the prime factorization is difficult to compute, and Euclidean algorithm leads to a much easier (and faster) computation. This algorithm consists of replacing of the input (a, b) by (b, r), where r is the remainder of the Euclidean division of a by b, and repeating this operation until getting a zero remainder, that is a pair (d, 0). This process terminates, because, at each step, the norm of the second Gaussian integer decreases. The resulting d is a greatest common divisor, because (at each step) b and r = a – bq have the same divisors as a and b, and thus the same greatest common divisor.

This method of computation works always, but is not as simple as for integers because Euclidean division is more complicated. Therefore, a third method is often preferred for hand-written computations. It consists in remarking that the norm N (d) of the greatest common divisor of a and b is a common divisor of N (a), N (b), and N (a + b). When the greatest common divisor D of these three integers has few factors, then it is easy to test, for common divisor, all Gaussian integers with a norm dividing D.

For example, if a = 5 + 3 i, and b = 2 – 8 i, one has N (a) = 34, N (b) = 68, and N (a + b) = 74. As the greatest common divisor of the three norms is 2, the greatest common divisor of a and b has 1 or 2 as a norm. As a gaussian integer of norm 2 is necessary associated to 1 + i, and as 1 + i divides a and b, then the greatest common divisor is 1 + i.

If b is replaced by its conjugate b = 2 + 8 i, then the greatest common divisor of the three norms is 34, the norm of a, thus one may guess that the greatest common divisor is a, that is, that a | b. In fact, one has 2 + 8 i = (5 + 3 i)(1 + i).