# Primary Invariants

Let $R=K[V]^G$ be the invariant ring of a finite group $G$ over the field $K$ and suppose the degree of $G$ is $n$. A set of *primary invariants* of $R$ is a set $\{ f_1, \ldots, f_n \}$ of $n$ algebraically independent homogeneous invariants of $R$ such that the invariant ring $R$ is a finitely generated module over $A = K[f_1, \ldots, f_n]$. A set of primary invariants always exists for any invariant ring $R$. The invocation `PrimaryInvariants(R)` allows automatic construction of primary invariants of $R$. The primary invariants are stored in $R$ and recalled as necessary in subsequent computations. The latest algorithm in Magma to compute primary invariants, due to G. Kemper [[Kemper, 1999](../../references.md#cite-kemper-primaries)], now guarantees that the degrees of the primary invariants found by the algorithm are optimal (with respect to their product and then their sum).

## `PrimaryInvariants(R): RngInvar -> [ RngMPolElt ]`

Construct optimal primary invariants for the invariant ring $R=K[V]^G$ as a sorted sequence (with increasing degrees) of $n$ polynomials of $R$ where $n$ is the degree of $G$.

## `Example: Adem Milgram (ex-93d2b8)`

We compute primary invariants for the “first $A_5$ in ${\operatorname{SL}}({\bf F}_{2})$”, discussed in [[Adem and Milgram, 1994](../../references.md#cite-ademmilgram), p. 116]. The resulting degrees $3, 5, 8$, and $12$ are necessarily optimal (see [[Kemper, 1996](../../references.md#cite-kemper-invar)]).

```magma
> K := GF(2);
> G := MatrixGroup<4, K |
>     [0,1,0,0, 1,1,0,0, 0,0,1,1, 0,0,1,0],
>     [1,0,0,0, 0,1,0,0, 1,0,1,0, 0,1,0,1],
>     [1,0,1,0, 0,1,0,1, 0,0,1,0, 0,0,0,1]>;
> R := InvariantRing(G);
> time p := PrimaryInvariants(R);
Time: 1.399
> [TotalDegree(f): f in p];
[ 3, 5, 8, 12 ]

```
