# Operations on Structure Constant Algebras and Elements

## Operations on Structure Constant Algebras

### `IsCommutative(A): AlgGen -> BoolElt`

Returns `true` if the algebra $A$ is commutative; otherwise `false`.

### `IsAssociative(A): AlgGen -> BoolElt`

Returns `true` if the algebra $A$ is associative; otherwise `false`.

Note that for a structure constant algebra of dimension $n$ this requires up to $n^3$ tests.

### `IsLie(A): AlgGen -> BoolElt`

Returns `true` if the algebra $A$ is a Lie algebra; otherwise `false`.

Note that for a structure constant algebra of dimension $n$ this requires about $n^3/3$ tests of the Jacobi identity.

### `DirectSum(A, B): AlgGen, AlgGen -> AlgGen`

Construct a structure constant algebra of dimension $n+m$ where $n$ and $m$ are the dimensions of the algebras $A$ and $B$, respectively. The basis of the new algebra is the concatenation of the bases of $A$ and $B$ and the products $a * b$ where $a \in A$ and $b \in B$ are defined to be 0.

### `Example: jordan (ex-381ebc)`

We define a structure constant algebra which is a Jordan algebra.

```magma
> M := MatrixAlgebra( GF(3), 2 );
> B := Basis(M);
> C := &cat[Coordinates(M,(B[i]*B[j]+B[j]*B[i])/2) : j in [1..#B], i in [1..#B]];
> A := Algebra< GF(3), #B | C >;
> #A;
81
> IsAssociative(A);
false
> IsLie(A);
false
> IsCommutative(A);
true

```

This is a good start, as one of the defining properties of Jordan algebras is that they are commutative. The other property is that the identity $(x^2 * y) * x = x^2 * (y * x)$ holds for all $x,y \in A$. We check this on a random pair.

```magma
> x := Random(A); y := Random(A); print (x^2*y)*x - x^2*(y*x);
(0 0 0 0)

```

The algebra is small enough to check this identity on all elements.

```magma
> forall{<x, y>: x, y in A | (x^2*y)*x eq x^2*(y*x)};
true

```

So the algebra is in fact a Jordan algebra (which was clear by construction). We finally have a look at the structure constants.

```magma
> BasisProducts(A);
[
    [ (1 0 0 0), (0 2 0 0), (0 0 2 0), (0 0 0 0) ],
    [ (0 2 0 0), (0 0 0 0), (2 0 0 2), (0 2 0 0) ],
    [ (0 0 2 0), (2 0 0 2), (0 0 0 0), (0 0 2 0) ],
    [ (0 0 0 0), (0 2 0 0), (0 0 2 0), (0 0 0 1) ]
]

```

## Indexing Elements

### `a[i]: AlgGenElt, RngIntElt -> RngElt`

If $a$ is an element of a structure constant algebra $A$ of dimension $n$ and $1 \leq i\leq n$ is a positive integer, then the $i$-th component of the element $a$ is returned (as an element of the base ring $R$ of $A$).

### `a[i] := r: AlgGenElt, RngIntElt, RngElt -> AlgGenElt`

Given an element $a$ belonging to a structure constant algebra of dimension $n$ over $R$, a positive integer $1 \leq i\leq n$ and an element $r \in R$, the $i$-th component of the element $a$ is redefined to be $r$.

## The Module Structure of a Structure Constant Algebra

### `Module(A): AlgGen -> ModTupRng`

The module $R^n$ underlying the structure constant algebra $A$.

### `Degree(A): AlgGen -> RngIntElt`

The degree (= dimension) of the module underlying the algebra $A$.

### `Degree(a): AlgGenElt -> RngIntElt`

Given an element belonging to the structure constant algebra $A$ of dimension $n$, return $n$.

### `ElementToSequence(a): AlgGenElt -> SeqEnum`

### `Eltseq(a): AlgGenElt -> SeqEnum`

The sequence of coefficients of the structure constant algebra element $a$.

### `Coordinates(S, a): AlgGen, AlgGenElt -> SeqEnum`

Let $a$ be an element of a structure constant algebra $A$ and let $S$ be a subalgebra of $A$ containing $a$. This function returns the coefficients of $a$ with respect to the basis of $S$.

### `InnerProduct(a, b): AlgGenElt, AlgGenElt -> RngElt`

The (Euclidean) inner product of the coefficient vectors of $a$ and $b$, where $a$ and $b$ are elements of some structure constant algebra $A$.

### `Support(a): AlgGenElt -> SetEnum`

The support of the structure constant algebra element $a$; i.e. the set of indices of the non-zero components of $a$.

## Homomorphisms

### `hom< A -> B | Q >: AlgGen, AlgGen, [ AlgGenElt ] -> Map`

### `hom< A -> B | Q >: AlgGen, TupMod, [ TupModElt ] -> Map`

Given a structure constant algebra $A$ of dimension $n$ over $R$ and either a structure constant algebra $B$ over $R$ or a module $B$ over $R$, construct the homomorphism from $A$ to $B$ specified by $Q$. The sequence $Q$ may be of the form $[b_1, \ldots, b_n]$, $b_i \in B$, indicating that the $i$-th basis element of $A$ is mapped to $b_1$ or of the form $[<a_1,b_1>, \ldots, <a_n,b_n>]$ indicating that $a_i$ maps to $b_i$, where the $a_i (1 \le i \le n)$ must form a basis of $A$.

Note that this is in general only a module homomorphism, it is not checked whether it is an algebra homomorphism.

### `Example: cayley (ex-fafa2a)`

We construct the real Cayley algebra, which is a non-associative algebra of dimension 8, containing 7 quaternion algebras. If the basis elements are labelled $1, \ldots, 8$ and 1 corresponds to the identity, these quaternion algebras are spanned by $\{ 1, (n+1) \bmod 7 + 2, (n+2) \bmod 7 + 2, (n+4) \bmod 7 + 4 \}$, where $0 \leq n \leq 6$. We first define a function, which, given three indices $i,j,k$ constructs a sequence with the structure constants for the quaternion algebra spanned by $1,i,j,k$ in the quadruple notation.

```magma
> quat := func<i,j,k | [<1,1,1, 1>, <i,i,1, -1>, <j,j,1, -1>, <k,k,1, -1>,
>   <1,i,i, 1>, <i,1,i, 1>, <1,j,j, 1>, <j,1,j, 1>, <1,k,k, 1>, <k,1,k, 1>,
>   <i,j,k, 1>, <j,i,k, -1>, <j,k,i, 1>, <k,j,i, -1>, <k,i,j, 1>, <i,k,j, -1>]>;

```

We now define the sequence of non-zero structure constants for the Cayley algebra using the function `quat`. Some structure constants are defined more than once and we have to get rid of these when defining the algebra.

```magma
> con := &cat[quat((n+1) mod 7 +2, (n+2) mod 7 +2, (n+4) mod 7 +2):n in [0..6]];
> C := Algebra< Rationals(), 8 | Setseq(Set(con)) >;
> C;
Algebra of dimension 8 with base ring Rational Field
> IsAssociative(C);
false
> IsAssociative( sub< C | C.1, C.2, C.3, C.5 > );
true

```

The integral elements in this algebra are those where either all coefficients are integral or exactly 4 coefficients lie in $1/2 + {\mathbb{Z}}$ in positions $i_1, i_2, i_3, i_4$, such that $i_1, i_2, i_3, i_4$ are a basis of one of the 7 quaternion algebras or a complement of such a basis. These elements are called the integral Cayley numbers and form a ${\mathbb{Z}}$-algebra. The units in this algebra are the elements with either one entry $\pm1$ and the others 0 or with 4 entries $\pm 1/2$ and 4 entries 0, where the non-zero entries are in the positions as described above. This gives 240 units and they form (after rescaling with $\sqrt{2}$) the roots in the root lattice of type $E_8$.

```magma
> a := (C.1 - C.2 + C.3 - C.5) / 2;
> MinimalPolynomial(a);
$.1^2 - $.1 + 1
> MinimalPolynomial(a^-1);
$.1^2 - $.1 + 1
> MinimalPolynomial(C.2+C.3);
$.1^2 + 2
> MinimalPolynomial((C.2+C.3)^-1);
$.1^2 + 1/2

```

Tensoring the integral Cayley algebra with a finite field gives a finite Cayley algebra. As the ${\mathbb{Z}}$-algebra generated by the chosen basis for $C$ has index $2^4$ in the full integral Cayley algebra, we can get the finite Cayley algebras by applying the `ChangeRing` function for finite fields of odd characteristic. The Cayley algebra over $GF(q)$ has the simple group $G_2(q)$ as its automorphism group. Since the identity has to be fixed, every automorphism is determined by its image on the remaining 7 basis elements. Each of these has minimal polynomial $x^2 + 1$, hence one obtains a permutation representation of $G_2(q)$ on the elements with this minimal polynomial. As $\pm$-pairs have to be preserved, this number can be divided by 2.

```magma
> C3 := ChangeRing( C, GF(3) );
> f := MinimalPolynomial(C3.2);
> f;
$.1^2 + 1
> #C3;
6561
> time Im := [ c : c in C3 | MinimalPolynomial(c) eq f ];
Time: 3.099
> #Im;
702
> C5 := ChangeRing( C, GF(5) );
> f := MinimalPolynomial(C5.2);
> f;
$.1^2 + 1
> #C5;
390625
> time Im := [ c : c in C5 | MinimalPolynomial(c) eq f ];
Time: 238.620
> #Im;
15750

```

In the case of the Cayley algebra over $GF(3)$ we obtain a permutation representation of degree 351, which is in fact the smallest possible degree (corresponding to the representation on the cosets of the largest maximal subgroup $U_3(3):2$). Over $GF(5)$, the permutation representation is of degree 7875, corresponding to the maximal subgroup $L_3(5):2$, the smallest possible degree being 3906.
