If

`d` is a

square-free

integer, then

**Q**(sqrt(

`d`)), the set of all numbers

`a + b `sqrt

`(d)` with

`a` and

`b` rational (in

**Q**), is called a

**quadratic field**. If

`d` is positive, it is called a

real quadratic field; if

`d` is negative, then it is called an

imaginary quadratic field. A quadratic field is, in fact, a

field.

The **defining equation** of `z` in **Q**(sqrt(`d`)) is the quadratic polynomial with integer coefficients of which `z` is a root. If `z = (a + b `sqrt`(d)) / c`, then the defining equation for `z` would be `(c x - a - b `sqrt`(d))(c x - a +b `sqrt`(d)) = c^2 x^2 - 2 a c x + a^2 - b^2 d`.

We can then define a **quadratic integer** as a number in **Q**(sqrt(`d`)) such that its defining equation is monic, i.e, that its leading coefficient is 1. Notice that this definition is compatible with the established definition of **Z**, the integers (in this context, **Z** is referred to as the rational integers to avoid confusion). The integers of **Q**(sqrt(-1)) are generally called the Gaussian integers.

If `d` is equal to 2 or 3 (mod 4) then the quadratic integers look like `a + b sqrt(d)`, where `a` and `b` are rational integers. If `d` is equal to 1 (mod 4), then the quadratic integers look like `a + b[(1 + `sqrt`(d)) / 2]`, again with `a` and `b` rational integers.

Unlike **Q**, **Q**(sqrt(`d`)) is not always a unique factorization domain; we don't always get to factor nicely. For example, **Q**(sqrt(-10)) is not a unique factorization domain, since 6 = 2 x 3 = (4 + sqrt(10))(4 - sqrt(10)). The question of which values of `d` give you unique factorization domain has been a matter of long debate. It is still unknown whether there are infinitely many such `d`. It is, however, known in the complex case:

**Theorem**: If `d` < 0, then **Q**(sqrt(`d`)) is a unique factorization domain if and only if `d` = -1, -2, -3, -7, -11, -19, -43, -67, or -163.

This theorem was originally conjectured by Gauss in *Disquisitiones Arithmeticae*. In 1934, it was shown there could be at most 10; and the nine above were already known. But it wasn't until 1966 that **Q**(sqrt(`d`)) was shown not to be a UFD for all `d` < -163.