Safe Haskell | None |
---|

A module for arithmetic in quadratic number fields. A quadratic number field is a field of the form Q(sqrt d), where d is a square-free integer. For example, we can perform the following calculation in Q(sqrt 2):

(1 + sqrt 2) / (2 + sqrt 2)

It is also possible to mix different square roots in the same calculation. For example:

(1 + sqrt 2) * (1 + sqrt 3)

Square roots of negative numbers are also permitted. For example:

i * sqrt(-3)

# Documentation

A basis for quadratic number fields Q(sqrt d), where d is a square-free integer.

Although this has the same name as the Prelude.sqrt function, it should be thought of as more like a constructor for creating elements of quadratic fields.

Note that for d positive, sqrt d means the positive square root, and sqrt (-d) should be interpreted as the square root with positive imaginary part, that is i * sqrt d. This has the consequence that for example, sqrt (-2) * sqrt (-3) = - sqrt 6.