In number theory, quadratic integers are a generalization of the integers to quadratic fields. Quadratic integers are algebraic integers of degree two, that is, solutions of equations of the form

with b and c (usual) integers. When algebraic integers are considered, the usual integers are often called rational integers.

Common examples of quadratic integers are the square roots of rational integers, such as 2, and the complex number i = –1, which generates the Gaussian integers. Another common example is the non-real cubic root of unity −1 + –3/2, which generates the Eisenstein integers.

Quadratic integers occur in the solutions of many Diophantine equations, such as Pell's equations, and other questions related to integral quadratic forms. The study of rings of quadratic integers is basic for many questions of algebraic number theory.

Medieval Indian mathematicians had already discovered a multiplication of quadratic integers of the same D, which allowed them to solve some cases of Pell's equation.[citation needed]

The characterization given in § Explicit representation of the quadratic integers was first given by Richard Dedekind in 1871.

In other words, every quadratic integer may be written a + ωb, where a and b are integers, and where ω is defined by:

where a and b are either both integers, or, only if D ≡ 1 (mod 4), both halves of odd integers. The norm of such a quadratic integer is

The norm of a quadratic integer is always an integer. If D < 0, the norm of a quadratic integer is the square of its absolute value as a complex number (this is false if D > 0). The norm is a completely multiplicative function, which means that the norm of a product of quadratic integers is always the product of their norms.

The square root of any integer is a quadratic integer, as every integer can be written n = m2D, where D is a square-free integer, and its square root is a root of x2m2D = 0.

The fundamental theorem of arithmetic is not true in many rings of quadratic integers. However, there is a unique factorization for ideals, which is expressed by the fact that every ring of algebraic integers is a Dedekind domain. Being the simplest examples of algebraic integers, quadratic integers are commonly the starting examples of most studies of algebraic number theory.

For real quadratic integer rings, the class number, which measures the failure of unique factorization, is given in ; for the imaginary case, they are given in .

The fundamental units for the 10 smallest positive square-free D are 1 + 2, 2 + 3, 1 + 5/2 (the golden ratio), 5 + 26, 8 + 37, 3 + 10, 10 + 311, 3 + 13/2, 15 + 414, 4 + 15. For larger D, the coefficients of the fundamental unit may be very large. For example, for D = 19, 31, 43, the fundamental units are respectively 170 + 39 19, 1520 + 273 31 and 3482 + 531 43.

For D < 0, ω is a complex (imaginary or otherwise non-real) number. Therefore, it is natural to treat a quadratic integer ring as a set of algebraic complex numbers.

Both rings mentioned above are rings of integers of cyclotomic fields Q4) and Q3) correspondingly. In contrast, Z[−3] is not even a Dedekind domain.

Both above examples are principal ideal rings and also Euclidean domains for the norm. This is not the case for

which is not even a unique factorization domain. This can be shown as follows.

For D > 0, ω is a positive irrational real number, and the corresponding quadratic integer ring is a set of algebraic real numbers. The solutions of the Pell's equation X2DY2 = 1, a Diophantine equation that has been widely studied, are the units of these rings, for D ≡ 2, 3 (mod 4).

Unique factorization property is not always verified for rings of quadratic integers, as seen above for the case of Z[−5]. However, as for every Dedekind domain, a ring of quadratic integers is a unique factorization domain if and only if it is a principal ideal domain. This occurs if and only if the class number of the corresponding quadratic field is one.

This result was first conjectured by Gauss and proven by Kurt Heegner, although Heegner's proof was not believed until Harold Stark gave a later proof in 1967. (See Stark–Heegner theorem.) This is a special case of the famous class number problem.

There are many known positive integers D > 0, for which the ring of quadratic integers is a principal ideal ring. However, the complete list is not known; it is not even known if the number of these principal ideal rings is finite or not.

When a ring of quadratic integers is a principal ideal domain, it is interesting to know whether it is a Euclidean domain. This problem has been completely solved as follows.

There is no other ring of quadratic integers that is Euclidean with the norm as a Euclidean function.

For negative D, a ring of quadratic integers is Euclidean if and only if the norm is a Euclidean function for it. It follows that, for

the four corresponding rings of quadratic integers are among the rare known examples of principal ideal domains that are not Euclidean domains.

On the other hand, the generalized Riemann hypothesis implies that a ring of real quadratic integers that is a principal ideal domain is also a Euclidean domain for some Euclidean function, which can indeed differ from the usual norm. The values D = 14, 69 were the first for which the ring of quadratic integers was proven to be Euclidean, but not norm-Euclidean.