# Gaussian integers

Assume that you are familiar with the imaginary number i, which is sqrt(-1).

Gaussian integers are numbers of the form x+yi, where x and y are integers. Formally, the set

R = { x+yi : x and y integers }

defines Gaussian integers. (Nothing is special about choosing the letter R.)

Examples are -3, 4, 0, i, -i, 3+4i, -5+2i, 2-2i.

## Units

The units of R are 1, -1, i, and -i. It is easy to verify that they are indeed units. To see that they are the only ones, suppose u+vi is a unit, so (u+vi)(s+ti) = 1 for some integers s and t, which means us - vt = 1 and ut + vs = 0, and also u(s^2 + t^2) = s. If s=0, then t!=0, u=0, and v=1 or -1. If s!=0, then |s|=1 and t=0, otherwise |u(s^2 + t^2)| = |s| would not hold; so v=0 and u=1 or -1.

## Primes

In R, 2 = (1+i)(1-i), so 2 is no longer a prime in R. This is not the only case: 5 = (1+2i)(1-2i) too. Fortunately, the new rules for primes and composites are still simple:

1. Composties in the integers remain as composites in R.
2. A prime p in the integers with p mod 4 = 3 remains as a prime in R.
3. A prime p in the integers with p=2 or p mod 4 = 1 becomes a composite in R. However, you can write p = (a+bi)(a-bi), and a+bi and a-bi are primes in R.
4. All primes in R can be obtained from the above rules.

So for example, 3, 7, 11 are primes in R, while 2 and 5 are not, as discussed; but then their factors, 1+i, 1-i, 1+2i, and 1-2i are primes in R, so the factorizations of 2 and 5 shown is finished.

## Factorization

The Gaussian integers R obeys a unique-factorization theorem analogous to that of the integers.

Theorem: In the Gaussian integers R, each non-zero, non-unit member can be factorized into a product of primes; furthermore, the factorization is unique up to ordering and associates.

For example, 3 is itself a prime, so 3 = 3 is a prime factorization. As another example, (1+2i)(1-2i) is a prime factorization of 5. Now, we seems to have another factorization: 5 = (2+i)(2-i), but notice that 1+2i and 2-i are associates, and so are 1-2i and 2+i: (1+2i)*(-i) = 2-i for example. Thus we are having the same factorization essentially. This is in the same principle as recognizing that 3*3 and (-3)*(-3) are essentially the same factorization of 9.

As a final example, 10 = 2*5 = (1+i)(1-i)(1+2i)(1-2i).