# Best Known Quantum Codes

An $[[n, k]]$ quantum stabiliser code $Q$ is said to be a *best known* $[[n, k]]$ *quantum code* (BKQC) if $C$ has the highest minimum weight among all known $[[n, k]]$ quantum codes. The acronym QECC (Quantum Error Correcting Code) will be used to more easily distinguish from the best known linear codes database (BKLC).

Magma currently has a database for binary quantum codes, though it should be noted that these codes are considered to be over the alphabet $GF(4)$, not $GF(2)$. The database for codes over $GF(4)$ currently contains constructions of all best known quantum codes of length $35$. This includes self-dual quantum codes up to length $35$, which are stored in the database as dimension $0$ quantum codes.

Quantum codes of length up to $12$ are optimal, in the sense that their minimum weights meet the upper bound. Thus the user has access to $665$ best-known binary quantum codes.

The Magma QECC database uses the tables of bounds and constructions compiled by Markus Grassl (Karlsruhe), available online at [[Grassl, n.d.](../../references.md#cite-grasslweb)], which are based on the results in [[Calderbank *et al.*, 1998](../../references.md#cite-crss)]. Good codes have also been contributed by Eric Rains and Zlatko Varbanov.

The user can display the method used to construct a particular QECC code through use of a verbose mode, triggered by the verbose flag `BestCode`. When it is set to `true`, all of the functions in this section will output the steps involved in each code they construct.

## `QECC(F, n, k): FldFin, RngIntElt, RngIntElt -> CodeQuantum, BoolElt`

## `BKQC(F, n, k): FldFin, RngIntElt, RngIntElt -> CodeQuantum, BoolElt`

## `BestKnownQuantumCode(F, n, k): FldFin, RngIntElt, RngIntElt -> CodeQuantum, BoolElt`

Given a finite field $F$, and positive integers $n$ and $k$ such that $k \le n$, return an $[[n,k]]$ quantum code over $F$ which has the largest minimum weight among all known $[[n,k]]$ quantum codes. A second boolean return value signals whether or not the desired code exists in the database.

The database currently exists for $GF(4)$ (which are in fact binary quantum codes) up to length $35$.

## `Example: QECC Egs (ex-4ef878)`

The weight distribution of a small best known quantum code is calculated, verifying its minimum weight. Note that the *larger* the dimension of a quantum code, the easier it is to calculate its weight distribution.

```magma
> F<w> := GF(4);
> Q := QECC(F,25,16);
> Q:Minimal;
[[25, 16, 3]] Quantum code over GF(2^2)
> time WD_S, WD_N, WD := WeightDistribution(Q);
Time: 0.010
> WD_S;
[ <0, 1>, <1, 2>, <2, 1>, <14, 4>, <15, 16>, <16, 38>, <17, 79>, <18, 126>, <19,
129>, <20, 77>, <21, 27>, <22, 9>, <23, 3> ]
> WD_N;
[ <0, 1>, <1, 2>, <2, 1>, <3, 399>, <4, 6527>, <5, 75363>, <6, 707543>, <7,
5404369>, <8, 34084490>, <9, 180107319>, <10, 804255370>, <11, 3052443894>, <12,
9883860222>, <13, 27348684334>, <14, 64649758926>, <15, 130286413858>, <16,
222912028997>, <17, 321704696752>, <18, 387985433701>, <19, 385943417035>, <20,
310898936275>, <21, 197566276671>, <22, 95232787563>, <23, 32688613821>, <24,
7109768160>, <25, 735493959> ]
> WD;
[ <3, 399>, <4, 6527>, <5, 75363>, <6, 707543>, <7, 5404369>, <8, 34084490>, <9,
180107319>, <10, 804255370>, <11, 3052443894>, <12, 9883860222>, <13,
27348684334>, <14, 64649758922>, <15, 130286413842>, <16, 222912028959>, <17,
321704696673>, <18, 387985433575>, <19, 385943416906>, <20, 310898936198>, <21,
197566276644>, <22, 95232787554>, <23, 32688613818>, <24, 7109768160>, <25,
735493959> ]

```

So the $[[25,16]]$ code is impure, and has a minimum distance of $3$.

## `Example: QECC Self Dual (ex-aece57)`

Unlike linear codes, dimension $0$ quantum codes are non-trivial and are the subject of much study. These are the *self-dual* quantum codes, which form a special subclass of quantum stabilizer codes. It can be seen that a length $n$ self-dual code is described by a $n\times n$ generator matrix, an indication of the non-triviality of its structure.

```magma
> F<w> := GF(4);
> C := QECC(GF(4),8, 0);
> C;
[[8, 0, 4]] self-dual Quantum code over GF(2^2), stabilised by:
[  1   0   0   1   0   1   1   0]
[  w   0   0   w   0   w   w   0]
[  0   1   0   1   0   1   0   1]
[  0   w   0   w   0   w   0   w]
[  0   0   1   1   0   0   1   1]
[  0   0   w   w   0   0   w   w]
[  0   0   0   0   1   1   1   1]
[  0   0   0   0   w   w   w   w]

```

## `Example: QECC Verbose (ex-e5b5cc)`

The verbose flag `BestCode` will show the method by which the best code is constructed in the database. In this example the construction of a $[[25, 11, 4]]$ quantum code is described.

```magma
> SetVerbose("BestCode",true);
> F<w> := GF(4);
> Q := QECC(F,25,11);
Construction of a [[ 25 , 11 , 4 ]] Quantum Code:
[1]:  [[40, 30, 4]] Quantum code over GF(2^2)
        QuasiCyclicCode of length 40 stacked to height 2 with generating
        polynomials: 1,  w^2*x^4 + w*x^3 + w^2*x^2 + w*x + w^2,  x^4 + w^2*x^2 +
        w^2*x + w^2,  x^4 + w*x^3 + x^2,  w*x^4 + x^3 + w^2*x,  w*x^4 + x^3 +
        x^2 + x,  w^2*x^4 + x^2 + w*x,  x^4 + w^2*x^3 + w^2*x^2 + x + 1,  w,
        x^4 + w^2*x^3 + x^2 + w^2*x + 1,  w*x^4 + x^2 + x + 1,  w*x^4 + w^2*x^3
        + w*x^2,  w^2*x^4 + w*x^3 + x,  w^2*x^4 + w*x^3 + w*x^2 + w*x,  x^4 +
        w*x^2 + w^2*x,  w*x^4 + x^3 + x^2 + w*x + w
[2]:  [[21, 11, 4]] Quantum code over GF(2^2)
        Shortening of [1] at { 2, 3, 4, 6, 8, 9, 10, 12, 13, 14, 15, 16, 18, 19,
        21, 24, 28, 34, 37 }
[3]:  [[25, 11, 4]] Quantum code over GF(2^2)
        ExtendCode [2] by 4
> Q:Minimal;
[[25, 11, 4]] Quantum code over GF(2^2)

```
