---
title: "Operations on Structure Constant Algebras and Elements"
canonical: "https://docs.magma-maths.org/v2.30-1/Algebras/StructureConstantAlgebras/creation-2.html"
source: "https://docs.magma-maths.org/v2.30-1/Algebras/StructureConstantAlgebras/creation-2.md"
part: "Algebras"
chapter: "Structure Constant Algebras"
breadcrumbs:
  - {"title": "Magma Handbook", "source": "https://docs.magma-maths.org/v2.30-1/index.md"}
  - {"title": "Algebras", "source": "https://docs.magma-maths.org/v2.30-1/Algebras/index-algebras.md"}
  - {"title": "Structure Constant Algebras", "source": "https://docs.magma-maths.org/v2.30-1/Algebras/StructureConstantAlgebras/index-structure-constant-algebras.md"}
prev: {"title": "Construction of Structure Constant Algebras and Elements", "source": "https://docs.magma-maths.org/v2.30-1/Algebras/StructureConstantAlgebras/creation.md"}
next: {"title": "Associative Algebras", "source": "https://docs.magma-maths.org/v2.30-1/Algebras/AssociativeAlgebras/index-associative-algebras.md"}
intrinsics:
  - {"name": "IsCommutative", "signature": "IsCommutative(A): AlgGen -> BoolElt"}
  - {"name": "IsAssociative", "signature": "IsAssociative(A): AlgGen -> BoolElt"}
  - {"name": "IsLie", "signature": "IsLie(A): AlgGen -> BoolElt"}
  - {"name": "DirectSum", "signature": "DirectSum(A, B): AlgGen, AlgGen -> AlgGen"}
  - {"name": "a", "signature": "a[i]: AlgGenElt, RngIntElt -> RngElt"}
  - {"name": "a[i] := r", "signature": "a[i] := r: AlgGenElt, RngIntElt, RngElt -> AlgGenElt"}
  - {"name": "Module", "signature": "Module(A): AlgGen -> ModTupRng"}
  - {"name": "Degree", "signature": "Degree(A): AlgGen -> RngIntElt"}
  - {"name": "Degree", "signature": "Degree(a): AlgGenElt -> RngIntElt"}
  - {"name": "ElementToSequence", "signature": "ElementToSequence(a): AlgGenElt -> SeqEnum"}
  - {"name": "Eltseq", "signature": "Eltseq(a): AlgGenElt -> SeqEnum"}
  - {"name": "Coordinates", "signature": "Coordinates(S, a): AlgGen, AlgGenElt -> SeqEnum"}
  - {"name": "InnerProduct", "signature": "InnerProduct(a, b): AlgGenElt, AlgGenElt -> RngElt"}
  - {"name": "Support", "signature": "Support(a): AlgGenElt -> SetEnum"}
  - {"name": "hom", "signature": "hom< A -> B | Q >: AlgGen, AlgGen, [ AlgGenElt ] -> Map"}
  - {"name": "hom", "signature": "hom< A -> B | Q >: AlgGen, TupMod, [ TupModElt ] -> Map"}
examples:
  - "ex-381ebc"
  - "ex-fafa2a"
---

# Operations on Structure Constant Algebras and Elements

## Operations on Structure Constant Algebras

<a id="function-iscommutative-alggen"></a>
### `IsCommutative(A): AlgGen -> BoolElt`

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

<a id="function-isassociative-alggen"></a>
### `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.

<a id="function-islie-alggen"></a>
### `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.

<a id="function-directsum-alggen-alggen"></a>
### `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.

<a id="example-ex-381ebc"></a>
### `Example: Jordan Algebra from Structure Constants (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 id="indexed-indexed-a-alggenelt-rngintelt-rngelt"></a>
### `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 id="literal-literal-a-i-r-alggenelt-rngintelt-rngelt-alggenelt"></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

<a id="function-module-alggen"></a>
### `Module(A): AlgGen -> ModTupRng`

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

<a id="function-degree-alggen"></a>
### `Degree(A): AlgGen -> RngIntElt`

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

<a id="function-degree-alggenelt"></a>
### `Degree(a): AlgGenElt -> RngIntElt`

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

<a id="function-elementtosequence-alggenelt"></a>
### `ElementToSequence(a): AlgGenElt -> SeqEnum`

<a id="function-eltseq-alggenelt"></a>
### `Eltseq(a): AlgGenElt -> SeqEnum`

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

<a id="function-coordinates-alggen-alggenelt"></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$.

<a id="function-innerproduct-alggenelt-alggenelt"></a>
### `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$.

<a id="function-support-alggenelt"></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

<a id="constructor-constructor-hom-alggen-alggen-alggenelt-map"></a>
### `hom< A -> B | Q >: AlgGen, AlgGen, [ AlgGenElt ] -> Map`

<a id="constructor-constructor-hom-alggen-tupmod-tupmodelt-map"></a>
### `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.

<a id="example-ex-fafa2a"></a>
### `Example: Real Cayley Algebra (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.
