---
title: "Introduction"
canonical: "https://docs.magma-maths.org/v2.30-1/GlobalFields/QuadraticFields/introduction.html"
source: "https://docs.magma-maths.org/v2.30-1/GlobalFields/QuadraticFields/introduction.md"
part: "Global Fields"
chapter: "Quadratic Fields"
breadcrumbs:
  - {"title": "Magma Handbook", "source": "https://docs.magma-maths.org/v2.30-1/index.md"}
  - {"title": "Global Fields", "source": "https://docs.magma-maths.org/v2.30-1/GlobalFields/index-global-fields.md"}
  - {"title": "Quadratic Fields", "source": "https://docs.magma-maths.org/v2.30-1/GlobalFields/QuadraticFields/index-quadratic-fields.md"}
prev: {"title": "Quadratic Fields", "source": "https://docs.magma-maths.org/v2.30-1/GlobalFields/QuadraticFields/index-quadratic-fields.md"}
next: {"title": "Creation of Structures", "source": "https://docs.magma-maths.org/v2.30-1/GlobalFields/QuadraticFields/creation.md"}
---

# Introduction

Quadratic fields in Magma can be created as a subtype of the number fields `FldNum`. The advantage of the special quadratic fields is that some special (faster) algorithms have been or will be implemented to deal with them; the functions for the special quadratic fields (created with the [`QuadraticField`](https://docs.magma-maths.org/v2.30-1/GlobalFields/QuadraticFields/creation.md#function-fldquad-quadraticfield) function) are described here. Functions which work generally for number fields and their orders are described in Chapter [Number Fields](https://docs.magma-maths.org/v2.30-1/GlobalFields/NumberFields/index-number-fields.md#fldnum-main).

The categories involved are `FldQuad` for fields, `RngQuad` for their orders and `FldQuadElt` and `RngQuadElt` for their elements.

## Representation

For every squarefree integer $d$ (not $0$ or $1$) there is a unique quadratic field ${\mathbb{Q}}(\sqrt{d})$; for any integer $k$ we have the field ${\mathbb{Q}}(\sqrt{k^2d})\cong {\mathbb{Q}}(\sqrt{d})$. Given any integer $m$, the function [`QuadraticField`](https://docs.magma-maths.org/v2.30-1/GlobalFields/QuadraticFields/creation.md#function-fldquad-quadraticfield) will create a structure corresponding to the quadratic field ${\mathbb{Q}}(\sqrt{d})$, where $d$ is the squarefree kernel of $m$ ($d$ will have the same sign as $m$ and its absolute value is the largest squarefree divisor of $m$). In Magma a list of quadratic fields currently present is maintained, and if ${\mathbb{Q}}(\sqrt{d})$ has been created before a reference on it will be returned: two fields with the same $d$ are the same. The discriminant $D$ of ${\mathbb{Q}}(\sqrt{d})$ will be $D=d$ if $d\equiv1\bmod4$ and $D=4d$ if $d\equiv2,3\bmod4$. Elements of ${\mathbb{Q}}(\sqrt{d})$ are represented by a common positive denominator $b$ and two integer coefficients: $\alpha={1\over b}(x+y\sqrt{d})$. The ring of integers of $F={\mathbb{Q}}(\sqrt{d})$ will be $O_F={\mathbb{Z}}+\epsilon_d{\mathbb{Z}}$, where

$$
\epsilon_d=\cases{
\sqrt{d}&if $d\equiv 2, 3\bmod 4$,\\
{1+\sqrt{d}\over2}&if $d\equiv 1\bmod 4$.\\}
$$

Elements of $O_F$ are represented by two integer coefficients $\alpha=x+y\epsilon_d$. The pair $1, \epsilon_d$ forms an integral basis for $F={\mathbb{Q}}(\sqrt{d})$, but note that elements of $F$ are represented using the basis of the equation order ($1, \sqrt{d}$) instead. For any positive integer $f$ there is a suborder of conductor $f$ in $O_F$, whose elements are of the form $x + y f \epsilon_d$, for any integers $x, y$. The discriminant of the order of conductor $f$ is $f^2D$, where $D$ is the field discriminant.

The equation order of $F$ is $E_F = {\mathbb{Z}}+ \sqrt{d}{\mathbb{Z}}$. Suborders of conductor $f$ can be formed which will contain elements of the form $x + y f \sqrt{d}$ for any integers $x$ and $y$.
