# Divisors

Divisors are represented in at least one of 4 ways. They can be represented

- as a linear combination of places (as given by [`Support`](#function-divfunelt-support)),

- by an ideal of a finite maximal order and an ideal of a corresponding infinite maximal order (as given by [`Ideals`](#function-divfunelt-ideals))

- in a reduced representation (as given by [`Reduction`](#function-divfunelt-reduction)) or

- as a complementary divisor to another divisor (as given by [`ComplementaryDivisor`](#function-divfunelt-complementarydivisor)).

While the representation as a linear combination of places can be efficient for divisor arithmetic, the reduced representation is more efficient for computations like [`Dimension`](#function-divfunelt-dimension). Computing the [`Support`](#function-divfunelt-support) of a divisor will ensure it has a representation as a linear combination stored. When divisors are combined in binary operations extra representations may need to be computed.

## Creation of Structures

### `DivisorGroup(F): FldFun -> DivFun`

Create the group of divisors of the algebraic function field $F/k$.

## Creation of Elements

### `Divisor(P): PlcFunElt -> DivFunElt`

### `Div ! P: DivFun, PlcFunElt -> DivFunElt`

### `1 * P: PlcFunElt -> DivFunElt`

Given a place $P$ in a function field, return the prime divisor $1*P$.

### `Div ! a: DivFun, RngElt -> DivFunElt`

### `Divisor(a): FldFunElt -> DivFunElt`

### `Divisor(a): RngFunOrdElt -> DivFunElt`

Given an algebraic function $a$, return the principal divisor $(a)$.

### `Div ! I: DivFun, RngFunOrdIdl -> DivFunElt`

### `Divisor(I): RngFunOrdIdl -> DivFunElt`

The divisor corresponding to the factorization of the ideal $I$.

### `Divisor(I, J): RngFunOrdIdl, RngFunOrdIdl -> DivFunElt`

The divisor corresponding to the ideal factorization of the ideals $I$ and $J$ belonging to the ‘finite’ and ‘infinite’ maximal order.

### `Identity(G): DivFun -> DivFunElt`

### `Id(G): DivFun -> DivFunElt`

Given the group $G$ of divisors of a function field, return the zero divisor.

### `CanonicalDivisor(F): FldFunG -> DivFunElt`

A canonical divisor of the function field $F/k$.

### `DifferentDivisor(F): FldFunG -> DivFunElt`

The different divisor of the underlying extension of the function field $F/k(x)$.

### `AssignNames(~D, s): DivFunElt, [ MonStgElt ]`

Change the print name employed when displaying $D$ to be the contents of $s$ which must have length $1$ in this case.

## Related Structures

### Parent and Category

The group of divisors form the Magma category `DivFun`. The notional power structure exists as parent but allows no operations.

#### `FunctionField(G): DivFun -> FldFun`

Given the group $G$ of divisors of a function field $F/k$, return $F$.

#### `Places(F): FldFun -> PlcFun`

The set of places of the algebraic function field $F/k$.

## Structure Invariants

### `NumberOfSmoothDivisors(n, m, P): RngIntElt, RngIntElt, SeqEnum[RngElt] -> RngElt`

The number of effective divisors of degree less equal $n$ who consist of places of degree less equal $m$ only. The sequence element $P[i]$ contains the (generic) number of places of degree $1 \leq i \leq \min \{ n, m \}$. The formula used is described in [[Heß, 1999](../../references.md#cite-he2)].

### `DivisorOfDegreeOne(F): FldFunG -> DivFunElt`

A divisor of degree one over the exact constant field of the global function field $F/k$.

## Structure Predicates

### `Div1 eq Div2: DivFun, DivFun -> BoolElt`

### `Div1 ne Div2: DivFun, DivFun -> BoolElt`

## Element Operations

### Arithmetic Operators

#### `- D: DivFunElt -> DivFunElt`

#### `D1 + D2: DivFunElt, DivFunElt -> DivFunElt`

#### `D1 - D2: DivFunElt, DivFunElt -> DivFunElt`

#### `k * D: RngIntElt, DivFunElt -> DivFunElt`

#### `D div k: DivFunElt, RngIntElt -> DivFunElt`

#### `D mod k: DivFunElt, RngIntElt -> DivFunElt`

#### `P + D: PlcFunElt, DivFunElt -> DivFunElt`

#### `D + P: DivFunElt, PlcFunElt -> DivFunElt`

#### `D - P: DivFunElt, PlcFunElt -> DivFunElt`

#### `P - D: PlcFunElt, DivFunElt -> DivFunElt`

#### `Quotrem(D, k): DivFunElt, RngIntElt -> DivFunElt, DivFunElt`

Returns divisors $D_1, D_2$ such that the divisor $D = kD_1 + D_2$ and the exponents in $D_2$ are of absolute value less than $|k|$. The operations `div` and `mod` yield $D_1$ resp. $D_2$.

#### `GCD(D1, D2): DivFunElt, DivFunElt -> DivFunElt`

#### `Gcd(D1, D2): DivFunElt, DivFunElt -> DivFunElt`

#### `GreatestCommonDivisor(D1, D2): DivFunElt, DivFunElt -> DivFunElt`

The greatest common divisor of the divisors $D1$ and $D2$.

#### `LCM(D1, D2): DivFunElt, DivFunElt -> DivFunElt`

#### `Lcm(D1, D2): DivFunElt, DivFunElt -> DivFunElt`

#### `LeastCommonMultiple(D1, D2): DivFunElt, DivFunElt -> DivFunElt`

The least common multiple of the divisors $D1$ and $D2$.

### Equality, Comparison and Membership

#### `D1 eq D2: DivFunElt, DivFunElt -> BoolElt`

#### `D1 ne D2: DivFunElt, DivFunElt -> BoolElt`

#### `D1 le D2: DivFunElt, DivFunElt -> BoolElt`

#### `D1 lt D2: DivFunElt, DivFunElt -> BoolElt`

#### `D1 ge D2: DivFunElt, DivFunElt -> BoolElt`

#### `D1 gt D2: DivFunElt, DivFunElt -> BoolElt`

#### `D in Div: DivFunElt, DivFun -> BoolElt`

#### `D notin Div: DivFunElt, DivFun -> BoolElt`

### Predicates on Elements

#### `IsZero(D): DivFunElt -> BoolElt`

#### `IsEffective(D): DivFunElt -> BoolElt`

#### `IsPositive(D): DivFunElt -> BoolElt`

#### `IsSpecial(D): DivFunElt -> BoolElt`

#### `IsPrincipal(D): DivFunElt -> BoolElt, FldFunElt`

#### `IsCanonical(D): DivFunElt -> BoolElt, DiffFunElt`

Returns `true` iff the divisor $D$ is canonical and a differential having $D$ as its divisor.

#### `Example: Divisors Simple Rel (ex-749efd)`

We show some simple creations and operations on divisors.

```magma
> PF<x> := PolynomialRing(GF(13, 2));
> P<y> := PolynomialRing(PF);
> FF1<b> := ext<FieldOfFractions(PF) | y^2 - x>;
> P<y> := PolynomialRing(FF1);
> FF2<d> := ext<FF1 | y^3 - b>;
> CanonicalDivisor(FF2);
Complementary divisor of Divisor in ideal representation:
Ideal of Maximal Equation Order of FF2 over Maximal Equation Order of FF1 over
Univariate Polynomial Ring in x over GF(13^2)
Generator:
1, Fractional ideal of Maximal Order of FF2 over Maximal Equation Order of FF1
over Valuation ring of Univariate rational function field over GF(13^2) with
generator 1/x
Generator:
x^2
> IsCanonical($1);
true
> D := Divisor(b) + Divisor(d);
> E := Divisor(Random(FF2, 2)*MaximalOrderFinite(FF2),
> Random(FF2, 2)*MaximalOrderInfinite(FF2));
> d := D + E;
> d;
Divisor in reduced representation:
Dtilde :
Divisor in ideal representation:
Fractional ideal of Maximal Equation Order of FF2 over Maximal Equation Order of
FF1 over Univariate Polynomial Ring in x over GF(13^2)
Basis:
Pseudo-matrix over Maximal Equation Order of FF1 over Univariate Polynomial Ring
in x over GF(13^2)
Ideal of Maximal Equation Order of FF1 over Univariate Polynomial Ring in x over
GF(13^2)
Generator:
1 * ( 1 0 0 )
Ideal of Maximal Equation Order of FF1 over Univariate Polynomial Ring in x over
GF(13^2)
Generator:
1 * ( 0 1 0 )
Fractional ideal of Maximal Equation Order of FF1 over Univariate Polynomial
Ring in x over GF(13^2)
Generators:
1
($.1^137*x^12 + $.1^80*x^11 + $.1^22*x^10 + $.1^79*x^9 + $.1^88*x^8 +
   $.1^138*x^7 + $.1^130*x^6 + $.1^127*x^5 + $.1^163*x^4 + $.1^78*x^3 + 6*x^2 +
   $.1^41*x + $.1^146)/(x^12 + $.1^166*x^11 + $.1^50*x^10 + $.1^136*x^9 +
   $.1^32*x^8 + $.1^46*x^7 + $.1^134*x^6 + $.1^64*x^5 + 8*x^4 + $.1^93*x^3 +
   $.1^153*x^2 + $.1^162*x)*b + ($.1^24*x + $.1^153)/(x^11 + $.1^166*x^10 +
   $.1^50*x^9 + $.1^136*x^8 + $.1^32*x^7 + $.1^46*x^6 + $.1^134*x^5 +
   $.1^64*x^4 + 8*x^3 + $.1^93*x^2 + $.1^153*x + $.1^162) * ( $.1^161*x^11 +
   $.1^74*x^10 + $.1^145*x^9 + $.1^72*x^8 + $.1^122*x^7 + $.1^123*x^6 + 3*x^5 +
   $.1^133*x^4 + 2*x^3 + $.1^105*x^2 + $.1^102*x $.1^48*x^11 + $.1^82*x^10 +
   4*x^9 + $.1^102*x^8 + $.1^145*x^7 + $.1^118*x^6 + $.1^129*x^5 + $.1^102*x^4
   + $.1^138*x^3 + $.1^146*x^2 + $.1^134*x 1 ) , Ideal of Maximal Order of FF2
over Maximal Equation Order of FF1 over Valuation ring of Univariate rational
function field over GF(13^2) with generator 1/x
Basis:
Pseudo-matrix over Maximal Equation Order of FF1 over Valuation ring of
Univariate rational function field over GF(13^2) with generator 1/x
Ideal of Maximal Equation Order of FF1 over Valuation ring of Univariate
rational function field over GF(13^2) with generator 1/x
Generator:
1/x^2 * ( 1 0 0 )
Ideal of Maximal Equation Order of FF1 over Valuation ring of Univariate
rational function field over GF(13^2) with generator 1/x
Generators:
1/x^3
($.1^21*x^3 + $.1^86*x^2 + $.1^151*x + $.1^48)/x^6*b + $.1^79/x^3 * ( 0 1 0 )
Ideal of Maximal Equation Order of FF1 over Valuation ring of Univariate
rational function field over GF(13^2) with generator 1/x
Generator:
1/x^3*b * ( 0 0 1 ) ,
r : 0,
A :
Divisor in ideal representation:
Ideal of Maximal Equation Order of FF2 over Maximal Equation Order of FF1 over
Univariate Polynomial Ring in x over GF(13^2)
Generator:
1, Fractional ideal of Maximal Order of FF2 over Maximal Equation Order of FF1
over Valuation ring of Univariate rational function field over GF(13^2) with
generator 1/x
Generators:
x
x,
a :
(x)^-1 * (b)

```

A nicer (but potentially more expensive) way to print, would be to ensure the divisor had a representation as a linear combination of places and exponents.

```magma
> p, e := Support(d);
> d;
4*(x, (($.1^24*x + 9)*b + ($.1^133*x + $.1^117))*d^2 + (($.1^83*x + $.1^36)*b +
    ($.1^97*x + $.1^2))*d + ($.1^101*x + $.1^165)*b + $.1^108*x) + (x + $.1^102,
    (($.1^141*x + $.1^113)*b + ($.1^157*x + $.1^48))*d^2 + (($.1^94*x + $.1^92)*b
    + ($.1^167*x + $.1^79))*d + ($.1^36*x + $.1^85)*b + $.1^18*x + 6) + (x^2 +
    $.1^47*x + 8, (($.1^19*x^3 + $.1^155*x^2 + $.1^75*x + $.1^106)*b + (8*x^3 +
    $.1^131*x^2 + $.1^125*x + $.1^46))*d^2 + (($.1^86*x^3 + $.1^11*x^2 +
    $.1^141)*b + ($.1^94*x^3 + $.1^127*x^2 + 6*x + $.1^57))*d + ($.1^68*x^3 +
    $.1^82*x^2 + $.1^52*x + $.1^69)*b + $.1^95*x^3 + $.1^55*x^2 + $.1^30*x +
    $.1) + (x^8 + $.1^138*x^7 + $.1^91*x^6 + $.1^59*x^5 + $.1^25*x^4 +
    $.1^74*x^3 + 6*x^2 + $.1^153*x + 5, (($.1^86*x^10 + 12*x^9 + $.1^5*x^8 +
    $.1^7*x^7 + $.1^123*x^6 + $.1^8*x^5 + $.1^77*x^4 + $.1^43*x^3 + $.1^110*x^2
    + $.1^124*x + $.1^51)*b + ($.1^78*x^9 + $.1^105*x^8 + $.1^153*x^7 + 6*x^6 +
    $.1^142*x^5 + $.1^152*x^4 + $.1^54*x^3 + $.1^9*x^2 + $.1^43*x + $.1^37))*d^2
    + (($.1^63*x^10 + $.1^125*x^9 + $.1^156*x^8 + $.1^44*x^7 + $.1^27*x^6 +
    $.1^127*x^5 + $.1^160*x^4 + $.1^46*x^3 + 9*x^2 + 8*x + $.1^37)*b +
    ($.1^99*x^10 + $.1^119*x^9 + $.1^103*x^8 + $.1^25*x^7 + $.1*x^6 +
    $.1^114*x^5 + $.1^133*x^4 + $.1^34*x^3 + $.1^4*x^2 + $.1^40*x + $.1^71))*d +
    ($.1^86*x^10 + $.1^7*x^9 + $.1^142*x^8 + 4*x^7 + $.1^161*x^6 + 2*x^5 +
    $.1^17*x^4 + $.1^50*x^3 + $.1^100*x^2 + $.1^144*x + $.1^12)*b + $.1^31*x^10
    + $.1^40*x^9 + 8*x^8 + 9*x^7 + $.1^39*x^6 + $.1^120*x^5 + $.1^114*x^4 +
    $.1^116*x^3 + $.1^43*x^2 + $.1^103*x + $.1^93) - 15*(1/x, (($.1^114*x^2 +
    $.1^96*x + 12)/x^3*b + ($.1^153*x^2 + 4*x + 12)/x^3)*d^2 + (($.1^17*x^2 +
    $.1^124*x + 12)/x^3*b + ($.1^159*x^2 + $.1^124*x + 12)/x^3)*d + ($.1^159*x^2
    + 6*x + 12)/x^3*b + ($.1^21*x + 12)/x^2)
> g := GCD(D, E);
> l := LCM(D, E);
> g + l eq d;
true
> g le D;
true
> l ge E;
true

```

### Other Element Operations

#### `FunctionField(D): DivFunElt -> FldFun`

Given a divisor $D$, return the function field.

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

The degree of the divisor $D$ over $k$, the constant field of definition.

#### `Support(D): DivFunElt -> [ PlcFunElt ]`

A sequence containing the places occurring in the divisor $D$.

#### `Numerator(D): DivFunElt -> DivFunElt`

#### `ZeroDivisor(D): DivFunElt -> DivFunElt`

The numerator of the divisor $D$.

#### `Denominator(D): DivFunElt -> DivFunElt`

#### `PoleDivisor(D): DivFunElt -> DivFunElt`

The denominator of the divisor $D$.

#### `Ideals(D): DivFunElt -> RngFunOrdIdl, RngFunOrdIdl`

Create two ideals of the ‘finite’ and ‘infinite’ maximal order respectively corresponding to the divisor $D$.

#### `Norm(D): DivFunElt -> DivFunElt`

The divisor of the norms of the ideals of the divisor $D$.

#### `FiniteSplit(D): DivFunElt -> DivFunElt, DivFunElt`

#### `FiniteDivisor(D): DivFunElt -> DivFunElt`

#### `InfiniteDivisor(D): DivFunElt -> DivFunElt`

Split the divisor $D$ into its finite and infinite part, returning either $2$ divisors which are the sum of the finite places in $D$ and the sum of the infinite places in $D$ or the appropriate one of these.

#### `Dimension(D): DivFunElt -> RngIntElt`

The dimension of the Riemann-Roch space ${\cal L}(D)$ of the divisor $D$ over $k$, the constant field of definition.

#### `IndexOfSpeciality(D): DivFunElt -> RngIntElt`

The index of speciality of the divisor $D$, which equals the dimension of ${\cal L}(W-D)$ where $W$ is a canonical divisor.

#### `ShortBasis(D : parameters): DivFunElt -> [RngElt], [RngIntElt]`

```magma
Reduction     : BoolElt                      Default: true
Simplification: MonStgElt                    Default: "Full"
```

Compute a basis for the Riemann-Roch space of $D$ in short form:

Let $F = k(x,y)$ be an algebraic function field defined by $f(x,y)=0$ over $k$. Given a divisor $D$ of $F/k$ this function returns a basis of the $k$-vector space

$$
{\cal
   L}(D) = \{ a \in F^\times \;|\; (a) \geq -D \} \cup \{ 0 \}
$$

in the short form $B = [ \, b_1 \dots, b_n \, ], \; [ \, d_1, \dots, d_n \, ]$ with $b_i \in F^\times$ and $d_i \in \Z$ for all $1 \leq i \leq n$, where $n$ denotes the degree in $y$ of the defining equation $f$ of $F$, such that

$$
{\cal L}(D) = \left\{ \sum_{i=1}^n
   \lambda_i b_i \;|\; \lambda_i \in k[x] \ {\rm with\  deg\ }
   \lambda_i \leq d_i \ {\rm for\ } 1 \leq i \leq n \right\}.
$$

The optional argument `Reduction` controls whether to use divisor reduction internally or not; it defaults to `true`. For small divisors this is sometimes faster.

The optional argument `Simplification` controls whether the resulting basis is simplified or not; it defaults to `"Full"`. Simplification sometimes is not insignificantly expensive and can be avoided by setting the parameter to `"None"`.

The algorithm is described in [[Heß, 1999](../../references.md#cite-he2)].

#### `Basis(D : parameters): DivFunElt -> [ FldFunElt ]`

```magma
Reduction     : BoolElt                      Default: true
Simplification: MonStgElt                    Default: "Full"
```

A sequence containing a basis of the Riemann-Roch space ${\cal L}(D)$, for the divisor $D$.

The optional argument `Reduction` controls whether to use divisor reduction internally or not; it defaults to `true`. For small divisors this is sometimes faster.

The optional argument `Simplification` controls whether the resulting basis is simplified or not; it defaults to `"Full"`. Simplification sometimes is not insignificantly expensive and can be avoided by setting the parameter to `"None"`.

#### `RiemannRochSpace(D): DivFunElt -> ModFld, Map`

#### `RiemannRochSpace(P): PlcFunElt -> ModFld, Map`

Given a function field $F/k$ and a divisor $D$ belonging to $F/k$, return a vector space $V$ and a $k$-linear mapping $h: V \longrightarrow F$ such that $V$ is isomorphic to the Riemann-Roch space ${\cal L}(D) \subset F$ under $h$.

#### `Valuation(D, P): DivFunElt, PlcFunElt -> RngIntElt`

The exponent of the place $P$ in the divisor $D$.

#### `Reduction(D): DivFunElt -> DivFunElt, RngIntElt, DivFunElt, FldFunElt`

#### `Reduction(D, A): DivFunElt, DivFunElt -> DivFunElt, RngIntElt, DivFunElt, FldFunElt`

Let $D$ be a divisor. Denote the result of both functions by $\tilde{D}$, $r$, $A$ and $a$ (for the second function the input $A$ always equals the output $A$). The divisor $A$ has (must have) positive degree and the following holds:

**(i)**
$D = \tilde{D} + rA - (a)$,

**(ii)**
$\tilde{D} \ge 0$ and $\deg(\tilde{D}) < g + \deg(A)$ (over the exact constant field),

**(iii)**
$\tilde{D}$ has minimal degree among all such divisors satisfying (i), (ii).

#### `GapNumbers(D, P): DivFunElt, PlcFunElt -> SeqEnum[RngIntElt]`

The sequence of gap numbers of the divisor $D$ at $P$ where $P$ must be a place of degree one:

Let $F/k$ be an algebraic function field, $D$ a divisor and $P$ a place of degree one. An integer $m \geq 1$ is a gap number of $D$ at $P$ if $\dim \bigl( D + (m-1)P \bigr) = \dim(D + mP)$ holds. The gap numbers $m$ of $D$ satisfy $1 \leq m \leq 2g-1-\deg(D)$ and their cardinality equals the index of speciality $i(D)$. `GapNumbers(D, P)` returns such a particular sequence. The sequences of gap numbers of $D$ at various $P$ are independent of constant field extensions for perfect $k$ and are the same for all but a finite number of places $P$ of degree one (consider e.g. $k$ algebraically closed). If $P$ is omitted in the function call, this uniform sequence is returned by `GapNumbers(D)`. The places $P$ where $D$ has different sequences of gap numbers are called Weierstraß places of $D$ and are returned by `WeierstrassPlaces(D)`. In the above mentioned functions it is equivalent to replace $D$ by either $F$ or the zero divisor.

#### `GapNumbers(D): DivFunElt -> SeqEnum[RngIntElt]`

```magma
SeparatingElement: FldFunGElt                    Default: 
```

The sequence of global gap numbers of the divisor $D$. A separating element used internally for the computation can be specified, it defaults to `SeparatingElement(F)`. See the description of [`GapNumbers`](#function-divfunelt-gapnumbers).

#### `Example: divisors (ex-bddf6b)`

Consider the function field $F$ defined by the curve of genus $7$ defined by

$$
y^4 + (2*x^5 + x^4 + 2*x^3 + x^2)*y^2 + x^8 + 2*x^6 + x^5 +x^4 + x^3 + x^2
$$

We construct the function field $F/{\bf F}_{9}$ and compute the Riemann-Roch space corresponding to a certain divisor.

```magma
> k<w> := GF(9);
> R<x> := FunctionField(k);
> P<y> := PolynomialRing(R);
> f := y^4 + (2*x^5 + x^4 + 2*x^3 + x^2)*y^2 + x^8
>      + 2*x^6 + x^5 +x^4 + x^3 + x^2;
> F<a> := FunctionField(f);
> Genus(F);
7
> P1 := RandomPlace(F, 1);
> P2 := RandomPlace(F, 1);
> D := P1 - P2;
> D;
(1/x, w^7/x^7*a^3 + w^5/x^5*a^2 + w^3/x^2*a + w) - (x, 2/(x^4 + x^2 + 2*x)*a^3 +
    w^3/x*a^2 + (w^5*x^3 + w^3*x + w^7)/(x^3 + x + 2)*a + w^5)
> IsPrincipal(336*D);
true
> infty := Poles(F!x)[1];
> V, h := RiemannRochSpace(11*infty);
> V;
KModule V of dimension 5 over GF(3^2)
> h;
Mapping from: ModFld: V to FldFun: F
> B := h(Basis(V));
> B;
[
    x/(x^3 + x + 2)*a^3 + (2*x^4 + 2*x^3 + x)/(x^3 + x + 2)*a,
    1/(x^3 + x + 2)*a^3 + (2*x^3 + 2*x^2 + 1)/(x^3 + x + 2)*a,
    a^2 + 2*x^3 + 2*x^2,
    1/x*a^2 + 2*x^2 + 2*x,
    1
]
> (B[2] + 2*B[3])@@h;
(    0     1     2     0     0)

```

#### `Example: Alg Reln1 (ex-3b8680)`

As a trivial but illustrative example we consider the algebraic function field generated by $\sin(x)$ and $\cos(x)$ over $Q$ and construct a single function $a(x)$ such that $\sin(x)$ and $\cos(x)$ can be expressed in terms of $a(x)$:

```magma
> Qc<c> := PolynomialRing(RationalField());
> Qcs<s> := PolynomialRing(Qc);
> F<s> := FunctionField(s^2 + c^2 - 1);
> c := F!c;
> Genus(F);
0
> Zeros(s);
[ (c - 1, s), (c + 1, s) ]
> Zeros(c-1);
[ (c - 1, s) ]
> P := Zeros(c-1)[1];
> Degree(P);
1
> Dimension(1*P);
2
> Basis(1*P);
[ 1/(c - 1)*s, 1 ]
> a := Basis(1*P)[1];
> Degree(a);
1
> MinimalPolynomial(a);
$.1^2 + (c + 1)/(c - 1)
> (a^2 - 1)/(a^2 + 1);
c
> a * ((a^2 - 1)/(a^2 + 1) - 1);
s

```

#### `Example: Alg Reln2 (ex-f4fe11)`

Over $Q(i)$ the familiar identities

$$
\cos(x) = (\exp(ix) + \exp(-ix))/2
$$

$$
\sin(x) = (\exp(ix) - \exp(-ix))/(2i).
$$

hold. In Magma one can proceed as follows:

```magma
> Qx<x> := PolynomialRing(RationalField());
> k<i> := NumberField(x^2 + 1);
> kc<c> := PolynomialRing(k);
> kcs<s> := PolynomialRing(kc);
> F<s> := FunctionField(s^2 + c^2 - 1);
> c := F!c;
> Genus(F);
0
> e := c + i*s;
> ebar := c - i*s;
> Degree(e);
1
> c eq (e + ebar) / 2;
true
> s eq (e - ebar) / (2*i);
true

```

#### `RamificationDivisor(D): DivFunElt -> DivFunElt`

```magma
SeparatingElement: FldFunGElt                    Default: 
```

The ramification divisor of the divisor $D$ (using `SeparatingElement` for the computation which defaults to `SeparatingElement(F)` for $F/k$ the function field of $D$):

Let $F/k$ be an algebraic function field, $x$ a separating variable and $D$ a divisor. The ramification divisor of $D$ is defined to be $i(D) \, ( W - D ) + \bigl( W_x(D) \bigr) + \nu \, (dx),$ where $W$ is a canonical divisor of $F/k$, $W_x(D)$ is the determinant of the Wronskian matrix of $D$ with respect to $x$ and $\nu$ is the sum of the Wronskian orders of $D$ with respect to $x$. It is effective and consists of the Weierstraß places of $D$. The constant field $k$ is required to be exact.

#### `WeierstrassPlaces(D): DivFunElt -> [PlcFunElt]`

```magma
SeparatingElement: FldFunGElt                    Default: 
```

The Weierstrass places of the divisor $D$ (using `SeparatingElement` for the computation which defaults to `SeparatingElement(F)` for $F/k$ the function field of $D$):

Let $F/k$ be an algebraic function field, $D$ a divisor and $P$ a place of degree one. An integer $m \geq 1$ is a gap number of $D$ at $P$ if $\dim \bigl( D + (m-1)P \bigr) = \dim(D + mP)$ holds. The gap numbers $m$ of $D$ at $P$ satisfy $1 \leq m \leq 2g-1-\deg(D)$ and their cardinality equals the index of speciality $i(D)$. The sequences of gap numbers of $D$ are independent of constant field extensions for perfect $k$ and are the same for all but a finite number of places $P$ of degree one (consider e.g. $k$ algebraically closed). The places $P$ of degree one at which $D$ has different sequences of gap numbers are called Weierstraß places of $D$.

This function returns a list of all places of $F/k$ (having not necessarily degree one) which are lying below Weierstraß places of $D$ viewed in $F \bar{k} / \bar{k}$ ($k$ perfect). The constant field $k$ is required to be exact. Note that if the characteristic of $F$ is positive this function is currently quite slow for large genus because of `Differentiation()`.

#### `IsWeierstrassPlace(D, P): DivFunElt, PlcFunElt -> BoolElt`

Given a divisor $D$ and a degree $1$ place $P$ of a function field, return whether $P$ is a weierstrass place of $D$.

#### `WronskianOrders(D): DivFunElt -> [RngIntElt]`

```magma
SeparatingElement: FldFunGElt                    Default: 
```

Let $D$ be a divisor of an algebraic function field $F/k$ with separating element $x$ and let $v_1, \dots v_l$ be a basis of ${\cal L}(D)$. For the differentiation $D_x$ with respect to $x$ consider the successively smallest $\nu_1 \leq \dots \leq \nu_l \in \Z^{\geq 0}$ such that the rows $D_x^{(\nu_i)}(v_1), \dots, D_x^{(\nu_i)}(v_l)$, $1 \leq i \leq l$ are $F$-linearly independent. The numbers $\nu_1, \dots, \nu_l$ are the Wronskian orders of $D$ with respect to $x$ and are returned. If $D$ has dimension zero, the empty list is returned. The constant field $k$ is required to be exact.

The separating element can be given by setting the `SeparatingElement` parameter appropriately.

#### `ComplementaryDivisor(D): DivFunElt -> DivFunElt`

Return the complementary divisor $D^\#$ of the divisor $D$. The function field $F/k$ of $D$ must be a finite extension of a rational function field $k(x)$. The divisor $D^\#$ equals Diff$(F/k(x)) - D$ for $F$ the function field of $D$ and Diff$(F/k(x))$ the different divisor of $F/k(x)$.

#### `DifferentialBasis(D): DivFunElt -> [DiffFunElt]`

A basis of the space of differentials of the divisor $D$. See [`DifferentialBasis`](differentials.md#function-differentials-subspaces-differentialbasis) for details.

#### `DifferentialSpace(D): DivFunElt -> ModFld, Map`

A vector space and the isomorphism from this space to the differential space of the divisor $D$.

#### `Parametrization(F, D): FldFun, DivFunElt -> FldFunElt, [FldFunRatUElt]`

An element $x$ in $F$ which is a non constant element of the basis of the divisor $D$ having degree one and a sequence of elements $L$ in the rational function field are returned such that $x$ generates the function field $F$ over the constant field and $L$ contains the images of the generators of $F$ over its constant field in the rational function field.

## Functions related to Divisor Class Groups of Global Function Fields

Let $F/k$ be a global function field. The group of divisor classes is isomorphic to the product of a copy of $\Z$ and the group of divisors classes of degree zero which is a finite abelian group. Magma features an algorithm to compute the divisor class group by computing an abelian group $G$ in the form $\Z/c_1\Z\times \dots \times \Z/c_{2g}\Z\times \Z$ with integers $c_1 | \dots | c_{2g}$ and a surjective homomorphism $f: Div(F) \ar G$ from the divisor group to $G$ whose kernel consists precisely of the principal divisors.

The algorithm employed is a randomized index calculus style method of expected subexponential running time for “small” constant field size and “large” genus. A description of this and other algorithms of this section can be found in [[Heß, 1999](../../references.md#cite-he2)].

Elements in product representation may result from applying the maps returned by some of the computations below. It can be expensive to put these elements into sets and to test them for equality.

### `ClassGroupGenerationBound(q, g): RngIntElt, RngIntElt -> RngIntElt`

A bound $B$ such that the places of degree (over the exact constant field) less than or equal to $B$, taken together with the places of a divisor of degree one, generate the whole divisor class group of any global function field of genus $g$ over the exact constant field of $q$ elements.

### `ClassGroupGenerationBound(F): FldFunG -> RngIntElt`

A bound $B$ such that all places of degree (over the exact constant field) less than or equal to $B$, taken together with the places of a divisor of degree one, generate the whole divisor class group of the function field $F$. Particular properties of the function field are taken into account.

### `ClassNumberApproximation(F, e): FldFunG, FldReElt -> FldReElt`

An approximation of the class number of the global function field $F/k$ with multiplicative error less than $1+e$ for $e > 0$. The formula

$$
\biggl| \,\log \bigl( h \,/\, q^g \, \bigr) -
             \sum_{r=1}^{b} q^{-r}/r \bigl( N_r - (q^r + 1) \bigl)
              \biggr| \,\leq\,  2g q^{-b/2} / \bigl( (q^{1/2}-1)(b+1) \bigr)
$$

is used where $N_r$ denotes the number of places of degree one in the constant field extension of degree $r$ of $F/k$.

### `ClassNumberApproximationBound(q, g, e): RngIntElt, RngIntElt, FldReElt -> RngIntElt`

Returns an integer $B$ such that all places of degree less than or equal to $B$ of a global function field of genus g over the exact constant field of $q$ elements have to be considered in order to approximate the class number with multiplicative error less than $1+e$ for $e > 0$.

### `ClassGroup(F : parameters): FldFun -> GrpAb, Map, Map`

```magma
DegreeBound     : RngIntElt                    Default: 
SizeBound       : RngIntElt                    Default: 
ReductionDivisor: DivFunElt                    Default: 
Proof           : BoolElt                      Default: 
```

The divisor class group of the function field $F/k$ as an abelian group, a map of representatives from the class group to the divisor group and the homomorphism from the divisor group onto the divisor class group.

The optional parameter `DegreeBound` allows to control the size of the factor basis which consists of all places of degree less equal `DegreeBound` (plus a small additional amount; the degree is taken over the exact constant field). If not provided the algorithm tries to choose an appropriate value.

The optional parameter `SizeBound` bounds the size of the factor basis to not exceed `SizeBound` places. Every time the factor basis has to be enlarged during the computation it will be by no more than `SizeBound` additional places. If not provided there is no bound on the size of the factor basis. Every enlargement of the factor basis will append all places of the next degree.

The optional parameter `ReductionDivisor` contains the reduction divisor used in the relation search stage. Reasonable choices are divisors of small positive degree. If not provided the algorithm tries to choose an appropriate reduction divisor.

The optional parameter `Proof` indicates whether the computed result should be proven in a proof step. If a small degree bound for the factor basis is used and the divisor class group happens to be a product of a large number of cyclic groups the proof step can be very time consuming and `Proof := false` might be helpful. Once a value is given for `Proof` it remains the default value until set differently. The initial value of `Proof` for every function field is `true`.

### `ClassGroupAbelianInvariants(F : parameters): FldFun -> SeqEnum`

```magma
DegreeBound     : RngIntElt                    Default: 
SizeBound       : RngIntElt                    Default: 
ReductionDivisor: DivFunElt                    Default: 
Proof           : BoolElt                      Default: 
```

Computes a sequence of integers containing the Abelian invariants of the divisor class group of the function field $F/k$.

The optional parameters are the same as for `ClassGroup`.

### `ClassNumber(F): FldFun -> RngIntElt`

The order of the group of divisor classes of degree zero of the function field $F/k$.

### `Example: Divisors Class (ex-caa2d2)`

Some class group calculations :

```magma
> Y<t> := PolynomialRing(Integers());
> R<x> := FunctionField(GF(9));
> P<y> := PolynomialRing(R);
> f := y^3 + y + x^5 + x + 1;
> F<alpha> := FunctionField(f);
> ClassNumberApproximation(F, 1.3);
24890.25505701632912193514
> ClassGroup(F);
Abelian Group isomorphic to Z/13 + Z/13 + Z/13 + Z/13 + Z
Defined on 5 generators
Relations:
    13*$.1 = 0
    13*$.2 = 0
    13*$.3 = 0
    13*$.4 = 0
Mapping from: Abelian Group isomorphic to Z/13 + Z/13 + Z/13 + Z/13 + Z
Defined on 5 generators
Relations:
    13*$.1 = 0
    13*$.2 = 0
    13*$.3 = 0
    13*$.4 = 0 to Divisor group of F
Mapping from: Divisor group of F to Abelian Group isomorphic to Z/13 + Z/13 +
Z/13 + Z/13 + Z
Defined on 5 generators
Relations:
    13*$.1 = 0
    13*$.2 = 0
    13*$.3 = 0
    13*$.4 = 0 given by a rule
> ClassNumber(F);
28561
> Evaluate(LPolynomial(F), 1);
28561

```

### `GlobalUnitGroup(F): FldFun -> GrpAb, Map`

The group of global units of the function field $F/k$, i. e. the multiplicative group of the exact constant field, as an Abelian group, together with the map into $F$.

### `IsGlobalUnit(a): FldFunElt -> BoolElt`

Whether the function field element $a$ is a global unit, i.e. a constant (equivalent to `IsConstant`).

### `IsGlobalUnitWithPreimage(a): FldFunElt -> BoolElt, GrpAbElt`

Returns `true` and the preimage of the function field element $a$ in the global unit group, `false` otherwise.

### `PrincipalDivisorMap(F): FldFunG -> Map`

The map from the multiplicative group of the function field to the group of divisors.

### `ClassGroupExactSequence(F): FldFunG -> Map, Map, Map`

Returns the three maps in the center of the exact sequence $0 \ar k^\times \ar F^\times \ar Div \ar Cl \ar 0$ where $k^\times$ is the global unit group of the function field, $F^\times$ is the multiplicative group of the function field, $Div$ is the divisor group and $Cl$ is the divisor class group.

### `SUnitGroup(S): SetEnum[PlcFunElt] -> GrpAb, Map`

The group of $S$-units as an Abelian group and the map into the function field, where $S$ is a sequence of places of a function field.

### `IsSUnit(a, S): FldFunElt, SetEnum[PlcFunElt] -> BoolElt`

Returns `true` if the function field element $a$ is an $S$-unit for the sequence of places $S$, `false` otherwise.

### `IsSUnitWithPreimage(a, S): FldFunElt, SetEnum[PlcFunElt] -> BoolElt, GrpAbElt`

Returns `true` and the preimage of the function field element $a$ in the $S$-unit group if $a$ is an $S$-unit for the sequence of places $S$, `false` otherwise.

### `SRegulator(S): SetEnum[PlcFunElt] -> RngIntElt`

The $S$-Regulator for the sequence of places $S$.

### `SPrincipalDivisorMap(S): SetEnum[PlcFunElt] -> Map`

The map from the multiplicative group of the function field to the group of divisors (mod places in the sequence $S$).

### `IsSPrincipal(D, S): DivFunElt, SetEnum[PlcFunElt] -> BoolElt, FldFunElt`

Returns `true` and a generator if the divisor $D$ is principal modulo places in the sequence $S$, `false` otherwise

### `SClassGroup(S): SetEnum[PlcFunElt] -> GrpAb, Map, Map`

The $S$-class group for the sequence of places $S$ as an Abelian group, a map of representatives from the $S$-class group to the group of divisors (mod places in $S$) and the homomorphism from the group of divisors (mod places in $S$) onto the $S$-class group.

### `SClassGroupExactSequence(S): SetEnum[PlcFunElt] -> Map, Map, Map`

Returns the three maps in the center of the exact sequence $0 \ar U(S) \ar F^\times \ar Div(S) \ar Cl(S) \ar 0$ where $U(S)$ is the $S$-unit group, $F^\times$ is the multiplicative group of the function field, $Div(S)$ is the group of divisors (mod places in the sequence $S$) and $Cl(S)$ is the $S$-class group.

### `SClassGroupAbelianInvariants(S): SetEnum[PlcFunElt] -> SeqEnum`

Computes a sequence of integers containing the Abelian invariants of the $S$-class group for the sequence of places $S$.

### `SClassNumber(S): SetEnum[PlcFunElt] -> RngIntElt`

The order of the torsion part of the $S$-class group for the sequence of places $S$.

### `ClassGroupPRank(F): FldFunG -> RngIntElt`

Compute the $p$-rank of the class group of $F/k$ where $p$ is the characteristic of $F/k$. More precisely: Let $F/k$ be a function field of characteristic $p$. Consider the subgroup $Cl^0(F/k)[p]$ of $p$-torsion elements of the group of divisor classes of degree zero. This function returns its dimension as an ${\bf F}_{p}$-vector space. Possible values range from $0$ to $g$, where $g$ is the genus of $F/k$. The field $k$ is currently required to be a finite field.

### `HasseWittInvariant(F): FldFunG -> RngIntElt`

Return the Hasse–Witt invariant of $F/k$. More precisely: Let $F/k$ be a function field of characteristic $p$. Let $F \bar{k} / \bar{k}$ be the constant field extension by the algebraic closure $\bar{k}$ of $k$ within an algebraic closure $\bar{F}$ of $F/k$. Consider the subgroup $Cl^0(F \bar{k} / \bar{k})[p]$ of $p$-torsion elements of the group of divisor classes of degree zero. This function returns its dimension as an ${\bf F}_{p}$-vector space. Possible values range from $0$ to $g$, where $g$ is the genus of $F/k$. $k$ is required to be perfect.

### `TateLichtenbaumPairing(D1, D2, m): DivFunElt, DivFunElt, RngIntElt -> RngElt`

The Tate–Lichtenbaum pairing $Cl_0[m] \times Cl_0/mCl_0 \ar k$ for coprime divisors $D1$ and $D2$.

### `Example: tate (ex-7f9ab0)`

```magma
> k<w> := GF(9);
> R<x> := FunctionField(k);
> P<y> := PolynomialRing(R);
> f := y^4 + (2*x^5 + x^4 + 2*x^3 + x^2)*y^2 +
>             x^8 + 2*x^6 + x^5 + x^4 + x^3 + x^2;
> F<a> := FunctionField(f);
> D1 := Zeros(a)[1] - Poles(F!x)[1];
> D2 := Zeros(a)[4] - Poles(F!x)[2];
> G,mapfromG,maptoG:=ClassGroup(F : Proof:=false);
> Order(maptoG(D1));
48
> Order(maptoG(D2));
336
> TateLichtenbaumPairing(D1,D2,48);
w^7
> TateLichtenbaumPairing(D2,D1,336);
w^3

```
