# 14.7 Ring Functions for Gaussian Integers

As already mentioned in the introduction to this chapter, the ring of Gaussian integers is a Euclidean ring. Therefore all ring functions are applicable to this ring and its elements (see chapter Rings). This section gives further comments on the definitions and implementations of those functions for the Gaussian integers. All functions not mentioned here are not treated specially, i.e., they are implemented by the default function mentioned in the respective section.

`IsUnit`, `Units`, `IsAssociated`, `Associates`

The units of `GaussianIntegers` are `[ 1, E(4), -1, -E(4) ]`.

`StandardAssociate`

The standard associate of a Gaussian integer x is the associated element y of x that lies in the first quadrant of the complex plane. That is y is that element from `x * [1,-1,E(4),-E(4)]` that has positive real part and nonnegative imaginary part.

`EuclideanDegree`

The Euclidean degree of a Gaussian integer x is the product of x and its complex conjugate.

`EuclideanRemainder`

Define the integer part i of the quotient of x and y as the point of the lattice spanned by 1 and `E(4)` that lies next to the rational quotient of x and y, rounding towards the origin if there are several such points. Then `EuclideanRemainder( x, y )` is defined as ```x - i * y```. With this definition the ordinary Euclidean algorithm for the greatest common divisor works, whereas it does not work if you always round towards the origin.

`EuclideanQuotient`

The Euclidean quotient of two Gaussian integers x and y is the quotient of w and y, where w is the difference between x and the Euclidean remainder of x and y.

`QuotientRemainder`

`QuotientRemainder` uses `EuclideanRemainder` and `EuclideanQuotient`.

`IsPrime`, `IsIrreducible`

Since the Gaussian integers are a Euclidean ring, primes and irreducibles are equivalent. The primes are the elements `1 + E(4)` and `1 - E(4)` of norm 2, the elements `a + b*E(4)` and `a - b*E(4)` of norm `p = a^2 + b^2` with p a rational prime congruent to 1 mod 4, and the elements p of norm `p^2` with p a rational prime congruent to 3 mod 4.

`Factors`

The list returned by `Factors` is sorted according to the norms of the primes, and among those of equal norm with respect to `<`. All elements in the list are standard associates, except the first, which is multiplied by a unit as necessary.

The above characterization already shows how one can factor a Gaussian integer. First compute the norm of the element, factor this norm over the rational integers and then split 2 and the primes congruent to 1 mod 4 with `TwoSquares` (see TwoSquares).

```    gap> Factors( GaussianIntegers, 30 );
[ -1-E(4), 1+E(4), 3, 1+2*E(4), 2+E(4) ] ```

GAP 3.4.4
April 1997