# Clifford Algebras

Clifford algebras are represented in Magma as structure constant algebras and therefore many of the functions described in Chapter [Algebras](../IntroductionToAlgebras/index-introduction-to-algebras.md#chapalggen) apply to Clifford algebras. However, the base ring of a Clifford algebra is required to be an *exact* field (see Chapter [Introduction to Rings](../../BasicRings/IntroductionToRings/index-introduction-to-rings.md#rngintro)). The Magma type of a Clifford algebra is `AlgClff` and the type of an element of a Clifford algebra is `AlgClffElt`. All Clifford algebras are created with the attributes

**space**: the quadratic space from which the Clifford algebra is derived;

**embedding**: the standard embedding of the quadratic space into the Clifford algebra.

Let $C$ be the Clifford algebra of the quadratic form $Q$ defined on the vector space $V$. If $e_1$, $e_2$, …, $e_n$ is a basis for $V$, a basis for $C$ is the set of all products $e_1^{i_1}e_2^{i_2}\cdots e_n^{i_n}$, where $i_k$ is 0 or 1 for all $k$. The function $k \mapsto i_k$ is the characteristic function of a subset of $\{1,2,\dots, n\}$, namely $S = \{k \mid i_k = 1 \}$. The map $S\mapsto 1 + \sum_{k\in S} 2^{k-1}$ is a bijection between the subsets of $\{1,2,\dots,n\}$ and the integers in the interval $[1\dots 2^n]$.

Thus the elements of $C$ can be represented by a sequence of pairs $\langle S,a\rangle$ where $S$ is a subset of $\{1,2,\dots,n\}$ and $a$ is a field element. Multiplication is determined by the fact that for all $u,v\in V$ we have

$$
v^2 = Q(v)\cdot 1\quad\hbox{and}\quad uv + vu = \beta(u,v)\cdot 1,
$$

where $\beta$ is the polar form of $Q$.

## `CliffordAlgebra(Q): AlgMatElt -> AlgClff, ModTupFld, Map`

This function returns a triple $C$, $V$, $f$, where $C$ is the Clifford algebra of the quadratic form $Q$, $V$ is the quadratic space of $Q$, and $f$ is the standard embedding of $V$ into $C$.

## `CliffordAlgebra(V): ModTupFld -> AlgClff, Map`

If $V$ is a quadratic space with quadratic form $Q$, this function returns the pair $C$, $f$, where $C$ is the Clifford algebra of $Q$ and $f$ is the standard embedding of $V$ into $C$.

## `Example: Cliff Quat Ex (ex-22ab1c)`

A quaternion algebra is a special case of a Clifford algebra.

```magma
> C,V,f := CliffordAlgebra(-IdentityMatrix(Rationals(),2));
> i := f(V.1);
> j := f(V.2);
> i^2 eq -One(C);
true
> j^2 eq -One(C);
true
> i*j eq -j*i;
true

```

## Print Names for Generators

The *generators* of a Clifford algebra $C$ defined on a quadratic space $V$ are the images of the standard basis elements of $V$ under the embedding of $V$ in $C$. If `C` is a Clifford algebra note that `C.1`, `C.2` and so on refer to the basis elements of the underlying vector space of `C` *not* its generators. The `AssignNames` procedure can be used to associate names with the generators of a Clifford algebra after its creation.

### `AssignNames(~C, S): AlgClff, [ MonStgElt ])`

Procedure to change the names of the generators of a Clifford algebra $C$. The $i$-th generator will be given the name of the $i$-th element of the sequence $S$; the sequence may have length less than the number of generators of $C$, in which case the remaining generator names remain unchanged. This procedure changes only the names used in printing the elements of $C$. It does *not* assign to identifiers corresponding to the strings in $S$; to do this, use assignment statements, or use angle brackets when creating the Clifford algebra. This procedure is called by the generator assignment operators `< >` at the time of creation of a Clifford algebra.

### `Name(C, i): AlgClff, RngIntElt -> AlgClffElt`

Given a Clifford algebra $C$, return the $i$-th generator of $C$ (as an element of $C$).

### `AsPolynomial(v): AlgClffElt`

Print the element $v$ of a Clifford algebra as a polynomial in its generators; that is, as a polynomial in the basis elements of its quadratic space. By default the generators are labelled $e_1$, $e_2$, …, $e_n$.

### `Example: Clifford Gen (ex-dfadc4)`

The generator assignment construction (see Section [Generator Assignment](../../MagmaLanguage/StatementsAndExpressions/assignment.md#gen-ass)) can be used to assign names to the generators of a Clifford algebra.

```magma
> C<x,y,z> := CliffordAlgebra(IdentityMatrix(GF(5),3));
> f := x^2 + 3*y + y*z;
> f;
(1 0 3 0 0 0 1 0)
> AsPolynomial(f);
y*z + 3*y + 1

```

### `Example: Clifford Names (ex-436f79)`

The names of the generators for printing (via `AsPolynomial`) can be changed using `AssignNames`. Furthermore, assigning new print names to the generators does *not* change the identifiers themselves.

```magma
> C<[x]> := CliffordAlgebra(IdentityMatrix(GF(5),3));
> f := 3*C.1 + 2*C.2 + C.5 +C.6;
> AsPolynomial(f);
x[1]*x[3] + 2*x[1] + x[3] + 3
> Name(C,3) eq C.5;
true
> AssignNames(~C,["x","y","z"]);
> AsPolynomial(f);
x*z + 2*x + z + 3
> x[2];
(0 0 1 0 0 0 0 0)
> y;
User error: Identifier 'y' has not been declared or assigned

```

## Elements of a Clifford Algebra

### `elt< C | r₁, r₂, ..., rₘ >: AlgClff, RngElt, RngElt, ..., RngElt -> AlgClffElt`

Given a Clifford algebra $C$ of dimension $m = 2^n$ over a field $F$, and field elements $r_1$, $r_2$, …, $r_m \in F$ construct the element $r_1 * C.1 + r_2 * C.2 + \cdots + r_m * C.m$ of $C$.

### `C ! L: AlgClff, SeqEnum[RngElt] -> AlgGenElt`

Given a Clifford algebra $C$ of dimension $m = 2^n$ and a sequence $L = [r_1, r_2, \ldots, r_m]$ of elements of the base ring $R$ of $C$, construct the element $r_1 * C.1 + r_2 * C.2 + \cdots + r_m * C.m$ of $C$.

### `SeqToClifford(C, ss): AlgClff, SeqEnum -> AlgClffElt`

Convert a sequence `ss` of pairs $\langle S, a\rangle$ to an element of the Clifford algebra $C$, where $S$ is a subset of $\{1,\dots,n\}$, $a$ is in the base field and the dimension of $C$ is $2^n$.

### `SeqFromClifford(v): AlgClffElt -> SeqEnum`

The sequence of pairs $\langle S, a\rangle$ which represents the element $v$ of a Clifford algebra.

### `Example: Eltfromseq (ex-3fca24)`

We illustrate the conversion of a Clifford algebra element to its monomial representation.

```magma
> K<z> := GF(5,2);
> Q := StandardQuadraticForm(4,K);
> C,V,f := CliffordAlgebra(Q);
> x := elt< C | 1,0,2,z,0,z^2,z^11,0,0,0,0,z,0,0,0,z^13 >;
> L := SeqFromClifford(x);
> L;
[
    <[], 1>,
    <[ 2 ], 2>,
    <[ 1, 2 ], z>,
    <[ 1, 3 ], z^2>,
    <[ 2, 3 ], z^11>,
    <[ 1, 2, 4 ], z>,
    <[ 1, 2, 3, 4 ], z^13>
]
> x eq SeqToClifford(C,L);
true
> AsPolynomial(x);
z^13*e1*e2*e3*e4 + z*e1*e2*e4 + z*e1*e2 + z^2*e1*e3 + z^11*e2*e3 + 2*e2 + 1

```

### `BasisProduct(C, i, j): AlgClff, RngIntElt, RngIntElt -> AlgGenElt`

The product of the $i$-th and $j$-th basis element of the Clifford algebra $C$.

### `BasisProduct(C, L): AlgClff, SeqEnum -> AlgGenElt`

The product of the basis elements (indexed by $L$) of the quadratic space of the Clifford algebra $C$.

### `BasisElement(C, S): AlgClff, SetEnum -> AlgClffElt`

The basis element $C.j$ of the Clifford algebra $C$ corresponding to the subset $S$ of $\{1,2,\dots,n\}$ where $j = 1+\sum_{k\in S}2^{k-1}$. If $e_1$, $e_2$, …, $e_n$ is the standard basis for the quadratic space of $C$, this corresponds to the product $e_{i_1} * e_{i_2} * \cdots * e_{i_h}$, where $S = \{i_1,i_2,\dots,i_h\}$ and $i_1 < i_2 < \cdots < i_h$.
