# Creation of Structures

Squarefree integers determine quadratic fields. Associated with any quadratic field is its ring of integers (maximal order) and an equation order, and for every positive integer $f$ there exists an order of conductor $f$ inside the maximal order. For information on creating elements see Section [Creation of Elements](../NumberFields/creation.md#fldnum-main-elt-create).

## `QuadraticField(m): RngIntElt -> FldQuad`

Given an integer $m$ that is not a square, create the field ${\mathbb{Q}}(\sqrt{d})$, where $d$ is the squarefree part of $m$. It is possible to assign a name to $\sqrt{d}$ using angle brackets: `R<s> := QuadraticField(m)`.

## `EquationOrder(F): FldQuad -> RngQuad`

Creation of the order ${\mathbb{Z}}[\sqrt{d}]$ in the quadratic field $F={\mathbb{Q}}(\sqrt{d})$, with $d$ squarefree.

## `MaximalOrder(F): FldQuad -> RngQuad`

## `IntegerRing(F): FldQuad -> RngQuad`

## `RingOfIntegers(F): FldQuad -> RngQuad`

Given a quadratic field $F={\mathbb{Q}}(\sqrt{d})$, with $d$ squarefree, create its maximal order. This order is ${\mathbb{Z}}[\sqrt{d}]$ if $d\equiv 2, 3\bmod 4$ and ${\mathbb{Z}}[{1+\sqrt{d}\over2}]$ if $d\equiv1\bmod4$.

## `NumberField(O): RngQuad -> FldQuad`

Given a quadratic order, this returns the quadratic field of which it is an order.

## `sub< O | f >: RngQuad, RngIntElt`

Create the sub-order of index $f$ in the order $O$ of a quadratic field. If $O$ is maximal, this will be the unique order of conductor $f$.

## `IsQuadratic(K): FldNum -> BoolElt, FldQuad`

## `IsQuadratic(O): RngOrd -> BoolElt, RngQuad`

Return `true` if the field $K$ or order $O$ can be created as a quadratic field or order and the quadratic field or order if so.

## `Example: creation (ex-a2440a)`

We create the quadratic field ${\mathbb{Q}}(\sqrt{5})$ and an order in it, and display some elements of the order in their representation as order element and as field element.

```magma
> Q<z> := QuadraticField(5);
> Q eq QuadraticField(45);
true
> O<w> := sub< MaximalOrder(Q) | 7 >;
> O;
Order of conductor 7 in Q
> w;
w
> Q ! w;
1/2*(7*z + 7)
> Eltseq(w), Eltseq(Q ! w);
[ 0, 1 ]
[ 7/2, 7/2 ]
> ( (7/2)+(7/2)*z )^2;
1/2*(49*z + 147)
>  Q ! w^2;
1/2*(49*z + 147)
> w^2;
7*w + 49

```

## `Example: hom (ex-6098de)`

We define an injection $\phi\colon{\mathbb{Q}}(\sqrt{5})\rightarrow{\mathbb{Q}}(\zeta_5)$. First a square root of $5$ is identified in ${\mathbb{Q}}(\zeta_5)$.

```magma
> Q<w> := QuadraticField(5);
> F<z> := CyclotomicField(5);
> C<c> := PolynomialRing(F);
> Factorization(c^2-5);
[
   <c - 2*z^3 - 2*z^2 - 1, 1>,
   <c + 2*z^3 + 2*z^2 + 1, 1>
]
> h := hom< Q -> F | -2*z^3 - 2*z^2 - 1 >;
> h(w)^2;
5

```
