# Number Field Database

An optional database of number fields may be downloaded from the Magma website. This section defines the interface to that database.

There are databases for number fields of degrees 2 through 9. In the case of degree 2 the enumeration is complete in the discriminant range (discriminants of absolute value less than a million); the other databases include fields with small (absolute value of) discriminant, as well as various other fields that may be of interest. The selection of fields is eclectic, and it may well be that certain “obvious” ones are missing.

For each number field in the database, the following information is stored and may be used to limit the number fields of interest via the [`sub< D | dmin, dmax : parameters>`](#constructor-anfdb-sub) constructor: The discriminant; the signature; the Galois group; the class number; and the class group.

## Creation

### `NumberFieldDatabase(d): RngIntElt -> DB`

Returns a database object for the number fields of degree $d$.

### `sub< D | dmin, dmax : parameters>: DB, RngIntElt, RngIntElt -> DB`

### `sub< D | dabs : parameters>: DB, RngIntElt -> DB`

### `sub< D | : parameters>: DB -> DB`

```magma
Signature            : [ RngIntElt ]                           Default: 
Signatures           : [ [RngIntElt] ]                         Default: 
GaloisGroup          : RngIntElt or GrpPerm                    Default: 
ClassNumber          : RngIntElt                               Default: 
ClassNumberLowerBound: RngIntElt                               Default: 1
ClassNumberUpperBound: RngIntElt                               Default: Infinity()
ClassNumberBounds    : [ RngIntElt ]                           Default: [ 1, Infinity() ]
ClassGroup           : [ RngIntElt ]                           Default: 
ClassSubGroup        : [ RngIntElt ]                           Default: [ ]
ClassSuperGroup      : [ RngIntElt ]                           Default: 
SearchByValue        : BoolElt                                 Default: false
```

Returns a sub-database of $D$, restricting (or further restricting, if $D$ is already a sub-database of the full database for that degree) the contents to those number fields satisfying the specified conditions. Note that (with the exception of `SearchByValue`, which does not actually limit the fields in the database) it is not possible to “undo” restrictions with this constructor — the results are always at least as limited as $D$ is.

The valid non-parameter arguments are up to two integers specifying the desired range of discriminants in the result. If two integers are provided these are taken as the lower (`dmin`) and upper (`dmax`) bounds on the discriminant. If one integer is provided it is taken as a bound (`dabs`) on the absolute value of the discriminant. If no integers are provided then the discriminant range is the same as for $D$.

The parameters `Signature` or `Signatures` may be used to specify the desired signature or signatures to match. A signature is specified as a sequence of two integers $[s_1, s_2]$ where $s_1 + 2s_2 = d$.

The parameter `GaloisGroup` may be used to specify the desired Galois group of the number field. It may be given as either a permutation group, or as the explicit index of this Galois group in the transitive groups database. (i.e., the first return value of `TransitiveGroupIdentification`.)

It is possible to require certain divisibility conditions on the class number. Internally, there are lower and upper bounds on this value, such that a number field will only match if its class number is divisible by the lower bound and divides the upper bound. These bounds may be set individually using `ClassNumberLowerBound` or `ClassNumberUpperBound`; setting `ClassNumber` is equivalent to setting both bounds to the same value. Both values may be specified at once by setting `ClassNumberBounds` to the sequence of the lower and upper bounds.

When finer control is desired, it is possible to specify desired sub- and super-groups of the class group. Each group is specified by the sequence of its Abelian invariants; the desired subgroup is set using `ClassSubGroup`, and the desired supergroup is set using `ClassSuperGroup`. Both may be set at once (thus requiring the group to match exactly) using `ClassGroup`.

When iterating through the database, the default is to iterate in order of the absolute value of the discriminant. Sometimes it is desirable to iterate in order of the actual value of the discriminant; this can be accomplished by setting the parameter `SearchByValue` to true.

## Access

### `Degree(D): DB -> RngIntElt`

Returns the degree of the number fields stored in the database.

### `DiscriminantRange(D): DB -> RngIntElt, RngIntElt`

Returns the smallest and largest discriminants of the number fields stored in the database.

### `# D: DB -> RngIntElt`

### `NumberOfFields(D): DB -> RngIntElt`

Returns how many number fields are stored in the database.

### `NumberOfFields(D, d): DB, RngIntElt -> RngIntElt`

Returns how many number fields of discriminant $d$ are stored in the database.

### `NumberFields(D): DB -> [ FldNum ]`

Returns the sequence of number fields stored in the database.

### `NumberFields(D, d): DB, RngIntElt -> [ FldNum ]`

Returns the sequence of number fields of discriminant $d$ stored in the database.

### `Example: Anfdb Basic1 (ex-461fd7)`

We illustrate with some basic examples. We start with the degree 2 number fields and get some basic information about the database.

```magma
> D := NumberFieldDatabase(2);
> DiscriminantRange(D);
-999995 999997
> #D;
607925

```

There are 13 fields with discriminant of absolute value less than 20:

```magma
> D20 := sub<D | 20>;
> #D20;
13
> [ Discriminant(F) : F in D20 ];
[ -3, -4, 5, -7, -8, 8, -11, 12, 13, -15, 17, -19, -20 ]

```

Note that these were listed in order of absolute value of the discriminant; we can also list them in value order:

```magma
> [ Discriminant(F) : F in sub<D20 | : SearchByValue> ];
[ -20, -19, -15, -11, -8, -7, -4, -3, 5, 8, 12, 13, 17 ]

```

Two of these number fields have class number 2:

```magma
> NumberFields(sub<D20 | : ClassNumber := 2>);
[
    Number Field with defining polynomial x^2 + x + 4 over the Rational Field,
    Number Field with defining polynomial x^2 + 5 over the Rational Field
]

```

### `Example: Anfdb Basic2 (ex-07449b)`

Now we move onto the fields of degree five, and in particular those with signature [1,2].

```magma
> D := NumberFieldDatabase(5);
> #D;
289040
> D12 := sub<D |: Signature := [1,2]>;
> #D12;
186906

```

We consider how many of these have class number equal to four. Note the cumulative nature of the restrictions has come into play.

```magma
> #sub<D12 |: ClassNumber := 4>;
1222
> #sub<D |: ClassNumber := 4>;
1255

```

The number with class group specifically isomorphic to $C_2\times C_2$ is much less:

```magma
> #sub<D12 |: ClassGroup := [2,2]>;
99

```
