---
title: "Handbook of Magma Functions, Part XI: Algebras"
version: "2.30-1"
canonical: "https://docs.magma-maths.org/Algebras/index-algebras.html"
---

# Algebras

- [Algebras](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/index-introduction-to-algebras.md): Overview, creation, substructures, and general operations on algebras.
- [Structure Constant Algebras](https://docs.magma-maths.org/Algebras/StructureConstantAlgebras/index-structure-constant-algebras.md): Algebras defined by structure constants.
- [Associative Algebras](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/index-associative-algebras.md): Structure, subalgebras, ideals, and the Jacobson radical.
- [Finitely Presented Algebras](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/index-finitely-presented-algebras.md): Algebras given by generators and relations.
- [Matrix Algebras](https://docs.magma-maths.org/Algebras/MatrixAlgebras/index-matrix-algebras.md): Matrix algebras: creation, substructures, and extensions.
- [Group Algebras](https://docs.magma-maths.org/Algebras/GroupAlgebras/index-group-algebras.md): Group algebras: creation, substructures, and element operations.
- [Basic Algebras](https://docs.magma-maths.org/Algebras/BasicAlgebras/index-basic-algebras.md): Basic algebras, gradings, idempotents, and their homomorphisms.
- [Quaternion Algebras](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/index-quaternion-algebras.md): Quaternion algebra constructors, maximal orders, and splitting.
- [Algebras with Involution](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/index-algebras-with-involution.md): Star algebras, involutions, and their decompositions.
- [Clifford Algebras](https://docs.magma-maths.org/Algebras/CliffordAlgebras/index-clifford-algebras.md): Clifford algebras, involutions, and spin groups.
- [Non-associative Algebras](https://docs.magma-maths.org/Algebras/NonAssociativeAlgebras/index-non-associative-algebras.md): Jordan algebras, alternative algebras, and octonions.

<a id="chapalggen"></a>
<a id="id1"></a>
## Algebras

- [Introduction](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/introduction.md)
  - [The Categories of Algebras](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/introduction.md#the-categories-of-algebras)
- [Construction of General Algebras and their Elements](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/creation.md)
  - [Construction of a General Algebra](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/creation.md#construction-of-a-general-algebra)
    - [`Algebra< R, n | Q >: Rng, RngIntElt, SeqEnum → AlgGen`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/creation.md#constructor-constructor-algebra-rng-rngintelt-seqenum-alggen)
    - [`AssociativeAlgebra< R, n | Q >: Rng, RngIntElt, SeqEnum → AlgAss`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/creation.md#constructor-constructor-associativealgebra-rng-rngintelt-seqenum-algass)
    - [`QuaternionAlgebra< K | a, b >: Rng, RngElt, RngElt → AlgQuat`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/creation.md#constructor-constructor-quaternionalgebra-rng-rngelt-rngelt-algquat)
    - [`LieAlgebra< R, n | Q >: Rng, RngIntElt, SeqEnum → AlgLie`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/creation.md#constructor-constructor-liealgebra-rng-rngintelt-seqenum-alglie)
    - [`LieAlgebra(A): AlgAss → AlgLie`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/creation.md#function-liealgebra-algass)
    - [`GroupAlgebra(R, G): Rng, Grp → AlgGrp`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/creation.md#function-groupalgebra-rng-grp)
    - [`MatrixAlgebra(R, n): Rng, RngInt → AlgMat`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/creation.md#function-matrixalgebra-rng-rngint)
  - [Construction of an Element of a General Algebra](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/creation.md#construction-of-an-element-of-a-general-algebra)
    - [`Zero(A): AlgGen → AlgGenElt`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/creation.md#function-zero-alggen)
    - [`A ! 0: AlgGen, RngIntElt → AlgGenElt`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/creation.md#operation-op-alggen-rngintelt)
    - [`One(A): AlgGen → AlgGenElt`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/creation.md#function-one-alggen)
    - [`A ! 1: AlgGen, RngIntElt → AlgGenElt`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/creation.md#operation-op-alggen-rngintelt-2)
    - [`Random(A): AlgGen → AlgGenElt`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/creation.md#function-random-alggen)
- [Construction of Subalgebras, Ideals, and Quotient Algebras](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/subs-quos.md)
  - [Subalgebras and Ideals](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/subs-quos.md#subalgebras-and-ideals)
    - [`sub< A | L >: AlgGen, List → AlgGen, Map`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/subs-quos.md#constructor-constructor-sub-alggen-list-alggen-map)
    - [`lideal< A | L >: AlgGen, List → AlgGen, Map`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/subs-quos.md#constructor-constructor-lideal-alggen-list-alggen-map)
    - [`rideal< A | L >: AlgGen, List → AlgGen, Map`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/subs-quos.md#constructor-constructor-rideal-alggen-list-alggen-map)
    - [`ideal< A | L >: AlgGen, List → AlgGen, Map`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/subs-quos.md#constructor-constructor-ideal-alggen-list-alggen-map)
  - [Quotient Algebras](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/subs-quos.md#quotient-algebras)
    - [`quo< A | L >: AlgGen, List → AlgGen, Map`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/subs-quos.md#constructor-constructor-quo-alggen-list-alggen-map)
    - [`A / S: AlgGen, AlgGen → AlgGen`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/subs-quos.md#operation-op-div-alggen-alggen)
- [Operations on Algebras and Subalgebras](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops.md)
  - [Invariants of an Algebra](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops.md#invariants-of-an-algebra)
    - [`CoefficientRing(A): AlgGen → Rng`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops.md#function-coefficientring-alggen)
    - [`CoefficientField(A): AlgGen → Rng`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops.md#function-coefficientfield-alggen)
    - [`BaseRing(A): AlgGen → Rng`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops.md#function-basering-alggen)
    - [`BaseField(A): AlgGen → Rng`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops.md#function-basefield-alggen)
    - [`Dimension(A): AlgGen → RngIntElt`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops.md#function-dimension-alggen)
    - [`# A: AlgGen → RngIntElt`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops.md#operation-operation-alggen-rngintelt)
  - [Changing Rings](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops.md#changing-rings)
    - [`ChangeRing(A, S): AlgGen, Rng → AlgGen, Map`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops.md#function-changering-alggen-rng)
    - [`ChangeRing(A, S, f): AlgGen, Rng, Map → AlgGen, Map`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops.md#function-changering-alggen-rng-map)
  - [Bases](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops.md#bases)
    - [`BasisElement(A, i): AlgGen, RngIntElt → AlgGenElt`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops.md#function-basiselement-alggen-rngintelt)
    - [`A . i: AlgGen, RngIntElt → AlgGenElt`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops.md#operation-operation-alggen-rngintelt-alggenelt)
    - [`Basis(A): AlgGen → [ AlgGenElt ]`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops.md#function-basis-alggen)
    - [`IsIndependent(Q): [ AlgGen ] → BoolElt`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops.md#function-isindependent-alggen)
    - [`ExtendBasis(S, A): AlgGen, AlgGen → [ AlgElt ]`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops.md#function-extendbasis-alggen-alggen)
    - [`ExtendBasis(Q, A): [ AlgGen ], AlgGen → [ AlgElt ]`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops.md#function-extendbasis-alggen-alggen-2)
  - [Decomposition of an Algebra](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops.md#decomposition-of-an-algebra)
    - [`CompositionSeries(A): AlgGen → [ AlgGen ], [ AlgGen ], AlgMatElt`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops.md#function-compositionseries-alggen)
    - [`CompositionFactors(A): AlgGen → [ AlgGen ]`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops.md#function-compositionfactors-alggen)
    - [`MinimalLeftIdeals(A : parameters): AlgGen → [ AlgGen ], BoolElt`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops.md#function-minimalleftideals-alggen)
    - [`MinimalRightIdeals(A : parameters): AlgGen → [ AlgGen ], BoolElt`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops.md#function-minimalrightideals-alggen)
    - [`MinimalIdeals(A : parameters): AlgGen → [ AlgGen ], BoolElt`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops.md#function-minimalideals-alggen)
    - [`MaximalLeftIdeals(A : parameters): AlgGen → [ AlgGen ], BoolElt`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops.md#function-maximalleftideals-alggen)
    - [`MaximalRightIdeals(A : parameters): AlgGen → [ AlgGen ], BoolElt`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops.md#function-maximalrightideals-alggen)
    - [`MaximalIdeals(A : parameters): AlgGen → [ AlgGen ], BoolElt`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops.md#function-maximalideals-alggen)
    - [`JacobsonRadical(A): AlgGen → AlgGen`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops.md#function-jacobsonradical-alggen)
    - [`IsSemisimple(A): AlgGen → BoolElt`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops.md#function-issemisimple-alggen)
    - [`IsSimple(A): AlgGen → BoolElt`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops.md#function-issimple-alggen)
    - [Example: Quaternions as a Matrix Algebra](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops.md#example-ex-0f19c1)
  - [Operations on Subalgebras](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops.md#operations-on-subalgebras)
    - [`IsZero(A): AlgGen → BoolElt`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops.md#function-iszero-alggen)
    - [`A eq B: AlgGen, AlgGen → BoolElt`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops.md#operation-op-eq-alggen-alggen)
    - [`A ne B: AlgGen, AlgGen → BoolElt`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops.md#operation-op-ne-alggen-alggen)
    - [`A subset B: AlgGen, AlgGen → BoolElt`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops.md#operation-op-subset-alggen-alggen)
    - [`A notsubset B: AlgGen, AlgGen → BoolElt`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops.md#operation-operation-notsubset-alggen-alggen-boolelt)
    - [`A meet B: AlgGen, AlgGen → AlgGen`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops.md#operation-op-meet-alggen-alggen)
    - [`A * B: AlgGen, AlgGen → AlgGen`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops.md#operation-op-times-alggen-alggen)
    - [`A ^ n: AlgGen, RngIntElt → AlgGen`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops.md#operation-op-pow-alggen-rngintelt)
    - [`Morphism(A, B): AlgGen, AlgGen → Map`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops.md#function-morphism-alggen-alggen)
- [Operations on Elements of an Algebra](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops-2.md)
  - [Operations on Elements](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops-2.md#operations-on-elements)
    - [`a + b: AlgGenElt, AlgGenElt → AlgGenElt`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops-2.md#operation-op-plus-alggenelt-alggenelt)
    - [`- a: AlgGenElt → AlgGenElt`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops-2.md#operation-operation-alggenelt-alggenelt)
    - [`a - b: AlgGenElt, AlgGenElt → AlgGenElt`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops-2.md#operation-op-minus-alggenelt-alggenelt)
    - [`a * b: AlgGenElt, AlgGenElt → AlgGenElt`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops-2.md#operation-op-times-alggenelt-alggenelt)
    - [`a * r: AlgGenElt, RngElt → AlgGenElt`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops-2.md#operation-op-times-alggenelt-rngelt)
    - [`r * a: RngElt, AlgGenElt → AlgGenElt`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops-2.md#operation-op-times-rngelt-alggenelt)
    - [`a / r: AlgGenElt, RngElt → AlgGenElt`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops-2.md#operation-op-div-alggenelt-rngelt)
    - [`a ^ n: AlgGenElt, RngIntElt → AlgGenElt`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops-2.md#operation-op-pow-alggenelt-rngintelt)
    - [`MinimalPolynomial(a): AlgGenElt → RngUPolElt`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops-2.md#function-minimalpolynomial-alggenelt)
    - [`Parent(a): AlgGenElt → AlgGen`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops-2.md#function-parent-alggenelt)
  - [Comparisons and Membership](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops-2.md#comparisons-and-membership)
    - [`a eq b: AlgGenElt, AlgGenElt → BoolElt`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops-2.md#operation-op-eq-alggenelt-alggenelt)
    - [`a ne b: AlgGenElt, AlgGenElt → BoolElt`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops-2.md#operation-op-ne-alggenelt-alggenelt)
    - [`a in A: AlgGenElt, AlgGen → BoolElt`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops-2.md#operation-op-in-alggenelt-alggen)
    - [`a notin A: AlgGenElt, AlgGen → BoolElt`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops-2.md#operation-op-notin-alggenelt-alggen)
  - [Predicates on Elements](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops-2.md#predicates-on-elements)
    - [`IsZero(a): AlgGenElt → BoolElt`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops-2.md#function-iszero-alggenelt)
    - [`IsOne(a): AlgGenElt → BoolElt`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops-2.md#function-isone-alggenelt)
    - [`IsMinusOne(a): AlgGenElt → BoolElt`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops-2.md#function-isminusone-alggenelt)
    - [`IsUnit(a): AlgGenElt → BoolElt, AlgGenElt`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops-2.md#function-isunit-alggenelt)
    - [`IsRegular(a): AlgGenElt → BoolElt`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops-2.md#function-isregular-alggenelt)
    - [`IsZeroDivisor(a): AlgGenElt → BoolElt`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops-2.md#function-iszerodivisor-alggenelt)
    - [`IsIdempotent(a): AlgGenElt → BoolElt`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops-2.md#function-isidempotent-alggenelt)
    - [`IsNilpotent(a): AlgGenElt → BoolElt, RngIntElt`](https://docs.magma-maths.org/Algebras/IntroductionToAlgebras/ops-2.md#function-isnilpotent-alggenelt)

### Introduction

Algebras are viewed as free modules over a ring $R$ with an additional multiplication. There are no a priori conditions imposed on the ring except that it must be unital, but some functions may require that an echelonization algorithm is available for modules over $R$ and sometimes it is also required that $R$ is a field. For example, quotients of algebras can only be constructed over fields, since otherwise the quotient module is not necessarily a free module over $R$.

The most general way to define an algebra is by structure constants, but for special types of algebras Magma uses more efficient representations.

#### The Categories of Algebras

At present, Magma contains seven main categories of algebras:

**(1)**
General algebras represented by structure constants: category `AlgGen`;

**(2)**
Associative algebras represented by structure constants: category `AlgAss`;

**(3)**
Quaternion algebras as special types of associative algebras; category `AlgQuat`;

**(4)**
Lie algebras represented by structure constants: category `AlgLie`;

**(5)**
Group algebras: category `AlgGrp` with a special type `AlgGrpSub` for subalgebras of group algebras;

**(6)**
Matrix algebras: category `AlgMat`;

**(7)**
Finitely presented algebras: category `AlgFP`.

The hierarchy of these categories is such that `AlgGen` is on the top level and `AlgAss` and `AlgLie` are on the next level inheriting the functions available for `AlgGen`. The categories `AlgQuat`, `AlgGrp`, and `AlgMat` are on a third level inheriting the functions available for `AlgAss`. Finitely presented algebras are independent of the other categories.

### Construction of General Algebras and their Elements

#### Construction of a General Algebra

The construction of an algebra depends on its category. The chapters on the individual algebra categories describe this in detail. Here only an overview is given.

<a id="constructor-constructor-algebra-rng-rngintelt-seqenum-alggen"></a>
##### `Algebra< R, n | Q >: Rng, RngIntElt, SeqEnum -> AlgGen`

Let $R$ be ring, $n$ an integer, and $Q$ a sequence of $n^3$ elements of $R$. This function creates an algebra $A$ of dimension $n$ over $R$ with basis $e_1, \ldots, e_n$ such that $Q$ contains the structure constants of $A$, i.e. $e_i * e_j = \sum a_{ij}^k e_k$, where $a_{ij}^k$ is the element in position $(i-1)*n^2 + (j-1)*n + k$ of $Q$.

<a id="constructor-constructor-associativealgebra-rng-rngintelt-seqenum-algass"></a>
##### `AssociativeAlgebra< R, n | Q >: Rng, RngIntElt, SeqEnum -> AlgAss`

```magma
Check: BoolElt                    Default: true
```

This function creates the associative structure constant algebra $A$ as returned by `Algebra< R, n | Q >`. By default, the algebra is checked on associativity, but this can be avoided by setting `Check := false`. The returned algebra is of type `AlgAss`.

<a id="constructor-constructor-quaternionalgebra-rng-rngelt-rngelt-algquat"></a>
##### `QuaternionAlgebra< K | a, b >: Rng, RngElt, RngElt -> AlgQuat`

This function creates the quaternion algebra $A$ over the field $K$ on generators $x$ and $y$ with relations $x^2 = a$, $y^2 = b$, and $xy = -yx$.

<a id="constructor-constructor-liealgebra-rng-rngintelt-seqenum-alglie"></a>
##### `LieAlgebra< R, n | Q >: Rng, RngIntElt, SeqEnum -> AlgLie`

```magma
Check: BoolElt                    Default: true
```

This function creates the Lie structure constant algebra $A$ as returned by `Algebra< R, n | Q >`. By default, the algebra is checked to be a Lie algebra, but this can be avoided by setting `Check := false`. The returned algebra is of type `AlgLie`.

<a id="function-liealgebra-algass"></a>
##### `LieAlgebra(A): AlgAss -> AlgLie`

Given an associative algebra $A$, create the Lie algebra generated by the elements in $L$ using the induced Lie product $(x,y) \rightarrow x*y - y*x$.

<a id="function-groupalgebra-rng-grp"></a>
##### `GroupAlgebra(R, G): Rng, Grp -> AlgGrp`

Given a ring $R$ and a group $G$ construct the group algebra $R[G]$ of dimension $|G|$ over $R$.

<a id="function-matrixalgebra-rng-rngint"></a>
##### `MatrixAlgebra(R, n): Rng, RngInt -> AlgMat`

Given a positive integer $n$ and a ring $R$, create the full matrix algebra $M_n(R)$ of dimension $n^2$ over $R$.

#### Construction of an Element of a General Algebra

The construction of a generic element of an algebra varies for the different types of algebras and is therefore explained in the corresponding chapters.

<a id="function-zero-alggen"></a>
##### `Zero(A): AlgGen -> AlgGenElt`

<a id="operation-op-alggen-rngintelt"></a>
##### `A ! 0: AlgGen, RngIntElt -> AlgGenElt`

Create the zero element of the algebra $A$.

<a id="function-one-alggen"></a>
##### `One(A): AlgGen -> AlgGenElt`

<a id="operation-op-alggen-rngintelt-2"></a>
##### `A ! 1: AlgGen, RngIntElt -> AlgGenElt`

If it exists, create the identity element of the algebra $A$; otherwise an error occurs.

<a id="function-random-alggen"></a>
##### `Random(A): AlgGen -> AlgGenElt`

Given an algebra $A$ defined over a finite ring, return a random element.

### Construction of Subalgebras, Ideals, and Quotient Algebras

#### Subalgebras and Ideals

If the coefficient ring $R$ of an algebra $A$ is a Euclidean domain then one may construct submodules and ideals of $A$ in Magma.

<a id="constructor-constructor-sub-alggen-list-alggen-map"></a>
##### `sub< A | L >: AlgGen, List -> AlgGen, Map`

Create the subalgebra $S$ of the algebra $A$ that is generated by the elements defined by $L$, where $L$ is a list of one or more items of the following types:

**(a)**
An element of $A$;

**(b)**
A set or sequence of elements of $A$;

**(c)**
A subalgebra or ideal of $A$;

**(d)**
A set or sequence of subalgebras or ideals of $A$.

The constructor returns the subalgebra as an algebra of the same type as $A$. An exception are group algebras, where the subalgebra is either of type `AlgAss` or of the special type `AlgGrpSub`. As well as the subalgebra $S$ itself, the constructor returns the inclusion homomorphism $f : S \rightarrow A$.

<a id="constructor-constructor-lideal-alggen-list-alggen-map"></a>
##### `lideal< A | L >: AlgGen, List -> AlgGen, Map`

Create the left ideal $I$ of the algebra $A$ generated by the elements defined by $L$, where $L$ is a list as for the `sub` constructor above. The constructor returns the left ideal as an algebra of the same type as $A$ with the same exception for group algebras as for the `sub` constructor. As well as the left ideal $I$ itself, the constructor returns the inclusion homomorphism $f : I \rightarrow A$.

<a id="constructor-constructor-rideal-alggen-list-alggen-map"></a>
##### `rideal< A | L >: AlgGen, List -> AlgGen, Map`

Create the right ideal $I$ of the algebra $A$ generated by the elements defined by $L$, where $L$ is a list as for the `sub` constructor above. The constructor returns the right ideal as an algebra of the same type as $A$ with the same exception for group algebras as for the `sub` constructor. As well as the right ideal $I$ itself, the constructor returns the inclusion homomorphism $f : I \rightarrow A$.

<a id="constructor-constructor-ideal-alggen-list-alggen-map"></a>
##### `ideal< A | L >: AlgGen, List -> AlgGen, Map`

Create the (two-sided) ideal $I$ of the algebra $A$ generated by the elements defined by $L$, where $L$ is a list as for the `sub` constructor above. The constructor returns the right ideal as an algebra of the same type as $A$ with the same exception for group algebras as for the `sub` constructor. As well as the ideal $I$ itself, the constructor returns the inclusion homomorphism $f : I \rightarrow A$.

#### Quotient Algebras

If the coefficient ring $R$ of an algebra $A$ is a field, then quotient algebras of $A$ may also be constructed.

<a id="constructor-constructor-quo-alggen-list-alggen-map"></a>
##### `quo< A | L >: AlgGen, List -> AlgGen, Map`

Create the quotient algebra $Q = A / I$, where $I$ is the two-sided ideal of $A$ generated by the elements of $A$ specified by the list $L$, which should satisfy the same conditions as for the `sub` constructor above. The constructor returns the quotient as a structure constant algebra with degree equal to its dimension. If $A$ is known to be associative, then $Q$ is of type `AlgAss`, otherwise $Q$ is of type `AlgGen`. As well as the quotient $Q$ itself, the constructor returns the natural homomorphism $f : A \rightarrow Q$.

<a id="operation-op-div-alggen-alggen"></a>
##### `A / S: AlgGen, AlgGen -> AlgGen`

The quotient of the algebra $A$ by the (two-sided) ideal closure of its subalgebra $S$.

### Operations on Algebras and Subalgebras

#### Invariants of an Algebra

<a id="function-coefficientring-alggen"></a>
##### `CoefficientRing(A): AlgGen -> Rng`

<a id="function-coefficientfield-alggen"></a>
##### `CoefficientField(A): AlgGen -> Rng`

<a id="function-basering-alggen"></a>
##### `BaseRing(A): AlgGen -> Rng`

<a id="function-basefield-alggen"></a>
##### `BaseField(A): AlgGen -> Rng`

The coefficient ring (or base ring) over which the algebra $A$ is defined.

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

The dimension of the algebra $A$.

<a id="operation-operation-alggen-rngintelt"></a>
##### `# A: AlgGen -> RngIntElt`

The cardinality of the algebra $A$ if both $R$ and the dimension of $A$ are finite. Note that this cannot be computed if the dimension of $A$ is too large.

#### Changing Rings

<a id="function-changering-alggen-rng"></a>
##### `ChangeRing(A, S): AlgGen, Rng -> AlgGen, Map`

Given an algebra $A$ with base ring $R$, together with a ring $S$, construct the algebra $B$ with base ring $S$ obtained by coercing the coefficients of elements of $A$ into $S$, together with the homomorphism from $A$ to $B$.

This function can not be applied if $A$ is of type `AlgGrpSub`, as the parent structure of elements of $A$ is the full group algebra of which $A$ is a subalgebra.

<a id="function-changering-alggen-rng-map"></a>
##### `ChangeRing(A, S, f): AlgGen, Rng, Map -> AlgGen, Map`

Given an algebra $A$ with base ring $R$, together with a ring $S$ and a map $f: R \rightarrow S$, construct the algebra $B$ with base ring $S$ obtained by mapping the coefficients of elements of $A$ into $S$ via $f$, together with the homomorphism from $A$ to $B$.

As above, this function can not be applied if $A$ is of type `AlgGrpSub`.

#### Bases

In general, every algebra comes with a basis, corresponding to its underlying module structure. The only exception for that are group algebras in the `"Terms"` representation, where the dimension of the algebra may be too large to create vectors of that degree.

<a id="function-basiselement-alggen-rngintelt"></a>
##### `BasisElement(A, i): AlgGen, RngIntElt -> AlgGenElt`

<a id="operation-operation-alggen-rngintelt-alggenelt"></a>
##### `A . i: AlgGen, RngIntElt -> AlgGenElt`

The $i$-th basis element of the algebra $A$.

<a id="function-basis-alggen"></a>
##### `Basis(A): AlgGen -> [ AlgGenElt ]`

The basis of the algebra $A$, as a sequence of elements of $A$.

Note that if $A$ is of type `AlgGrpSub` the returned elements will be elements of the full group algebra of which $A$ is a subalgebra.

<a id="function-isindependent-alggen"></a>
##### `IsIndependent(Q): [ AlgGen ] -> BoolElt`

Given a sequence $Q$ of elements of the $R$-algebra $A$, this functions returns `true` if these elements are linearly independent over $R$; otherwise `false`.

<a id="function-extendbasis-alggen-alggen"></a>
##### `ExtendBasis(S, A): AlgGen, AlgGen -> [ AlgElt ]`

<a id="function-extendbasis-alggen-alggen-2"></a>
##### `ExtendBasis(Q, A): [ AlgGen ], AlgGen -> [ AlgElt ]`

Given an algebra $A$ and either a subalgebra $S$ of dimension $m$ of $A$ or a sequence $Q$ of $m$ linearly independent elements of $A$, return a sequence containing a basis of $A$ such that the first $m$ elements are the basis of $S$ resp. the elements in $Q$.

#### Decomposition of an Algebra

An algebra $A$ can be regarded as a (left- or right-) module for itself. If $A$ is defined over a finite field, the machinery to decompose modules over finite fields can be used to investigate the structure of the algebra $A$.

<a id="function-compositionseries-alggen"></a>
##### `CompositionSeries(A): AlgGen -> [ AlgGen ], [ AlgGen ], AlgMatElt`

Compute a composition series for the algebra $A$. The function has three return values:

**(a)**
a sequence containing the composition series as an ascending chain of subalgebras such that the successive quotients are irreducible $A$-modules;

**(b)**
a sequence containing the composition factors as structure constant algebras;

**(c)**
a transformation matrix to a basis compatible with the composition series, that is, the first basis elements form a basis of the first term of the composition series, the next extend these to a basis for the second term etc.

<a id="function-compositionfactors-alggen"></a>
##### `CompositionFactors(A): AlgGen -> [ AlgGen ]`

Compute the composition factors of a composition series for the algebra $A$. This function returns the same as the second return value of `CompositionSeries` above, but will often be very much quicker.

<a id="function-minimalleftideals-alggen"></a>
##### `MinimalLeftIdeals(A : parameters): AlgGen -> [ AlgGen ], BoolElt`

<a id="function-minimalrightideals-alggen"></a>
##### `MinimalRightIdeals(A : parameters): AlgGen -> [ AlgGen ], BoolElt`

<a id="function-minimalideals-alggen"></a>
##### `MinimalIdeals(A : parameters): AlgGen -> [ AlgGen ], BoolElt`

```magma
Limit: RngIntElt                    Default: Infinity()
```

Return the minimal left/right/two-sided ideals of $A$ (in non-decreasing size). If `Limit` is set to $n$, at most $n$ ideals are calculated and the second return value indicates whether all of the ideals were computed.

<a id="function-maximalleftideals-alggen"></a>
##### `MaximalLeftIdeals(A : parameters): AlgGen -> [ AlgGen ], BoolElt`

<a id="function-maximalrightideals-alggen"></a>
##### `MaximalRightIdeals(A : parameters): AlgGen -> [ AlgGen ], BoolElt`

<a id="function-maximalideals-alggen"></a>
##### `MaximalIdeals(A : parameters): AlgGen -> [ AlgGen ], BoolElt`

```magma
Limit: RngIntElt                    Default: Infinity()
```

Return the maximal left/right/two-sided ideals of $A$ (in non-decreasing size). If `Limit` is set to $n$, at most $n$ ideals are calculated and the second return value indicates whether all of the ideals were computed.

<a id="function-jacobsonradical-alggen"></a>
##### `JacobsonRadical(A): AlgGen -> AlgGen`

Construct the Jacobson (or nilpotent) radical of $A$, that is, the intersection of the maximal ideals of $A$ (which is equal to the intersection of the maximal left or right ideals).

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

Return `true` if the Jacobson radical of $A$ is trivial; otherwise `false`.

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

Return `true` if $A$ has no non-trivial composition factor; otherwise `false`.

<a id="example-ex-0f19c1"></a>
##### `Example: Quaternions as a Matrix Algebra (ex-0f19c1)`

We create a division algebra of dimension 4 over the rational field.

```magma
> Q := MatrixAlgebra< Rationals(), 4 |
>    [0,1,0,0, -1,0,0,0, 0,0,0,-1, 0,0,1,0],
>    [0,0,1,0, 0,0,0,1, -1,0,0,0, 0,-1,0,0]>;
> i := Q.1;
> j := Q.2;
> k := i*j;
> Dimension(Q);
4
> MinimalPolynomial( (1+i+j+k)/2 );
$.1^2 - $.1 + 1
```

Hence, the element `(1+i+j+k)/2` is integral. In fact, together with `1`, `i`, and `j` it forms a $\Z$-basis of a maximal order in `Q`. We create this maximal order as a structure constant algebra over the integers.

```magma
> a := [ Q!1, i, j, (1+i+j+k)/2 ];
> T := MatrixAlgebra(Rationals(),4) ! &cat[ Coordinates(Q,a[i]) : i in [1..4] ];
> V := RSpace(Rationals(), 4);
> C := [ V ! Coordinates(Q, a[i]*a[j]) * T^-1 : j in [1..4], i in [1..4] ];
> A := ChangeRing( Algebra< V | C >, Integers() );
> IsAssociative(A);
true
> AA := AssociativeAlgebra(A);
> AA;
Associative Algebra of dimension 4 with base ring Integer Ring
> MinimalPolynomial(AA.4);
$.1^2 - $.1 + 1
```

The so constructed maximal order is ramified at 2 and $\infty$, hence it should be simple after reducing at odd primes.

```magma
> for p in [ i : i in [1..100] | IsPrime(i) ] do
>    if not IsSimple( ChangeRing( AA, GF(p) ) ) then
>       print p;
>    end if;
> end for;
2
> CS, CF, T := CompositionSeries( ChangeRing( AA, GF(2) ) );
> T;
[1 0 1 0]
[0 1 1 0]
[0 0 1 0]
[0 0 0 1]
```

A glance at the preimages of the basis of the irreducible submodule shows the ramification of $AA$ at the prime 2.

```magma
> MinimalPolynomial(AA.1 + AA.3);
$.1^2 - 2*$.1 + 2
> MinimalPolynomial(AA.2 + AA.3);
$.1^2 + 2
```

#### Operations on Subalgebras

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

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

<a id="operation-op-eq-alggen-alggen"></a>
##### `A eq B: AlgGen, AlgGen -> BoolElt`

Returns `true` if the algebras $A$ and $B$ (having a common superalgebra) are equal; otherwise `false`.

<a id="operation-op-ne-alggen-alggen"></a>
##### `A ne B: AlgGen, AlgGen -> BoolElt`

Returns `true` if the algebras $A$ and $B$ are not equal; otherwise `false`.

<a id="operation-op-subset-alggen-alggen"></a>
##### `A subset B: AlgGen, AlgGen -> BoolElt`

Returns `true` if $A$ is a subalgebra of the algebra $B$; otherwise `false`.

<a id="operation-operation-notsubset-alggen-alggen-boolelt"></a>
##### `A notsubset B: AlgGen, AlgGen -> BoolElt`

Returns `true` if $A$ is not a subalgebra of the algebra $B$; otherwise `false`.

<a id="operation-op-meet-alggen-alggen"></a>
##### `A meet B: AlgGen, AlgGen -> AlgGen`

The intersection of the algebras $A$ and $B$, which must have a common superalgebra.

<a id="operation-op-times-alggen-alggen"></a>
##### `A * B: AlgGen, AlgGen -> AlgGen`

The algebra product $A * B$ of the algebras $A$ and $B$, which must have a common superalgebra.

<a id="operation-op-pow-alggen-rngintelt"></a>
##### `A ^ n: AlgGen, RngIntElt -> AlgGen`

The (left-normed) $n$-th power of the algebra $A$. i.e., $(( \ldots (A*A)* \ldots )*A)$.

<a id="function-morphism-alggen-alggen"></a>
##### `Morphism(A, B): AlgGen, AlgGen -> Map`

The map giving the morphism from $A$ to $B$. Either $A$ is a subalgebra of $B$, in which case the embedding of $A$ into $B$ is returned, or $B$ is a quotient algebra of $A$, in which case the natural epimorphism from $A$ onto $B$ is returned.

### Operations on Elements of an Algebra

#### Operations on Elements

<a id="operation-op-plus-alggenelt-alggenelt"></a>
##### `a + b: AlgGenElt, AlgGenElt -> AlgGenElt`

The sum of the elements $a$ and $b$ of an algebra $A$.

<a id="operation-operation-alggenelt-alggenelt"></a>
##### `- a: AlgGenElt -> AlgGenElt`

The negation of the algebra element $a$.

<a id="operation-op-minus-alggenelt-alggenelt"></a>
##### `a - b: AlgGenElt, AlgGenElt -> AlgGenElt`

The difference of the elements $a$ and $b$ of an algebra $A$.

<a id="operation-op-times-alggenelt-alggenelt"></a>
##### `a * b: AlgGenElt, AlgGenElt -> AlgGenElt`

The product of the elements $a$ and $b$ of an algebra $A$.

<a id="operation-op-times-alggenelt-rngelt"></a>
##### `a * r: AlgGenElt, RngElt -> AlgGenElt`

<a id="operation-op-times-rngelt-alggenelt"></a>
##### `r * a: RngElt, AlgGenElt -> AlgGenElt`

The product of the element $a$ of the algebra $A$ and the ring element $r \in R$, where $R$ is the coefficient ring of $A$.

<a id="operation-op-div-alggenelt-rngelt"></a>
##### `a / r: AlgGenElt, RngElt -> AlgGenElt`

The product of the element $a$ of the $R$-algebra $A$ and the ring element $1 / r \in R$, where $R$ is a field.

<a id="operation-op-pow-alggenelt-rngintelt"></a>
##### `a ^ n: AlgGenElt, RngIntElt -> AlgGenElt`

If $n$ is positive, form the (left-normed) $n$-th power $(( \ldots ((a*a)*a) \ldots )*a)$ of $a$; if the parent algebra $A$ of $a$ has an identity and $n$ is zero, return the identity; if $n < 0$ and $a$ has an inverse $a^{-1}$ in $A$, form the $n$-th power of $a^{-1}$.

<a id="function-minimalpolynomial-alggenelt"></a>
##### `MinimalPolynomial(a): AlgGenElt -> RngUPolElt`

If $R$ is a field or the integer ring, return the minimal polynomial of the algebra element $a$.

<a id="function-parent-alggenelt"></a>
##### `Parent(a): AlgGenElt -> AlgGen`

For an element $a$ in an algebra $A$ return $A$.

#### Comparisons and Membership

<a id="operation-op-eq-alggenelt-alggenelt"></a>
##### `a eq b: AlgGenElt, AlgGenElt -> BoolElt`

Returns `true` if the elements $a$ and $b$ of an algebra $A$ are equal; otherwise `false`.

<a id="operation-op-ne-alggenelt-alggenelt"></a>
##### `a ne b: AlgGenElt, AlgGenElt -> BoolElt`

Returns `true` if the elements $a$ and $b$ of an algebra $A$ are not equal; otherwise `false`.

<a id="operation-op-in-alggenelt-alggen"></a>
##### `a in A: AlgGenElt, AlgGen -> BoolElt`

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

<a id="operation-op-notin-alggenelt-alggen"></a>
##### `a notin A: AlgGenElt, AlgGen -> BoolElt`

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

#### Predicates on Elements

<a id="function-iszero-alggenelt"></a>
##### `IsZero(a): AlgGenElt -> BoolElt`

Returns `true` if the algebra element $a$ is zero; otherwise `false`.

<a id="function-isone-alggenelt"></a>
##### `IsOne(a): AlgGenElt -> BoolElt`

Returns `true` if the algebra element $a$ is the identity; otherwise `false`.

<a id="function-isminusone-alggenelt"></a>
##### `IsMinusOne(a): AlgGenElt -> BoolElt`

Returns `true` if the algebra element $a$ is the negative of the identity element; otherwise `false`.

<a id="function-isunit-alggenelt"></a>
##### `IsUnit(a): AlgGenElt -> BoolElt, AlgGenElt`

Returns `true` if the element $a$ is a unit, plus the inverse; otherwise `false`.

<a id="function-isregular-alggenelt"></a>
##### `IsRegular(a): AlgGenElt -> BoolElt`

Returns `true` if the element $a$ is regular, that is, is not a zero divisor; otherwise `false`.

<a id="function-iszerodivisor-alggenelt"></a>
##### `IsZeroDivisor(a): AlgGenElt -> BoolElt`

Returns `true` if the algebra element $a$ is a divisor of zero; otherwise `false`.

<a id="function-isidempotent-alggenelt"></a>
##### `IsIdempotent(a): AlgGenElt -> BoolElt`

Returns `true` if the element $a$ is an idempotent, i.e. if $a^2 = a$; otherwise `false`.

<a id="function-isnilpotent-alggenelt"></a>
##### `IsNilpotent(a): AlgGenElt -> BoolElt, RngIntElt`

Returns `true` if the element $a$ is nilpotent, i.e. if $a^n = 0$ for some $n \geq 0$; otherwise `false`. If `true`, the minimal $n$ such that $a^n = 0$ is returned as a second value.

## Structure Constant Algebras

- [Introduction](https://docs.magma-maths.org/Algebras/StructureConstantAlgebras/introduction.md)
- [Construction of Structure Constant Algebras and Elements](https://docs.magma-maths.org/Algebras/StructureConstantAlgebras/creation.md)
  - [Construction of a Structure Constant Algebra](https://docs.magma-maths.org/Algebras/StructureConstantAlgebras/creation.md#construction-of-a-structure-constant-algebra)
    - [`Algebra< R, n | Q : parameters >: Rng, RngIntElt, SeqEnum → AlgGen`](https://docs.magma-maths.org/Algebras/StructureConstantAlgebras/creation.md#constructor-constructor-algebra-rng-rngintelt-seqenum-alggen)
    - [`Algebra< M | Q : parameters >: ModTupRng, SeqEnum → AlgGen`](https://docs.magma-maths.org/Algebras/StructureConstantAlgebras/creation.md#constructor-constructor-algebra-modtuprng-seqenum-alggen)
    - [`Algebra< R, n | T : parameters >: Rng, RngIntElt, SeqEnum → AlgGen`](https://docs.magma-maths.org/Algebras/StructureConstantAlgebras/creation.md#constructor-constructor-algebra-rng-rngintelt-seqenum-alggen-2)
    - [`ChangeBasis(A, B): AlgGen, {[AlgGenElt]} → AlgGen`](https://docs.magma-maths.org/Algebras/StructureConstantAlgebras/creation.md#function-changebasis-alggen-alggenelt)
    - [`ChangeBasis(A, B): AlgGen, {[ModTupFldElt]} → AlgGen`](https://docs.magma-maths.org/Algebras/StructureConstantAlgebras/creation.md#function-changebasis-alggen-modtupfldelt)
    - [`ChangeBasis(A, B): AlgGen, Mtrx → AlgGen`](https://docs.magma-maths.org/Algebras/StructureConstantAlgebras/creation.md#function-changebasis-alggen-mtrx)
  - [Construction of Elements of a Structure Constant Algebra](https://docs.magma-maths.org/Algebras/StructureConstantAlgebras/creation.md#construction-of-elements-of-a-structure-constant-algebra)
    - [`elt< A | r₁, r₂, ..., rₙ >: AlgGen, RngElt, RngElt, ..., RngElt → AlgGenElt`](https://docs.magma-maths.org/Algebras/StructureConstantAlgebras/creation.md#constructor-constructor-elt-alggen-rngelt-rngelt-rngelt-alggenelt)
    - [`A ! Q: AlgGen, SeqEnum[RngElt] → AlgGenElt`](https://docs.magma-maths.org/Algebras/StructureConstantAlgebras/creation.md#operation-op-alggen-seqenum-rngelt)
    - [`BasisProduct(A, i, j): AlgGen, RngIntElt, RngIntElt → AlgGenElt`](https://docs.magma-maths.org/Algebras/StructureConstantAlgebras/creation.md#function-basisproduct-alggen-rngintelt-rngintelt)
    - [`BasisProducts(A): AlgGen → SeqEnum`](https://docs.magma-maths.org/Algebras/StructureConstantAlgebras/creation.md#function-basisproducts-alggen)
- [Operations on Structure Constant Algebras and Elements](https://docs.magma-maths.org/Algebras/StructureConstantAlgebras/creation-2.md)
  - [Operations on Structure Constant Algebras](https://docs.magma-maths.org/Algebras/StructureConstantAlgebras/creation-2.md#operations-on-structure-constant-algebras)
    - [`IsCommutative(A): AlgGen → BoolElt`](https://docs.magma-maths.org/Algebras/StructureConstantAlgebras/creation-2.md#function-iscommutative-alggen)
    - [`IsAssociative(A): AlgGen → BoolElt`](https://docs.magma-maths.org/Algebras/StructureConstantAlgebras/creation-2.md#function-isassociative-alggen)
    - [`IsLie(A): AlgGen → BoolElt`](https://docs.magma-maths.org/Algebras/StructureConstantAlgebras/creation-2.md#function-islie-alggen)
    - [`DirectSum(A, B): AlgGen, AlgGen → AlgGen`](https://docs.magma-maths.org/Algebras/StructureConstantAlgebras/creation-2.md#function-directsum-alggen-alggen)
    - [Example: Jordan Algebra from Structure Constants](https://docs.magma-maths.org/Algebras/StructureConstantAlgebras/creation-2.md#example-ex-381ebc)
  - [Indexing Elements](https://docs.magma-maths.org/Algebras/StructureConstantAlgebras/creation-2.md#indexing-elements)
    - [`a[i]: AlgGenElt, RngIntElt → RngElt`](https://docs.magma-maths.org/Algebras/StructureConstantAlgebras/creation-2.md#indexed-indexed-a-alggenelt-rngintelt-rngelt)
    - [`a[i] := r: AlgGenElt, RngIntElt, RngElt → AlgGenElt`](https://docs.magma-maths.org/Algebras/StructureConstantAlgebras/creation-2.md#literal-literal-a-i-r-alggenelt-rngintelt-rngelt-alggenelt)
  - [The Module Structure of a Structure Constant Algebra](https://docs.magma-maths.org/Algebras/StructureConstantAlgebras/creation-2.md#the-module-structure-of-a-structure-constant-algebra)
    - [`Module(A): AlgGen → ModTupRng`](https://docs.magma-maths.org/Algebras/StructureConstantAlgebras/creation-2.md#function-module-alggen)
    - [`Degree(A): AlgGen → RngIntElt`](https://docs.magma-maths.org/Algebras/StructureConstantAlgebras/creation-2.md#function-degree-alggen)
    - [`Degree(a): AlgGenElt → RngIntElt`](https://docs.magma-maths.org/Algebras/StructureConstantAlgebras/creation-2.md#function-degree-alggenelt)
    - [`ElementToSequence(a): AlgGenElt → SeqEnum`](https://docs.magma-maths.org/Algebras/StructureConstantAlgebras/creation-2.md#function-elementtosequence-alggenelt)
    - [`Eltseq(a): AlgGenElt → SeqEnum`](https://docs.magma-maths.org/Algebras/StructureConstantAlgebras/creation-2.md#function-eltseq-alggenelt)
    - [`Coordinates(S, a): AlgGen, AlgGenElt → SeqEnum`](https://docs.magma-maths.org/Algebras/StructureConstantAlgebras/creation-2.md#function-coordinates-alggen-alggenelt)
    - [`InnerProduct(a, b): AlgGenElt, AlgGenElt → RngElt`](https://docs.magma-maths.org/Algebras/StructureConstantAlgebras/creation-2.md#function-innerproduct-alggenelt-alggenelt)
    - [`Support(a): AlgGenElt → SetEnum`](https://docs.magma-maths.org/Algebras/StructureConstantAlgebras/creation-2.md#function-support-alggenelt)
  - [Homomorphisms](https://docs.magma-maths.org/Algebras/StructureConstantAlgebras/creation-2.md#homomorphisms)
    - [`hom< A -> B | Q >: AlgGen, AlgGen, [ AlgGenElt ] → Map`](https://docs.magma-maths.org/Algebras/StructureConstantAlgebras/creation-2.md#constructor-constructor-hom-alggen-alggen-alggenelt-map)
    - [`hom< A -> B | Q >: AlgGen, TupMod, [ TupModElt ] → Map`](https://docs.magma-maths.org/Algebras/StructureConstantAlgebras/creation-2.md#constructor-constructor-hom-alggen-tupmod-tupmodelt-map)
    - [Example: Real Cayley Algebra](https://docs.magma-maths.org/Algebras/StructureConstantAlgebras/creation-2.md#example-ex-fafa2a)

### Introduction

A structure constant algebra $A$ of dimension $n$ over a ring $R$ can be defined in Magma by giving the $n^3$ *structure constants* $a_{ij}^k \in R ( 1 \le i, j, k \le n)$ such that, if ${e_1, e_2, \ldots, e_n}$ is the basis of $A$, $e_i * e_j = \sum_{k = 1}^n a_{ij}^k * e_k.$ Structure constant algebras may be defined over any unital ring $R$. However, many operations require that $R$ be a Euclidean domain or even a field.

### Construction of Structure Constant Algebras and Elements

#### Construction of a Structure Constant Algebra

There are three ways in Magma to specify the structure constants for a structure constant algebra $A$ of dimension $n$. The first is to give $n^3$ ring elements, the second to identify $A$ with the module $M = R^n$ and give the products $e_i * e_j$ as elements of $M$ and the third to specify only the non-zero structure constants.

<a id="constructor-constructor-algebra-rng-rngintelt-seqenum-alggen"></a>
##### `Algebra< R, n | Q : parameters >: Rng, RngIntElt, SeqEnum -> AlgGen`

<a id="constructor-constructor-algebra-modtuprng-seqenum-alggen"></a>
##### `Algebra< M | Q : parameters >: ModTupRng, SeqEnum -> AlgGen`

```magma
Rep: MonStgElt                    Default: "Dense"
```

This function creates the structure constant algebra $A$ over the free module $M = R^n$, with standard basis ${e_1, e_2, \ldots, e_n}$, and with the structure constants $a_{ij}^k$ being given by the sequence $Q$. The sequence $Q$ can be of any of the following three forms. Note that in all cases the actual ordering of the structure constants is the same: it is only their division that varies.

**(i)**
A sequence of $n$ sequences of $n$ sequences of length $n$. The $j$-th element of the $i$-th sequence is the sequence $[ a_{ij}^1, \ldots, a_{ij}^n ]$, or the element $(a_{ij}^1, \ldots, a_{ij}^n)$ of $M$, giving the coefficients of the product $e_i * e_j$.

**(ii)**
A sequence of $n^2$ sequences of length $n$, or $n^2$ elements of $M$. Here the coefficients of $e_i * e_j$ are given by position $(i - 1)*n + j$ of $Q$.

**(iii)**
A sequence of $n^3$ elements of the ring $R$. Here the sequence elements are the structure constants themselves, with the ordering $a_{11}^1, a_{11}^2, \ldots, a_{11}^n, a_{12}^1, a_{12}^2, \ldots, a_{nn}^n$. So $a_{ij}^k$ lies in position $(i - 1)*n^2 + (j - 1)*n + k$ of $Q$.

The optional parameter `Rep` can be used to select the internal representation of the structure constants. The possible values for `Rep` are `"Dense"`, `"Sparse"`, and `"Partial"`, with the default being `"Dense"`. In the dense format, the $n^3$ structure constants are stored as $n^2$ vectors of length $n$, similarly to (ii) above. This is the best representation if most of the structure constants are non-zero. The sparse format, intended for use when most structure constants are zero, stores the positions and values of the non-zero structure constants. The partial format stores the vectors, but records for efficiency the positions of the non-zero structure constants.

<a id="constructor-constructor-algebra-rng-rngintelt-seqenum-alggen-2"></a>
##### `Algebra< R, n | T : parameters >: Rng, RngIntElt, SeqEnum -> AlgGen`

```magma
Rep: MonStgElt                    Default: "Sparse"
```

This function creates the structure constant algebra $A$ with standard basis ${e_1, e_2, \ldots, e_n}$ over $R$. The sequence $T$ contains quadruples $< i, j, k, a_{ij}^k>$ giving the non-zero structure constants. All other structure constants are defined to be 0.

As above, the optional parameter `Rep` can be used to select the internal representation of the structure constants.

<a id="function-changebasis-alggen-alggenelt"></a>
##### `ChangeBasis(A, B): AlgGen, {[AlgGenElt]} -> AlgGen`

<a id="function-changebasis-alggen-modtupfldelt"></a>
##### `ChangeBasis(A, B): AlgGen, {[ModTupFldElt]} -> AlgGen`

<a id="function-changebasis-alggen-mtrx"></a>
##### `ChangeBasis(A, B): AlgGen, Mtrx -> AlgGen`

```magma
Rep: MonStgElt                    Default: "Dense"
```

Create a new structure constant algebra $A'$, isomorphic to $A$, by recomputing the structure constants with respect to the basis $B$. The basis $B$ can be specified as a set or sequence of elements of $A$, a set or sequence of vectors, or a matrix. The second returned value is the isomorphism from $A$ to $A'$.

As above, the optional parameter `Rep` can be used to select the internal representation of the structure constants. Note that the default is dense representation, regardless of the representation used by $A$.

#### Construction of Elements of a Structure Constant Algebra

<a id="constructor-constructor-elt-alggen-rngelt-rngelt-rngelt-alggenelt"></a>
##### `elt< A | r₁, r₂, ..., rₙ >: AlgGen, RngElt, RngElt, ..., RngElt -> AlgGenElt`

Given a structure constant algebra $A$ of dimension $n$ over a ring $R$, and ring elements $r_1, r_2, \ldots, r_n \in R$ construct the element $r_1 * e_1 + r_2 * e_2 + \ldots + r_n * e_n$ of $A$.

<a id="operation-op-alggen-seqenum-rngelt"></a>
##### `A ! Q: AlgGen, SeqEnum[RngElt] -> AlgGenElt`

Given a structure constant algebra $A$ of dimension $n$ and a sequence $Q = [r_1, r_2, \ldots, r_n]$ of elements of the base ring $R$ of $A$, construct the element $r_1 * e_1 + r_2 * e_2 + \ldots + r_n * e_n$ of $A$.

<a id="function-basisproduct-alggen-rngintelt-rngintelt"></a>
##### `BasisProduct(A, i, j): AlgGen, RngIntElt, RngIntElt -> AlgGenElt`

Return the product of the $i$-th and $j$-th basis element of the algebra $A$.

<a id="function-basisproducts-alggen"></a>
##### `BasisProducts(A): AlgGen -> SeqEnum`

```magma
Rep: MonStgElt                    Default: "Dense"
```

Return the products of all basis elements of the algebra $A$.

The optional parameter `Rep` may be used to specify the format of the result. If `Rep` is set to “Dense”, the products are returned as a sequence $Q$ of $n$ sequences of $n$ elements of $A$, where $n$ is the dimension of $A$. The element $Q[i][j]$ is the product of the $i$-th and $j$-th basis elements.

If `Rep` is set to “Sparse”, the products are returned as a sequence $Q$ containing quadruples $(i,j,k,a_{ijk})$ signifying that the product of the $i$-th and $j$-th basis elements is $\sum_{k=1}^n a_{ijk} b_k$, where $b_k$ is the $k$-th basis element and $n =$ dim($A$).

### 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.

## Associative Algebras

- [Introduction](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/introduction.md)
- [Construction of Associative Algebras](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/creation.md)
  - [Construction of an Associative Structure Constant Algebra](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/creation.md#construction-of-an-associative-structure-constant-algebra)
    - [`AssociativeAlgebra< R, n | Q : parameters >: Rng, RngIntElt, SeqEnum → AlgAss`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/creation.md#constructor-constructor-associativealgebra-rng-rngintelt-seqenum-algass)
    - [`AssociativeAlgebra< M | Q : parameters >: ModTupRng, SeqEnum → AlgAss`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/creation.md#constructor-constructor-associativealgebra-modtuprng-seqenum-algass)
    - [`AssociativeAlgebra< R, n | T : parameters >: Rng, RngIntElt, SeqEnum → AlgAss`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/creation.md#constructor-constructor-associativealgebra-rng-rngintelt-seqenum-algass-2)
    - [`AssociativeAlgebra(A): AlgGen → AlgAss`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/creation.md#function-associativealgebra-alggen)
    - [`ChangeBasis(A, B): AlgAss, {[AlgAssElt]} → AlgAss`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/creation.md#function-changebasis-algass-algasselt)
    - [`ChangeBasis(A, B): AlgAss, {[ModTupFldElt]} → AlgAss`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/creation.md#function-changebasis-algass-modtupfldelt)
    - [`ChangeBasis(A, B): AlgAss, Mtrx → AlgAss`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/creation.md#function-changebasis-algass-mtrx)
  - [Associative Structure Constant Algebras from other Algebras](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/creation.md#associative-structure-constant-algebras-from-other-algebras)
    - [`Algebra(A): AlgGrp → AlgAss, Map`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/creation.md#function-algebra-alggrp)
    - [`Algebra(F, E): FldFin, FldFin → AlgAss, Map;`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/creation.md#function-algebra-fldfin-fldfin)
    - [`Algebra(F, E): FldNum, FldNum → AlgAss, Map;`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/creation.md#function-algebra-fldnum-fldnum)
    - [`AlgebraOverCenter(A): Alg → AlgAss, Map;`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/creation.md#function-algebraovercenter-alg)
- [Operations on Algebras and their Elements](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ops.md)
  - [Operations on Algebras](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ops.md#operations-on-algebras)
    - [`Centre(A): AlgAss → AlgAss`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ops.md#function-centre-algass)
    - [`Centralizer(A, S): AlgAss, AlgAss → AlgAss`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ops.md#function-centralizer-algass-algass)
    - [`Centraliser(A, S): AlgAss, AlgAss → AlgAss`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ops.md#function-centraliser-algass-algass)
    - [`Idealizer(A, B: parameters): AlgAss, AlgAss → AlgAss`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ops.md#function-idealizer-algass-algass)
    - [`Idealiser(A, B: parameters): AlgAss, AlgAss → AlgAss`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ops.md#function-idealiser-algass-algass)
    - [`LieAlgebra(A): AlgAss → AlgGen, Map`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ops.md#function-liealgebra-algass)
    - [`CommutatorModule(A, B): AlgAss, AlgAss → ModTupRng`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ops.md#function-commutatormodule-algass-algass)
    - [`CommutatorIdeal(A, B): AlgAss, AlgAss → AlgAss`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ops.md#function-commutatorideal-algass-algass)
    - [`LeftAnnihilator(A, B): AlgAss, AlgAss → AlgAss, AlgAss`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ops.md#function-leftannihilator-algass-algass)
    - [`RightAnnihilator(A, B): AlgAss, AlgAss → AlgAss, AlgAss`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ops.md#function-rightannihilator-algass-algass)
    - [Example: Lie Algebra sl3 over the Rationals](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ops.md#example-ex-28076e)
    - [`RestrictionOfScalars(A): AlgAss[FldAlg] → AlgAss, Map`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ops.md#function-restrictionofscalars)
    - [`RestrictionOfScalars(A): AlgAss[FldFun] → AlgAss, Map`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ops.md#function-restrictionofscalars-algass-fldfun)
    - [`RestrictionOfScalars(A, F): AlgAss[FldAlg], Fld → AlgAss, Map`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ops.md#function-restrictionofscalars-algass-fldalg-fld)
    - [`RestrictionOfScalars(A, F): AlgAss[FldFun], FldFunG → AlgAss, Map`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ops.md#function-restrictionofscalars-algass-fldfun-fldfung)
    - [Example: Restricting Scalars of an Algebra](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ops.md#example-ex-661f6a)
  - [Operations on Elements](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ops.md#operations-on-elements)
    - [`Centralizer(A, s): AlgAss, AlgAssElt → AlgAss`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ops.md#function-centralizer-algass-algasselt)
    - [`Centraliser(A, s): AlgAss, AlgAssElt → AlgAss`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ops.md#function-centraliser-algass-algasselt)
    - [`LieBracket(a, b): AlgAssElt, AlgAssElt → AlgAssElt`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ops.md#function-liebracket-algasselt-algasselt)
    - [`(a, b): AlgAssElt, AlgAssElt → AlgAssElt`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ops.md#literal-literal-a-b-algasselt-algasselt-algasselt)
    - [`IsScalar(a): AlgAssElt → BoolElt, RngElt`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ops.md#function-isscalar-algasselt)
    - [`RepresentationMatrix(a, M : parameters): AlgAssElt, AlgAss → AlgMatElt`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ops.md#function-representationmatrix-algasselt-algass)
  - [Representations](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ops.md#representations)
    - [`MatrixAlgebra(A): AlgAss → AlgMat`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ops.md#function-matrixalgebra-algass)
    - [`MatrixAlgebra(A, M : parameters): AlgAss, AlgAss → AlgMat, Map`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ops.md#function-matrixalgebra-algass-algass)
    - [`RegularRepresentation(A : parameters): AlgAss → AlgMat, Map`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ops.md#function-regularrepresentation-algass)
  - [Decomposition of an Algebra](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ops.md#decomposition-of-an-algebra)
    - [`JacobsonRadical(A): AlgAssV → AlgAssV`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ops.md#function-jacobsonradical-algassv)
    - [Example: Jacobson Radical of a Group Algebra](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ops.md#example-ex-564d9d)
    - [`DirectSumDecomposition(A): AlgAssV → [ AlgAssV ], [ AlgAssVElt ]`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ops.md#function-directsumdecomposition-algassv)
    - [`IndecomposableSummands(A): AlgAssV → [ AlgAssV ], [ AlgAssVElt ]`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ops.md#function-indecomposablesummands-algassv)
    - [`CentralIdempotents(A): AlgAssV → SeqEnum, SeqEnum`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ops.md#function-centralidempotents-algassv)
    - [Example: Central Idempotents of a Group Algebra](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ops.md#example-ex-4239e7)
- [Orders](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md)
  - [Construction of Orders](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#construction-of-orders)
    - [`Order(R, S): Rng, SeqEnum[AlgAssVElt] → AlgAssVOrd`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-order-rng-seqenum-algassvelt)
    - [`Order(R, S): RngFunOrd, SeqEnum[AlgAssVElt[FldFunG]] → AlgAssVOrd`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-order-rngfunord-seqenum-algassvelt-fldfung)
    - [`Order(S): SeqEnum[AlgAssVElt[FldAlg]] → AlgAssVOrd`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-order-seqenum-algassvelt-fldalg)
    - [`Order(S): SeqEnum[AlgAssVElt[FldFun]] → AlgAssVOrd`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-order-seqenum-algassvelt-fldfun)
    - [`Order(S, I): SeqEnum[AlgAssVElt[FldAlg]], SeqEnum[RngOrdFracIdl] → AlgAssVOrd`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-order-seqenum-algassvelt-fldalg-seqenum-rngordfracidl)
    - [`Order(S, I): SeqEnum[AlgAssVElt[FldFunG]], SeqEnum[RngFunOrdIdl] → AlgAssVOrd`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-order-seqenum-algassvelt-fldfung-seqenum-rngfunordidl)
    - [`Order(A, m, I): AlgAssV[FldOrd], AlgMatElt[FldOrd], SeqEnum[RngOrdFracIdl] → AlgAssVOrd`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-order-algassv-fldord-algmatelt-fldord-seqenum-rngordfracidl)
    - [`Order(A, m, I): AlgAssV[FldNum], AlgMatElt[FldNum], SeqEnum[RngOrdFracIdl] → AlgAssVOrd, Map`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-order-algassv-fldnum-algmatelt-fldnum-seqenum-rngordfracidl)
    - [`Order(A, m, I): AlgAssV[FldFun], AlgMatElt[FldFun], SeqEnum[RngFunOrdIdl] → AlgAssVOrd`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-order-algassv-fldfun-algmatelt-fldfun-seqenum-rngfunordidl)
    - [`Order(A, pm): AlgAssV[FldOrd], PMat → AlgAssVOrd`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-order-algassv-fldord-pmat)
    - [`Order(A, pm): AlgAssV[FldNum], PMat → AlgAssVOrd, Map`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-order-algassv-fldnum-pmat)
    - [`Order(A, pm): AlgAssV[FldFun], PMat → AlgAssVOrd`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-order-algassv-fldfun-pmat)
    - [Example: Three Ways to Create an Order](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#example-ex-5ab68c)
    - [Example: Order in a Cyclic Algebra](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#example-ex-1d14f4)
    - [`MaximalOrder(A): AlgAssV[FldRat] → AlgAssVOrd`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-maximalorder-algassv-fldrat)
    - [`MaximalOrder(A): AlgAssV[FldAlg] → AlgAssVOrd`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-maximalorder-algassv-fldalg)
    - [`MaximalOrder(O): AlgAssVOrd[RngInt] → AlgAssVOrd`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-maximalorder-algassvord-rngint)
    - [`MaximalOrder(O): AlgAssVOrd[RngOrd] → AlgAssVOrd`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-maximalorder-algassvord-rngord)
    - [`MaximalOrderFinite(A): AlgAssV[FldFunRat] → AlgAssVOrd`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-maximalorderfinite-algassv-fldfunrat)
    - [`MaximalOrderInfinite(A): AlgAssV[FldFunRat] → AlgAssVOrd`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-maximalorderinfinite-algassv-fldfunrat)
    - [`MaximalOrderFinite(A): AlgAssV[FldFun] → AlgAssVOrd`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-maximalorderfinite-algassv-fldfun)
    - [`MaximalOrderInfinite(A): AlgAssV[FldFun] → AlgAssVOrd`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-maximalorderinfinite-algassv-fldfun)
    - [`MaximalOrder(O): AlgAssVOrd[RngUPol] → AlgAssVOrd`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-maximalorder-algassvord-rngupol)
    - [`MaximalOrder(O): AlgAssVOrd[RngVal] → AlgAssVOrd`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-maximalorder-algassvord-rngval)
    - [`MaximalOrder(O): AlgAssVOrd[RngFunOrd] → AlgAssVOrd`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-maximalorder-algassvord-rngfunord)
    - [Example: Maximal Order of a Matrix Algebra](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#example-ex-9fdfa9)
    - [Example: Maximal Order over a Number Field](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#example-ex-23b948)
    - [`RestrictionOfScalars(O): AlgAssVOrd[RngOrd] → AlgAssVOrd, Map`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-restrictionofscalars-algassvord-rngord)
    - [`RestrictionOfScalars(O): AlgAssVOrd[RngFunOrd] → AlgAssVOrd, Map`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-restrictionofscalars-algassvord-rngfunord)
    - [`RestrictionOfScalars(O, C): AlgAssVOrd[RngOrd], Rng → AlgAssVOrd, Map`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-restrictionofscalars-algassvord-rngord-rng)
    - [`RestrictionOfScalars(O, C): AlgAssVOrd[RngFunOrd], Rng → AlgAssVOrd, Map`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-restrictionofscalars-algassvord-rngfunord-rng)
    - [Example: Restriction of Scalars for an Order](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#example-ex-bbfaa2)
  - [Attributes](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#attributes)
    - [`BaseRing(O): AlgAssVOrd → Rng`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-basering-algassvord)
    - [`CoefficientRing(O): AlgAssVOrd → Rng`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-coefficientring-algassvord)
    - [`Algebra(O): AlgAssVOrd → AlgAssV`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-algebra-algassvord)
    - [`Degree(O): AlgAssVOrd → RngIntElt`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-degree-algassvord)
    - [`Dimension(O): AlgAssVOrd → RngIntElt`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-dimension-algassvord)
    - [`Discriminant(O): AlgAssVOrd[RngOrd] → RngOrdIdl`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-discriminant-algassvord-rngord)
    - [`Discriminant(O): AlgAssVOrd[RngFunOrd] → RngOrdIdl`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-discriminant-algassvord-rngfunord)
    - [`Discriminant(O): AlgAssVOrd[RngInt] → RngIntElt`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-discriminant-algassvord-rngint)
    - [`Discriminant(O): AlgAssVOrd[RngUPol] → RngIntElt`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-discriminant-algassvord-rngupol)
    - [`Discriminant(O): AlgAssVOrd[RngVal] → RngIntElt`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-discriminant-algassvord-rngval)
    - [`FactoredDiscriminant(O): AlgAssVOrd[RngOrd] → [Tup]`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-factoreddiscriminant-algassvord-rngord)
    - [`MultiplicationTable(O): AlgAssVOrd → SeqEnum`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-multiplicationtable-algassvord)
    - [`Module(O): AlgAssVOrd[RngOrd] → PMat`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-module-algassvord-rngord)
    - [`TraceZeroSubspace(O): AlgAssVOrd → SeqEnum`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-tracezerosubspace-algassvord)
  - [Bases of Orders](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#bases-of-orders)
    - [`PseudoBasis(O): AlgAssVOrd[RngOrd] → SeqEnum`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-pseudobasis-algassvord-rngord)
    - [`PseudoBasis(O): AlgAssVOrd[RngFunOrd] → SeqEnum`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-pseudobasis-algassvord-rngfunord)
    - [`PseudoMatrix(O): AlgAssVOrd[RngOrd] → PMat`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-pseudomatrix-algassvord-rngord)
    - [`PseudoMatrix(O): AlgAssVOrd[RngFunOrd] → PMat`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-pseudomatrix-algassvord-rngfunord)
    - [`Basis(O): AlgAssVOrd → SeqEnum`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-basis-algassvord)
    - [`ZBasis(O): AlgAssVOrd[RngOrd] → [AlgAssVElt]`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-zbasis-algassvord-rngord)
    - [`ZBasis(O): AlgAssVOrd[RngFunOrd] → [AlgAssVElt]`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-zbasis-algassvord-rngfunord)
    - [`Generators(O): AlgAssVOrd → [AlgAssVElt]`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-generators-algassvord)
    - [`LocalBasis(O, p): AlgAssVOrd, RngOrdIdl → [AlgAssElt]`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-localbasis-algassvord-rngordidl)
    - [Example: Pseudobasis of an Order](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#example-ex-1fcab8)
  - [Predicates](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#predicates)
    - [`O1 eq O2: AlgAssVOrd, AlgAssVOrd → BoolElt`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#operation-op-eq-algassvord-algassvord)
    - [`x in O: AlgAssVElt, AlgAssVOrd → BoolElt`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#operation-op-in-algassvelt-algassvord)
    - [`x notin O: AlgAssVElt, AlgAssVOrd → BoolElt`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#operation-op-notin-algassvelt-algassvord)
  - [Operations with Orders](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#operations-with-orders)
    - [`Adjoin(O, x): AlgAssVOrd, AlgAssVElt → AlgAssVOrd`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-adjoin-algassvord-algassvelt)
    - [`Adjoin(O, x, I): AlgAssVOrd, AlgAssVElt, RngOrdFracIdl → AlgAssVOrd`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#function-adjoin-algassvord-algassvelt-rngordfracidl)
    - [`O1 + O2: AlgAssVOrd[RngOrd], AlgAssVOrd[RngOrd] → AlgAssVOrd`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#operation-op-plus-algassvord-rngord-algassvord-rngord)
    - [`O1 meet O2: AlgAssVOrd[RngOrd], AlgAssVOrd[RngOrd] → AlgAssVOrd`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#operation-op-meet-algassvord-rngord-algassvord-rngord)
    - [`O ^ x: AlgAssVOrd, AlgAssElt → AlgAssvOrd`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#operation-op-pow-algassvord-algasselt)
    - [Example: Sums of Orders and Adjoining Elements](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#example-ex-9c61c8)
- [Elements of Orders](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/elements.md)
  - [Construction of Elements](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/elements.md#construction-of-elements)
    - [`O ! 0: AlgAssVOrd, RngIntElt → AlgAssVOrdElt`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/elements.md#operation-op-algassvord-rngintelt)
    - [`Zero(O): AlgAssVOrd → AlgAssVOrdElt`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/elements.md#function-zero-algassvord)
    - [`O ! 1: AlgAssVOrd, RngIntElt → AlgAssVOrdElt`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/elements.md#operation-op-algassvord-rngintelt-2)
    - [`One(O): AlgAssVOrd → AlgAssVOrdElt`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/elements.md#function-one-algassvord)
    - [`O . i: AlgAssVOrd, RngIntElt → AlgAssVElt`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/elements.md#operation-operation-algassvord-rngintelt-algassvelt)
    - [`O ! x: AlgAssVOrd, Any → AlgAssVOrdElt`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/elements.md#operation-op-algassvord-any)
  - [Arithmetic of Elements](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/elements.md#arithmetic-of-elements)
    - [`x + y: AlgAssVOrdElt, AlgAssVOrdElt → AlgAssVOrdElt`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/elements.md#operation-op-plus-algassvordelt-algassvordelt)
    - [`x - y: AlgAssVOrdElt, AlgAssVOrdElt → AlgAssVOrdElt`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/elements.md#operation-op-minus-algassvordelt-algassvordelt)
    - [`- x: AlgAssVOrdElt → AlgAssVOrdElt`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/elements.md#operation-operation-algassvordelt-algassvordelt)
    - [`x * y: AlgAssVOrdElt, AlgAssVOrdElt → AlgAssVOrdElt`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/elements.md#operation-op-times-algassvordelt-algassvordelt)
    - [`u * c: AlgAssVOrdElt, RngElt → AlgAssVOrdElt`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/elements.md#operation-op-times-algassvordelt-rngelt)
    - [`c * u: RngElt, AlgAssVOrdElt → AlgAssVOrdElt`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/elements.md#operation-op-times-rngelt-algassvordelt)
    - [`x / y: AlgAssVOrdElt, AlgAssVOrdElt → AlgAssVElt`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/elements.md#operation-op-div-algassvordelt-algassvordelt)
    - [`x div y: AlgAssVOrdElt, AlgAssVOrdElt → AlgAssVOrdElt`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/elements.md#operation-operation-div-algassvordelt-algassvordelt-algassvordelt)
    - [`x ^ n: AlgAssVOrdElt, RngIntElt → AlgAssVOrdElt`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/elements.md#operation-op-pow-algassvordelt-rngintelt)
  - [Predicates on Elements](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/elements.md#predicates-on-elements)
    - [`x eq y: AlgAssVOrdElt, AlgAssVOrdElt → BoolElt`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/elements.md#operation-op-eq-algassvordelt-algassvordelt)
    - [`x ne y: AlgAssVOrdElt, AlgAssVOrdElt → BoolElt`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/elements.md#operation-op-ne-algassvordelt-algassvordelt)
    - [`IsZero(x): AlgAssVOrdElt → BoolElt`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/elements.md#function-iszero-algassvordelt)
    - [`IsUnit(a): AlgAssVOrdElt → BoolElt`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/elements.md#function-isunit-algassvordelt)
    - [`IsScalar(x): AlgAssVOrdElt → BoolElt, RngElt`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/elements.md#function-isscalar-algassvordelt)
  - [Other Operations with Elements](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/elements.md#other-operations-with-elements)
    - [`ElementToSequence(x): AlgAssVOrdElt → SeqEnum`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/elements.md#function-elementtosequence-algassvordelt)
    - [`Eltseq(x): AlgAssVOrdElt → SeqEnum`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/elements.md#function-eltseq-algassvordelt)
    - [`Norm(x): AlgAssVOrdElt → RngElt`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/elements.md#function-norm-algassvordelt)
    - [`Trace(x): AlgAssVOrdElt → RngElt`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/elements.md#function-trace-algassvordelt)
    - [`LeftRepresentationMatrix(e): AlgAssVOrdElt → AlgMatElt`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/elements.md#function-leftrepresentationmatrix-algassvordelt)
    - [`RightRepresentationMatrix(e): AlgAssVOrdElt → AlgMatElt`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/elements.md#function-rightrepresentationmatrix-algassvordelt)
    - [`RepresentationMatrix(a): AlgAssVOrdElt → AlgMatElt`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/elements.md#function-representationmatrix-algassvordelt)
    - [`CharacteristicPolynomial(x): AlgAssVOrdElt → RngUPolElt`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/elements.md#function-characteristicpolynomial-algassvordelt)
    - [`MinimalPolynomial(x): AlgAssVOrdElt → RngUPolElt`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/elements.md#function-minimalpolynomial-algassvordelt)
- [Ideals of Orders](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md)
  - [Construction of Ideals](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#construction-of-ideals)
    - [`lideal<O | E>: AlgAssVOrd, [AlgAssVOrdElt] → AlgAssVOrdIdl`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#constructor-constructor-lideal-algassvord-algassvordelt-algassvordidl)
    - [`rideal<O | E>: AlgAssVOrd, [AlgAssVOrdElt] → AlgAssVOrdIdl`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#constructor-constructor-rideal-algassvord-algassvordelt-algassvordidl)
    - [`ideal<O | E>: AlgAssVOrd, [AlgAssVOrdElt] → AlgAssVOrdIdl`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#constructor-constructor-ideal-algassvord-algassvordelt-algassvordidl)
    - [`lideal<O | M>: AlgAssVOrd, PMat → AlgAssVOrdIdl`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#constructor-constructor-lideal-algassvord-pmat-algassvordidl)
    - [`lideal<O | M>: AlgAssVOrd, Mtrx → AlgAssVOrdIdl`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#constructor-constructor-lideal-algassvord-mtrx-algassvordidl)
    - [`rideal<O | M>: AlgAssVOrd, PMat → AlgAssVOrdIdl`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#constructor-constructor-rideal-algassvord-pmat-algassvordidl)
    - [`rideal<O | M>: AlgAssVOrd, Mtrx → AlgAssVOrdIdl`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#constructor-constructor-rideal-algassvord-mtrx-algassvordidl)
    - [`ideal<O | M>: AlgAssVOrd, PMat → AlgAssVOrdIdl`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#constructor-constructor-ideal-algassvord-pmat-algassvordidl)
    - [`ideal<O | M>: AlgAssVOrd, Mtrx → AlgAssVOrdIdl`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#constructor-constructor-ideal-algassvord-mtrx-algassvordidl)
    - [`O * e: AlgAssVOrd, RngElt → AlgAssVOrdIdl`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#operation-op-times-algassvord-rngelt)
    - [`e * O: RngElt, AlgAssVOrd → AlgAssVOrdIdl`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#operation-op-times-rngelt-algassvord)
  - [Attributes of Ideals](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#attributes-of-ideals)
    - [`Order(I): AlgAssVOrdIdl → AlgAssVOrd`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#function-order-algassvordidl)
    - [`Algebra(I): AlgAssVOrdIdl → AlgAssV`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#function-algebra-algassvordidl)
    - [`LeftOrder(I): AlgAssVOrdIdl → AlgAssVOrd`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#function-leftorder-algassvordidl)
    - [`RightOrder(I): AlgAssVOrdIdl → AlgAssVOrd`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#function-rightorder-algassvordidl)
    - [`ArithmeticRadical(O, p): AlgAssVOrd[RngOrd], RngOrdIdl → AlgAssVOrdIdl`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#function-arithmeticradical-algassvord-rngord-rngordidl)
    - [`ArithmeticRadical(O, p): AlgQuat, RngElt → AlgQuatOrdIdl`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#function-arithmeticradical-algquat-rngelt)
    - [`RadicalIdealizer(O, p): AlgAssVOrd[RngOrd], RngOrdIdl → AlgAssVOrd`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#function-radicalidealizer-algassvord-rngord-rngordidl)
    - [`RadicalIdealizer(O, p): AlgQuat, RngElt → AlgQuat`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#function-radicalidealizer-algquat-rngelt)
    - [`Neighbors(I, p): AlgAssVOrdIdl, RngOrdIdl → SeqEnum[AlgAssVOrdIdl]`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#function-neighbors-algassvordidl-rngordidl)
    - [`Neighbors(I, p): AlgQuatOrdIdl, RngInt → SeqEnum[AlgQuatOrdIdl]`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#function-neighbors-algquatordidl-rngint)
    - [`ElementsOfNorm(I, n): AlgAssVOrdIdl, RngElt → SeqEnum`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#function-elementsofnorm-algassvordidl-rngelt)
  - [Bases of Ideals](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#bases-of-ideals)
    - [`Denominator(I): AlgAssVOrdIdl → RngElt`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#function-denominator-algassvordidl)
    - [`PseudoBasis(I): AlgAssVOrdIdl[RngOrd] → SeqEnum`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#function-pseudobasis-algassvordidl-rngord)
    - [`PseudoMatrix(I): AlgAssVOrdIdl[RngOrd] → PMat`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#function-pseudomatrix-algassvordidl-rngord)
    - [`PseudoMatrix(I): AlgAssVOrdIdl[RngFunOrd] → PMat`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#function-pseudomatrix-algassvordidl-rngfunord)
    - [`Basis(I): AlgAssVOrdIdl → SeqEnum`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#function-basis-algassvordidl)
    - [`BasisMatrix(I): AlgAssVOrdIdl → AlgMatElt`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#function-basismatrix-algassvordidl)
    - [`ZBasis(I): AlgAssVOrdIdl[RngOrd] → [AlgAssVOrdElt]`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#function-zbasis-algassvordidl-rngord)
    - [`Generators(I): AlgAssVOrdIdl[RngOrd] → [AlgAssVOrdElt]`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#function-generators-algassvordidl-rngord)
    - [`LocalBasis(I, p): AlgAssVOrdIdl, RngOrdIdl → [AlgAssElt]`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#function-localbasis-algassvordidl-rngordidl)
    - [`PseudoBasis(I, R): AlgAssVOrdIdl[RngOrd], Str → SeqEnum`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#function-pseudobasis-algassvordidl-rngord-str)
    - [`PseudoMatrix(I, R): AlgAssVOrdIdl[RngOrd], Str → PMat`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#function-pseudomatrix-algassvordidl-rngord-str)
    - [`Basis(I, R): AlgAssVOrdIdl, Str → SeqEnum`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#function-basis-algassvordidl-str)
    - [`BasisMatrix(I, R): AlgAssVOrdIdl, Str → AlgMatElt`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#function-basismatrix-algassvordidl-str)
  - [Arithmetic for Ideals](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#arithmetic-for-ideals)
    - [`I + J: AlgAssVOrdIdl, AlgAssVOrdIdl → AlgAssVOrdIdl`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#operation-op-plus-algassvordidl-algassvordidl)
    - [`I * J: AlgAssVOrdIdl, AlgAssVOrdIdl → AlgAssVOrdIdl, AlgAssVOrdIdl`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#operation-op-times-algassvordidl-algassvordidl)
    - [`I * J: AlgAssVOrdIdl[RngOrd], AlgAssVOrdIdl[RngOrd] → AlgAssVOrdIdl, AlgAssVOrdIdl`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#operation-op-times-algassvordidl-rngord-algassvordidl-rngord)
    - [`a * I: RngElt, AlgAssVOrdIdl → AlgAssVOrdIdl`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#operation-op-times-rngelt-algassvordidl)
    - [`I * a: AlgAssVOrdIdl, RngElt → AlgAssVOrdIdl`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#operation-op-times-algassvordidl-rngelt)
    - [`a * I: RngElt, AlgQuatOrdIdl → AlgQuatOrdIdl`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#operation-op-times-rngelt-algquatordidl)
    - [`I * a: AlgQuatOrdIdl, RngElt → AlgQuatOrdIdl`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#operation-op-times-algquatordidl-rngelt)
    - [`A * I: RngOrdFracIdl, AlgAssVOrdIdl[RngOrd] → AlgAssVOrdIdl`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#operation-op-times-rngordfracidl-algassvordidl-rngord)
    - [`I * A: RngOrdFracIdl, AlgAssVOrdIdl[RngOrd] → AlgAssVOrdIdl`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#operation-op-times-rngordfracidl-algassvordidl-rngord-2)
    - [`Colon(J, I): AlgAssVOrdIdl[RngOrd], AlgAssVOrdIdl[RngOrd] → PMat`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#function-colon-algassvordidl-rngord-algassvordidl-rngord)
    - [`MultiplicatorRing(I): AlgAssVOrdIdl → AlgAssVOrd`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#function-multiplicatorring-algassvordidl)
  - [Predicates on Ideals](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#predicates-on-ideals)
    - [`IsLeftIdeal(I): AlgAssVOrdIdl → BoolElt`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#function-isleftideal-algassvordidl)
    - [`IsRightIdeal(I): AlgAssVOrdIdl → BoolElt`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#function-isrightideal-algassvordidl)
    - [`IsTwoSidedIdeal(I): AlgAssVOrdIdl → BoolElt`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#function-istwosidedideal-algassvordidl)
    - [`I eq J: AlgAssVOrdIdl, AlgAssVOrdIdl → BoolElt`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#operation-op-eq-algassvordidl-algassvordidl)
    - [`I subset J: AlgAssVOrdIdl, AlgAssVOrdIdl → BoolElt`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#operation-op-subset-algassvordidl-algassvordidl)
    - [`a in I: AlgAssVElt, AlgAssVOrdIdl → BoolElt`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#operation-op-in-algassvelt-algassvordidl)
    - [`a notin I: AlgAssVElt, AlgAssVOrdIdl → BoolElt`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#operation-op-notin-algassvelt-algassvordidl)
  - [Other Operations on Ideals](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#other-operations-on-ideals)
    - [`Norm(I): AlgAssVOrdIdl[RngOrd] → RngOrdIdl`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#function-norm-algassvordidl-rngord)
    - [Example: One-Sided Ideals of an Order](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ideals.md#example-ex-d618e7)
- [Bibliography](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/bibliography.md)

### Introduction

Defining an algebra by structure constants gives a very general set-up, but many structural concepts are restricted to associative algebras. Therefore, Magma provides a special type for structure constant algebras which are known to be associative.

### Construction of Associative Algebras

#### Construction of an Associative Structure Constant Algebra

The construction of an associative structure constant algebra is identical to that of a general structure constant algebra, with the exception that an additional parameter is provided which may be used to avoid checking that the algebra is associative.

<a id="constructor-constructor-associativealgebra-rng-rngintelt-seqenum-algass"></a>
##### `AssociativeAlgebra< R, n | Q : parameters >: Rng, RngIntElt, SeqEnum -> AlgAss`

<a id="constructor-constructor-associativealgebra-modtuprng-seqenum-algass"></a>
##### `AssociativeAlgebra< M | Q : parameters >: ModTupRng, SeqEnum -> AlgAss`

```magma
Check: BoolElt                      Default: true
Rep  : MonStgElt                    Default: "Dense"
```

This function creates the associative structure constant algebra $A$ over the free module $M = R^n$, with standard basis ${e_1, e_2, \ldots, e_n}$, and with the structure constants $a_{ij}^k$ being given by the sequence $Q$. The sequence $Q$ can be of any of the following three forms. Note that in all cases the actual ordering of the structure constants is the same: it is only their division that varies.

**(i)**
A sequence of $n$ sequences of $n$ sequences of length $n$. The $j$-th element of the $i$-th sequence is the sequence $[ a_{ij}^1, \ldots, a_{ij}^n ]$, or the element $(a_{ij}^1, \ldots, a_{ij}^n)$ of $M$, giving the coefficients of the product $e_i * e_j$.

**(ii)**
A sequence of $n^2$ sequences of length $n$, or $n^2$ elements of $M$. Here the coefficients of $e_i * e_j$ are given by position $(i - 1)*n + j$ of $Q$.

**(iii)**
A sequence of $n^3$ elements of the ring $R$. Here the sequence elements are the structure constants themselves, $a_{11}^1, a_{11}^2, \ldots, a_{11}^n, a_{12}^1, a_{12}^2, \ldots, a_{nn}^n$. So $a_{ij}^k$ lies in position $(i - 1)*n^2 + (j - 1)*n + k$ of $Q$.

By default the algebra is checked to be associative; this can be overruled by setting the parameter `Check` to `false`.

The optional parameter `Rep` can be used to select the internal representation of the structure constants. The possible values for `Rep` are `"Dense"`, `"Sparse"`, and `"Partial"`, with the default being `"Dense"`. In the dense format, the $n^3$ structure constants are stored as $n^2$ vectors of length $n$, similarly to (ii) above. This is the best representation if most of the structure constants are non-zero. The sparse format, intended for use when most structure constants are zero, stores the positions and values of the non-zero structure constants. The partial format stores the vectors, but records for efficiency the positions of the non-zero structure constants.

<a id="constructor-constructor-associativealgebra-rng-rngintelt-seqenum-algass-2"></a>
##### `AssociativeAlgebra< R, n | T : parameters >: Rng, RngIntElt, SeqEnum -> AlgAss`

```magma
Check: BoolElt                      Default: true
Rep  : MonStgElt                    Default: "Sparse"
```

This function creates the associative structure constant algebra $A$ with standard basis ${e_1, e_2, \ldots, e_n}$ over $R$. The sequence $T$ contains quadruples $< i, j, k, a_{ij}^k>$ giving the non-zero structure constants. All other structure constants are defined to be 0.

The optional parameters are as above.

<a id="function-associativealgebra-alggen"></a>
##### `AssociativeAlgebra(A): AlgGen -> AlgAss`

Given a structure constant algebra $A$ of type `AlgGen`, construct an isomorphic associative structure constant algebra of type `AlgAss`. If it is not known whether or not $A$ is associative, this will be checked and an error occurs if it is not. The elements of the resulting algebra can be coerced into $A$ and vice versa.

<a id="function-changebasis-algass-algasselt"></a>
##### `ChangeBasis(A, B): AlgAss, {[AlgAssElt]} -> AlgAss`

<a id="function-changebasis-algass-modtupfldelt"></a>
##### `ChangeBasis(A, B): AlgAss, {[ModTupFldElt]} -> AlgAss`

<a id="function-changebasis-algass-mtrx"></a>
##### `ChangeBasis(A, B): AlgAss, Mtrx -> AlgAss`

```magma
Rep: MonStgElt                    Default: "Dense"
```

Create a new associative structure constant algebra $A'$, isomorphic to $A$, by recomputing the structure constants with respect to the basis $B$. The basis $B$ can be specified as a set or sequence of elements of $A$, a set or sequence of vectors, or a matrix. The second returned value is the isomorphism from $A$ to $A'$.

As above, the optional parameter `Rep` can be used to select the internal representation of the structure constants. Note that the default is dense representation, regardless of the representation used by $A$.

#### Associative Structure Constant Algebras from other Algebras

<a id="function-algebra-alggrp"></a>
##### `Algebra(A): AlgGrp -> AlgAss, Map`

If $A$ is either a group algebra of type `AlgGrp` given in vector representation or a matrix algebra of type `AlgMat`, construct the associative structure constant algebra $B$ isomorphic to $A$ together with the isomorphism $A \rightarrow B$.

<a id="function-algebra-fldfin-fldfin"></a>
##### `Algebra(F, E): FldFin, FldFin -> AlgAss, Map;`

<a id="function-algebra-fldnum-fldnum"></a>
##### `Algebra(F, E): FldNum, FldNum -> AlgAss, Map;`

Let $E$ and $F$ be either finite fields or algebraic number fields such that $E$ is a subfield of $F$. This function returns the associative algebra $A$ of dimension $[F:E]$ over $E$ which is isomorphic to $F$, together with the isomorphism from $F$ to $A$ such that the $(i-1)$-th power of the generator of $F$ over $E$ is mapped to the $i$-th basis vector of $A$.

<a id="function-algebraovercenter-alg"></a>
##### `AlgebraOverCenter(A): Alg -> AlgAss, Map;`

Given a simple algebra $A$ of type `AlgMat` or `AlgAss` with center $K$, this function returns a $K$-algebra $B$ which is $K$-isomorphic to $A$ as well as an isomorphism from $A$ to $B$.

### Operations on Algebras and their Elements

#### Operations on Algebras

<a id="function-centre-algass"></a>
##### `Centre(A): AlgAss -> AlgAss`

The centre of the associative algebra $A$.

<a id="function-centralizer-algass-algass"></a>
##### `Centralizer(A, S): AlgAss, AlgAss -> AlgAss`

<a id="function-centraliser-algass-algass"></a>
##### `Centraliser(A, S): AlgAss, AlgAss -> AlgAss`

The centralizer of the subalgebra $S$ of the associative algebra $A$, that is, the subalgebra of $A$ commuting elementwise with $S$.

<a id="function-idealizer-algass-algass"></a>
##### `Idealizer(A, B: parameters): AlgAss, AlgAss -> AlgAss`

<a id="function-idealiser-algass-algass"></a>
##### `Idealiser(A, B: parameters): AlgAss, AlgAss -> AlgAss`

```magma
Side: MonStgElt                    Default: "Both"
```

Given an associative algebra $A$ and a subalgebra $B$ of $A$, compute the idealizer of $B$ in $A$, that is, the largest subalgebra of $A$ in which $B$ is an ideal. By default the two-sided idealizer, that is, the largest subalgebra in which $B$ is a two-sided ideal, is found; the left- or right-idealizer can be found by setting the parameter `Side` to `"Left"` or `"Right"` respectively.

<a id="function-liealgebra-algass"></a>
##### `LieAlgebra(A): AlgAss -> AlgGen, Map`

For an associative structure constant algebra $A$, return the structure constant algebra $L$ with product given by the Lie bracket $(a,b) \mapsto a*b - b*a$. As a second value the map identifying the elements of $A$ and $L$ is returned.

<a id="function-commutatormodule-algass-algass"></a>
##### `CommutatorModule(A, B): AlgAss, AlgAss -> ModTupRng`

Let $A$ and $B$ be subalgebras of an associative algebra with underlying module $M$. This function returns the submodule of $M$ which is spanned by the elements $[a,b] = a*b - b*a$, $a \in A, b \in B$.

<a id="function-commutatorideal-algass-algass"></a>
##### `CommutatorIdeal(A, B): AlgAss, AlgAss -> AlgAss`

For two subalgebras $A$ and $B$ of an associative algebra, return the ideal generated by all $[a,b] = a*b - b*a$, $a \in A, b \in B$.

<a id="function-leftannihilator-algass-algass"></a>
##### `LeftAnnihilator(A, B): AlgAss, AlgAss -> AlgAss, AlgAss`

For two subalgebras $A$ and $B$ of an associative algebra, return the left annihilator of $B$ in $A$; that is, the subalgebra of $A$ consisting of all elements $a$ such that $a*b = 0$ for all $b \in B$.

<a id="function-rightannihilator-algass-algass"></a>
##### `RightAnnihilator(A, B): AlgAss, AlgAss -> AlgAss, AlgAss`

For two subalgebras $A$ and $B$ of an associative algebra, return the right annihilator of $B$ in $A$; that is, the subalgebra of $A$ consisting of all elements $a$ such that $b*a = 0$ for all $b \in B$.

<a id="example-ex-28076e"></a>
##### `Example: Lie Algebra sl3 over the Rationals (ex-28076e)`

We create the Lie algebra $sl_3({\mathbb{Q}})$ as a structure constant algebra. First, we construct $gl_3({\mathbb{Q}})$ from the full matrix algebra $M_3({\mathbb{Q}})$ and get $sl_3({\mathbb{Q}})$ as the derived algebra of $gl_3({\mathbb{Q}})$.

```magma
> gl3 := LieAlgebra(Algebra(MatrixRing(Rationals(), 3)));
> sl3 := gl3 * gl3;
> sl3;
Lie Algebra of dimension 8 with base ring Rational Field
```

Let’s see how the first basis element acts.

```magma
> for i in [1..8] do
>     print sl3.i * sl3.1;
> end for;
(0 0 0 0 0 0 0 0)
( 0 -1  0  0  0  0  0  0)
( 0  0 -2  0  0  0  0  0)
(0 0 0 1 0 0 0 0)
(0 0 0 0 0 0 0 0)
( 0  0  0  0  0 -1  0  0)
(0 0 0 0 0 0 2 0)
(0 0 0 0 0 0 0 1)
```

Since it acts diagonally, this element lies in a Cartan subalgebra. The next candidate seems to be the fifth basis element.

```magma
> for i in [1..8] do
>     print sl3.i * sl3.5;
> end for;
(0 0 0 0 0 0 0 0)
(0 1 0 0 0 0 0 0)
( 0  0 -1  0  0  0  0  0)
( 0  0  0 -1  0  0  0  0)
(0 0 0 0 0 0 0 0)
( 0  0  0  0  0 -2  0  0)
(0 0 0 0 0 0 1 0)
(0 0 0 0 0 0 0 2)
```

This also acts diagonally and commutes with `sl3.1`, hence we have luckily found a full Cartan algebra in $sl_3(\Q)$. We can now easily work out the root system. Obviously the root spaces correspond to the pairs `(sl3.2, sl3.4)`, `(sl3.3, sl3.7)`, and `(sl3.6, sl3.8)`. The product of a positive root with its negative should lie in the Cartan algebra.

```magma
> sl3.2*sl3.4;
( 1  0  0  0 -1  0  0  0)
> sl3.3*sl3.7;
(1 0 0 0 0 0 0 0)
> sl3.6*sl3.8;
(0 0 0 0 1 0 0 0)
```

Clearly some choices have to be made and we fix `sl3.3` as the element $e_\alpha$ corresponding to the first fundamental root $\alpha$, `sl3.7` as $e_{-\alpha}$ and get `sl3.1` as $h_\alpha = e_\alpha * e_{-\alpha}$. For the other fundamental root $\beta$ we have to find an element $e_\beta$ such that $e_\alpha * e_\beta$ is non-zero.

```magma
> sl3.3*sl3.2;
(0 0 0 0 0 0 0 0)
> sl3.3*sl3.4;
( 0  0  0  0  0 -1  0  0)
> sl3.3*sl3.6;
(0 0 0 0 0 0 0 0)
> sl3.3*sl3.8;
(0 1 0 0 0 0 0 0)
```

We choose `sl3.8` as $e_\beta$, `sl3.6` as $e_{-\beta}$, and consequently `-sl3.5` as $h_\beta$. This now determines $e_{\alpha+\beta}$ to be `sl3.2` and $e_{-\alpha-\beta}$ to be `sl3.4`.

<a id="function-restrictionofscalars"></a>
##### `RestrictionOfScalars(A): AlgAss[FldAlg] -> AlgAss, Map`

<a id="function-restrictionofscalars-algass-fldfun"></a>
##### `RestrictionOfScalars(A): AlgAss[FldFun] -> AlgAss, Map`

<a id="function-restrictionofscalars-algass-fldalg-fld"></a>
##### `RestrictionOfScalars(A, F): AlgAss[FldAlg], Fld -> AlgAss, Map`

<a id="function-restrictionofscalars-algass-fldfun-fldfung"></a>
##### `RestrictionOfScalars(A, F): AlgAss[FldFun], FldFunG -> AlgAss, Map`

Given an associative algebra $A$ over an algebraic number or function field $K$ and an optional coefficient field $F$ of $K$, return the algebra isomorphic to $A$ whose coefficient field is $F$ if given otherwise the coefficient field of $K$.

<a id="example-ex-661f6a"></a>
##### `Example: Restricting Scalars of an Algebra (ex-661f6a)`

We illustrate some computations of restricting scalars, first over the coefficient field.

```magma
> P<x> := PolynomialRing(Rationals());
> F<b> := NumberField(x^3-3*x-1);
> Z_F := MaximalOrder(F);
> A<alpha,beta,alphabeta> := QuaternionAlgebra<F | -3,b>;
> A := AssociativeAlgebra(A);
> A;
Associative Algebra of dimension 4 with base ring F
> RA, m := RestrictionOfScalars(A);
> RA;
Associative Algebra of dimension 12 with base ring Rational Field
> m;
Mapping from: AlgAss: A to AlgAss: RA given by a rule
> m(A.1);
(1 0 0 0 0 0 0 0 0 0 0 0)
> $1 @@ m;
(1 0 0 0)
> RA.6 @@ m;
(  0 b^2   0   0)
> m($1);
(0 0 0 0 0 1 0 0 0 0 0 0)
```

We now show an example where the scalars we are restricting to are not necessarily the coefficient field but a coefficient field of the coefficient field.

```magma
> P<x> := PolynomialRing(QuadraticField(23));
> F<b> := NumberField(x^3-3*x-1);
> Z_F := MaximalOrder(F);
> A<alpha,beta,alphabeta> := QuaternionAlgebra<F | -3,b>;
> A := AssociativeAlgebra(A);
> RA, m := RestrictionOfScalars(A);
> RA;
Associative Algebra of dimension 12 with base ring Quadratic Field with defining
polynomial x^2 - 23 over the Rational Field
> m;
Mapping from: AlgAss: A to AlgAss: RA given by a rule
> RA.6 @@ m;
(  0 b^2   0   0)
> m($1);
(0 0 0 0 0 1 0 0 0 0 0 0)
> RAQ, mQ := RestrictionOfScalars(A, Rationals());
> RAQ, mQ;
Associative Algebra of dimension 24 with base ring Rational Field
Mapping from: AlgAss: A to AlgAss: RAQ given by a rule
> mQ(A.1);
(1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)
> $1 @@ mQ;
(1 0 0 0)
> RAQ.15 @@ mQ;
(                 0                  0 b^2 + 2*$.1*b + 23                  0)
> mQ($1);
(0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0)
```

#### Operations on Elements

<a id="function-centralizer-algass-algasselt"></a>
##### `Centralizer(A, s): AlgAss, AlgAssElt -> AlgAss`

<a id="function-centraliser-algass-algasselt"></a>
##### `Centraliser(A, s): AlgAss, AlgAssElt -> AlgAss`

The centralizer of the element $s$ of the associative algebra $A$, that is, the subalgebra of $A$ commuting with $s$.

<a id="function-liebracket-algasselt-algasselt"></a>
##### `LieBracket(a, b): AlgAssElt, AlgAssElt -> AlgAssElt`

<a id="literal-literal-a-b-algasselt-algasselt-algasselt"></a>
##### `(a, b): AlgAssElt, AlgAssElt -> AlgAssElt`

The Lie bracket $a * b - b * a$ of $a$ and $b$, where $a$ and $b$ are elements of an associative algebra $A$.

<a id="function-isscalar-algasselt"></a>
##### `IsScalar(a): AlgAssElt -> BoolElt, RngElt`

Returns `true` (and $a$ coerced to $F$) iff a belongs to the base ring $F$ of its parent algebra.

<a id="function-representationmatrix-algasselt-algass"></a>
##### `RepresentationMatrix(a, M : parameters): AlgAssElt, AlgAss -> AlgMatElt`

```magma
Side: MonStgElt                    Default: "Right"
```

Returns the matrix representation of `Side`-multiplication by the element $a$ in the associative algebra $A$ (which must have $1$) on the $A$-module $M$.

#### Representations

<a id="function-matrixalgebra-algass"></a>
##### `MatrixAlgebra(A): AlgAss -> AlgMat`

For an associative algebra $A$ of dimension $n$ return an isomorphic matrix algebra. If $A$ contains the identity-element, the matrix algebra will be of degree $n$, otherwise it will be of degree $n+1$.

<a id="function-matrixalgebra-algass-algass"></a>
##### `MatrixAlgebra(A, M : parameters): AlgAss, AlgAss -> AlgMat, Map`

```magma
Side: MonStgElt                    Default: "Right"
```

Given a finite-dimensional $R$-algebra $A$ and a `Side` $A$-module $M$ (both free as $R$-modules), return the matrix algebra of $A$-endomorphisms of $M$, and the $R$-algebra homomorphism from $A$ into this endomorphism ring.

<a id="function-regularrepresentation-algass"></a>
##### `RegularRepresentation(A : parameters): AlgAss -> AlgMat, Map`

```magma
Side: MonStgElt                    Default: "Right"
```

For an associative algebra $A$ of dimension $n$ over $R$ return its regular representation. If $B = (e_1, e_2, \ldots, e_n)$ is the stored basis for $A$, an element $a \in A$ is mapped to the matrix in $R^{n \times n}$ which has as its $i$-th row the coordinates of $e_i * a$ with respect to $B$. As a second map, the homomorphism of $A$ onto the regular representation is returned.

By default, the right-regular representation is computed. This can be changed to the left-regular representation (in which the $i$-th row of the image of $a$ contains the coordinates of $a * e_i$) by setting the parameter `Side` to `"Left"`.

#### Decomposition of an Algebra

This section describes a few functions that can be used to obtain information on the structure of a finite-dimensional associative algebra.

<a id="function-jacobsonradical-algassv"></a>
##### `JacobsonRadical(A): AlgAssV -> AlgAssV`

```magma
Al: MonStgElt                    Default: "Default"
```

This returns the largest nilpotent ideal of $A$. This function works for finite-dimensional associative algebras defined over a field of characteristic $0$, or over a finite field.

The algorithm used by default is taken from [[CIW97](https://docs.magma-maths.org/references.md#cite-cohen-ivanyos-wales)]. The meataxe algorithm can be used by setting `Al := "Meataxe"`.

<a id="example-ex-564d9d"></a>
##### `Example: Jacobson Radical of a Group Algebra (ex-564d9d)`

We compute the Jacobson radical of the group algebra over the field of three elements of a $3$-group. In that case it is equal to the augmentation ideal.

```magma
> G:= SmallGroup( 27, 5 );
> A:= GroupAlgebra( GF(3), G );
> JacobsonRadical( A );
Ideal of dimension 26 of the group algebra A
```

<a id="function-directsumdecomposition-algassv"></a>
##### `DirectSumDecomposition(A): AlgAssV -> [ AlgAssV ], [ AlgAssVElt ]`

<a id="function-indecomposablesummands-algassv"></a>
##### `IndecomposableSummands(A): AlgAssV -> [ AlgAssV ], [ AlgAssVElt ]`

Given an associative algebra $A$, return the direct sum decomposition of $L$ as a sequence of ideals of $L$ whose sum is $L$ and each of which cannot be further decomposed into a direct sum of ideals. The second sequence return contains the corresponding primitive central idempotents.

For a description of the algorithm we refer to [[EG96](https://docs.magma-maths.org/references.md#cite-eberly-giesbrecht)].

<a id="function-centralidempotents-algassv"></a>
##### `CentralIdempotents(A): AlgAssV -> SeqEnum, SeqEnum`

Let $Z$ be the centre of the associative algebra $A$, and let $J(Z)$ denote its Jacobson radical. This function returns a sequence of primitive orthogonal idempotents in $Z$ such that their images in $Z/J(Z)$ span $J(Z)$. Each such idempotent generates a two-sided ideal in $A$. The second return value is the sequence of these ideals.

In particular, if $A$ is a semisimple algebra, then this function returns a sequence of primitive orthogonal idempotents spanning $Z$. Furthermore, the ideals in the second sequence returned are simple algebras, and their direct sum equals $A$.

For a description of the algorithm we refer to [[EG96](https://docs.magma-maths.org/references.md#cite-eberly-giesbrecht)].

<a id="example-ex-4239e7"></a>
##### `Example: Central Idempotents of a Group Algebra (ex-4239e7)`

We compute the direct sum decomposition of a group algebra.

```magma
> G:= SmallGroup( 10, 2 );
> A:= GroupAlgebra( Rationals(), G );
> ee, II:= CentralIdempotents( A );
> ee[1];
1/10*Id(G) + 1/10*G.2 + 1/10*G.2^2 + 1/10*G.2^3 + 1/10*G.2^4 + 1/10*G.1 +
1/10*G.1 * G.2 + 1/10*G.1 * G.2^2 + 1/10*G.1 * G.2^3 + 1/10*G.1 * G.2^4
> II;
[
    Ideal of dimension 1 of the group algebra A
    Basis:
        Id(G) + G.2 + G.2^2 + G.2^3 + G.2^4 + G.1 + G.1 * G.2 + G.1 * G.2^2 +
        G.1 * G.2^3 + G.1 * G.2^4,
    Ideal of dimension 1 of the group algebra A
    Basis:
        Id(G) + G.2 + G.2^2 + G.2^3 + G.2^4 - G.1 - G.1 * G.2 - G.1 * G.2^2 -
        G.1 * G.2^3 - G.1 * G.2^4,
    Ideal of dimension 4 of the group algebra A
    Basis:
        Id(G) - G.2^4 + G.1 - G.1 * G.2^4
        G.2 - G.2^4 + G.1 * G.2 - G.1 * G.2^4
        G.2^2 - G.2^4 + G.1 * G.2^2 - G.1 * G.2^4
        G.2^3 - G.2^4 + G.1 * G.2^3 - G.1 * G.2^4,
    Ideal of dimension 4 of the group algebra A
    Basis:
        Id(G) - G.2^4 - G.1 + G.1 * G.2^4
        G.2 - G.2^4 - G.1 * G.2 + G.1 * G.2^4
        G.2^2 - G.2^4 - G.1 * G.2^2 + G.1 * G.2^4
        G.2^3 - G.2^4 - G.1 * G.2^3 + G.1 * G.2^4
]
```

We see that here the group algebra is the direct sum of two $1$-dimensional and two $4$-dimensional ideals. The first idempotent is the sum over all group elements divided by the group order.

<a id="alg-ass-ord"></a>
<a id="secalgassvord"></a>
### Orders

Let $F$ be a number field with ring of integers $R$, and let $A$ be a associative algebra over $F$ (finite-dimensional, with $1$). An *associative order* $O$ of $A$ is a subring $O \subset A$ which is a projective $R$-module such that $O\cdot F = A$. We will also refer to an associative order simply as an *order*.

In Magma, associative orders have the type `AlgAssVOrd`, and may be declared for any associative algebra of type `AlgAssV`, namely, `AlgAss`, `AlgMat`, `AlgQuat`, and `AlgGrp`. Orders have ideals of type `AlgAssVOrdIdl`, and elements of type `AlgAssVOrdElt`. In the special case where $A$ is a quaternion algebra over the rationals, $A$ has type `AlgQuat` and orders in $A$ have type `AlgQuatOrd`.

Orders, like modules over Dedekind domains, are represented by a pseudobasis, see Section [Pseudo Matrices](https://docs.magma-maths.org/Modules/ModulesOverDedekindDomains/pmat.md#secpmat). Currently, only basic arithmetic functions and procedures are available for general associative orders. Most of the nontrivial functionality currently available is designed for orders in quaternion algebras (over the rationals or number fields). The specialised functions for quaternionic orders are described in Chapter [Quaternion Algebras](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/index-quaternion-algebras.md#chapalgquat).

*Algebras over the rationals:* In Magma, the rationals are *not* considered to be a number field (the type `FldRat` is not a subtype of `FldNum`). Currently, much of the functionality here is designed primarily for algebras whose base field is a `FldNum` (while some of it, but not all, also works for algebras over the `FldRat`). To compute with algebras over ${\mathbb{Q}}$, in many cases the best solution is to use `RationalsAsNumberField()`.

#### Construction of Orders

<a id="function-order-rng-seqenum-algassvelt"></a>
##### `Order(R, S): Rng, SeqEnum[AlgAssVElt] -> AlgAssVOrd`

<a id="function-order-rngfunord-seqenum-algassvelt-fldfung"></a>
##### `Order(R, S): RngFunOrd, SeqEnum[AlgAssVElt[FldFunG]] -> AlgAssVOrd`

```magma
Check: BoolElt                    Default: true
```

Given a ring $R$ and sequence $S$ of elements of an associative algebra $A$, returns the order of $A$ generated freely over $R$ by the sequence $S$. The ring $R$ must be a number or function ring, $\Z$, $F[t]$, or $F[1/t]$.

If the parameter `Check` is set to `true` then the elements in the sequence $S$ are checked to be a basis.

<a id="function-order-seqenum-algassvelt-fldalg"></a>
##### `Order(S): SeqEnum[AlgAssVElt[FldAlg]] -> AlgAssVOrd`

<a id="function-order-seqenum-algassvelt-fldfun"></a>
##### `Order(S): SeqEnum[AlgAssVElt[FldFun]] -> AlgAssVOrd`

Given a sequence of elements $S$ of an associative algebra $A$, returns the order of $A$ generated by the sequence $S$. The algebra $A$ must be defined over a number or function field $F$.

<a id="function-order-seqenum-algassvelt-fldalg-seqenum-rngordfracidl"></a>
##### `Order(S, I): SeqEnum[AlgAssVElt[FldAlg]], SeqEnum[RngOrdFracIdl] -> AlgAssVOrd`

<a id="function-order-seqenum-algassvelt-fldfung-seqenum-rngfunordidl"></a>
##### `Order(S, I): SeqEnum[AlgAssVElt[FldFunG]], SeqEnum[RngFunOrdIdl] -> AlgAssVOrd`

Given a sequence of elements $S$ of an associative algebra $A$ and a sequence $I$ of ideals of a number or function ring $R$, returns the order of $A$ generated by the sequence $S$ with coefficient ideals $I$. The algebra $A$ must be defined over a number or function field $F$ and have ring of integers $R$.

<a id="function-order-algassv-fldord-algmatelt-fldord-seqenum-rngordfracidl"></a>
##### `Order(A, m, I): AlgAssV[FldOrd], AlgMatElt[FldOrd], SeqEnum[RngOrdFracIdl] -> AlgAssVOrd`

<a id="function-order-algassv-fldnum-algmatelt-fldnum-seqenum-rngordfracidl"></a>
##### `Order(A, m, I): AlgAssV[FldNum], AlgMatElt[FldNum], SeqEnum[RngOrdFracIdl] -> AlgAssVOrd, Map`

<a id="function-order-algassv-fldfun-algmatelt-fldfun-seqenum-rngfunordidl"></a>
##### `Order(A, m, I): AlgAssV[FldFun], AlgMatElt[FldFun], SeqEnum[RngFunOrdIdl] -> AlgAssVOrd`

Given an associative algebra $A$, a matrix $m$, and a sequence $I$ of ideals of a number or function ring $R$, returns the order of $A$ generated by the sequence of elements specified by the rows of $m$ in the basis of $A$ with coefficient ideals $I$. The algebra $A$ must be defined over a number or function field $F$ with ring of integers $R$.

<a id="function-order-algassv-fldord-pmat"></a>
##### `Order(A, pm): AlgAssV[FldOrd], PMat -> AlgAssVOrd`

<a id="function-order-algassv-fldnum-pmat"></a>
##### `Order(A, pm): AlgAssV[FldNum], PMat -> AlgAssVOrd, Map`

<a id="function-order-algassv-fldfun-pmat"></a>
##### `Order(A, pm): AlgAssV[FldFun], PMat -> AlgAssVOrd`

Given an associative algebra $A$ and a pseudomatrix $pm$, returns the order of $A$ specified by the pseudomatrix $pm$. The basis of the order is specified by the rows of $pm$ which have coefficients with respect to the basis of $A$. The algebra $A$ must be defined over a number or function field with ring of integers $R$ which is the base ring of the pseudomatrix $pm$.

<a id="example-ex-5ab68c"></a>
##### `Example: Three Ways to Create an Order (ex-5ab68c)`

We begin by illustrating three methods for creating an associative order.

```magma
> P<x> := PolynomialRing(Rationals());
> F<b> := NumberField(x^3-3*x-1);
> Z_F := MaximalOrder(F);
> A<alpha,beta,alphabeta> := QuaternionAlgebra<F | -3,b>;
```

First type of constructor takes an algebra, a matrix representing the basis elements, and coefficient ideals.

```magma
> M := MatrixAlgebra(F,4) ! 1;
> I := [ideal<Z_F | 1> : i in [1..4]];
> O := Order(A, M, I);
> O;
Order of Quaternion Algebra with base ring Field of Fractions of Z_F
with coefficient ring Maximal Equation Order with defining polynomial x^3 - 3*x
    - 1 over its ground order
```

The second type takes an algebra and a pseudomatrix.

```magma
> P := PseudoMatrix(I, M);
> O := Order(A, P);
> O;
Order of Quaternion Algebra with base ring Field of Fractions of Z_F
with coefficient ring Maximal Equation Order with defining polynomial x^3 - 3*x
    - 1 over its ground order
```

The third takes simply a sequence of elements.

```magma
> O := Order([alpha,beta]);
> O;
Order of Quaternion Algebra with base ring Field of Fractions of Z_F
with coefficient ring Maximal Equation Order with defining polynomial x^3 - 3*x
    - 1 over its ground order
```

<a id="example-ex-1d14f4"></a>
##### `Example: Order in a Cyclic Algebra (ex-1d14f4)`

Here we give two other examples of order creation.

```magma
> F<w> := CyclotomicField(3);
> A := FPAlgebra<F, x,y | x^3-3, y^3+5, y*x-w*x*y>;
> Aass, f := Algebra(A);
> Aass;
Associative Algebra of dimension 9 with base ring F
> f;
Mapping from: AlgFP: A to AlgAss: Aass
> S := [f(A.i) : i in [1..2]];
> S;
[ (0 0 1 0 0 0 0 0 0), (0 1 0 0 0 0 0 0 0) ]
> O := Order(S);
> O;
Order of Associative Algebra of dimension 9 with base ring Field of Fractions of R
with coefficient ring Maximal Equation Order with defining polynomial x^2 + x +
    1 over its ground order
>
> A := GroupAlgebra(F, DihedralGroup(6));
> Aass := Algebra(A);
> O := Order([g : g in Generators(Aass)]);
> O;
Order of Associative Algebra of dimension 12 with base ring Field of Fractions
of R with coefficient ring Maximal Equation Order with defining polynomial
x^2 + x + 1 over its ground order
```

<a id="function-maximalorder-algassv-fldrat"></a>
##### `MaximalOrder(A): AlgAssV[FldRat] -> AlgAssVOrd`

Computes a maximal ${\mathbb{Z}}$-order in the semisimple associative algebra $A$, which must be defined over the rational numbers. The algorithm can be found in [[Fri00](https://docs.magma-maths.org/references.md#cite-fr2)], §3.5. We refer to [[IR93](https://docs.magma-maths.org/references.md#cite-ivanyos-ronyai)] for a very similar approach.

<a id="function-maximalorder-algassv-fldalg"></a>
##### `MaximalOrder(A): AlgAssV[FldAlg] -> AlgAssVOrd`

Given an associative algebra over an algebraic field compute the maximal order in $A$. This computation uses [`RestrictionOfScalars`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ops.md#function-restrictionofscalars) and the `MaximalOrder` computation of the isomorphic algebra over the rationals as described above.

<a id="function-maximalorder-algassvord-rngint"></a>
##### `MaximalOrder(O): AlgAssVOrd[RngInt] -> AlgAssVOrd`

<a id="function-maximalorder-algassvord-rngord"></a>
##### `MaximalOrder(O): AlgAssVOrd[RngOrd] -> AlgAssVOrd`

Given an order $O$ of an associative algebra $A$ over the rationals or a number field return the maximal order of $A$ which contains $O$.

<a id="function-maximalorderfinite-algassv-fldfunrat"></a>
##### `MaximalOrderFinite(A): AlgAssV[FldFunRat] -> AlgAssVOrd`

Computes a maximal $F[t]$ order in the semisimple associative algebra $A$, which must be defined over some rational function field $F(t)$. The algorithm can be found in [[Fri00](https://docs.magma-maths.org/references.md#cite-fr2)], §3.5. We refer to [[IR93](https://docs.magma-maths.org/references.md#cite-ivanyos-ronyai)] for a very similar approach.

<a id="function-maximalorderinfinite-algassv-fldfunrat"></a>
##### `MaximalOrderInfinite(A): AlgAssV[FldFunRat] -> AlgAssVOrd`

Computes a maximal $F[1/t]$ order in the semisimple associative algebra $A$, which must be defined over some rational function field $F(t)$. The algorithm can be found in [[Fri00](https://docs.magma-maths.org/references.md#cite-fr2)], §3.5. We refer to [[IR93](https://docs.magma-maths.org/references.md#cite-ivanyos-ronyai)] for a very similar approach.

<a id="function-maximalorderfinite-algassv-fldfun"></a>
##### `MaximalOrderFinite(A): AlgAssV[FldFun] -> AlgAssVOrd`

<a id="function-maximalorderinfinite-algassv-fldfun"></a>
##### `MaximalOrderInfinite(A): AlgAssV[FldFun] -> AlgAssVOrd`

Given an associative algebra over an algebraic function field $K$ compute the maximal order in $A$ containing the finite or infinite maximal order of $K$. This computation uses [`RestrictionOfScalars`](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/ops.md#function-restrictionofscalars) and one of the `MaximalOrderFinite` or `MaximalOrderInfinite` computations of the isomorphic algebra over the rational function field as described above.

<a id="function-maximalorder-algassvord-rngupol"></a>
##### `MaximalOrder(O): AlgAssVOrd[RngUPol] -> AlgAssVOrd`

<a id="function-maximalorder-algassvord-rngval"></a>
##### `MaximalOrder(O): AlgAssVOrd[RngVal] -> AlgAssVOrd`

<a id="function-maximalorder-algassvord-rngfunord"></a>
##### `MaximalOrder(O): AlgAssVOrd[RngFunOrd] -> AlgAssVOrd`

Given an order $O$ of an associative algebra $A$ over a function field return the maximal order of $A$ which contains $O$.

<a id="example-ex-9fdfa9"></a>
##### `Example: Maximal Order of a Matrix Algebra (ex-9fdfa9)`

First we define two $9\times 9$-matrices that generate a $9$-dimensional associative algebra. We check that its Jacobson radical is zero, and then we compute a maximal order.

```magma
> a1 := Matrix( [
> [-184174/80137, -325/80137, 71/2163699, 0, 0, 0, 0, 0, 0],
> [17713719/80137, 92087/80137, -325/80137, 0, 0, 0, 0, 0, 0],
> [-2189265975/80137, -16429806/80137, 92087/80137, 0, 0, 0, 0, 0, 0],
> [0, 0, 0, 64850/80137, 1472/240411, -25/2163699, 0, 0, 0],
> [0, 0, 0, -6237225/80137, -32425/80137, 1472/240411, 0, 0, 0],
> [0, 0, 0, 3305230272/80137, 45310743/80137, -32425/80137, 0, 0, 0],
> [0, 0, 0, 0, 0, 0, 119324/80137, -497/240411, -46/2163699],
> [0, 0, 0, 0, 0, 0, -11476494/80137, -59662/80137, -497/240411],
> [0, 0, 0, 0, 0, 0, -1115964297/80137, -28880937/80137, -59662/80137] ] );
> a2:= Matrix( [
> [0, 0, 0, 282469/240411, 956/2163699, -26/2163699, 0, 0, 0],
> [0, 0, 0, -6486714/80137, -21029/240411, 956/2163699, 0, 0, 0],
> [0, 0, 0, 238511484/80137, -2766918/80137, -21029/240411, 0, 0, 0],
> [0, 0, 0, 0, 0, 0, -85879/240411, -4894/2163699, 64/6491097],
> [0, 0, 0, 0, 0, 0, 5322432/80137, 163145/240411, -4894/2163699],
> [0, 0, 0, 0, 0, 0, -1220999166/80137, -13720122/80137, 163145/240411],
> [-1183167/80137, -11814/80137, -14/80137, 0, 0, 0, 0, 0, 0],
> [-94306842/80137, -2653965/80137, -11814/80137, 0, 0, 0, 0, 0, 0],
> [-79581502242/80137, -1335450240/80137, -2653965/80137, 0, 0, 0, 0, 0, 0] ] );

> M := MatrixAlgebra( Rationals(), 9 );
> A := sub< M | [ a1, a2 ] >;
> Dimension(A);
9
> JacobsonRadical(A);
Matrix Algebra [ideal of A] of degree 9 and dimension 0 with 0 generators over
Rational Field
> O := MaximalOrder(A);
> Discriminant(O);
-19683
> Determinant(Matrix(9, [Trace(a*b) : a, b in Basis(O)]));
-19683
```

```magma
> T :=MultiplicationTable(O);
> T[3][7];
[ -16583482050411285785256, 5672389828626293786946, 1059868937213366777403,
55245368126632733561175, -41598423838438078787076, 1726223870812049536260,
66694491159819102489072, 76373181201401217517416, -114928189655490866071212 ]
```

<a id="example-ex-23b948"></a>
##### `Example: Maximal Order over a Number Field (ex-23b948)`

We show a maximal order computation for an algebra over a number field.

```magma
> P<x> := PolynomialRing(Rationals());
> F<b> := NumberField(x^3-3*x-1);
> Z_F := MaximalOrder(F);
> A<alpha,beta,alphabeta> := QuaternionAlgebra<F | -3,b>;
> AA := AssociativeAlgebra(A);
> MAA := MaximalOrder(AA);
> MAA;
Order of Associative Algebra of dimension 4 with base ring F
with coefficient ring Maximal Equation Order with defining polynomial x^3 - 3*x
    - 1 over Z
> Discriminant(MAA);
Ideal of Z_F
Basis:
[16  0  0]
[ 0 16  0]
[ 0  0 16]
```

Below we give an example of a maximal order computation of an algebra defined over a number field in relative representation.

```magma
> P<x> := PolynomialRing(QuadraticField(23));
> F<b> := NumberField(x^3-3*x-1);
> Z_F := MaximalOrder(F);
> A<alpha,beta,alphabeta> := QuaternionAlgebra<F | -3,b>;
> AA := AssociativeAlgebra(A);
> MAA := MaximalOrder(AA);
> Discriminant(MAA);
Ideal of Z_F
Basis:
Pseudo-matrix over Maximal Equation Order of Quadratic Field with defining
polynomial x^2 - 23 over the Rational Field
Principal Ideal
Generator:
    -2304/1*$.1 * ( $.1 0 0 )
Principal Ideal
Generator:
    -2304/1*$.1 * ( 0 $.1 0 )
Principal Ideal
Generator:
    -2304/1*$.1 * ( 0 0 $.1 )
```

<a id="function-restrictionofscalars-algassvord-rngord"></a>
##### `RestrictionOfScalars(O): AlgAssVOrd[RngOrd] -> AlgAssVOrd, Map`

<a id="function-restrictionofscalars-algassvord-rngfunord"></a>
##### `RestrictionOfScalars(O): AlgAssVOrd[RngFunOrd] -> AlgAssVOrd, Map`

<a id="function-restrictionofscalars-algassvord-rngord-rng"></a>
##### `RestrictionOfScalars(O, C): AlgAssVOrd[RngOrd], Rng -> AlgAssVOrd, Map`

<a id="function-restrictionofscalars-algassvord-rngfunord-rng"></a>
##### `RestrictionOfScalars(O, C): AlgAssVOrd[RngFunOrd], Rng -> AlgAssVOrd, Map`

Given an order $O$ over an order $R$ of an algebraic number or function field $K$ of an associative algebra $A$ over $K$ and an optional coefficient ring $C$ of $R$ return the order isomorphic to $O$ over $C$ if given otherwise the coefficient ring of $R$.

<a id="example-ex-bbfaa2"></a>
##### `Example: Restriction of Scalars for an Order (ex-bbfaa2)`

We give an example showing a `RestrictionOfScalars` computation of an order over an order of an algebraic field.

```magma
> P<x> := PolynomialRing(QuadraticField(23));
> F<b> := NumberField(x^3-3*x-1);
> Z_F := MaximalOrder(F);
> A<alpha,beta,alphabeta> := QuaternionAlgebra<F | -3,b>;
> A := AssociativeAlgebra(A);
> O := Order([A | alpha, beta]);
> RO, m := RestrictionOfScalars(O);
> m(O.1);
[$.1 0 0 0 0 0 0 0 0 0 0 0]
> $1 @@ m;
[Z_F.1 0 0 0]
> RO;
Order of Associative Algebra of dimension 12 with base ring Quadratic Field with
defining polynomial x^2 - 23 over the Rational Field
with coefficient ring Maximal Equation Order of Quadratic Field with defining
polynomial x^2 - 23 over the Rational Field
> m;
Mapping from: AlgAssVOrd: O to AlgAssVOrd: RO given by a rule
> RO.7 @@ m;
[0 0 Z_F.1 0]
> m($1);
[0 0 0 0 0 0 $.1 0 0 0 0 0]
> ROZ := RestrictionOfScalars(O, Integers());
> ROZ, mZ := RestrictionOfScalars(O, Integers());
> ROZ;
Order of Associative Algebra of dimension 24 with base ring Rational Field
with coefficient ring Integer Ring
> mZ;
Mapping from: AlgAssVOrd: O to AlgAssVOrd: ROZ given by a rule
> mZ(O.1);
[633707 -253386 -65276 -157853 -61885 -80837 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0]
> $1 @@ mZ;
[Z_F.1 0 0 0]
> ROZ.22 @@ mZ;
[0 0 0 ($.1 + 23/1*$.2)*Z_F.1 + 72/1*$.1*Z_F.2 + 3/1*$.2*Z_F.3]
> mZ($1);
[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0]
```

#### Attributes

<a id="function-basering-algassvord"></a>
##### `BaseRing(O): AlgAssVOrd -> Rng`

<a id="function-coefficientring-algassvord"></a>
##### `CoefficientRing(O): AlgAssVOrd -> Rng`

The base ring of the associative order $O$.

<a id="function-algebra-algassvord"></a>
##### `Algebra(O): AlgAssVOrd -> AlgAssV`

The container algebra of the associative order $O$.

<a id="function-degree-algassvord"></a>
##### `Degree(O): AlgAssVOrd -> RngIntElt`

<a id="function-dimension-algassvord"></a>
##### `Dimension(O): AlgAssVOrd -> RngIntElt`

The rank of $O$ over its base ring. Equivalently: $O$ is an order of some algebra $A$, this returns the dimension of $A$ over its base field.

<a id="function-discriminant-algassvord-rngord"></a>
##### `Discriminant(O): AlgAssVOrd[RngOrd] -> RngOrdIdl`

<a id="function-discriminant-algassvord-rngfunord"></a>
##### `Discriminant(O): AlgAssVOrd[RngFunOrd] -> RngOrdIdl`

<a id="function-discriminant-algassvord-rngint"></a>
##### `Discriminant(O): AlgAssVOrd[RngInt] -> RngIntElt`

<a id="function-discriminant-algassvord-rngupol"></a>
##### `Discriminant(O): AlgAssVOrd[RngUPol] -> RngIntElt`

<a id="function-discriminant-algassvord-rngval"></a>
##### `Discriminant(O): AlgAssVOrd[RngVal] -> RngIntElt`

For an order $O$ in a quaternion algebra (with type `AlgQuat`), this returns the reduced discriminant of $O$. For all other types of algebra, it returns the discriminant of $O$ defined in the most generic way, i.e the determinant of the trace form where trace is the generic trace.

<a id="function-factoreddiscriminant-algassvord-rngord"></a>
##### `FactoredDiscriminant(O): AlgAssVOrd[RngOrd] -> [Tup]`

This returns the factorization of `Discriminant(O)` (see above) for the order $O$.

<a id="function-multiplicationtable-algassvord"></a>
##### `MultiplicationTable(O): AlgAssVOrd -> SeqEnum`

Returns the multiplication table of the maximal order $O$. This is a three dimensional table of structure constants. If $T$ denotes this table, then $T[i][j]$ is a sequence of integers containing the coefficients of the product of the $i$-th and $j$-th basis elements with respect to the basis of the order.

<a id="function-module-algassvord-rngord"></a>
##### `Module(O): AlgAssVOrd[RngOrd] -> PMat`

Return the pseudo matrix describing the basis of the associative order $O$ over a number ring.

<a id="function-tracezerosubspace-algassvord"></a>
##### `TraceZeroSubspace(O): AlgAssVOrd -> SeqEnum`

Given an order $O$ in a quaternion algebra, this computes the submodule of elements with trace $0$. A basis or a pseudo-basis for this submodule is returned, depending whether the base field of the quaternion algebra is ${\mathbb{Q}}$ or a number field. (The base ring of $O$ is, respectively, either ${\mathbb{Z}}$ or an order in that number field.)

#### Bases of Orders

<a id="function-pseudobasis-algassvord-rngord"></a>
##### `PseudoBasis(O): AlgAssVOrd[RngOrd] -> SeqEnum`

<a id="function-pseudobasis-algassvord-rngfunord"></a>
##### `PseudoBasis(O): AlgAssVOrd[RngFunOrd] -> SeqEnum`

Given an associative order $O$ over $R$, where $R$ is an order in a number or function field, this returns data describing $O$ as an $R$-module. It returns a sequence of tuples $\langle I_i, b_i \rangle$ where $I_i$ is an ideal of $R$ and $b_i$ is an element of `Algebra(O)`, such that $O$ is the direct sum of the $R$-modules $I_i b_i$. In particular, the $b_i$ form a basis of `Algebra(O)` as a vector space over the field of fractions of $R$. Note that the $b_i$ may not lie in $O$.

<a id="function-pseudomatrix-algassvord-rngord"></a>
##### `PseudoMatrix(O): AlgAssVOrd[RngOrd] -> PMat`

<a id="function-pseudomatrix-algassvord-rngfunord"></a>
##### `PseudoMatrix(O): AlgAssVOrd[RngFunOrd] -> PMat`

Returns the pseudomatrix corresponding to `PseudoBasis(O)`.

<a id="function-basis-algassvord"></a>
##### `Basis(O): AlgAssVOrd -> SeqEnum`

When $O$ is an order over ${\mathbb{Z}}$, this returns a ${\mathbb{Z}}$-module basis of $O$.

When the base ring of $O$ is an extension of ${\mathbb{Z}}$, this returns part of the data returned by `PseudoBasis(O)`: it returns a basis of `Algebra(O)`. Note that this determines nothing about $O$, while the full data returned by `PseudoBasis(O)` determines $O$.

<a id="function-zbasis-algassvord-rngord"></a>
##### `ZBasis(O): AlgAssVOrd[RngOrd] -> [AlgAssVElt]`

<a id="function-zbasis-algassvord-rngfunord"></a>
##### `ZBasis(O): AlgAssVOrd[RngFunOrd] -> [AlgAssVElt]`

Returns a ${\mathbb{Z}}$-module basis for the order $O$.

<a id="function-generators-algassvord"></a>
##### `Generators(O): AlgAssVOrd -> [AlgAssVElt]`

Returns a sequence of generators of $O$ as a module over its base ring.

<a id="function-localbasis-algassvord-rngordidl"></a>
##### `LocalBasis(O, p): AlgAssVOrd, RngOrdIdl -> [AlgAssElt]`

```magma
Type: MonStgElt                    Default: ""
```

Given an order $O$ over a ring $R$ in an algebra $A$, this function returns a basis of a free $R$-module $F$ in $A$ such that $O$ and $F$ agree at the completion at the prime ideal $p$ of $R$. If `Type` is specified, it must either be `"Submodule"` or `"Supermodule"`. In which case $F$ is either a sub- or supermodule of $O$.

<a id="example-ex-1fcab8"></a>
##### `Example: Pseudobasis of an Order (ex-1fcab8)`

This example demonstrates use of `PseudoBasis` of an order.

```magma
> P<x> := PolynomialRing(Rationals());
> F<b> := NumberField(x^3-3*x-1);
> Z_F := MaximalOrder(F);
> A := QuaternionAlgebra<F | -3,b>;
> O := Order([1/3*A.1, A.2], [ideal<Z_F | b^2+b+1>, ideal<Z_F | 1>]);
> O;
Order of Quaternion Algebra with base ring Field of Fractions of Z_F
with coefficient ring Maximal Equation Order with defining polynomial x^3 - 3*x
    - 1 over its ground order
> Basis(O);
[ Z_F.1, i, j, k ]
```

This is a basis of `Algebra(O)` but not a basis of $O$ itself. The structure of $O$ as a $Z_F$-module is given by this basis together with coefficient ideals, as returned by either of the following:

```magma
> PseudoBasis(O);
[
    <Principal Ideal of Z_F
    Generator:
        Z_F.1, Z_F.1>,
    <Fractional Principal Ideal of Z_F
    Generator:
        1/3*Z_F.1 + 1/3*Z_F.2 + 1/3*Z_F.3, i>,
    <Principal Ideal of Z_F
    Generator:
        Z_F.1, j>,
    <Fractional Principal Ideal of Z_F
    Generator:
        1/3*Z_F.1 + 1/3*Z_F.2 + 1/3*Z_F.3, k>
]
> PseudoMatrix(O);
Pseudo-matrix over Maximal Equation Order with defining polynomial x^3 - 3*x
     - 1 over its ground order
Principal Ideal of Z_F
Generator:
    Z_F.1 * ( Z_F.1 0 0 0 )
Fractional Principal Ideal of Z_F
Generator:
    1/3*Z_F.1 + 1/3*Z_F.2 + 1/3*Z_F.3 * ( 0 Z_F.1 0 0 )
Principal Ideal of Z_F
Generator:
    Z_F.1 * ( 0 0 Z_F.1 0 )
Fractional Principal Ideal of Z_F
Generator:
    1/3*Z_F.1 + 1/3*Z_F.2 + 1/3*Z_F.3 * ( 0 0 0 Z_F.1 )
> ZBasis(O);
[ Z_F.1, Z_F.2, Z_F.3, (1/3*Z_F.1 + 1/3*Z_F.2 + 1/3*Z_F.3)*i, (1/3*Z_F.1 +
4/3*Z_F.2 + 1/3*Z_F.3)*i, (1/3*Z_F.1 + 4/3*Z_F.2 + 4/3*Z_F.3)*i, j, Z_F.2*j,
Z_F.3*j, (1/3*Z_F.1 + 1/3*Z_F.2 + 1/3*Z_F.3)*k, (1/3*Z_F.1 + 4/3*Z_F.2 +
1/3*Z_F.3)*k, (1/3*Z_F.1 + 4/3*Z_F.2 + 4/3*Z_F.3)*k ]
```

#### Predicates

<a id="operation-op-eq-algassvord-algassvord"></a>
##### `O1 eq O2: AlgAssVOrd, AlgAssVOrd -> BoolElt`

Return `true` if and only if the orders $O_1$ and $O_2$ are equal as subrings of the same algebra.

<a id="operation-op-in-algassvelt-algassvord"></a>
##### `x in O: AlgAssVElt, AlgAssVOrd -> BoolElt`

<a id="operation-op-notin-algassvelt-algassvord"></a>
##### `x notin O: AlgAssVElt, AlgAssVOrd -> BoolElt`

Return `true` (respectively, `false`) if the element $x$ of an associative algebra is in the associative order $O$.

#### Operations with Orders

<a id="function-adjoin-algassvord-algassvelt"></a>
##### `Adjoin(O, x): AlgAssVOrd, AlgAssVElt -> AlgAssVOrd`

<a id="function-adjoin-algassvord-algassvelt-rngordfracidl"></a>
##### `Adjoin(O, x, I): AlgAssVOrd, AlgAssVElt, RngOrdFracIdl -> AlgAssVOrd`

Returns the order obtained by adjoining the element $x$ to the order $O$, optionally with coefficient ideal $I$.

<a id="operation-op-plus-algassvord-rngord-algassvord-rngord"></a>
##### `O1 + O2: AlgAssVOrd[RngOrd], AlgAssVOrd[RngOrd] -> AlgAssVOrd`

Returns the sum of the orders $O_1$ and $O_2$.

<a id="operation-op-meet-algassvord-rngord-algassvord-rngord"></a>
##### `O1 meet O2: AlgAssVOrd[RngOrd], AlgAssVOrd[RngOrd] -> AlgAssVOrd`

Returns the intersection of the orders $O_1$ and $O_2$.

<a id="operation-op-pow-algassvord-algasselt"></a>
##### `O ^ x: AlgAssVOrd, AlgAssElt -> AlgAssvOrd`

Returns the conjugate order $x^{-1} O x$.

<a id="example-ex-9c61c8"></a>
##### `Example: Sums of Orders and Adjoining Elements (ex-9c61c8)`

```magma
> P<x> := PolynomialRing(Rationals());
> F<b> := NumberField(x^3-3*x-1);
> Z_F := MaximalOrder(F);
> F := FieldOfFractions(Z_F);
> A<alpha,beta,alphabeta> := QuaternionAlgebra<F | -3,b>;
> O := Order([alpha,beta]);
> O1 := Order([1/3*alpha,beta], [ideal<Z_F | b^2+b+1>, ideal<Z_F | 1>]);
> Discriminant(O1);
Principal Ideal of Z_F
Generator:
    4/1*F.1 + 12/1*F.2 + 8/1*F.3
> xi := (1 + alpha + (7+5*b+6*b^2)*beta + (3+b+6*b^2)*alphabeta)/2;
> zeta := (-6-25*b-5*b^2)*alpha - 3*beta;
> O2 := Adjoin(O, xi);
> O := O1+O2;
> Discriminant(O);
Ideal of Z_F
Basis:
[2 0 4]
[0 2 4]
[0 0 6]
```

### Elements of Orders

#### Construction of Elements

<a id="operation-op-algassvord-rngintelt"></a>
##### `O ! 0: AlgAssVOrd, RngIntElt -> AlgAssVOrdElt`

<a id="function-zero-algassvord"></a>
##### `Zero(O): AlgAssVOrd -> AlgAssVOrdElt`

The zero element of the associative order $O$.

<a id="operation-op-algassvord-rngintelt-2"></a>
##### `O ! 1: AlgAssVOrd, RngIntElt -> AlgAssVOrdElt`

<a id="function-one-algassvord"></a>
##### `One(O): AlgAssVOrd -> AlgAssVOrdElt`

The identity element of the associative order $O$.

<a id="operation-operation-algassvord-rngintelt-algassvelt"></a>
##### `O . i: AlgAssVOrd, RngIntElt -> AlgAssVElt`

Given an associative order $O$ and an integer $i$, returns the $i$th basis element as an order over the base ring. Note that the element $1$ may or may not be the first element of a basis. These basis elements are returned as elements of the algebra of $O$ not as elements of $O$ itself.

<a id="operation-op-algassvord-any"></a>
##### `O ! x: AlgAssVOrd, Any -> AlgAssVOrdElt`

Return an element of the associative order $O$ described by $x$, where $x$ may be a sequence, an element of an associative order, an element coercible into the coefficient ring of $O$ or into the algebra of $O$.

#### Arithmetic of Elements

<a id="operation-op-plus-algassvordelt-algassvordelt"></a>
##### `x + y: AlgAssVOrdElt, AlgAssVOrdElt -> AlgAssVOrdElt`

The sum of elements $x$ and $y$ of an order of an associative algebra.

<a id="operation-op-minus-algassvordelt-algassvordelt"></a>
##### `x - y: AlgAssVOrdElt, AlgAssVOrdElt -> AlgAssVOrdElt`

The difference of elements $x$ and $y$ of an order of an associative algebra.

<a id="operation-operation-algassvordelt-algassvordelt"></a>
##### `- x: AlgAssVOrdElt -> AlgAssVOrdElt`

The negation of element $x$ of an order of an associative algebra.

<a id="operation-op-times-algassvordelt-algassvordelt"></a>
##### `x * y: AlgAssVOrdElt, AlgAssVOrdElt -> AlgAssVOrdElt`

The product of elements $x$ and $y$ of an associative algebra.

<a id="operation-op-times-algassvordelt-rngelt"></a>
##### `u * c: AlgAssVOrdElt, RngElt -> AlgAssVOrdElt`

<a id="operation-op-times-rngelt-algassvordelt"></a>
##### `c * u: RngElt, AlgAssVOrdElt -> AlgAssVOrdElt`

The product of the element $u$ of an associative order by the scalar $c$.

<a id="operation-op-div-algassvordelt-algassvordelt"></a>
##### `x / y: AlgAssVOrdElt, AlgAssVOrdElt -> AlgAssVElt`

The quotient of $x$ by the unit $y$ in the parent algebra.

<a id="operation-operation-div-algassvordelt-algassvordelt-algassvordelt"></a>
##### `x div y: AlgAssVOrdElt, AlgAssVOrdElt -> AlgAssVOrdElt`

The exact division of $x$ by $y$ in the order containing them.

<a id="operation-op-pow-algassvordelt-rngintelt"></a>
##### `x ^ n: AlgAssVOrdElt, RngIntElt -> AlgAssVOrdElt`

The product of the element $x$ of an associative order with itself $n$ times.

#### Predicates on Elements

<a id="operation-op-eq-algassvordelt-algassvordelt"></a>
##### `x eq y: AlgAssVOrdElt, AlgAssVOrdElt -> BoolElt`

Returns `true` if and only if the elements $x$ and $y$ are equal.

<a id="operation-op-ne-algassvordelt-algassvordelt"></a>
##### `x ne y: AlgAssVOrdElt, AlgAssVOrdElt -> BoolElt`

Returns `true` if and only if the elements $x$ and $y$ are not equal.

<a id="function-iszero-algassvordelt"></a>
##### `IsZero(x): AlgAssVOrdElt -> BoolElt`

Return `true` if the element $x$ of an associative order is the zero element.

<a id="function-isunit-algassvordelt"></a>
##### `IsUnit(a): AlgAssVOrdElt -> BoolElt`

Return `true` if the element $x$ of an associative order is a unit in that order.

<a id="function-isscalar-algassvordelt"></a>
##### `IsScalar(x): AlgAssVOrdElt -> BoolElt, RngElt`

Returns `true` if and only if $x$ is an element of the base ring of the order containing it, and if so returns the coerced element.

#### Other Operations with Elements

<a id="function-elementtosequence-algassvordelt"></a>
##### `ElementToSequence(x): AlgAssVOrdElt -> SeqEnum`

<a id="function-eltseq-algassvordelt"></a>
##### `Eltseq(x): AlgAssVOrdElt -> SeqEnum`

Given an element $x$ of an associative order $O$, returns the sequence of coordinates of $x$ in terms of the basis of $O$.

<a id="function-norm-algassvordelt"></a>
##### `Norm(x): AlgAssVOrdElt -> RngElt`

The norm of the element $x$ of an order as an element of its parent algebra.

<a id="function-trace-algassvordelt"></a>
##### `Trace(x): AlgAssVOrdElt -> RngElt`

The trace of the element $x$ of an order as an element of its parent algebra.

<a id="function-leftrepresentationmatrix-algassvordelt"></a>
##### `LeftRepresentationMatrix(e): AlgAssVOrdElt -> AlgMatElt`

<a id="function-rightrepresentationmatrix-algassvordelt"></a>
##### `RightRepresentationMatrix(e): AlgAssVOrdElt -> AlgMatElt`

The representation matrix describing left (right) multiplication by the element $e$ of an associative order.

<a id="function-representationmatrix-algassvordelt"></a>
##### `RepresentationMatrix(a): AlgAssVOrdElt -> AlgMatElt`

```magma
Side: MonStgElt                    Default: "Left"
```

The representation matrix of the element $a$ of an associative order. This describes left multiplication unless the parameter `Side` is set to `"Right"`.

<a id="function-characteristicpolynomial-algassvordelt"></a>
##### `CharacteristicPolynomial(x): AlgAssVOrdElt -> RngUPolElt`

The characteristic polynomial of the element $x$ of an order as an element of its parent algebra.

<a id="function-minimalpolynomial-algassvordelt"></a>
##### `MinimalPolynomial(x): AlgAssVOrdElt -> RngUPolElt`

The minimal polynomial of the element $x$ of an order as an element of its parent algebra.

### Ideals of Orders

#### Construction of Ideals

<a id="constructor-constructor-lideal-algassvord-algassvordelt-algassvordidl"></a>
##### `lideal<O | E>: AlgAssVOrd, [AlgAssVOrdElt] -> AlgAssVOrdIdl`

<a id="constructor-constructor-rideal-algassvord-algassvordelt-algassvordidl"></a>
##### `rideal<O | E>: AlgAssVOrd, [AlgAssVOrdElt] -> AlgAssVOrdIdl`

<a id="constructor-constructor-ideal-algassvord-algassvordelt-algassvordidl"></a>
##### `ideal<O | E>: AlgAssVOrd, [AlgAssVOrdElt] -> AlgAssVOrdIdl`

For an associative order $O$, this constructs the left, right, or two sided $O$-ideal generated by the elements in the given sequence $E$ (these elements should be coercible into $O$).

<a id="constructor-constructor-lideal-algassvord-pmat-algassvordidl"></a>
##### `lideal<O | M>: AlgAssVOrd, PMat -> AlgAssVOrdIdl`

<a id="constructor-constructor-lideal-algassvord-mtrx-algassvordidl"></a>
##### `lideal<O | M>: AlgAssVOrd, Mtrx -> AlgAssVOrdIdl`

<a id="constructor-constructor-rideal-algassvord-pmat-algassvordidl"></a>
##### `rideal<O | M>: AlgAssVOrd, PMat -> AlgAssVOrdIdl`

<a id="constructor-constructor-rideal-algassvord-mtrx-algassvordidl"></a>
##### `rideal<O | M>: AlgAssVOrd, Mtrx -> AlgAssVOrdIdl`

<a id="constructor-constructor-ideal-algassvord-pmat-algassvordidl"></a>
##### `ideal<O | M>: AlgAssVOrd, PMat -> AlgAssVOrdIdl`

<a id="constructor-constructor-ideal-algassvord-mtrx-algassvordidl"></a>
##### `ideal<O | M>: AlgAssVOrd, Mtrx -> AlgAssVOrdIdl`

Constructs a left, right, or two sided ideal of the associative order $O$ whose basis is given by $M$, which may be either a matrix or a pseudo matrix.

<a id="operation-op-times-algassvord-rngelt"></a>
##### `O * e: AlgAssVOrd, RngElt -> AlgAssVOrdIdl`

<a id="operation-op-times-rngelt-algassvord"></a>
##### `e * O: RngElt, AlgAssVOrd -> AlgAssVOrdIdl`

The principal left (right) ideal of the associative order $O$ generated by the element $e$.

#### Attributes of Ideals

In this section, $I$ is an ideal of some order in an associative algebra.

<a id="function-order-algassvordidl"></a>
##### `Order(I): AlgAssVOrdIdl -> AlgAssVOrd`

For an ideal $I$ created as an ideal of an order $O$, this returns $O$.

<a id="function-algebra-algassvordidl"></a>
##### `Algebra(I): AlgAssVOrdIdl -> AlgAssV`

This returns `Algebra(Order(I))`.

<a id="function-leftorder-algassvordidl"></a>
##### `LeftOrder(I): AlgAssVOrdIdl -> AlgAssVOrd`

<a id="function-rightorder-algassvordidl"></a>
##### `RightOrder(I): AlgAssVOrdIdl -> AlgAssVOrd`

For an ideal $I$, this returns the (full) order in `Algebra(I)` which stabilizes $I$ under multiplication on the left or right respectively. Explicitly, the left order of $I$ is defined as $\{ x : x I \subseteq I \}$.

<a id="function-arithmeticradical-algassvord-rngord-rngordidl"></a>
##### `ArithmeticRadical(O, p): AlgAssVOrd[RngOrd], RngOrdIdl -> AlgAssVOrdIdl`

<a id="function-arithmeticradical-algquat-rngelt"></a>
##### `ArithmeticRadical(O, p): AlgQuat, RngElt -> AlgQuatOrdIdl`

Given an order $O$ over a number ring $R$ and a prime ideal $p$ in $R$, return the *Arithmetic Radical* of $O$ over $p$. This is the unique two-sided ideal $J$ of $O$ over $pO$ such that $J/pO$ is the Jacobson radical of $O/pO$.

<a id="function-radicalidealizer-algassvord-rngord-rngordidl"></a>
##### `RadicalIdealizer(O, p): AlgAssVOrd[RngOrd], RngOrdIdl -> AlgAssVOrd`

<a id="function-radicalidealizer-algquat-rngelt"></a>
##### `RadicalIdealizer(O, p): AlgQuat, RngElt -> AlgQuat`

```magma
Side: MonStgElt                    Default: "Intersection"
```

Returns either the left or right order of the arithmetical radical of $O$ at $p$ or the intersection of these two orders, depending on whether `Side` is `"Left"`, `"Right"`, or `"Intersection"`.

<a id="function-neighbors-algassvordidl-rngordidl"></a>
##### `Neighbors(I, p): AlgAssVOrdIdl, RngOrdIdl -> SeqEnum[AlgAssVOrdIdl]`

<a id="function-neighbors-algquatordidl-rngint"></a>
##### `Neighbors(I, p): AlgQuatOrdIdl, RngInt -> SeqEnum[AlgQuatOrdIdl]`

Returns the $p$-neighbors of the ideal $I$, namely the ideals $J \subseteq I$ such that ${\rm Nm}(J) = p {\rm Nm}(I)$. Currently, only implemented for squarefree ideals $p$ coprime to ${\rm Disc}(O) {\rm Nm}(I)$, where $O$ is `Order(I)`.

<a id="function-elementsofnorm-algassvordidl-rngelt"></a>
##### `ElementsOfNorm(I, n): AlgAssVOrdIdl, RngElt -> SeqEnum`

```magma
ModUnits: BoolElt                    Default: false
```

Returns the elements in $I$ of norm $n$. Currently, only implemented when $I$ is an ideal in a definite quaternion algebra. If `ModUnits` is set to `true`, returns only one representative from every orbit under the action of the group of units of norm $1$ in $O$, where $O$ is `Order(I)`.

#### Bases of Ideals

In this section, $I$ is an ideal of an order $O$ in an associative algebra.

<a id="function-denominator-algassvordidl"></a>
##### `Denominator(I): AlgAssVOrdIdl -> RngElt`

This returns an element $d$ of `BaseRing(O)` such that $d I \subseteq O$, where $O$ is `Order(I)`.

<a id="function-pseudobasis-algassvordidl-rngord"></a>
##### `PseudoBasis(I): AlgAssVOrdIdl[RngOrd] -> SeqEnum`

Given an ideal $I$ of an order over $R$, where $R$ is an order in a number field, this returns data describing $I$ as an $R$-module. It returns a sequence of tuples $\langle I_i, b_i \rangle$ where $I_i$ is an ideal of $R$ and $b_i$ is an element of `Algebra(I)`, such that $I$ is the direct sum of the $R$-modules $I_i b_i$. In particular, the $b_i$ form a basis of `Algebra(I)` as a vector space over the field of fractions of $R$. Note that the $b_i$ may not lie in $I$.

<a id="function-pseudomatrix-algassvordidl-rngord"></a>
##### `PseudoMatrix(I): AlgAssVOrdIdl[RngOrd] -> PMat`

<a id="function-pseudomatrix-algassvordidl-rngfunord"></a>
##### `PseudoMatrix(I): AlgAssVOrdIdl[RngFunOrd] -> PMat`

Returns the pseudomatrix corresponding to `PseudoBasis(I)`.

<a id="function-basis-algassvordidl"></a>
##### `Basis(I): AlgAssVOrdIdl -> SeqEnum`

When $I$ is an ideal of an order over ${\mathbb{Z}}$, this returns a ${\mathbb{Z}}$-module basis of $I$.

When the base ring of `Order(I)` is an extension of ${\mathbb{Z}}$, this returns part of the data returned by `PseudoBasis(I)`: it returns a basis of `Algebra(I)`. Note that this determines nothing about $I$, while the full data returned by `PseudoBasis(I)` determines $I$.

<a id="function-basismatrix-algassvordidl"></a>
##### `BasisMatrix(I): AlgAssVOrdIdl -> AlgMatElt`

This returns `Basis(I)` as a row matrix.

<a id="function-zbasis-algassvordidl-rngord"></a>
##### `ZBasis(I): AlgAssVOrdIdl[RngOrd] -> [AlgAssVOrdElt]`

Returns a ${\mathbb{Z}}$-module basis for the ideal $I$.

<a id="function-generators-algassvordidl-rngord"></a>
##### `Generators(I): AlgAssVOrdIdl[RngOrd] -> [AlgAssVOrdElt]`

Returns a sequence of generators for the ideal $I$ as a module over its base ring.

<a id="function-localbasis-algassvordidl-rngordidl"></a>
##### `LocalBasis(I, p): AlgAssVOrdIdl, RngOrdIdl -> [AlgAssElt]`

```magma
Type: MonStgElt                    Default: ""
```

Given an ideal $I$ of an $R$-order in an algebra $A$, this function returns a basis of a free $R$-module $F$ in $A$ such that $I$ and $F$ agree at the completion at the prime ideal $p$ of $R$. If `Type` is specified, it must either be `"Submodule"` or `"Supermodule"`. In which case $F$ is either a sub- or supermodule of $I$.

<a id="function-pseudobasis-algassvordidl-rngord-str"></a>
##### `PseudoBasis(I, R): AlgAssVOrdIdl[RngOrd], Str -> SeqEnum`

<a id="function-pseudomatrix-algassvordidl-rngord-str"></a>
##### `PseudoMatrix(I, R): AlgAssVOrdIdl[RngOrd], Str -> PMat`

<a id="function-basis-algassvordidl-str"></a>
##### `Basis(I, R): AlgAssVOrdIdl, Str -> SeqEnum`

<a id="function-basismatrix-algassvordidl-str"></a>
##### `BasisMatrix(I, R): AlgAssVOrdIdl, Str -> AlgMatElt`

In these variants of the functions described above, the elements of the basis are expressed with respect to the basis of $R$, where $R$ is some ring contained in $A =$ `Algebra(I)` such that $R \otimes F = A$ where $F$ is the base field of $A$.

#### Arithmetic for Ideals

<a id="operation-op-plus-algassvordidl-algassvordidl"></a>
##### `I + J: AlgAssVOrdIdl, AlgAssVOrdIdl -> AlgAssVOrdIdl`

The sum of the ideals $I$ and $J$, which are ideals which share a side in equal orders.

<a id="operation-op-times-algassvordidl-algassvordidl"></a>
##### `I * J: AlgAssVOrdIdl, AlgAssVOrdIdl -> AlgAssVOrdIdl, AlgAssVOrdIdl`

<a id="operation-op-times-algassvordidl-rngord-algassvordidl-rngord"></a>
##### `I * J: AlgAssVOrdIdl[RngOrd], AlgAssVOrdIdl[RngOrd] -> AlgAssVOrdIdl, AlgAssVOrdIdl`

The product of the ideals $I$ and $J$, where $I$ is a right ideal and $J$ is a left ideal of the same order $O$. Returns the product given the structure of left and right ideal.

<a id="operation-op-times-rngelt-algassvordidl"></a>
##### `a * I: RngElt, AlgAssVOrdIdl -> AlgAssVOrdIdl`

<a id="operation-op-times-algassvordidl-rngelt"></a>
##### `I * a: AlgAssVOrdIdl, RngElt -> AlgAssVOrdIdl`

<a id="operation-op-times-rngelt-algquatordidl"></a>
##### `a * I: RngElt, AlgQuatOrdIdl -> AlgQuatOrdIdl`

<a id="operation-op-times-algquatordidl-rngelt"></a>
##### `I * a: AlgQuatOrdIdl, RngElt -> AlgQuatOrdIdl`

Returns the product of $a$ and $I$ as an ideal.

<a id="operation-op-times-rngordfracidl-algassvordidl-rngord"></a>
##### `A * I: RngOrdFracIdl, AlgAssVOrdIdl[RngOrd] -> AlgAssVOrdIdl`

<a id="operation-op-times-rngordfracidl-algassvordidl-rngord-2"></a>
##### `I * A: RngOrdFracIdl, AlgAssVOrdIdl[RngOrd] -> AlgAssVOrdIdl`

Returns the product of a fractional ideal $A$ of the base ring with $I$ as an ideal.

<a id="function-colon-algassvordidl-rngord-algassvordidl-rngord"></a>
##### `Colon(J, I): AlgAssVOrdIdl[RngOrd], AlgAssVOrdIdl[RngOrd] -> PMat`

If $I,J$ are left ideals, returns the colon $(J:I)=\{x \in A: xI \subset J\}$, similarly defined if $I,J$ are right ideals.

<a id="function-multiplicatorring-algassvordidl"></a>
##### `MultiplicatorRing(I): AlgAssVOrdIdl -> AlgAssVOrd`

Returns the colon $(I:I)$ of the ideal $I$, the set of all elements which multiply $I$ into $I$.

#### Predicates on Ideals

<a id="function-isleftideal-algassvordidl"></a>
##### `IsLeftIdeal(I): AlgAssVOrdIdl -> BoolElt`

<a id="function-isrightideal-algassvordidl"></a>
##### `IsRightIdeal(I): AlgAssVOrdIdl -> BoolElt`

<a id="function-istwosidedideal-algassvordidl"></a>
##### `IsTwoSidedIdeal(I): AlgAssVOrdIdl -> BoolElt`

Return `true` if the associative ideal $I$ is a left, right, or two sided ideal (respectively).

<a id="operation-op-eq-algassvordidl-algassvordidl"></a>
##### `I eq J: AlgAssVOrdIdl, AlgAssVOrdIdl -> BoolElt`

Return `true` if the associative ideals $I$ and $J$ are equal.

<a id="operation-op-subset-algassvordidl-algassvordidl"></a>
##### `I subset J: AlgAssVOrdIdl, AlgAssVOrdIdl -> BoolElt`

Returns `true` if and only if the ideal $I$ is contained in the ideal $J$.

<a id="operation-op-in-algassvelt-algassvordidl"></a>
##### `a in I: AlgAssVElt, AlgAssVOrdIdl -> BoolElt`

<a id="operation-op-notin-algassvelt-algassvordidl"></a>
##### `a notin I: AlgAssVElt, AlgAssVOrdIdl -> BoolElt`

Return `true` (`false`) if the element $a$ of an associative algebra is contained in the associative ideal $I$.

#### Other Operations on Ideals

<a id="function-norm-algassvordidl-rngord"></a>
##### `Norm(I): AlgAssVOrdIdl[RngOrd] -> RngOrdIdl`

Returns the norm of the ideal $I$, the ideal of the base number ring of $I$ generated by the norms of the elements in $I$.

<a id="example-ex-d618e7"></a>
##### `Example: One-Sided Ideals of an Order (ex-d618e7)`

```magma
> F<w> := CyclotomicField(3);
> R := MaximalOrder(F);
> A := Algebra(FPAlgebra<F, x, y | x^3-3, y^3+5, y*x-w*x*y>);
> O := Order([A.i : i in [1..9]]);
> MinimalPolynomial(O.2);
$.1^3 + 5/1*R.1
> I := rideal<O | O.2>;
> IsLeftIdeal(I), IsRightIdeal(I), IsTwoSidedIdeal(I);
false true false
> MultiplicatorRing(I) eq O;
true
> PseudoBasis(I);
[
    <Principal Ideal of R
    Generator:
        R.1, (0 R.1 0 0 0 0 0 0 0)>,
    <Principal Ideal of R
    Generator:
        R.1, (0 0 0 R.1 0 0 0 0 0)>,
    <Principal Ideal of R
    Generator:
        R.1, (0 0 0 0 -R.1 - R.2 0 0 0 0)>,
    <Principal Ideal of R
    Generator:
        R.1, (-5/1*R.1 0 0 0 0 0 0 0 0)>,
    <Principal Ideal of R
    Generator:
        R.1, (0 0 0 0 0 0 -R.1 - R.2 0 0)>,
    <Principal Ideal of R
    Generator:
        R.1, (0 0 0 0 0 0 0 R.2 0)>,
    <Principal Ideal of R
    Generator:
        R.1, (0 0 5/1*R.1 + 5/1*R.2 0 0 0 0 0 0)>,
    <Principal Ideal of R
    Generator:
        R.1, (0 0 0 0 0 0 0 0 R.2)>,
    <Principal Ideal of R
    Generator:
        R.1, (0 0 0 0 0 -5/1*R.2 0 0 0)>
]
> ZBasis(I);
[ [0 R.1 0 0 0 0 0 0 0], [0 R.2 0 0 0 0 0 0 0], [0 0 0 R.1 0 0 0 0 0], [0 0 0
    R.2 0 0 0 0 0], [0 0 0 0 -R.1 - R.2 0 0 0 0], [0 0 0 0 R.1 0 0 0 0],
    [-5/1*R.1 0 0 0 0 0 0 0 0], [-5/1*R.2 0 0 0 0 0 0 0 0] ]
> Norm(I);
Principal Ideal of R
Generator:
    15625/1*R.1
> J := rideal<O | O.3>;
> Norm(J);
Principal Ideal of R
Generator:
    729/1*R.1
> A!1 in I+J;
false
> Denominator(1/6*I);
[1, 0]
> Colon(J,I);
Pseudo-matrix over Maximal Equation Order with defining polynomial x^2 + x + 1
over its ground order
Principal Ideal of R
Generator:
    3/1*R.1 * ( R.1 0 0 0 0 0 0 0 0 )
Principal Ideal of R
Generator:
    3/1*R.1 * ( 0 R.1 0 0 0 0 0 0 0 )
Principal Ideal of R
Generator:
    R.1 * ( 0 0 R.1 0 0 0 0 0 0 )
Fractional Principal Ideal of R
Generator:
    3/5*R.1 * ( 0 0 0 R.1 0 0 0 0 0 )
Principal Ideal of R
Generator:
    R.1 * ( 0 0 0 0 R.1 0 0 0 0 )
Principal Ideal of R
Generator:
    R.1 * ( 0 0 0 0 0 R.1 0 0 0 )
Fractional Principal Ideal of R
Generator:
    -1/5*R.1 * ( 0 0 0 0 0 0 R.1 0 0 )
Principal Ideal of R
Generator:
    R.1 * ( 0 0 0 0 0 0 0 R.1 0 )
Fractional Principal Ideal of R
Generator:
    1/5*R.1 * ( 0 0 0 0 0 0 0 0 R.1 )
```

<a id="finitely-presented"></a>
<a id="chap-fpa"></a>
## Finitely Presented Algebras

- [Introduction](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/introduction.md)
- [Representation and Monomial Orders](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/order.md)
- [Exterior Algebras](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/exterior.md)
- [Creation of Free Algebras and Elements](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/algebras.md)
  - [Creation of Free Algebras](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/algebras.md#creation-of-free-algebras)
    - [`FreeAlgebra(K, n): Fld, RngIntElt → AlgFr`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/algebras.md#function-freealgebra-fld-rngintelt)
    - [`ExteriorAlgebra(K, n): Fld, RngIntElt → AlgExt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/algebras.md#function-fpa-exterioralgebra)
  - [Print Names](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/algebras.md#print-names)
    - [`AssignNames(~F, s): AlgFr, [ MonStgElt ]`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/algebras.md#procedure-assignnames-algfr-monstgelt-ref)
    - [`Name(F, i): AlgFr, RngIntElt → AlgFrElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/algebras.md#function-name-algfr-rngintelt)
  - [Creation of Polynomials](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/algebras.md#creation-of-polynomials)
    - [`F . i: AlgFr, RngInt → AlgFrElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/algebras.md#operation-operation-algfr-rngint-algfrelt)
    - [`elt< R | a >: AlgFr, RngElt → AlgFrElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/algebras.md#constructor-constructor-elt-algfr-rngelt-algfrelt)
    - [`R ! s: AlgFr, RngElt → AlgFrElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/algebras.md#operation-op-algfr-rngelt)
    - [`R ! s: AlgFr, [ RngElt ] → AlgFrElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/algebras.md#operation-op-algfr-rngelt-2)
    - [`elt< R | s >: AlgFr, [ RngElt ] → AlgFrElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/algebras.md#constructor-constructor-elt-algfr-rngelt-algfrelt-2)
    - [`One(F): AlgFr → AlgFrElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/algebras.md#function-one-algfr)
    - [`Identity(F): AlgFr → AlgFrElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/algebras.md#function-identity-algfr)
    - [`Zero(F): AlgFr → AlgFrElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/algebras.md#function-zero-algfr)
    - [`Representative(F): AlgFr → AlgFrElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/algebras.md#function-representative-algfr)
- [Structure Operations](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation.md)
  - [Related Structures](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation.md#related-structures)
    - [`BaseRing(F): AlgFr → Rng`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation.md#function-basering-algfr)
    - [`CoefficientRing(F): AlgFr → Rng`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation.md#function-coefficientring-algfr)
    - [`Category(F): AlgFr → Cat`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation.md#function-category-algfr)
    - [`Parent(F): AlgFr → Pow`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation.md#function-parent-algfr)
    - [`PrimeRing(F): AlgFr → Rng`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation.md#function-primering-algfr)
  - [Numerical Invariants](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation.md#numerical-invariants)
    - [`Rank(F): AlgFr → RngIntElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation.md#function-rank-algfr)
    - [`Characteristic(F): AlgFr → RngIntElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation.md#function-characteristic-algfr)
    - [`# F: AlgFr → RngIntElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation.md#operation-operation-algfr-rngintelt)
  - [Homomorphisms](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation.md#homomorphisms)
    - [`hom< F -> S | f, y₁, ..., yₙ >: AlgFr, Rng → Map`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation.md#constructor-constructor-hom-algfr-rng-map)
    - [`hom< F -> S | y₁, ..., yₙ >: AlgFr, Rng → Map`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation.md#constructor-constructor-hom-algfr-rng-map-2)
    - [Example: Homomorphisms from a Free Algebra](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation.md#example-ex-15e82d)
- [Element Operations](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation-element.md)
  - [Arithmetic Operators](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation-element.md#arithmetic-operators)
    - [`+ a: AlgFrElt → AlgFrElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation-element.md#operation-operation-algfrelt-algfrelt)
    - [`- a: AlgFrElt → AlgFrElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation-element.md#operation-operation-algfrelt-algfrelt-2)
    - [`a + b: AlgFrElt, AlgFrElt → AlgFrElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation-element.md#operation-op-plus-algfrelt-algfrelt)
    - [`a - b: AlgFrElt, AlgFrElt → AlgFrElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation-element.md#operation-op-minus-algfrelt-algfrelt)
    - [`a * b: AlgFrElt, AlgFrElt → AlgFrElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation-element.md#operation-op-times-algfrelt-algfrelt)
    - [`a ^ k: AlgFrElt, RngIntElt → AlgFrElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation-element.md#operation-op-pow-algfrelt-rngintelt)
    - [`a / b: AlgFrElt, AlgFrElt → FldFunMElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation-element.md#operation-op-div-algfrelt-algfrelt)
    - [`a div b: AlgFrElt, AlgFrElt → AlgFrElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation-element.md#operation-operation-div-algfrelt-algfrelt-algfrelt)
    - [`a +:= b: AlgFrElt, AlgFrElt → AlgFrElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation-element.md#operation-operation-algfrelt-algfrelt-algfrelt)
    - [`a -:= b: AlgFrElt, AlgFrElt → AlgFrElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation-element.md#operation-operation-algfrelt-algfrelt-algfrelt-2)
    - [`a *:= b: AlgFrElt, AlgFrElt → AlgFrElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation-element.md#operation-operation-algfrelt-algfrelt-algfrelt-3)
    - [`a div:= b: AlgFrElt, AlgFrElt → AlgFrElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation-element.md#operation-operation-div-algfrelt-algfrelt-algfrelt-2)
  - [Equality and Membership](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation-element.md#equality-and-membership)
    - [`a eq b: AlgFrElt, AlgFrElt → BoolElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation-element.md#operation-op-eq-algfrelt-algfrelt)
    - [`a ne b: AlgFrElt, AlgFrElt → BoolElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation-element.md#operation-op-ne-algfrelt-algfrelt)
    - [`a in R: AlgFrElt, Rng → BoolElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation-element.md#operation-op-in-algfrelt-rng)
    - [`a notin R: AlgFrElt, Rng → BoolElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation-element.md#operation-op-notin-algfrelt-rng)
  - [Predicates on Algebra Elements](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation-element.md#predicates-on-algebra-elements)
    - [`IsZero(f): AlgFrElt → BoolElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation-element.md#function-iszero-algfrelt)
    - [`IsOne(f): AlgFrElt → BoolElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation-element.md#function-isone-algfrelt)
    - [`IsMinusOne(f): AlgFrElt → BoolElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation-element.md#function-isminusone-algfrelt)
    - [`IsNilpotent(f): AlgFrElt → BoolElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation-element.md#function-isnilpotent-algfrelt)
    - [`IsIdempotent(f): AlgFrElt → BoolElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation-element.md#function-isidempotent-algfrelt)
    - [`IsUnit(f): AlgFrElt → BoolElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation-element.md#function-isunit-algfrelt)
    - [`IsZeroDivisor(f): AlgFrElt → BoolElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation-element.md#function-iszerodivisor-algfrelt)
    - [`IsRegular(f): AlgFrElt → BoolElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation-element.md#function-isregular-algfrelt)
    - [`IsIrreducible(f): AlgFrElt → BoolElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation-element.md#function-isirreducible-algfrelt)
    - [`IsPrime(f): AlgFrElt → BoolElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation-element.md#function-isprime-algfrelt)
  - [Coefficients, Monomials, Terms, and Degree](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation-element.md#coefficients-monomials-terms-and-degree)
    - [`Coefficients(f): AlgFrElt → [ RngElt ]`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation-element.md#function-coefficients-algfrelt)
    - [`LeadingCoefficient(f): AlgFrElt → RngElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation-element.md#function-leadingcoefficient-algfrelt)
    - [`TrailingCoefficient(f): AlgFrElt → RngElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation-element.md#function-trailingcoefficient-algfrelt)
    - [`MonomialCoefficient(f, m): AlgFrElt, AlgFrElt → RngElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation-element.md#function-monomialcoefficient-algfrelt-algfrelt)
    - [`Monomials(f): AlgFrElt → [ AlgFrElt ]`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation-element.md#function-monomials-algfrelt)
    - [`LeadingMonomial(f): AlgFrElt → AlgFrElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation-element.md#function-leadingmonomial-algfrelt)
    - [`Terms(f): AlgFrElt → [ AlgFrElt ]`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation-element.md#function-terms-algfrelt)
    - [`LeadingTerm(f): AlgFrElt → AlgFrElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation-element.md#function-leadingterm-algfrelt)
    - [`TrailingTerm(f): AlgFrElt → RngElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation-element.md#function-trailingterm-algfrelt)
    - [`Length(m): AlgFrElt → RngIntElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation-element.md#function-length-algfrelt)
    - [`m[i]: AlgFrElt, RngIntElt → AlgFrElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation-element.md#literal-literal-m-i-algfrelt-rngintelt-algfrelt)
    - [`TotalDegree(f): AlgFrElt → RngIntElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation-element.md#function-totaldegree-algfrelt)
    - [`LeadingTotalDegree(f): AlgFrElt → RngIntElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation-element.md#function-leadingtotaldegree-algfrelt)
    - [Example: Monomials and Terms of an Element](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation-element.md#example-ex-4ecfe7)
  - [Evaluation](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation-element.md#evaluation)
    - [`Evaluate(f, s): AlgFrElt, [ RngElt ] → RngElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation-element.md#function-evaluate-algfrelt-rngelt)
    - [`Evaluate(f, s): AlgFrElt, < RngElt, ..., RngElt > → RngElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation-element.md#function-evaluate-algfrelt-rngelt-rngelt)
    - [Example: Evaluating an Element of a Free Algebra](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operation-element.md#example-ex-88ec97)
- [Ideals and Gröbner Bases](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/ideals.md)
  - [Creation of Ideals](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/ideals.md#creation-of-ideals)
    - [`ideal<A | L>: AlgFr, List → AlgFr`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/ideals.md#constructor-constructor-ideal-algfr-list-algfr)
    - [`lideal<A | L>: AlgFr, List → AlgFr`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/ideals.md#constructor-constructor-lideal-algfr-list-algfr)
    - [`rideal<A | L>: AlgFr, List → AlgFr`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/ideals.md#constructor-constructor-rideal-algfr-list-algfr)
    - [`Basis(I): AlgFr → [ AlgFrElt ]`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/ideals.md#function-basis-algfr)
    - [`BasisElement(I, i): AlgFr, RngIntElt → AlgFrElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/ideals.md#function-basiselement-algfr-rngintelt)
  - [Gröbner Bases](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/ideals.md#grobner-bases)
    - [`Groebner(I: parameters): AlgFr`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/ideals.md#procedure-fpa-groebner)
    - [`GroebnerBasis(I: parameters): AlgFr → AlgFrElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/ideals.md#function-fpa-groebnerbasis)
    - [`GroebnerBasis(S: parameters): [ AlgFrElt ] → [ AlgFrElt ]`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/ideals.md#function-groebnerbasis-algfrelt)
    - [`GroebnerBasis(S: parameters): { AlgFrElt } → [ AlgFrElt ]`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/ideals.md#function-groebnerbasis-algfrelt-2)
    - [`GroebnerBasis(S, d: parameters): [ AlgFr ], RngInt → AlgFrElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/ideals.md#function-fpa-gb-deg)
  - [Verbosity](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/ideals.md#verbosity)
    - [`SetVerbose("Groebner", v): MonStgElt, RngIntElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/ideals.md#procedure-setverbose-monstgelt-rngintelt-groebner)
    - [`SetVerbose("Buchberger", v): MonStgElt, RngIntElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/ideals.md#procedure-setverbose-monstgelt-rngintelt-buchberger)
    - [`SetVerbose("Faugere", v): MonStgElt, RngIntElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/ideals.md#procedure-setverbose-monstgelt-rngintelt-faugere)
  - [Related Functions](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/ideals.md#related-functions)
    - [`MarkGroebner(I): AlgFr`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/ideals.md#procedure-markgroebner-algfr)
    - [`Reduce(S): [ AlgFrElt ] → [ AlgFrElt ]`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/ideals.md#function-fpa-reduce)
    - [`Reduce(S): { AlgFrElt } → [ AlgFrElt ]`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/ideals.md#function-reduce-algfrelt)
    - [Example: One-Sided and Two-Sided Groebner Bases](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/ideals.md#example-ex-45e44f)
- [Basic Operations on Ideals](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/ideal-operation.md)
  - [Construction of New Ideals](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/ideal-operation.md#construction-of-new-ideals)
    - [`I + J: AlgFr, AlgFr → AlgFr`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/ideal-operation.md#operation-op-plus-algfr-algfr)
    - [`I * J: AlgFr, AlgFr → AlgFr`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/ideal-operation.md#operation-op-times-algfr-algfr)
    - [`F / J: AlgFr, AlgFr → AlgFrRes`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/ideal-operation.md#operation-op-div-algfr-algfr)
    - [`Generic(I): AlgFr → AlgFr`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/ideal-operation.md#function-generic-algfr)
  - [Ideal Predicates](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/ideal-operation.md#ideal-predicates)
    - [`I eq J: AlgFr, AlgFr → BoolElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/ideal-operation.md#operation-op-eq-algfr-algfr)
    - [`I ne J: AlgFr, AlgFr → BoolElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/ideal-operation.md#operation-op-ne-algfr-algfr)
    - [`I notsubset J: AlgFr, AlgFr → BoolElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/ideal-operation.md#operation-operation-notsubset-algfr-algfr-boolelt)
    - [`I subset J: AlgFr, AlgFr → BoolElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/ideal-operation.md#operation-op-subset-algfr-algfr)
    - [`IsZero(I): AlgFr → BoolElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/ideal-operation.md#function-iszero-algfr)
  - [Operations on Elements of Ideals](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/ideal-operation.md#operations-on-elements-of-ideals)
    - [`f in I: AlgFrElt, AlgFr → BoolElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/ideal-operation.md#operation-op-in-algfrelt-algfr)
    - [`NormalForm(f, I): AlgFrElt, AlgFr → AlgFrElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/ideal-operation.md#function-normalform-algfrelt-algfr)
    - [`NormalForm(f, S): AlgFrElt, [ AlgFrElt ] → AlgFrElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/ideal-operation.md#function-normalform-algfrelt-algfrelt)
    - [`f notin I: AlgFrElt, AlgFr → BoolElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/ideal-operation.md#operation-op-notin-algfrelt-algfr)
    - [Example: Normal Forms Modulo an Ideal](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/ideal-operation.md#example-ex-3dd8c1)
- [Changing Coefficient Ring](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/change-ring.md)
  - [`ChangeRing(I, S): AlgFr, Rng → AlgFr`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/change-ring.md#function-fpa-changering)
- [Finitely Presented Algebras](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/fp-algebra.md)
- [Creation of FP-Algebras](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/creation.md)
  - [`quo< F | J >: AlgFr, AlgFr → AlgFP`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/creation.md#constructor-constructor-quo-algfr-algfr-algfp)
  - [`quo< F | a₁, ..., aᵣ >: AlgFr, AlgFrElt, ..., AlgFrElt → AlgFrRes, Map`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/creation.md#constructor-constructor-quo-algfr-algfrelt-algfrelt-algfrres-map)
  - [`F / J: AlgFr, AlgFr → AlgFP`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/creation.md#operation-op-div-algfr-algfr-2)
  - [`FPAlgebra< K, X | L >: Fld, List, List → AlgFP`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/creation.md#constructor-constructor-fpalgebra-fld-list-list-algfp)
  - [Example: Creating FP-Algebras](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/creation.md#example-ex-8d1242)
- [Operations on FP-Algebras](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operations.md)
  - [`A . i: AlgFP, RngIntElt → AlgFPElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operations.md#operation-operation-algfp-rngintelt-algfpelt)
  - [`CoefficientRing(A): AlgFP → Rng`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operations.md#function-coefficientring-algfp)
  - [`Rank(A): AlgFP → RngIntElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operations.md#function-rank-algfp)
  - [`DivisorIdeal(I): AlgFP → AlgFr`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operations.md#function-divisorideal-algfp)
  - [`PreimageIdeal(I): AlgFP → AlgFr`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operations.md#function-preimageideal-algfp)
  - [`PreimageRing(A): AlgFP → AlgFr`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operations.md#function-preimagering-algfp)
  - [`OriginalRing(A): AlgFP → Rng`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operations.md#function-originalring-algfp)
  - [`IsCommutative(A): AlgFP → BoolElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operations.md#function-iscommutative-algfp)
  - [`I eq J: AlgFP, AlgFP → BoolElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operations.md#operation-op-eq-algfp-algfp)
  - [`I subset J: AlgFP, AlgFP → BoolElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operations.md#operation-op-subset-algfp-algfp)
  - [`I + J: AlgFP, AlgFP → AlgFP`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operations.md#operation-op-plus-algfp-algfp)
  - [`I * J: AlgFP, AlgFP → AlgFP`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operations.md#operation-op-times-algfp-algfp)
  - [`IsProper(I): AlgFP → BoolElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operations.md#function-isproper-algfp)
  - [`IsZero(I): AlgFP → BoolElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/operations.md#function-iszero-algfp)
- [Finite Dimensional FP-Algebras](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/finite-dimension-quotient.md)
  - [`Dimension(A): AlgFP → RngIntElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/finite-dimension-quotient.md#function-dimension-algfp)
  - [`VectorSpace(A): AlgFP → ModTupFld, Map`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/finite-dimension-quotient.md#function-vectorspace-algfp)
  - [`MatrixAlgebra(A): AlgFP → AlgMat, Map`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/finite-dimension-quotient.md#function-matrixalgebra-algfp)
  - [`Algebra(A): AlgFP → AlgAss, Map`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/finite-dimension-quotient.md#function-algebra-algfp)
  - [`RepresentationMatrix(f): AlgFPElt → AlgMatElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/finite-dimension-quotient.md#function-representationmatrix-algfpelt)
  - [`IsUnit(f): AlgFPElt → BoolElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/finite-dimension-quotient.md#function-isunit-algfpelt)
  - [`IsNilpotent(f): AlgFPElt → BoolElt, RngIntElt`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/finite-dimension-quotient.md#function-isnilpotent-algfpelt)
  - [`MinimalPolynomial(f): AlgFPElt → RngUPol`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/finite-dimension-quotient.md#function-minimalpolynomial-algfpelt)
  - [Example: Functions for a Finite-Dimensional FP-Algebra](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/finite-dimension-quotient.md#example-ex-b673ef)
- [Vector Enumeration](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/vector-enumeration.md)
  - [Finitely Presented Modules](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/vector-enumeration.md#finitely-presented-modules)
  - [$S$-algebras](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/vector-enumeration.md#s-algebras)
  - [Finitely Presented Algebras](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/vector-enumeration.md#finitely-presented-algebras)
  - [Vector Enumeration](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/vector-enumeration.md#id1)
    - [Example: Vector Enumeration in the Abstract](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/vector-enumeration.md#example-ex-d47ce9)
  - [The Isomorphism](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/vector-enumeration.md#the-isomorphism)
  - [Sketch of the Algorithm](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/vector-enumeration.md#sketch-of-the-algorithm)
  - [Weights](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/vector-enumeration.md#weights)
  - [Setup Functions](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/vector-enumeration.md#setup-functions)
    - [`FreeAlgebra(R, M): Rng, MonFP → AlgFPOld`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/vector-enumeration.md#function-freealgebra-rng-monfp)
    - [`FreeAlgebra(R, G): Rng, GrpFP → AlgFPOld`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/vector-enumeration.md#function-freealgebra-rng-grpfp)
  - [The Quotient Module Function](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/vector-enumeration.md#the-quotient-module-function)
    - [`QuotientModule(A, S): AlgFPOld, AlgFPOld → [AlgMatElt], [ModTupFldElt], [AlgFPEltOld]`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/vector-enumeration.md#function-quotientmodule-algfpold-algfpold)
  - [Structuring Presentations](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/vector-enumeration.md#structuring-presentations)
  - [Options and Controls](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/vector-enumeration.md#options-and-controls)
  - [Weights](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/vector-enumeration.md#id2)
    - [`QuotientModule(A, S): AlgFP, AlgFP → AlgFP`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/vector-enumeration.md#function-quotientmodule-algfp-algfp)
  - [Limits](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/vector-enumeration.md#limits)
    - [`QuotientModule(A, S): AlgFP, AlgFP → AlgFP`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/vector-enumeration.md#function-quotientmodule-algfp-algfp-2)
  - [Logging](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/vector-enumeration.md#logging)
    - [`QuotientModule(A, S): AlgFP, AlgFP → AlgFP`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/vector-enumeration.md#function-quotientmodule-algfp-algfp-3)
  - [Miscellaneous](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/vector-enumeration.md#miscellaneous)
    - [`QuotientModule(A, S): AlgFP, AlgFP → AlgFP`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/vector-enumeration.md#function-quotientmodule-algfp-algfp-4)
    - [Example: Permutation Action of D8](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/vector-enumeration.md#example-ex-80fd44)
    - [Example: Quotient of a Permutation Module](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/vector-enumeration.md#example-ex-631bdb)
- [Bibliography](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/bibliography.md)

### Introduction

This chapter describes finitely presented algebras (FPAs) in Magma. An FPA is a quotient of a free associative algebra by an ideal of relations. To compute with these ideals, one constructs *noncommutative* Gröbner bases (GBs), which have many parallels with the standard commutative GBs, discussed in Chapter [Gröbner Bases](https://docs.magma-maths.org/CommutativeAlgebra/GrobnerBases/index-grobner-bases.md#chapgb). At the heart of the theory is a noncommutative version of the *Buchberger algorithm* which computes a GB of an ideal of an algebra starting from an arbitrary basis (generating set) of the ideal. One significant difference with the commutative case is that a noncommutative GB may not be finite for a finitely-generated ideal. For overviews of the theory and the basic algorithms, see [[Li02](https://docs.magma-maths.org/references.md#cite-li-noncommut), [Mor94](https://docs.magma-maths.org/references.md#cite-moranoncommut)]. Magma also contains an implementation of a noncommutative generalization of the Faugere $F_4$ algorithm (due to Allan Steel), based on sparse linear algebra techniques, which usually performs dramatically better than the Buchberger algorithm, and so this is used by Magma by default.

### Representation and Monomial Orders

Let $A$ be the free algebra $K\langle x_1, \ldots, x_n\rangle$ of rank $n$ over a field $K$. A word in the underlying monoid of $A$ is simply an associative product of the letters (or variables) of $A$. For consistency with the commutative case, we will call these monoid words *monomials*. Elements of $A$, called noncommutative polynomials, are finite sums of terms, where a term is the product of a coefficient from $K$ and a monomial. The terms are sorted with respect to an admissible order $<$, which satisfies, for monomials $p,q,r$, the following conditions:

**(a)**
If $p<q$, then $pr < qr$ and $sp < sq$.

**(b)**
If $p=qr$ then $p > q$ and $p > r$. Currently Magma only supports the noncommutative graded-lexicographical order (*glex*), which first compares degrees and then uses a left-lexicographical comparison for degree-ties. There is no admissible lexicographic order in the noncommutative case.

### Exterior Algebras

Since V2.15 (December 2008), Magma has a special type for *exterior algebras*. Such an algebra is skew-commutative and is a quotient of the free algebra $K\langle x_1, \ldots, x_n\rangle$ by the relations $x_i^2 = 0$ and $x_i x_j = -x_j x_i$ for $1 \leq i,j \leq n$, $i \not= j$. Because of these relations, elements of the algebra can be written in terms of commutative monomials in the variables (via a collection algorithm), and the associated algorithms are much more efficient than for the general noncommutative case. Also, a Gröbner basis of an ideal of an exterior algebra is always finite (in fact, the whole exterior algebra has dimension $2^n$ as a $K$-vector space). Exterior algebras may be constructed with the [`ExteriorAlgebra`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/algebras.md#function-fpa-exterioralgebra) function below, and all operations applicable to general FP algebras are also applicable to them (so will not be duplicated here). Furthermore, modules over exterior algebras are also allowed: see Chapter [Modules over Multivariate Rings](https://docs.magma-maths.org/CommutativeAlgebra/ModulesOverMultivariateRings/index-modules-over-multivariate-rings.md#pmod-chap) for details.

### Creation of Free Algebras and Elements

#### Creation of Free Algebras

Currently algebras may only be created over fields. Free algebras are objects of type `AlgFr` with elements of type `AlgFrElt`.

<a id="function-freealgebra-fld-rngintelt"></a>
##### `FreeAlgebra(K, n): Fld, RngIntElt -> AlgFr`

Create a free algebra in $n>0$ variables over the field $K$. The angle bracket notation can be used to assign names to the indeterminates; e.g., `F<a,b,c> := FreeAlgebra(GF(2), 3);`.

<a id="function-fpa-exterioralgebra"></a>
##### `ExteriorAlgebra(K, n): Fld, RngIntElt -> AlgExt`

Create an exterior algebra in $n>0$ variables over the field $K$. The angle bracket notation can be used to assign names to the indeterminates; The angle bracket notation can be used to assign names to the indeterminates; e.g., `F<a,b,c> := ExteriorAlgebra(GF(2), 3);`.

#### Print Names

The `AssignNames` and `Name` functions can be used to associate names with the indeterminates of free algebras after creation.

<a id="procedure-assignnames-algfr-monstgelt-ref"></a>
##### `AssignNames(~F, s): AlgFr, [ MonStgElt ]`

Procedure to change the name of the indeterminates of a free algebra $F$. The $i$-th indeterminate will be given the name of the $i$-th element of the sequence of strings $s$ (for $1\leq i\leq \#s$); the sequence may have length less than the number of indeterminates of $F$, in which case the remaining indeterminate names remain unchanged. This procedure only changes the name used in printing the elements of $F$. It does *not* assign to identifiers corresponding to the strings the indeterminates in $F$; to do this, use an assignment statement, or use angle brackets when creating the free algebra.

<a id="function-name-algfr-rngintelt"></a>
##### `Name(F, i): AlgFr, RngIntElt -> AlgFrElt`

Given a free algebra $F$, return the $i$-th indeterminate of $F$ (as an element of $F$).

#### Creation of Polynomials

The easiest way to create (noncommutative) polynomials in a given algebra is to use the angle bracket construction to attach variables to the indeterminates, and then to use these variables to create polynomials (see the examples). Below we list other options.

<a id="operation-operation-algfr-rngint-algfrelt"></a>
##### `F . i: AlgFr, RngInt -> AlgFrElt`

Return the $i$-th indeterminate for the free algebra $F$ in $n$ variables ($1\leq i\leq n$) as an element of $F$.

<a id="constructor-constructor-elt-algfr-rngelt-algfrelt"></a>
##### `elt< R | a >: AlgFr, RngElt -> AlgFrElt`

<a id="operation-op-algfr-rngelt"></a>
##### `R ! s: AlgFr, RngElt -> AlgFrElt`

<a id="operation-op-algfr-rngelt-2"></a>
##### `R ! s: AlgFr, [ RngElt ] -> AlgFrElt`

<a id="constructor-constructor-elt-algfr-rngelt-algfrelt-2"></a>
##### `elt< R | s >: AlgFr, [ RngElt ] -> AlgFrElt`

This element constructor can only be used for trivial purposes in noncommutative free algebras: given a free algebra $F=R[x_1, \ldots, x_{n}]$ and an element $a$ that can be coerced into the coefficient ring $R$, the constant polynomial $a$ is returned; if $a$ is in $F$ already it will be returned unchanged.

<a id="function-one-algfr"></a>
##### `One(F): AlgFr -> AlgFrElt`

<a id="function-identity-algfr"></a>
##### `Identity(F): AlgFr -> AlgFrElt`

<a id="function-zero-algfr"></a>
##### `Zero(F): AlgFr -> AlgFrElt`

<a id="function-representative-algfr"></a>
##### `Representative(F): AlgFr -> AlgFrElt`

### Structure Operations

#### Related Structures

The main structure related to a free algebra is its coefficient ring. Multivariate free algebras belong to the Magma category `AlgFr`.

<a id="function-basering-algfr"></a>
##### `BaseRing(F): AlgFr -> Rng`

<a id="function-coefficientring-algfr"></a>
##### `CoefficientRing(F): AlgFr -> Rng`

Return the coefficient ring of the free algebra $F$.

<a id="function-category-algfr"></a>
##### `Category(F): AlgFr -> Cat`

<a id="function-parent-algfr"></a>
##### `Parent(F): AlgFr -> Pow`

<a id="function-primering-algfr"></a>
##### `PrimeRing(F): AlgFr -> Rng`

#### Numerical Invariants

Note that the `#` operator only returns a value for finite (quotients of) free algebras.

<a id="function-rank-algfr"></a>
##### `Rank(F): AlgFr -> RngIntElt`

Return the number of indeterminates of free algebra $F$ over its coefficient ring.

<a id="function-characteristic-algfr"></a>
##### `Characteristic(F): AlgFr -> RngIntElt`

<a id="operation-operation-algfr-rngintelt"></a>
##### `# F: AlgFr -> RngIntElt`

#### Homomorphisms

In its most general form, a homomorphism taking a free algebra $K\langle x_1, \ldots, x_n\rangle$ as domain requires $n+1$ pieces of information, namely, a map (homomorphism) telling how to map the coefficient ring $K$ together with the images of the $n$ indeterminates. The map for the coefficient ring is optional.

<a id="constructor-constructor-hom-algfr-rng-map"></a>
##### `hom< F -> S | f, y₁, ..., yₙ >: AlgFr, Rng -> Map`

<a id="constructor-constructor-hom-algfr-rng-map-2"></a>
##### `hom< F -> S | y₁, ..., yₙ >: AlgFr, Rng -> Map`

Given a free algebra $F=K\langle x_1, \ldots, x_n\rangle$, a ring or associative algebra $S$ (including another FP-algebra or a matrix algebra), and a map $f : K\rightarrow S$ and $n$ elements $y_1, \ldots, y_n\in S$, create the homomorphism $g : F\rightarrow S$ by applying the rules that $g(rx_1^{a_1}\cdots x_n^{a_n})=f(r)y_1^{a_1}\cdots y_n^{a_n}$ for monomials and linearity, that is, $g(M+N)=g(M)+g(N)$. The coefficient ring map may be omitted, in which case the coefficients are mapped into $S$ by the coercion map. No attempt is made to check whether the map defines a genuine homomorphism.

<a id="example-ex-15e82d"></a>
##### `Example: Homomorphisms from a Free Algebra (ex-15e82d)`

In this example we map an algebra $F$ first into $F$ itself, and then into a matrix algebra.

```magma
> K := RationalField();
> F<x,y,z> := FreeAlgebra(K, 3);
> h := hom<F -> F | x*y, y*x, z*x>;
> h(x);
x*y
> h(y);
y*x
> h(x*y);
x*y^2*x
> h(x + y + z);
x*y + y*x + z*x
> A := MatrixAlgebra(K, 2);
> M := [A | [1,1,-1,1], [-1,3,4,1], [11,7,-7,8]];
> M;
[
    [ 1  1]
    [-1  1],

    [-1  3]
    [ 4  1],

    [11  7]
    [-7  8]
]
> h := hom<F -> A | M>;
> h(x);
[ 1  1]
[-1  1]
> h(y);
[-1  3]
[ 4  1]
> h(x*y - y*z);
[ 35 -13]
[-32 -38]
```

### Element Operations

#### Arithmetic Operators

The usual unary and binary ring operations are available for noncommutative polynomials, noting that multiplication is associative but noncommutative, of course.

<a id="operation-operation-algfrelt-algfrelt"></a>
##### `+ a: AlgFrElt -> AlgFrElt`

<a id="operation-operation-algfrelt-algfrelt-2"></a>
##### `- a: AlgFrElt -> AlgFrElt`

<a id="operation-op-plus-algfrelt-algfrelt"></a>
##### `a + b: AlgFrElt, AlgFrElt -> AlgFrElt`

<a id="operation-op-minus-algfrelt-algfrelt"></a>
##### `a - b: AlgFrElt, AlgFrElt -> AlgFrElt`

<a id="operation-op-times-algfrelt-algfrelt"></a>
##### `a * b: AlgFrElt, AlgFrElt -> AlgFrElt`

<a id="operation-op-pow-algfrelt-rngintelt"></a>
##### `a ^ k: AlgFrElt, RngIntElt -> AlgFrElt`

<a id="operation-op-div-algfrelt-algfrelt"></a>
##### `a / b: AlgFrElt, AlgFrElt -> FldFunMElt`

<a id="operation-operation-div-algfrelt-algfrelt-algfrelt"></a>
##### `a div b: AlgFrElt, AlgFrElt -> AlgFrElt`

<a id="operation-operation-algfrelt-algfrelt-algfrelt"></a>
##### `a +:= b: AlgFrElt, AlgFrElt -> AlgFrElt`

<a id="operation-operation-algfrelt-algfrelt-algfrelt-2"></a>
##### `a -:= b: AlgFrElt, AlgFrElt -> AlgFrElt`

<a id="operation-operation-algfrelt-algfrelt-algfrelt-3"></a>
##### `a *:= b: AlgFrElt, AlgFrElt -> AlgFrElt`

<a id="operation-operation-div-algfrelt-algfrelt-algfrelt-2"></a>
##### `a div:= b: AlgFrElt, AlgFrElt -> AlgFrElt`

#### Equality and Membership

<a id="operation-op-eq-algfrelt-algfrelt"></a>
##### `a eq b: AlgFrElt, AlgFrElt -> BoolElt`

<a id="operation-op-ne-algfrelt-algfrelt"></a>
##### `a ne b: AlgFrElt, AlgFrElt -> BoolElt`

<a id="operation-op-in-algfrelt-rng"></a>
##### `a in R: AlgFrElt, Rng -> BoolElt`

<a id="operation-op-notin-algfrelt-rng"></a>
##### `a notin R: AlgFrElt, Rng -> BoolElt`

#### Predicates on Algebra Elements

<a id="function-iszero-algfrelt"></a>
##### `IsZero(f): AlgFrElt -> BoolElt`

<a id="function-isone-algfrelt"></a>
##### `IsOne(f): AlgFrElt -> BoolElt`

<a id="function-isminusone-algfrelt"></a>
##### `IsMinusOne(f): AlgFrElt -> BoolElt`

<a id="function-isnilpotent-algfrelt"></a>
##### `IsNilpotent(f): AlgFrElt -> BoolElt`

<a id="function-isidempotent-algfrelt"></a>
##### `IsIdempotent(f): AlgFrElt -> BoolElt`

<a id="function-isunit-algfrelt"></a>
##### `IsUnit(f): AlgFrElt -> BoolElt`

<a id="function-iszerodivisor-algfrelt"></a>
##### `IsZeroDivisor(f): AlgFrElt -> BoolElt`

<a id="function-isregular-algfrelt"></a>
##### `IsRegular(f): AlgFrElt -> BoolElt`

<a id="function-isirreducible-algfrelt"></a>
##### `IsIrreducible(f): AlgFrElt -> BoolElt`

<a id="function-isprime-algfrelt"></a>
##### `IsPrime(f): AlgFrElt -> BoolElt`

#### Coefficients, Monomials, Terms, and Degree

The functions in this subsection allow one to access noncommutative polynomials.

<a id="function-coefficients-algfrelt"></a>
##### `Coefficients(f): AlgFrElt -> [ RngElt ]`

Given a noncommutative polynomial $f$ with coefficients in $R$, this function returns a sequence of ‘base’ coefficients, that is, a sequence of elements of $R$ occurring as coefficients of the monomials in $f$. Note that the monomials are ordered, and that the sequence of coefficients corresponds exactly to the sequence of monomials returned by `Monomials(f)`.

<a id="function-leadingcoefficient-algfrelt"></a>
##### `LeadingCoefficient(f): AlgFrElt -> RngElt`

Given a noncommutative polynomial $f$ with coefficients in $R$, this function returns the leading coefficient of $f$ as an element of $R$; this is the coefficient of the leading monomial of $f$, that is, the first among the monomials occurring in $f$ with respect to the ordering of monomials used in $F$.

<a id="function-trailingcoefficient-algfrelt"></a>
##### `TrailingCoefficient(f): AlgFrElt -> RngElt`

Given a noncommutative polynomial $f$ with coefficients in $R$, this function returns the trailing coefficient of $f$ as an element of $R$; this is the coefficient of the trailing monomial of $f$, that is, the last among the monomials occurring in $f$ with respect to the ordering of monomials used in $F$.

<a id="function-monomialcoefficient-algfrelt-algfrelt"></a>
##### `MonomialCoefficient(f, m): AlgFrElt, AlgFrElt -> RngElt`

Given a noncommutative polynomial $f$ and a monomial $m$, this function returns the coefficient with which $m$ occurs in $f$ as an element of $R$.

<a id="function-monomials-algfrelt"></a>
##### `Monomials(f): AlgFrElt -> [ AlgFrElt ]`

Given a noncommutative polynomial $f\in F$, this function returns a sequence of the monomials (monoid words) occurring in $f$. Note that the monomials in $F$ are ordered, and that the sequence of monomials corresponds exactly to the sequence of coefficients returned by `Coefficients(f)`.

<a id="function-leadingmonomial-algfrelt"></a>
##### `LeadingMonomial(f): AlgFrElt -> AlgFrElt`

Given a noncommutative polynomial $f\in F$ this function returns the leading monomial of $f$, that is, the first monomial element of $F$ that occurs in $f$, with respect to the ordering of monomials used in $F$.

<a id="function-terms-algfrelt"></a>
##### `Terms(f): AlgFrElt -> [ AlgFrElt ]`

Given a noncommutative polynomial $f\in F$, this function returns the sequence of (non-zero) terms of $f$ as elements of $F$. The terms are ordered according to the ordering on the monomials in $F$. Consequently the $i$-th element of this sequence of terms will be equal to the product of the $i$-th element of the sequence of coefficients and the $i$-th element of the sequence of monomials.

<a id="function-leadingterm-algfrelt"></a>
##### `LeadingTerm(f): AlgFrElt -> AlgFrElt`

Given a noncommutative polynomial $f\in F$, this function returns the leading term of $f$ as an element of $F$; this is the product of the leading monomial and the leading coefficient that is, the first among the monomial terms occurring in $f$ with respect to the ordering of monomials used in $F$.

<a id="function-trailingterm-algfrelt"></a>
##### `TrailingTerm(f): AlgFrElt -> RngElt`

Given a noncommutative polynomial $f\in F$, this function returns the trailing term of $f$ as an element of $F$; this is the last among the monomial terms occurring in $f$ with respect to the ordering of monomials used in $F$.

<a id="function-length-algfrelt"></a>
##### `Length(m): AlgFrElt -> RngIntElt`

Given a noncommutative monomial (word) $m$, return the length of $m$, i.e., the number of letters of $m$. Note that this differs from the commutative case, where the number of terms in a polynomial is returned.

<a id="literal-literal-m-i-algfrelt-rngintelt-algfrelt"></a>
##### `m[i]: AlgFrElt, RngIntElt -> AlgFrElt`

Given a noncommutative monomial (word) $m$ of length $l$, and an integer $i$ with $1\leq i\leq l$, return the $i$-th letter of $m$.

<a id="function-totaldegree-algfrelt"></a>
##### `TotalDegree(f): AlgFrElt -> RngIntElt`

Given a noncommutative polynomial $f$, this function returns the total degree of $f$, which is the maximum of the lengths of all monomials that occur in $f$. If $f$ is the zero polynomial, the return value is $-1$.

<a id="function-leadingtotaldegree-algfrelt"></a>
##### `LeadingTotalDegree(f): AlgFrElt -> RngIntElt`

Given a noncommutative polynomial, this function returns the leading total degree of $f$, which is the length of the leading monomial of $f$.

<a id="example-ex-4ecfe7"></a>
##### `Example: Monomials and Terms of an Element (ex-4ecfe7)`

In this example we illustrate the above access functions.

```magma
> K := RationalField();
> F<x,y,z> := FreeAlgebra(K, 3);
> f := (3*x*y - 2*y*z)*(4*x - 7*z*y) + 23*x*y*z;
> f;
-21*x*y*z*y + 14*y*z^2*y + 12*x*y*x + 23*x*y*z - 8*y*z*x
> TotalDegree(f);
4
> Coefficients(f);
[ -21, 14, 12, 23, -8 ]
> Monomials(f);
[
    x*y*z*y,
    y*z^2*y,
    x*y*x,
    x*y*z,
    y*z*x
]
> Terms(f);
[
    -21*x*y*z*y,
    14*y*z^2*y,
    12*x*y*x,
    23*x*y*z,
    -8*y*z*x
]
> MonomialCoefficient(f, x*y*z);
23
> LeadingTerm(f);
-21*x*y*z*y
> LeadingCoefficient(f);
-21
> m := Monomials(f)[1];
> m;
x*y*z*y
> Length(m);
4
> m[1];
x
> m[2];
y
```

#### Evaluation

<a id="function-evaluate-algfrelt-rngelt"></a>
##### `Evaluate(f, s): AlgFrElt, [ RngElt ] -> RngElt`

<a id="function-evaluate-algfrelt-rngelt-rngelt"></a>
##### `Evaluate(f, s): AlgFrElt, < RngElt, ..., RngElt > -> RngElt`

Given an element $f$ of a free algebra $F=R\langle x_1, \ldots, x_n\rangle$ and a sequence or tuple $s$ of ring or algebra elements of length $n$, return the value of $f$ at $s$, that is, the value obtained by substituting $x_i=s[i]$. This behaves in the same way as the `hom` constructor above. If the elements of $s$ lie in a ring and can be lifted into the coefficient ring $R$, then the result will be an element of $R$. If the elements of $s$ cannot be lifted to the coefficient ring, then an attempt is made to do a generic evaluation of $f$ at $s$. In this case, the result will be of the same type as the elements of $s$.

<a id="example-ex-88ec97"></a>
##### `Example: Evaluating an Element of a Free Algebra (ex-88ec97)`

In this example we illustrate the above access functions.

```magma
> K := RationalField();
> F<x,y,z> := FreeAlgebra(K, 3);
> g := x*y + y*z;
> g;
x*y + y*z
> Evaluate(g, [1,2,3]);
8
> Parent($1);
Rational Field
> Evaluate(g, [y,x,z]);
x*z + y*x
> Parent($1);
Finitely presented algebra of rank 3 over Rational Field
Non-commutative Graded Lexicographical Order
Variables: x, y, z
```

<a id="ideals-and-grobner-bases"></a>
### Ideals and Gröbner Bases

Magma supports left-sided, right-sided, and two-sided ideals of free algebras. In general, there are not many operations applicable to single-sided ideals: quotients are supported only in the case of two-sided ideals. Within the general context of fp-algebras, the term “basis” will refer to an *ordered* sequence of polynomials which generate an ideal. (Thus a basis may contain duplicates and zero elements so it is dissimilar to a basis of a vector space.)

#### Creation of Ideals

<a id="constructor-constructor-ideal-algfr-list-algfr"></a>
##### `ideal<A | L>: AlgFr, List -> AlgFr`

<a id="constructor-constructor-lideal-algfr-list-algfr"></a>
##### `lideal<A | L>: AlgFr, List -> AlgFr`

<a id="constructor-constructor-rideal-algfr-list-algfr"></a>
##### `rideal<A | L>: AlgFr, List -> AlgFr`

Given a free algebra $A$ over a field $K$, return the two-sided (`ideal`), left-sided (`lideal`), or right-sided (`rideal`) of $A$ generated by the elements of $A$ specified by the list $L$. Each term of the list $L$ must be an expression defining an object of one of the following types:

**(a)**
An element of $A$;

**(b)**
A set or sequence of elements of $A$;

**(c)**
An ideal of $A$;

**(d)**
A set or sequence of ideals of $A$.

<a id="function-basis-algfr"></a>
##### `Basis(I): AlgFr -> [ AlgFrElt ]`

Given an ideal $I$, return the current basis of $I$. If a Gröbner basis of $I$ has been computed, that is returned.

<a id="function-basiselement-algfr-rngintelt"></a>
##### `BasisElement(I, i): AlgFr, RngIntElt -> AlgFrElt`

Given an ideal $I$ together with an integer $i$, return the $i$-th element of the current basis of $I$. This the same as `Basis(I)[i]`.

<a id="grobner-bases"></a>
#### Gröbner Bases

Gröbner bases (GBs) may be computed for any kind of ideal (left-, right-, or two-sided), but for single-sided ideals, the GBs are generally weak (i.e., they rarely differ much from the original generators of the ideals). Unfortunately, the GB of a given ideal may not be finite. Thus the Buchberger or $F_4$ algorithms below will run forever in such cases. One can interrupt any GB computation by pressing `Ctrl-C`. Alternatively, the function [`GroebnerBasis`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/ideals.md#function-fpa-gb-deg)`(S,d)` below, which creates a truncated degree-$d$ Gröbner basis, can be used to set a limit on the degrees of the pairs considered, so the computation will always terminate. As in the commutative case, when Magma constructs a GB $G$ of an ideal $I$, then $G$ is always the unique sorted minimal reduced GB of $I$. Before this happens, an ideal will usually possess a basis which is not a Gröbner basis, but that will be changed into the unique Gröbner basis when the GB is computed. Thus the original basis will be discarded. See the procedure [`Groebner`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/ideals.md#procedure-fpa-groebner) below for details on the algorithms available. The unique Gröbner basis will be computed automatically when necessary; the [`Groebner`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/ideals.md#procedure-fpa-groebner) procedure below simply allows control of the algorithms used to compute the Gröbner basis.

<a id="procedure-fpa-groebner"></a>
##### `Groebner(I: parameters): AlgFr`

```magma
Faugere: BoolElt                    Default: true
```

(Procedure.) Explicitly force a Gröbner basis (GB) for $I$ to be constructed. This procedure is normally not necessary, as Magma will automatically compute the GB when needed, but it does allow one to control how the GB is constructed.

Magma has two algorithms for computing noncommutative GBs:

**(1)**
A noncommutative generalization (due to Allan Steel) of the Faugère $F_4$ algorithm [[Fau99](https://docs.magma-maths.org/references.md#cite-faugeref4)], which works by specialized sparse linear algebra and is applicable to two-sided ideals defined over a finite field or the rational field;

**(2)**
The noncommutative Buchberger algorithm [[CLO96](https://docs.magma-maths.org/references.md#cite-clo)] (Chap. 2, §7) for ideals defined over any field.

If the parameter `Faugere` is set to `true`, then the Faugère $F_4$ algorithm will be used (if the field is a finite field or the rational field); otherwise the Buchberger algorithm is used. The current implementation of the Faugère algorithm is usually very much faster than the Buchberger algorithm and usually does not take much more memory, so that it is why it is selected by default. However, there may be examples for which it may be more desirable to use the Buchberger algorithm (particularly to save some memory).

<a id="function-fpa-groebnerbasis"></a>
##### `GroebnerBasis(I: parameters): AlgFr -> AlgFrElt`

Given an ideal $I$, force the Gröbner basis of $I$ to be computed, and then return that. The parameters are the same as those for the procedure [`Groebner`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/ideals.md#procedure-fpa-groebner).

<a id="function-groebnerbasis-algfrelt"></a>
##### `GroebnerBasis(S: parameters): [ AlgFrElt ] -> [ AlgFrElt ]`

<a id="function-groebnerbasis-algfrelt-2"></a>
##### `GroebnerBasis(S: parameters): { AlgFrElt } -> [ AlgFrElt ]`

Given a set or sequence $S$ of polynomials, return the unique Gröbner basis of the two-sided ideal generated by $S$ as a sorted sequence. This function is useful for computing Gröbner bases without the need to construct ideals. The parameters are the same as those for the procedure [`Groebner`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/ideals.md#procedure-fpa-groebner). See also the function [`GroebnerBasis`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/ideals.md#function-fpa-gb-deg)`(S,d)` below, which creates a truncated degree-$d$ Gröbner basis.

<a id="function-fpa-gb-deg"></a>
##### `GroebnerBasis(S, d: parameters): [ AlgFr ], RngInt -> AlgFrElt`

Given a set or sequence $S$ of polynomials, return the degree-$d$ Gröbner basis of the ideal generated by $S$, which is the truncated Gröbner basis obtained by ignoring S-polynomial pairs whose total degree is greater than $d$.

If the ideal is homogeneous, then it is guaranteed that the result is equal to the set of all polynomials in the full Gröbner basis of the ideal whose total degree is less than or equal to $d$, and a polynomial whose total degree is less than or equal to $d$ is in the ideal if and only if its normal form with respect to this truncated basis is zero. But if the ideal is not homogeneous, these last properties may not hold, but it may still be useful to construct the truncated basis.

The parameters are the same as those for the procedure [`Groebner`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/ideals.md#procedure-fpa-groebner).

#### Verbosity

This subsection describes the verbose flags available for the Gröbner basis algorithms. There are separate verbose flags for each algorithm (`Buchberger`, etc.), but the all-encompassing verbose flag `Groebner` includes all these flags implicitly.

For each procedure provided for setting one of these flags, the value `false` is equivalent to level 0 (nothing), and `true` is equivalent to level 1 (minimal verbosity). For each `Set-` procedure, there is also a corresponding `Get-` function to return the value of the corresponding flag.

<a id="procedure-setverbose-monstgelt-rngintelt-groebner"></a>
##### `SetVerbose("Groebner", v): MonStgElt, RngIntElt`

(Procedure.) Change the verbose printing level for all Gröbner basis algorithms to be $v$. This includes all of the algorithms whose verbosity is controlled by flags subsequently listed, as well as some other minor related algorithms. Currently the legal levels are 0, 1, 2, 3, or 4. One would normally set this flag to 1 for minimal verbosity for Gröbner basis-type computations, and possibly also set one or more of the following flags to levels higher than 1 for more verbosity.

<a id="procedure-setverbose-monstgelt-rngintelt-buchberger"></a>
##### `SetVerbose("Buchberger", v): MonStgElt, RngIntElt`

(Procedure.) Change the verbose printing level for the Buchberger algorithm to be $v$. Currently the legal levels are 0, 1, 2, 3, or 4. If the value $w$ of the `Groebner` verbose flag is greater than $v$, then $w$ is taken to be the current value of this flag.

<a id="procedure-setverbose-monstgelt-rngintelt-faugere"></a>
##### `SetVerbose("Faugere", v): MonStgElt, RngIntElt`

(Procedure.) Change the verbose printing level for the Faugère algorithm to be $v$. Currently the legal levels are 0, 1, 2, or 3. If the value $w$ of the `Groebner` verbose flag is greater than $v$, then $w$ is taken to be the current value of this flag.

#### Related Functions

The following functions and procedures perform operations related to Gröbner bases.

<a id="procedure-markgroebner-algfr"></a>
##### `MarkGroebner(I): AlgFr`

(Procedure.) Given an ideal $I$, mark the current basis of $I$ to be *the* Gröbner basis of the ideal with respect to the monomial order of the ideal. Note that the current basis must exactly equal the unique (reverse) sorted minimal reduced Gröbner basis for the ideal, as returned by the function [`GroebnerBasis`](https://docs.magma-maths.org/Algebras/FinitelyPresentedAlgebras/ideals.md#function-fpa-groebnerbasis). This procedure is useful when one creates an ideal with a basis known to be the Gröbner basis of the ideal from a previous computation or for other reasons. If the basis is not the unique Gröbner basis, the results are unpredictable.

<a id="function-fpa-reduce"></a>
##### `Reduce(S): [ AlgFrElt ] -> [ AlgFrElt ]`

<a id="function-reduce-algfrelt"></a>
##### `Reduce(S): { AlgFrElt } -> [ AlgFrElt ]`

Given a set or sequence $S$ of polynomials, return the sequence consisting of the reduction of $S$. The reduction is obtained by reducing to normal form each element of S with respect to the other elements and sorting the resulting non-zero elements left. Note that all Gröbner bases returned by Magma are automatically reduced so that this function would usually only be used just to simplify a set or sequence of polynomials which is not a Gröbner basis.

<a id="example-ex-45e44f"></a>
##### `Example: One-Sided and Two-Sided Groebner Bases (ex-45e44f)`

For a certain sequence $B$ of noncommutative polynomials, we create the left-, right-, and two-sided ideals generated by $B$. We note that for the first two cases, the GB is no different from $B$, but for the two-sided case, the GB contains several more elements.

```magma
> K := RationalField();
> F<x,y,z> := FreeAlgebra(K, 3);
> B := [x^2 - y*z, x*y - y*z, y*x - z^2, y^3 - x*z];
> I := lideal<F | B>;
> I;
Left ideal of Finitely presented algebra of rank 3 over Rational Field
Non-commutative Graded Lexicographical Order
Variables: x, y, z
Basis:
[
    x^2 - y*z,
    x*y - y*z,
    y*x - z^2,
    y^3 - x*z
]
> GroebnerBasis(I);
[
    y^3 - x*z,
    x^2 - y*z,
    x*y - y*z,
    y*x - z^2
]
> I := rideal<F | B>;
> GroebnerBasis(I);
[
    y^3 - x*z,
    x^2 - y*z,
    x*y - y*z,
    y*x - z^2
]
> I := ideal<F | B>;
> Groebner(I);
> I;
Two-sided ideal of Finitely presented algebra of rank 3 over Rational Field
Non-commutative Graded Lexicographical Order
Variables: x, y, z
Groebner basis:
[
    y*z^2*y - y*z^2,
    y*z^3 - y*z^2,
    z*y*z^2 - y*z^2,
    z^2*y^2 - y*z^2,
    z^2*y*z - y*z^2,
    z^3*y - y*z^2,
    z^4 - y*z^2,
    x*z*x - y*z^2,
    x*z*y - z^3,
    x*z^2 - y*z^2,
    y^3 - x*z,
    y^2*z - z^2*y,
    y*z*x - y*z^2,
    y*z*y - y*z^2,
    z^2*x - z^2*y,
    x^2 - y*z,
    x*y - y*z,
    y*x - z^2
]
> NormalForm(x*y, I);
y*z
> NormalForm(y*x, I);
z^2
```

Finally, we compute some truncated bases of the two-sided ideal. For degree 2, the truncated GB has no new polynomials while for degree 3, some are added. Only at degree 5 do we obtain the full GB.

```magma
> GroebnerBasis(B, 2);
[
    y^3 - x*z,
    x^2 - y*z,
    x*y - y*z,
    y*x - z^2
]
> GroebnerBasis(B, 3);
[
    x*z^2 - y*z^2,
    y^3 - x*z,
    y^2*z - z^2*y,
    y*z*x - y*z^2,
    y*z*y - y*z^2,
    z^2*x - z^2*y,
    x^2 - y*z,
    x*y - y*z,
    y*x - z^2
]
> #GroebnerBasis(I);
18
> #GroebnerBasis(B, 4);
16
> #GroebnerBasis(B, 5);
18
> GroebnerBasis(B, 5) eq GroebnerBasis(I);
true
```

### Basic Operations on Ideals

In the following, note that the free algebra $F$ itself is a valid ideal (the ideal containing 1).

#### Construction of New Ideals

<a id="operation-op-plus-algfr-algfr"></a>
##### `I + J: AlgFr, AlgFr -> AlgFr`

Given ideals $I$ and $J$ belonging to the same algebra $F$, return the sum of $I$ and $J$, which is the ideal generated by the union of the generators of $I$ and $J$.

<a id="operation-op-times-algfr-algfr"></a>
##### `I * J: AlgFr, AlgFr -> AlgFr`

Given ideals $I$ and $J$ belonging to the same algebra $A$, return the product of $I$ and $J$, which is the ideal generated by the products of the generators of $I$ with those of $J$.

<a id="operation-op-div-algfr-algfr"></a>
##### `F / J: AlgFr, AlgFr -> AlgFrRes`

Given an algebra $F$ over a field and an ideal $J$ of $F$, return the fp-algebra $F/J$ (see below).

<a id="function-generic-algfr"></a>
##### `Generic(I): AlgFr -> AlgFr`

Given an ideal $I$ of a generic algebra $A$, return $A$.

#### Ideal Predicates

<a id="operation-op-eq-algfr-algfr"></a>
##### `I eq J: AlgFr, AlgFr -> BoolElt`

Given two ideals $I$ and $J$ belonging to the same algebra $F$, return whether $I$ and $J$ are equal.

<a id="operation-op-ne-algfr-algfr"></a>
##### `I ne J: AlgFr, AlgFr -> BoolElt`

Given two ideals $I$ and $J$ belonging to the same algebra $F$, return whether $I$ and $J$ are not equal.

<a id="operation-operation-notsubset-algfr-algfr-boolelt"></a>
##### `I notsubset J: AlgFr, AlgFr -> BoolElt`

Given two ideals $I$ and $J$ belonging to the same algebra $F$ return whether $I$ is not contained in $J$.

<a id="operation-op-subset-algfr-algfr"></a>
##### `I subset J: AlgFr, AlgFr -> BoolElt`

Given two ideals $I$ and $J$ belonging to the same algebra $F$ return whether $I$ is contained in $J$.

<a id="function-iszero-algfr"></a>
##### `IsZero(I): AlgFr -> BoolElt`

Given an ideal $I$ of the algebra $F$, return whether $I$ is the zero ideal (contains zero alone).

#### Operations on Elements of Ideals

<a id="operation-op-in-algfrelt-algfr"></a>
##### `f in I: AlgFrElt, AlgFr -> BoolElt`

Given a polynomial $f$ from an algebra $F$, together with an ideal $I$ of $F$, return whether $f$ is in $I$.

<a id="function-normalform-algfrelt-algfr"></a>
##### `NormalForm(f, I): AlgFrElt, AlgFr -> AlgFrElt`

Given a polynomial $f$ from an algebra $F$, together with an ideal $I$ of $F$, return the unique normal form of $f$ with respect to (the Gröbner basis of) $I$. The normal form of $f$ is zero if and only if $f$ is in $I$.

<a id="function-normalform-algfrelt-algfrelt"></a>
##### `NormalForm(f, S): AlgFrElt, [ AlgFrElt ] -> AlgFrElt`

Given a polynomial $f$ from an algebra $F$, together with a set or sequence $S$ of polynomials from $F$, return a normal form of $f$ with respect to $S$. This is not unique in general. If the normal form of $f$ is zero then $f$ is in the ideal generated by $S$, but the converse is false in general. In fact, the normal form is unique if and only if $S$ forms a Groëbner basis.

<a id="operation-op-notin-algfrelt-algfr"></a>
##### `f notin I: AlgFrElt, AlgFr -> BoolElt`

Given a polynomial $f$ from an algebra $F$, together with an ideal $I$ of $F$, return whether $f$ is not in $I$.

<a id="example-ex-3dd8c1"></a>
##### `Example: Normal Forms Modulo an Ideal (ex-3dd8c1)`

We demonstrate the element operations with respect to an ideal of ${\mathbb{Q}}[x, y, z]$.

```magma
> F<x,y,z> := FreeAlgebra(RationalField(), 3);
> I := ideal<F | (x + y)^3, (y - z)^2, y^2*z + z>;
> NormalForm(y^2*z + z, I);
0
> NormalForm(x^3, I);
-x^2*y - x*y*x - x*y*z - x*z*y + x*z^2 - y*x^2 - y*x*y - y*z*x -
    y*z*y - z*y*x - z*y*z + z^2*x + z^3
> NormalForm(z^4 + y^2, I);
z^4 + y*z + z*y - z^2
> x + y in I;
false
```

### Changing Coefficient Ring

The `ChangeRing` function enables the changing of the coefficient ring of an algebra or ideal.

<a id="function-fpa-changering"></a>
#### `ChangeRing(I, S): AlgFr, Rng -> AlgFr`

Given an ideal $I$ of an algebra $F=R[x_1, \ldots, x_n]$ of rank $n$ with coefficient ring $R$, together with a ring $S$, construct the ideal $J$ of the algebra $Q=S[x_1, \ldots, x_n]$ obtained by coercing the coefficients of the elements of the basis of $I$ into $S$. It is necessary that all elements of the old coefficient ring $R$ can be automatically coerced into the new coefficient ring $S$. If $R$ and $S$ are fields and $R$ is known to be a subfield of $S$ and the current basis of $I$ is a Gröbner basis, then the basis of $J$ is marked automatically to be a Gröbner basis of $J$.

### Finitely Presented Algebras

A finitely presented algebra (fp-algebra) in Magma is simply the quotient ring of a free algebra $F = R\langle x_1,\ldots,x_n\rangle$ by an ideal $J$ of $F$. It is an object of type `AlgFP` with elements of type `AlgFPElt`.

The elements of fp-algebras are simply noncommutative polynomials which are always kept reduced to normal form modulo the ideal $J$ of “relations”. Practically all operations which are applicable to noncommutative polynomials are also applicable in Magma to elements of fp-algebras (when meaningful).

If an fp-algebra $A$ has finite dimension, considered as a vector space over its coefficient field, then extra special operations are available for $A$ and its elements.

### Creation of FP-Algebras

One can create an fp-algebra simply by forming the quotient of a free algebra by an ideal (`quo` constructor or `/` function). A special constructor `FPAlgebra` is also provided to remove the need to create the free algebra. **NOTE:** When one creates an fp-algebra, the ideal of relations is left unchanged, but as soon as one does just about any operation with elements of the algebra (such as printing or multiplying), then the Gröbner basis of the underlying ideal will have to be computed to enable Magma to compute a unique form of each element of the algebra.

<a id="constructor-constructor-quo-algfr-algfr-algfp"></a>
#### `quo< F | J >: AlgFr, AlgFr -> AlgFP`

<a id="constructor-constructor-quo-algfr-algfrelt-algfrelt-algfrres-map"></a>
#### `quo< F | a₁, ..., aᵣ >: AlgFr, AlgFrElt, ..., AlgFrElt -> AlgFrRes, Map`

Given a free algebra $F$ and a two-sided ideal $J$ of $F$, return the fp-algebra (quotient algebra) $F/J$. The ideal $J$ may either be specified as an ideal or by a list $a_1$, $a_2$, $\ldots$, $a_r$, of generators which all lie in $F$. The angle bracket notation can be used to assign names to the indeterminates: `A<q, r> := quo< I | I.1 + I.2, I.2^2 - 2, I.3^2 + I.4 >;`.

<a id="operation-op-div-algfr-algfr-2"></a>
#### `F / J: AlgFr, AlgFr -> AlgFP`

Given a free algebra $F$ and an ideal $J$ of $F$, return the fp-algebra $F/J$.

<a id="constructor-constructor-fpalgebra-fld-list-list-algfp"></a>
#### `FPAlgebra< K, X | L >: Fld, List, List -> AlgFP`

Given a field $K$, a list $X$ of $n$ identifiers, and a list $L$ of noncommutative polynomials (relations) in the $n$ variables $X$, create the fp-algebra of rank $n$ with base ring $K$ with given quotient relations; i.e., return $K[X]/\langle L\rangle$. The angle bracket notation can be used to assign names to the indeterminates.

<a id="example-ex-8d1242"></a>
#### `Example: Creating FP-Algebras (ex-8d1242)`

We illustrate equivalent ways of creating FP-algebras.

```magma
> K := RationalField();
> A<x,y> := FPAlgebra<K, x, y | x^2*y - y*x, x*y^3 - y*x>;
> A;
Finitely Presented Algebra of rank 2 over Rational Field
Non-commutative Graded Lexicographical Order
Variables: x, y
Quotient relations:
[
    x^2*y - y*x,
    x*y^3 - y*x
]
> x;
x
> x*y;
x*y
> x^2*y;
y*x
> A;
Finitely Presented Algebra of rank 2 over Rational Field
Non-commutative Graded Lexicographical Order
Variables: x, y
Quotient relations:
[
    x*y*x^2 - y*x^2,
    x*y*x*y - y^2*x,
    x*y^2*x - y^2*x,
    x*y^3 - y*x,
    y*x^3 - y*x^2,
    y*x*y*x - y^2*x,
    y*x*y^2 - x*y*x,
    y^2*x^2 - y^2*x,
    y^2*x*y - y*x^2,
    y^3*x - y*x^2,
    x^2*y - y*x
]
```

The following is equivalent.

```magma
> K := RationalField();
> F<x,y> := FreeAlgebra(K, 2);
> A<x,y> := quo<F | x^2*y - y*x, x*y^3 - y*x>;
```

### Operations on FP-Algebras

This section describes operations on fp-algebras. Most of the operations are very similar to those for noncommutative free algebras; such operations are done by mapping the computation to the preimage ideal and then by mapping the result back into the fp-algebra. See the corresponding functions for the noncommutative free algebras for details.

<a id="operation-operation-algfp-rngintelt-algfpelt"></a>
#### `A . i: AlgFP, RngIntElt -> AlgFPElt`

Given an fp-algebra $A$, return the $i$-th indeterminate of $A$ as an element of $A$.

<a id="function-coefficientring-algfp"></a>
#### `CoefficientRing(A): AlgFP -> Rng`

Return the coefficient ring of the fp-algebra $A$.

<a id="function-rank-algfp"></a>
#### `Rank(A): AlgFP -> RngIntElt`

Return the rank of the fp-algebra $A$ (the number of indeterminates of $A$).

<a id="function-divisorideal-algfp"></a>
#### `DivisorIdeal(I): AlgFP -> AlgFr`

Given an ideal $I$ of an fp-algebra $A$ which is the quotient ring $F/J$, where $F$ is a free algebra and $J$ an ideal of $F$, return the ideal $J$.

<a id="function-preimageideal-algfp"></a>
#### `PreimageIdeal(I): AlgFP -> AlgFr`

Given an ideal $I$ of an fp-algebra $A$ which is the quotient ring $F/J$, where $F$ is a free algebra and $J$ an ideal of $F$, return the ideal $I'$ of $F$ such that the image of $I'$ under the natural epimorphism $F\rightarrow A$ is $I$.

<a id="function-preimagering-algfp"></a>
#### `PreimageRing(A): AlgFP -> AlgFr`

Given an fp-algebra $A$ which is the quotient ring $F/J$, where $F$ is a free algebra and $J$ an ideal of $F$, return the free algebra $F$.

<a id="function-originalring-algfp"></a>
#### `OriginalRing(A): AlgFP -> Rng`

Return the generic free algebra $F$ such that $A$ is $F/J$ for some ideal $J$ of $F$.

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

Return whether the algebra $A$ is commutative.

<a id="operation-op-eq-algfp-algfp"></a>
#### `I eq J: AlgFP, AlgFP -> BoolElt`

Given two ideals $I$ and $J$ of the same fp-algebra $A$, return `true` if and only if $I$ and $J$ are equal.

<a id="operation-op-subset-algfp-algfp"></a>
#### `I subset J: AlgFP, AlgFP -> BoolElt`

Given two ideals $I$ and $J$ of the same fp-algebra $A$, return `true` if and only if $I$ is contained in $J$.

<a id="operation-op-plus-algfp-algfp"></a>
#### `I + J: AlgFP, AlgFP -> AlgFP`

Given two ideals $I$ and $J$ of the same fp-algebra $A$, return the sum $I+J$.

<a id="operation-op-times-algfp-algfp"></a>
#### `I * J: AlgFP, AlgFP -> AlgFP`

Given two ideals $I$ and $J$ of the same fp-algebra $A$, return the product $I*J$.

<a id="function-isproper-algfp"></a>
#### `IsProper(I): AlgFP -> BoolElt`

Given an ideal $I$ of the fp-algebra $A$, return whether $I$ is proper; that is, whether $I$ is strictly contained in $A$.

<a id="function-iszero-algfp"></a>
#### `IsZero(I): AlgFP -> BoolElt`

Given an ideal $I$ of the fp-algebra $A$, return whether $I$ is the zero ideal. Note that this is equivalent to whether the preimage ideal of $I$ is the divisor ideal of $A$.

### Finite Dimensional FP-Algebras

If an fp-algebra $A$ has finite dimension, considered as a vector space over its coefficient field, then extra special operations are available for $A$ and the elements of $A$.

<a id="function-dimension-algfp"></a>
#### `Dimension(A): AlgFP -> RngIntElt`

Given a finite dimensional fp-algebra $A$, return the dimension of $A$.

<a id="function-vectorspace-algfp"></a>
#### `VectorSpace(A): AlgFP -> ModTupFld, Map`

Given a finite dimensional fp-algebra $A$, construct the vector space $V$ isomorphic to $A$, and return $V$ together with the isomorphism $f$ from $A$ onto $V$.

<a id="function-matrixalgebra-algfp"></a>
#### `MatrixAlgebra(A): AlgFP -> AlgMat, Map`

Given a finite dimensional fp-algebra $A$, construct the matrix algebra $M$ isomorphic to $A$, and return $M$ together with the isomorphism $f$ from $A$ onto $M$.

<a id="function-algebra-algfp"></a>
#### `Algebra(A): AlgFP -> AlgAss, Map`

Given a finite dimensional fp-algebra $A$, construct the associative structure-constant algebra $S$ isomorphic to $A$, and return $S$ together with the isomorphism $f$ from $A$ onto $S$.

<a id="function-representationmatrix-algfpelt"></a>
#### `RepresentationMatrix(f): AlgFPElt -> AlgMatElt`

Given an element $f$ of a finite dimensional fp-algebra $A$, return the representation matrix of $f$, which is a $d$ by $d$ matrix over the coefficient field of $A$ which represents $f$ (where $d$ is the dimension of $A$).

<a id="function-isunit-algfpelt"></a>
#### `IsUnit(f): AlgFPElt -> BoolElt`

Given an element $f$ of a finite dimensional fp-algebra $A$ defined over a field, return whether $f$ is a unit.

<a id="function-isnilpotent-algfpelt"></a>
#### `IsNilpotent(f): AlgFPElt -> BoolElt, RngIntElt`

Given an element $f$ of a finite dimensional fp-algebra $A$ defined over a field, return whether $f$ is nilpotent, and if so, return also the smallest $q$ such that $f^q = 0$.

<a id="function-minimalpolynomial-algfpelt"></a>
#### `MinimalPolynomial(f): AlgFPElt -> RngUPol`

Given an element $f$ of a finite dimensional fp-algebra $A$ defined over a field, return the minimal polynomial of $f$ as a univariate polynomial over the coefficient field of $A$.

<a id="example-ex-b673ef"></a>
#### `Example: Functions for a Finite-Dimensional FP-Algebra (ex-b673ef)`

We demonstrate the functions available for finite-dimensional fp-algebras.

```magma
> K := RationalField();
> A<x,y,z> := FPAlgebra<K, x,y,z |
>           x^2 - y*z*y + z, y^2 - y*x*y + 1, z^2 - y*x*y - x*z*x>;
> A;
Finitely Presented Algebra of rank 3 over Rational Field
Non-commutative Graded Lexicographical Order
Variables: x, y, z
Quotient relations:
[
    y^4 - 7/2*z^2*x + z^3 - 1/2*x^2 + 2*y^2 + z*x + z^2 + x + 1,
    z*y*x^2 + y^3 - z^2*y + y,
    z^2*y*x - 1/2*z*y*z - z^2*y - 1/2*y*x,
    z^2*y*z - 3/2*y*x^2 - 3/4*z*y*z - 3/2*z^2*y - 3/4*y*x - y*z - z*y,
    z^3*x - 3/2*z^3 - 1/2*z*x,
    z^3*y - 3/2*y*x^2 - 3/4*z*y*z - 3/2*z^2*y - 3/4*y*x - y*z - z*y,
    z^4 - 2*z^2*x - 9/4*z^3 + 3/2*y^2 - 3/4*z*x - 1/2*z^2 + x + 3/2,
    x^3 + 3/2*z^2*x - z^3 + 1/2*x^2 + z*x,
    y^2*x - y^2 - 1,
    y^2*z + 3/2*z^2*x - z^3 + 1/2*x^2 + z,
    y*z*x - z*y*x,
    y*z*y - x^2 - z,
    y*z^2 - z^2*y,
    z*x^2 + y^2 - z^2 + 1,
    z*y^2 + 3/2*z^2*x - z^3 + 1/2*x^2 + z,
    x*y - y*x,
    x*z - z*x
]
> IsCommutative(A);
false
> y*z;
y*z
> z*y;
z*y
> U<u> := PolynomialRing(K);
> MinimalPolynomial(x);
u^8 - 7/2*u^7 + 4*u^6 - 3/2*u^5 - 1/2*u^4 + 2*u^3 - 2*u^2
> MinimalPolynomial(y);
u^16 - u^12 + 3*u^10 + u^8 - 10*u^6 - 15*u^4 - 9*u^2 - 2
> Dimension(A);
18
> V, Vf := VectorSpace(A);
> V;
Full Vector space of degree 18 over Rational Field
> Vf(x);
(0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0)
> [V.i@@Vf: i in [1 .. Dimension(V)]];
[
    1,
    z,
    y,
    x,
    z^2,
    z*y,
    z*x,
    y*z,
    y^2,
    y*x,
    x^2,
    z^3,
    z^2*y,
    z^2*x,
    z*y*z,
    z*y*x,
    y^3,
    y*x^2
]
> M, Mf := MatrixAlgebra(A);
> M;
Matrix Algebra of degree 18 with 4 generators over Rational Field
> M.1;
[0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0]
[-1 0 0 0 1 0 0 0 -1 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0]
[1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1]
[0 0 0 0 0 0 -1 0 0 0 -1/2 1 0 -3/2 0 0 0 0]
[0 0 0 0 0 0 1/2 0 0 0 0 3/2 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 1/2 0 0 1 0 1/2 0 0 0]
[0 0 0 0 0 0 0 0 0 0 1/2 0 0 3/2 0 0 0 0]
[0 0 0 0 0 0 0 0 0 1/2 0 0 1 0 1/2 0 0 0]
[0 0 -1 0 0 0 0 0 0 0 0 0 1 0 0 0 -1 0]
[0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0]
[0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 -1 0 1]
> M.1 eq RepresentationMatrix(x);
true
> MinimalPolynomial(M.1);
u^8 - 7/2*u^7 + 4*u^6 - 3/2*u^5 - 1/2*u^4 + 2*u^3 - 2*u^2

> FactoredMinimalPolynomial(M.1);
[
    <u, 2>,
    <u^6 - 7/2*u^5 + 4*u^4 - 3/2*u^3 - 1/2*u^2 + 2*u - 2, 1>
]
> N := Kernel(M.1);
> N;
Vector space of degree 18, dimension 4 over Rational Field
Echelonized basis:
(0 1 0 0 0 0 0 0 0 0 3/4 -1/2 0 3/4 0 0 0 0)
(0 0 0 1 3 0 0 0 0 0 0 0 0 -2 0 0 0 0)
(0 0 0 0 0 1 0 -1 0 0 0 0 0 0 0 0 0 0)
(0 0 0 0 0 0 0 0 0 0 0 0 1 0 -1 0 0 0)
> a := N.1 @@ Vf;
> a;
3/4*z^2*x - 1/2*z^3 + 3/4*x^2 + z
> IsNilpotent(a);
true 3
> a^3;
0
> S, Sf := Algebra(A);
> S;
Associative Algebra of dimension 18 with base ring Rational Field
> Centre(S);
Associative Algebra of dimension 15 with base ring Rational Field
> J := JacobsonRadical(S);
> J;
Associative Algebra of dimension 4 with base ring Rational Field
> L := [J.i@@Sf: i in [1 .. 4]];
> L;
[
    3/4*z^2*x - 1/2*z^3 + 3/4*x^2 + z,
    -2*z^2*x + 3*z^2 + x,
    -y*z + z*y,
    -z*y*z + z^2*y
]
> [MinimalPolynomial(x): x in L];
[
    u^3,
    u^2,
    u^3,
    u^2
]
```

### Vector Enumeration

Vector enumeration (originally misnamed module enumeration) is an algorithm for converting a finitely-presented module for a finitely-presented algebra into a concrete vector space on which the algebra has explicit matrix action. The algebra may be the group algebra of an fp-group, in which case the resulting module will be a matrix representation of the group, or it might be a more general fp-algebra, such as a Hecke algebra or a quotient of a polynomial ring.

#### Finitely Presented Modules

For a ring $R$, let $M$ be an $R$-module $M$, generated as an $R$-module by $s$ elements $\{m_1,\ldots,m_s\}$. There is an $R$-module epimorphism $\psi: R^s \mapsto M$, given by $(r_1,\ldots,r_s) \mapsto m_1r_1+\cdots+m_sr_s.$ This shows that $M$ is isomorphic to $A^s/\ker\psi$. If $\ker\psi$ is generated as an $R$-module by a finite set $L$ then we will say that $M$ is presented by $s$ generators and the relators $L$.

#### $S$-algebras

Suppose there is another ring $S$, equipped with a ring homomorphism $\phi: S\mapsto R$, such that $\phi(S)$ is central in $R$. In this situation any $R$-module can be described as an $S$-module, on which $R$ acts as a ring of $S$-module endomorphisms. We say that $R$ is an $S$-algebra. In particular, when $S$ is a field $k$, any $R$-module is a $k$-vector space. If such a module $V$ has finite $k$-dimension $n$, then $V$ is characterised by this dimension and $R$ will act on it as a subring of $M_n(k)$.

#### Finitely Presented Algebras

Given a finite set $X$, and a ring $S$, we can define the free $S$-algebra $A$ generated by $X$. This can be seen either as the monoid algebra of the free monoid of words in $X$, or as all expressions in $X$ and $k$, combined by addition and multiplication. Given a finite set $R\subset A$ we can define

$$
P = {A\over\left\langle ARA\right\rangle}.
$$

We say that $P$ is a *finitely-presented* $S$-algebra, with generators $X$ and relators $R$, and write it

$$
P = \left\langle X\mid R\right\rangle.
$$

The monoid algebra of any finitely-presented monoid (or group, of course) is finitely-presented, since

$$
k\left\langle X \mid l_1 = r_1,\ldots,l_k=r_k\right\rangle_{{\rm
monoid}} = \left\langle X \mid
l_1-r_1,\ldots,l_k-r_k\right\rangle_{k\rm -algebra}.
$$

Furthermore, any quotient of a finitely-presented algebra by a finitely-generated two-sided ideal is finitely-presented. This gives us the general form of a finitely-presented algebra in Magma, as the quotient of the monoid algebra of an fp-monoid, by the two-sided ideal generated by some additional relators.

<a id="id1"></a>
#### Vector Enumeration

The vector enumeration algorithm explicitly reconciles these two descriptions of an $R$-module, in the case where $R$ is a finitely presented $k$-algebra for a field $k$, and $M$ is a finitely presented $R$-module, which also has finite $k$-dimension. Given the presentation of $R$ as $k$-algebra, and that of $M$ as $R$-module, it computes the $k$-dimension of $M$ and the matrices giving the action of the generators of $R$ on $M$. If $M$ has infinite $k$-dimension the algorithm will fail to terminate.

<a id="example-ex-d47ce9"></a>
##### `Example: Vector Enumeration in the Abstract (ex-d47ce9)`

We consider some examples in the abstract. Below we will see how these and other calculations may be performed in Magma.

**(1) A permutation module**

In practice, it is always better to use the classical Todd-Coxeter algorithm to construct permutation representations of groups. We know that the group with presentation

$$
\left\langle a,b\mid a^4 = b^2 =
   (ab)^2 = 1\right\rangle
$$

is the dihedral group of order 8. Its group algebra over any field $k$ is thus the fp-$k$-algebra

$$
\left\langle
   a,b,a',b'\mid
   aa'-1,a'a-1,bb'-1,b'b-1,a^4-1,b^2-1,(ab)^2-1\right\rangle.
$$

The permutation module of degree 4 of this algebra is presented by one generator (as it is transitive) and the submodule generator $b-1$. Applying the algorithm to this case we obtain the matrices

$$
a = \begin{pmatrix}0&0&1&0\\1&0&0&0\\0&0&0&1\\0&1&0&0\end{pmatrix}\qquad
     b = \begin{pmatrix}1&0&0&0\\0&0&1&0\\0&1&0&0\\0&0&0&1\end{pmatrix}
$$

and their inverses for $a'$ and $b'$.

**(2) A quotient of a permutation module**

Like all permutation modules, this one fixes the all-ones vector $(1,1,1,1)$, which we can see to be an image of $1+a'(1+b+a')$. We can construct the quotient of the permutation module by this 1-dimensional submodule by adding that word to the submodule generators. This gives

$$
a = \begin{pmatrix}0&0&1\\ 1&0&0\\ -1&-1&-1\end{pmatrix}\qquad
     b = \begin{pmatrix}1&0&0\\ 0&0&1\\ 0&1&0\end{pmatrix}.
$$

**(3) A non-cyclic module**

A permutation module of a group-ring is cyclic (that is, generated as a module by one element) just when the permutation representation is transitive. An intransitive permutation representation can be easily constructed from its transitive components, but in general it is not so easy to construct an arbitrary module from cyclic submodules. Accordingly it can be worthwhile to construct non-cyclic modules directly. As an example we take two copies of the representation constructed in example one, and fuse their one-dimensional submodules. The generators and relators are as before, and now $s=2$ and the submodule generators are $a^2 = \{(b-1,0),(0,b-1),(1+a'(1+a'+b),-1-a'(1+a'+b))\}$. We obtain a representation of degree seven, given by

$$
a = \begin{pmatrix}0&0&0&1&0&0&0\\ 0&0&0&0&0&0&1\\ 1&0&0&0&0&0&0\\
   0&0&0&0&1&0&0\\ 0&0&1&0&0&0&0\\ 0&1&0&0&0&0&0\\
   1&-1&1&1&1&-1&-1\end{pmatrix}\qquad
   b = \begin{pmatrix}1&0&0&0&0&0&0\\ 0&1&0&0&0&0&0\\ 0&0&0&1&0&0&0\\
   0&0&1&0&0&0&0\\ 0&0&0&0&1&0&0\\ 0&0&0&0&0&0&1\\
   0&0&0&0&0&1&0\end{pmatrix}.
$$

#### The Isomorphism

In determining the $k$-dimension of $M$, and giving matrices representing the action of $R$ on $M$, the algorithm is, in effect, constructing a $k$-vector space, on which $R$ has matrix action, and which is $R$-module isomorphic to $M$, which is formally a quotient module of $R^s$. The algorithm also computes this isomorphism, giving images in the vector space for the $s$ standard generators of $R^s$ and pre-images in $R^s$ of the basis of the vector space. In example (1) above, we find that the module generator has image $(1,0,0,0)$, while the basis vectors have pre-images $1$, $a'$, $a'^2$, and $b$. In example (3) the images of the two module generators are $(1,0,0,0,0,0,0)$ and $(0,1,0,0,0,0,0)$ while the basis vectors are images of $(1,0)$, $(0,1)$, $(a',0)$ ,$(a,0)$, $(a^2,0)$, $(0,a')$, and $(0,a)$.

#### Sketch of the Algorithm

The algorithm is based on the Haselgrove-Leech-Trotter (HLT) version of the Todd-Coxeter algorithm, which we consider as a means of constructing the permutation representation of a finitely-presented group on the cosets of a finitely generated subgroup. The algorithm proceeds by manipulating a partial action of the free algebra on a vector space. This is represented as a table, with columns indexed by the generators of the algebra, and rows indexed by the basis of the space. Each entry is either a vector or $\bot$, signifying that no action is given. We can extend this to a “complete action with side-effects”, by adding a new row to the table whenever needed. We call this *the action with defining*. The action of the fp-algebra $P$ on $M$ gives an action for the free algebra $A$, and our objective is to modify out partial action until it becomes this action. We know certain things about this action, which drive our modification process:

1. It is a complete action.
2. The relators of $P$ annihilate every vector.
3. The images in the space of the relators of $M$ are zero.
4. The space contains images of the $R$-module generators of $M$.

The algorithm begins by applying the fourth fact and creating $s$ linearly independent vectors. It then applies the third, computing the action with defining of the relators of $M$ (the set called $L$ above). The fact that these images should be zero gives a linear dependence among our basis vectors (called a coincidence), which we use to reduce their number. As we do this, we have to take care not to lose the information already in the table, which may give rise to further coincidences. We now start to exploit the second fact about $M$, constructing the action (with defining) of the relators of $P$, on the basis vectors, and applying the resulting coincidences. This process may not terminate, as we are defining new basis vectors on the one hand, and removing them through coincidences on the other. It is possible to prove, however, that if $M$ is in fact finite-dimensional then the process will terminate. The first fact is applied by adding the relators $x-x$ for each $x\in X$ to the relators of $P$, so that the image of every basis vector under each $x$ is sure to be defined.

#### Weights

The above sketch leaves open the question of the order in which the relators are applied to the basis vectors. The proof that the algorithm completes when $M$ is finite-dimensional imposes some rather loose constraints, but within these constraints there is considerable choice. The implementation in Magma uses a system of weights. Each relator $r$ is assigned a weight $w_r$ by the user, and each basis vector $e$ has a weight $w_e$. There is a current weight $w$, which increases as the computation progresses, and at weight $w$ all basis vector, relator pairs $(b,r)$ such that $w_b+w_r \le w$, which have not been processed already, are processed. New basis vectors defined during this process are assigned weight $w$. The initial basis vectors and those defined during processing of the submodule generators are assigned weight 1. See below for details of how to set the weights, and their default values.

#### Setup Functions

For V2.11, the following functions create the old representation for fp-algebras which are necessary for the Vector Enumeration algorithm. These are compatible with older versions of Magma. See the examples below for examples of how to use these functions.

<a id="function-freealgebra-rng-monfp"></a>
##### `FreeAlgebra(R, M): Rng, MonFP -> AlgFPOld`

<a id="function-freealgebra-rng-grpfp"></a>
##### `FreeAlgebra(R, G): Rng, GrpFP -> AlgFPOld`

Construct the special fp-algebra over the ring $R$ and the monoid $M$ or the group $G$, for use in the Vector Enumeration algorithm.

#### The Quotient Module Function

<a id="function-quotientmodule-algfpold-algfpold"></a>
##### `QuotientModule(A, S): AlgFPOld, AlgFPOld -> [AlgMatElt], [ModTupFldElt], [AlgFPEltOld]`

Given an fp-$k$-algebra $A$, for a field $k$, with $r$ generators, and a submodule $N$ of the free $A$-module of rank $s$ specified by $S$, construct an $A$-module isomorphic to the quotient module $A^s/N$ together with the isomorphism. The three values returned are:

**$M$**
a sequence of $r$ $n\times n$ matrices with entries in $k$;

**$I$**
a sequence of $s$ vectors of length $n$ with entries in $k$;

**$P$**
a sequence of $n$ elements of the free $A$-module $A^s$.

The matrices $M$ specify a homomorphism from $A$ to ${\operatorname{End}}_k(k^n)$, under which $k^n$ becomes an $A$-module isomorphic to $A^s/N$. That isomorphism is given in one direction by the vectors $I$, which are the images in $k^n$ of the $s$ generators $(1,0,\ldots,0)$, $(0,1,0,\ldots,0)$, …, $(0,\ldots,0,1)$ of $A^s$. In the other direction, the elements $P$ give representatives for the images in $A^s/N$ of the images of the $n$ standard basis elements of $k^n$. The submodule $N$ may be specified by the parameter $S$ in three ways:

**(1)**
$S$ may simply be $N$, a finitely generated submodule of a free $A$-module (except that such an object cannot currently be created).

**(2)**
$S$ may be a finitely generated right ideal of $A$, in which case $s = 1$ and $N$ is $S$ considered as a submodule of $A$ considered as a right module for itself.

**(3)**
$S$ may be a sequence of elements of a free $A$-module $A^s$, in which case $N$ is the submodule that they generate (this is a stand in for 1 and could be removed when 1 is implemented).

#### Structuring Presentations

The relations used by the vector enumeration algorithm come from three sources:

**(1)**
The relations of the fp-group or fp-monoid underlying $A$.

**(2)**
The relations of $A$ itself.

**(3)**
The generators of $N$.

The third group play the same role as subgroup generators in the Todd-Coxeter algorithm, and are treated specially, while the first two groups are logically equivalent, forming the relations of $A$ in the variety of free finitely-generated associative algebras. However, when the underlying monoid of $A$ is actually an fp-group $G$, the vector enumeration algorithm can use a more efficient technique to process the relations of $G$, and can take advantage of the fact that the generators of $G$ are known to be invertible. This greatly improves the performance of the algorithm, and so users are recommended to ensure as far as possible that:

**(1)**
If the underlying monoid of an fp-algebra is in fact an fp-group then it should be presented to Magma as such.

**(2)**
Relations which can be written as equations between monomials should be given as relations of the underlying monoid, rather than as relations of the algebra.

#### Options and Controls

The `QuotientModule` function supports a large selection of optional arguments.

<a id="id2"></a>
#### Weights

The processing of the relations of $A$ by the vector enumeration algorithm depends on weights which are assigned to those relations (see above). The higher the weight of a relation the later it will be processed. By default, all relations are given weight 3, except those arising from relators of an fp-group, which are given weight equal to half the length of the relator. Separate weights are used in lookahead mode, with the same default values.

<a id="function-quotientmodule-algfp-algfp"></a>
##### `QuotientModule(A, S): AlgFP, AlgFP -> AlgFP`

```magma
MonomialWeights         : [ RngIntElt ]                    Default: 
MonWts                  : [ RngIntElt ]                    Default: 
MonomialLookaheadWeights: [ RngIntElt ]                    Default: 
MonLWts                 : [ RngIntElt ]                    Default: 
AlgebraWeights          : [ RngIntElt ]                    Default: 
AlgWts                  : [ RngIntElt ]                    Default: 
AlgebraLookaheadWeights : [ RngIntElt ]                    Default: 
AlgLWts                 : [ RngIntElt ]                    Default: 
```

This option sets the sequence of weights for the relations derived from the relations of the underlying monoid of $A$. The weights $w_1$, $w_2$, etc. are applied to the relations in the order in which they appear. If there are fewer weights than relations the remaining relations are assigned the default weight; if there are more weights than relations the extra weights are silently discarded. Unless the `MonomialLookaheadweights` or `MonLWts` parameters are present, these weights are also used in lookahead mode.

This option sets the sequence of weights for the relations derived from the relations of the underlying monoid of $A$ in lookahead mode only. It is otherwise similar to `MonomialWeights`.

This option sets the sequence of weights for the relations given explicitly as relations of the algebra $A$. It is otherwise similar to `MonomialWeights`.

This option sets the sequence of weights for the relations given explicitly as relations of the algebra $A$ in lookahead mode only. It is otherwise similar to `AlgebraWeights`.

#### Limits

<a id="function-quotientmodule-algfp-algfp-2"></a>
##### `QuotientModule(A, S): AlgFP, AlgFP -> AlgFP`

```magma
MaximumDimension: RngIntElt                        Default: Infinity()
MaxDim          : [ RngIntElt ]                    Default: Infinity()
MaximumTime     : FldReElt                         Default: Infinity()
MaxTime         : FldReElt                         Default: Infinity()
MaximumWeight   : RngIntElt                        Default: 100
MaxWt           : RngIntElt                        Default: 100
```

Options in this group set limits on the progress of the algorithm. If the calculation cannot be performed under these constraints the value `undef` is returned, unless the `ErrorOnFail` option was set, in which case a run-time error is generated.

This sets a limit of $n$ on the dimension of the vector-space constructed, and on the dimension of the intermediate spaces used in the construction. By default there is no limit, except for available memory.

This sets a limit on the CPU time available for the vector enumeration. The limit is given as a real number $t$ and is measured in seconds. This limit is only checked at certain points in the calculation, so it is possible for a vector enumeration to over-run, possibly by a significant amount. By default, there is no limit.

This sets a limit on the maximum weight of (basis vector, relation) pairs that will be used by the algorithm. The weight of a basis vector is the weight of the pair that was being processed when it was defined. The weight of a pair is the weight of the basis vector plus the weight of the relation (see above). The default limit is 100.

#### Logging

<a id="function-quotientmodule-algfp-algfp-3"></a>
##### `QuotientModule(A, S): AlgFP, AlgFP -> AlgFP`

```magma
NoLogging        : BoolElt                      Default: false
NoLog            : BoolElt                      Default: false
Silent           : BoolElt                      Default: false
MaximumLogging   : BoolElt                      Default: false
MaxLog           : BoolElt                      Default: false
LogActions       : RngIntElt                    Default: 0
LogAct           : RngIntElt                    Default: 0
LogCoincidences  : RngIntElt                    Default: 0
LogCoin          : RngIntElt                    Default: 0
LogInitialization: RngIntElt                    Default: 0
LogInitialisation: RngIntElt                    Default: 0
LogInit          : RngIntElt                    Default: 0
LogPacking       : RngIntElt                    Default: 1
LogPack          : RngIntElt                    Default: 1
LogPushes        : RngIntElt                    Default: 0
LogPush          : RngIntElt                    Default: 0
LogProgress      : RngIntElt                    Default: 0
LogStages        : RngIntElt                    Default: 0
LogWeightChanges : RngIntElt                    Default: 1
LogWt            : RngIntElt                    Default: 1
```

There are a number of options to control the level of detail provided in the informational message from the vector enumerator. When multiple contradictory options are given the first one given takes precedence. This option turns off all the informational messages produced by the vector enumerator.

This option turns on the highest possible level of detail in the informational messages. This is *too detailed* for almost all purposes except debugging.

This option sets the level of messages about the computation of the action of the algebra on the vector space under construction. At level 0 (the default) no messages are produced. All other levels produce copious output, with all levels above 2 being equivalent.

This option sets the level of messages about the coincidences discovered and the processing of them. At level 0 (the default) no messages are produced. At level 1 every coincidence and deduction is recorded when it is discovered and when it is processed. At level 2 or higher the operation of finding the undeleted image of a vector is also recorded.

This option sets the level of messages about the initialisation of new basis vectors. At level 0 (the default) no messages are produced. All other levels produce a message whenever a new basis vector is defined.

This option sets the level of messages about the reclamation of free space in the tables used by the algorithm. At level 0 no messages are produced. At level 1 (the default) it produces a message each time the pack routine is called. At level 2 or higher it records the exact renaming used to reclaim the space.

This option sets the level of messages about the pushing (or tracing) of (basis vector, relation) pairs. At level 0 (the default) it produces no messages. At level 1 a message is produced for each push that is started. At level 2 or higher the outcome of the push is also recorded.

This option sets the level of messages about the overall progress of the algorithm. At level 0 no messages are produced. At level 1, simple messages are printed as the algorithm passes through its major stages. At level 2 the relations are printed as they are read in, and the complete action on the final module is printed. At level 3 or higher the action is also printed after the processing of submodule generators is complete.

This option sets the level of messages about changes in the current weight (ie the weight of (basis vector, relation pairs) currently being pushed. At level 0 no such messages are produced. At level 1 (the default) or higher a message giving the new weight and the current dimension is printed.

#### Miscellaneous

<a id="function-quotientmodule-algfp-algfp-4"></a>
##### `QuotientModule(A, S): AlgFP, AlgFP -> AlgFP`

```magma
Lookahead          : BoolElt                      Default: true
EarlyClosing       : BoolElt                      Default: false
Early              : BoolElt                      Default: false
EarlyClosingMinimum: RngIntElt                    Default: 
ECMin              : RngIntElt                    Default: 
EarlyClosingMaximum: RngIntElt                    Default: 
ECMax              : RngIntElt                    Default: 
ConstructMorphism  : BoolElt                      Default: true
Morphism           : BoolElt                      Default: true
ErrorOnFail        : BoolElt                      Default: 
ErrFail            : BoolElt                      Default: 
```

This option controls whether, and to what extent, lookahead is used. If $x$ is `false` then lookahead is not used. If $x$ is `true`, the default, the lookahead by the default amount (two weights) is used. If $x$ is a positive integer $n$ then lookahead $n$ weights is used. A sufficiently large value of $n$ is equivalent to complete lookahead. Lookahead is commenced approximately every time the dimension doubles.

This option permits the algorithm to stop as soon as the table represents a complete action (but see below), without checking to see whether the action satisfies all the relations. In practice this action is usually correct. The default behaviour is to continue and check all the relations.

This option sets a minimum dimension at which the algorithm may stop without checking all the relators. It implies `EarlyClosing`.

This option sets a maximum dimension at which the algorithm aamy stop without checking all the relators. It implies `EarlyClosing`.

This option controls whether the third return value of the `QuotientModule` function is in fact computed. A small overhead of time and space is required to compute it, and many applications do not need it, so this option is provided. When $b$ is `true` (the default) the third return value is computed, when $b$ is `false` it is not.

This option controls the behaviour of the program if there is insufficient time or space to complete the calculation, or if the calculation has not been completed when the maximum weight is reached. If it is present a run-time error is generated, otherwise the value `undef` is returned.

<a id="example-ex-80fd44"></a>
##### `Example: Permutation Action of D8 (ex-80fd44)`

First we repeat the examples above, in Magma. The permutation action of $D_8$ :

```magma
> d8<a,b> := Group<a,b | a^4 = b^2 = (a*b)^2 = 1>;
> q := RationalField();
> a1<a,b> := FreeAlgebra(q,d8);
> i1 := rideal<a1 | b-1 >;
> mats, im, preim := QuotientModule(a1,i1);
Read Input
Done submodule generators
Starting weight 2 in define mode, 1 alive out of 2
Starting weight 3 in define mode, 1 alive out of 2
Looking ahead ...
Starting weight 4 in lookahead mode, 4 alive out of 5
Starting weight 5 in lookahead mode, 4 alive out of 5
    ...done
Packing 5 to 4
Starting weight 4 in define mode, 4 alive out of 4
Starting weight 5 in define mode, 4 alive out of 4
Starting weight 6 in define mode, 4 alive out of 4
Starting weight 7 in define mode, 5 alive out of 6
Starting weight 8 in define mode, 6 alive out of 7
Starting weight 9 in define mode, 4 alive out of 7
Starting weight 10 in define mode, 4 alive out of 7
Closed, 7 rows defined
Packing 7 to 4
4 live dimensions
Successful
> mats;
[
    [0 0 1 0]
    [1 0 0 0]
    [0 0 0 1]
    [0 1 0 0],

    [1 0 0 0]
    [0 0 1 0]
    [0 1 0 0]
    [0 0 0 1]
]
> im;
[
    (1 0 0 0)
]
> preim;
[ Id(), a^-1, a^-1 * b, a^-2 ]
>
```

<a id="example-ex-631bdb"></a>
##### `Example: Quotient of a Permutation Module (ex-631bdb)`

A quotient of that module. We continue from the last example and set:

```magma
> d8<a,b> := Group<a,b | a^4 = b^2 = (a*b)^2 = 1>;
> q := RationalField();
> a1<a,b> := FreeAlgebra(q,d8);
> i2 := rideal<a1 | b-1, 1+a^3+a^3*b+a^2>;
> mats, im, preim := QuotientModule(a1,i2);
Read Input
Done submodule generators
Starting weight 2 in define mode, 4 alive out of 6
Starting weight 3 in define mode, 5 alive out of 7
Starting weight 4 in define mode, 3 alive out of 7
Starting weight 5 in define mode, 3 alive out of 7
Closed, 7 rows defined
Packing 7 to 3
3 live dimensions
Successful
> mats;
[
    [ 0  1  0]
    [ 0  0  1]
    [-1 -1 -1],

    [ 1  0  0]
    [-1 -1 -1]
    [ 0  0  1]
]
```

<a id="matrix"></a>
<a id="chapalgmat"></a>
## Matrix Algebras

- [Introduction](https://docs.magma-maths.org/Algebras/MatrixAlgebras/introduction.md)
- [Construction of Matrix Algebras and their Elements](https://docs.magma-maths.org/Algebras/MatrixAlgebras/creation.md)
  - [Construction of the Complete Matrix Algebra](https://docs.magma-maths.org/Algebras/MatrixAlgebras/creation.md#construction-of-the-complete-matrix-algebra)
    - [`MatrixAlgebra(S, n): Rng, RngIntElt → AlgMat`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/creation.md#function-matrixalgebra-rng-rngintelt)
    - [`MatrixRing(S, n): Rng, RngIntElt → AlgMat`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/creation.md#function-matrixring-rng-rngintelt)
  - [Construction of a Matrix](https://docs.magma-maths.org/Algebras/MatrixAlgebras/creation.md#construction-of-a-matrix)
    - [`elt< R | L >: AlgMat, RngElt → AlgMatElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/creation.md#constructor-constructor-elt-algmat-rngelt-algmatelt)
    - [`R ! Q: AlgMat, [ RngElt ] → AlgMatElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/creation.md#operation-op-algmat-rngelt)
    - [`CambridgeMatrix(t, K, n, Q): RngIntElt, FldFin, RngIntElt, [ ] → AlgMatElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/creation.md#function-cambridgematrix-rngintelt-fldfin-rngintelt)
    - [`CompanionMatrix(p): RngUPolElt → AlgMatElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/creation.md#function-companionmatrix-rngupolelt)
    - [`DiagonalMatrix(R, Q): AlgMat, [ RngElt ] → AlgMatElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/creation.md#function-diagonalmatrix-algmat-rngelt)
    - [`MatrixUnit(R, i, j): AlgMat, RngIntElt, RngIntElt → AlgMatElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/creation.md#function-matrixunit-algmat-rngintelt-rngintelt)
    - [`Random(R): AlgMat → AlgMatElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/creation.md#function-random-algmat)
    - [`ScalarMatrix(R, t): AlgMat, RngElt → AlgMatElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/creation.md#function-scalarmatrix-algmat-rngelt)
    - [`R ! 1: AlgMat, RngIntElt → AlgMatElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/creation.md#operation-op-algmat-rngintelt)
    - [`R ! 0: AlgMat, RngIntElt → AlgMatElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/creation.md#operation-op-algmat-rngintelt-2)
    - [`R ! t: AlgMat, RngIntElt → AlgMatElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/creation.md#operation-op-algmat-rngintelt-3)
  - [Constructing a General Matrix Algebra](https://docs.magma-maths.org/Algebras/MatrixAlgebras/creation.md#constructing-a-general-matrix-algebra)
    - [`MatrixAlgebra<S, n | L>: Rng, RngIntElt, List → AlgMat`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/creation.md#constructor-constructor-matrixalgebra-rng-rngintelt-list-algmat)
    - [`MatrixRing<S, n | L>: Rng, RngIntElt, List → AlgMat`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/creation.md#constructor-constructor-matrixring-rng-rngintelt-list-algmat)
    - [Example: Algebra of Lower-Triangular Matrices](https://docs.magma-maths.org/Algebras/MatrixAlgebras/creation.md#example-ex-0b78f0)
    - [Example: Constructing a Cambridge Matrix](https://docs.magma-maths.org/Algebras/MatrixAlgebras/creation.md#example-ex-424fbd)
    - [`Algebra(R): AlgMatV → AlgGen, Map`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/creation.md#function-algebra-algmatv)
  - [The Invariants of a Matrix Algebra](https://docs.magma-maths.org/Algebras/MatrixAlgebras/creation.md#the-invariants-of-a-matrix-algebra)
    - [`R . i: AlgMat, RngIntElt → AlgMatElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/creation.md#operation-operation-algmat-rngintelt-algmatelt)
    - [`BaseRing(R): AlgMatV → Rng`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/creation.md#function-basering-algmatv)
    - [`CoefficientRing(R): AlgMatV → Rng`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/creation.md#function-coefficientring-algmatv)
    - [`Degree(R): AlgMatV → RngIntElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/creation.md#function-degree-algmatv)
    - [`Generators(R): AlgMat → { AlgMatElt}`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/creation.md#function-generators-algmat)
    - [`Generic(R): AlgMat → AlgMat`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/creation.md#function-generic-algmat)
    - [`BaseModule(R): AlgMatV → ModTup`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/creation.md#function-basemodule-algmatv)
    - [`NumberOfGenerators(R): AlgMat → { AlgMatElt}`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/creation.md#function-numberofgenerators-algmat)
    - [`Ngens(R): AlgMat → { AlgMatElt}`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/creation.md#function-ngens-algmat)
    - [`Parent(a): AlgMatElt → AlgMat`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/creation.md#function-parent-algmatelt)
    - [Example: Invariants of a Lower-Triangular Algebra](https://docs.magma-maths.org/Algebras/MatrixAlgebras/creation.md#example-ex-97af59)
- [Construction of Subalgebras, Ideals, and Quotient Rings](https://docs.magma-maths.org/Algebras/MatrixAlgebras/subring-ideal-quotient.md)
  - [`sub<R | L>: AlgMat, List → AlgMat, Hom(Alg)`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/subring-ideal-quotient.md#constructor-constructor-sub-algmat-list-algmat-hom-alg)
  - [`ideal<R | L>: AlgMat, List → AlgMat`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/subring-ideal-quotient.md#constructor-constructor-ideal-algmat-list-algmat)
  - [`lideal<R | L>: AlgMat, List → AlgMat`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/subring-ideal-quotient.md#constructor-constructor-lideal-algmat-list-algmat)
  - [`rideal<R | L>: AlgMat, List → AlgMat`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/subring-ideal-quotient.md#constructor-constructor-rideal-algmat-list-algmat)
  - [Example: Subalgebra Generated by One Element](https://docs.magma-maths.org/Algebras/MatrixAlgebras/subring-ideal-quotient.md#example-ex-3c6faa)
- [The Construction of Extensions and their Elements](https://docs.magma-maths.org/Algebras/MatrixAlgebras/extension.md)
  - [The Construction of Direct Sums and Tensor Products](https://docs.magma-maths.org/Algebras/MatrixAlgebras/extension.md#the-construction-of-direct-sums-and-tensor-products)
    - [`DirectSum(R, T): AlgMat, AlgMat → AlgMat`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/extension.md#function-directsum-algmat-algmat)
    - [`TensorProduct(A, B): AlgMat, AlgMat → AlgMat`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/extension.md#function-tensorproduct-algmat-algmat)
    - [Example: Direct Sum and Tensor Product](https://docs.magma-maths.org/Algebras/MatrixAlgebras/extension.md#example-ex-548c90)
  - [Construction of Direct Sums and Tensor Products of Elements](https://docs.magma-maths.org/Algebras/MatrixAlgebras/extension.md#construction-of-direct-sums-and-tensor-products-of-elements)
    - [`DirectSum(a, b): AlgMatElt, AlgMatElt → AlgMatElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/extension.md#function-directsum-algmatelt-algmatelt)
    - [`ExteriorSquare(a): AlgMatElt → AlgMatElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/extension.md#function-exteriorsquare-algmatelt)
    - [`ExteriorPower(a,r): AlgMat, RngIntElt → AlgMatElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/extension.md#function-exteriorpower-algmat-rngintelt)
    - [`SymmetricSquare(a): AlgMatElt → AlgMatElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/extension.md#function-symmetricsquare-algmatelt)
    - [`SymmetricPower(a,r): AlgMatElt, RngIntElt → AlgMatElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/extension.md#function-symmetricpower-algmatelt-rngintelt)
    - [`TensorProduct(a, b): AlgMatElt, AlgMatElt → AlgMatElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/extension.md#function-tensorproduct-algmatelt-algmatelt)
- [Operations on Matrix Algebras](https://docs.magma-maths.org/Algebras/MatrixAlgebras/operation.md)
  - [`Centre(A): AlgMat → AlgMat`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/operation.md#function-centre-algmat)
  - [`Centralizer(A, S): AlgMat, AlgMat → AlgMat`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/operation.md#function-centralizer-algmat-algmat)
  - [`Centraliser(A, S): AlgMat, AlgMat → AlgMat`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/operation.md#function-centraliser-algmat-algmat)
- [Changing Rings](https://docs.magma-maths.org/Algebras/MatrixAlgebras/change-ring.md)
  - [`ChangeRing(A, S): AlgMatV, Rng → AlgMat, Map`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/change-ring.md#function-changering-algmatv-rng)
  - [`ChangeRing(A, S, f): AlgMatV, Rng, Map → AlgMat, Map`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/change-ring.md#function-changering-algmatv-rng-map)
  - [`hom< A -> B | f >: AlgMat, AlgMat, Map → Map`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/change-ring.md#constructor-constructor-hom-algmat-algmat-map-map)
- [Elementary Operations on Elements](https://docs.magma-maths.org/Algebras/MatrixAlgebras/element.md)
  - [Arithmetic](https://docs.magma-maths.org/Algebras/MatrixAlgebras/element.md#arithmetic)
    - [`a + b: AlgMatElt, AlgMatElt → AlgMatElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/element.md#operation-op-plus-algmatelt-algmatelt)
    - [`a + t: AlgMatElt, RngElt → AlgMatElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/element.md#operation-op-plus-algmatelt-rngelt)
    - [`t + a: AlgMatElt, RngElt → AlgMatElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/element.md#operation-op-plus-algmatelt-rngelt-2)
    - [`- a: AlgMatElt → AlgMatElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/element.md#operation-operation-algmatelt-algmatelt)
    - [`a - b: AlgMatElt, AlgMatElt → AlgMatElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/element.md#operation-op-minus-algmatelt-algmatelt)
    - [`a - t: AlgMatElt, RngElt → AlgMatElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/element.md#operation-op-minus-algmatelt-rngelt)
    - [`t - a: AlgMatElt, RngElt → AlgMatElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/element.md#operation-op-minus-algmatelt-rngelt-2)
    - [`a * b: AlgMatElt, AlgMatElt → AlgMatElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/element.md#operation-op-times-algmatelt-algmatelt)
    - [`a * b: AlgMatElt, Mtrx → Mtrx`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/element.md#operation-op-times-algmatelt-mtrx)
    - [`a * b: Mtrx, AlgMatElt → Mtrx`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/element.md#operation-op-times-mtrx-algmatelt)
    - [`t * a: RngElt, AlgMatElt → AlgMatElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/element.md#operation-op-times-rngelt-algmatelt)
    - [`a * t: AlgMatElt, RngElt → AlgMatElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/element.md#operation-op-times-algmatelt-rngelt)
    - [`u * a: ModTupRngElt, AlgMatElt → ModTupElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/element.md#operation-op-times-modtuprngelt-algmatelt)
    - [`a ^ n: AlgMatElt, RngIntElt → AlgMatElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/element.md#operation-op-pow-algmatelt-rngintelt)
    - [`NumberOfColumns(a): AlgMatElt → RngIntElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/element.md#function-numberofcolumns-algmatelt)
    - [`Ncols(a): AlgMatElt → RngIntElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/element.md#function-ncols-algmatelt)
    - [`NumberOfRows(a): AlgMatElt → RngIntElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/element.md#function-numberofrows-algmatelt)
    - [`Nrows(a): AlgMatElt → RngIntElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/element.md#function-nrows-algmatelt)
  - [Predicates](https://docs.magma-maths.org/Algebras/MatrixAlgebras/element.md#predicates)
    - [Comparison](https://docs.magma-maths.org/Algebras/MatrixAlgebras/element.md#comparison)
      - [`a eq b: AlgMatElt, AlgMatElt → BoolElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/element.md#operation-op-eq-algmatelt-algmatelt)
      - [`a ne b: AlgMatElt, AlgMatElt → BoolElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/element.md#operation-op-ne-algmatelt-algmatelt)
    - [Properties of Elements](https://docs.magma-maths.org/Algebras/MatrixAlgebras/element.md#properties-of-elements)
      - [`IsDiagonal(a): AlgMatElt → BoolElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/element.md#function-isdiagonal-algmatelt)
      - [`IsMinusOne(a): AlgMatElt → BoolElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/element.md#function-isminusone-algmatelt)
      - [`IsOne(a): AlgMatElt → BoolElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/element.md#function-isone-algmatelt)
      - [`IsScalar(a): AlgMatElt → BoolElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/element.md#function-isscalar-algmatelt)
      - [`IsSymmetric(a): AlgMatElt → BoolElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/element.md#function-issymmetric-algmatelt)
      - [`IsUnit(a): AlgMatElt → BoolElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/element.md#function-isunit-algmatelt)
      - [`IsZero(a): AlgMatElt → BoolElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/element.md#function-iszero-algmatelt)
      - [`IsNilpotent(a): AlgMatElt → BoolElt, RngIntElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/element.md#function-isnilpotent-algmatelt)
      - [`IsUnipotent(a): AlgMatElt → BoolElt, RngIntElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/element.md#function-isunipotent-algmatelt)
      - [`Rank(a): AlgMatElt → RngIntElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/element.md#function-rank-algmatelt)
      - [`Determinant(A): AlgMatElt → RngElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/element.md#function-determinant-algmatelt)
      - [`Trace(a): AlgMatElt → RngElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/element.md#function-trace-algmatelt)
      - [`Transpose(a): AlgMatElt → AlgMatElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/element.md#function-transpose-algmatelt)
      - [`Order(a): AlgMatElt → RngIntElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/element.md#function-order-algmatelt)
      - [`FactoredOrder(a): AlgMatElt → [ <RngIntElt, RngIntElt> ]`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/element.md#function-factoredorder-algmatelt)
      - [`ProjectiveOrder(a): AlgMatElt → RngIntElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/element.md#function-projectiveorder-algmatelt)
      - [`FactoredProjectiveOrder(a): AlgMatElt → [ <RngIntElt, RngIntElt> ]`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/element.md#function-factoredprojectiveorder-algmatelt)
      - [`CharacteristicPolynomial(a: parameters): AlgMatElt → RngUPolElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/element.md#function-characteristicpolynomial-algmatelt)
      - [`MinimalPolynomial(a): AlgMatElt → RngUPolElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/element.md#function-minimalpolynomial-algmatelt)
      - [`HessenbergForm(a): AlgMatElt → AlgMatElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/element.md#function-hessenbergform-algmatelt)
      - [`Adjoint(a): AlgMatElt → AlgMatElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/element.md#function-adjoint-algmatelt)
      - [`Eigenvalues(a): AlgMatElt → { <FldElt, RngIntElt> }`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/element.md#function-eigenvalues-algmatelt)
      - [`Eigenspace(a, e): AlgMatElt, FldElt → ModTup`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/element.md#function-eigenspace-algmatelt-fldelt)
- [Elements of $M_n$ as Homomorphisms](https://docs.magma-maths.org/Algebras/MatrixAlgebras/homomorphism-element.md)
  - [`Image(a): AlgMatElt → ModTup`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/homomorphism-element.md#function-image-algmatelt)
  - [`RowSpace(a): AlgMatElt → ModTup`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/homomorphism-element.md#function-rowspace-algmatelt)
  - [`Kernel(a): AlgMatElt → ModTup`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/homomorphism-element.md#function-kernel-algmatelt)
  - [`NullSpace(a): AlgMatElt → ModTup`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/homomorphism-element.md#function-nullspace-algmatelt)
  - [`RowNullSpace(a): AlgMatElt → ModTup`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/homomorphism-element.md#function-rownullspace-algmatelt)
  - [`NullspaceOfTranspose(a): AlgMatVElt → ModTupRng`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/homomorphism-element.md#function-nullspaceoftranspose-algmatvelt)
  - [`Restrict(a, V): AlgMatElt, ModTupRng → AlgMatElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/homomorphism-element.md#function-restrict-algmatelt-modtuprng)
  - [`Restrict(a, V): AlgMatElt, ModTupFld → AlgMatElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/homomorphism-element.md#function-restrict-algmatelt-modtupfld)
- [Elementary Operations on Subalgebras and Ideals](https://docs.magma-maths.org/Algebras/MatrixAlgebras/subalgebra-ideal.md)
  - [Bases](https://docs.magma-maths.org/Algebras/MatrixAlgebras/subalgebra-ideal.md#bases)
    - [`Dimension(R): AlgMatV → RngIntElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/subalgebra-ideal.md#function-dimension-algmatv)
    - [`Basis(R): AlgMatV → [ AlgMatElt ]`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/subalgebra-ideal.md#function-basis-algmatv)
    - [`BasisElement(R, i): AlgMatV, RngIntElt → AlgMatElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/subalgebra-ideal.md#function-basiselement-algmatv-rngintelt)
    - [`Coordinates(R, X): AlgMatV, AlgMatVElt → [ RngElt ]`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/subalgebra-ideal.md#function-coordinates-algmatv-algmatvelt)
  - [Intersection of Subalgebras](https://docs.magma-maths.org/Algebras/MatrixAlgebras/subalgebra-ideal.md#intersection-of-subalgebras)
    - [`R meet T: AlgMat, AlgMat → AlgMat`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/subalgebra-ideal.md#operation-op-meet-algmat-algmat)
  - [Membership and Equality](https://docs.magma-maths.org/Algebras/MatrixAlgebras/subalgebra-ideal.md#membership-and-equality)
    - [`x in R: AlgMatElt, AlgMat → BoolElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/subalgebra-ideal.md#operation-op-in-algmatelt-algmat)
    - [`X subset R: { AlgMatElt}, AlgMat → BoolElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/subalgebra-ideal.md#operation-op-subset-algmatelt-algmat)
    - [`T subset R: AlgMat, AlgMat → BoolElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/subalgebra-ideal.md#operation-op-subset-algmat-algmat)
    - [`x notin R: AlgMatElt, AlgMat → BoolElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/subalgebra-ideal.md#operation-op-notin-algmatelt-algmat)
    - [`X notsubset R: { AlgMatElt}, AlgMat → BoolElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/subalgebra-ideal.md#operation-operation-notsubset-algmatelt-algmat-boolelt)
    - [`T notsubset R: AlgMat, AlgMat → BoolElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/subalgebra-ideal.md#operation-operation-notsubset-algmat-algmat-boolelt)
    - [`R eq T: AlgMat, AlgMat → BoolElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/subalgebra-ideal.md#operation-op-eq-algmat-algmat)
    - [`R ne T: AlgMat, AlgMat → BoolElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/subalgebra-ideal.md#operation-op-ne-algmat-algmat)
- [Accessing and Modifying a Matrix](https://docs.magma-maths.org/Algebras/MatrixAlgebras/operation-element.md)
  - [Indexing](https://docs.magma-maths.org/Algebras/MatrixAlgebras/operation-element.md#indexing)
    - [`a[i]: AlgMatElt, RngIntElt → ModTupElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/operation-element.md#indexed-indexed-a-algmatelt-rngintelt-modtupelt)
    - [`a[i] := u: AlgMatElt, RngIntElt, RngElt → AlgMatElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/operation-element.md#literal-literal-a-i-u-algmatelt-rngintelt-rngelt-algmatelt)
    - [`a[i, j]: AlgMatElt, RngIntElt, RngIntElt → RngElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/operation-element.md#indexed-indexed-a-algmatelt-rngintelt-rngintelt-rngelt)
    - [`a[i, j] := t: AlgMatElt, RngIntElt, RngIntElt, RngElt → AlgMatElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/operation-element.md#literal-literal-a-i-j-t-algmatelt-rngintelt-rngintelt-rngelt-algmatelt)
    - [`ElementToSequence(a): AlgMatElt → [ RngElt ]`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/operation-element.md#function-elementtosequence-algmatelt)
    - [`Eltseq(a): AlgMatElt → [ RngElt ]`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/operation-element.md#function-eltseq-algmatelt)
  - [Extracting and Inserting Blocks](https://docs.magma-maths.org/Algebras/MatrixAlgebras/operation-element.md#extracting-and-inserting-blocks)
    - [`Submatrix(a, i, j, p, q): Mtrx, RngIntElt, RngIntElt, RngIntElt, RngIntElt → Mtrx`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/operation-element.md#function-submatrix-mtrx-rngintelt-rngintelt-rngintelt-rngintelt)
    - [`ExtractBlock(a, i, j, p, q): Mtrx, RngIntElt, RngIntElt, RngIntElt, RngIntElt → Mtrx`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/operation-element.md#function-extractblock-mtrx-rngintelt-rngintelt-rngintelt-rngintelt)
    - [`InsertBlock(~a, b, i, j): Mtrx, Mtrx, RngIntElt, RngIntElt → Mtrx`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/operation-element.md#function-insertblock-mtrx-mtrx-rngintelt-rngintelt-ref)
  - [Joining Matrices](https://docs.magma-maths.org/Algebras/MatrixAlgebras/operation-element.md#joining-matrices)
    - [`HorizontalJoin(X, Y): Mtrx, Mtrx → Mtrx`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/operation-element.md#function-horizontaljoin-mtrx-mtrx)
    - [`HorizontalJoin(Q): [ ModMatRngElt ] → ModMatRngElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/operation-element.md#function-horizontaljoin-modmatrngelt)
    - [`VerticalJoin(X, Y): ModMatRngElt, ModMatRngElt → ModMatRngElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/operation-element.md#function-verticaljoin-modmatrngelt-modmatrngelt)
    - [`VerticalJoin(Q): [ ModMatRngElt ] → ModMatRngElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/operation-element.md#function-verticaljoin-modmatrngelt)
    - [`DiagonalJoin(X, Y): ModMatRngElt, ModMatRngElt → ModMatRngElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/operation-element.md#function-diagonaljoin-modmatrngelt-modmatrngelt)
    - [`DiagonalJoin(Q): [ ModMatRngElt ] → ModMatRngElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/operation-element.md#function-diagonaljoin-modmatrngelt)
  - [Row and Column Operations](https://docs.magma-maths.org/Algebras/MatrixAlgebras/operation-element.md#row-and-column-operations)
    - [`SwapRows(~a, i, j): AlgMatElt, RngIntElt, RngIntElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/operation-element.md#procedure-swaprows-algmatelt-rngintelt-rngintelt-ref)
    - [`MultiplyRow(~a, u, j): AlgMatElt, RngElt, RngIntElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/operation-element.md#procedure-multiplyrow-algmatelt-rngelt-rngintelt-ref)
    - [`AddRow(~a, u, i, j): AlgMatElt, RngElt, RngIntElt, RngIntElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/operation-element.md#procedure-addrow-algmatelt-rngelt-rngintelt-rngintelt-ref)
    - [`SwapColumns(~a, i, j): AlgMatElt, RngIntElt, RngIntElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/operation-element.md#procedure-swapcolumns-algmatelt-rngintelt-rngintelt-ref)
    - [`MultiplyColumn(~a, u, i): AlgMatElt, RngElt, RngIntElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/operation-element.md#procedure-multiplycolumn-algmatelt-rngelt-rngintelt-ref)
    - [`AddColumn(~a, u, i, j): AlgMatElt, RngElt, RngIntElt, RngIntElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/operation-element.md#procedure-addcolumn-algmatelt-rngelt-rngintelt-rngintelt-ref)
- [Canonical Forms](https://docs.magma-maths.org/Algebras/MatrixAlgebras/canonical-form.md)
  - [Canonical Forms for Matrices over Euclidean Domains](https://docs.magma-maths.org/Algebras/MatrixAlgebras/canonical-form.md#canonical-forms-for-matrices-over-euclidean-domains)
    - [`EchelonForm(a): AlgMatElt → AlgMatElt, AlgMatElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/canonical-form.md#function-echelonform-algmatelt)
    - [`ElementaryDivisors(a): AlgMatElt → [RngElt]`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/canonical-form.md#function-elementarydivisors-algmatelt)
    - [`HermiteForm(X): AlgMatElt → AlgMatElt, AlgMatElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/canonical-form.md#function-hermiteform-algmatelt)
    - [`SmithForm(a): AlgMatElt → AlgMatElt, AlgMatElt, AlgMatElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/canonical-form.md#function-smithform-algmatelt)
    - [Example: Echelon Form](https://docs.magma-maths.org/Algebras/MatrixAlgebras/canonical-form.md#example-ex-e0346c)
  - [Canonical Forms for Matrices over a Field](https://docs.magma-maths.org/Algebras/MatrixAlgebras/canonical-form.md#canonical-forms-for-matrices-over-a-field)
    - [`PrimaryRationalForm(a): AlgMatElt → AlgMatElt, AlgMatElt, [ <RngUPolElt, RngIntElt ]`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/canonical-form.md#function-primaryrationalform-algmatelt)
    - [`JordanForm(a): AlgMatElt → AlgMatElt, AlgMatElt, [ <RngUPolElt, RngIntElt ]`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/canonical-form.md#function-jordanform-algmatelt)
    - [`RationalForm(a): AlgMatElt → AlgMatElt, AlgMatElt, [ RngUPolElt ]`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/canonical-form.md#function-rationalform-algmatelt)
    - [`PrimaryInvariantFactors(a): AlgMatElt → [ <RngUPolElt, RngIntElt ]`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/canonical-form.md#function-primaryinvariantfactors-algmatelt)
    - [`InvariantFactors(a): AlgMatElt → [ AlgPolElt ]`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/canonical-form.md#function-invariantfactors-algmatelt)
    - [`IsSimilar(a, b): AlgMatElt, AlgMatElt → BoolElt, AlgMatElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/canonical-form.md#function-issimilar-algmatelt-algmatelt)
    - [Example: Elementary Divisors](https://docs.magma-maths.org/Algebras/MatrixAlgebras/canonical-form.md#example-ex-29de54)
    - [Example: Canonical Forms over a Finite Field](https://docs.magma-maths.org/Algebras/MatrixAlgebras/canonical-form.md#example-ex-a68b91)
- [Diagonalising Commutative Algebras over a Field](https://docs.magma-maths.org/Algebras/MatrixAlgebras/diag.md)
  - [`CommonEigenspaces(Q): [AlgMatElt] → [**], [[FldElt]]`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/diag.md#function-commoneigenspaces-algmatelt)
  - [`CommonEigenspaces(A): AlgMat → [**], [[FldElt]]`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/diag.md#function-commoneigenspaces-algmat)
  - [`IsEtale(A): AlgMat → BoolElt, AlgMatElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/diag.md#function-isetale-algmat)
  - [`Diagonalisation(Q): [AlgMatElt] → [AlgMatElt], AlgMatElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/diag.md#function-diagonalisation-algmatelt)
  - [`Diagonalization(Q): [AlgMatElt] → [AlgMatElt], AlgMatElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/diag.md#function-diagonalization-algmatelt)
  - [`Diagonalisation(A): AlgMat → AlgMat, AlgMatElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/diag.md#function-diagonalisation-algmat)
  - [`Diagonalization(A): AlgMat → AlgMat, AlgMatElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/diag.md#function-diagonalization-algmat)
  - [`Diagonalisation(M): AlgMatElt → AlgMatElt, AlgMatElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/diag.md#function-diagonalisation-algmatelt-2)
  - [`Diagonalization(M): AlgMatElt → AlgMatElt, AlgMatElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/diag.md#function-diagonalization-algmatelt-2)
  - [`IsDiagonalisable(M): AlgMatElt → Boolelt, AlgMatElt, AlgMatElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/diag.md#function-isdiagonalisable-algmatelt)
  - [`IsDiagonalizable(M): AlgMatElt → Boolelt, AlgMatElt, AlgMatElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/diag.md#function-isdiagonalizable-algmatelt)
  - [Example: Common Eigenspaces of Commuting Matrices](https://docs.magma-maths.org/Algebras/MatrixAlgebras/diag.md#example-ex-b2afd3)
  - [Example: Diagonalising over an Extension Field](https://docs.magma-maths.org/Algebras/MatrixAlgebras/diag.md#example-ex-a7004a)
- [Solutions of Systems of Linear Equations](https://docs.magma-maths.org/Algebras/MatrixAlgebras/solution-equation.md)
  - [`IsConsistent(A, w): ModMatRngElt, ModTupRng → BoolElt, ModTupRngElt, ModTupRng`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/solution-equation.md#function-isconsistent-modmatrngelt-modtuprng)
  - [`IsConsistent(A, W): ModMatRngElt, [ ModTupRng ] → BoolElt, [ ModTupRngElt ], ModTupRng`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/solution-equation.md#function-isconsistent-modmatrngelt-modtuprng-2)
  - [`Solution(A, w): ModMatRngElt, ModTupRng → ModTupRngElt, ModTupRng`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/solution-equation.md#function-solution-modmatrngelt-modtuprng)
  - [`Solution(A, W): ModMatRngElt, [ ModTupRng ] → [ ModTupRngElt ], ModTupRng`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/solution-equation.md#function-solution-modmatrngelt-modtuprng-2)
- [Presentations for Matrix Algebras](https://docs.magma-maths.org/Algebras/MatrixAlgebras/presentations.md)
  - [Quotients and Idempotents](https://docs.magma-maths.org/Algebras/MatrixAlgebras/presentations.md#quotients-and-idempotents)
    - [`NaturalFreeAlgebraCover(A): AlgMat → Map`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/presentations.md#function-naturalfreealgebracover-algmat)
    - [`SimpleQuotientAlgebras(A): AlgMat → Rec`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/presentations.md#function-simplequotientalgebras-algmat)
    - [`PrimitiveIdempotentData(A): AlgMat → SeqEnum, Map, SeqEnum`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/presentations.md#function-primitiveidempotentdata-algmat)
    - [`PrimitiveIdempotents(A): AlgMat → SeqEnum`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/presentations.md#function-primitiveidempotents-algmat)
    - [`RanksOfPrimitiveIdempotents(A): AlgMat → SeqEnum`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/presentations.md#function-ranksofprimitiveidempotents-algmat)
    - [`NaturalFreeAlgebraCover(A): AlgMat → Map`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/presentations.md#function-naturalfreealgebracover-algmat-2)
    - [`CondensedAlgebra(A): AlgMat → AlgMat`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/presentations.md#function-condensedalgebra-algmat)
    - [Example: Primitive Idempotents](https://docs.magma-maths.org/Algebras/MatrixAlgebras/presentations.md#example-ex-b62a87)
  - [Generators and Presentations](https://docs.magma-maths.org/Algebras/MatrixAlgebras/presentations.md#generators-and-presentations)
    - [`SemisimpleGeneratorData(A): AlgMat → SeqEnum`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/presentations.md#function-semisimplegeneratordata-algmat)
    - [`AlgebraGenerators(A): AlgMat → Rec`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/presentations.md#function-algebragenerators-algmat)
    - [`AlgebraStructure(A): AlgMat → Rec`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/presentations.md#function-algebrastructure-algmat)
    - [`Presentation(A): AlgMat → AlgFr, AlgFr, Map`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/presentations.md#function-presentation-algmat)
    - [`StandardFormConjugationMatrices(A): AlgMat → Tup`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/presentations.md#function-standardformconjugationmatrices-algmat)
    - [`CondensationMatrices(A): AlgMat → Tup`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/presentations.md#function-condensationmatrices-algmat)
    - [`SequenceOfRadicalGenerators(A): AlgMat → SeqEnum`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/presentations.md#function-sequenceofradicalgenerators-algmat)
    - [`CartanMatrix(A): AlgMat → ModMatRngElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/presentations.md#function-cartanmatrix-algmat)
    - [Example: Condensed Algebra of a Permutation Module](https://docs.magma-maths.org/Algebras/MatrixAlgebras/presentations.md#example-ex-865183)
  - [Solving the Word Problem](https://docs.magma-maths.org/Algebras/MatrixAlgebras/presentations.md#solving-the-word-problem)
    - [`WordProblemData(A): AlgMat → List`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/presentations.md#function-wordproblemdata-algmat)
    - [`WordProblem(A, x): AlgMat, AlgMatElt → BoolElt, AlgFrElt`](https://docs.magma-maths.org/Algebras/MatrixAlgebras/presentations.md#function-wordproblem-algmat-algmatelt)
    - [Example: Presentation of a Matrix Algebra](https://docs.magma-maths.org/Algebras/MatrixAlgebras/presentations.md#example-ex-6d214a)
- [Bibliography](https://docs.magma-maths.org/Algebras/MatrixAlgebras/bibliography.md)

### Introduction

Matrix algebras (or matrix rings) may be defined over any ring $S$. We shall regard such a matrix algebra as an $S$*-algebra*. Let us denote the complete algebra of $n\times n$ matrices over $S$ by $M_n(S)$. It will often be convenient to regard $M_n(S)$ as the endomorphism ring of the free $S$-module $S^{(n)}$. We will then speak of $S^{(n)}$ as the natural $S$-module associated with $M_n(S)$.

Matrix algebras have type `AlgMat` and their elements have type `AlgMatElt`. These types inherit from `AlgMatV` and `AlgMatVElt` respectively (which cover both ordinary matrix algebras and matrix Lie algebras).

### Construction of Matrix Algebras and their Elements

#### Construction of the Complete Matrix Algebra

<a id="function-matrixalgebra-rng-rngintelt"></a>
##### `MatrixAlgebra(S, n): Rng, RngIntElt -> AlgMat`

<a id="function-matrixring-rng-rngintelt"></a>
##### `MatrixRing(S, n): Rng, RngIntElt -> AlgMat`

Given a positive integer $n$ and a ring $S$, create the complete matrix algebra $M_n(S)$, consisting of all $n\times n$ matrices with coefficients in the ring $S$.

<a id="element"></a>
<a id="algmat-elt-constr"></a>
#### Construction of a Matrix

<a id="constructor-constructor-elt-algmat-rngelt-algmatelt"></a>
##### `elt< R | L >: AlgMat, RngElt -> AlgMatElt`

Given a matrix algebra defined as a subalgebra of $M_n(S)$, create the element of $R$ defined by the list $L$ of $n^2$ elements from $S$.

<a id="operation-op-algmat-rngelt"></a>
##### `R ! Q: AlgMat, [ RngElt ] -> AlgMatElt`

Given a matrix algebra $R$ defined as a subalgebra of $M_n(S)$ and a sequence $Q=[a_{11}, \ldots, a_{1n}, a_{21},\ldots, a_{2n}, \ldots, a_{n1},\ldots, a_{nn}]$ of $n^2$ elements of $S$, return the matrix $\begin{pmatrix}a_{11}&a_{12}&\ldots&a_{1n}\\ a_{21}&a_{22}&\ldots&a_{2n}\\ \vdots&\vdots&\ddots&\vdots\\ a_{n1}&a_{n2}&\ldots&a_{nn}\end{pmatrix}$

as an element of $R$. Note that the algebra $R$ must exist before an attempt is made to create matrices.

<a id="function-cambridgematrix-rngintelt-fldfin-rngintelt"></a>
##### `CambridgeMatrix(t, K, n, Q): RngIntElt, FldFin, RngIntElt, [ ] -> AlgMatElt`

This function creates a $n$ by $n$ matrix over the finite field $K$ of cardinality $q$ specified in a “Cambridge” format in the general matrix algebra of degree $n$ over $K$. The parameter $t$ specifies the type of the format. If $t$ is 1, then $q$ is assumed to be less than 10 and the sequence $Q$ must consist of $n$ strings which give the $n$ rows—each string must have length $n$ and contain the entries of that row (each entry is a digit in the range [0, $q - 1$]). If $t$ is 3 then $Q$ must consist of $n^2$ integers in the range [0, $q-1$] which give the entries in row-major order. In either format, if $q=p^e$, where $p$ is prime and $e>1$, then an entry $x$ is written as a vector using the base-$p$ representation of length $e$ of $x$ and the corresponding element in $K$ is used (see the Finite Fields chapter for details). This function is principally provided for the reading in of large matrices.

<a id="function-companionmatrix-rngupolelt"></a>
##### `CompanionMatrix(p): RngUPolElt -> AlgMatElt`

Given a monic polynomial $p$ of degree $n$ over a ring $R$, create the companion matrix $C$ for $p$ as an element of $M_n(R)$. The minimal and characteristic polynomial of $C$ is then $p$.

<a id="function-diagonalmatrix-algmat-rngelt"></a>
##### `DiagonalMatrix(R, Q): AlgMat, [ RngElt ] -> AlgMatElt`

If $R$ is a subalgebra of $M_n(S)$ and $Q$ is a sequence of $n$ elements of $S$, create the diagonal matrix $diag( Q[1], Q[2], \ldots, Q[n] )$.

<a id="function-matrixunit-algmat-rngintelt-rngintelt"></a>
##### `MatrixUnit(R, i, j): AlgMat, RngIntElt, RngIntElt -> AlgMatElt`

Create the matrix unit $E(i, j)$ in the matrix algebra $R$, i.e. the matrix having the one of the coefficient ring of $R$ in position $(i, j)$ and zeros elsewhere.

<a id="function-random-algmat"></a>
##### `Random(R): AlgMat -> AlgMatElt`

Create a random matrix of the matrix algebra $R$.

<a id="function-scalarmatrix-algmat-rngelt"></a>
##### `ScalarMatrix(R, t): AlgMat, RngElt -> AlgMatElt`

If $R$ is a subalgebra of $M_n(S)$ and $t$ is an element of the ring $S$, create the scalar matrix $t*I$ in $R$.

<a id="operation-op-algmat-rngintelt"></a>
##### `R ! 1: AlgMat, RngIntElt -> AlgMatElt`

Create the identity matrix $I_n$ of the matrix algebra $R$.

<a id="operation-op-algmat-rngintelt-2"></a>
##### `R ! 0: AlgMat, RngIntElt -> AlgMatElt`

Create the zero matrix of the matrix algebra $R$.

<a id="operation-op-algmat-rngintelt-3"></a>
##### `R ! t: AlgMat, RngIntElt -> AlgMatElt`

Create the scalar matrix $t * I$ of the matrix algebra $R$.

#### Constructing a General Matrix Algebra

<a id="constructor-constructor-matrixalgebra-rng-rngintelt-list-algmat"></a>
##### `MatrixAlgebra<S, n | L>: Rng, RngIntElt, List -> AlgMat`

<a id="constructor-constructor-matrixring-rng-rngintelt-list-algmat"></a>
##### `MatrixRing<S, n | L>: Rng, RngIntElt, List -> AlgMat`

Given a commutative ring $S$ and a positive integer $n$, create the $S$-algebra $R$ consisting of the $n \times n$ matrices over the ring $S$ generated by the elements defined in the list $L$. Let $F$ denote the algebra $M_n(S)$. Each term $L_i$ of the list $L$ must be an expression defining an object of one of the following types:

**(a)**
A sequence of $n^2$ elements of $S$ defining an element of $F$.

**(b)**
A set or sequence whose terms are sequences of type (a).

**(c)**
An element of $F$.

**(d)**
A set or sequence whose terms are elements of $F$.

**(e)**
The null list.

The generators stored for $R$ consist of the elements specified by terms $L_i$ together with the stored generators for subalgebras specified by terms of $L_i$. Repetitions of an element and occurrences of scalar matrices are removed.

<a id="example-ex-0b78f0"></a>
##### `Example: Algebra of Lower-Triangular Matrices (ex-0b78f0)`

We demonstrate the use of the matrix algebra constructor by creating an algebra of $3 \times 3$ lower-triangular matrices over the rational field.

```magma
> Q := RationalField();
> A := MatrixAlgebra< Q, 3 | [ 1/3,0,0, 3/2,3,0, -1/2,4,3],
>        [ 3,0,0, 1/2,-5,0, 8,-1/2,4] >;
> A:Maximal;
Matrix Algebra of degree 3 with 2 generators over Rational Field
Generators:
[ 1/3    0    0]
[ 3/2    3    0]
[-1/2    4    3]

[   3    0    0]
[ 1/2   -5    0]
[   8 -1/2    4]
> Dimension(A);
6
```

<a id="example-ex-424fbd"></a>
##### `Example: Constructing a Cambridge Matrix (ex-424fbd)`

We construct a 4 by 4 matrix over the finite field with 5 elements using the CambridgeMatrix function.

```magma
> K := FiniteField(5);
> x := CambridgeMatrix(1, K, 4, [ "1234", "0111", "4321", "1211" ]);
> x;
[1 2 3 4]
[0 1 1 1]
[4 3 2 1]
[1 2 1 1]
```

<a id="function-algebra-algmatv"></a>
##### `Algebra(R): AlgMatV -> AlgGen, Map`

Given a matrix algebra $R$, construct a structure-constant algebra $C$ isomorphic to $R$ together with the isomorphism from $R$ onto $C$.

#### The Invariants of a Matrix Algebra

<a id="operation-operation-algmat-rngintelt-algmatelt"></a>
##### `R . i: AlgMat, RngIntElt -> AlgMatElt`

The $i$-th defining generator for the matrix algebra $R$.

<a id="function-basering-algmatv"></a>
##### `BaseRing(R): AlgMatV -> Rng`

<a id="function-coefficientring-algmatv"></a>
##### `CoefficientRing(R): AlgMatV -> Rng`

The coefficient ring $S$ for the matrix algebra $R$.

<a id="function-degree-algmatv"></a>
##### `Degree(R): AlgMatV -> RngIntElt`

Given a matrix algebra $R$, return the degree $n$ of $R$.

<a id="function-generators-algmat"></a>
##### `Generators(R): AlgMat -> { AlgMatElt}`

The set consisting of the defining generators for the matrix algebra $R$.

<a id="function-generic-algmat"></a>
##### `Generic(R): AlgMat -> AlgMat`

The complete matrix algebra $M_n(S)$ in which the matrix algebra $R$ is naturally embedded.

<a id="function-basemodule-algmatv"></a>
##### `BaseModule(R): AlgMatV -> ModTup`

If $R$ is a subring of the matrix algebra $M_n(S)$, then $R$ is considered to act on the free $S$-module of rank $n$, consisting of $n$-tuples over $S$. The function `BaseModule` returns this $S$-module.

<a id="function-numberofgenerators-algmat"></a>
##### `NumberOfGenerators(R): AlgMat -> { AlgMatElt}`

<a id="function-ngens-algmat"></a>
##### `Ngens(R): AlgMat -> { AlgMatElt}`

The number of defining generators for the matrix algebra $R$.

<a id="function-parent-algmatelt"></a>
##### `Parent(a): AlgMatElt -> AlgMat`

Given an element $a$ belonging to the matrix algebra $R$, return $R$, i.e. the parent structure for $a$.

<a id="example-ex-97af59"></a>
##### `Example: Invariants of a Lower-Triangular Algebra (ex-97af59)`

We illustrate the use of these functions by applying them to the algebra of $3 \times 3$ lower-triangular matrices over the rational field constructed above.

```magma
> Q := RationalField();
> A := MatrixAlgebra< Q, 3 | [ 1/3,0,0, 3/2,3,0, -1/2,4,3],
>        [ 3,0,0, 1/2,-5,0, 8,-1/2,4] >;
> CoefficientRing(A);
Rational Field
> Degree(A);
3
> Ngens(A);
2
> Generators(A);
{
    [ 1/3    0    0]
    [ 3/2    3    0]
    [-1/2    4    3],

    [   3    0    0]
    [ 1/2   -5    0]
    [   8 -1/2    4]
}
> Generic(A);
Full Matrix Algebra of degree 3 over Rational Field
> Dimension(A);
6
```

### Construction of Subalgebras, Ideals, and Quotient Rings

<a id="constructor-constructor-sub-algmat-list-algmat-hom-alg"></a>
#### `sub<R | L>: AlgMat, List -> AlgMat, Hom(Alg)`

Given the matrix algebra $R$, defined as a subring of $M_n(S)$, construct the subring $T$ of $R$ generated by the elements specified by the list $L$, where $L$ is a list of one or more items of the following types:

**(a)**
A sequence of $n^2$ elements of $S$ defining an element of $R$;

**(b)**
An element of $R$;

**(c)**
A set or sequence of elements of $R$;

**(d)**
A subring of $R$;

**(e)**
A set or sequence of subrings of $R$.

Each element or subalgebra specified by the list must belong to the *same* complete matrix algebra. The subalgebra $T$ will be constructed as a subalgebra of some matrix algebra which contains each of the elements and subalgebras specified in the list. The generators of $T$ consist of the elements specified by the terms of the list $L$ together with the stored generators for subalgebras specified by terms of the list. Repetitions of an element and occurrences of the identity element are removed (unless $T$ is trivial). The constructor returns the subalgebra $T$ and the inclusion homomorphism $f : T \rightarrow R$.

<a id="constructor-constructor-ideal-algmat-list-algmat"></a>
#### `ideal<R | L>: AlgMat, List -> AlgMat`

Given the matrix algebra $R$, construct the two-sided ideal $I$ of $R$ generated by the elements of $R$ specified by the list $L$, where the possibilities for $L$ are the same as for the `sub`-constructor.

<a id="constructor-constructor-lideal-algmat-list-algmat"></a>
#### `lideal<R | L>: AlgMat, List -> AlgMat`

Given the matrix algebra $R$, construct the left ideal $I$ of $R$ generated by the elements of $R$ specified by the list $L$, where the possibilities for $L$ are the same as for the `sub`-constructor.

<a id="constructor-constructor-rideal-algmat-list-algmat"></a>
#### `rideal<R | L>: AlgMat, List -> AlgMat`

Given the matrix algebra $R$, construct the right ideal $I$ of $R$ generated by the elements of $R$ specified in the list $L$, where the possibilities for $L$ are the same as for the `sub`-constructor.

<a id="example-ex-3c6faa"></a>
#### `Example: Subalgebra Generated by One Element (ex-3c6faa)`

We construct the subalgebra of the matrix algebra $A$ (defined above) that is generated by the first generator.

```magma
> Q := RationalField();
> A := MatrixAlgebra< Q, 3 | [ 1/3,0,0, 3/2,3,0, -1/2,4,3],
>        [ 3,0,0, 1/2,-5,0, 8,-1/2,4] >;
> B := sub< A | A.1 >;
> Dimension(B);
3
> B: Maximal;
Matrix Algebra of degree 3 and dimension 3 with 1 generator
over Rational Field
Generators:
[ 1/3    0    0]
[ 3/2    3    0]
[-1/2    4    3]

Basis:

[1 0 0]
[0 1 0]
[0 0 1]

[    0     0     0]
[    1  16/9     0]
[    0 88/27  16/9]

[   0    0    0]
[   0    0    0]
[   1 16/9    0]
```

### The Construction of Extensions and their Elements

#### The Construction of Direct Sums and Tensor Products

<a id="function-directsum-algmat-algmat"></a>
##### `DirectSum(R, T): AlgMat, AlgMat -> AlgMat`

Given two matrix algebras $R$ and $T$, where $R$ and $T$ have the same coefficient ring $S$, return the direct sum $D$ of $R$ and $T$ (with the action given by the direct sum of the action of $R$ and the action of $T$).

<a id="function-tensorproduct-algmat-algmat"></a>
##### `TensorProduct(A, B): AlgMat, AlgMat -> AlgMat`

Given two unital matrix algebras $A$ and $B$, where $A$ and $B$ have the same coefficient ring $S$, construct the tensor product of $A$ and $B$.

<a id="example-ex-548c90"></a>
##### `Example: Direct Sum and Tensor Product (ex-548c90)`

We construct the direct product and tensor product of the matrix algebra $A$ (defined above) with itself.

```magma
> Q := RationalField();
> A := MatrixAlgebra< Q, 3 | [ 1/3,0,0, 3/2,3,0, -1/2,4,3],
>        [ 3,0,0, 1/2,-5,0, 8,-1/2,4] >;
> AplusA := DirectSum(A, A);
> AplusA: Maximal;
Matrix Algebra of degree 6 with 4 generators over
    Rational Field
Generators:
[ 1/3    0    0    0    0    0]
[ 3/2    3    0    0    0    0]
[-1/2    4    3    0    0    0]
[   0    0    0    0    0    0]
[   0    0    0    0    0    0]
[   0    0    0    0    0    0]

[   3    0    0    0    0    0]
[ 1/2   -5    0    0    0    0]
[   8 -1/2    4    0    0    0]
[   0    0    0    0    0    0]
[   0    0    0    0    0    0]
[   0    0    0    0    0    0]

[   0    0    0    0    0    0]
[   0    0    0    0    0    0]
[   0    0    0    0    0    0]
[   0    0    0  1/3    0    0]
[   0    0    0  3/2    3    0]
[   0    0    0 -1/2    4    3]

[   0    0    0    0    0    0]
[   0    0    0    0    0    0]
[   0    0    0    0    0    0]
[   0    0    0    3    0    0]
[   0    0    0  1/2   -5    0]
[   0    0    0    8 -1/2    4]
> AtimesA := TensorProduct(A, A);
> AtimesA: Maximal;
Matrix Algebra of degree 9 with 4 generators over
    Rational Field
Generators:
[ 1/3    0    0    0    0    0    0    0    0]
[   0  1/3    0    0    0    0    0    0    0]
[   0    0  1/3    0    0    0    0    0    0]
[ 3/2    0    0    3    0    0    0    0    0]
[   0  3/2    0    0    3    0    0    0    0]
[   0    0  3/2    0    0    3    0    0    0]
[-1/2    0    0    4    0    0    3    0    0]
[   0 -1/2    0    0    4    0    0    3    0]
[   0    0 -1/2    0    0    4    0    0    3]

[   3    0    0    0    0    0    0    0    0]
[   0    3    0    0    0    0    0    0    0]
[   0    0    3    0    0    0    0    0    0]
[ 1/2    0    0   -5    0    0    0    0    0]
[   0  1/2    0    0   -5    0    0    0    0]
[   0    0  1/2    0    0   -5    0    0    0]
[   8    0    0 -1/2    0    0    4    0    0]
[   0    8    0    0 -1/2    0    0    4    0]
[   0    0    8    0    0 -1/2    0    0    4]

[ 1/3    0    0    0    0    0    0    0    0]
[ 3/2    3    0    0    0    0    0    0    0]
[-1/2    4    3    0    0    0    0    0    0]
[   0    0    0  1/3    0    0    0    0    0]
[   0    0    0  3/2    3    0    0    0    0]
[   0    0    0 -1/2    4    3    0    0    0]
[   0    0    0    0    0    0  1/3    0    0]
[   0    0    0    0    0    0  3/2    3    0]
[   0    0    0    0    0    0 -1/2    4    3]

[   3    0    0    0    0    0    0    0    0]
[ 1/2   -5    0    0    0    0    0    0    0]
[   8 -1/2    4    0    0    0    0    0    0]
[   0    0    0    3    0    0    0    0    0]
[   0    0    0  1/2   -5    0    0    0    0]
[   0    0    0    8 -1/2    4    0    0    0]
[   0    0    0    0    0    0    3    0    0]
[   0    0    0    0    0    0  1/2   -5    0]
[   0    0    0    0    0    0    8 -1/2    4]
```

#### Construction of Direct Sums and Tensor Products of Elements

<a id="function-directsum-algmatelt-algmatelt"></a>
##### `DirectSum(a, b): AlgMatElt, AlgMatElt -> AlgMatElt`

Given an element $a$ of the matrix algebra $Q$ and an element $b$ of the matrix algebra $R$, form the direct sum of matrices $a$ and $b$. The square is returned as an element of the matrix algebra $T$, which must be the direct sum of the parent of $a$ and the parent of $b$.

<a id="function-exteriorsquare-algmatelt"></a>
##### `ExteriorSquare(a): AlgMatElt -> AlgMatElt`

Given an element $a$ of the matrix algebra $M_n(S)$, form the exterior square of $a$ as an element of $M_m(S)$, where $m = n(n-1)/2$.

<a id="function-exteriorpower-algmat-rngintelt"></a>
##### `ExteriorPower(a, r): AlgMat, RngIntElt -> AlgMatElt`

Given an element $a$ of the matrix algebra $M_n(S)$, form the $r$th exterior power of $a$ as an element of $M_m(S)$, where $m = n\choose r$.

<a id="function-symmetricsquare-algmatelt"></a>
##### `SymmetricSquare(a): AlgMatElt -> AlgMatElt`

Given an element $a$ of the matrix algebra $M_n(S)$, form the symmetric square of $a$ as an element of $M_m(S)$, where $m = n(n+1)/2$.

<a id="function-symmetricpower-algmatelt-rngintelt"></a>
##### `SymmetricPower(a, r): AlgMatElt, RngIntElt -> AlgMatElt`

Given an element $a$ of the matrix algebra $M_n(S)$, form the $r$th symmetric power of $a$ as an element of $M_m(S)$, for the appropriate $m$.

<a id="function-tensorproduct-algmatelt-algmatelt"></a>
##### `TensorProduct(a, b): AlgMatElt, AlgMatElt -> AlgMatElt`

Given an element $a$ belonging to a subalgebra of $M_{n_1}(S)$ and an element $b$ belonging to a subalgebra of $M_{n_2}(S)$, construct the tensor product of $a$ and $b$ as an element of the matrix algebra $M_n(S)$, where $n = n_1 * n_2$.

### Operations on Matrix Algebras

<a id="function-centre-algmat"></a>
#### `Centre(A): AlgMat -> AlgMat`

Given a matrix algebra $A$ whose base ring is a field, return the centre of $A$.

<a id="function-centralizer-algmat-algmat"></a>
#### `Centralizer(A, S): AlgMat, AlgMat -> AlgMat`

<a id="function-centraliser-algmat-algmat"></a>
#### `Centraliser(A, S): AlgMat, AlgMat -> AlgMat`

Given a matrix algebra $A$ whose base ring is a field, together with a subalgebra $S$ of $A$ return the centralizer of $S$ in $A$.

### Changing Rings

<a id="function-changering-algmatv-rng"></a>
#### `ChangeRing(A, S): AlgMatV, Rng -> AlgMat, Map`

Given a matrix algebra $A$ with base ring $R$, together with a ring $S$, construct the matrix algebra $B$ with base ring $S$ obtained by coercing the components of elements of $A$ into $S$, together with the homomorphism from $A$ to $B$.

<a id="function-changering-algmatv-rng-map"></a>
#### `ChangeRing(A, S, f): AlgMatV, Rng, Map -> AlgMat, Map`

Given a matrix algebra $A$ with base ring $R$, together with a ring $S$ and a homomorphism $f: R \rightarrow S$, construct the matrix algebra $B$ with base ring $S$ obtained by mapping the components of elements of $R$ into $S$ by $f$, together with the homomorphism from $A$ to $B$.

<a id="constructor-constructor-hom-algmat-algmat-map-map"></a>
#### `hom< A -> B | f >: AlgMat, AlgMat, Map -> Map`

Given *full* matrix algebras $A$ and $B$, together with a homomorphism $f$ from the base ring $R$ of $A$ to the base ring $S$ of $B$, create the homomorphism from $A$ to $B$ which, given a matrix in $A$, applies $f$ to the entries of the matrix.

### Elementary Operations on Elements

#### Arithmetic

<a id="operation-op-plus-algmatelt-algmatelt"></a>
##### `a + b: AlgMatElt, AlgMatElt -> AlgMatElt`

Sum of the matrices $a$ and $b$, where $a$ and $b$ belong to a common matrix algebra $R$.

<a id="operation-op-plus-algmatelt-rngelt"></a>
##### `a + t: AlgMatElt, RngElt -> AlgMatElt`

<a id="operation-op-plus-algmatelt-rngelt-2"></a>
##### `t + a: AlgMatElt, RngElt -> AlgMatElt`

Sum of the matrix $a$ and the scalar matrix $t * I$.

<a id="operation-operation-algmatelt-algmatelt"></a>
##### `- a: AlgMatElt -> AlgMatElt`

Negation of the matrix $a$.

<a id="operation-op-minus-algmatelt-algmatelt"></a>
##### `a - b: AlgMatElt, AlgMatElt -> AlgMatElt`

Difference of the matrices $a$ and $b$, where $a$ and $b$ belong to the same matrix algebra $R$.

<a id="operation-op-minus-algmatelt-rngelt"></a>
##### `a - t: AlgMatElt, RngElt -> AlgMatElt`

<a id="operation-op-minus-algmatelt-rngelt-2"></a>
##### `t - a: AlgMatElt, RngElt -> AlgMatElt`

Difference of the matrix $a$ and the scalar matrix $t * I$.

<a id="operation-op-times-algmatelt-algmatelt"></a>
##### `a * b: AlgMatElt, AlgMatElt -> AlgMatElt`

Product of the matrices $a$ and $b$, where $a$ and $b$ belong to the same matrix algebra $R$.

<a id="operation-op-times-algmatelt-mtrx"></a>
##### `a * b: AlgMatElt, Mtrx -> Mtrx`

Given a matrix $a$ belonging to a subalgebra of $M_n(S)$ and an element $b$ of a submodule of ${\operatorname{Hom}}(R^{(n)}, R^{(m)})$, construct the product of $a$ and $b$ as an element of ${\operatorname{Hom}}(R^{(n)}, R^{(m)})$.

<a id="operation-op-times-mtrx-algmatelt"></a>
##### `a * b: Mtrx, AlgMatElt -> Mtrx`

Given a matrix $a$ belonging to a submodule of ${\operatorname{Hom}}(R^{(n)}, R^{(m)})$ and an element $b$ of a subalgebra of $M_m(S)$, construct the product of $a$ and $b$ as an element of ${\operatorname{Hom}}(R^{(n)}, R^{(m)})$.

<a id="operation-op-times-rngelt-algmatelt"></a>
##### `t * a: RngElt, AlgMatElt -> AlgMatElt`

<a id="operation-op-times-algmatelt-rngelt"></a>
##### `a * t: AlgMatElt, RngElt -> AlgMatElt`

Given an element $a$ of the matrix algebra $R$, and an element $t$ belonging to the coefficient ring $S$ of $R$, form their scalar product.

<a id="operation-op-times-modtuprngelt-algmatelt"></a>
##### `u * a: ModTupRngElt, AlgMatElt -> ModTupElt`

Given an element $u$ belonging to the $S$-module $S^{(n)}$ and an element $a$ belonging to a subalgebra of $M_n(S)$, form the element $u*a$ of $S^n$.

<a id="operation-op-pow-algmatelt-rngintelt"></a>
##### `a ^ n: AlgMatElt, RngIntElt -> AlgMatElt`

If $n$ is positive, form the $n$-th power of $a$; if $n$ is zero, form the identity matrix; if $n$ is negative, form the $(-n)$-th power of the inverse of $a$.

<a id="function-numberofcolumns-algmatelt"></a>
##### `NumberOfColumns(a): AlgMatElt -> RngIntElt`

<a id="function-ncols-algmatelt"></a>
##### `Ncols(a): AlgMatElt -> RngIntElt`

The number of columns in the matrix $a$.

<a id="function-numberofrows-algmatelt"></a>
##### `NumberOfRows(a): AlgMatElt -> RngIntElt`

<a id="function-nrows-algmatelt"></a>
##### `Nrows(a): AlgMatElt -> RngIntElt`

The number of rows in the matrix $a$.

#### Predicates

##### Comparison

<a id="operation-op-eq-algmatelt-algmatelt"></a>
###### `a eq b: AlgMatElt, AlgMatElt -> BoolElt`

Returns `true` if the matrix $a$ is equal to the matrix $b$, where $a$ and $b$ are elements of a common matrix algebra $R$.

<a id="operation-op-ne-algmatelt-algmatelt"></a>
###### `a ne b: AlgMatElt, AlgMatElt -> BoolElt`

Returns `true` if the matrix $a$ is not equal to the matrix $b$, where $a$ and $b$ are elements of a common matrix algebra $R$.

##### Properties of Elements

The functions given here test properties of matrices. See also the section in the Lattices chapter for a description of the function `IsPositiveDefinite` and related functions.

<a id="function-isdiagonal-algmatelt"></a>
###### `IsDiagonal(a): AlgMatElt -> BoolElt`

Returns `true` iff the element $a$ belonging to the matrix algebra $R$ is a diagonal matrix; i.e. the only non-zero entries are on the diagonal.

<a id="function-isminusone-algmatelt"></a>
###### `IsMinusOne(a): AlgMatElt -> BoolElt`

Returns `true` iff the element $a$ belonging to the matrix algebra $R$ is the negation of the identity element for $R$.

<a id="function-isone-algmatelt"></a>
###### `IsOne(a): AlgMatElt -> BoolElt`

Returns `true` iff the element $a$ belonging to the matrix algebra $R$ is the identity element for $R$.

<a id="function-isscalar-algmatelt"></a>
###### `IsScalar(a): AlgMatElt -> BoolElt`

Returns `true` iff the element $a$ belonging to the matrix algebra $R$ is a scalar matrix.

<a id="function-issymmetric-algmatelt"></a>
###### `IsSymmetric(a): AlgMatElt -> BoolElt`

Returns `true` iff the element $a$ belonging to the matrix algebra $R$ is a symmetric matrix; i.e. the transpose of $a$ equals $a$.

<a id="function-isunit-algmatelt"></a>
###### `IsUnit(a): AlgMatElt -> BoolElt`

Returns `true` iff the matrix $a$ belonging to the matrix algebra $R$ is a unit.

<a id="function-iszero-algmatelt"></a>
###### `IsZero(a): AlgMatElt -> BoolElt`

Returns `true` iff the element $a$ belonging to the matrix algebra $R$ is the zero element for $R$.

<a id="function-isnilpotent-algmatelt"></a>
###### `IsNilpotent(a): AlgMatElt -> BoolElt, RngIntElt`

Return `true` if some power of the matrix $a$ belonging to a matrix algebra is the zero of the matrix algebra. Also returns the minimum exponent $n$ such that $a^n = 0$.

<a id="function-isunipotent-algmatelt"></a>
###### `IsUnipotent(a): AlgMatElt -> BoolElt, RngIntElt`

Return `true` if the matrix $a$ belonging to a matrix algebra is the identity of that algebra plus a nilpotent matrix. Also returns the index of nilpotence of $a - I$.

<a id="function-rank-algmatelt"></a>
###### `Rank(a): AlgMatElt -> RngIntElt`

Return the rank of the element $a$ belonging to the matrix algebra $R$.

<a id="function-determinant-algmatelt"></a>
###### `Determinant(A): AlgMatElt -> RngElt`

```magma
MonteCarloLevel: RngIntElt                    Default: 0
Proof          : BoolElt                      Default: true
pAdic          : BoolElt                      Default: true
Divisor        : RngIntElt                    Default: 0
```

Given a square matrix $A$ over the ring $R$, return the determinant of $A$ as an element of $R$. $R$ may be any commutative ring. The determinant of the $0 \times 0$ matrix over $R$ is defined to be `R!1`. If the coefficient ring is the integer ring ${\mathbb{Z}}$ or the rational field ${\mathbb{Q}}$ then a modular algorithm based on that of Abbott et al. [[ABM99](https://docs.magma-maths.org/references.md#cite-abm-det)] is used, which first computes a divisor $d$ of the determinant $D$ using a fast $p$-adic nullspace computation, and then computes the quotient $D/d$ by computing the determinant $D$ modulo enough small primes to cover the Hadamard bound divided by $d$. This always yields a correct answer. If the parameter `MonteCarloLevel` is set to a small positive integer $s$, then a probabilistic Monte-Carlo modular technique is used. Rather than using sufficient primes to cover the Hadamard bound divided by the divisor $d$, this version of the algorithm terminates when the constructed residue remains constant for $s$ steps. The probability of this being wrong is non-zero but extremely small, even if $s$ is only 1 or 2. If the level is set to 0, then the normal deterministic algorithm is used. Setting the parameter `Proof` to `false` is equivalent to setting `MonteCarloLevel` to 2. If the coefficient ring is ${\mathbb{Z}}$ and the parameter `Divisor` is set to an integer $d$, then $d$ must be a known exact divisor of the determinant (the sign does not matter), and the algorithm may be sped up because of this knowledge.

<a id="function-trace-algmatelt"></a>
###### `Trace(a): AlgMatElt -> RngElt`

Given an element $a$ of a subalgebra of $M_n(S)$, return the trace of $a$ as an element of $S$.

<a id="function-transpose-algmatelt"></a>
###### `Transpose(a): AlgMatElt -> AlgMatElt`

Given an element $a$ of a subalgebra of $M_n(S)$, return the transpose of $a$ as an element of $M_n(S)$.

<a id="function-order-algmatelt"></a>
###### `Order(a): AlgMatElt -> RngIntElt`

Given an invertible matrix $a$ over any commutative ring, determine the order of $a$. If $a$ has infinite order, the function may become stuck indefinitely since it cannot prove such.

<a id="function-factoredorder-algmatelt"></a>
###### `FactoredOrder(a): AlgMatElt -> [ <RngIntElt, RngIntElt> ]`

Given an invertible matrix $a$ over a finite field, return the order of $a$ in factored form.

<a id="function-projectiveorder-algmatelt"></a>
###### `ProjectiveOrder(a): AlgMatElt -> RngIntElt`

Given an invertible matrix $a$ over a finite field, return the projective order $o$ of $a$ and a scalar $s$ such that $a^o = sI$.

<a id="function-factoredprojectiveorder-algmatelt"></a>
###### `FactoredProjectiveOrder(a): AlgMatElt -> [ <RngIntElt, RngIntElt> ]`

Given an invertible matrix $a$ over a finite field, return the projective order $o$ of $a$ in factored form and a scalar $s$ such that $a^o = sI$.

<a id="function-characteristicpolynomial-algmatelt"></a>
###### `CharacteristicPolynomial(a: parameters): AlgMatElt -> RngUPolElt`

```magma
Al   : MonStgElt                    Default: "Modular"
Proof: BoolElt                      Default: true
```

The characteristic polynomial of the element $a$ belonging to the algebra $M_n(R)$, where $R$ can be any commutative ring. The parameter `Al` may be used to specify the algorithm used. The algorithm `Modular` (the default) can be used for matrices over $Z$ and $Q$—in such a case the parameter `Proof` can also be used to suppress proof of correctness. The algorithm `Hessenberg`, allowed for matrices over fields, works by first reducing the matrix to Hessenberg form. The algorithm `Interpolation`, allowed for matrices over $Z$ and $Q$, works by evaluating the characteristic matrix of $a$ at various points and then interpolating. The algorithm `Trace`, allowed for matrices over fields, works by calculating the traces of powers of $a$.

<a id="function-minimalpolynomial-algmatelt"></a>
###### `MinimalPolynomial(a): AlgMatElt -> RngUPolElt`

The minimal polynomial of the element $a$ belonging to the module $M_n(R)$, where $R$ is a field or $Z$.

<a id="function-hessenbergform-algmatelt"></a>
###### `HessenbergForm(a): AlgMatElt -> AlgMatElt`

The Hessenberg form for the matrix $a$ belonging to the algebra $M_n(K)$, where the coefficient ring $K$ must be a field. The form has zero entries above the super-diagonal. (This form is used in one of the characteristic polynomial algorithms.)

<a id="function-adjoint-algmatelt"></a>
###### `Adjoint(a): AlgMatElt -> AlgMatElt`

The adjoint of the matrix $a$ belonging to the algebra $M_n(K)$, where the coefficient ring $K$ must be a ring with exact division whose characteristic must be zero or greater than the degree of $a$.

<a id="function-eigenvalues-algmatelt"></a>
###### `Eigenvalues(a): AlgMatElt -> { <FldElt, RngIntElt> }`

The eigenvalues of the matrix $a$ returned as a set of pairs, each of which gives the value of a distinct eigenvalue and its multiplicity. The coefficient ring must have a polynomial roots algorithm.

<a id="function-eigenspace-algmatelt-fldelt"></a>
###### `Eigenspace(a, e): AlgMatElt, FldElt -> ModTup`

The eigenspace of the matrix $a$, corresponding to the eigenvalue $e$, returned as a submodule of the base module for the parent algebra of $a$ (i.e. the kernel of $a-eI$). If the ring element $e$ is not a eigenvalue for the matrix $a$ then the trivial space is returned.

<a id="elements-of-m-n-as-homomorphisms"></a>
### Elements of $M_n$ as Homomorphisms

The matrix algebra $M_n(S)$ may also be viewed as the module ${\operatorname{Hom}}(S^{(n)}, S^{(n)})$. At present this will not happen automatically so that in order to treat elements of $M_n(S)$ as homomorphisms, it is necessary to explicitly coerce the matrix into ${\operatorname{Hom}}(S^{(n)}, S^{(n)})$. However, two fundamental homomorphism-type operators are provided for elements of $M_n(S)$.

<a id="function-image-algmatelt"></a>
#### `Image(a): AlgMatElt -> ModTup`

<a id="function-rowspace-algmatelt"></a>
#### `RowSpace(a): AlgMatElt -> ModTup`

Given an element of $M_n(S)$, return the image of the module $S^{(n)}$ under the homomorphism represented by the matrix $a$ (as an element of $S^{(n)}$).

<a id="function-kernel-algmatelt"></a>
#### `Kernel(a): AlgMatElt -> ModTup`

<a id="function-nullspace-algmatelt"></a>
#### `NullSpace(a): AlgMatElt -> ModTup`

```magma
Al: MonStgElt                    Default: "Default"
```

Given an element of $M_n(S)$, return the kernel of the homomorphism represented by the matrix $a$ (as an element of $S^{(n)}$).

<a id="function-rownullspace-algmatelt"></a>
#### `RowNullSpace(a): AlgMatElt -> ModTup`

<a id="function-nullspaceoftranspose-algmatvelt"></a>
#### `NullspaceOfTranspose(a): AlgMatVElt -> ModTupRng`

Given an element of $M_n(S)$, return the row nullspace of the homomorphism represented by the matrix $a$ (as an element of $S^{(n)}$). This is equal to the kernel of the transpose of $a$.

<a id="function-restrict-algmatelt-modtuprng"></a>
#### `Restrict(a, V): AlgMatElt, ModTupRng -> AlgMatElt`

<a id="function-restrict-algmatelt-modtupfld"></a>
#### `Restrict(a, V): AlgMatElt, ModTupFld -> AlgMatElt`

If $V \simeq S^{(m)}$ is a free submodule of $S^{(n)}$ stable by an element $a$ of $M_n(S)$, returns the restriction of the homomorphism $a$ to the stable submodule $V$, as an element of $M_m(S)$.

### Elementary Operations on Subalgebras and Ideals

#### Bases

The functions described here assume that the matrix algebra $R$ is defined over a ring $S$ with a matrix echelonization algorithm. Magma computes a basis for $R$ considered as a $S$-module when necessary so then operations like membership testing can be performed. The following functions allow one to access this basis.

<a id="function-dimension-algmatv"></a>
##### `Dimension(R): AlgMatV -> RngIntElt`

Assuming that $R$ is a subalgebra of $M_n(S)$, return the dimension of $R$, considered as a $S$-module.

<a id="function-basis-algmatv"></a>
##### `Basis(R): AlgMatV -> [ AlgMatElt ]`

Assuming that $R$ is a subalgebra of $M_n(S)$, return the $S$-basis of $R$, considered as a $S$-module. The basis is returned as a sequence of matrices of $R$.

<a id="function-basiselement-algmatv-rngintelt"></a>
##### `BasisElement(R, i): AlgMatV, RngIntElt -> AlgMatElt`

Given $R$ a subalgebra of $M_n(S)$, return the $i$-th element of the $S$-basis of $R$, where $i$ must be between 1 and the dimension of $R$.

<a id="function-coordinates-algmatv-algmatvelt"></a>
##### `Coordinates(R, X): AlgMatV, AlgMatVElt -> [ RngElt ]`

Assuming that $R$ is a subalgebra of $M_n(S)$, and given an element $X$ of $R$, return the coordinates of $X$ with respect to the basis of $R$. If $R$ has dimension $k$ over its coefficient ring $S$, and $R$ has basis $U_1, \ldots, U_k$, the coordinates are returned as the unique sequence $[a_1, \ldots, a_k]$ of elements of $S$ such that $X = a_1 U_1 + \ldots + a_r U_r$.

#### Intersection of Subalgebras

<a id="operation-op-meet-algmat-algmat"></a>
##### `R meet T: AlgMat, AlgMat -> AlgMat`

Given algebras $R$ and $S$ that are subalgebras of the same complete algebra $M_n(S)$, where $S$ is a PIR, this operator constructs their intersection.

#### Membership and Equality

The operations described here assume that the matrix algebra is defined over a principal ideal ring.

<a id="operation-op-in-algmatelt-algmat"></a>
##### `x in R: AlgMatElt, AlgMat -> BoolElt`

<a id="operation-op-subset-algmatelt-algmat"></a>
##### `X subset R: { AlgMatElt}, AlgMat -> BoolElt`

<a id="operation-op-subset-algmat-algmat"></a>
##### `T subset R: AlgMat, AlgMat -> BoolElt`

Given a matrix $x$ (set of matrices $X$, matrix algebra $T$) and a matrix algebra $R$ all belonging to a common matrix algebra defined over a PIR, return `true` if $x$ ($X$, $T$, respectively) is contained in $R$, `false` otherwise.

<a id="operation-op-notin-algmatelt-algmat"></a>
##### `x notin R: AlgMatElt, AlgMat -> BoolElt`

<a id="operation-operation-notsubset-algmatelt-algmat-boolelt"></a>
##### `X notsubset R: { AlgMatElt}, AlgMat -> BoolElt`

<a id="operation-operation-notsubset-algmat-algmat-boolelt"></a>
##### `T notsubset R: AlgMat, AlgMat -> BoolElt`

Given a matrix $x$ (set of matrices $X$, matrix algebra $T$) and a matrix algebra $R$ all belonging to a common matrix algebra defined over a PIR, return `true` if $x$ ($X$, $T$, respectively) is not contained in $R$, `false` otherwise.

<a id="operation-op-eq-algmat-algmat"></a>
##### `R eq T: AlgMat, AlgMat -> BoolElt`

Given a matrix algebra $R$, and a matrix algebra $T$, return `true` if $R$ is equal to $T$, `false` otherwise.

<a id="operation-op-ne-algmat-algmat"></a>
##### `R ne T: AlgMat, AlgMat -> BoolElt`

Given a matrix algebra $R$ and a matrix algebra $T$, return `true` if $R$ is not equal to $T$, `false` otherwise.

### Accessing and Modifying a Matrix

#### Indexing

<a id="indexed-indexed-a-algmatelt-rngintelt-modtupelt"></a>
##### `a[i]: AlgMatElt, RngIntElt -> ModTupElt`

Given an element $a$ belonging to the matrix algebra $R$ over the ring $S$, return the $i$-th row of $a$ as an element of the natural $S$-module associated with $R$.

<a id="literal-literal-a-i-u-algmatelt-rngintelt-rngelt-algmatelt"></a>
##### `a[i] := u: AlgMatElt, RngIntElt, RngElt -> AlgMatElt`

Given an element $a$ belonging to the matrix algebra $R$ over the ring $S$, an integer $i$ in the range $[1, n]$ and an element $u$ of the natural $S$-module associated with $R$, replace the $i$-th row of $a$ by the vector $u$.

<a id="indexed-indexed-a-algmatelt-rngintelt-rngintelt-rngelt"></a>
##### `a[i, j]: AlgMatElt, RngIntElt, RngIntElt -> RngElt`

Given an element $a$ belonging to the matrix algebra $R$ over the ring $S$, return the $(i,j)$-th entry of $a$ as an element of $S$.

<a id="literal-literal-a-i-j-t-algmatelt-rngintelt-rngintelt-rngelt-algmatelt"></a>
##### `a[i, j] := t: AlgMatElt, RngIntElt, RngIntElt, RngElt -> AlgMatElt`

Given an element $a$ belonging to the matrix algebra $R$ over the ring $S$, integers $i$ and $j$ in the range $[1, n]$, and an element $t$ of $S$, replace the $(i,j)$-th entry of $a$ by $t$.

<a id="function-elementtosequence-algmatelt"></a>
##### `ElementToSequence(a): AlgMatElt -> [ RngElt ]`

<a id="function-eltseq-algmatelt"></a>
##### `Eltseq(a): AlgMatElt -> [ RngElt ]`

Given an element $a$ of the matrix algebra $R$ over $S$, where $a = (a_{ij})$, $1 \leq i$, $j \leq n$, return $a$ as the sequence of elements of $S$:

$$
[a_{11}, \ldots, a_{1n}, a_{21},\ldots, a_{2n}, \ldots, a_{n1},\ldots, a_{nn}].
$$

#### Extracting and Inserting Blocks

<a id="function-submatrix-mtrx-rngintelt-rngintelt-rngintelt-rngintelt"></a>
##### `Submatrix(a, i, j, p, q): Mtrx, RngIntElt, RngIntElt, RngIntElt, RngIntElt -> Mtrx`

<a id="function-extractblock-mtrx-rngintelt-rngintelt-rngintelt-rngintelt"></a>
##### `ExtractBlock(a, i, j, p, q): Mtrx, RngIntElt, RngIntElt, RngIntElt, RngIntElt -> Mtrx`

Given a matrix $a$ belonging to a subalgebra of $M_n(S)$ and integers $i$, $j$, $p$, and $q$ satisfying the conditions, $1 \le i + p \le m$, $1 \le j + q \le n$, create the matrix $b$ consisting of the $p\times q$ submatrix of $a$ whose first entry is the $(i,j)$-th entry of $a$. If $p \ne q$, the matrix $b$ is created as an element of $\Hom(P, Q)$, where [`Rank`](https://docs.magma-maths.org/search.html?q=Rank&show=intrinsics&match=exact)$(P) = p$, [`Rank`](https://docs.magma-maths.org/search.html?q=Rank&show=intrinsics&match=exact)$(Q) = q$. Otherwise it is created as an element of $M_p(S)$.

<a id="function-insertblock-mtrx-mtrx-rngintelt-rngintelt-ref"></a>
##### `InsertBlock(~a, b, i, j): Mtrx, Mtrx, RngIntElt, RngIntElt -> Mtrx`

(Procedure.) Given that the matrix $a$ belongs to a subalgebra of $M_n(S)$ and the $p\times q$ matrix $b$ is also over $S$, the integers $i$, $j$, $p$, and $q$ must satisfy the conditions, $1 \le i + p \le m$, $1 \le j + q \le n$. This procedure modifies $a$ so that the $p\times q$ block beginning at the $(i,j)$-th entry of $a$ is replaced by $b$.

#### Joining Matrices

<a id="function-horizontaljoin-mtrx-mtrx"></a>
##### `HorizontalJoin(X, Y): Mtrx, Mtrx -> Mtrx`

Given matrices $X$ with $r$ rows and $c$ columns, and $Y$ with $r$ rows and $d$ columns, both over the same coefficient ring $R$, return the matrix over $R$ with $r$ rows and $(c+d)$ columns obtained by joining $X$ and $Y$ horizontally (placing $Y$ to the right of $X$).

<a id="function-horizontaljoin-modmatrngelt"></a>
##### `HorizontalJoin(Q): [ ModMatRngElt ] -> ModMatRngElt`

Given a sequence $Q$ of matrices, each having the same number of rows and being over the same coefficient ring $R$, return the matrix over $R$ obtained by joining the elements of $Q$ horizontally in order.

<a id="function-verticaljoin-modmatrngelt-modmatrngelt"></a>
##### `VerticalJoin(X, Y): ModMatRngElt, ModMatRngElt -> ModMatRngElt`

Given matrices $X$ with $r$ rows and $c$ columns and $Y$ with $s$ rows and $c$ columns, both over the same coefficient ring $R$, return the matrix with $(r+s)$ rows and $c$ columns over $R$ obtained by joining $X$ and $Y$ vertically (placing $Y$ underneath $X$).

<a id="function-verticaljoin-modmatrngelt"></a>
##### `VerticalJoin(Q): [ ModMatRngElt ] -> ModMatRngElt`

Given a sequence $Q$ of matrices, each having the same number of columns and being over the same coefficient ring $R$, return the matrix over $R$ obtained by joining the elements of $Q$ vertically in order.

<a id="function-diagonaljoin-modmatrngelt-modmatrngelt"></a>
##### `DiagonalJoin(X, Y): ModMatRngElt, ModMatRngElt -> ModMatRngElt`

Given matrices $X$ with $a$ rows and $b$ columns and $Y$ with $c$ rows and $d$ columns, both over the same coefficient ring $R$, return the matrix with $(a+c)$ rows and $(b+d)$ columns over $R$ obtained by joining $X$ and $Y$ diagonally (placing $Y$ diagonally to the right of and underneath $X$, with zero blocks above and below the diagonal).

<a id="function-diagonaljoin-modmatrngelt"></a>
##### `DiagonalJoin(Q): [ ModMatRngElt ] -> ModMatRngElt`

Given a sequence $Q$ of matrices, each being over the same coefficient ring $R$, return the matrix over $R$ obtained by joining the elements of $Q$ diagonally in order.

#### Row and Column Operations

For the following operations, $a$ is an element of a subring of the matrix algebra $M_n(S)$, $u$ is a non-zero element of $S$, and $i$ and $j$ are integers in the range $[1, n]$. Each of the operations described here acts on the matrix in place, and is therefore implemented as a procedure.

<a id="procedure-swaprows-algmatelt-rngintelt-rngintelt-ref"></a>
##### `SwapRows(~a, i, j): AlgMatElt, RngIntElt, RngIntElt`

Mutate the matrix $a$ by interchanging rows $i$ and $j$.

<a id="procedure-multiplyrow-algmatelt-rngelt-rngintelt-ref"></a>
##### `MultiplyRow(~a, u, j): AlgMatElt, RngElt, RngIntElt`

Mutate the matrix $a$ by multiplying row $j$ by the scalar $u$.

<a id="procedure-addrow-algmatelt-rngelt-rngintelt-rngintelt-ref"></a>
##### `AddRow(~a, u, i, j): AlgMatElt, RngElt, RngIntElt, RngIntElt`

Mutate the matrix $a$ by adding $u$ times row $i$ to row $j$.

<a id="procedure-swapcolumns-algmatelt-rngintelt-rngintelt-ref"></a>
##### `SwapColumns(~a, i, j): AlgMatElt, RngIntElt, RngIntElt`

Mutate the matrix $a$ by interchanging columns $i$ and $j$.

<a id="procedure-multiplycolumn-algmatelt-rngelt-rngintelt-ref"></a>
##### `MultiplyColumn(~a, u, i): AlgMatElt, RngElt, RngIntElt`

Mutate the matrix $a$ by multiplying column $i$ by the scalar $u$.

<a id="procedure-addcolumn-algmatelt-rngelt-rngintelt-rngintelt-ref"></a>
##### `AddColumn(~a, u, i, j): AlgMatElt, RngElt, RngIntElt, RngIntElt`

Mutate the matrix $a$ by adding $u$ times column $i$ to column $j$.

### Canonical Forms

#### Canonical Forms for Matrices over Euclidean Domains

The functions given here apply to matrices defined over Euclidean Domains. See also the section on Reduction in the Lattices chapter for a description of the function `LLL` and related functions.

<a id="function-echelonform-algmatelt"></a>
##### `EchelonForm(a): AlgMatElt -> AlgMatElt, AlgMatElt`

The (row) echelon form of matrix $a$ belonging to a submodule of the module $M_n(S)$. This function returns two values:

**(a)**
The (row) echelon form $e$ of $a$; and

**(b)**
A matrix $b$ such that $b*a = e$, i.e. $b$ is a product of elementary matrices that transforms $a$ into echelon form.

<a id="function-elementarydivisors-algmatelt"></a>
##### `ElementaryDivisors(a): AlgMatElt -> [RngElt]`

The elementary divisors of the matrix $a$ belonging to a submodule of the module $M_n(S)$. The divisors are returned as a sequence $[e_1, \ldots, e_d]$, $e_i | e_{i+1}$ ($i=1 , \ldots, d-1$) of $d$ elements of $R$ (which may include ones), where $d$ is the rank of $a$. If $R$ is a field, the result is always the sequence of $r$ ones, where $r$ is the rank of $a$.

<a id="function-hermiteform-algmatelt"></a>
##### `HermiteForm(X): AlgMatElt -> AlgMatElt, AlgMatElt`

```magma
Al      : MonStg                     Default: "LLL"
Optimize: BoolElt                    Default: true
Integral: BoolElt                    Default: true
```

The row Hermite normal form of a matrix $X$ belonging to the matrix algebra $M_n(R)$. The coefficient ring $R$ must be an Euclidean domain. This function returns two values:

**(a)**
The Hermite normal form $H$ of $X$; and

**(b)**
A unimodular matrix $T$ such that $T\cdot X = H$, i.e., $T$ is the product of elementary matrices which transforms $X$ into Hermite normal form.

If $R$ is the ring of integers ${\mathbb{Z}}$ and the matrix $T$ is requested (i.e., if an assignment statement is used with two variables on the left side), then the LLL algorithm will be used by default to improve $T$ (using the kernel of $X$) so that the size of its entries are very small. If the parameter `Optimize` is set to $\texttt{false}$, then this will not happen (which will be faster but the entries of $T$ will not be as small). If the parameter `Integral` is set to $\texttt{true}$, then the integral (de Weger) LLL method will be used in the LLL step, instead of the default floating point method. The integral method will often be faster if the rank of the kernel of $X$ is very large (say 200 or more). If $R$ is the ring of integers ${\mathbb{Z}}$ and the parameter `Al` is set to the string `"Sort"`, then the sorting-gcd algorithm will be used. However, the new algorithm will practically always perform better than the sorting-gcd algorithm.

<a id="function-smithform-algmatelt"></a>
##### `SmithForm(a): AlgMatElt -> AlgMatElt, AlgMatElt, AlgMatElt`

The Smith normal form for the matrix $a$ belonging to a submodule of the module $M_n(S)$, where $S$ is a Euclidean Domain. This function returns three values:

**(a)**
The Smith normal form $s$ of $a$; and

**(b)**
Unimodular matrices $b$ and $c$ such that $b*a*c = s$, i.e. $b$ and $c$ are matrices that transform $a$ into Smith normal form.

<a id="example-ex-e0346c"></a>
##### `Example: Echelon Form (ex-e0346c)`

We illustrate some of these operations in the context of the algebra $M_4(K)$, where $K$ is the field ${\bf F}_{8}$.

```magma
> K<w> := FiniteField(8);
> M := MatrixAlgebra(K, 4);
> A := M ! [1, w, w^5, 0,  w^3, w^4, w, 1,  w^6, w^3, 1, w^4, 1, w, 1, w ];
> A;
[  1   w w^5   0]
[w^3 w^4   w   1]
[w^6 w^3   1 w^4]
[  1   w   1   w]
> EchelonForm(A);
[1 0 0 0]
[0 1 0 0]
[0 0 1 0]
[0 0 0 1]
```

#### Canonical Forms for Matrices over a Field

The functions in this group apply to elements of matrix algebras whose coefficient rings are fields which allow factorization of univariate polynomials over them.

<a id="function-primaryrationalform-algmatelt"></a>
##### `PrimaryRationalForm(a): AlgMatElt -> AlgMatElt, AlgMatElt, [ <RngUPolElt, RngIntElt ]`

The primary rational canonical form of a matrix $a$ belonging to $M_n(K)$, where the coefficient ring $K$ must be a field allowing factorization of univariate polynomials over it. Each block corresponds to a power of an irreducible polynomial. This function returns three values:

**(a)**
The primary rational canonical form $p$ of $a$;

**(b)**
A non-singular matrix $t$ such that $t*a*t^{-1} = p$;

**(c)**
A sequence of pairs corresponding to the blocks of $p$ where each pair consists of the irreducible polynomial and multiplicity making up the block.

<a id="function-jordanform-algmatelt"></a>
##### `JordanForm(a): AlgMatElt -> AlgMatElt, AlgMatElt, [ <RngUPolElt, RngIntElt ]`

The (generalized) Jordan canonical form for the matrix $a$ belonging to the algebra $M_n(K)$, where the coefficient ring $K$ must be a field allowing factorization of univariate polynomials over it. This function returns three values:

**(a)**
The (generalized) Jordan canonical form $j$ of $a$;

**(b)**
A non-singular matrix $t$ such that $t*a*t^{-1}= j$;

**(c)**
A sequence of pairs corresponding to the blocks of $j$ where each pair consists of the irreducible polynomial and multiplicity making up the block.

<a id="function-rationalform-algmatelt"></a>
##### `RationalForm(a): AlgMatElt -> AlgMatElt, AlgMatElt, [ RngUPolElt ]`

The rational canonical form of a matrix $a$ belonging to $M_n(K)$, where the coefficient ring $K$ must be a field allowing factorization of univariate polynomials over it. For each block before the last block, the polynomial corresponding to that block divides the polynomial corresponding to the next block. This function returns three values:

**(a)**
The rational canonical form $f$ of $a$;

**(b)**
A non-singular matrix $t$ such that $t*a*t^{-1} = f$;

**(c)**
A sequence containing the polynomials corresponding to each block (each non-last one dividing the next).

<a id="function-primaryinvariantfactors-algmatelt"></a>
##### `PrimaryInvariantFactors(a): AlgMatElt -> [ <RngUPolElt, RngIntElt ]`

The primary invariant factors of the matrix $a$. This is the same as the third return value of `PrimaryRationalForm(a)` or `JordanForm(a)`. The coefficient ring must be a field allowing factorization of univariate polynomials over it.

<a id="function-invariantfactors-algmatelt"></a>
##### `InvariantFactors(a): AlgMatElt -> [ AlgPolElt ]`

The invariant factors of the matrix $a$. This is the same as the third return value of `RationalForm(a)`. The coefficient ring must be a field allowing factorization of univariate polynomials over it.

<a id="function-issimilar-algmatelt-algmatelt"></a>
##### `IsSimilar(a, b): AlgMatElt, AlgMatElt -> BoolElt, AlgMatElt`

Returns `true` iff the matrix $a$ is similar to the matrix $b$. If $a$ is similar to $b$, a transformation matrix $t$ is also returned with $t*a*t^{-1}=b$. The coefficient ring must be a field allowing factorization of univariate polynomials over it.

<a id="example-ex-29de54"></a>
##### `Example: Elementary Divisors (ex-29de54)`

We consider the algebra $M_5(P)$, where $P$ is the polynomial ring in indeterminate $x$ over the field ${\bf F}_{5}$. We take the matrix having $x^i + x^j$ in its $(i, j)$-th position.

```magma
> K := GaloisField(5);
> P<x> := PolynomialAlgebra(K);
> M := MatrixAlgebra(P, 5);
> a := M ! [x^i + x^j: i, j in [1..5]];
> a;
[      2*x   x^2 + x   x^3 + x   x^4 + x   x^5 + x]
[  x^2 + x     2*x^2 x^3 + x^2 x^4 + x^2 x^5 + x^2]
[  x^3 + x x^3 + x^2     2*x^3 x^4 + x^3 x^5 + x^3]
[  x^4 + x x^4 + x^2 x^4 + x^3     2*x^4 x^5 + x^4]
[  x^5 + x x^5 + x^2 x^5 + x^3 x^5 + x^4     2*x^5]
> ElementaryDivisors(a);
[
    x,
    x^3 + 3*x^2 + x
]
> Rank(a);
2
```

<a id="example-ex-a68b91"></a>
##### `Example: Canonical Forms over a Finite Field (ex-a68b91)`

We construct a 5 by 5 matrix over the finite field with 5 elements and then calculate various canonical forms. We verify the correctness of the polynomial invariant factors corresponding to the rational form by calculating the Smith form of the characteristic matrix of the original matrix.

```magma
> K := GF(5);
> P<x> := PolynomialRing(K);
> A := MatrixAlgebra(K, 5);
> a := A !
> [
>     0, 2, 4, 2, 0,
>     2, 2, 2, 3, 3,
>     3, 4, 4, 1, 3,
>     0, 0, 0, 0, 1,
>     0, 0, 0, 1, 0
> ];
> a;
[0 2 4 2 0]
[2 2 2 3 3]
[3 4 4 1 3]
[0 0 0 0 1]
[0 0 0 1 0]
> PrimaryInvariantFactors(a);
[
    <x + 1, 1>,
    <x + 1, 1>,
    <x + 4, 1>,
    <x + 4, 1>,
    <x + 4, 1>
]
> r, t, f := RationalForm(a);
> r;
[1 0 0 0 0]
[0 0 1 0 0]
[0 1 0 0 0]
[0 0 0 0 1]
[0 0 0 1 0]
> t;
[1 3 0 2 1]
[2 1 2 2 0]
[3 4 3 4 1]
[1 0 0 0 0]
[0 2 4 2 0]
> f;
[
    x + 4,
    x^2 + 4,
    x^2 + 4
]
> PA := MatrixAlgebra(P, 5);
> ax := PA ! x - PA ! a;
> ax;
[    x     3     1     3     0]
[    3 x + 3     3     2     2]
[    2     1 x + 1     4     2]
[    0     0     0     x     4]
[    0     0     0     4     x]
> SmithForm(ax);
[      1       0       0       0       0]
[      0       1       0       0       0]
[      0       0   x + 4       0       0]
[      0       0       0 x^2 + 4       0]
[      0       0       0       0 x^2 + 4]
> ElementaryDivisors(ax);
[
    1,
    1,
    x + 4,
    x^2 + 4,
    x^2 + 4
]
```

### Diagonalising Commutative Algebras over a Field

The functions in this group apply to (elements of) matrix algebras whose coefficient rings are fields which allow the construction of splitting fields of univariate polynomials over them. Specifically, the base field must be the rationals, a number field, a finite field, or an algebraically closed field.

<a id="function-commoneigenspaces-algmatelt"></a>
#### `CommonEigenspaces(Q): [AlgMatElt] -> [**], [[FldElt]]`

```magma
Check: BoolElt                      Default: true
U    : ModTupFld                    Default: [ ]
```

For a sequence $Q$ of commuting matrices over a field, return a list $S$ of subspaces of `U` and a sequence $E$ of eigenvalues such that $Q[j]$ acts on $S[i]$ as scalar multiplication by $E[i][j]$. If the parameter $U$ is not provided, it defaults to the base module of the universe of $Q$.

By default the matrices are checked to ensure that they commute. If the parameter `Check` is `false`, this test is skipped.

<a id="function-commoneigenspaces-algmat"></a>
#### `CommonEigenspaces(A): AlgMat -> [**], [[FldElt]]`

For a commutative algebra $A$, return a list $S$ of eigenspaces and a sequence $E$ of eigenvalues such that $A.j$ acts on $S[i]$ as scalar multiplication by $E[i][j]$.

<a id="function-isetale-algmat"></a>
#### `IsEtale(A): AlgMat -> BoolElt, AlgMatElt`

A $k$-algebra $A$ is étale ([[Bou03](https://docs.magma-maths.org/references.md#cite-bourbaki-algebra-ii)], II Chap V §6 No. 3) if there is a finite extension of the field $k$ that diagonalises $A$.

If $A$ is an étale algebra, return `true` and a matrix $L$ such that $LML^{-1}$ is diagonal for all $M\in A$; otherwise return `false`.

<a id="function-diagonalisation-algmatelt"></a>
#### `Diagonalisation(Q): [AlgMatElt] -> [AlgMatElt], AlgMatElt`

<a id="function-diagonalization-algmatelt"></a>
#### `Diagonalization(Q): [AlgMatElt] -> [AlgMatElt], AlgMatElt`

The diagonalisation of the sequence $Q$ of pairwise-commuting matrices. That is, a sequence of diagonal matrices of the form $[P*Q[1]*P^{-1},P*Q[2]*P^{-1},\dots]$. The second value returned is the matrix $P$. Note that the returned values may have a larger base field than the input.

<a id="function-diagonalisation-algmat"></a>
#### `Diagonalisation(A): AlgMat -> AlgMat, AlgMatElt`

<a id="function-diagonalization-algmat"></a>
#### `Diagonalization(A): AlgMat -> AlgMat, AlgMatElt`

The diagonalisation of the commutative matrix algebra $A$. That is, an algebra with diagonal generators $[P*A.1*P^{-1},P*A.2*P^{-1},\dots]$. The second value returned is the matrix $P$.

<a id="function-diagonalisation-algmatelt-2"></a>
#### `Diagonalisation(M): AlgMatElt -> AlgMatElt, AlgMatElt`

<a id="function-diagonalization-algmatelt-2"></a>
#### `Diagonalization(M): AlgMatElt -> AlgMatElt, AlgMatElt`

```magma
ExtendField: Boolelt                    Default: false
```

The diagonalisation of the matrix $M$. That is, a diagonal matrix $D$ and a matrix $L$ such that $LML^{-1} = D$. By default the diagonalisation is carried out over the base field. If the parameter `ExtendField` is `true`, the diagonalisation is over the splitting field of the characteristic polynomial of $M$.

<a id="function-isdiagonalisable-algmatelt"></a>
#### `IsDiagonalisable(M): AlgMatElt -> Boolelt, AlgMatElt, AlgMatElt`

<a id="function-isdiagonalizable-algmatelt"></a>
#### `IsDiagonalizable(M): AlgMatElt -> Boolelt, AlgMatElt, AlgMatElt`

```magma
ExtendField: Boolelt                    Default: false
```

If $M$ is diagonalisable, return `true`, a diagonal matrix $D$, and an invertible matrix $T$ such that $TMT^{-1} = M$; otherwise return `false`. If the parameter `ExtendField` is `true`, diagonalisation of $M$ will be checked over the splitting field of the characteristic polynomial of $M$.

<a id="example-ex-b2afd3"></a>
#### `Example: Common Eigenspaces of Commuting Matrices (ex-b2afd3)`

```magma
> M := MatrixAlgebra(Rationals(),2);
> x := M![0,1,-2,0];
> y := M![0,3,-6,0];
> CommonEigenspaces([x,y]);
[*
    Vector space of degree 2, dimension 1 over Number Field with defining
    polynomial $.1^2 + 2 over the Rational Field
    Generators:
    (      1 1/2*r.1)
    Echelonized basis:
    (      1 1/2*r.1),

    Vector space of degree 2, dimension 1 over Number Field with defining
    polynomial $.1^2 + 2 over the Rational Field
    Generators:
    (       1 -1/2*r.1)
    Echelonized basis:
    (       1 -1/2*r.1)
*] [
    [
        -r.1,
        -3*r.1
    ],
    [
        r.1,
        3*r.1
    ]
]
> Diagonalisation(sub<M|x,y>);
Matrix Algebra of degree 2 with 2 generators over Number Field with defining
polynomial $.1^2 + 2 over the Rational Field

[       1  1/2*r.1]
[       1 -1/2*r.1]
```

<a id="example-ex-a7004a"></a>
#### `Example: Diagonalising over an Extension Field (ex-a7004a)`

```magma
> F<z> := GF(5,3);
> M := Matrix(F,4,4,[
>  [ z^19,  z^45,     2,  z^90],
>  [ z^72,  z^54,  z^72,  z^58],
>  [  z^4,  z^58,  z^37,  z^35],
>  [ z^69, z^102,  z^61, z^115]]);
> IsDiagonalisable(M);
false
> IsDiagonalisable(M : ExtendField);
true
[ $.1^9049         0         0         0]
[        0 $.1^12678         0         0]
[        0         0  $.1^6197         0]
[        0         0         0  $.1^6726]

[ $.1^8396  $.1^4303 $.1^11772 $.1^12232]
[$.1^14704 $.1^12093  $.1^4253  $.1^8647]
[ $.1^2692  $.1^6659  $.1^2844 $.1^13472]
[ $.1^9992 $.1^11721   $.1^409  $.1^2819]
```

### Solutions of Systems of Linear Equations

<a id="function-isconsistent-modmatrngelt-modtuprng"></a>
#### `IsConsistent(A, w): ModMatRngElt, ModTupRng -> BoolElt, ModTupRngElt, ModTupRng`

Given a matrix $A$ belonging to $M_n(R)$ and a vector $w$ belonging to the tuple module $R^{(n)}$, return `true` iff the system of linear equations $v*A = w$ is consistent. If the system is consistent, then the function will also return:

**(a)**
A particular solution $v$;

**(b)**
The kernel $K$ of $A$ so that $(v + k) * A = w$ for $k\in K$.

<a id="function-isconsistent-modmatrngelt-modtuprng-2"></a>
#### `IsConsistent(A, W): ModMatRngElt, [ ModTupRng ] -> BoolElt, [ ModTupRngElt ], ModTupRng`

Given a matrix $A$ belonging to $M_n(R)$ and a sequence $W$ of vectors belonging to the tuple module $R^{(m)}$, return `true` iff the system of linear equations $V[i]*A = W[i]$ for each $i$ is consistent. If the systems are all consistent, then the function will also return:

**(a)**
A solution sequence $V$;

**(b)**
The kernel $K$ of $A$ so that $(V[i] + k) * A = W[i]$ for $k\in K$.

<a id="function-solution-modmatrngelt-modtuprng"></a>
#### `Solution(A, w): ModMatRngElt, ModTupRng -> ModTupRngElt, ModTupRng`

Given a matrix $A$ belonging to $M_n(R)$ and a vector $w$ belonging to the tuple module $R^{(n)}$, solve the system of linear equations $v*A = w$. The function returns two values:

**(a)**
A particular solution $v$;

**(b)**
The kernel $K$ of $A$ so that $(v + k) * A = w$ for $k\in K$.

<a id="function-solution-modmatrngelt-modtuprng-2"></a>
#### `Solution(A, W): ModMatRngElt, [ ModTupRng ] -> [ ModTupRngElt ], ModTupRng`

Given a matrix $A$ belonging to $M_n(R)$ and a sequence $W$ of vectors belonging to the tuple module $R^{(n)}$, solve the system of linear equations $V[i]*A = W[i]$ for each $i$. The function returns two values:

**(a)**
A solution sequence $V$;

**(b)**
The kernel $K$ of $A$ so that $(V[i] + k) * A = W[i]$ for $k\in K$.

### Presentations for Matrix Algebras

Magma has the capability of constructing a presentation for an algebra $A$ generated by a collection ${\alpha_1, \dots, \alpha_t}$ of $n \times n$ matrices over a finite field $k$. The presentation has the form

$$
A \cong P/ I
$$

where $P$ is a free algebra in noncommuting variable and $I$ is a two-sided ideal in $P$. The presentation is obtained by computing a set of primitive idempotents for the algebra and extracting generators for the radical of the algebra. For such an algebra there is a sequence

$$
0 \longrightarrow {\rm Rad}(A) \longrightarrow A
\longrightarrow A/{\rm Rad}(A) \longrightarrow 0
$$

which is split in the sense that $A/{\rm Rad}(A)$ is a subalgebra $A$. Moreover, $A/{\rm Rad}(A)$ is a direct sum of complete matrix algebras $A_i$ over extensions $K_i$ of the field $k$. Each complete matrix algebra $A_i$ is generated by two elements $b_i$ and $t_i$. The element $b_i$ has minimal rank and $b_i^{n_i-1} = e_i$ is a primitive idempotent where $n_i$ is the number of elements in the field $K_i$. That is, $b_i$ is a generator for the multiplicative group of nonzero elements of $e_iA_ie_i \cong K_i$. The element $t_i$ is conjugate to a permutation matrix of degree $n_i$ in $A_i$. The elements $z_1, \dots, z_s$ are generators of the radical of $A$. These elements are computed so as to lie in the condensed algebra $eAe$ where $e = \sum e_i$.

The calculation produces also a set of generators and relations for the condensed algebra $eAe$. This algebra is Morita equivalent to $A$, and hence shares many of the same homological properties of the algebra $A$.

In the course of obtaining the presentation, several aspects of the algebra are computed.

#### Quotients and Idempotents

<a id="function-naturalfreealgebracover-algmat"></a>
##### `NaturalFreeAlgebraCover(A): AlgMat -> Map`

Returns the map of a free algebra onto the matrix algebra $A$, such that the variables of the free algebra go to the generators of $A$.

<a id="function-simplequotientalgebras-algmat"></a>
##### `SimpleQuotientAlgebras(A): AlgMat -> Rec`

The simple quotient algebras of the matrix algebra $A$. The output is a record having the following fields:

**(a)**
The actual simple algebras that are the quotients of the algebra $A$. The function returns the sequence of mappings from the natural free-algebra cover of $A$ to the quotients. The variable corresponding to a generator of $A$ is mapped to the corresponding generator of the quotient. (field name `SimpleQuotients`)

**(b)**
The degrees of the quotients as matrix algebras over their centers (field name `DegreesOverCenters`).

**(c)**
The degrees of the extension of center of the quotient algebra over the base field of $A$ (field name `DegreesOfCenters`).

**(d)**
The number of elements in the center of the quotient algebra (field name `OrdersOfCenters`).

<a id="function-primitiveidempotentdata-algmat"></a>
##### `PrimitiveIdempotentData(A): AlgMat -> SeqEnum, Map, SeqEnum`

The initial data for a decomposition of the matrix algebra $A$. The output is a sequence of records, one for each simple quotient algebra of $A$, each consisting of the following fields.

**(a)**
`AlgebraIdempotent` : An idempotent whose image in the simple quotient is the identity matrix.

**(b)**
`PrimitiveIdempotent` : A primitive idempotents whose image in the quotient is primitive.

**(c)**
`PrimitiveIdempotentOnQuotient` : The image of the primitive idempotent in the quotient algebra.

**(d)**
`FieldGenerator` : A multiple of the primitive idempotent which is a field generator for the center of the algebra.

**(e)**
`FieldGeneratorOnQuotient` : The image of the field generator in the quotient algebra.

**(f)**
`GeneratingPolForCenter` : The minimal polynomial for the matrix of the field generator.

<a id="function-primitiveidempotents-algmat"></a>
##### `PrimitiveIdempotents(A): AlgMat -> SeqEnum`

A list of primitive idempotent for the matrix algebra $A$, one idempotent for each irreducible module.

<a id="function-ranksofprimitiveidempotents-algmat"></a>
##### `RanksOfPrimitiveIdempotents(A): AlgMat -> SeqEnum`

The sequence of ranks of the primitive idempotents for the matrix algebra $A$.

<a id="function-naturalfreealgebracover-algmat-2"></a>
##### `NaturalFreeAlgebraCover(A): AlgMat -> Map`

Returns the map of a free algebra onto the matrix algebra $A$, such that the variables of the free algebra go the generators of the algebra.

<a id="function-condensedalgebra-algmat"></a>
##### `CondensedAlgebra(A): AlgMat -> AlgMat`

Returns the algebra $eAe$ where $e$ is a sum of primitive idempotents, one for each simple $A$-module.

<a id="example-ex-b62a87"></a>
##### `Example: Primitive Idempotents (ex-b62a87)`

We form a matrix algebra over the field with three elements generated by two elements. The algebra is block upper triangular, where the upper left block is a field extension of degree three and the lower block is a filed extension of degree 2.

```magma
> a1 := KMatrixSpace(GF(3),3,3)![0,1,0,0,0,1,-1,0,1];
> a2 := KMatrixSpace(GF(3),2,2)![0,1,-1,0];
> z1 := KMatrixSpace(GF(3),5,5)!0;
> z2 := InsertBlock(z1,a1,1,1);
> z2;
[0 1 0 0 0]
[0 0 1 0 0]
[2 0 1 0 0]
[0 0 0 0 0]
[0 0 0 0 0]
> z3 := InsertBlock(z1,a2,4,4);
```

$z2$ and $z3$ are the matrices of the field extensions. Next, add an entry to $z3$ that is an extension class between the two algebras.

```magma
> z3[1][4] := 1;
> z3;
[0 0 0 1 0]
[0 0 0 0 0]
[0 0 0 0 0]
[0 0 0 0 1]
[0 0 0 2 0]
> A := MatrixAlgebra<GF(3),5|z2,z3>;
```

We can check to see if the quotients came out as expected.

```magma
> SimpleQuotientAlgebras(A);
rec<recformat<SimpleQuotients: SeqEnum, DegreesOverCenters:
SeqEnum, DegreesOfCenters: SeqEnum, OrdersOfCenters: SeqEnum> |
    SimpleQuotients := [
        Mapping from: Free associative algebra of rank 2 over
                GF(3) to Matrix Algebra of degree 3 with 2
            generators over GF(3),
        Mapping from: Free associative algebra of rank 2 over
                GF(3) to Matrix Algebra of degree 2 with 2
            generators over GF(3)
    ],
    DegreesOverCenters := [ 1, 1 ],
    DegreesOfCenters := [ 3, 2 ],
    OrdersOfCenters := [ 27, 9 ]
```

Here are the idempotents.

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

    [0 0 0 0 0]
    [0 0 0 0 0]
    [0 0 0 0 1]
    [0 0 0 1 0]
    [0 0 0 0 1]
]
```

Finally we have the Cartan matrix.

```magma
> CartanMatrix(A);
[1 3]
[0 1]
```

#### Generators and Presentations

We use the idempotents as the first step in the presentation process. The generators of the algebra consist of the field generators, each of which is a generator of the center of a simple quotient algebra multiplied by a corresponding primitive idempotent, permutation matrices, one for each simple quotient algebra, and generators for the radical, all of which can be taken to be in the subalgebra $eAe$ where $e$ is the sum of one primitive idempotent for each simple quotient algebra.

For display purposes the variables for the free algebra of the presentations are given names. The variables $b.i$ represent field generators, while the $t.i$’s are permutation matrices and the $z.i$’s are the generators of the radical. The reader should be warned that these names are not suitable for input into other function.

<a id="function-semisimplegeneratordata-algmat"></a>
##### `SemisimpleGeneratorData(A): AlgMat -> SeqEnum`

The data on the semisimple generators of the algebra $A$, that is the generators in $A$ of $A/Rad(A)$. Some of the output is intended for use in other functions. The return is a sequence of records, one for each simple quotient algebra. Each record consists of the following fields.

**(a)**
`PowersOfFieldGenerators` : A record consisting of look-up tables for the powers of the field generators as elements both of the algebra $A$ and the simple quotient algebra.

**(b)**
`Permutation` : The permutation matrix of the quotient algebra as an element of $A$.

**(c)**
`PermutationOnQuotient` : The permutation matrix on the quotient.

**(d)**
`FieldGenerator` : The matrix of the field generator as an element of $A$.

**(e)**
`FieldGeneratorOnQuotient` : The matrix of the field generator as an element of the quotient algebra.

**(f)**
`PrimitiveIdempotent` : The matrix of the primitive idempotent on $A$.

**(g)**
`PrimitiveIdempotentOnQuotient` : The matrix of the primitive idempotent on the quotient algebra.

**(h)**
`GeneratingPolForCenter` : The Galois polynomial for the extension of the center of the quotient algebra over the base ring.

<a id="function-algebragenerators-algmat"></a>
##### `AlgebraGenerators(A): AlgMat -> Rec`

The standard generators of the matrix algebra $A$. The output is a record consisting of the following fields.

**(a)**
`FieldGenerators` : The sequence of matrices of the field generators, one for each simple quotient algebra.

**(b)**
`PermutationMatrices` : The sequence of permutation matrices for the quotient algebras as elements of A, one for each quotient algebra.

**(c)**
`PrimitiveIdempotents` : The sequence of primitive idempotents for $A$, one for each quotient algebra.

**(d)**
`RadicalGenerators` : A set of generators for the radical of $A$ arranged as a list of lists of generators of the radical of $e_iAe_j$ for $e_i$ and $e_j$ primitive idempotents.

**(e)**
`SequenceRadicalGenerators` : A sequence of minimal generators of radical of $A$.

**(f)**
`GeneratingPolynomialsForCenters` : The galois polynomials of the centers over the base field.

**(g)**
`StandardFormConjugationMatrices` : The matrices which conjugate the element of $A$ into the standard form relative to the computed primitive idempotents for $A$.

<a id="function-algebrastructure-algmat"></a>
##### `AlgebraStructure(A): AlgMat -> Rec`

The accumulated structure of the matrix algebra $A$. The return is a record with the following fields. Some of this information is saved to be used in other calculations.

**(a)**
`FreeAlgebra` : The free algebra in the newly computed variables for the algebra.

**(b)**
`RelationsIdeal` : The ideal of relations among the new computed generators.

**(c)**
`StandardFreeAlgebraCover` : The map from the free algebra to $A$.

**(d)**
`FieldGenerators` : The matrices in $A$ of the generators of the centers of the simple quotient algebras of $A$.

**(e)**
`PermutationMatrices` : The permutation matrices each of which together with the corresponding field generator, generates a simple quotient algebra as a subalgebra of $A$.

**(f)**
`PrimitiveIdempotents` : The primitive idempotents, each of which is a power of the corresponding field generator.

**(g)**
`RadicalGenerators` : A list of lists giving the generators of the radical of $A$ which are in $e_iAe_j$ where $\{ e_i\}$ are the primitive idempotents.

**(h)**
`CondensedRadicalBasis` : The condensed matrices in $eAe$ of a basis for the radical of the algebra. The output is a list of lists giving the basis for $e_iAe_j$. Each entry in the list of lists is a tuple consisting of a matrix in the condensed algebra and the monomial which expresses this matrix as a product of the generators.

**(i)**
`CondensedFieldGenerators` : The condensed matrices in $eAe$ of the field generators.

**(j)**
`FieldPolynomials` : The sequence of minimal polynomials of the field generators.

**(k)**
`DegreesOfSimpleModules` : The dimensions of the Simple modules of $A$.

**(l)**
`DegreeOfFieldExtensions` : The degrees of the centers of simple quotient algebras of $A$ over the base field of $A$.

**(m)**
`SimpleQuotientAlgebras` : The simple quotient algebras of $A$.

**(n)**
`StandardFormConjugationMatrices` : The matrices which conjugate the algebra $A$ into standard form with respect to the computed system of primitive idempotents.

<a id="function-presentation-algmat"></a>
##### `Presentation(A): AlgMat -> AlgFr, AlgFr, Map`

The presentation in generators and relations of the matrix algebra $A$. The function returns the free algebra and the relations ideal calculated in the algebra structure program, as well as the map from the free algebra to $A$.

<a id="function-standardformconjugationmatrices-algmat"></a>
##### `StandardFormConjugationMatrices(A): AlgMat -> Tup`

Returns the pair ($M$ and $M^{-1}$) of matrices that conjugate the matrix algebra $A$ into standard form with respect to a chosen set of primitive idempotents.

<a id="function-condensationmatrices-algmat"></a>
##### `CondensationMatrices(A): AlgMat -> Tup`

The matrices, conjugating by which, gives the condensation of $A$.

<a id="function-sequenceofradicalgenerators-algmat"></a>
##### `SequenceOfRadicalGenerators(A): AlgMat -> SeqEnum`

The sequence of matrices of elements that generate the radical of $A$.

<a id="function-cartanmatrix-algmat"></a>
##### `CartanMatrix(A): AlgMat -> ModMatRngElt`

The Cartan Matrix of the algebra $A$.

<a id="example-ex-865183"></a>
##### `Example: Condensed Algebra of a Permutation Module (ex-865183)`

In this example we form the permutation module $M$ of the symmetric group $G$ on seven letters by the Young subgroup that is the direct product $H$ of two copies of the symmetric group on three letters. The algebra $A$ is the image of the group algebra in the ring of endomorphisms of $M$.

```magma
> G := Sym(7);
> H := sub<G| G!(1,2,3),G!(1,2),G!(4,5,6), G!(4,5)>;
> M := PermutationModule(G, H, GF(5));
> M;
GModule M of dimension 140 over GF(5)
> A := Action(M);
```

We see that $A$ has seven simple quotients.

```magma
> SimpleQuotientAlgebras(A);
rec<recformat<SimpleQuotients: SeqEnum, DegreesOverCenters:
SeqEnum, DegreesOfCenters: SeqEnum, OrdersOfCenters: SeqEnum> |
    SimpleQuotients := [
        Mapping from: Free associative algebra of rank 2 over
                GF(5) to Matrix Algebra of degree 35 with 2
            generators over GF(5),
        Mapping from: Free associative algebra of rank 2 over
                GF(5) to Matrix Algebra of degree 15 with 2
            generators over GF(5),
        Mapping from: Free associative algebra of rank 2 over
                GF(5) to Matrix Algebra of degree 13 with 2
            generators over GF(5),
        Mapping from: Free associative algebra of rank 2 over
                GF(5) to Matrix Algebra of degree 8 with 2
            generators over GF(5),
        Mapping from: Free associative algebra of rank 2 over
                GF(5) to Matrix Algebra of degree 8 with 2
            generators over GF(5),
        Mapping from: Free associative algebra of rank 2 over
                GF(5) to Matrix Algebra of degree 6 with 2
            generators over GF(5),
        Mapping from: Free associative algebra of rank 2 over
                GF(5) to Matrix Algebra of degree 1 with 2
            generators over GF(5)
    ],
    DegreesOverCenters := [ 35, 15, 13, 8, 8, 6, 1 ],
    DegreesOfCenters := [ 1, 1, 1, 1, 1, 1, 1 ],
    OrdersOfCenters := [ 5, 5, 5, 5, 5, 5, 5 ]
    >
> RanksOfPrimitiveIdempotents(A);
[ 1, 1, 3, 2, 1, 4, 3 ]
```

The condensed algbra of $A$ is a much smaller object.

```magma
> B := CondensedAlgebra(A);
> B;
Matrix Algebra of degree 15 with 13 generators over GF(5)
> CartanMatrix(A);
[1 0 0 0 0 0 0]
[0 1 0 0 0 0 0]
[0 0 2 0 1 0 1]
[0 0 0 1 0 1 0]
[0 0 1 0 1 0 0]
[0 0 0 1 0 2 0]
[0 0 1 0 0 0 2]
```

From the Cartan Matrix we can see that $A$ has four blocks. The first and second simple subalgebras are in blocks by themselves. The subalgebras numbers 3, 5, and 7 form another block as do the subalgebras 4 and 6. Note that $B$, being Morita equivalent to $A$, has the same Cartan Matrix and the same block structure.

#### Solving the Word Problem

The presentation machinery also gives a test for membership in a matrix algebra. If $A$ is a subalgebra of the $n \times n$ matrices generated by some collection of matrices, Magma can tell if any $n \times n$ matrix is an element of $A$. If the element is in $A$ then Magma can write the element as a polynomial in the polynomial ring of the presentation.

<a id="function-wordproblemdata-algmat"></a>
##### `WordProblemData(A): AlgMat -> List`

The data needed for the solution to the word problem. The output is a list of lists of basis elements for the radical together with the corresponding monomials in the generators of the free algebra.

<a id="function-wordproblem-algmat-algmatelt"></a>
##### `WordProblem(A, x): AlgMat, AlgMatElt -> BoolElt, AlgFrElt`

Returns `true` if the matrix $x$ is in the subalgebra $A$, and if true returns also an expression of the element $x$ as a polynomial in the presentation of $A$.

<a id="example-ex-6d214a"></a>
##### `Example: Presentation of a Matrix Algebra (ex-6d214a)`

In this example we form the permutation module for the symmetric group $G$ acting on the coset space of the normalizer $H$ of Sylow 3-subgroup of $G$. The coefficients are in the field with two elements. The algebra $A$ is the image of the group algebra in the endomorphism ring of the permutation module.

```magma
> G := Sym(5);
> H := Normalizer(G,Sylow(G,3));
> M := PermutationModule(G,H, GF(2));
> M;
GModule M of dimension 10 over GF(2)
> A := Action(M);
```

Here we get the presentation of $A$.

```magma
> P, I, mu  := Presentation(A);
> Dimension(P/I);
42
```

Thus the dimension of $A$ is 42.

```magma
> CartanMatrix(A);
[1 0 1]
[0 1 0]
[1 0 2]
> B := CondensedAlgebra(A);
> Q, J, theta := Presentation(B);
```

The presentation of $B$ has the form:

```magma
> J;
Two-sided ideal of Free associative algebra of rank 5 over GF(2)
Non-commutative Graded Lexicographical Order
Variables: b_1, b_2, b_3, z_1, z_2
Groebner basis:
[
    b_2^2 + b_2,
    b_2*b_3,
    b_2*z_1,
    b_2*z_2,
    b_3*b_2,
    b_3^2 + b_3,
    b_3*z_1,
    b_3*z_2 + z_2,
    z_1*b_2,
    z_1*b_3 + z_1,
    z_1^2,
    z_1*z_2,
    z_2*b_2,
    z_2*b_3,
    z_2^2,
    b_1 + b_2 + b_3 + 1
]
```

The matrix $A.1$ is the first of the original generators for $A$. We can check that $A.1$ is an element of the algebra generated by the computed generators of A.

```magma
> boo, y := WordProblem(A,A.1);
> boo;
true
```

The element $y$ is the expression of $A.1$ as a polynomial in the free algebra $P$ in the new computed generators for $A$.

```magma
> y;
t_1^4*b_1*t_1^3 + t_2^4*b_2*t_2^3 + t_1^4*b_1*t_1^2 +
    t_2^3*b_2*t_2^3 + t_1^2*b_1*t_1^3 + t_1^4*b_1*t_1 +
    t_2^2*b_2*t_2^3 + t_2^3*b_2*t_2^2 + t_2^4*b_2*t_2 +
    t_1^2*b_1*t_1^2 + t_1^3*b_1*t_1 + t_1^4*b_1 + t_1^4*z_1 +
    t_2*b_2*t_2^3 + t_2^2*b_2*t_2^2 + t_2^3*b_2*t_2 +
    t_1*b_1*t_1^2 + t_1^3*b_1 + t_3*z_2*t_1^2 + t_1^2*b_1 +
    t_2*b_2*t_2 + t_2^2*b_2 + t_1*b_1 + t_2*b_2 + t_3*b_3 +
    t_3*z_2
```

The mapping $mu$ is the function from the free algebra $P$ into $A$.

```magma
> mu(y);
[0 1 0 0 0 0 0 0 0 0]
[0 0 0 1 0 0 0 0 0 0]
[0 0 0 0 1 0 0 0 0 0]
[0 0 0 0 0 1 0 0 0 0]
[0 0 0 0 0 0 1 0 0 0]
[0 0 0 0 0 0 0 0 1 0]
[0 0 0 0 0 0 0 1 0 0]
[0 0 0 0 0 0 0 0 0 1]
[1 0 0 0 0 0 0 0 0 0]
[0 0 1 0 0 0 0 0 0 0]
```

The ultimate check of the accuracy of the computation is that the polynomial expressions give back the original generators.

```magma
> mu(y) eq A.1;
true
```

Finally we can check whether a random $10 \times 10$ matrix is an element of $A$.

```magma
> b := Random(Generic(A));
> WordProblem(A,b);
false
```

## Group Algebras

- [Introduction](https://docs.magma-maths.org/Algebras/GroupAlgebras/introduction.md)
- [Construction of Group Algebras and their Elements](https://docs.magma-maths.org/Algebras/GroupAlgebras/creation.md)
  - [Construction of a Group Algebra](https://docs.magma-maths.org/Algebras/GroupAlgebras/creation.md#construction-of-a-group-algebra)
    - [`GroupAlgebra( R, G: parameters ): Rng, Grp → AlgGrp`](https://docs.magma-maths.org/Algebras/GroupAlgebras/creation.md#function-groupalgebra-rng-grp)
    - [`GroupAlgebra< R, G: parameters >: Rng, Grp → AlgGrp`](https://docs.magma-maths.org/Algebras/GroupAlgebras/creation.md#constructor-constructor-groupalgebra-rng-grp-alggrp)
    - [Example: Constructing a Group Algebra](https://docs.magma-maths.org/Algebras/GroupAlgebras/creation.md#example-ex-a0675c)
  - [Construction of a Group Algebra Element](https://docs.magma-maths.org/Algebras/GroupAlgebras/creation.md#construction-of-a-group-algebra-element)
    - [`elt< A | r, g >: AlgGrp, RngElt, GrpElt → AlgGrpElt`](https://docs.magma-maths.org/Algebras/GroupAlgebras/creation.md#constructor-constructor-elt-alggrp-rngelt-grpelt-alggrpelt)
    - [`A ! g: AlgGrp, GrpElt → AlgGrpElt`](https://docs.magma-maths.org/Algebras/GroupAlgebras/creation.md#operation-op-alggrp-grpelt)
    - [`A ! r: AlgGrp, RngElt → AlgGrpElt`](https://docs.magma-maths.org/Algebras/GroupAlgebras/creation.md#operation-op-alggrp-rngelt)
    - [`A ! [c₁, ..., cₙ]: AlgGrp, SeqEnum → AlgGrpElt`](https://docs.magma-maths.org/Algebras/GroupAlgebras/creation.md#operation-op-alggrp-seqenum)
    - [`Eta(A): AlgGrp → AlgGrpElt`](https://docs.magma-maths.org/Algebras/GroupAlgebras/creation.md#function-eta-alggrp)
    - [Example: Idempotent in a Group Algebra](https://docs.magma-maths.org/Algebras/GroupAlgebras/creation.md#example-ex-b66604)
- [Construction of Subalgebras, Ideals, and Quotient Algebras](https://docs.magma-maths.org/Algebras/GroupAlgebras/subring-ideal-quotient.md)
  - [`sub< cat : A | L>: Cat, AlgGrp, List → AlgGrp, Map`](https://docs.magma-maths.org/Algebras/GroupAlgebras/subring-ideal-quotient.md#constructor-constructor-sub-cat-alggrp-list-alggrp-map)
  - [`lideal< cat : A | L>: Cat, AlgGrp, List → AlgGrp, Map`](https://docs.magma-maths.org/Algebras/GroupAlgebras/subring-ideal-quotient.md#constructor-constructor-lideal-cat-alggrp-list-alggrp-map)
  - [`rideal< cat : A | L>: Cat, AlgGrp, List → AlgGrp, Map`](https://docs.magma-maths.org/Algebras/GroupAlgebras/subring-ideal-quotient.md#constructor-constructor-rideal-cat-alggrp-list-alggrp-map)
  - [`ideal< cat : A | L>: Cat, AlgGrp, List → AlgGrp, Map`](https://docs.magma-maths.org/Algebras/GroupAlgebras/subring-ideal-quotient.md#constructor-constructor-ideal-cat-alggrp-list-alggrp-map)
  - [`a * I: AlgGrpElt, AlgGrpSub → AlgGrpSub`](https://docs.magma-maths.org/Algebras/GroupAlgebras/subring-ideal-quotient.md#operation-op-times-alggrpelt-alggrpsub)
  - [`I * a: AlgGrpSub, AlgGrpElt → AlgGrpSub`](https://docs.magma-maths.org/Algebras/GroupAlgebras/subring-ideal-quotient.md#operation-op-times-alggrpsub-alggrpelt)
  - [`quo< A | L >: AlgGrp, List → AlgAss, Map`](https://docs.magma-maths.org/Algebras/GroupAlgebras/subring-ideal-quotient.md#constructor-constructor-quo-alggrp-list-algass-map)
  - [`A / S: AlgGrp, AlgGrpSub → AlgAss`](https://docs.magma-maths.org/Algebras/GroupAlgebras/subring-ideal-quotient.md#operation-op-div-alggrp-alggrpsub)
  - [Example: Wedderburn Decomposition of a Group Algebra](https://docs.magma-maths.org/Algebras/GroupAlgebras/subring-ideal-quotient.md#example-ex-d83263)
- [Operations on Group Algebras and their Subalgebras](https://docs.magma-maths.org/Algebras/GroupAlgebras/grp-alg-ops.md)
  - [Operations on Group Algebras](https://docs.magma-maths.org/Algebras/GroupAlgebras/grp-alg-ops.md#operations-on-group-algebras)
    - [`Algebra(A): AlgGrp → AlgAss, Map`](https://docs.magma-maths.org/Algebras/GroupAlgebras/grp-alg-ops.md#function-algebra-alggrp)
    - [`AugmentationMap(A): AlgGrp → Map`](https://docs.magma-maths.org/Algebras/GroupAlgebras/grp-alg-ops.md#function-augmentationmap-alggrp)
    - [`AugmentationIdeal(A): AlgGrp → AlgGrpSub`](https://docs.magma-maths.org/Algebras/GroupAlgebras/grp-alg-ops.md#function-augmentationideal-alggrp)
    - [`RepresentationType(A): AlgGrp → MonStgElt`](https://docs.magma-maths.org/Algebras/GroupAlgebras/grp-alg-ops.md#function-representationtype-alggrp)
    - [`ChangeRepresentationType(A, Rep): AlgGrp, MonStgElt → AlgGrp, Map`](https://docs.magma-maths.org/Algebras/GroupAlgebras/grp-alg-ops.md#function-changerepresentationtype-alggrp-monstgelt)
    - [`ConstructTable(A): AlgGrp`](https://docs.magma-maths.org/Algebras/GroupAlgebras/grp-alg-ops.md#procedure-constructtable-alggrp)
    - [`CoefficientRing(A): AlgGrp → Rng`](https://docs.magma-maths.org/Algebras/GroupAlgebras/grp-alg-ops.md#function-coefficientring-alggrp)
    - [`BaseRing(A): AlgGrp → Rng`](https://docs.magma-maths.org/Algebras/GroupAlgebras/grp-alg-ops.md#function-basering-alggrp)
  - [Operations on Subalgebras of Group Algebras](https://docs.magma-maths.org/Algebras/GroupAlgebras/grp-alg-ops.md#operations-on-subalgebras-of-group-algebras)
    - [`S ! 1: AlgGrpSub → Grp`](https://docs.magma-maths.org/Algebras/GroupAlgebras/grp-alg-ops.md#operation-op-alggrpsub)
    - [`S ! 1: AlgGrp → Grp`](https://docs.magma-maths.org/Algebras/GroupAlgebras/grp-alg-ops.md#operation-op-alggrp)
    - [`Group(S): AlgGrpSub → Grp`](https://docs.magma-maths.org/Algebras/GroupAlgebras/grp-alg-ops.md#function-group-alggrpsub)
    - [`Group(S): AlgGrp → Grp`](https://docs.magma-maths.org/Algebras/GroupAlgebras/grp-alg-ops.md#function-group-alggrp)
    - [`GroupAlgebra(S): AlgGrpSub → AlgGrp`](https://docs.magma-maths.org/Algebras/GroupAlgebras/grp-alg-ops.md#function-groupalgebra-alggrpsub)
    - [`GroupAlgebra(S): AlgGrp → AlgGrp`](https://docs.magma-maths.org/Algebras/GroupAlgebras/grp-alg-ops.md#function-groupalgebra-alggrp)
    - [`Module(S): AlgGrpSub → ModTupRng, Map`](https://docs.magma-maths.org/Algebras/GroupAlgebras/grp-alg-ops.md#function-module-alggrpsub)
    - [`Module(S): AlgGrp → ModTupRng, Map`](https://docs.magma-maths.org/Algebras/GroupAlgebras/grp-alg-ops.md#function-module-alggrp)
    - [`CoefficientRing(A): AlgGrpSub → Rng`](https://docs.magma-maths.org/Algebras/GroupAlgebras/grp-alg-ops.md#function-coefficientring-alggrpsub)
    - [`BaseRing(A): AlgGrpSub → Rng`](https://docs.magma-maths.org/Algebras/GroupAlgebras/grp-alg-ops.md#function-basering-alggrpsub)
    - [`BasisMatrix(S): AlgGrpSub → ModMatRngElt`](https://docs.magma-maths.org/Algebras/GroupAlgebras/grp-alg-ops.md#function-basismatrix-alggrpsub)
    - [`BasisMatrix(S): AlgGrp → ModMatRngElt`](https://docs.magma-maths.org/Algebras/GroupAlgebras/grp-alg-ops.md#function-basismatrix-alggrp)
    - [`Coordinates(S, a): AlgGrpSub, AlgGrpElt → [ RingElt ]`](https://docs.magma-maths.org/Algebras/GroupAlgebras/grp-alg-ops.md#function-coordinates-alggrpsub-alggrpelt)
    - [`Coordinates(S, a): AlgGrp, AlgGrpElt → [ RingElt ]`](https://docs.magma-maths.org/Algebras/GroupAlgebras/grp-alg-ops.md#function-coordinates-alggrp-alggrpelt)
    - [`IsLeftIdeal(S): AlgGrpSub → BoolElt`](https://docs.magma-maths.org/Algebras/GroupAlgebras/grp-alg-ops.md#function-isleftideal-alggrpsub)
    - [`IsLeftIdeal(S): AlgGrp → BoolElt`](https://docs.magma-maths.org/Algebras/GroupAlgebras/grp-alg-ops.md#function-isleftideal-alggrp)
    - [`IsRightIdeal(S): AlgGrpSub → BoolElt`](https://docs.magma-maths.org/Algebras/GroupAlgebras/grp-alg-ops.md#function-isrightideal-alggrpsub)
    - [`IsRightIdeal(S): AlgGrp → BoolElt`](https://docs.magma-maths.org/Algebras/GroupAlgebras/grp-alg-ops.md#function-isrightideal-alggrp)
    - [`IsIdeal(S): AlgGrpSub → BoolElt`](https://docs.magma-maths.org/Algebras/GroupAlgebras/grp-alg-ops.md#function-isideal-alggrpsub)
    - [`IsIdeal(S): AlgGrp → BoolElt`](https://docs.magma-maths.org/Algebras/GroupAlgebras/grp-alg-ops.md#function-isideal-alggrp)
    - [`Centraliser(S): AlgGrpSub → AlgGrpSub`](https://docs.magma-maths.org/Algebras/GroupAlgebras/grp-alg-ops.md#function-centraliser-alggrpsub)
    - [`Centralizer(S): AlgGrpSub → AlgGrpSub`](https://docs.magma-maths.org/Algebras/GroupAlgebras/grp-alg-ops.md#function-centralizer-alggrpsub)
    - [`Centraliser(S): AlgGrp → AlgGrpSub`](https://docs.magma-maths.org/Algebras/GroupAlgebras/grp-alg-ops.md#function-centraliser-alggrp)
    - [`Centralizer(S): AlgGrp → AlgGrpSub`](https://docs.magma-maths.org/Algebras/GroupAlgebras/grp-alg-ops.md#function-centralizer-alggrp)
    - [`Idealiser(S): AlgGrpSub → AlgGrpSub`](https://docs.magma-maths.org/Algebras/GroupAlgebras/grp-alg-ops.md#function-idealiser-alggrpsub)
    - [`Idealizer(S): AlgGrpSub → AlgGrpSub`](https://docs.magma-maths.org/Algebras/GroupAlgebras/grp-alg-ops.md#function-idealizer-alggrpsub)
    - [`Idealiser(S): AlgGrp → AlgGrpSub`](https://docs.magma-maths.org/Algebras/GroupAlgebras/grp-alg-ops.md#function-idealiser-alggrp)
    - [`Idealizer(S): AlgGrp → AlgGrpSub`](https://docs.magma-maths.org/Algebras/GroupAlgebras/grp-alg-ops.md#function-idealizer-alggrp)
    - [`LeftAnnihilator(S): AlgGrpSub → AlgGrpSub`](https://docs.magma-maths.org/Algebras/GroupAlgebras/grp-alg-ops.md#function-leftannihilator-alggrpsub)
    - [`LeftAnnihilator(S): AlgGrp → AlgGrpSub`](https://docs.magma-maths.org/Algebras/GroupAlgebras/grp-alg-ops.md#function-leftannihilator-alggrp)
    - [`RightAnnihilator(S): AlgGrpSub → AlgGrpSub`](https://docs.magma-maths.org/Algebras/GroupAlgebras/grp-alg-ops.md#function-rightannihilator-alggrpsub)
    - [`RightAnnihilator(S): AlgGrp → AlgGrpSub`](https://docs.magma-maths.org/Algebras/GroupAlgebras/grp-alg-ops.md#function-rightannihilator-alggrp)
    - [Example: Jacobson Radical of a Group Algebra](https://docs.magma-maths.org/Algebras/GroupAlgebras/grp-alg-ops.md#example-ex-71b601)
- [Operations on Elements](https://docs.magma-maths.org/Algebras/GroupAlgebras/elt-ops.md)
  - [`a + r: AlgGrpElt, RngElt → AlgGrpElt`](https://docs.magma-maths.org/Algebras/GroupAlgebras/elt-ops.md#operation-op-plus-alggrpelt-rngelt)
  - [`r + a: RngElt, AlgGrpElt → AlgGrpElt`](https://docs.magma-maths.org/Algebras/GroupAlgebras/elt-ops.md#operation-op-plus-rngelt-alggrpelt)
  - [`a + g: AlgGrpElt, GrpElt → AlgGrpElt`](https://docs.magma-maths.org/Algebras/GroupAlgebras/elt-ops.md#operation-op-plus-alggrpelt-grpelt)
  - [`g + a: GrpElt, AlgGrpElt → AlgGrpElt`](https://docs.magma-maths.org/Algebras/GroupAlgebras/elt-ops.md#operation-op-plus-grpelt-alggrpelt)
  - [`a - r: AlgGrpElt, RngElt → AlgGrpElt`](https://docs.magma-maths.org/Algebras/GroupAlgebras/elt-ops.md#operation-op-minus-alggrpelt-rngelt)
  - [`r - a: RngElt, AlgGrpElt → AlgGrpElt`](https://docs.magma-maths.org/Algebras/GroupAlgebras/elt-ops.md#operation-op-minus-rngelt-alggrpelt)
  - [`a - g: AlgGrpElt, GrpElt → AlgGrpElt`](https://docs.magma-maths.org/Algebras/GroupAlgebras/elt-ops.md#operation-op-minus-alggrpelt-grpelt)
  - [`g - a: GrpElt, AlgGrpElt → AlgGrpElt`](https://docs.magma-maths.org/Algebras/GroupAlgebras/elt-ops.md#operation-op-minus-grpelt-alggrpelt)
  - [`a * r: AlgGrpElt, RngElt → AlgGrpElt`](https://docs.magma-maths.org/Algebras/GroupAlgebras/elt-ops.md#operation-op-times-alggrpelt-rngelt)
  - [`r * a: RngElt, AlgGrpElt → AlgGrpElt`](https://docs.magma-maths.org/Algebras/GroupAlgebras/elt-ops.md#operation-op-times-rngelt-alggrpelt)
  - [`g * a: GrpElt, AlgGrpElt → AlgGrpElt`](https://docs.magma-maths.org/Algebras/GroupAlgebras/elt-ops.md#operation-op-times-grpelt-alggrpelt)
  - [`a * g: AlgGrpElt, GrpElt → AlgGrpElt`](https://docs.magma-maths.org/Algebras/GroupAlgebras/elt-ops.md#operation-op-times-alggrpelt-grpelt)
  - [`Support(a): AlgGrpElt → SeqEnum`](https://docs.magma-maths.org/Algebras/GroupAlgebras/elt-ops.md#function-support-alggrpelt)
  - [`Trace(a): AlgGrpElt → RngElt`](https://docs.magma-maths.org/Algebras/GroupAlgebras/elt-ops.md#function-trace-alggrpelt)
  - [`Augmentation(a): AlgGrpElt → RngElt`](https://docs.magma-maths.org/Algebras/GroupAlgebras/elt-ops.md#function-augmentation-alggrpelt)
  - [`Involution(a): AlgGrpElt → AlgGrpElt`](https://docs.magma-maths.org/Algebras/GroupAlgebras/elt-ops.md#function-involution-alggrpelt)
  - [`Coefficient(a, g): AlgGrpElt, GrpElt → RngElt`](https://docs.magma-maths.org/Algebras/GroupAlgebras/elt-ops.md#function-coefficient-alggrpelt-grpelt)
  - [`a[g]: AlgGrpElt, GrpElt → RngElt`](https://docs.magma-maths.org/Algebras/GroupAlgebras/elt-ops.md#indexed-indexed-a-alggrpelt-grpelt-rngelt)
  - [`ElementToSequence(a): AlgGrpElt → SeqEnum`](https://docs.magma-maths.org/Algebras/GroupAlgebras/elt-ops.md#function-elementtosequence-alggrpelt)
  - [`Eltseq(a): AlgGrpElt → SeqEnum`](https://docs.magma-maths.org/Algebras/GroupAlgebras/elt-ops.md#function-eltseq-alggrpelt)
  - [`Coefficients(a): AlgGrpElt → SeqEnum`](https://docs.magma-maths.org/Algebras/GroupAlgebras/elt-ops.md#function-coefficients-alggrpelt)
  - [`Centraliser(a): AlgGrpElt → AlgGrpSub`](https://docs.magma-maths.org/Algebras/GroupAlgebras/elt-ops.md#function-centraliser-alggrpelt)
  - [`Centralizer(a): AlgGrpElt → AlgGrpSub`](https://docs.magma-maths.org/Algebras/GroupAlgebras/elt-ops.md#function-centralizer-alggrpelt)
  - [`Centraliser(S, a): AlgGrpSub, AlgGrpElt → AlgGrpSub`](https://docs.magma-maths.org/Algebras/GroupAlgebras/elt-ops.md#function-centraliser-alggrpsub-alggrpelt)
  - [`Centralizer(S, a): AlgGrpSub, AlgGrpElt → AlgGrpSub`](https://docs.magma-maths.org/Algebras/GroupAlgebras/elt-ops.md#function-centralizer-alggrpsub-alggrpelt)
  - [Example: Diameter of a Cayley Graph](https://docs.magma-maths.org/Algebras/GroupAlgebras/elt-ops.md#example-ex-76435e)
  - [Example: Random Distribution of Words](https://docs.magma-maths.org/Algebras/GroupAlgebras/elt-ops.md#example-ex-1a2ff9)

### Introduction

Group algebras (or group rings) may be defined over any unital ring $R$ and any group $G$ in which elements have a canonical form (for example permutation groups, matrix groups, or polycyclic groups). Basic operations, such as simple arithmetic of elements, may be applied in any such group algebra. Certain functions, however, place stricter requirements on $R$ and $G$, such as requiring that $R$ have a matrix echelon algorithm in Magma.

### Construction of Group Algebras and their Elements

#### Construction of a Group Algebra

There are two different representations of group algebra elements used in Magma. Which is most suitable depends on the group $G$ and on the operations required, and must be decided upon when the algebra is created.

The first representation, which requires that $G$ is not too large, is to choose (once and for all) an ordering $(g_1, g_2, \ldots, g_n)$ of the elements of $G$ (where $n = |G|$), and then to store elements of the group algebra $A = R[G]$ as coefficient vectors relative to the basis $(g_1, g_2, \ldots, g_n)$ of $A$. So an element $a = a_1 * g_1 + a_2 * g_2 + \ldots + a_n * g_n$ ($a_i \in R$) of $A$ will be stored as the vector $(a_1, a_2, \ldots, a_n)$. This makes for fast arithmetic and allows the use of matrix echelonization for dealing with subalgebras and ideals (if $R$ has a matrix echelon algorithm).

The alternative representation, necessary when dealing with large groups, stores an element $a \in A = R[G]$ as a pair of parallel arrays giving the terms of the element. One array contains the nonzero coefficients of the element and the other contains their associated group elements. This representation allows group algebras to be defined over any group in which the elements have a canonical form, including potentially infinite matrix groups over a ring of characteristic 0 or even free groups. Note however, that operations in such algebras are limited, as the length of the representing arrays may grow exponentially with the number of multiplications performed.

<a id="function-groupalgebra-rng-grp"></a>
##### `GroupAlgebra(R, G: parameters): Rng, Grp -> AlgGrp`

<a id="constructor-constructor-groupalgebra-rng-grp-alggrp"></a>
##### `GroupAlgebra< R, G: parameters >: Rng, Grp -> AlgGrp`

```magma
Rep  : MonStgElt                    Default: 
Table: BoolElt                      Default: 
```

Given a unital ring $R$ and a group $G$ (which is not a finitely presented group), create the group algebra $R[G]$. There are two optional arguments associated with this creation function.

The optional parameter `Rep` can be used to specify which representation should be chosen for elements of the algebra. Its possible values are `"Vector"` and `"Terms"`. If `Rep` is not assigned, then Magma chooses the vector representation if $|G| \leq 1000$ and the term representation otherwise. If `Rep` is set to `"Vector"`, Magma has to compute the order of $G$. If it does not succeed in that or the order is too large to construct vectors of this size, then an error message is displayed.

The second optional parameter `Table` can be used to specify whether or not the multiplication table of the group should be computed and stored upon creation of the algebra. Storing the multiplication table makes multiplication of algebra elements (and all other group algebra operations using this) much faster. Building this table does, however, increase the time needed to create the algebra. The table can only be stored if the vector representation of elements is used. If the `Table` parameter is not set, then Magma stores the multiplication table only if $G \leq 200$.

<a id="example-ex-a0675c"></a>
##### `Example: Constructing a Group Algebra (ex-a0675c)`

We first construct the default group algebra $A = R[G]$ where $R$ is the ring of integers and $G$ is the symmetric group on three points.

```magma
> G := SymmetricGroup(3);
> R := Integers();
> A := GroupAlgebra( R, G );
> A;
Group algebra with vector representation and stored multiplication table
Coefficient ring: Integer Ring
Group: Permutation group G acting on a set of cardinality 3
    Order = 6 = 2 * 3
        (1, 2, 3)
        (1, 2)
```

Next we construct the group algebra $A = R[G]$ where $R = GF(5)$ and $G$ is the dihedral group of order 100, given as a polycyclic group. This time we specify that the term representation should be used for elements.

```magma
> G := PCGroup( DihedralGroup(50) );
> A := GroupAlgebra( GF(5), G: Rep := "Terms" );
> A;
Group algebra with terms representation
Coefficient ring: Finite field of size 5
Group: GrpPC : G of order 100 = 2^2 * 5^2
    PC-Relations:
        G.1^2 = Id(G),
        G.2^2 = Id(G),
        G.3^5 = G.4,
        G.4^5 = Id(G),
        G.3^G.1 = G.3^4 * G.4^4,
        G.4^G.1 = G.4^4
```

#### Construction of a Group Algebra Element

<a id="constructor-constructor-elt-alggrp-rngelt-grpelt-alggrpelt"></a>
##### `elt< A | r, g >: AlgGrp, RngElt, GrpElt -> AlgGrpElt`

Given a group algebra $A = R[G]$, a ring element $r \in R$, and a group element $g \in G$, create the element $r * g$ of $A$.

<a id="operation-op-alggrp-grpelt"></a>
##### `A ! g: AlgGrp, GrpElt -> AlgGrpElt`

Given a group element $g \in G$ create the element $1_R * g$ of the group algebra $A = R[G]$.

<a id="operation-op-alggrp-rngelt"></a>
##### `A ! r: AlgGrp, RngElt -> AlgGrpElt`

Given a ring element $r \in R$, create the element $r * 1_G$ of the group algebra $A = R[G]$.

<a id="operation-op-alggrp-seqenum"></a>
##### `A ! [c₁, ..., cₙ]: AlgGrp, SeqEnum -> AlgGrpElt`

Given a group algebra $A = R[G]$ in vector representation and a sequence $[c_1, \ldots, c_n]$ of $n = |G|$ elements of $R$, create the element $c_1 * g_1 + \ldots + c_n * g_n$, where $(g_1, \ldots, g_n)$ is the fixed basis of $A$.

<a id="function-eta-alggrp"></a>
##### `Eta(A): AlgGrp -> AlgGrpElt`

For a group algebra $A = R[G]$ in vector representation, create the element $\sum_{g \in G} 1_R * g$ of $A$.

<a id="example-ex-b66604"></a>
##### `Example: Idempotent in a Group Algebra (ex-b66604)`

We check that $Eta(A)/|G|$ is an idempotent in $A$ (provided the characteristic of $R$ does not divide the order of $G$).

```magma
> G := Alt(6);
> A := GroupAlgebra( GF(7), G );
> e := Eta(A) / #G;
> e^2 - e;
0
```

### Construction of Subalgebras, Ideals, and Quotient Algebras

Let $A = R[G]$ be a group algebra defined in Magma, where $R$ is a unital ring with a matrix echelon algorithm and $G$ is a group. If $A$ was constructed to use the vector representation for its elements, then subalgebras and left, right, and two-sided ideals of $A$ can be constructed. If $R$ is a field, then quotient algebras of $A$ are also possible.

A subalgebra or ideal of a group algebra $A$ is not in general a group algebra; hence, a different type is needed for these objects. Two possibilities are provided in Magma. The first is to construct the subalgebra or ideal to have type `AlgGrpSub`: a subalgebra (which may be an ideal) of a group algebra. Its elements are elements of the group algebra and it remains closely connected to its defining group algebra. By default, ideals of group algebras will be of this type.

The alternative is to create the subalgebra or ideal as an associative algebra given by structure constants (type `AlgAss`). The required structure constants are easily computable from the group algebra. This is the default Magma uses when creating subalgebras of a group algebra.

Regardless of the type given to a subalgebra or ideal, the inclusion map back into the group algebra is also provided.

<a id="constructor-constructor-sub-cat-alggrp-list-alggrp-map"></a>
#### `sub< cat : A | L>: Cat, AlgGrp, List -> AlgGrp, Map`

```magma
cat: Cat                    Default: AlgGrpSub
```

Create the subalgebra $S$ of the group algebra $A$ generated by the elements defined by $L$, where $L$ is a list of one or more items of the following types:

**(a)**
an element of $A$;

**(b)**
a set or sequence of elements of $A$;

**(c)**
a subalgebra of $A$;

**(d)**
a set or sequence of subalgebras of $A$;

**(e)**
a sequence of ring elements specifying an element of $A$, as returned when the `ElementToSequence` (or `Eltseq`) function is applied to the element.

The constructor returns the subalgebra as an element of the category `cat`, where `cat` is either `AlgGrpSub` (the default) or `AlgAss`. As well as the subalgebra itself, the constructor returns the inclusion homomorphism $f : S \rightarrow A$.

<a id="constructor-constructor-lideal-cat-alggrp-list-alggrp-map"></a>
#### `lideal< cat : A | L>: Cat, AlgGrp, List -> AlgGrp, Map`

```magma
cat: Cat                    Default: AlgGrpSub
```

Create the left ideal of the group algebra $A$, generated by the elements defined by $L$, where $L$ is a list as for the `sub` constructor above. The constructor returns the ideal as an element of the category `cat`, where `cat` is either `AlgGrpSub` (the default) or `AlgAss`. As well as the ideal itself, the constructor returns the inclusion homomorphism $f : I \rightarrow A$.

<a id="constructor-constructor-rideal-cat-alggrp-list-alggrp-map"></a>
#### `rideal< cat : A | L>: Cat, AlgGrp, List -> AlgGrp, Map`

```magma
cat: Cat                    Default: AlgGrpSub
```

Create the right ideal of the group algebra $A$ generated by the elements defined by $L$, where $L$ is a list as for the `sub` constructor above. The constructor returns the ideal as an element of the category `cat`, where `cat` is either `AlgGrpSub` (the default) or `AlgAss`. As well as the ideal itself, the constructor returns the inclusion homomorphism $f : I \rightarrow A$.

<a id="constructor-constructor-ideal-cat-alggrp-list-alggrp-map"></a>
#### `ideal< cat : A | L>: Cat, AlgGrp, List -> AlgGrp, Map`

```magma
cat: Cat                    Default: AlgGrpSub
```

Create the (two-sided) ideal $I$ of the group algebra $A$ generated by the elements defined by $L$, where $L$ is a list as for the `sub` constructor above. The constructor returns the ideal as an element of the category `cat`, where `cat` is either `AlgGrpSub` (the default) or `AlgAss`. As well as the ideal itself, the constructor returns the inclusion homomorphism $f : I \rightarrow A$.

The above operations can also be applied with a subalgebra (type `AlgGrpSub`) $S$ in place of the group algebra $A$. In this case the subalgebra and ideal closures are taken in $S$.

<a id="operation-op-times-alggrpelt-alggrpsub"></a>
#### `a * I: AlgGrpElt, AlgGrpSub -> AlgGrpSub`

For a right ideal $I$ of the group algebra $A$ construct the right ideal $\{a * b: b \in I\}$.

<a id="operation-op-times-alggrpsub-alggrpelt"></a>
#### `I * a: AlgGrpSub, AlgGrpElt -> AlgGrpSub`

For a left ideal $I$ of the group algebra $A$ construct the left ideal $\{b * a: b \in I\}$.

<a id="constructor-constructor-quo-alggrp-list-algass-map"></a>
#### `quo< A | L >: AlgGrp, List -> AlgAss, Map`

Create the quotient of the group algebra $A$ by the ideal of $A$ generated by the elements defined by $L$, where $L$ is a list as for the `sub` constructor above. The constructor returns the quotient as an associative algebra. As well as the quotient $Q$ itself, the constructor returns the natural homomorphism $f : A \rightarrow Q$.

<a id="operation-op-div-alggrp-alggrpsub"></a>
#### `A / S: AlgGrp, AlgGrpSub -> AlgAss`

The quotient of the algebra $A$ by the ideal closure of its subalgebra $S$.

<a id="example-ex-d83263"></a>
#### `Example: Wedderburn Decomposition of a Group Algebra (ex-d83263)`

We demonstrate how the degrees of the absolutely irreducible characters of a group can be found by computing the Wedderburn decomposition of the group algebra over a suitable finite field. Of course, this is neither the smartest nor the quickest way to get this information. In the example we deal with an extraspecial group of order $3^3$.

```magma
> G := ExtraSpecialGroup(3, 1);
> Exponent(G);
3
```

We have to choose a finite field that contains the roots of unity that may be required by the absolutely irreducible characters. This is the case for $GF(q)$ if the exponent of $G$ divides $q-1$. In our example, $q=4$ or $q=7$ are possible choices.

```magma
> FG := GroupAlgebra(GF(4), G);
> FG;
Group algebra with vector representation and stored multiplication table
Coefficient ring: Finite field of size 2^2
Group: Permutation group G acting on a set of cardinality 27
    Order = 27 = 3^3
        (1, 19, 10)(2, 20, 11)(3, 21, 12)(4, 22, 13)(5, 23, 14)(6, 24, 15)(7,
            25, 16)(8, 26, 17)(9, 27, 18)
        (1, 7, 4)(2, 8, 5)(3, 9, 6)(10, 18, 14)(11, 16, 15)(12, 17, 13)(19, 26,
            24)(20, 27, 22)(21, 25, 23)
        (1, 3, 2)(4, 6, 5)(7, 9, 8)(10, 12, 11)(13, 15, 14)(16, 18, 17)(19, 21,
            20)(22, 24, 23)(25, 27, 26)
> MI := MinimalIdeals(FG);
> #MI;
11
```

The minimal ideals are the simple Wedderburn components of the group algebra, corresponding to the absolutely irreducible characters of the group, and their dimensions are the squares of the character degrees.

```magma
> [ Isqrt(Dimension(I)) : I in MI ];
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3 ]
```

Hence, there are 9 linear characters and two of degree 3 (which we might have concluded immediately from the fact that the derived quotient of $G$ has order 9).

### Operations on Group Algebras and their Subalgebras

#### Operations on Group Algebras

The operations in this section can only be applied to a full group algebra. Functions accepting also a subalgebra of type `AlgGrpSub` are dealt with in the next section.

<a id="function-algebra-alggrp"></a>
##### `Algebra(A): AlgGrp -> AlgAss, Map`

For a group algebra $A$ given in vector representation, construct the associative structure constant algebra $B$ isomorphic to $A$ together with the isomorphism $A \rightarrow B$.

<a id="function-augmentationmap-alggrp"></a>
##### `AugmentationMap(A): AlgGrp -> Map`

The augmentation map of $A$. That is, the map $A \rightarrow R : \sum_{g \in G} r_g * g \rightarrow \sum_{g \in G} r_g$.

<a id="function-augmentationideal-alggrp"></a>
##### `AugmentationIdeal(A): AlgGrp -> AlgGrpSub`

The augmentation ideal of the group algebra $A$ given in vector representation. This is defined as the kernel of the augmentation map.

<a id="function-representationtype-alggrp"></a>
##### `RepresentationType(A): AlgGrp -> MonStgElt`

Given a group algebra $A$, return either `"Vector"` or `"Terms"` depending on which representation is used for the elements of $A$.

<a id="function-changerepresentationtype-alggrp-monstgelt"></a>
##### `ChangeRepresentationType(A, Rep): AlgGrp, MonStgElt -> AlgGrp, Map`

Given a group algebra $A$, construct an isomorphic group algebra $B$ in which the elements are represented as specified by `Rep` which may be `"Vector"` or `"Terms"`, together with the homomorphism from $A$ to $B$.

<a id="procedure-constructtable-alggrp"></a>
##### `ConstructTable(A): AlgGrp`

Procedure which, given a group algebra $A = R[G]$ in vector representation, constructs the multiplication table for the group $G$ to speed up multiplication in $A$. If the multiplication table already exists, nothing is done.

<a id="function-coefficientring-alggrp"></a>
##### `CoefficientRing(A): AlgGrp -> Rng`

<a id="function-basering-alggrp"></a>
##### `BaseRing(A): AlgGrp -> Rng`

The coefficient ring (base ring) of A.

#### Operations on Subalgebras of Group Algebras

The functions in this section can be applied to group algebras and their subalgebras of type `AlgGrpSub`.

<a id="operation-op-alggrpsub"></a>
##### `S ! 1: AlgGrpSub -> Grp`

<a id="operation-op-alggrp"></a>
##### `S ! 1: AlgGrp -> Grp`

Create the identity element of the group algebra (subalgebra) $S$. Note that for a proper subalgebra of the full group algebra this may be different from the identity element of the group.

<a id="function-group-alggrpsub"></a>
##### `Group(S): AlgGrpSub -> Grp`

<a id="function-group-alggrp"></a>
##### `Group(S): AlgGrp -> Grp`

The group $G$ for the group algebra (subalgebra) $S$.

<a id="function-groupalgebra-alggrpsub"></a>
##### `GroupAlgebra(S): AlgGrpSub -> AlgGrp`

<a id="function-groupalgebra-alggrp"></a>
##### `GroupAlgebra(S): AlgGrp -> AlgGrp`

The group algebra of which $S$ is a subalgebra.

<a id="function-module-alggrpsub"></a>
##### `Module(S): AlgGrpSub -> ModTupRng, Map`

<a id="function-module-alggrp"></a>
##### `Module(S): AlgGrp -> ModTupRng, Map`

For a subalgebra $S$ of the group algebra $A = R[G]$, return the submodule of the module underlying $A$ which corresponds to $S$. This is an $R$-module of dimension `Dimension(S)` and degree `Dimension(A)`. Also returns (as a second return value) the natural map from the subalgebra to the module.

<a id="function-coefficientring-alggrpsub"></a>
##### `CoefficientRing(A): AlgGrpSub -> Rng`

<a id="function-basering-alggrpsub"></a>
##### `BaseRing(A): AlgGrpSub -> Rng`

The coefficient ring (base ring) of A.

<a id="function-basismatrix-alggrpsub"></a>
##### `BasisMatrix(S): AlgGrpSub -> ModMatRngElt`

<a id="function-basismatrix-alggrp"></a>
##### `BasisMatrix(S): AlgGrp -> ModMatRngElt`

For a subalgebra $S$ of the group algebra $A = R[G]$ return the coefficient matrix of the basis of $S$ with respect to the basis of $A$. If $S$ has dimension $m$ this is an $m \times |G|$-matrix over $R$ where the $i$-th row are the coefficients of the $i$-th basis vector of $S$ with respect to the fixed basis of $A$.

<a id="function-coordinates-alggrpsub-alggrpelt"></a>
##### `Coordinates(S, a): AlgGrpSub, AlgGrpElt -> [ RingElt ]`

<a id="function-coordinates-alggrp-alggrpelt"></a>
##### `Coordinates(S, a): AlgGrp, AlgGrpElt -> [ RingElt ]`

Given an element $a$ which lies in the subalgebra $S$, return a sequence giving the coordinates of $a$ with respect to the basis of $S$.

<a id="function-isleftideal-alggrpsub"></a>
##### `IsLeftIdeal(S): AlgGrpSub -> BoolElt`

<a id="function-isleftideal-alggrp"></a>
##### `IsLeftIdeal(S): AlgGrp -> BoolElt`

Returns `true` if $S$ is a left ideal of its group algebra; otherwise `false`.

<a id="function-isrightideal-alggrpsub"></a>
##### `IsRightIdeal(S): AlgGrpSub -> BoolElt`

<a id="function-isrightideal-alggrp"></a>
##### `IsRightIdeal(S): AlgGrp -> BoolElt`

Returns `true` if $S$ is a right ideal of its group algebra; otherwise `false`.

<a id="function-isideal-alggrpsub"></a>
##### `IsIdeal(S): AlgGrpSub -> BoolElt`

<a id="function-isideal-alggrp"></a>
##### `IsIdeal(S): AlgGrp -> BoolElt`

Returns `true` if $S$ is a (two-sided) ideal of its group algebra; otherwise `false`.

<a id="function-centraliser-alggrpsub"></a>
##### `Centraliser(S): AlgGrpSub -> AlgGrpSub`

<a id="function-centralizer-alggrpsub"></a>
##### `Centralizer(S): AlgGrpSub -> AlgGrpSub`

<a id="function-centraliser-alggrp"></a>
##### `Centraliser(S): AlgGrp -> AlgGrpSub`

<a id="function-centralizer-alggrp"></a>
##### `Centralizer(S): AlgGrp -> AlgGrpSub`

The centralizer of the subalgebra $S$ of a group algebra $A$ (in $A$).

<a id="function-idealiser-alggrpsub"></a>
##### `Idealiser(S): AlgGrpSub -> AlgGrpSub`

<a id="function-idealizer-alggrpsub"></a>
##### `Idealizer(S): AlgGrpSub -> AlgGrpSub`

<a id="function-idealiser-alggrp"></a>
##### `Idealiser(S): AlgGrp -> AlgGrpSub`

<a id="function-idealizer-alggrp"></a>
##### `Idealizer(S): AlgGrp -> AlgGrpSub`

The largest subalgebra $T$ of $A$ such that $S$ is an ideal in $T$.

<a id="function-leftannihilator-alggrpsub"></a>
##### `LeftAnnihilator(S): AlgGrpSub -> AlgGrpSub`

<a id="function-leftannihilator-alggrp"></a>
##### `LeftAnnihilator(S): AlgGrp -> AlgGrpSub`

For a subalgebra $S$ of the group algebra $A$ construct the left annihilator of $S$, that is, the subalgebra of $A$ consisting of all elements $a$ such that $a*s = 0$ for all $s \in S$.

<a id="function-rightannihilator-alggrpsub"></a>
##### `RightAnnihilator(S): AlgGrpSub -> AlgGrpSub`

<a id="function-rightannihilator-alggrp"></a>
##### `RightAnnihilator(S): AlgGrp -> AlgGrpSub`

For a subalgebra $S$ of the group algebra $A$ construct the right annihilator of $S$, that is, the subalgebra of $A$ consisting of all elements $a$ such that $s*a = 0$ for all $s \in S$.

<a id="example-ex-71b601"></a>
##### `Example: Jacobson Radical of a Group Algebra (ex-71b601)`

We construct the group algebra of an elementary abelian group over $GF(2)$ and get its Jacobson ideal.

```magma
> A := AbelianGroup([2,2,2,2,2]);
> FG := GroupAlgebra(GF(2), A);
> J := JacobsonRadical(FG);
> J;
Ideal of dimension 31 of the group algebra FG
```

We now check that the Jacobson radical is nilpotent and get its nilpotency class.

```magma
> JPow := [ J ];
> I := J;
> while Dimension(I) ne 0 do
>     I := I*J;
>     Append(~JPow, I);
> end while;
> [ Dimension(I) : I in JPow ];
[ 31, 26, 16, 6, 1, 0 ]
```

Thus, $J$ is nilpotent of class 6. However, every non-zero element of $J$ is of course nilpotent of class 2.

```magma
> IsNilpotent(Random(J));
true 2
```

### Operations on Elements

The operations in this section can be applied to elements of either a group algebra or of a group algebra subalgebra of type `AlgGrpSub`. Only those operations are listed, which are additional to those available for general algebras.

<a id="operation-op-plus-alggrpelt-rngelt"></a>
#### `a + r: AlgGrpElt, RngElt -> AlgGrpElt`

<a id="operation-op-plus-rngelt-alggrpelt"></a>
#### `r + a: RngElt, AlgGrpElt -> AlgGrpElt`

The sum of the group algebra element $a \in R[G]$ and the scalar $r \in R$.

<a id="operation-op-plus-alggrpelt-grpelt"></a>
#### `a + g: AlgGrpElt, GrpElt -> AlgGrpElt`

<a id="operation-op-plus-grpelt-alggrpelt"></a>
#### `g + a: GrpElt, AlgGrpElt -> AlgGrpElt`

The sum of the group algebra element $a \in R[G]$ and the group element $g \in G$.

<a id="operation-op-minus-alggrpelt-rngelt"></a>
#### `a - r: AlgGrpElt, RngElt -> AlgGrpElt`

<a id="operation-op-minus-rngelt-alggrpelt"></a>
#### `r - a: RngElt, AlgGrpElt -> AlgGrpElt`

The difference of the group algebra element $a \in R[G]$ and the scalar $r \in R$.

<a id="operation-op-minus-alggrpelt-grpelt"></a>
#### `a - g: AlgGrpElt, GrpElt -> AlgGrpElt`

<a id="operation-op-minus-grpelt-alggrpelt"></a>
#### `g - a: GrpElt, AlgGrpElt -> AlgGrpElt`

The difference of the group algebra element $a \in R[G]$ and the group element $g \in G$.

<a id="operation-op-times-alggrpelt-rngelt"></a>
#### `a * r: AlgGrpElt, RngElt -> AlgGrpElt`

<a id="operation-op-times-rngelt-alggrpelt"></a>
#### `r * a: RngElt, AlgGrpElt -> AlgGrpElt`

The product of the group algebra element $a \in R[G]$ and the scalar $r \in R$.

<a id="operation-op-times-grpelt-alggrpelt"></a>
#### `g * a: GrpElt, AlgGrpElt -> AlgGrpElt`

<a id="operation-op-times-alggrpelt-grpelt"></a>
#### `a * g: AlgGrpElt, GrpElt -> AlgGrpElt`

The product of the group algebra element $a \in R[G]$ and the group element $g \in G$.

<a id="function-support-alggrpelt"></a>
#### `Support(a): AlgGrpElt -> SeqEnum`

The support of $a$; that is, the sequence of group elements whose coefficients in $a$ are non-zero.

<a id="function-trace-alggrpelt"></a>
#### `Trace(a): AlgGrpElt -> RngElt`

The trace of $a$; that is, the coefficient of $1_G$ in $a$.

<a id="function-augmentation-alggrpelt"></a>
#### `Augmentation(a): AlgGrpElt -> RngElt`

The augmentation of the group algebra element $a$; that is, $\sum_{g \in G} r_g$ where $a = \sum_{g \in G} r_g * g$.

<a id="function-involution-alggrpelt"></a>
#### `Involution(a): AlgGrpElt -> AlgGrpElt`

If $a = \sum_{g \in G} r_g * g$, returns $\sum_{g \in G} r_g * g^{-1}$.

<a id="function-coefficient-alggrpelt-grpelt"></a>
#### `Coefficient(a, g): AlgGrpElt, GrpElt -> RngElt`

<a id="indexed-indexed-a-alggrpelt-grpelt-rngelt"></a>
#### `a[g]: AlgGrpElt, GrpElt -> RngElt`

The coefficient of $g \in G$ in $a \in R[G]$.

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

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

If $a$ is an element from a group algebra $A$ given in vector representation, this returns the sequence of coefficients with respect to the fixed basis of $A$. If $A$ is given in terms representation, this returns a sequence of tuples, where the second entry is a group element and the first is the coefficient of that group element in $a$.

<a id="function-coefficients-alggrpelt"></a>
#### `Coefficients(a): AlgGrpElt -> SeqEnum`

For an element $a$ from a group algebra $A$ given in vector representation, this returns the sequence of coefficients with respect to the fixed basis of $A$.

<a id="function-centraliser-alggrpelt"></a>
#### `Centraliser(a): AlgGrpElt -> AlgGrpSub`

<a id="function-centralizer-alggrpelt"></a>
#### `Centralizer(a): AlgGrpElt -> AlgGrpSub`

The centralizer in the group algebra $A$ of the element $a$ of $A$.

<a id="function-centraliser-alggrpsub-alggrpelt"></a>
#### `Centraliser(S, a): AlgGrpSub, AlgGrpElt -> AlgGrpSub`

<a id="function-centralizer-alggrpsub-alggrpelt"></a>
#### `Centralizer(S, a): AlgGrpSub, AlgGrpElt -> AlgGrpSub`

The centralizer of the element $a$ (of a group algebra $A$) in the subalgebra $S$ of $A$.

<a id="example-ex-76435e"></a>
#### `Example: Diameter of a Cayley Graph (ex-76435e)`

We use the group algebra to determine the diameter of the Cayley graph of a group.

```magma
> G := Alt(6);
> QG := GroupAlgebra( Rationals(), G );
> e := QG!1 + &+[ QG!g : g in Generators(G) ];
> e;
Id(G) + (1, 2)(3, 4, 5, 6) + (1, 2, 3)
```

The group elements that can be expressed as words of length at most $n$ in the generators of $G$ have non-zero coefficient in $e^n$. The following function returns for a group algebra element $e$ a sequence with the cardinalities of the supports of $e^n$ and breaks when the group order is reached.

```magma
> wordcount := function(e)
>     f := e;
>     count := [ #Support(f) ];
>     while count[#count] lt #Group(Parent(e)) do
>         f *:= e;
>         Append(~count, #Support(f));
>     end while;
>     return count;
> end function;
```

Now apply this function to the above defined element:

```magma
> wordcount( e );
[ 3, 7, 14, 26, 47, 83, 140, 219, 293, 345, 360 ]
```

Thus, every element in $A_6$ can be expressed as a word of length at most 11 in the generators $(1,2)(3,4,5,6)$ and $(1,2,3)$. A better 2-generator set is for example $(1,2,3,4,5)$ and $(1,5,3,6,4)$, where all elements can be expressed as words of length at most 10 and this is in fact optimal. A worst 2-generator set is given by $(1,2)(3,4)$ and $(1,5,3,2)(4,6)$.

```magma
> wordcount( QG!1 + G!(1,2,3,4,5) + G!(1,5,3,6,4) );
[ 3, 7, 15, 31, 60, 109, 183, 274, 350, 360 ]
> wordcount( QG!1 + G!(1,2)(3,4) + G!(1,5,3,2)(4,6) );
[ 3, 6, 11, 18, 28, 43, 63, 88, 119, 158, 206, 255, 297, 329, 352, 360 ]
```

<a id="example-ex-1a2ff9"></a>
#### `Example: Random Distribution of Words (ex-1a2ff9)`

The group algebra can also be used to investigate the random distribution of words of a certain length in the generators of the group.

```magma
> M11 := sub< Sym(11) | (1,11,9,10,4,3,7,2,6,5,8), (1,5,6,3,4,2,7,11,9,10,8) >;
> A := GroupAlgebra(RealField(16), M11 : Rep := "Vector");
> A;
Group algebra with vector representation
Coefficient ring: Real Field of precision 16
Group: Permutation group M11 acting on a set of cardinality 11
    Order = 7920 = 2^4 * 3^2 * 5 * 11
        (1, 11, 9, 10, 4, 3, 7, 2, 6, 5, 8)
        (1, 5, 6, 3, 4, 2, 7, 11, 9, 10, 8)
> e := (A!M11.1 + A!M11.2) / 2.0;
> eta := Eta(A) / #M11;
```

For growing $n$, the words of length $n$ in the generators of `M11` converge towards a random distribution iff `e`$^n$ converges towards `eta`. We look at the quadratic differences of the coefficients of `e^n-eta` for $n = 10,20,30,40,50$.

```magma
> e10 := e^10;
> f := A!1;
> for i in [1..5] do
>     f *:= e10;
>     print &+[ c^2 : c in Eltseq(f - eta) ];
> end for;
0.0012050667195213
1.289719354694155e-5
5.9390965208879e-7
3.394099291966e-8
2.19432454574986e-9
```

<a id="basic"></a>
<a id="algbas-chap"></a>
## Basic Algebras

- [Introduction](https://docs.magma-maths.org/Algebras/BasicAlgebras/introduction.md)
- [Basic Algebras](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md)
  - [Creation](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#creation)
    - [`BasicAlgebra(Q): SeqEnum[Tup] → AlgBas`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#function-basicalgebra-seqenum-tup)
    - [`BasicAlgebra(F,R,s,P): AlgFr, SeqEnum, RngIntElt, SeqEnum → AlgBas`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#function-basicalgebra-algfr-seqenum-rngintelt-seqenum)
    - [`BasicAlgebra(F,R): AlgFr, SeqEnum → AlgBas`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#function-basicalgebra-algfr-seqenum)
    - [`TensorProduct(A, B): AlgBas, AlgBas → AlgBas`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#function-tensorproduct-algbas-algbas)
    - [`BasicAlgebra(G, k): GrpPerm, FldFin → AlgBas`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#function-basicalgebra-grpperm-fldfin)
    - [`BasicAlgebra(G, k): GrpPC, FldFin → AlgBas`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#function-basicalgebra-grppc-fldfin)
    - [`BasicAlgebra(G): GrpPerm → AlgBass`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#function-basicalgebra-grpperm)
  - [Special Basic Algebras](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#special-basic-algebras)
    - [`BasicAlgebra(A): AlgMat → AlgBas`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#function-basicalgebra-algmat)
    - [`BasicAlgebraOfMatrixAlgebra(A): AlgMat → AlgBas`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#function-basicalgebraofmatrixalgebra-algmat)
    - [`BasicAlgebraOfEndomorphismAlgebra(M): ModRng → AlgBas`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#function-basicalgebraofendomorphismalgebra-modrng)
    - [`BasicAlgebraOfHeckeAlgebra(G, H, F): GrpPerm, GrpPerm, FldFin → AlgBas`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#function-basicalgebraofheckealgebra-grpperm-grpperm-fldfin)
    - [`BasicAlgebraOfHeckeAlgebra(G, H, F): GrpPC, GrpPC, FldFin → AlgBas`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#function-basicalgebraofheckealgebra-grppc-grppc-fldfin)
    - [`BasicAlgebraOfHeckeAlgebra(G, H, F): GrpAb, GrpAb, FldFin → AlgBas`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#function-basicalgebraofheckealgebra-grpab-grpab-fldfin)
    - [`BasicAlgebraOfSchurAlgebra(n, r, F): RngIntElt, RngIntElt, FldFin → AlgBas`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#function-basicalgebraofschuralgebra-rngintelt-rngintelt-fldfin)
    - [`BasicAlgebraOfGroupAlgebra(G,F): GrpPerm, FldFin → AlgBas`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#function-basicalgebraofgroupalgebra-grpperm-fldfin)
    - [`BasicAlgebraOfGroupAlgebra(G,F): GrpPC, FldFin → AlgBas`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#function-basicalgebraofgroupalgebra-grppc-fldfin)
    - [`BasicAlgebraOfGroupAlgebra(G,F): GrpAb, FldFin → AlgBas`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#function-basicalgebraofgroupalgebra-grpab-fldfin)
    - [`BasicAlgebra(S): SeqEnum → AlgBas`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#function-basicalgebra-seqenum)
    - [`BasicAlgebraOfBlockAlgebra(S): SeqEnum → AlgBas`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#function-basicalgebraofblockalgebra-seqenum)
    - [`BasicAlgebraOfPrincipalBlock(G,k): GrpPerm, FldFin → AlgBas`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#function-basicalgebraofprincipalblock-grpperm-fldfin)
    - [`BasicAlgebraOfExtAlgebra(A): AlgBas → AlgBas`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#function-basicalgebraofextalgebra-algbas)
    - [`BasicAlgebraOfExtAlgebra(A, n): AlgBas, RngIntElt → AlgBas`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#function-basicalgebraofextalgebra-algbas-rngintelt)
    - [`BasicAlgebraOfExtAlgebra(A): Rec → AlgBas`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#function-basicalgebraofextalgebra-rec)
    - [`OppositeAlgebra(B): AlgBas → AlgBas`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#function-oppositealgebra-algbas)
    - [Example: Basic Algebra of an Alternating Group Algebra](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#example-ex-cb7ecb)
    - [Example: Basic Algebra of a Schur Algebra](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#example-ex-8e74b4)
  - [A Database of Basic Algebras](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#a-database-of-basic-algebras)
    - [`BasicAlgebraFromGroup(A, p, b): MonStgElt, RngIntElt, RngIntElt → AlgBas`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#function-basicalgebrafromgroup-monstgelt-rngintelt-rngintelt)
    - [`BasicAlgebraGroupNames() → SetIndx`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#function-basicalgebragroupnames)
    - [`BasicAlgebraFromSchur(n, r, p): RngIntElt, RngIntElt, RngIntElt → AlgBas`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#function-basicalgebrafromschur-rngintelt-rngintelt-rngintelt)
    - [Example: Basic Algebra of an Atlas Group Block](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#example-ex-9fefcd)
  - [Access Functions](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#access-functions)
    - [`B . i: AlgBas, RngIntElt → AlgBasElt`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#operation-operation-algbas-rngintelt-algbaselt)
    - [`BaseRing(B): AlgBas → Rng`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#function-basering-algbas)
    - [`CoefficientRing(B): AlgBas → Rng`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#function-coefficientring-algbas)
    - [`VectorSpace(B): AlgBas → ModTupFld`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#function-vectorspace-algbas)
    - [`KSpace(B): AlgBas → ModTupFld`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#function-kspace-algbas)
    - [`Dimension(B): AlgBas → RngIntElt`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#function-dimension-algbas)
    - [`Basis(B): AlgBas → SeqEnum`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#function-basis-algbas)
    - [`Generators(B): AlgBas → SeqEnum`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#function-generators-algbas)
    - [`IdempotentGenerators(B): AlgBas → SeqEnum`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#function-idempotentgenerators-algbas)
    - [`IdempotentPositions(B): AlgBas → SeqEnum`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#function-idempotentpositions-algbas)
    - [`NonIdempotentGenerators(B): AlgBas → SeqEnum`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#function-nonidempotentgenerators-algbas)
    - [`Random(B): AlgBas → AlgBasElt`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#function-random-algbas)
    - [`NumberOfProjectives(B): AlgBas → RngIntElt`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#function-numberofprojectives-algbas)
    - [`NumberOfGenerators(B): AlgBas → RngIntElt`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#function-numberofgenerators-algbas)
    - [`Ngens(B): AlgBas → RngIntElt`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#function-ngens-algbas)
    - [`DimensionsOfProjectiveModules(B): AlgBas → SeqEnum`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#function-dimensionsofprojectivemodules-algbas)
    - [`DimensionsOfInjectiveModules(B): AlgBas → SeqEnum`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#function-dimensionsofinjectivemodules-algbas)
  - [Elementary Operations](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#elementary-operations)
    - [`a + b: AlgBasElt, AlgBasElt → AlgBasElt`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#operation-op-plus-algbaselt-algbaselt)
    - [`a * b: AlgBasElt, AlgBasElt → AlgBasElt`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#operation-op-times-algbaselt-algbaselt)
    - [`a ^ n: AlgBasElt, RngIntElt → AlgBasElt`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#operation-op-pow-algbaselt-rngintelt)
    - [Example: Basic Algebra of a Quiver](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#example-ex-49b24a)
    - [Example: Basic Algebra of S3 in Characteristic 3](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#example-ex-bfaaa4)
    - [Example: Basic Algebra of A4 from Projective Modules](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#example-ex-cfd0f2)
  - [Boolean Functions](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#boolean-functions)
    - [`IsDimensionCompatible(B): AlgBas → Bool`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#function-isdimensioncompatible-algbas)
    - [`IsPathTree(B): AlgBas → Bool`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#function-ispathtree-algbas)
    - [Commutativity](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#commutativity)
      - [`IsCommutative(A): AlgBas → Bool`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#function-iscommutative-algbas)
      - [`IsCentral(A,x): AlgBas, AlgBasElt → BoolElt`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#function-iscentral-algbas-algbaselt)
    - [Other Properties](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#other-properties)
      - [`IsSymmetric(A): AlgBas → BoolElt`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#function-issymmetric-algbas)
      - [`IsSelfInjective(A): AlgBas → BoolElt`](https://docs.magma-maths.org/Algebras/BasicAlgebras/algebras.md#function-isselfinjective-algbas)
- [Homomorphisms](https://docs.magma-maths.org/Algebras/BasicAlgebras/homomorphisms-algebras.md)
  - [`hom<A -> B | S>: AlgBas, AlgBas, ModMatFldElt → Map`](https://docs.magma-maths.org/Algebras/BasicAlgebras/homomorphisms-algebras.md#constructor-constructor-hom-algbas-algbas-modmatfldelt-map)
  - [`Kernel(phi): Map → ModTupFld`](https://docs.magma-maths.org/Algebras/BasicAlgebras/homomorphisms-algebras.md#function-kernel-map)
  - [`Image(phi): Map → AlgBas, Map`](https://docs.magma-maths.org/Algebras/BasicAlgebras/homomorphisms-algebras.md#function-image-map)
  - [`IsAlgebraHomomorphism(A, B, psi): AlgBas, AlgBas, Mtrx → Bool`](https://docs.magma-maths.org/Algebras/BasicAlgebras/homomorphisms-algebras.md#function-isalgebrahomomorphism-algbas-algbas-mtrx)
  - [`X * Y: Map, Map → Map`](https://docs.magma-maths.org/Algebras/BasicAlgebras/homomorphisms-algebras.md#operation-op-times-map-map)
  - [`IsAlgebraHomomorphism(A, B, psi): AlgBas, AlgBas, Map → Bool`](https://docs.magma-maths.org/Algebras/BasicAlgebras/homomorphisms-algebras.md#function-isalgebrahomomorphism-algbas-algbas-map)
  - [`IsAlgebraHomomorphism(A, B, psi): AlgBasGrpP, AlgBasGrpP, Map → Bool`](https://docs.magma-maths.org/Algebras/BasicAlgebras/homomorphisms-algebras.md#function-isalgebrahomomorphism-algbasgrpp-algbasgrpp-map)
  - [`IsAlgebraHomomorphism(A, B, psi): AlgBasGrpP, AlgBas, Map → Bool`](https://docs.magma-maths.org/Algebras/BasicAlgebras/homomorphisms-algebras.md#function-isalgebrahomomorphism-algbasgrpp-algbas-map)
  - [`IsAlgebraHomomorphism(A, B, psi): AlgBas, AlgBasGrpP, Map → Bool`](https://docs.magma-maths.org/Algebras/BasicAlgebras/homomorphisms-algebras.md#function-isalgebrahomomorphism-algbas-algbasgrpp-map)
  - [`IsAlgebraHomomorphism(psi): Map → Bool`](https://docs.magma-maths.org/Algebras/BasicAlgebras/homomorphisms-algebras.md#function-isalgebrahomomorphism-map)
- [Subalgebras and Quotient Algebras](https://docs.magma-maths.org/Algebras/BasicAlgebras/sub-quo.md)
  - [Subalgebras and their Constructions](https://docs.magma-maths.org/Algebras/BasicAlgebras/sub-quo.md#subalgebras-and-their-constructions)
    - [`sub<A | S>: AlgBas, SeqEnum → AlgBas, Map`](https://docs.magma-maths.org/Algebras/BasicAlgebras/sub-quo.md#constructor-constructor-sub-algbas-seqenum-algbas-map)
    - [`SubalgebraFromBasis(A, V): AlgBas, SeqEnum → AlgBas, Map`](https://docs.magma-maths.org/Algebras/BasicAlgebras/sub-quo.md#function-subalgebrafrombasis-algbas-seqenum)
    - [`MaximalIdempotent(A, S): AlgBas, SeqEnum → AlgBasElt`](https://docs.magma-maths.org/Algebras/BasicAlgebras/sub-quo.md#function-maximalidempotent-algbas-seqenum)
    - [`MinimalIdentity(A, S): AlgBas, SeqEnum[AlgBasElt] → AlgBasElt`](https://docs.magma-maths.org/Algebras/BasicAlgebras/sub-quo.md#function-minimalidentity-algbas-seqenum-algbaselt)
    - [`Centre(A): AlgBas → AlgBas, Map`](https://docs.magma-maths.org/Algebras/BasicAlgebras/sub-quo.md#function-centre-algbas)
    - [`Centralizer(A,S): AlgBas, SeqEnum → AlgBas, Map`](https://docs.magma-maths.org/Algebras/BasicAlgebras/sub-quo.md#function-centralizer-algbas-seqenum)
    - [`MaximalCommutativeSubalgebra(A,S): AlgBas, SeqEnum → AlgBas, Map`](https://docs.magma-maths.org/Algebras/BasicAlgebras/sub-quo.md#function-maximalcommutativesubalgebra-algbas-seqenum)
  - [Ideals and their Construction](https://docs.magma-maths.org/Algebras/BasicAlgebras/sub-quo.md#ideals-and-their-construction)
    - [`ideal< A | S>: AlgBas, SeqEnum[AlgBasElt] → ModTupFld`](https://docs.magma-maths.org/Algebras/BasicAlgebras/sub-quo.md#constructor-constructor-ideal-algbas-seqenum-algbaselt-modtupfld)
    - [`ideal< A | S>: AlgBasGrpP, SeqEnum[AlgBasElt] → ModTupFld`](https://docs.magma-maths.org/Algebras/BasicAlgebras/sub-quo.md#constructor-constructor-ideal-algbasgrpp-seqenum-algbaselt-modtupfld)
    - [`LeftAnnihilator(A, S): AlgBas, SeqEnum[AlgBasElt] → SeqEnum[AlgBasElt]`](https://docs.magma-maths.org/Algebras/BasicAlgebras/sub-quo.md#function-leftannihilator-algbas-seqenum-algbaselt)
    - [`RightAnnihilator(A, S): AlgBas, SeqEnum[AlgBasElt] → SeqEnum[AlgBaselt]`](https://docs.magma-maths.org/Algebras/BasicAlgebras/sub-quo.md#function-rightannihilator-algbas-seqenum-algbaselt)
    - [`Annihilator(A,S): AlgBas, SeqEnum[AlgBasElt] → SeqEnum[AlgBasElt]`](https://docs.magma-maths.org/Algebras/BasicAlgebras/sub-quo.md#function-annihilator-algbas-seqenum-algbaselt)
    - [`IsIdeal(A, S): AlgBas, ModTupFld → Bool`](https://docs.magma-maths.org/Algebras/BasicAlgebras/sub-quo.md#function-isideal-algbas-modtupfld)
    - [`IsLeftIdeal(A,S): AlgBas, ModTupFld → Bool`](https://docs.magma-maths.org/Algebras/BasicAlgebras/sub-quo.md#function-isleftideal-algbas-modtupfld)
    - [`IsRightIdeal(A, S): AlgBas, ModTupFld → Bool`](https://docs.magma-maths.org/Algebras/BasicAlgebras/sub-quo.md#function-isrightideal-algbas-modtupfld)
    - [`RandomIdealGeneratedBy(A, n): AlgBas, RngIntElt → ModTupFld`](https://docs.magma-maths.org/Algebras/BasicAlgebras/sub-quo.md#function-randomidealgeneratedby-algbas-rngintelt)
  - [Quotient Algebras](https://docs.magma-maths.org/Algebras/BasicAlgebras/sub-quo.md#quotient-algebras)
    - [`quo<A | S>: AlgBas, ModTupFld → AlgBas, Map`](https://docs.magma-maths.org/Algebras/BasicAlgebras/sub-quo.md#constructor-constructor-quo-algbas-modtupfld-algbas-map)
    - [`CoverAlgebra(A): AlgBas → AlgBas, ModMatFldElt`](https://docs.magma-maths.org/Algebras/BasicAlgebras/sub-quo.md#function-coveralgebra-algbas)
    - [`GradedCoverAlgebra(A): AlgBas → AlgBas, ModMatFldElt`](https://docs.magma-maths.org/Algebras/BasicAlgebras/sub-quo.md#function-gradedcoveralgebra-algbas)
    - [`TruncatedAlgebra(A, n): AlgBas, RngIntElt → AlgBas, ModMatFldElt`](https://docs.magma-maths.org/Algebras/BasicAlgebras/sub-quo.md#function-truncatedalgebra-algbas-rngintelt)
  - [Units](https://docs.magma-maths.org/Algebras/BasicAlgebras/sub-quo.md#units)
    - [`GeneratorsOfGroupOfUnits(A): AlgBas → SeqEnum, SeqEnum`](https://docs.magma-maths.org/Algebras/BasicAlgebras/sub-quo.md#function-generatorsofgroupofunits-algbas)
    - [`NoncentralGeneratorsOfGroupOfUnits(A): AlgBas → SeqEnum, SeqEnum`](https://docs.magma-maths.org/Algebras/BasicAlgebras/sub-quo.md#function-noncentralgeneratorsofgroupofunits-algbas)
- [Minimal Forms and Gradings](https://docs.magma-maths.org/Algebras/BasicAlgebras/forms-gradings-permute-idempotents.md)
  - [`MinimalGeneratorForm(A): AlgBas → Rec`](https://docs.magma-maths.org/Algebras/BasicAlgebras/forms-gradings-permute-idempotents.md#function-minimalgeneratorform-algbas)
  - [`MinimalGeneratorFormAlgebra(A): AlgBas → AlgBas`](https://docs.magma-maths.org/Algebras/BasicAlgebras/forms-gradings-permute-idempotents.md#function-minimalgeneratorformalgebra-algbas)
  - [`AssociatedGradedAlgebra(A): AlgBas → AlgBas`](https://docs.magma-maths.org/Algebras/BasicAlgebras/forms-gradings-permute-idempotents.md#function-associatedgradedalgebra-algbas)
  - [`GradedCapHomomorphism(A): AlgBas → ModMatFldElt`](https://docs.magma-maths.org/Algebras/BasicAlgebras/forms-gradings-permute-idempotents.md#function-gradedcaphomomorphism-algbas)
  - [`GradedCapHomomorphism(A, B, mu): AlgBas, AlgBas, ModMatFldElt → ModMatFldElt`](https://docs.magma-maths.org/Algebras/BasicAlgebras/forms-gradings-permute-idempotents.md#function-gradedcaphomomorphism-algbas-algbas-modmatfldelt)
  - [`BuildHomomorphismFromGradedCap(A, B, phi): AlgBas, AlgBas, ModMatFldElt → ModMatFldElt`](https://docs.magma-maths.org/Algebras/BasicAlgebras/forms-gradings-permute-idempotents.md#function-buildhomomorphismfromgradedcap-algbas-algbas-modmatfldelt)
  - [`ChangeIdempotents(A, S): AlgBas, SeqEnum → AlgBas, Map`](https://docs.magma-maths.org/Algebras/BasicAlgebras/forms-gradings-permute-idempotents.md#function-changeidempotents-algbas-seqenum)
  - [`ChangeIdempotents(A, S): AlgBas, GrpPermElt → AlgBas, Map`](https://docs.magma-maths.org/Algebras/BasicAlgebras/forms-gradings-permute-idempotents.md#function-changeidempotents-algbas-grppermelt)
  - [Example: Graded Properties of a Schur Algebra](https://docs.magma-maths.org/Algebras/BasicAlgebras/forms-gradings-permute-idempotents.md#example-ex-804d0a)
  - [Example: Reordering Primitive Idempotents](https://docs.magma-maths.org/Algebras/BasicAlgebras/forms-gradings-permute-idempotents.md#example-ex-27c999)
- [Automorphisms and Isomorphisms](https://docs.magma-maths.org/Algebras/BasicAlgebras/automorphism.md)
  - [`GradedAutomorphismGroupMatchingIdempotents(A): AlgBas → GrpMat, SeqEnum, SecEnum`](https://docs.magma-maths.org/Algebras/BasicAlgebras/automorphism.md#function-gradedautomorphismgroupmatchingidempotents-algbas)
  - [`GradedAutomorphismGroup(A): AlgBas → GrpMat, SeqEnum[ModMatFldElt], SeqEnum[ModMatFldElt], SeqEnum[ModMatFldElt]`](https://docs.magma-maths.org/Algebras/BasicAlgebras/automorphism.md#function-gradedautomorphismgroup-algbas)
  - [`IsGradedIsomorphic(A, B): AlgBas, AlgBas → Bool, ModMatFldElt`](https://docs.magma-maths.org/Algebras/BasicAlgebras/automorphism.md#function-isgradedisomorphic-algbas-algbas)
  - [`AutomorphismGroupMatchingIdempotents(A): AlgBas → AlgBas, ModMatFldElt`](https://docs.magma-maths.org/Algebras/BasicAlgebras/automorphism.md#function-automorphismgroupmatchingidempotents-algbas)
  - [`AutomorphismGroup(A): AlgBas → GrpMat, SeqEnum, SeqEnum, SeqEnum`](https://docs.magma-maths.org/Algebras/BasicAlgebras/automorphism.md#function-automorphismgroup-algbas)
  - [`InnerAutomorphismGroup(A): AlgBas → GrpMat`](https://docs.magma-maths.org/Algebras/BasicAlgebras/automorphism.md#function-innerautomorphismgroup-algbas)
  - [`IsIsomorphic(A, B): AlgBas, AlgBas → Bool, Map`](https://docs.magma-maths.org/Algebras/BasicAlgebras/automorphism.md#function-isisomorphic-algbas-algbas)
  - [Example: Automorphism Group of a Group Algebra](https://docs.magma-maths.org/Algebras/BasicAlgebras/automorphism.md#example-ex-4a1204)
  - [Example: Changing a Presentation](https://docs.magma-maths.org/Algebras/BasicAlgebras/automorphism.md#example-ex-1b7b38)
  - [Example: Graded Group Algebras of Order 32](https://docs.magma-maths.org/Algebras/BasicAlgebras/automorphism.md#example-ex-ac24e3)
- [Quiver and Relations](https://docs.magma-maths.org/Algebras/BasicAlgebras/quiver.md)
  - [`Quiver(A): AlgBas → SeqEnum`](https://docs.magma-maths.org/Algebras/BasicAlgebras/quiver.md#function-quiver-algbas)
  - [`QuiverAndRelations(A): AlgBas → SeqEnum, SeqEnum, SeqEnum`](https://docs.magma-maths.org/Algebras/BasicAlgebras/quiver.md#function-quiverandrelations-algbas)
  - [Example: Quiver of the Principal Block of A7](https://docs.magma-maths.org/Algebras/BasicAlgebras/quiver.md#example-ex-3af24d)
- [Modules over Basic Algebras](https://docs.magma-maths.org/Algebras/BasicAlgebras/modules.md)
  - [Indecomposable Projective Modules](https://docs.magma-maths.org/Algebras/BasicAlgebras/modules.md#indecomposable-projective-modules)
    - [`ProjectiveModule(B, i): AlgBas, RngIntElt → ModRng`](https://docs.magma-maths.org/Algebras/BasicAlgebras/modules.md#function-projectivemodule-algbas-rngintelt)
    - [`PathTree(B, i): AlgBas, RngIntElt → ModRng`](https://docs.magma-maths.org/Algebras/BasicAlgebras/modules.md#function-pathtree-algbas-rngintelt)
    - [`ActionGenerator(B, i): AlgBas, RngIntElt → SeqEnum`](https://docs.magma-maths.org/Algebras/BasicAlgebras/modules.md#function-actiongenerator-algbas-rngintelt)
    - [`IdempotentActionGenerators(B, i): AlgBas, RngIntElt → SeqEnum`](https://docs.magma-maths.org/Algebras/BasicAlgebras/modules.md#function-idempotentactiongenerators-algbas-rngintelt)
    - [`NonIdempotentActionGenerators(B, i): AlgBas, RngIntElt → SeqEnum`](https://docs.magma-maths.org/Algebras/BasicAlgebras/modules.md#function-nonidempotentactiongenerators-algbas-rngintelt)
    - [`Injection(B, i, v): AlgBas, RngIntElt, ModRngElt → AlgBasElt`](https://docs.magma-maths.org/Algebras/BasicAlgebras/modules.md#function-injection-algbas-rngintelt-modrngelt)
  - [Creation](https://docs.magma-maths.org/Algebras/BasicAlgebras/modules.md#creation)
    - [`AModule(B, Q): AlgBas, SeqEnum[AlgMatElt] → ModRng`](https://docs.magma-maths.org/Algebras/BasicAlgebras/modules.md#function-amodule-algbas-seqenum-algmatelt)
    - [`ProjectiveModule(B, S): AlgBas, SeqEnum[RngIntElt] → ModAlg, SeqEnum, SeqEnum`](https://docs.magma-maths.org/Algebras/BasicAlgebras/modules.md#function-projectivemodule-algbas-seqenum-rngintelt)
    - [`IrreducibleModule(B, i): AlgBas, RngIntElt → ModAlg`](https://docs.magma-maths.org/Algebras/BasicAlgebras/modules.md#function-irreduciblemodule-algbas-rngintelt)
    - [`SimpleModule(B, i): AlgBas, RngIntElt → ModAlg`](https://docs.magma-maths.org/Algebras/BasicAlgebras/modules.md#function-simplemodule-algbas-rngintelt)
    - [`ZeroModule(B): AlgBas → ModAlg`](https://docs.magma-maths.org/Algebras/BasicAlgebras/modules.md#function-zeromodule-algbas)
    - [`RightRegularModule(B): AlgBas → ModAlg`](https://docs.magma-maths.org/Algebras/BasicAlgebras/modules.md#function-rightregularmodule-algbas)
    - [`RegularRepresentation(v): AlgBasElt → AlgMatElt`](https://docs.magma-maths.org/Algebras/BasicAlgebras/modules.md#function-regularrepresentation-algbaselt)
    - [`Restriction(M, B, xi): ModAlgBas, AlgBas, ModMatFldElt → ModAlgBas`](https://docs.magma-maths.org/Algebras/BasicAlgebras/modules.md#function-restriction-modalgbas-algbas-modmatfldelt)
    - [`ChangeAlgebra(M, B, xi): ModAlgBas, AlgBas, Map → ModAlgBas`](https://docs.magma-maths.org/Algebras/BasicAlgebras/modules.md#function-changealgebra-modalgbas-algbas-map)
    - [`ChangeAlgebra(M, B, xi): ModAlgBas, AlgBas, ModMatFldElt → ModAlgBas`](https://docs.magma-maths.org/Algebras/BasicAlgebras/modules.md#function-changealgebra-modalgbas-algbas-modmatfldelt)
    - [`JacobsonRadical(M): ModAlg → ModAlg`](https://docs.magma-maths.org/Algebras/BasicAlgebras/modules.md#function-jacobsonradical-modalg)
    - [`Socle(M): ModAlg → ModAlg`](https://docs.magma-maths.org/Algebras/BasicAlgebras/modules.md#function-socle-modalg)
  - [Access Functions](https://docs.magma-maths.org/Algebras/BasicAlgebras/modules.md#access-functions)
    - [`Algebra(M): ModAlg → AlgBas`](https://docs.magma-maths.org/Algebras/BasicAlgebras/modules.md#function-algebra-modalg)
    - [`Dimension(M): ModAlg → RngIntElt`](https://docs.magma-maths.org/Algebras/BasicAlgebras/modules.md#function-dimension-modalg)
    - [`Action(M): ModAlg → AlgMat`](https://docs.magma-maths.org/Algebras/BasicAlgebras/modules.md#function-action-modalg)
    - [`IsomorphismTypesOfRadicalLayers(M): ModAlgBas → SeqEnum`](https://docs.magma-maths.org/Algebras/BasicAlgebras/modules.md#function-isomorphismtypesofradicallayers-modalgbas)
    - [`IsomorphismTypesOfSocleLayers(M): ModAlgBas → SeqEnum`](https://docs.magma-maths.org/Algebras/BasicAlgebras/modules.md#function-isomorphismtypesofsoclelayers-modalgbas)
    - [`IsomorphismTypesOfBasicAlgebraSequence(S): SeqEnum → SeqEnum`](https://docs.magma-maths.org/Algebras/BasicAlgebras/modules.md#function-isomorphismtypesofbasicalgebrasequence-seqenum)
    - [Example: Restricting a Module to the Center](https://docs.magma-maths.org/Algebras/BasicAlgebras/modules.md#example-ex-6be5c5)
    - [Example: Pulling Back a Module Along a Quotient](https://docs.magma-maths.org/Algebras/BasicAlgebras/modules.md#example-ex-5bc3d0)
    - [Example: Projective Modules of a Hecke Algebra](https://docs.magma-maths.org/Algebras/BasicAlgebras/modules.md#example-ex-e824ff)
  - [Predicates](https://docs.magma-maths.org/Algebras/BasicAlgebras/modules.md#predicates)
    - [`IsSemisimple(M): ModAlg → BoolElt, SeqEnum`](https://docs.magma-maths.org/Algebras/BasicAlgebras/modules.md#function-issemisimple-modalg)
    - [`IsProjective(M): ModAlg → BoolElt, SeqEnum`](https://docs.magma-maths.org/Algebras/BasicAlgebras/modules.md#function-isprojective-modalg)
    - [`IsInjective(M): ModAlg → BoolElt, SeqEnum`](https://docs.magma-maths.org/Algebras/BasicAlgebras/modules.md#function-isinjective-modalg)
  - [Elementary Operations](https://docs.magma-maths.org/Algebras/BasicAlgebras/modules.md#elementary-operations)
    - [`m * b: ModAlgElt, AlgBasElt → ModAlgElt`](https://docs.magma-maths.org/Algebras/BasicAlgebras/modules.md#operation-op-times-modalgelt-algbaselt)
    - [Example: Radical Layers of an Extraspecial Group Algebra](https://docs.magma-maths.org/Algebras/BasicAlgebras/modules.md#example-ex-bb4604)
    - [Example: Inducing the Trivial Module](https://docs.magma-maths.org/Algebras/BasicAlgebras/modules.md#example-ex-2f301a)
- [Homomorphisms of Modules](https://docs.magma-maths.org/Algebras/BasicAlgebras/homomorphisms.md)
  - [Creation](https://docs.magma-maths.org/Algebras/BasicAlgebras/homomorphisms.md#creation)
    - [`AHom(M, N): ModAlg, ModAlg → ModMatFld`](https://docs.magma-maths.org/Algebras/BasicAlgebras/homomorphisms.md#function-ahom-modalg-modalg)
    - [`PHom(M,N): ModAlg, ModAlg → ModMatFld`](https://docs.magma-maths.org/Algebras/BasicAlgebras/homomorphisms.md#function-phom-modalg-modalg)
    - [`ZeroMap(M, N): ModAlg, ModAlg → ModMatFld`](https://docs.magma-maths.org/Algebras/BasicAlgebras/homomorphisms.md#function-zeromap-modalg-modalg)
    - [`LiftHomomorphism(x, n): ModAlgElt, RngIntElt → ModMatFldElt`](https://docs.magma-maths.org/Algebras/BasicAlgebras/homomorphisms.md#function-lifthomomorphism-modalgelt-rngintelt)
    - [`LiftHomomorphism(X, N): SeqEnum[ModAlgElt], SeqEnum[RngIntElt] → ModMatFldElt`](https://docs.magma-maths.org/Algebras/BasicAlgebras/homomorphisms.md#function-lifthomomorphism-seqenum-modalgelt-seqenum-rngintelt)
    - [`Pushout(M, f1, N1, f2, N2): ModAlg, ModMatFldElt, ModAlg, ModMatFldElt, ModAlg → ModAlg, ModMatFldElt, ModMatFldElt`](https://docs.magma-maths.org/Algebras/BasicAlgebras/homomorphisms.md#function-pushout-modalg-modmatfldelt-modalg-modmatfldelt-modalg)
    - [`Pullback(f1, M1, f2, M2, N): ModAlg, ModMatFldElt, ModAlg, ModMatFldElt, ModAlg → ModAlg, ModMatFldElt, ModMatFldElt`](https://docs.magma-maths.org/Algebras/BasicAlgebras/homomorphisms.md#function-pullback-modalg-modmatfldelt-modalg-modmatfldelt-modalg)
  - [Access Functions](https://docs.magma-maths.org/Algebras/BasicAlgebras/homomorphisms.md#access-functions)
    - [`IsModuleHomomorphism(f): ModMatFldElt → BoolElt`](https://docs.magma-maths.org/Algebras/BasicAlgebras/homomorphisms.md#function-ismodulehomomorphism-modmatfldelt)
    - [`Domain(f): ModMatFldElt → ModAlg`](https://docs.magma-maths.org/Algebras/BasicAlgebras/homomorphisms.md#function-domain-modmatfldelt)
    - [`Codomain(f): ModMatFldElt → ModAlg`](https://docs.magma-maths.org/Algebras/BasicAlgebras/homomorphisms.md#function-codomain-modmatfldelt)
    - [`Kernel(f): ModMatFldElt → ModAlg, ModMatFldElt`](https://docs.magma-maths.org/Algebras/BasicAlgebras/homomorphisms.md#function-kernel-modmatfldelt)
    - [`Cokernel(f): ModMatFldElt → ModAlg, ModMatFldElt`](https://docs.magma-maths.org/Algebras/BasicAlgebras/homomorphisms.md#function-cokernel-modmatfldelt)
  - [Projective Covers and Resolutions](https://docs.magma-maths.org/Algebras/BasicAlgebras/homomorphisms.md#projective-covers-and-resolutions)
    - [`ProjectiveCover(M): ModAlg → ModAlg, ModMatFldElt, SeqEnum[ModMatFldElt], SeqEnum[ModMatFldElt], SeqEnum[RngIntElt]`](https://docs.magma-maths.org/Algebras/BasicAlgebras/homomorphisms.md#function-projectivecover-modalg)
    - [`ProjectiveResolution(M, n): ModAlg, RngIntElt → ModCpx, ModMatFldElt`](https://docs.magma-maths.org/Algebras/BasicAlgebras/homomorphisms.md#function-projectiveresolution-modalg-rngintelt)
    - [`CompactProjectiveResolution(M, n): ModAlg, RngIntElt → Rec`](https://docs.magma-maths.org/Algebras/BasicAlgebras/homomorphisms.md#function-compactprojectiveresolution-modalg-rngintelt)
    - [`CompactProjectiveResolutionsOfSimpleModules(A,n): AlgBas, RngIntElt → SeqEnum`](https://docs.magma-maths.org/Algebras/BasicAlgebras/homomorphisms.md#function-compactprojectiveresolutionsofsimplemodules-algbas-rngintelt)
    - [`SyzygyModule(M, n): ModAlg, RngIntElt → ModAlg`](https://docs.magma-maths.org/Algebras/BasicAlgebras/homomorphisms.md#function-syzygymodule-modalg-rngintelt)
    - [`SimpleHomologyDimensions(M): ModAlg → SeqEnum`](https://docs.magma-maths.org/Algebras/BasicAlgebras/homomorphisms.md#function-simplehomologydimensions-modalg)
    - [Example: Projective Resolution for a Quiver Algebra](https://docs.magma-maths.org/Algebras/BasicAlgebras/homomorphisms.md#example-ex-8bea28)
    - [Example: Quotient of an Extraspecial Group Algebra](https://docs.magma-maths.org/Algebras/BasicAlgebras/homomorphisms.md#example-ex-c5e505)
- [Duals and Injectives](https://docs.magma-maths.org/Algebras/BasicAlgebras/duals-injectives.md)
  - [`Dual(M): ModAlg → ModAlg`](https://docs.magma-maths.org/Algebras/BasicAlgebras/duals-injectives.md#function-dual-modalg)
  - [`BaseChangeMatrix(A): AlgBas → ModAlg`](https://docs.magma-maths.org/Algebras/BasicAlgebras/duals-injectives.md#function-basechangematrix-algbas)
  - [Injective Modules](https://docs.magma-maths.org/Algebras/BasicAlgebras/duals-injectives.md#injective-modules)
    - [`InjectiveModule(B, i): AlgBas, RngIntElt → ModAlg`](https://docs.magma-maths.org/Algebras/BasicAlgebras/duals-injectives.md#function-injectivemodule-algbas-rngintelt)
    - [`InjectiveHull(M): ModAlg → ModAlg, ModMatFldElt, SeqEnum[ModMatFldElt], SeqEnum[ModMatFldElt], SeqEnum[RngIntElt]`](https://docs.magma-maths.org/Algebras/BasicAlgebras/duals-injectives.md#function-injectivehull-modalg)
    - [`InjectiveResolution(M, n): ModAlg, RngIntElt → ModCpx, ModMatFldElt`](https://docs.magma-maths.org/Algebras/BasicAlgebras/duals-injectives.md#function-injectiveresolution-modalg-rngintelt)
    - [`CompactInjectiveResolution(M, n): ModAlg, RngIntElt → Rec`](https://docs.magma-maths.org/Algebras/BasicAlgebras/duals-injectives.md#function-compactinjectiveresolution-modalg-rngintelt)
    - [`InjectiveSyzygyModule(M, n): ModAlg, RngIntElt → ModAlg`](https://docs.magma-maths.org/Algebras/BasicAlgebras/duals-injectives.md#function-injectivesyzygymodule-modalg-rngintelt)
    - [`SimpleCohomologyDimensions(M): ModAlg → SeqEnum`](https://docs.magma-maths.org/Algebras/BasicAlgebras/duals-injectives.md#function-simplecohomologydimensions-modalg)
    - [Example: Injective Modules of a Quiver Algebra](https://docs.magma-maths.org/Algebras/BasicAlgebras/duals-injectives.md#example-ex-51e2ac)
- [Cohomology](https://docs.magma-maths.org/Algebras/BasicAlgebras/cohomology.md)
  - [`CohomologyRingGenerators(P): Rec → Rec`](https://docs.magma-maths.org/Algebras/BasicAlgebras/cohomology.md#function-cohomologyringgenerators-rec)
  - [`CohomologyRightModuleGenerators(P, Q, CQ): Rec, Rec, Rec → Rec`](https://docs.magma-maths.org/Algebras/BasicAlgebras/cohomology.md#function-cohomologyrightmodulegenerators-rec-rec-rec)
  - [`CohomologyLeftModuleGenerators(P, CP, Q): Tup, Tup, Tup → Tup`](https://docs.magma-maths.org/Algebras/BasicAlgebras/cohomology.md#function-cohomologyleftmodulegenerators-tup-tup-tup)
  - [`DegreesOfCohomologyGenerators(C): Rec → SeqEnum`](https://docs.magma-maths.org/Algebras/BasicAlgebras/cohomology.md#function-degreesofcohomologygenerators-rec)
  - [`CohomologyGeneratorToChainMap(P,Q,C,n): ModCpx, ModCpx, Rec, RngIntElt → MapChn`](https://docs.magma-maths.org/Algebras/BasicAlgebras/cohomology.md#function-cohomologygeneratortochainmap-modcpx-modcpx-rec-rngintelt)
  - [`CohomologyGeneratorToChainMap(P, C, n): ModCpx, Tup, RngIntElt → MapChn`](https://docs.magma-maths.org/Algebras/BasicAlgebras/cohomology.md#function-cohomologygeneratortochainmap-modcpx-tup-rngintelt)
  - [Example: Cohomology of the Principal Block of M11](https://docs.magma-maths.org/Algebras/BasicAlgebras/cohomology.md#example-ex-6a7d27)
  - [Ext-Algebras](https://docs.magma-maths.org/Algebras/BasicAlgebras/cohomology.md#ext-algebras)
    - [`ExtAlgebra(A, n): AlgBas, RngIntElt → Rec`](https://docs.magma-maths.org/Algebras/BasicAlgebras/cohomology.md#function-extalgebra-algbas-rngintelt)
    - [`BasicAlgebraOfExtAlgebra(ext): Rec → AlgBas`](https://docs.magma-maths.org/Algebras/BasicAlgebras/cohomology.md#function-basicalgebraofextalgebra-rec-2)
    - [`BasicAlgebraOfExtAlgebra(A): AlgBas → AlgBas`](https://docs.magma-maths.org/Algebras/BasicAlgebras/cohomology.md#function-basicalgebraofextalgebra-algbas-2)
    - [`BasicAlgebraOfExtAlgebra(A, n): AlgBas, RngIntElt → AlgBas`](https://docs.magma-maths.org/Algebras/BasicAlgebras/cohomology.md#function-basicalgebraofextalgebra-algbas-rngintelt-2)
    - [`SumOfBettiNumbersOfSimpleModules(A, n): AlgBas, RngIntElt → RngIntElt`](https://docs.magma-maths.org/Algebras/BasicAlgebras/cohomology.md#function-sumofbettinumbersofsimplemodules-algbas-rngintelt)
    - [Example: Ext-Algebra of Lower Triangular Matrices](https://docs.magma-maths.org/Algebras/BasicAlgebras/cohomology.md#example-ex-0c2786)
- [Group Algebras of $p$-groups](https://docs.magma-maths.org/Algebras/BasicAlgebras/p-groups.md)
  - [Access Functions](https://docs.magma-maths.org/Algebras/BasicAlgebras/p-groups.md#access-functions)
    - [`Group(A): AlgBasGrpP → Grp`](https://docs.magma-maths.org/Algebras/BasicAlgebras/p-groups.md#function-group-algbasgrpp)
    - [`PCGroup(A): AlgBasGrpP → Grp`](https://docs.magma-maths.org/Algebras/BasicAlgebras/p-groups.md#function-pcgroup-algbasgrpp)
    - [`PCMap(A): AlgBasGrpP → Map`](https://docs.magma-maths.org/Algebras/BasicAlgebras/p-groups.md#function-pcmap-algbasgrpp)
    - [`AModule(M): ModGrp → ModAlg`](https://docs.magma-maths.org/Algebras/BasicAlgebras/p-groups.md#function-amodule-modgrp)
    - [`GModule(M): AlgBasGrpP → ModGrp, ModGrp`](https://docs.magma-maths.org/Algebras/BasicAlgebras/p-groups.md#function-gmodule-algbasgrpp)
    - [`GModule(M): ModAlgBas → ModGrp`](https://docs.magma-maths.org/Algebras/BasicAlgebras/p-groups.md#function-gmodule-modalgbas)
  - [Projective Resolutions](https://docs.magma-maths.org/Algebras/BasicAlgebras/p-groups.md#projective-resolutions)
    - [`ResolutionData(A): AlgBasGrpP → Rec`](https://docs.magma-maths.org/Algebras/BasicAlgebras/p-groups.md#function-resolutiondata-algbasgrpp)
    - [`CompactProjectiveResolutionPGroup(M, n): ModAlgBas, RngIntElt → Rec`](https://docs.magma-maths.org/Algebras/BasicAlgebras/p-groups.md#function-compactprojectiveresolutionpgroup-modalgbas-rngintelt)
    - [`CompactProjectiveResolution(M, n): ModAlgBas, RngIntElt → Rec`](https://docs.magma-maths.org/Algebras/BasicAlgebras/p-groups.md#function-compactprojectiveresolution-modalgbas-rngintelt)
    - [`ProjectiveResolutionPGroup(PR): Rec → ModCpx`](https://docs.magma-maths.org/Algebras/BasicAlgebras/p-groups.md#function-projectiveresolutionpgroup-rec)
    - [`ProjectiveResolution(M, n): ModAlgBas, RngIntElt → ModCpx, ModMatFldElt`](https://docs.magma-maths.org/Algebras/BasicAlgebras/p-groups.md#function-projectiveresolution-modalgbas-rngintelt)
    - [`ProjectiveResolution(PR): Rec → ModCpx, ModMatFldElt`](https://docs.magma-maths.org/Algebras/BasicAlgebras/p-groups.md#function-projectiveresolution-rec)
  - [Cohomology Generators](https://docs.magma-maths.org/Algebras/BasicAlgebras/p-groups.md#cohomology-generators)
    - [`AllCompactChainMaps(PR): Rec → Rec`](https://docs.magma-maths.org/Algebras/BasicAlgebras/p-groups.md#function-allcompactchainmaps-rec)
    - [`CohomologyElementToChainMap(P, d, n): ModCpx, RngIntElt, RngIntElt → MapChn`](https://docs.magma-maths.org/Algebras/BasicAlgebras/p-groups.md#function-cohomologyelementtochainmap-modcpx-rngintelt-rngintelt)
    - [`CohomologyElementToCompactChainMap(PR, d, n): Rec, RngIntElt, RngIntElt → ModMatFldElt`](https://docs.magma-maths.org/Algebras/BasicAlgebras/p-groups.md#function-cohomologyelementtocompactchainmap-rec-rngintelt-rngintelt)
  - [Cohomology Rings](https://docs.magma-maths.org/Algebras/BasicAlgebras/p-groups.md#cohomology-rings)
    - [`CohomologyRing(k, n): ModAlgBas, RngIntElt → Rec`](https://docs.magma-maths.org/Algebras/BasicAlgebras/p-groups.md#function-cohomologyring-modalgbas-rngintelt)
    - [`CohomologyRing(PR, AC): Rec, Rec → Rec`](https://docs.magma-maths.org/Algebras/BasicAlgebras/p-groups.md#function-cohomologyring-rec-rec)
    - [`MinimalRelations(R): Rec → SeqEnum`](https://docs.magma-maths.org/Algebras/BasicAlgebras/p-groups.md#function-minimalrelations-rec)
  - [Restrictions and Inflations](https://docs.magma-maths.org/Algebras/BasicAlgebras/p-groups.md#restrictions-and-inflations)
    - [`RestrictionData(A,B): AlgBasGrpP, AlgBasGrpP → ModMatFldElt, ModMatFldElt, SeqEnum`](https://docs.magma-maths.org/Algebras/BasicAlgebras/p-groups.md#function-restrictiondata-algbasgrpp-algbasgrpp)
    - [`RestrictResolution(PR, RD): Rec, Rec → ModCpx`](https://docs.magma-maths.org/Algebras/BasicAlgebras/p-groups.md#function-restrictresolution-rec-rec)
    - [`RestrictionChainMap(P1,P2): Rec, Rec → MapChn`](https://docs.magma-maths.org/Algebras/BasicAlgebras/p-groups.md#function-restrictionchainmap-rec-rec)
    - [`RestrictionOfGenerators(PR1, PR2, AC1, AC2, REL2): Rec, Rec, Rec, Rec, Rec → SeqEnum`](https://docs.magma-maths.org/Algebras/BasicAlgebras/p-groups.md#function-restrictionofgenerators-rec-rec-rec-rec-rec)
    - [`InflationMap(PR2, PR1, AC2, AC1, REL1, theta): Rec, Rec, Rec, Rec, Rec → SeqEnum`](https://docs.magma-maths.org/Algebras/BasicAlgebras/p-groups.md#function-inflationmap-rec-rec-rec-rec-rec)
    - [Example: Restriction and Inflation of Cohomology](https://docs.magma-maths.org/Algebras/BasicAlgebras/p-groups.md#example-ex-9fb5b5)
- [A-infinity Algebra Structures on Group Cohomology](https://docs.magma-maths.org/Algebras/BasicAlgebras/a-infinity.md)
  - [`AInfinityRecord(G,n): Grp, RngIntElt → Rec`](https://docs.magma-maths.org/Algebras/BasicAlgebras/a-infinity.md#function-ainfinityrecord-grp-rngintelt)
  - [`MasseyProduct(Aoo,terms): Rec, SeqEnum[RngElt] → RngElt`](https://docs.magma-maths.org/Algebras/BasicAlgebras/a-infinity.md#function-masseyproduct-rec-seqenum-rngelt)
  - [`HighProduct(Aoo,terms): Rec, SeqEnum[RngElt] → RngElt`](https://docs.magma-maths.org/Algebras/BasicAlgebras/a-infinity.md#function-highproduct-rec-seqenum-rngelt)
  - [`HighMap(Aoo,terms): Rec, SeqEnum[RngElt] → MapChn`](https://docs.magma-maths.org/Algebras/BasicAlgebras/a-infinity.md#function-highmap-rec-seqenum-rngelt)
  - [Example: A-infinity Structure in Characteristic 2](https://docs.magma-maths.org/Algebras/BasicAlgebras/a-infinity.md#example-ex-b55050)
  - [Example: A-infinity Structure in Characteristic 3](https://docs.magma-maths.org/Algebras/BasicAlgebras/a-infinity.md#example-ex-21e1bf)
  - [Homological Algebra Toolkit](https://docs.magma-maths.org/Algebras/BasicAlgebras/a-infinity.md#homological-algebra-toolkit)
    - [`ActionMatrix(A,x): AlgBas, Mtrx → ModMatFldElt`](https://docs.magma-maths.org/Algebras/BasicAlgebras/a-infinity.md#function-actionmatrix-algbas-mtrx)
    - [`CohomologyRingQuotient(CR): Rec → Rng, Map`](https://docs.magma-maths.org/Algebras/BasicAlgebras/a-infinity.md#function-cohomologyringquotient-rec)
    - [`LiftToChainmap(P,f,d): ModCpx, Mtrx, RngIntElt → MapChn`](https://docs.magma-maths.org/Algebras/BasicAlgebras/a-infinity.md#function-lifttochainmap-modcpx-mtrx-rngintelt)
    - [`NullHomotopy(f): MapChn → MapChn`](https://docs.magma-maths.org/Algebras/BasicAlgebras/a-infinity.md#function-nullhomotopy-mapchn)
    - [`IsNullHomotopy(f,H): MapChn, MapChn → BoolElt`](https://docs.magma-maths.org/Algebras/BasicAlgebras/a-infinity.md#function-isnullhomotopy-mapchn-mapchn)
    - [`ChainmapToCohomology(f,CR): MapChn, Rec → RngElt`](https://docs.magma-maths.org/Algebras/BasicAlgebras/a-infinity.md#function-chainmaptocohomology-mapchn-rec)
    - [`CohomologyToChainmap(xi,CR,P): RngElt, Rec, ModCpx → MapChn`](https://docs.magma-maths.org/Algebras/BasicAlgebras/a-infinity.md#function-cohomologytochainmap-rngelt-rec-modcpx)
    - [Example: Null Homotopies for a Cyclic Group](https://docs.magma-maths.org/Algebras/BasicAlgebras/a-infinity.md#example-ex-ca2dae)
- [Bibliography](https://docs.magma-maths.org/Algebras/BasicAlgebras/bibliography.md)

### Introduction

A basic algebra is a finite dimensional algebra $A$ over a field, all of whose simple modules have dimension one. In the literature such an algebra is known as a “split” basic algebra. Every algebra is Morita equivalent to a basic algebra, though a field extension may be necessary to obtain the split basic algebra. Magma has several functions that create the basic algebras corresponding to algebras of different types.

The type `AlgBas` in Magma is optimized for the purposes of doing homological calculations. A basic algebra $A$ is generated by elements $a_1, a_2, \ldots,  a_t$ where $a_1, \ldots, a_s$ are the primitive idempotent generators and $a_{s+1}, \ldots, a_t$ are the nonidempotent generators. Each nonidempotent generator, $a_k$ must have the property that $a_i*a_k*a_j = a_k$ for specific idempotent generators $a_i$ and $a_j$. The projective indecomposable modules have the form $P_i = a_i \cdot A$ for $i = 1, \ldots, s$ and the simple modules have the form $S_i = P_i/\hbox{Rad}(P_i)$, where $\hbox{Rad}(P_i)$ is the radical of $P_i$.

### Basic Algebras

In the Magma implementation the algebra is given as the sequence of projective modules $P_1, \ldots, P_s$ together with a path tree for each projective module. A projective module consists of a matrix for each generator $a_1, a_2, \ldots,  a_t$ giving the action of the generator on the vector space of the module. The basis $b_1,b_2, \ldots, b_n$ for the vector space of $P_i$ is chosen so that each basis element is the image of a basis element of lower index under multiplication by a nonidempotent generator of $A$. The structure of the basis is recorded in the path tree which is a sequence $[<1,i>,<j,k>, \ldots ]$ of 2-tuples of length $n = \hbox{\tt Dimension}(P_i)$. The first entry $<1,i>$ indicates that $b_1 = b_1*a_i$ where $a_i$ is the primitive idempotent in the algebra $A$ such that $P_i = A\cdot a_i$. Similarly, if entry number $k$ in the path tree is $\langle u,v \rangle$ then $b_k = b_u*a_v$ where $v > s$ if $k > 1$.

#### Creation

The first function for creating a basic algebra is the most basic, in which the user supplies the projective modules and the path trees directly.

<a id="function-basicalgebra-seqenum-tup"></a>
##### `BasicAlgebra(Q): SeqEnum[Tup] -> AlgBas`

Given a sequence $[Q_i, \ldots, Q_s]$ of 2-tuples such that each $Q_i = <M_i,T_i>$ consisting of a module for a matrix algebra $M_i$ and a path tree $T_i$ for $M_i$, the function creates the basic algebra whose projective modules are the first entries $M_1, \ldots, M_s$ and the path trees are the corresponding second entries.

The next two functions create a basic algebra from generators and relations. The user must, additionally, specify the quiver with relations, giving the number of idempotents and the beginning and end points of the arrows in the quiver.

<a id="function-basicalgebra-algfr-seqenum-rngintelt-seqenum"></a>
##### `BasicAlgebra(F, R, s, P): AlgFr, SeqEnum, RngIntElt, SeqEnum -> AlgBas`

Creates the basic algebra given by the presentation. Here $F$ is a free algebra and $R$ is the sequence of relation for the nonidempotent generators of the algebra. If the free algebra $F$ is generated by elements $a_1, \ldots, a_t$, the function assumes that $a_1, \ldots, a_s$ are the mutually orthogonal primitive idempotents and it creates all of the appropriate relations including $a_1 + \ldots  + a_s = 1$. The nonidempotent generators are then $a_{s+1}, \ldots, a_t$. So $\ell_k = \langle i,j \rangle$ for $i,j \le s$ means that $a_{s+k} = a_i*a_{s+k}*a_j$. Each of the relations in $R$ is given as a linear combination of words in the nonidempotent generators $a_{s+1}, \ldots, a_t \in F$. The sequence $P$ is a sequence of 2-tuples, one for each nonidempotent generator, giving the beginning and ending nodes of the generator. That is, each tuple is the pair of indices of the idempotents which multiply as the identity on the nonidempotent generator on the left and on the right.

<a id="function-basicalgebra-algfr-seqenum"></a>
##### `BasicAlgebra(F, R): AlgFr, SeqEnum -> AlgBas`

Creates the basic algebra of a local algebra from the presentation of the algebra. Here $F$ is a free algebra whose variable represent the nonidempotent generators and $R$ is the sequence of relations among those variables.

<a id="function-tensorproduct-algbas-algbas"></a>
##### `TensorProduct(A, B): AlgBas, AlgBas -> AlgBas`

The tensor product of the basic algebras $A$ and $B$.

The modular group algebra of a $p$-group is naturally a basic algebra. The next function create the basic algebra from the group information.

<a id="function-basicalgebra-grpperm-fldfin"></a>
##### `BasicAlgebra(G, k): GrpPerm, FldFin -> AlgBas`

<a id="function-basicalgebra-grppc-fldfin"></a>
##### `BasicAlgebra(G, k): GrpPC, FldFin -> AlgBas`

<a id="function-basicalgebra-grpperm"></a>
##### `BasicAlgebra(G): GrpPerm -> AlgBass`

Given a finite $p$-group $G$ and a finite field $k$ of characteristic $p$, returns the group algebra $kG$ in the form of a basic algebra. If no field $k$ is supplied then the prime field of characteristic $p$ is assumed to be the field of coefficients.

#### Special Basic Algebras

There are several functions that create basic algebras of special interest. The most basic of these creates the basic algebra that is Morita equivalent to a matrix algebra defined over a finite field by first condensing the algebra and then splitting the irreducible modules as needed.

Included among these constructions are the basic algebras of Schur algebras and Hecke algebras over finite fields. The Schur algebras arise in the representation theory of symmetric groups. The Schur algebras have finite global dimension and hence their ext-algebras have finite dimension. By a Hecke algebra, we mean the algebra of endomorphisms of a permutation module of a finite group.

<a id="function-basicalgebra-algmat"></a>
##### `BasicAlgebra(A): AlgMat -> AlgBas`

<a id="function-basicalgebraofmatrixalgebra-algmat"></a>
##### `BasicAlgebraOfMatrixAlgebra(A): AlgMat -> AlgBas`

This function creates the split basic algebra of the matrix algebra $A$. The function first produces a presentation and condensed algebra for $A$. In the event that the field of coefficients $k$ of $A$ is not a splitting field, then the returned basic algebra is defined over the minimal extension of $k$ that is a splitting field for $A$.

<a id="function-basicalgebraofendomorphismalgebra-modrng"></a>
##### `BasicAlgebraOfEndomorphismAlgebra(M): ModRng -> AlgBas`

Returns the split basic algebra of the endomorphism ring of the module $M$. In the event that the field of coefficients of $M$ is not a splitting field for $M$, then the field is extended and the basic algebra is defined over the minimal extension needed to split $M$.

<a id="function-basicalgebraofheckealgebra-grpperm-grpperm-fldfin"></a>
##### `BasicAlgebraOfHeckeAlgebra(G, H, F): GrpPerm, GrpPerm, FldFin -> AlgBas`

<a id="function-basicalgebraofheckealgebra-grppc-grppc-fldfin"></a>
##### `BasicAlgebraOfHeckeAlgebra(G, H, F): GrpPC, GrpPC, FldFin -> AlgBas`

<a id="function-basicalgebraofheckealgebra-grpab-grpab-fldfin"></a>
##### `BasicAlgebraOfHeckeAlgebra(G, H, F): GrpAb, GrpAb, FldFin -> AlgBas`

Returns the basic algebra of the Hecke algebra which is the algebra of endomorphisms of the permutation module over $G$ with point stabilizer $H$ and field of coefficients $F$. In the event that $F$ is not a splitting field then the field $F$ is extended to a splitting field which is the field of coefficients of the returned basic algebra.

<a id="function-basicalgebraofschuralgebra-rngintelt-rngintelt-fldfin"></a>
##### `BasicAlgebraOfSchurAlgebra(n, r, F): RngIntElt, RngIntElt, FldFin -> AlgBas`

Creates the basic algebra of the Schur algebra $S(n,r)$ over the field $F$. The Schur algebra is the algebra of endomorphisms of the module over the symmetric group $Sym(r)$ that is the tensor product of $r$ copies of a vector space $V$ over $F$ of dimension $n$, the group $Sym(r)$ acting by permuting the $r$ copies.

<a id="function-basicalgebraofgroupalgebra-grpperm-fldfin"></a>
##### `BasicAlgebraOfGroupAlgebra(G, F): GrpPerm, FldFin -> AlgBas`

<a id="function-basicalgebraofgroupalgebra-grppc-fldfin"></a>
##### `BasicAlgebraOfGroupAlgebra(G, F): GrpPC, FldFin -> AlgBas`

<a id="function-basicalgebraofgroupalgebra-grpab-fldfin"></a>
##### `BasicAlgebraOfGroupAlgebra(G, F): GrpAb, FldFin -> AlgBas`

The function returns the basic algebra of the group algebra of $G$ with coefficients in the field $F$. The function requires the creation of the projective indecomposable $FG$-modules. In the event that the field $F$ is not a splitting field for the irreducible $FG$-modules then the base ring of the returned algebra is the minimal extension of $F$ that is necessary to get a splitting field.

<a id="function-basicalgebra-seqenum"></a>
##### `BasicAlgebra(S): SeqEnum -> AlgBas`

Returns the basic algebra of the action algebra on the module which is the direct sum of the modules in the sequence $S$. In the event that the irreducible composition factors of the modules in $S$ are not absolutely irreducible, then the returned basic algebra is defined over the splitting field for the irreducible modules.

<a id="function-basicalgebraofblockalgebra-seqenum"></a>
##### `BasicAlgebraOfBlockAlgebra(S): SeqEnum -> AlgBas`

Returns the basic algebra of the block algebra, the projective modules of which are given in the sequence $S$. In the event that the irreducible composition factors of the modules in $S$ are not absolutely irreducible, then the returned basic algebra is defined over the splitting field for the irreducible modules.

<a id="function-basicalgebraofprincipalblock-grpperm-fldfin"></a>
##### `BasicAlgebraOfPrincipalBlock(G, k): GrpPerm, FldFin -> AlgBas`

Returns the basic algebra of the principal block of the group algebra of $G$. If the simple modules in the principal $kG$ block are all absolutely simple, then the ordering of the projective modules for the returned basic algebra is exactly the same as the ordering of the projectives modules in the principal block returned by the function `IndecomposableProjectives`. Otherwise, the base ring of the returned basic algebra is the least extension of $k$ necessary to split the simple modules in the principal block and the simple modules of the returned algebra are ordered by increasing dimension of the corresponding simple modules of $kG$.

<a id="function-basicalgebraofextalgebra-algbas"></a>
##### `BasicAlgebraOfExtAlgebra(A): AlgBas -> AlgBas`

The function returns the basic algebra from a computed ext-algebra which is $\mathop{\hbox{\rm Ext}}_A^*(S,S)$, where $S$ is the direct sum of the irreducible $A$-modules, of the basic algebra A. If no ext-algebra for $A$ has been computed or if the exalgebra is not verified to be finite dimensional then an error is returned.

<a id="function-basicalgebraofextalgebra-algbas-rngintelt"></a>
##### `BasicAlgebraOfExtAlgebra(A, n): AlgBas, RngIntElt -> AlgBas`

The function returns the basic algebra for the ext-algebra, which is $\mathop{\hbox{\rm Ext}}_A^*(S,S)$, where $S$ is the direct sum of the irreducible $A$-modules, of $A$ computed to n steps. If no ext-algebra for $A$ to $n$ steps has been computed then it will be computed. If the ext-algebra is not verified to be finite dimensional by the computation, then an error is returned.

<a id="function-basicalgebraofextalgebra-rec"></a>
##### `BasicAlgebraOfExtAlgebra(A): Rec -> AlgBas`

The function creates the basic algebra from a computed ext-algebra. The input $ext$ is the output of the `ExtAlgebra` function. If the ext-algebra is not verified to be finite dimensional by the computation, then an error is returned.

<a id="function-oppositealgebra-algbas"></a>
##### `OppositeAlgebra(B): AlgBas -> AlgBas`

The opposite algebra of the basic algebra $B$. The opposite algebra of $B$ is the algebra with the same set of elements and the same addition but with multiplication $*$ given by $a*b = ba$ for $a$ and $b$ in $A$.

<a id="example-ex-cb7ecb"></a>
##### `Example: Basic Algebra of an Alternating Group Algebra (ex-cb7ecb)`

We form the basic algebra of the group algebra of the alternating group on 6 letters in characteristic 2.

```magma
> G := AlternatingGroup(6);
> A := BasicAlgebraOfGroupAlgebra(G, GF(2));
> A;
Basic algebra of dimension 36 over GF(2^2)
Number of projective modules: 5
Number of generators: 9
```

Note that the field of coefficients has been extended in order to split the irreducible $G$-modules. A great deal of information on the nature of the group algebra and its basic algebra can be obtained from analysis such as the following.

```magma
> [Dimension(ProjectiveModule(A,i)): i in [1 .. 5]];
[ 9, 9, 16, 1, 1 ]
> prj := CompactProjectiveResolutionsOfAllSimpleModules(A,8);
> [x`BettiNumbers:x in prj];
[
    [
        [ 1, 0, 0, 0, 0 ],
        [ 0, 0, 1, 0, 0 ],
        [ 1, 0, 0, 0, 0 ],
        [ 1, 0, 0, 0, 0 ],
        [ 0, 0, 1, 0, 0 ],
        [ 1, 0, 0, 0, 0 ],
        [ 1, 0, 0, 0, 0 ],
        [ 0, 0, 1, 0, 0 ],
        [ 1, 0, 0, 0, 0 ]
    ],
    [
        [ 0, 1, 0, 0, 0 ],
        [ 0, 0, 1, 0, 0 ],
        [ 0, 1, 0, 0, 0 ],
        [ 0, 1, 0, 0, 0 ],
        [ 0, 0, 1, 0, 0 ],
        [ 0, 1, 0, 0, 0 ],
        [ 0, 1, 0, 0, 0 ],
        [ 0, 0, 1, 0, 0 ],
        [ 0, 1, 0, 0, 0 ]
    ],
    [
        [ 0, 0, 3, 0, 0 ],
        [ 1, 1, 2, 0, 0 ],
        [ 0, 0, 3, 0, 0 ],
        [ 0, 0, 2, 0, 0 ],
        [ 1, 1, 1, 0, 0 ],
        [ 0, 0, 2, 0, 0 ],
        [ 0, 0, 1, 0, 0 ],
        [ 1, 1, 0, 0, 0 ],
        [ 0, 0, 1, 0, 0 ]
    ],
    [
        [ 0, 0, 0, 0, 0 ],
        [ 0, 0, 0, 0, 0 ],
        [ 0, 0, 0, 0, 0 ],
        [ 0, 0, 0, 0, 0 ],
        [ 0, 0, 0, 0, 0 ],
        [ 0, 0, 0, 0, 0 ],
        [ 0, 0, 0, 0, 0 ],
        [ 0, 0, 0, 0, 0 ],
        [ 0, 0, 0, 1, 0 ]
    ],
    [
        [ 0, 0, 0, 0, 0 ],
        [ 0, 0, 0, 0, 0 ],
        [ 0, 0, 0, 0, 0 ],
        [ 0, 0, 0, 0, 0 ],
        [ 0, 0, 0, 0, 0 ],
        [ 0, 0, 0, 0, 0 ],
        [ 0, 0, 0, 0, 0 ],
        [ 0, 0, 0, 0, 0 ],
        [ 0, 0, 0, 0, 1 ]
    ]
]
```

So we see that the last two simple modules are projective and hence in the group algebra $FG$, they represent blocks of defect 0. From the information on the Betti numbers we observe that the first two simple modules have periodic projective resolutions. Thus the third simple module for the basic algebra corresponds to the trivial $FG$-module, which we know is neither projective nor periodic.

<a id="example-ex-8e74b4"></a>
##### `Example: Basic Algebra of a Schur Algebra (ex-8e74b4)`

We construct the Schur algebra $S(3,7)$ with coefficients in a field of characteristic 2.

```magma
> A := BasicAlgebraOfSchurAlgebra(3,6,GF(2));
> A;
Basic algebra of dimension 58 over GF(2)
Number of projective modules: 7
Number of generators: 21
```

It is known that $A$ has finite global dimension, hence its ext-algebra has finite dimension.

```magma
> B := BasicAlgebraOfExtAlgebra(A,10);
> B;
Basic algebra of dimension 56 over GF(2)
Number of projective modules: 7
Number of generators: 25
```

We check to see if the ext-algebra of $B$ might have finite dimension.

```magma
> SumOfBettiNumbersOfSimpleModules(B,5);
600
> SumOfBettiNumbersOfSimpleModules(B,6);
1334
> SumOfBettiNumbersOfSimpleModules(B,7);
3008
```

The sum of the Betti number would be the dimension of the ext-algebra computed to the indicated degree. It would appear that the ext-algebra is infinite dimensional. Just to check, we look at a particular simple module, chosen randomly.

```magma
> CompactProjectiveResolution(SimpleModule(B,4),10)`BettiNumbers;
[
    [ 8, 0, 81, 3, 61, 69, 55 ],
    [ 3, 0, 36, 1, 26, 30, 24 ],
    [ 1, 0, 16, 1, 11, 13, 10 ],
    [ 1, 0, 7, 1, 5, 5, 4 ],
    [ 1, 0, 3, 1, 2, 2, 1 ],
    [ 1, 0, 1, 0, 1, 1, 0 ],
    [ 0, 0, 0, 0, 1, 1, 0 ],
    [ 0, 0, 0, 0, 1, 0, 1 ],
    [ 0, 0, 0, 1, 0, 1, 0 ],
    [ 1, 0, 0, 0, 0, 0, 1 ],
    [ 0, 0, 0, 1, 0, 0, 0 ]
]
```

Thus we have strong evidence that the fourth simple module has infinite projective dimension. In that case, the ext-algebra of $B$ is not finite dimensional.

Now we consider the same example except in characteristic 3.

```magma
> A := BasicAlgebraOfSchurAlgebra(3,6,GF(3));
> A;
Basic algebra of dimension 48 over GF(3)
Number of projective modules: 7
Number of generators: 21
> B := BasicAlgebraOfExtAlgebra(A,10);
> B;
Basic algebra of dimension 98 over GF(3)
Number of projective modules: 7
Number of generators: 21
> SumOfBettiNumbersOfSimpleModules(B,5);
48
> SumOfBettiNumbersOfSimpleModules(B,6);
48
```

So we see that the algebra $B$ has global dimension at most 5. We can compute its ext-algebra.

```magma
> C := BasicAlgebraOfExtAlgebra(B,10);
> C;
Basic algebra of dimension 48 over GF(3)
Number of projective modules: 7
Number of generators: 21
> D := BasicAlgebraOfExtAlgebra(C,10);
> D;
Basic algebra of dimension 98 over GF(3)
Number of projective modules: 7
Number of generators: 21
```

This provides evidence that $A$ is isomorphic to its double ext-algebra. This would suggest that $A$ might be a Koszul algebra.

#### A Database of Basic Algebras

A small library of basic algebras for the $p$-modular group algebras of some of the smaller groups that are catalogued in Atlas is provided. This library will be referred to as the *Basic Algebras for Atlas Groups* database. For each group $G$ included in the library and each prime $p$ dividing the order of $G$, the basic algebra for each $p$-block of the group algebra $K[G]$ is stored. A second library contains the basic algebras of a small collection of Schur algebras $S(n, r)$ and will be referred to as the *Basic Algebras for Schur Algebras* database.

<a id="function-basicalgebrafromgroup-monstgelt-rngintelt-rngintelt"></a>
##### `BasicAlgebraFromGroup(A, p, b): MonStgElt, RngIntElt, RngIntElt -> AlgBas`

This function reconstructs from a library the basic algebra of the block number $b$ of the group algebra $K[G]$ where $K$ is a field of characteristic $p$ and $G$ is the finite group with Atlas name $A$. Block number $1$ is always the principal block.

<a id="function-basicalgebragroupnames"></a>
##### `BasicAlgebraGroupNames() -> SetIndx`

This intrinsic returns the names of the basic algebras that are stored in the *Basic Algebras for Atlas Groups* database.

<a id="function-basicalgebrafromschur-rngintelt-rngintelt-rngintelt"></a>
##### `BasicAlgebraFromSchur(n, r, p): RngIntElt, RngIntElt, RngIntElt -> AlgBas`

Let $n$ and $r$ be positive integers and $p$ a prime such that the triple is the name of a basic algebra in the *Basic Algebras for Schur Algebras* database. This intrinsic retrieves a basic algebra for the Schur algebra $S(n, r)$ from the database.

<a id="example-ex-9fefcd"></a>
##### `Example: Basic Algebra of an Atlas Group Block (ex-9fefcd)`

We retrieve the basic algebra for the principal $5$-block of Atlas Group $2A8$ from the *Basic Algebras for Atlas Groups* database.

```magma
> A := BasicAlgebraFromGroup("2A8", 5, 1);
> A;
Basic algebra of dimension 14 over GF(5)
Number of projective modules: 4
Number of generators: 10
>
> [ Dimension(ProjectiveModule(A, i)) : i in [1..4] ];
[ 3, 4, 3, 4 ]
```

For some groups not all basic algebras are stored. Thus for the sporadic group $McL$ only the algebras for the principal blocks for $p = 2, 3, 5$ are currently in the database.

```magma
> A := BasicAlgebraFromGroup("McL", 2, 1);
> A;
Basic algebra of dimension 1004 over GF(2)
Number of projective modules: 8
Number of generators: 28
>
>  [ Dimension(ProjectiveModule(A, i)) : i in [1..8] ];
[ 152, 280, 100, 128, 128, 64, 64, 88 ]
>
> A := BasicAlgebraFromGroup("McL", 3, 1);
> A;
Basic algebra of dimension 6284 over GF(3^2)
Number of projective modules: 10
Number of generators: 42
>
> [ Dimension(ProjectiveModule(A, i)) : i in [1..10] ];
[ 1274, 857, 657, 657, 876, 1127, 194, 194, 252, 196 ]
>
> A := BasicAlgebraFromGroup("McL", 5, 1);
> A;
Basic algebra of dimension 788 over GF(5^2)
Number of projective modules: 12
Number of generators: 42
>
>  [ Dimension(ProjectiveModule(A, i)) : i in [1..12] ];
[ 64, 122, 46, 15, 117, 104, 104, 67, 67, 52, 15, 15 ]
```

#### Access Functions

These functions return basic information, underlying structures, and elements of the given basic algebras.

<a id="operation-operation-algbas-rngintelt-algbaselt"></a>
##### `B . i: AlgBas, RngIntElt -> AlgBasElt`

The $i^{th}$ element in the standard basis for the underlying vector space of the algebra $B$.

<a id="function-basering-algbas"></a>
##### `BaseRing(B): AlgBas -> Rng`

<a id="function-coefficientring-algbas"></a>
##### `CoefficientRing(B): AlgBas -> Rng`

Given an algebra $B$ over a field $k$ the function returns $k$.

<a id="function-vectorspace-algbas"></a>
##### `VectorSpace(B): AlgBas -> ModTupFld`

<a id="function-kspace-algbas"></a>
##### `KSpace(B): AlgBas -> ModTupFld`

The underlying $k$-vector space of the algebra $B$. The space is the direct sum of the underlying vector space of the indecomposable projective modules.

<a id="function-dimension-algbas"></a>
##### `Dimension(B): AlgBas -> RngIntElt`

The dimension of the underlying vector space of the algebra $B$.

<a id="function-basis-algbas"></a>
##### `Basis(B): AlgBas -> SeqEnum`

A basis of the underlying vector space of the algebra $B$.

<a id="function-generators-algbas"></a>
##### `Generators(B): AlgBas -> SeqEnum`

The generators of the algebra $B$ as a sequence of elements in the underlying vector space of the algebra $B$.

<a id="function-idempotentgenerators-algbas"></a>
##### `IdempotentGenerators(B): AlgBas -> SeqEnum`

The sequence of mutually orthogonal idempotent generators of the basic algebra $B$ as elements in the underlying vector space of $B$.

<a id="function-idempotentpositions-algbas"></a>
##### `IdempotentPositions(B): AlgBas -> SeqEnum`

The sequence $N = [n_1, \ldots, n_s]$ such that $B.n_1, \ldots,  B.n_s$ are the mutually orthogonal idempotent generators of the algebra $B$.

<a id="function-nonidempotentgenerators-algbas"></a>
##### `NonIdempotentGenerators(B): AlgBas -> SeqEnum`

The sequence of nonidempotent generators of the basic algebra $B$ as elements in the underlying vector space of the algebra $B$.

<a id="function-random-algbas"></a>
##### `Random(B): AlgBas -> AlgBasElt`

A random element of the algebra $B$ as an element of the underlying vector space of $B$.

<a id="function-numberofprojectives-algbas"></a>
##### `NumberOfProjectives(B): AlgBas -> RngIntElt`

The number of nonisomorphic indecomposable projective modules in the basic algebra $B$.

<a id="function-numberofgenerators-algbas"></a>
##### `NumberOfGenerators(B): AlgBas -> RngIntElt`

<a id="function-ngens-algbas"></a>
##### `Ngens(B): AlgBas -> RngIntElt`

The number of generators (idempotent and nonidempotent) of the basic algebra $B$.

<a id="function-dimensionsofprojectivemodules-algbas"></a>
##### `DimensionsOfProjectiveModules(B): AlgBas -> SeqEnum`

The sequence of the dimensions of the projective modules of the basic algebra $B$.

<a id="function-dimensionsofinjectivemodules-algbas"></a>
##### `DimensionsOfInjectiveModules(B): AlgBas -> SeqEnum`

The sequence of the dimensions of the injective modules of the basic algebra $B$.

#### Elementary Operations

<a id="operation-op-plus-algbaselt-algbaselt"></a>
##### `a + b: AlgBasElt, AlgBasElt -> AlgBasElt`

The sum of the two elements $a$ and $b$.

<a id="operation-op-times-algbaselt-algbaselt"></a>
##### `a * b: AlgBasElt, AlgBasElt -> AlgBasElt`

The product of the two elements $a$ and $b$.

<a id="operation-op-pow-algbaselt-rngintelt"></a>
##### `a ^ n: AlgBasElt, RngIntElt -> AlgBasElt`

The $n^{th}$ power of the element $a$.

<a id="example-ex-49b24a"></a>
##### `Example: Basic Algebra of a Quiver (ex-49b24a)`

We create the basic algebra of the quiver with three nodes and three arrows over the field with 7 elements. The first arrow (`a`) goes from node 1 to node 2, the second (`b`) from node 2 to node 1, and (`c`) from node 2 to node 3. The arrows satisfy the relation that $(\hbox{\tt a}*\hbox{\tt b})^3 = 0$.

```magma
> ff := GF(7);
> FA<e1,e2,e3,a,b,c> := FreeAlgebra(ff,6);
> rrr := [a*b*a*b*a*b];
> D := BasicAlgebra(FA,rrr,3,[<1,2>,<2,1>,<2,3>]);
> D;
Basic algebra of dimension 21 over GF(7)
Number of projective modules: 3
Number of generators: 6

> DimensionsOfProjectiveModules(D);
[ 9, 11, 1 ]
> DimensionsOfInjectiveModules(D);
[ 6, 7, 8 ]
```

So we can see that the algebra is not self-injective.

Now we can check the nilpotence degree of the radical of `D`. The radical of `D` is generated by the nonidempotent generators.

```magma
> S := NonIdempotentGenerators(D);
> S;
[ (0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0), (0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0
0 0 0 0 0), (0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0) ]
> S2 := [x*y:x in S, y in S|x*y ne 0];
> #S2;
3
> S3 := [x*y:x in S2, y in S|x*y ne 0];
> #S3;
3
> S4 := [x*y:x in S3, y in S|x*y ne 0];
> #S4;
3
> S5 := [x*y:x in S4, y in S|x*y ne 0];
> #S5;
3
> S6 := [x*y:x in S5, y in S|x*y ne 0];
> #S6;
2
> S7 := [x*y:x in S6, y in S|x*y ne 0];
> #S7;
1
> S8 := [x*y:x in S7, y in S|x*y ne 0];
> #S8;
0
```

<a id="example-ex-bfaaa4"></a>
##### `Example: Basic Algebra of S3 in Characteristic 3 (ex-bfaaa4)`

First we create the basic algebra for the symmetric group $S_3$ over the field $GF(3)$

```magma
> FA<e1,e2,a,b> := FreeAlgebra(GF(3),4);
> MM:= [a*b*a, b*a*b];
> BS3 := BasicAlgebra(FA, MM, 2, [<1,2>,<2,1>]);
> BS3;
Basic algebra of dimension 6 over GF(3)
Number of projective modules: 2
Number of generators: 4
> DimensionsOfProjectiveModules(BS3);
[ 3, 3 ]
```

Next we create the basic algebra for the cyclic group of order 3.

```magma
> gg := CyclicGroup(3);
> BC3 := BasicAlgebra(gg,GF(3));
> BC3;
Basic algebra of dimension 3 over GF(3)
Number of projective modules: 1
Number of generators: 2
```

We create the basic algebra for the direct product $C_3 \times S_3$.

```magma
> A := TensorProduct(BS3,BC3);
> A;
Basic algebra of dimension 18 over GF(3)
Number of projective modules: 2
Number of generators: 6
> DimensionsOfProjectiveModules(A);
[ 9, 9 ]
```

<a id="example-ex-cfd0f2"></a>
##### `Example: Basic Algebra of A4 from Projective Modules (ex-cfd0f2)`

We create the basic algebra for $A_4$ over a field with 2 elements. The group algebra has two nonisomorphic projective modules. We define the basic algebra by constructing the matrix algebra for the projective modules and the path trees and entering this data into the `BasicAlgebra` function.

Note that the matrices are sparse so we will define them by specifying the nonzero rows.

```magma
> ff := GF(2);
> MM6 := MatrixAlgebra(ff,6);
> e11 := MM6!0;
> e12 := MM6!0;
> VV6 := VectorSpace(GF(2),6);
> BB6 := Basis(VV6);
> e11[1]  := BB6[1];
> e11[3]  := BB6[3];
> e11[4]  := BB6[4];
> e11[6]  := BB6[6];
> e12[2]  := BB6[2];
> e12[5]  := BB6[5];
> a1 := MM6!0;
> b1 := MM6!0;
> c1 := MM6!0;
> d1 := MM6!0;
> a1[1] := BB6[2];
> b1[1] := BB6[3];
> c1[2] := BB6[4];
> a1[3] := BB6[5];
> b1[4] := BB6[6];
> c1[5] := BB6[6];
> A1 := sub< MM6 | [e11, e12, a1, b1, c1, d1] >;
> T1 := [ <1,1>, <1,3>, <1,4>, <2,5>, <3,3>, <4,4>];
>
> VV5 := VectorSpace(ff,5);
> BB5 := Basis(VV5);
> MM5 := MatrixAlgebra(ff,5);
> e21 := MM5!0;
> e22 := MM5!0;
> e22[1]  := BB5[1];
> e22[3]  := BB5[3];
> e22[5]  := BB5[5];
> e21[2]  := BB5[2];
> e21[4]  := BB5[4];
> a2 := MM5!0;
> b2 := MM5!0;
> c2 := MM5!0;
> d2 := MM5!0;
> f2 := MM5!0;
> g2 := MM5!0;
> c2[1] := BB5[2];
> d2[1] := BB5[3];
> b2[2] := BB5[4];
> d2[3] := BB5[5];
> a2[4] := BB5[5];
> A2 := sub< MM5 | [e21, e22, a2, b2, c2, d2] >;
> T2 := [<1,2>, <1,5>, <1,6>, <2,4>, <3,6>];
>
> C := BasicAlgebra( [<A1, T1>, <A2, T2>] );
> C;
Basic algebra of dimension 11 over GF(2)
Number of projective modules: 2
Number of generators: 6
> DimensionsOfProjectiveModules(C);
[ 6, 5 ]
> DimensionsOfInjectiveModules(C);
[ 6, 5 ]
```

#### Boolean Functions

A basic algebra in Magma is a sequence of matrix algebras, each with a path tree. When a basic algebra is created by entering such a sequence, Magma does not check to see if all of the properties of a basic algebra are satisfied, as this is an expensive operation. The following two function check to see if the properties of a basic algebra are satisfied.

<a id="function-isdimensioncompatible-algbas"></a>
##### `IsDimensionCompatible(B): AlgBas -> Bool`

Returns `true` if the dimension of a basic algebra is the same as the dimension of the matrix algebra of its action on itself. If `false` then the algebra is not a basic algebra.

<a id="function-ispathtree-algbas"></a>
##### `IsPathTree(B): AlgBas -> Bool`

Returns `true` if the basis elements of the projective modules in the basic algebra are determined by the path tree. If `false`, then the algebra is not a true basic algebra.

##### Commutativity

Two other functions check commutativity.

<a id="function-iscommutative-algbas"></a>
###### `IsCommutative(A): AlgBas -> Bool`

Returns `true` if the basic algebra $A$ is commutative.

<a id="function-iscentral-algbas-algbaselt"></a>
###### `IsCentral(A, x): AlgBas, AlgBasElt -> BoolElt`

Returns `true` if the element $x$ is in the center of the basic algebra $A.$

##### Other Properties

<a id="function-issymmetric-algbas"></a>
###### `IsSymmetric(A): AlgBas -> BoolElt`

Returns `true` if the basic algebra A is a symmetric (Frobenius) algebra.

<a id="function-isselfinjective-algbas"></a>
###### `IsSelfInjective(A): AlgBas -> BoolElt`

Returns `true` if the basic algebra A is self injective.

### Homomorphisms

Magma has the capability of creating homomorphisms of basic algebras. A homomorphism of a basic algebra has the type Map. The matrix of the homomorphism $\phi$ is accessed by entering `Matrix(phi)`. The kernel of a homomorphism is returned as a subspace of the vector space of the domain of the algebra. This is a two-sided ideal. There is no special type for ideals. They are subspaces of the underlying vector space of the algebra. They can be generated from any given set of elements of the algebra

The image of a homomorphism is returned as a basic algebra, together with the embedding homomorphism.

A homomorphism from a basic algebra $A$ to a basic algebra $B$ is normally created from a matrix having dimension of $A$ rows and dimension of $B$ columns. Note that Magma does not automatically check to see if the created map is an algebra homomorphism.

<a id="constructor-constructor-hom-algbas-algbas-modmatfldelt-map"></a>
#### `hom<A -> B | S>: AlgBas, AlgBas, ModMatFldElt -> Map`

The algebra homomorphism from basic algebra $A$ to basic algebra $B$, whose matrix is the matrix S. Given a map $\phi$, a homomorphism of basic algebra, the matrix of that map is recalled with the command `Matrix(phi)`.

<a id="function-kernel-map"></a>
#### `Kernel(phi): Map -> ModTupFld`

The kernel of the map $\phi$.

<a id="function-image-map"></a>
#### `Image(phi): Map -> AlgBas, Map`

The image of the homomorphism $\phi$ together with the embedding homomorphism of the image into the codomain of $\phi$.

<a id="function-isalgebrahomomorphism-algbas-algbas-mtrx"></a>
#### `IsAlgebraHomomorphism(A, B, psi): AlgBas, AlgBas, Mtrx -> Bool`

Return `true` if the matrix $\psi$ represents a homomorphism from basic algebra A to basic algebra B.

<a id="operation-op-times-map-map"></a>
#### `X * Y: Map, Map -> Map`

The composition of the maps $X$ and $Y$.

<a id="function-isalgebrahomomorphism-algbas-algbas-map"></a>
#### `IsAlgebraHomomorphism(A, B, psi): AlgBas, AlgBas, Map -> Bool`

<a id="function-isalgebrahomomorphism-algbasgrpp-algbasgrpp-map"></a>
#### `IsAlgebraHomomorphism(A, B, psi): AlgBasGrpP, AlgBasGrpP, Map -> Bool`

<a id="function-isalgebrahomomorphism-algbasgrpp-algbas-map"></a>
#### `IsAlgebraHomomorphism(A, B, psi): AlgBasGrpP, AlgBas, Map -> Bool`

<a id="function-isalgebrahomomorphism-algbas-algbasgrpp-map"></a>
#### `IsAlgebraHomomorphism(A, B, psi): AlgBas, AlgBasGrpP, Map -> Bool`

Returns `true`, if the map $\psi$ is a homomorphism of basic algebras

<a id="function-isalgebrahomomorphism-map"></a>
#### `IsAlgebraHomomorphism(psi): Map -> Bool`

Returns `true` if the map $\psi$ is a homomorphism of basic algebras.

### Subalgebras and Quotient Algebras

A subalgebra is also returned with the embedding homomorphism, and a quotient algebra is returned with the natural quotient map. These are needed for creating some standard subalgebras such as the centre of the algebra.

#### Subalgebras and their Constructions

<a id="constructor-constructor-sub-algbas-seqenum-algbas-map"></a>
##### `sub<A | S>: AlgBas, SeqEnum -> AlgBas, Map`

The subalgebra of $A$ generated by the elements of the sequence $S$, together with the inclusion map of the subalgebra into $A$. The subalgebra contains the idempotent of minimal rank in $A$ that acts as a multiplicative identity on the elements of $S$.

<a id="function-subalgebrafrombasis-algbas-seqenum"></a>
##### `SubalgebraFromBasis(A, V): AlgBas, SeqEnum -> AlgBas, Map`

Given a basic algebra A and the basis $V$ of a subspace of $A$, the function returns the basic algebra which is the subalgebra spanned by the subspace and the inclusion matrix of the homomorphism embedding the subalgebra into $A.$ Note that the space $V$ might not contain the identity element of V and in that case the minimal possible identity element is added to the returned subalgebra.

<a id="function-maximalidempotent-algbas-seqenum"></a>
##### `MaximalIdempotent(A, S): AlgBas, SeqEnum -> AlgBasElt`

Given a basic algebra $A$, a subspace $S$ of the vector space of $A$ that is closed under multiplication, this function returns an idempotent in $A$ which has maximal rank among all idempotents contained in $S$.

<a id="function-minimalidentity-algbas-seqenum-algbaselt"></a>
##### `MinimalIdentity(A, S): AlgBas, SeqEnum[AlgBasElt] -> AlgBasElt`

Returns the idempotent of smallest rank that is a two sided identity for the elements in the set $S.$

<a id="function-centre-algbas"></a>
##### `Centre(A): AlgBas -> AlgBas, Map`

The centre of the basic algebra as a basic algebra together with the inclusion homomorphism.

<a id="function-centralizer-algbas-seqenum"></a>
##### `Centralizer(A, S): AlgBas, SeqEnum -> AlgBas, Map`

Returns the centralizer in the basic algebra $A$ of the elements in the sequence $S$, along with the homomorphism embedding the centralizer into $A.$

<a id="function-maximalcommutativesubalgebra-algbas-seqenum"></a>
##### `MaximalCommutativeSubalgebra(A, S): AlgBas, SeqEnum -> AlgBas, Map`

Returns a maximal commutative subalgebra of the basic algebra $A$ that contains the elements of the sequence $S$. An error occurs if the elements of $S$ do not commute.

#### Ideals and their Construction

<a id="constructor-constructor-ideal-algbas-seqenum-algbaselt-modtupfld"></a>
##### `ideal< A | S>: AlgBas, SeqEnum[AlgBasElt] -> ModTupFld`

<a id="constructor-constructor-ideal-algbasgrpp-seqenum-algbaselt-modtupfld"></a>
##### `ideal< A | S>: AlgBasGrpP, SeqEnum[AlgBasElt] -> ModTupFld`

Returns the subspace of the vector space of the algebra $A$ that is the ideal of the $A$ generated by the given sequence of elements $S$.

<a id="function-leftannihilator-algbas-seqenum-algbaselt"></a>
##### `LeftAnnihilator(A, S): AlgBas, SeqEnum[AlgBasElt] -> SeqEnum[AlgBasElt]`

Returns a basis for the left annihilator of the sequence $S$ of elements in the basic algebra $A.$

<a id="function-rightannihilator-algbas-seqenum-algbaselt"></a>
##### `RightAnnihilator(A, S): AlgBas, SeqEnum[AlgBasElt] -> SeqEnum[AlgBaselt]`

Returns a basis for the right annihilator of the sequence $S$ of elements in the basic algebra $A.$

<a id="function-annihilator-algbas-seqenum-algbaselt"></a>
##### `Annihilator(A, S): AlgBas, SeqEnum[AlgBasElt] -> SeqEnum[AlgBasElt]`

Returns a basis for the two-sided annihilator of the sequence of elements $S$ of the basic algebra $A.$

<a id="function-isideal-algbas-modtupfld"></a>
##### `IsIdeal(A, S): AlgBas, ModTupFld -> Bool`

Returns `true` if the subspace spanned by the elements of $S$ is a two-sided ideal of the basic algebra $A.$

<a id="function-isleftideal-algbas-modtupfld"></a>
##### `IsLeftIdeal(A, S): AlgBas, ModTupFld -> Bool`

Returns `true` if the subspace spanned by the elements of $S$ is a left ideal of the basic algebra $A.$

<a id="function-isrightideal-algbas-modtupfld"></a>
##### `IsRightIdeal(A, S): AlgBas, ModTupFld -> Bool`

Returns `true` if the subspace spanned by the elements of $S$ is a two-sided ideal of the basic algebra $A.$

<a id="function-randomidealgeneratedby-algbas-rngintelt"></a>
##### `RandomIdealGeneratedBy(A, n): AlgBas, RngIntElt -> ModTupFld`

Returns the ideal generated by $n$ randomly selected elements in the Jacobson radical of the basic algebra $A.$

#### Quotient Algebras

<a id="constructor-constructor-quo-algbas-modtupfld-algbas-map"></a>
##### `quo<A | S>: AlgBas, ModTupFld -> AlgBas, Map`

Returns the quotient algebra of $A$ by the ideal $S$, which is a subspace of the vector space of $A$, together with the quotient map.

<a id="function-coveralgebra-algbas"></a>
##### `CoverAlgebra(A): AlgBas -> AlgBas, ModMatFldElt`

Constructs the maximal extension B as in [$0 \rightarrow  K \rightarrow  B \rightarrow  A \rightarrow 0$] such that $B$ acts trivially on $K$ and $B$ is an algebra with exactly the same minimal number of generators as $A$. Returns $B$ and the algebra homomorphism of $B$ onto $A$.

<a id="function-gradedcoveralgebra-algbas"></a>
##### `GradedCoverAlgebra(A): AlgBas -> AlgBas, ModMatFldElt`

This assumes that we are given the truncated algebra of a graded algebra. It creates the basic algebra of the natural cover of $A$ and also returns the matrix of the cover onto $A.$

<a id="function-truncatedalgebra-algbas-rngintelt"></a>
##### `TruncatedAlgebra(A, n): AlgBas, RngIntElt -> AlgBas, ModMatFldElt`

The quotient of the algebra by the $n^{th}$ power of the radical of $A$. Returns also the quotient map.

#### Units

<a id="function-generatorsofgroupofunits-algbas"></a>
##### `GeneratorsOfGroupOfUnits(A): AlgBas -> SeqEnum, SeqEnum`

Returns a sequence of elements of the basic algebra $A$ that generate the group of invertible elements in $A$ and a sequence containing the inverses of those elements.

<a id="function-noncentralgeneratorsofgroupofunits-algbas"></a>
##### `NoncentralGeneratorsOfGroupOfUnits(A): AlgBas -> SeqEnum, SeqEnum`

Returns a sequence of elements of the basic algebra $A$ that generate the quotient of the group of invertible elements in $A$ by the subgroup of invertible central elements. The inverses of those elements is also returned as a sequence.

### Minimal Forms and Gradings

There are some standard ways of rewriting an algebra to an isomorphic form. We can also constructed the associated graded algebra of a basic algebra. Also included here is a function for rearranging the orders of idempotents in a basic algebra.

The first intrinsic is used extensively in the programs for computing automorphisms and isomorphisms.

<a id="function-minimalgeneratorform-algbas"></a>
#### `MinimalGeneratorForm(A): AlgBas -> Rec`

Returns a record consisting of an isomorphic basic algebra having the property that it is generated by a minimal number of elements and the projective modules are filtered by radical layers. The record consists of the following fields:

**(a)**
The algebra in minimal form (field `algebra`).

**(b)**
The map from the minimal generator form algebra to $A$ (field `Homomorphism`).

**(c)**
The inverse map from $A$ to the minimal generator form algebra (field `InverseHomomorphism`).

**(d)**
The dimensions of the radical layer (field `RadicalDimensions`).

**(e)**
The dimensions of the filtration of the top radical layer by the socle layer (field `FilterDimensions`).

<a id="function-minimalgeneratorformalgebra-algbas"></a>
#### `MinimalGeneratorFormAlgebra(A): AlgBas -> AlgBas`

Returns an isomorphic algebra having minimal generator form.

<a id="function-associatedgradedalgebra-algbas"></a>
#### `AssociatedGradedAlgebra(A): AlgBas -> AlgBas`

Returns the basic algebra that is isomorphic to the associated graded algebra of $A.$

<a id="function-gradedcaphomomorphism-algbas"></a>
#### `GradedCapHomomorphism(A): AlgBas -> ModMatFldElt`

Returns the matrix of the map from $A/Rad(A)$ to $X/Rad(X)$ where $X$ is the associated graded algebra of $A.$

<a id="function-gradedcaphomomorphism-algbas-algbas-modmatfldelt"></a>
#### `GradedCapHomomorphism(A, B, mu): AlgBas, AlgBas, ModMatFldElt -> ModMatFldElt`

Given an algebra homomorphism $mu: A \rightarrow B$, returns the induced homomorphism $A/\mathop{\hbox{\rm Rad}}^2(A) \rightarrow B/\mathop{\hbox{\rm Rad}}^2(B)$, where $\mathop{\hbox{\rm Rad}}^2$ is the second power of the Jacobson radical.

<a id="function-buildhomomorphismfromgradedcap-algbas-algbas-modmatfldelt"></a>
#### `BuildHomomorphismFromGradedCap(A, B, phi): AlgBas, AlgBas, ModMatFldElt -> ModMatFldElt`

Returns the graded homomorphism from the associated graded algebra $X$ of $A$ to the associated graded algebra $Y$ of $B$, whose cap is $\phi$. That is phi is the matrix of the induced homomorphism of $X/Rad^2(X)$ to $Y/Rad^2(Y).$

<a id="function-changeidempotents-algbas-seqenum"></a>
#### `ChangeIdempotents(A, S): AlgBas, SeqEnum -> AlgBas, Map`

<a id="function-changeidempotents-algbas-grppermelt"></a>
#### `ChangeIdempotents(A, S): AlgBas, GrpPermElt -> AlgBas, Map`

Returns the basic algebra isomorphic to $A$, obtained by permuting the order of the idempotents by the permutation $S$. The permutation $S$ can be given as an element of the symmetric group or as the sequence of images of the permutation.

<a id="example-ex-804d0a"></a>
#### `Example: Graded Properties of a Schur Algebra (ex-804d0a)`

In this examples we investigate properties of the basic algebra of a Schur algebra.

```magma
> A := BasicAlgebraOfSchurAlgebra(3,6,GF(3));
> A;
Basic algebra of dimension 48 over GF(3)
Number of projective modules: 7
Number of generators: 21
> B := BasicAlgebraOfExtAlgebra(A,10);
> B;
Basic algebra of dimension 98 over GF(3)
Number of projective modules: 7
Number of generators: 21
> C := BasicAlgebraOfExtAlgebra(B,10);
> C;
Basic algebra of dimension 48 over GF(3)
Number of projective modules: 7
Number of generators: 21
> boo,mat := IsIsomorphic(A,C);
> boo;
true
> IsAlgebraHomomorphism(mat);
true
```

So we see that $A$ is isomorphic to its double ext-algebra, and it is graded since the double ext-algebra is graded. Thus we know that the basic algebra $A$ is a Koszul algebra.

<a id="example-ex-27c999"></a>
#### `Example: Reordering Primitive Idempotents (ex-27c999)`

Here we see how to rearrange an algebra by changing the ordering on the primitive idempotents.

```magma
> A := BasicAlgebraOfSchurAlgebra(3,5,GF(3));
> A;
Basic algebra of dimension 11 over GF(3)
Number of projective modules: 5
Number of generators: 9
> B, uu  := ChangeIdempotents(A,[2,4,5,1,3]);
> B;
Basic algebra of dimension 11 over GF(3)
Number of projective modules: 5
Number of generators: 9
> DimensionsOfProjectiveModules(A);
[ 2, 3, 2, 1, 3 ]
> DimensionsOfProjectiveModules(B);
[ 3, 1, 3, 2, 2 ]
> IsAlgebraHomomorphism(A,B,uu);
true
> uu;
[0 0 0 0 0 0 0 1 0 0 0]
[0 0 0 0 0 0 0 0 1 0 0]
[1 0 0 0 0 0 0 0 0 0 0]
[0 1 0 0 0 0 0 0 0 0 0]
[0 0 1 0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 0 0 1 0]
[0 0 0 0 0 0 0 0 0 0 1]
[0 0 0 1 0 0 0 0 0 0 0]
[0 0 0 0 1 0 0 0 0 0 0]
[0 0 0 0 0 1 0 0 0 0 0]
[0 0 0 0 0 0 1 0 0 0 0]
```

We see that $uu$ is a permutation matrix.

### Automorphisms and Isomorphisms

Magma has the capability of computing automorphisms and isomorphisms of basic algebras. Because the automorphism groups tend to be rather large, the functions work best on small examples.

<a id="function-gradedautomorphismgroupmatchingidempotents-algbas"></a>
#### `GradedAutomorphismGroupMatchingIdempotents(A): AlgBas -> GrpMat, SeqEnum, SecEnum`

Returns the group of graded automorphisms of the basic algebra $A$ that preserve the idempotents of $A$. Returns also the graded caps (matrices of homomorphisms from $X/Rad^2(X)$ to itself, where $X$ is the Associated Graded algebra of $A$) of the generators of the automorphism group in two sequenced, nonunipotent generators and unipotent generators.

<a id="function-gradedautomorphismgroup-algbas"></a>
#### `GradedAutomorphismGroup(A): AlgBas -> GrpMat, SeqEnum[ModMatFldElt], SeqEnum[ModMatFldElt], SeqEnum[ModMatFldElt]`

Returns the group of graded automorphisms of the associated graded algebra $X$ of the basic algebra $A$. The function returns also the graded caps of the generators of the graded automorphism group. These are the induced automorphisms of $X/Rad^2(X)$ to itself, and they are returned as two lists of nonunipotent and unipotent generators that preserve the idempotents of $X$ and a list of generators that permute the idempotents.

<a id="function-isgradedisomorphic-algbas-algbas"></a>
#### `IsGradedIsomorphic(A, B): AlgBas, AlgBas -> Bool, ModMatFldElt`

Returns `true` if the associated graded algebras of $A$ and $B$ are isomorphic, in which case the isomorphism is returned.

<a id="function-automorphismgroupmatchingidempotents-algbas"></a>
#### `AutomorphismGroupMatchingIdempotents(A): AlgBas -> AlgBas, ModMatFldElt`

Returns the group of all automorphism of the basic algebra $A$ that preserve the basic idempotent structure. That is, any element of this group induces the identity automorphism on the quotient $A/Rad(A)$ of $A$ by its Jacobson radical.

<a id="function-automorphismgroup-algbas"></a>
#### `AutomorphismGroup(A): AlgBas -> GrpMat, SeqEnum, SeqEnum, SeqEnum`

Returns the automorphism group of the basic Algebra $A$, together with the sequences of nonnilpotent generators preserving idempotents, nilpotent generators preserving idempotents, and generators that permute the idempotents.

<a id="function-innerautomorphismgroup-algbas"></a>
#### `InnerAutomorphismGroup(A): AlgBas -> GrpMat`

Returns the group of inner automorphisms of the basic algebra $A$.

<a id="function-isisomorphic-algbas-algbas"></a>
#### `IsIsomorphic(A, B): AlgBas, AlgBas -> Bool, Map`

Returns `true` if the basic algebra $A$ is isomorphic to the basic algebra $B$ and, if so, the function also returns an isomorphism.

<a id="example-ex-4a1204"></a>
#### `Example: Automorphism Group of a Group Algebra (ex-4a1204)`

We compute the automorphism group of a group algebra.

```magma
> A := BasicAlgebra(SmallGroup(81, 7));
> time ba := AutomorphismGroup(A);
Time: 6.260
> #ba;
687170027642681774715281506354161696936143362668
> Factorization(#ba);
[ <2, 2>, <3, 99> ]
```

As expected the automorphism group has a very large unipotent 3-subgroup.

<a id="example-ex-1b7b38"></a>
#### `Example: Changing a Presentation (ex-1b7b38)`

We can see if small changes in the presentation of an algebra affect the isomorphism type. We define the algebras by generators and relations.

```magma
> F<e1,e2,z,y,x> := FreeAlgebra(GF(5),5);
> RR:= [(y*z)^3,x^4,x*y*z];
> A := BasicAlgebra(F,RR,2,[<1,2>,<2,1>,<2,2>]);
> A;
Basic algebra of dimension 49 over GF(5)
Number of projective modules: 2
Number of generators: 5
> RS:= [(y*z)^3-x^4,x^5,x*y*z,(z*y)^3];
> B := BasicAlgebra(F,RS,2,[<1,2>,<2,1>,<2,2>]);
> B;
Basic algebra of dimension 49 over GF(5)
Number of projective modules: 2
Number of generators: 5
> RT:= [(y*z)^3-2*x^4,x^5,x*y*z,(z*y)^3];
> C := BasicAlgebra(F,RS,2,[<1,2>,<2,1>,<2,2>]);
> C;
Basic algebra of dimension 49 over GF(5)
Number of projective modules: 2
Number of generators: 5
> time ab, x := IsIsomorphic(A,B);
Time: 0.100
> ab;
false
> time ac, x := IsIsomorphic(A,C);
Time: 0.050
> print ac;
false
> time bc,x := IsIsomorphic(B,C);
Time: 2.350
> print bc;
true
```

<a id="example-ex-ac24e3"></a>
#### `Example: Graded Group Algebras of Order 32 (ex-ac24e3)`

We can see which groups of order 32 have mod 2 group algebras that are graded. The algebra is graded if and only if it is isomorphic to its associated graded algebra. So we make a list of those algebras whose group algebras are graded. Note that there are 51 isomorphism classes of groups of order 32. The last one (number 51) is elementary abelian and we know that its group algebra is graded.

```magma
> graded := [];
> for i := 1 to 50 do
>     A := BasicAlgebra(SmallGroup(32,i));
>     B := AssociatedGradedAlgebra(A);
>     boo, map := IsIsomorphic(A, B);
>     if boo then Append(~graded, i); end if;
> end for;
> graded;
[ 1, 2, 3, 5, 9, 12, 14, 16, 18, 21, 22, 25, 36, 39, 45, 46 ]
```

### Quiver and Relations

<a id="function-quiver-algbas"></a>
#### `Quiver(A): AlgBas -> SeqEnum`

For a basic algebra $A$, this intrinsic returns the quiver of $A$. The quiver is returned as a sequence of integer pairs where each pair represents an arrow. The first integer of a pair is the index of the source and the second is the index of the target of the arrow.

<a id="function-quiverandrelations-algbas"></a>
#### `QuiverAndRelations(A): AlgBas -> SeqEnum, SeqEnum, SeqEnum`

For a basic algebra $A$, this intrinsic returns the quiver of $A$ and associated relations. The first return value is the quiver where each arrow is given as a pair consisting of the index of the source and the index of the target of the arrow. The second return value is a sequence containing relations on the quiver. The third return value is a sequence containing a condensed sequence of relations that does not contain the obvious relations of degree two where the head of the first arrow does not match the tail of the second.

<a id="example-ex-3af24d"></a>
#### `Example: Quiver of the Principal Block of A7 (ex-3af24d)`

In this example we construct the quiver and relations for the basic algebra of the principal block of the alternating group $A_7$ over $GF(2)$.

```magma
> G := AlternatingGroup(7);
> A := BasicAlgebraOfPrincipalBlock(G, GF(2));
> A;
Basic algebra of dimension 19 over GF(2)
Number of projective modules: 3
Number of generators: 8
> quiv, rels, crels := QuiverAndRelations(A);
> quiv;
[ <1, 2>, <1, 3>, <2, 1>, <2, 2>, <3, 1> ]
> rels;

[
    $.1*$.3*$.2*$.5 + $.2*$.5*$.1*$.3,
    $.3*$.2*$.5*$.1 + $.4^2,
    $.1*$.4,
    $.3*$.1 + $.4^2,
    $.4*$.3,
    $.5*$.2,
    $.1^2,
    $.2*$.1,
    $.4*$.1,
    $.1*$.2,
    $.2^2,
    $.4*$.2,
    $.2*$.3,
    $.3^2,
    $.5*$.3,
    $.2*$.4,
    $.3*$.4,
    $.5*$.4,
    $.1*$.5,
    $.3*$.5,
    $.4*$.5,
    $.5^2
]

> crels;

[
    $.1*$.3*$.2*$.5 + $.2*$.5*$.1*$.3,
    $.3*$.2*$.5*$.1 + $.4^2,
    $.1*$.4,
    $.3*$.1 + $.4^2,
    $.4*$.3,
    $.5*$.2
]
```

### Modules over Basic Algebras

A module $M$ over a basic algebra $B$ is presented as a sequence of matrices, one for each generator of the algebra.

#### Indecomposable Projective Modules

The indecomposable projective modules are defined from the structure of the algebra and have associated path trees that solve the homomorphism lifting problem.

<a id="function-projectivemodule-algbas-rngintelt"></a>
##### `ProjectiveModule(B, i): AlgBas, RngIntElt -> ModRng`

The $i^{th}$ projective module of the basic algebra $B$.

<a id="function-pathtree-algbas-rngintelt"></a>
##### `PathTree(B, i): AlgBas, RngIntElt -> ModRng`

The path tree of the $i^{th}$ projective module of the basic algebra $B$.

<a id="function-actiongenerator-algbas-rngintelt"></a>
##### `ActionGenerator(B, i): AlgBas, RngIntElt -> SeqEnum`

The sequence of matrices for the generators of the basic algebra $B$ acting on the $i^{th}$ projective module of $B$.

<a id="function-idempotentactiongenerators-algbas-rngintelt"></a>
##### `IdempotentActionGenerators(B, i): AlgBas, RngIntElt -> SeqEnum`

The sequence of matrices for the idempotent generators of the basic algebra $B$ acting on the $i^{th}$ projective module of $B$.

<a id="function-nonidempotentactiongenerators-algbas-rngintelt"></a>
##### `NonIdempotentActionGenerators(B, i): AlgBas, RngIntElt -> SeqEnum`

The sequence of matrices for the nonidempotent generators of the basic algebra $B$ acting on the $i^{th}$ projective module of $B$.

<a id="function-injection-algbas-rngintelt-modrngelt"></a>
##### `Injection(B, i, v): AlgBas, RngIntElt, ModRngElt -> AlgBasElt`

Given a vector $v$ in the $i^{th}$ projective module of the basic algebra $B$, the function returns the image of inclusion of $v$ into $B$.

#### Creation

<a id="function-amodule-algbas-seqenum-algmatelt"></a>
##### `AModule(B, Q): AlgBas, SeqEnum[AlgMatElt] -> ModRng`

Given a basic algebra $B$ and a sequence $Q$ of elements in a matrix algebra the function returns the $B$-module $M$ on which the generators of $B$ act by multiplication by the corresponding elements of $Q$.

<a id="function-projectivemodule-algbas-seqenum-rngintelt"></a>
##### `ProjectiveModule(B, S): AlgBas, SeqEnum[RngIntElt] -> ModAlg, SeqEnum, SeqEnum`

Given a sequence $S = [s_1,s_2, ... ]$, the function returns a projective module which is the direct sum of $s_1$ copies of the first projective of the algebra $B$, $s_2$ copies of the second, etc. It also returns the sequence of inclusions and projections from and to the indecomposable projective modules.

<a id="function-irreduciblemodule-algbas-rngintelt"></a>
##### `IrreducibleModule(B, i): AlgBas, RngIntElt -> ModAlg`

<a id="function-simplemodule-algbas-rngintelt"></a>
##### `SimpleModule(B, i): AlgBas, RngIntElt -> ModAlg`

The $i^{th}$ irreducible module of the algebra $B$. The module is the quotient of the $i^{th}$ projective module by its radical.

<a id="function-zeromodule-algbas"></a>
##### `ZeroModule(B): AlgBas -> ModAlg`

The zero $B$-module.

<a id="function-rightregularmodule-algbas"></a>
##### `RightRegularModule(B): AlgBas -> ModAlg`

The algebra $B$ as a right module over itself. The module is the direct sum of the projectives modules of $B$.

<a id="function-regularrepresentation-algbaselt"></a>
##### `RegularRepresentation(v): AlgBasElt -> AlgMatElt`

If $v$ is an element of a basic algebra given as a vector in the underlying space, then the function computes the matrix of the action by right multiplication of the element on the algebra.

<a id="function-restriction-modalgbas-algbas-modmatfldelt"></a>
##### `Restriction(M, B, xi): ModAlgBas, AlgBas, ModMatFldElt -> ModAlgBas`

If $B$ is a subalgebra of the basic algebra $A$, $\xi$ is the embedding of $B$ into $A$, and $M$ is an $A$-module, then the function returns the restriction of M to a B-module.

<a id="function-changealgebra-modalgbas-algbas-map"></a>
##### `ChangeAlgebra(M, B, xi): ModAlgBas, AlgBas, Map -> ModAlgBas`

<a id="function-changealgebra-modalgbas-algbas-modmatfldelt"></a>
##### `ChangeAlgebra(M, B, xi): ModAlgBas, AlgBas, ModMatFldElt -> ModAlgBas`

Given a module $M$ over an algebra $A$ and an algebra homomorphism $\xi$ from $B$ to $A$, the function returns the module $M$ as a $B$-module.

<a id="function-jacobsonradical-modalg"></a>
##### `JacobsonRadical(M): ModAlg -> ModAlg`

The Jacobson radical of the module $M$.

<a id="function-socle-modalg"></a>
##### `Socle(M): ModAlg -> ModAlg`

The socle of the module $M$. The sum of the simple submodules of $M$.

#### Access Functions

<a id="function-algebra-modalg"></a>
##### `Algebra(M): ModAlg -> AlgBas`

Given a module $M$ over a basic algebra $B$, the function returns $B$.

<a id="function-dimension-modalg"></a>
##### `Dimension(M): ModAlg -> RngIntElt`

The dimension of the module $M$ over its base ring.

<a id="function-action-modalg"></a>
##### `Action(M): ModAlg -> AlgMat`

The matrix algebra of the action of the algebra of $M$ on $M$.

<a id="function-isomorphismtypesofradicallayers-modalgbas"></a>
##### `IsomorphismTypesOfRadicalLayers(M): ModAlgBas -> SeqEnum`

Given a module $M$ over a basic algebra, returns the sequence of isomorphism types of simple composition factors in each layer of the radical filtration of $M$.

<a id="function-isomorphismtypesofsoclelayers-modalgbas"></a>
##### `IsomorphismTypesOfSocleLayers(M): ModAlgBas -> SeqEnum`

Given a module $M$ over a basic algebra, returns a sequence of isomorphism types of simple composition factors in each socle layer with reversed order, *i. e.* isomorphism types of the socle of $M$ will appear last.

<a id="function-isomorphismtypesofbasicalgebrasequence-seqenum"></a>
##### `IsomorphismTypesOfBasicAlgebraSequence(S): SeqEnum -> SeqEnum`

Given a sequence of irreducible modules $S$ for a basic algebra $A$, return a sequence of isomorphism types comparing with the simple modules of $A$.

<a id="example-ex-6be5c5"></a>
##### `Example: Restricting a Module to the Center (ex-6be5c5)`

We show the restriction of a module over an algebra $A$ to a subalgebra of $A$.

```magma
> G := SmallGroup(32,7);
> A := BasicAlgebra(G);
> C, mu := Center(A);
> X := RightRegularModule(A);
> Z := JacobsonRadical(X);
> L := Restriction(Z,C,mu);
> L;
AModule L of dimension 31 over GF(2)
> A eq Algebra(L);
True
> IndecomposableSummands(L);
[
    AModule of dimension 1 over GF(2),
    AModule of dimension 30 over GF(2)
]
> Dimension(Socle(L));
16
```

Next we show how to pull back modules along a quotient map. We use the same algebra $A$.

```magma
> U := ideal<A|[A.13 +A.17]>;
> Q, theta := quo<A|U>;
> X := ProjectiveModule(Q,1);
> Y := ChangeAlgebras(X,A,theta);
> Y;
AModule Y of dimension 16 over GF(2)
```

<a id="example-ex-5bc3d0"></a>
##### `Example: Pulling Back a Module Along a Quotient (ex-5bc3d0)`

Here is another example of pulling back a module along a quotient map. This one involves algebras with more than one idempotent.

```magma
> load m11;
Loading "/usr/local/dmagma/libs/pergps/m11"
M11 - Mathieu group on 11 letters - degree 11
Order 7 920 = 2^4 * 3^2 * 5 * 11;  Base 1,2,3,4
Group: G
> A:= BasicAlgebraOfPrincipalBlock(G,GF(2));
> A;
Basic algebra of dimension 22 over GF(2)
Number of projective modules: 3
Number of generators: 9
> DimensionsOfProjectiveModules(A);
[ 8, 8, 6 ]
> I := ideal<A|[A.9]>;
> B, mu := quo<A|I>;
> B;
Basic algebra of dimension 6 over GF(2)
Number of projective modules: 2
Number of generators: 5
> P := ProjectiveModule(B,1);
> P;
AModule P of dimension 3 over GF(2)
> Q := ChangeAlgebras(P,A,mu);
> Algebra(Q) eq A;
true
```

<a id="example-ex-e824ff"></a>
##### `Example: Projective Modules of a Hecke Algebra (ex-e824ff)`

In this example, we investigate the structure of the projective modules of a basic algebra.

```magma
> G := PSL(3,3);
> N := Normalizer(G,Sylow(G,2));
> A := BasicAlgebraOfHeckeAlgebra(G,N,GF(2));
> DimensionsOfProjectiveModules(A);
[ 1, 2, 3, 9, 9, 1, 1, 1, 1 ]
> IsomorphismTypesOfRadicalLayers(ProjectiveModule(A,4));
[
    [ 4 ],
    [ 2, 3, 4, 5 ],
    [ 4, 4, 5 ],
    [ 5 ]
]
> IsomorphismTypesOfSocleLayers(ProjectiveModule(A,4));
[
    [ 4 ],
    [ 3, 4, 5 ],
    [ 2, 4, 5 ],
    [ 4, 5 ]
]
```

So we see that, unlike a group algebra, a Hecke algebra can have indecomposable projective modules whose socles are not simple.

#### Predicates

The following functions return a boolean value.

<a id="function-issemisimple-modalg"></a>
##### `IsSemisimple(M): ModAlg -> BoolElt, SeqEnum`

Returns `true` if the module $M$ is a semisimple module and `false` otherwise. If `true`, then the function also returns a list of the ranks of the primitive idempotents of the algebra. This is also a list of the multiplicities of the simple modules of the algebra as composition factors in a composition series for the module.

<a id="function-isprojective-modalg"></a>
##### `IsProjective(M): ModAlg -> BoolElt, SeqEnum`

Returns `true` if the module $M$ is projective. The function also returns a sequence of multiplicities of the standard projective modules as direct summands of the projective cover of $M$.

<a id="function-isinjective-modalg"></a>
##### `IsInjective(M): ModAlg -> BoolElt, SeqEnum`

Returns `true` if the module $M$ is injective. The function also returns a sequence of multiplicities of the standard injective modules as direct summands of the injective hull of $M$.

#### Elementary Operations

<a id="operation-op-times-modalgelt-algbaselt"></a>
##### `m * b: ModAlgElt, AlgBasElt -> ModAlgElt`

Given an element $b$ in a basic algebra $B$ and an element $m$ in a module $M$ over $B$, $m*b$ is the product.

<a id="example-ex-bb4604"></a>
##### `Example: Radical Layers of an Extraspecial Group Algebra (ex-bb4604)`

We obtain the dimensions of the radical layers of the group algebra of an extra special group of order 243 over a field of characteristic 3.

```magma
> G := ExtraSpecialGroup(3,2);
> G;
Permutation group G acting on a set of cardinality 243
> ff := GF(3);
> A := BasicAlgebra(G,ff);
> A;
Basic algebra of dimension 243 over GF(3)
Number of projective modules: 1
Number of generators: 6
> P := ProjectiveModule(A,1);
> P;
AModule P of dimension 243 over GF(3)
> R := JacobsonRadical(P);
> R;
AModule R of dimension 242 over GF(3)
> while Dimension(R) ne 0 do
>     T := JacobsonRadical(R);
>     print Dimension(R) - Dimension(T);
>     R := T;
> end while;
4
11
20
30
36
39
36
30
20
11
4
1
```

<a id="example-ex-2f301a"></a>
##### `Example: Inducing the Trivial Module (ex-2f301a)`

We consider the mod-2 group algebra of an extraspecial group of order 128, and construct the module induced from the trivial module on the subgroups of order 4 generated by the first generator of the group.

```magma
> G := ExtraSpecialGroup(2,3);
> G;
Permutation group G acting on a set of cardinality 128
> F := GF(2);
> A := BasicAlgebra(G,F);
> A;
Basic algebra of dimension 128 over GF(2)
Number of projective modules: 1
Number of generators: 8
> A.1;
(1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0)
```

Note that `A.1` is the unique idempotent (identity element) in the group algebra, whereas `A.2` is `G.1 - 1` where `G.1` is the first generator of the group.

```magma
> A.2;
(0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0)
> g := A.1+A.2;
```

Now we check the order of `g`.

```magma
> g^2;
(1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0)
> g^4;
(1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0 0 0 0)
> g^4 eq A!1;
true
```

So `g` has order 4.

```magma
> P := ProjectiveModule(A,1);
> P;
AModule P of dimension 128 over GF(2)
```

Note that `P` is generated by `P.1` which corresponds to the identity element of `A` if we think of `P` as the algebra `A` as a module over itself. Now we create the induced module as the submodule generated by $(\hbox{\tt g}-1)^3$, since $(\hbox{\tt g}-1)^4 = 0$.

```magma
> U := sub<P|P.1*A.6>;
> U;
AModule U of dimension 32 over GF(2)
```

Because the dimension is a quarter of the order of the group we can be sure that we have the right thing by just checking that `U` is generated by a `g` fixed point.

```magma
> U.1*g eq U.1;
true
```

### Homomorphisms of Modules

A homomorphism from module $M$ to module $N$ is simply a matrix that commutes with the action of the algebra on $M$ and $N$.

#### Creation

<a id="function-ahom-modalg-modalg"></a>
##### `AHom(M, N): ModAlg, ModAlg -> ModMatFld`

The space of homomorphisms from module $M$ to module $N$.

<a id="function-phom-modalg-modalg"></a>
##### `PHom(M, N): ModAlg, ModAlg -> ModMatFld`

The space of projective homomorphisms from module $M$ to module $N$. That is, the space of all homomorphisms that factor through a projective module.

<a id="function-zeromap-modalg-modalg"></a>
##### `ZeroMap(M, N): ModAlg, ModAlg -> ModMatFld`

The zero homomorphism from module $M$ to module $N$.

<a id="function-lifthomomorphism-modalgelt-rngintelt"></a>
##### `LiftHomomorphism(x, n): ModAlgElt, RngIntElt -> ModMatFldElt`

Given an element $x$ in a module over a basic algebra and a natural number $n$, the function returns the homomorphism from the $n^{th}$ projective module for the algebra to the module with the property that the idempotent $e$ of the projective module maps to $x*e$.

<a id="function-lifthomomorphism-seqenum-modalgelt-seqenum-rngintelt"></a>
##### `LiftHomomorphism(X, N): SeqEnum[ModAlgElt], SeqEnum[RngIntElt] -> ModMatFldElt`

Given a sequence $X = [x_1, \ldots, x_t]$ of elements in a module $M$ over a basic algebra and a sequence $N = [n_1, \ldots, n_s]$ of nonnegative integers, such that $n_1 + \ldots + n_s = t$, the function returns the homomorphism $P \rightarrow M$ from the projective module $P = \sum_{j=1}^s P_j^{n_i}$ to $M$ that takes the idempotent $e$ for the $i^{th}$ summand in $P$ to the element $x_i*e$ in $M$. Here $P_{j}$ denotes the $j^{th}$ projective module for the algebra.

<a id="function-pushout-modalg-modmatfldelt-modalg-modmatfldelt-modalg"></a>
##### `Pushout(M, f1, N1, f2, N2): ModAlg, ModMatFldElt, ModAlg, ModMatFldElt, ModAlg -> ModAlg, ModMatFldElt, ModMatFldElt`

The pushout of the diagram

$$

   \begin{matrix}M & \xrightarrow{f_1} & N_1 \\
   \mathop{\downarrow}\limits^{f_2} & & \\
   N_2 & & \end{matrix}
$$

The function returns the module $L = (N_1 \oplus N_2)/\{(f_1(m),-f_2(m))\vert m \in M\}$ and the homomorphisms $g_1:N_1 \longrightarrow L$ and $g_2: N_2 \longrightarrow L$ such that $f_1g_1 = f_2g_2$.

<a id="function-pullback-modalg-modmatfldelt-modalg-modmatfldelt-modalg"></a>
##### `Pullback(f1, M1, f2, M2, N): ModAlg, ModMatFldElt, ModAlg, ModMatFldElt, ModAlg -> ModAlg, ModMatFldElt, ModMatFldElt`

The pullback of the diagram

$$

   \begin{matrix}& & M_2 \\
    & & \mathop{\downarrow}\limits^{f_2}\\
   M_1 & \xrightarrow{f_1} & N \end{matrix}
$$

The function returns the module $L = \{(m_1,m_2) \in M_1 \oplus M_2 \vert f_1(m_1) = f_2(m_2)\}$ and the homomorphisms $g_1:L\longrightarrow M_1$ and $g_2: L \longrightarrow M_2$ such that $g_1f_1 = g_2f_2$.

#### Access Functions

<a id="function-ismodulehomomorphism-modmatfldelt"></a>
##### `IsModuleHomomorphism(f): ModMatFldElt -> BoolElt`

Returns `true` if the map $f$ is a homomorphism of modules over the algebra.

<a id="function-domain-modmatfldelt"></a>
##### `Domain(f): ModMatFldElt -> ModAlg`

The domain of $f$.

<a id="function-codomain-modmatfldelt"></a>
##### `Codomain(f): ModMatFldElt -> ModAlg`

The codomain of $f$.

<a id="function-kernel-modmatfldelt"></a>
##### `Kernel(f): ModMatFldElt -> ModAlg, ModMatFldElt`

The kernel of $f$ and the inclusion of the kernel in `Domain(f)`.

<a id="function-cokernel-modmatfldelt"></a>
##### `Cokernel(f): ModMatFldElt -> ModAlg, ModMatFldElt`

The cokernel of $f$ and the quotient map from `Codomain(f)` onto the cokernel.

#### Projective Covers and Resolutions

A projective cover of a module $M$ is a projective module $P$ and a surjective homomorphism $\phi:P \longrightarrow M$ such that $P$ is minimal with respect to the property of having such a surjective homomorphism to $M$. A projective resolution to $n$ steps of an $A$-module $M$ is a pair consisting of a complex

$$
P_n \xrightarrow{\partial_n} P_{n-1} \longrightarrow  \ldots
\longrightarrow P_1 \xrightarrow{\partial_1} P_0
$$

which is exact except at the ends, and an augmentation homomorphism $\epsilon: P_0 \rightarrow M$ that is a projective cover of $M$. In addition, the image of $\partial_1$ must equal the kernel of $\epsilon$. The resolution is minimal if each $P_i$ is a projective cover of its image in $P_{i-1}$. In this case the $i^{th}$ syzygy module is the image of $\partial_i$.

In the implementation the main function is `CompactProjectiveResolution`. This function computes a minimal projective resolution of a given module and stores the minimal amount of information that is necessary to create the boundary maps and the terms of the resolution. It runs relatively fast because it avoids the computation of the terms of the projective resolution as modules over the algebra. Instead the terms in the compact resolution are only vector spaces together with a sequence of types for the projective modules. The other information that is recorded is the sequence of images of the generators for the indecomposable projective modules. That is, for the boundary map

$$
P_n \xrightarrow{\partial_n} P_{n-1}
$$

the module $P_n \cong \oplus_{i = 1}^m Q_i$ where each $Q_i$ is an indecomposable projective module generated by an element $a_i$ corresponding to the appropriate idempotent in the basic algebra. The function records the images $\partial_n(a_i)$ as a sequence of vectors in the vector space of the module $P_{n-1}$.

<a id="function-projectivecover-modalg"></a>
##### `ProjectiveCover(M): ModAlg -> ModAlg, ModMatFldElt, SeqEnum[ModMatFldElt], SeqEnum[ModMatFldElt], SeqEnum[RngIntElt]`

The projective cover of the module $M$ given as the projective module $P$, the surjective homomorphism of $P$ onto $M$, the sequences of inclusion and projection homomorphism of $P$ from and to its indecomposable direct summands and the isomorphism type of $P$ in the form of a list of the number of copies of the projective modules of the algebra of each type that make up $P$.

<a id="function-projectiveresolution-modalg-rngintelt"></a>
##### `ProjectiveResolution(M, n): ModAlg, RngIntElt -> ModCpx, ModMatFldElt`

The complex giving the minimal projective resolution of the module $M$ out to $n$ steps together with the augmentation homomorphism from the projective cover of $M$ into $M$. Note that homomorphisms go from left to right so that last term of the complex (in degree 0) is the projective cover of $M$ and the cokernel of the last homomorphism in the complex is $M$. The complex is constructed from the compact projective resolution of $M$. The function creates the compact projective resolution if it has not already been computed.

<a id="function-compactprojectiveresolution-modalg-rngintelt"></a>
##### `CompactProjectiveResolution(M, n): ModAlg, RngIntElt -> Rec`

Returns a minimal projective resolution for the module $M$ out to $n$ steps in compact form together with the augmentation map ($P_0 \rightarrow M$). The compact form of the resolution is a list of the minimal pieces of information needed to reconstruct the boundary maps in the resolution. That is the boundary map ($P_i \xrightarrow{\partial_i} P_{i-1}$) is recorded as a matrix whose entries are the images of the generators for indecomposable projective modules making up $P_i$ in the indecomposable projective modules making up $P_{i-1}$. If a compact projective resolution has been previously computed to degree $m$ and $m < n$ then the function extends that resolution by $n-m$ steps. If $m \geq n$ the function returns the previously computed compact projective resolution. The function returns a record with the fields:

**(a)**
The list of isomorphism types of the projective modules in the resolution, each given as a sequence of integers giving the number of direct summands of each indecomposable projective in the module (field name `BettiNumbers`).

**(b)**
The record of the boundary maps (field name `ResolutionRecord`).

**(c)**
The module $M$ (field name `Module`).

**(d)**
The augmentation map (field name `AugmentationMap`).

**(e)**
The type of the resolution, whether projective or injective (field name `Typ`).

<a id="function-compactprojectiveresolutionsofsimplemodules-algbas-rngintelt"></a>
##### `CompactProjectiveResolutionsOfSimpleModules(A, n): AlgBas, RngIntElt -> SeqEnum`

Returns a sequence of the compact projective resolutions of the simple A-modules computed to degree $n$.

<a id="function-syzygymodule-modalg-rngintelt"></a>
##### `SyzygyModule(M, n): ModAlg, RngIntElt -> ModAlg`

The $n^{th}$ syzygy module of the module $M$. The module is constructed from the compact projective resolution of $M$. The compact resolution is constructed if it does not already exist.

<a id="function-simplehomologydimensions-modalg"></a>
##### `SimpleHomologyDimensions(M): ModAlg -> SeqEnum`

The sequence of sequences of dimensions of the homology groups $\hbox{Tor}_j(S_i,M)$ for simple modules $S_i$ and module $M$, to the extent that they have been computed.

<a id="example-ex-8bea28"></a>
##### `Example: Projective Resolution for a Quiver Algebra (ex-8bea28)`

We consider the basic algebra of a quiver with relation. The quiver has four nodes and 5 nonidempotent generators $(a,b,c,d,e)$. The first goes from node 1 to node 2, the second from 2 to 3, the third from 3 to 4, the fourth from 3 to 2, and the last from 4 to 1. They satisfy the relations $bcfadbd = (abcf)^5ab = (bd)^2b = 0$.

```magma
> ff := GF(8);
> FA<e1,e2,e3,e4,a,b,c,d,f> := FreeAlgebra(ff,9);
> rrr := [b*c*f*a*b*d*b,a*b*c*f*a*b*c*f*a*b*c*f*a*b*c*f*a*b*c*f*a*b,
>     b*d*b*d*b];
> BA := BasicAlgebra(FA,rrr,4,[<1,2>,<2,3>,<3,4>,<3,2>,<4,1>]);
> BA;
Basic algebra of dimension 296 over GF(2^3)
Number of projective modules: 4
Number of generators: 9
```

Now we take the projective resolutions of the simple modules out to 5 steps. We print the type of the projective module at each stage.

```magma
> for i := 1 to 4 do
>     S := SimpleModule(BA,i);
>     prj := CompactProjectiveResolution(S, 5);
>     SimpleHomologyDimensions(S);
> end for;
[
    [ 0, 0, 10, 0 ],
    [ 0, 0, 5, 0 ],
    [ 0, 0, 2, 0 ],
    [ 0, 0, 1, 0 ],
    [ 0, 1, 0, 0 ],
    [ 1, 0, 0, 0 ]
]
[
    [ 0, 0, 16, 0 ],
    [ 0, 0, 8, 0 ],
    [ 0, 0, 4, 0 ],
    [ 0, 0, 2, 0 ],
    [ 0, 0, 1, 0 ],
    [ 0, 1, 0, 0 ]
]
[
    [ 0, 0, 0, 0 ],
    [ 0, 0, 0, 0 ],
    [ 0, 0, 0, 0 ],
    [ 0, 0, 0, 0 ],
    [ 0, 1, 0, 1 ],
    [ 0, 0, 1, 0 ]
]
[
    [ 0, 0, 0, 0 ],
    [ 0, 0, 0, 0 ],
    [ 0, 0, 0, 0 ],
    [ 0, 0, 0, 0 ],
    [ 1, 0, 0, 0 ],
    [ 0, 0, 0, 1 ]
]
```

So we see that the third and fourth simple modules have finite projective dimension. The projective resolutions of the first and second simple modules appear to have exponential rates of growth but the terms after the second term are all direct sums of copies of the third projective module.

```magma
> for i := 1 to 4 do
>     Dimension(Socle(ProjectiveModule(BA,i)));
> end for;
12
13
25
12
```

Notice that the socles of the projective modules have very large dimensions so the injective resolutions are probably going to grow at a very rapid rate.

<a id="example-ex-c5e505"></a>
##### `Example: Quotient of an Extraspecial Group Algebra (ex-c5e505)`

We create the quotient of the group algebra of a $p$-group by the ideal generated by a central element. In particular, we choose the group algebra of an extra special 3-group and factor out the ideal generated by $(z-1)^2$ where $z$ is a central element of order 3. Then we compare the size of the projective resolution of the trivial module for the new algebra with that of the antecedent group algebra.

```magma
> G := ExtraSpecialGroup(3,1);
> F := GF(3);
> B := BasicAlgebra(G,F);
> B;
Basic algebra of dimension 27 over GF(3)
Number of projective modules: 1
Number of generators: 4
> s := NonIdempotentGenerators(B)[3];
```

Now check that `s` is in the center.

```magma
> [s*x eq x*s: x in Generators(B)];
[ true, true, true, true ]
> P := ProjectiveModule(B,1);
> Q := quo<P|P.1*s^2>;
> Q;
AModule Q of dimension 18 over GF(3)
```

We need to create the path tree for the projective module of the matrix algebra of the action on `Q`. In this case it is an easy exercise because the last 9 element of the basis of the projective module for `B` span the submodule that we are factoring out. This can actually be seen from the path tree for the projective module of `B`.

```magma
> PathTree(B,1);
[ <1, 1>, <1, 2>, <2, 2>, <1, 3>, <2, 3>, <3, 3>, <4, 3>,
<5, 3>, <6, 3>, <1, 4>, <2, 4>, <3, 4>, <4, 4>, <5, 4>,
<6, 4>, <7, 4>, <8, 4>, <9, 4>, <10, 4>, <11, 4>, <12, 4>,
<13, 4>, <14, 4>, <15, 4>, <16, 4>, <17, 4>, <18, 4> ]
```

So we get the path tree for the new module by truncation.

```magma
> PT := [PathTree(B,1)[j]: j in [1 .. 18]];
> PT;
[ <1, 1>, <1, 2>, <2, 2>, <1, 3>, <2, 3>, <3, 3>,
<4, 3>, <5, 3>, <6, 3>, <1, 4>, <2, 4>, <3, 4>,
<4, 4>, <5, 4>, <6, 4>, <7, 4>, <8, 4>, <9, 4> ]
```

Now form the new basic algebra.

```magma
> C := BasicAlgebra([<Action(Q),PT>]);
> C;
Basic algebra of dimension 18 over GF(3)
Number of projective modules: 1
Number of generators: 4
> S := SimpleModule(C,1);
> prj := CompactProjectiveResolution(S, 15);
> SimpleHomologyDimensions(S);
[ 92, 77, 70, 57, 51, 40, 35, 26, 22, 15, 12, 7, 5, 2, 1 ]
```

Now compare this with the projective resolution for the group algebra.

```magma
> T := SimpleModule(B,1);
> pj2 := CompactProjectiveResolution(T,15);
> SimpleHomologyDimensions(T);
[ 20, 18, 17, 16, 15, 14, 12, 10, 9, 8, 7, 6, 4, 2, 1 ]
```

### Duals and Injectives

If $k$ is the base ring for the algebra $A$ then the $k$-dual $\hbox{Hom}_k(M,k)$ for a right module $M$ over $A$ is a right module over the opposite algebra $OA$ of $A$. Furthermore, the dual of a projective $OA$-module is an injective $A$-module and the dual of a projective $OA$-resolution of a module $M$ is an $A$-injective resolution of the dual of $M$.

<a id="function-dual-modalg"></a>
#### `Dual(M): ModAlg -> ModAlg`

Given a module $M$ defined over a basic algebra $M$, this function returns the dual of $M$ as a module over the opposite of the algebra of $M$. Note that the opposite of the algebra of $M$ is created if it does not already exist.

<a id="function-basechangematrix-algbas"></a>
#### `BaseChangeMatrix(A): AlgBas -> ModAlg`

Given a basic algebra $A$ that has opposite algebra $O$, the function creates the change of basis matrix $B$ from the vector space of $A$ to the vector space of $O$, so that if $x$, $y$ are in $A$ then $(xy)B$ is the same as $(yB)(xB) \in O$.

#### Injective Modules

Injective hulls, and injective resolutions of a module are computed by taking the projective cover or projective resolution of the dual module over the opposite algebra and then again taking the dual to retrieve modules or complexes over the original algebra. If the opposite algebra of the module has not been computed then it will be created in the evaluation of any of the injective module functions.

<a id="function-injectivemodule-algbas-rngintelt"></a>
##### `InjectiveModule(B, i): AlgBas, RngIntElt -> ModAlg`

The $i^{th}$ injective module of the algebra $B$.

<a id="function-injectivehull-modalg"></a>
##### `InjectiveHull(M): ModAlg -> ModAlg, ModMatFldElt, SeqEnum[ModMatFldElt], SeqEnum[ModMatFldElt], SeqEnum[RngIntElt]`

The injective hull of the module $M$ is the injective module $I$ of minimal dimension such that there is an inclusion $\iota: M \rightarrow I$. The function returns $I$, $\iota$, the sequences of inclusions and projections from and to the indecomposable injective summands of $I$, and the type of $I$ as a sequence $T := [t_1 \ldots, t_s]$ where $I$ has $t_1$ summands of type  1, $t_2$ of type  2, etc.

<a id="function-injectiveresolution-modalg-rngintelt"></a>
##### `InjectiveResolution(M, n): ModAlg, RngIntElt -> ModCpx, ModMatFldElt`

The complex giving the minimal injective resolution of the module $M$ together with the inclusion homomorphism from $M$ into its injective hull. Note that homomorphisms go from left to right so that the kernel of the first homomorphism in the complex is $M$. The function computes the compact injective resolution and creates the complex of the injective resolution from that.

<a id="function-compactinjectiveresolution-modalg-rngintelt"></a>
##### `CompactInjectiveResolution(M, n): ModAlg, RngIntElt -> Rec`

A minimal injective resolution for the module $M$ out to $n$ steps in compact form together with the coaugmentation map ($M \rightarrow I_0$). The compact form of the resolution is a list of the minimal pieces of information needed to reconstruct the boundary maps in the resolution. That is, the boundary map ($I_{i-1} \xrightarrow{\partial_i} I_i$) is recorded as a matrix whose entries are the images of the generators for indecomposable injective modules making up $I_{i-1}$ in the indecomposable projective modules making up $I_i$. The actual return of the function is the compact projective resolution of the dual module of $M$ over the opposite algebra of the algebra of $M$. The return is a record with the fields:

**(a)**
The list of isomorphism types of the injective modules in the resolution, each given as a sequence of integers giving the number of direct summands of each indecomposable injective in the module (field name `BettiNumbers`).

**(b)**
The record of the boundary maps (field name `ResolutionRecord`).

**(c)**
The module $M$ (field name `Module`).

**(d)**
The coaugmentation map (field name `CoaugmentationMap`).

**(e)**
The type of the resolution, whether projective or injective (field name `Typ`).

<a id="function-injectivesyzygymodule-modalg-rngintelt"></a>
##### `InjectiveSyzygyModule(M, n): ModAlg, RngIntElt -> ModAlg`

The $n^{th}$ injective-syzygy module of $M$. The module is constructed from the compact injective resolution of $M$. The compact resolution is constructed if it does not already exist.

<a id="function-simplecohomologydimensions-modalg"></a>
##### `SimpleCohomologyDimensions(M): ModAlg -> SeqEnum`

The sequence of sequences of dimensions of the cohomology groups $\hbox{Ext}^j(S_i,M)$ for simple modules $S_i$ and module $M$, to the extent that they have been computed.

<a id="example-ex-51e2ac"></a>
##### `Example: Injective Modules of a Quiver Algebra (ex-51e2ac)`

We create the basic algebra of a quiver over a field with 8 elements. The quiver has two nodes and three arrows, going from node 1 to node 2, from 2 to 1, and from 1 to 1. The relations are given in the sequence `rrr`.

```magma
> ff := GF(8);
> FA<e1,e2,a,b,c> := FreeAlgebra(ff,5);
> rrr := [a*b*a*b*a, c*c*c*c, a*b*c - c*a*b];
> B := BasicAlgebra(FA,rrr,2,[<1,2>,<2,1>,<1,1>]);
> B;
Basic algebra of dimension 41 over GF(2^3)
Number of projective modules: 2
Number of generators: 5
> DimensionsOfProjectiveModules(B);
[ 20, 21 ]
> DimensionsOfInjectiveModules(B);
[ 24, 17 ]
> P1 := ProjectiveModule(B,1);
> Socle(P1);
AModule of dimension 1 over GF(2^3)
```

We consider the injective resolution of the first projective module.

```magma
> time in1 := CompactInjectiveResolution(P1,10);
reverse trees
Time: 3.850
```

Note that part of the time was required to create the opposite algebra of `B`.

```magma
> SimpleCohomologyDimensions(P1);
[
    [ 1, 0 ],
    [ 0, 4 ],
    [ 4, 0 ],
    [ 4, 0 ],
    [ 4, 0 ],
    [ 4, 0 ],
    [ 4, 0 ],
    [ 4, 0 ],
    [ 4, 0 ],
    [ 4, 0 ]
]
```

The injective resolution appears to be periodic. Now we look at a module constructed from the resolution.

```magma
> M := InjectiveSyzygyModule(P1,6);
> M;
AModule M of dimension 64 over GF(2^3)
```

Consider the space of endomorphisms of M.

```magma
> hh := AHom(M,M);
> hh;
KMatrixSpace of 64 by 64 matrices and dimension 128 over GF(2^3)
> [Rank(hh.i): i in [1 .. Dimension(hh)]];
[ 16, 16, 16, 16, 12, 12, 12, 12, 8, 8, 8, 8, 8, 8, 8, 8, 6, 6, 6, 6, 4, 4, 4,
4, 4, 4, 4, 4, 2, 2, 2, 2, 4, 8, 12, 16, 16, 12, 8, 4, 8, 4, 12, 16, 4, 8, 12,
16, 16, 16, 16, 16, 2, 4, 6, 8, 8, 6, 4, 2, 4, 2, 6, 8, 2, 4, 6, 8, 12, 12, 12,
12, 8, 8, 8, 8, 8, 8, 8, 8, 6, 6, 6, 6, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 16,
16, 16, 16, 12, 12, 12, 12, 8, 8, 8, 8, 8, 8, 8, 8, 6, 6, 6, 6, 4, 4, 4, 4, 4,
4, 4, 4, 2, 2, 2, 2 ]
```

Note that no generator of the endomorphism ring has rank more than 16. This would indicate that the module is decomposable since the identity map must be a sum of homomorphisms of smaller rank.

How can we produce a decomposition? One method is the following.

```magma
> vv := Random(hh);
> Rank(vv);
64
> vv*vv eq vv;
false
> [Rank(vv*vv-u*vv):u in ff];
[ 60, 64, 64, 64, 64, 64, 64, 64 ]
> [u:u in ff];
[ 1, ff.1, ff.1^2, ff.1^3, ff.1^4, ff.1^5, ff.1^6, 0 ]
> Rank(vv*vv - vv);
60
> U := vv*vv - vv;
> Rank(U);
60
> Rank(U*U);
56
> Rank(U*U*U);
52
> Rank(U*U*U*U);
48
> Rank(U*U*U*U*U);
48
> Rank(U*U*U*U*U*U);
48
> T := U*U*U*U;
> N1 := Kernel(T);
> N2 := Image(T);
> Dimension(N1);
16
> Dimension(N2);
48
> Dimension(N1+N2);
64
```

So the sum of `N1` and `N2` must be all of `M` and by counting dimensions, it must be a direct sum.

### Cohomology

<a id="function-cohomologyringgenerators-rec"></a>
#### `CohomologyRingGenerators(P): Rec -> Rec`

Given a compact projective resolution $P$ for a simple module $S$ over a basic algebra $A$, the function returns the chain maps in compact form of a minimal set of generators for the cohomology $\hbox{Ext}_A^*(S, S)$, as well as some other information. The record that is returned has the following fields:

**(a)**
The list of maps in compact form for the chain map of the generators (field name `ChainMapRecord`).

**(b)**
The sequence of degrees of cohomology generators (field name `ChainDegrees`).

**(c)**
The tops of the chain maps (maps on modules modulo radicals) for the purposes of computing products (field name `TopsOfCohomologyGenerators`).

**(d)**
The tops of the chain maps representing monomials in the generators (field name `TopsOfCohomologyChainMaps`).

**(e)**
The original compact projective resolution (field name `ProjectiveResolution`).

<a id="function-cohomologyrightmodulegenerators-rec-rec-rec"></a>
#### `CohomologyRightModuleGenerators(P, Q, CQ): Rec, Rec, Rec -> Rec`

Given projective resolutions $P$ and $Q$ for simple modules $S$ and $T$ over a basic algebra $A$ and the cohomology generators $CQ$ for $T$ associated to the resolution $Q$, the function returns the chain maps in compact form of the minimal generators for the cohomology $\hbox{Ext}_A^*(S, T)$ as a right module over the cohomology ring $\hbox{Ext}_A^*(T,T)$. The function returns a record consisting of the following fields.

**(a)**
The list of maps in compact form for the chain map of each cohomology generator (field name `ChainMapRecord`).

**(b)**
The sequence of degrees of cohomology generators (field name `ChainDegrees`).

**(c)**
The tops of the chain maps (maps on modules module radicals) for the purposes of computing products (field name `TopsOfCohomologyGenerators`).

<a id="function-cohomologyleftmodulegenerators-tup-tup-tup"></a>
#### `CohomologyLeftModuleGenerators(P, CP, Q): Tup, Tup, Tup -> Tup`

Given projective resolutions $P$ and $Q$ for simple modules $S$ and $T$ over a basic algebra $A$ and the cohomology generators $CP$ for $T$ associated to the resolution $Q$, the function returns the chain maps in compact form of the minimal generators for the cohomology $\hbox{Ext}_A^*(S, T)$ as a left module over the cohomology ring $\hbox{Ext}_A^*(S, S)$. The function returns a record consisting of the following fields.

**(a)**
The list of maps in compact form for the chain map of each cohomology generator (field name `ChainMapRecord`).

**(b)**
The sequence of degrees of cohomology generators (field name `ChainDegrees`).

**(c)**
The tops of the chain maps (maps on modules module radicals) for the purposes of computing products (field name `TopsOfCohomologyGenerators`).

<a id="function-degreesofcohomologygenerators-rec"></a>
#### `DegreesOfCohomologyGenerators(C): Rec -> SeqEnum`

Given the generators $C$ for cohomology, as either module generators or as ring generators, the function returns the list of degrees of the minimal generators.

<a id="function-cohomologygeneratortochainmap-modcpx-modcpx-rec-rngintelt"></a>
#### `CohomologyGeneratorToChainMap(P, Q, C, n): ModCpx, ModCpx, Rec, RngIntElt -> MapChn`

Given the projective resolutions $P$ and $Q$ of two modules $M$ and $N$ and the cohomology generators $C$ of the cohomology module, ${\rm Ext}_B^*(M,N)$, the function returns the chain map from $P$ to $Q$ that lifts the $n^{th}$ generator of the cohomology module and has degree equal to the degree of that generator.

<a id="function-cohomologygeneratortochainmap-modcpx-tup-rngintelt"></a>
#### `CohomologyGeneratorToChainMap(P, C, n): ModCpx, Tup, RngIntElt -> MapChn`

Given the projective resolution $P$ of a module and the cohomology generators $C$ of the cohomology ring of that module, the function returns the chain map from $P$ to $P$ that lifts the $n^{th}$ generator of the cohomology ring and has degree equal to the degree of that generator.

<a id="example-ex-6a7d27"></a>
#### `Example: Cohomology of the Principal Block of M11 (ex-6a7d27)`

We create the Basic algebra for the principal block of the sporadic simple group $M_{11}$ in characteristic 2. The block algebra has three simple modules of dimension 1, 44, and 10. The basic algebra has dimension 22.

```magma
> ff := GF(2);
> VV8 := VectorSpace(ff,8);
> BB8 := Basis(VV8);
> MM8 := MatrixAlgebra(ff,8);
> e11 := MM8!0;
> e12 := MM8!0;
> e13 := MM8!0;
> e11[1]  := BB8[1];
> e11[4]  := BB8[4];
> e11[5]  := BB8[5];
> e11[8]  := BB8[8];
> e12[2]  := BB8[2];
> e12[7]  := BB8[7];
> e13[3]  := BB8[3];
> e13[6]  := BB8[6];
> a1 := MM8!0;
> b1 := MM8!0;
> c1 := MM8!0;
> d1 := MM8!0;
> e1 := MM8!0;
> f1 := MM8!0;
> a1[1] :=  BB8[2];
> a1[5] :=  BB8[7];
> b1[1] :=  BB8[3];
> b1[4] :=  BB8[6];
> c1[2] :=  BB8[4];
> c1[7] :=  BB8[8];
> e1[3] :=  BB8[5];
> e1[6] :=  BB8[8];
> f1[3] :=  BB8[6];
> A1 := sub< MM8 | [e11, e12, e13, a1, b1, c1, d1, e1, f1] >;
> T1 := [ <1,1>,<1,4>,<1,5>,<2,6>,<3,8>,<4,5>,<5,4>,<6,8>];
> VV6 := VectorSpace(ff,6);
> BB6 := Basis(VV6);
> MM6 := MatrixAlgebra(ff,6);
> e21 := MM6!0;
> e22 := MM6!0;
> e23 := MM6!0;
> e22[1]  := BB6[1];
> e22[5]  := BB6[5];
> e22[6]  := BB6[6];
> e21[2]  := BB6[2];
> e21[4]  := BB6[4];
> e23[3]  := BB6[3];
> a2 := MM6!0;
> b2 := MM6!0;
> c2 := MM6!0;
> d2 := MM6!0;
> e2 := MM6!0;
> f2 := MM6!0;
> a2[4] := BB6[6];
> b2[2] := BB6[3];
> c2[1] := BB6[2];
> d2[1] := BB6[5];
> d2[5] := BB6[6];
> e2[3] := BB6[4];
> A2 := sub< MM6 | [e21, e22, e23, a2, b2, c2, d2, e2, f2]>;
> T2 := [ <1,2>, <1,6>, <2,5>, <3,8>, <1,7>, <5,7> ];
> VV8 := VectorSpace(ff,8);
> BB8 := Basis(VV8);
> MM8 := MatrixAlgebra(ff,8);
> e31 := MM8!0;
> e32 := MM8!0;
> e33 := MM8!0;
> e31[2]  := BB8[2];
> e31[6]  := BB8[6];
> e32[4]  := BB8[4];
> e33[1]  := BB8[1];
> e33[3]  := BB8[3];
> e33[5]  := BB8[5];
> e33[7]  := BB8[7];
> e33[8]  := BB8[8];
> a3 := MM8!0;
> b3 := MM8!0;
> c3 := MM8!0;
> d3 := MM8!0;
> e3 := MM8!0;
> f3 := MM8!0;a3[2] :=  BB8[4];
> b3[6] :=  BB8[8];
> b3[2] :=  BB8[7];
> c3[4] :=  BB8[6];
> e3[1] :=  BB8[2];
> e3[3] :=  BB8[6];
> f3[1] :=  BB8[3];
> f3[3] :=  BB8[5];
> f3[5] :=  BB8[7];
> f3[7] :=  BB8[8];
> A3 := sub< MM8 | [e31, e32, e33, a3, b3, c3, d3, e3, f3] >;
> T3 := [ <1,3>,<1,8>,<1,9>,<2,4>,<3,9>,<4,6>,<5,9>,<6,5>];
>
> m11 := BasicAlgebra( [<A1, T1>, <A2, T2>, <A3, T3>] );
> m11;
Basic algebra of dimension 22 over GF(2)
Number of projective modules: 3
Number of generators: 9
> s1 := SimpleModule(m11,1);
> s2 := SimpleModule(m11,2);
```

Now we compute the projective resolutions of the first and second simple modules. Then we find the degrees of their cohomology ring generators.

```magma
> prj1 := CompactProjectiveResolution(s1,20);
> prj2 := CompactProjectiveResolution(s2,20);
> CR1 := CohomologyRingGenerators(prj1);
> CR2 := CohomologyRingGenerators(prj2);
> DegreesOfCohomologyGenerators(CR1);
[ 3, 4, 5 ]
> DegreesOfCohomologyGenerators(CR2);
[ 1, 2 ]
```

Finally we look at the cohomology $\hbox{Ext}(\hbox{\tt s2},\hbox{\tt s1})$ as a left module over the cohomology ring of `s1` and as a right module over the cohomology ring of `s2`.

```magma
> CR12 := CohomologyLeftModuleGenerators(prj1,CR1,prj2);
> DegreesOfCohomologyGenerators(CR12);
[ 1, 2, 3, 4 ]
> CR12 := CohomologyRightModuleGenerators(prj1,prj2,CR2);
> DegreesOfCohomologyGenerators(CR12);
[ 1 ]
```

So as a module over the cohomology ring of `s1` it is generated by 4 elements. But as a module over the cohomology ring of `s2` it is generated by a single element.

Next we get the chain complex for the projective resolution of the first simple module and the chain map for the third generator of the cohomology ring of the first simple module.

```magma
> pj1 := ProjectiveResolution(s1,20);
> pj1;
Basic algebra complex with terms of degree 20 down to 0
Dimensions of terms: 74 66 68 68 60 54 54 54 48 40 40 42 34 26 28 28 20 14 14
   14 8
> gen113 := CohomologyGeneratorToChainMap(pj1,CR1,3);
> gen113;
Basic algebra chain map of degree -5
```

We can compose this with itself.

```magma
> gen113*gen113;
Basic algebra chain map of degree -10
```

Now compute the kernel and the dimensions of the homology of the kernel.

```magma
> Ker, phi := Kernel(gen113);
> Ker, phi;
Basic algebra complex with terms of degree 20 down to 0
Dimensions of terms: 20 15 19 20 20 17 17 20 22 15 17 22 20 15 19 20 20 14 14
14 8
Basic algebra chain map of degree 0
> DimensionsOfHomology(Ker);
[ 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0 ]
```

We apply the same procedure in the case of the cokernel.

```magma
> Cok, mu := Cokernel(gen113);
> Cok, mu;
Basic algebra complex with terms of degree 20 down to 0
Dimensions of terms: 74 66 68 68 60 0 3 5 0 0 3 5 0 0 3 5 0 0 3 5 0
Basic algebra chain map of degree 0
> DimensionsOfHomology(Cok);
[ 0, 0, 0, 27, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 2 ]
```

We can also check the image.

```magma
> Imm, theta, gamma := Image(gen113);
> Imm;
Basic algebra complex with terms of degree 20 down to 0
Dimensions of terms: 0 0 0 0 0 54 51 49 48 40 37 37 34 26 25 23 20 14 11 9 8
> DimensionsOfHomology(Imm);
[ 0, 0, 0, 0, 27, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0 ]
```

We can check that certain things make sense.

```magma
> IsChainMap(theta);
true
> IsChainMap(gamma);
true
```

#### Ext-Algebras

The ext-algebra of an algebra $B$ is the algebra $Ext_B^*(S,S)$ for $S = S_1 \oplus \dots \oplus S_n$ where $S_1, \dots, S_n$ are all of the simple $B$-modules. In the event that the algebra $B$ had finite global dimension, this is a finite dimensional algebra and we can form its basic algebra.

<a id="function-extalgebra-algbas-rngintelt"></a>
##### `ExtAlgebra(A, n): AlgBas, RngIntElt -> Rec`

The function computes the information on the ext-algebra $B$ of the basic algebra $A$ where the projective resolutions and cohomology have been computed to degree $n$. The function returns a record carrying the data:

**(i)**
A free algebra $F$,

**(ii)**
A list of relations in the elements of $F$, such that the ext-algebra is the quotient $F/I$ where $I$ is the ideal generated by the relations,

**(iii)**
The sequence of chain maps of the generators. Each chain map goes from the projective resolution of one simple module to that of another.

**(iv)**
The sequence of degrees of the generators.

**(v)**
A sequence of sequences of sequences of basis element such the $j^{th}$ element of the $i^{th}$ sequence is a basis of in $Ext^*_A(S_i,S_j)$ where $S_i$ is the $i^{th}$ simple module.

**(vi)**
A basis of the entire ext-algebra, the concatenation of the previous sequences.

**(vii)**
The number of steps of the cohomology that were computed.

**(viii)**
The global dimension that has been computed. This number is smaller than the number of steps only in the case that the global dimension of $A$ is less than $n$, meaning that the $n^{th}$ step in the projective resolution of any simple module is the zero module.

<a id="function-basicalgebraofextalgebra-rec-2"></a>
##### `BasicAlgebraOfExtAlgebra(ext): Rec -> AlgBas`

The function creates the basic algebra from a computed ext-algebra. The input is the output of the `ExtAlgebra` function. If the ext-algebra is not verified to be finite dimensional by the computation, then an error is returned.

<a id="function-basicalgebraofextalgebra-algbas-2"></a>
##### `BasicAlgebraOfExtAlgebra(A): AlgBas -> AlgBas`

The function forms the basic algebra from a computed ext-algebra of the basic algebra $A$. If no ext-algebra for $A$ has been computed or if the ext-algebra is not verified to be finite dimensional then an error is returned.

<a id="function-basicalgebraofextalgebra-algbas-rngintelt-2"></a>
##### `BasicAlgebraOfExtAlgebra(A, n): AlgBas, RngIntElt -> AlgBas`

The function creates the basic algebra for the ext-algebra of $A$ computed to $n$ steps. If no ext-algebra for $A$ to $n$ steps has been computed then it computes one. If the ext-algebra is not verified to be finite dimensional by the computation, then an error is returned.

<a id="function-sumofbettinumbersofsimplemodules-algbas-rngintelt"></a>
##### `SumOfBettiNumbersOfSimpleModules(A, n): AlgBas, RngIntElt -> RngIntElt`

This function computes the Betti numbers of all of simple $A$-modules out to degree $n$. This is the dimension of the ext-algebra of $A$ computed to degree $n$.

<a id="example-ex-0c2786"></a>
##### `Example: Ext-Algebra of Lower Triangular Matrices (ex-0c2786)`

We construct the basic algebra of the algebra $B$ of lower triangular matrices over the field with 5 elements. Note that because the identity element of $B$ is the sum of primitive idempotents of rank 1, $B$ is actually isomorphic to its basic algebra.

```magma
> A := MatrixAlgebra(GF(5),10);
> U := A!0;
> ElementaryMatrix := function(i,j);
>     W := U;
>     W[i,j] := 1;
>     return W;
> end function;
> S := &cat[[ElementaryMatrix(i,j): i in [j .. 10]]:j in [1 .. 10]];
> B := sub<A|S>;
> B;
Matrix Algebra of degree 10 with 55 generators over GF(5)
> C := BasicAlgebra(B);
> C;
Basic algebra of dimension 55 over GF(5)
Number of projective modules: 10
Number of generators: 19
```

Note that $C$ has the same dimension as $B$. The two are isomorphic, though they have different types.

```magma
> SumOfBettiNumbersOfSimpleModules(C,9);
19
> SumOfBettiNumbersOfSimpleModules(C,10);
19
```

From the above we see that $C$ has global dimension at most 9. Consequently, we can compute the basic algebra of its ext-algebra.

```magma
> D:= ExtAlgebra(C,10);
> E := BasicAlgebraOfExtAlgebra(D);
> E;
Basic algebra of dimension 19 over GF(5)
Number of projective modules: 10
Number of generators: 19
> SumOfBettiNumbersOfSimpleModules(E,8);
54
> SumOfBettiNumbersOfSimpleModules(E,9);
55
> SumOfBettiNumbersOfSimpleModules(E,10);
55
```

Here we see that $E$ has global dimension 9. So we compute the basic algebra of its ext-algebra.

```magma
> F := BasicAlgebraOfExtAlgebra(E,10);
> F;
Basic algebra of dimension 55 over GF(5)
Number of projective modules: 10
Number of generators: 19
> G := BasicAlgebraOfExtAlgebra(F,10);
> G;
Basic algebra of dimension 19 over GF(5)
Number of projective modules: 10
Number of generators: 19
```

So it would appear that $C$ and $F$ are isomorphic as well as $E$ and $G$.

### Group Algebras of $p$-groups

There is a special type for the basic algebras which are the modular group algebras of $p$-groups for $p$ a prime. If $G$ is a finite $p$ and $k$ is a field of characteristic $p$, then the commands `BasicAlgebra(G,k)` and `BasicAlgebra(G)` automatically create a basic algebra of type `AlgBasGrpP`. The type is optimized for the computation of cohomology rings. Included for this type are restriction and inflation maps. Most of the functions for modules and complexes are the same as for general basic algebras.

#### Access Functions

<a id="function-group-algbasgrpp"></a>
##### `Group(A): AlgBasGrpP -> Grp`

The group which defines the algebra $A$.

<a id="function-pcgroup-algbasgrpp"></a>
##### `PCGroup(A): AlgBasGrpP -> Grp`

The internal PC group of the algebra $A$.

<a id="function-pcmap-algbasgrpp"></a>
##### `PCMap(A): AlgBasGrpP -> Map`

The map from `Group(A)` to `PCGroup(A)` for an algebra $A$.

<a id="function-amodule-modgrp"></a>
##### `AModule(M): ModGrp -> ModAlg`

Converts a `GModule` $M$ over a $p$-group to a module over the basic algebra of that group.

<a id="function-gmodule-algbasgrpp"></a>
##### `GModule(M): AlgBasGrpP -> ModGrp, ModGrp`

Returns the standard module of the algebra $A$ as a module over `Group(A)` and as a module over `PCGroup(A)`.

<a id="function-gmodule-modalgbas"></a>
##### `GModule(M): ModAlgBas -> ModGrp`

Converts a module $M$ for the basic algebra of a $p$-group into a module over the $p$-group.

#### Projective Resolutions

<a id="function-resolutiondata-algbasgrpp"></a>
##### `ResolutionData(A): AlgBasGrpP -> Rec`

Returns the data needed to compute the projective resolution of an $A$-module for an algebra $A$. The data is given as a record with the fields:

**(a)**
The matrices of the `PCGenerators` of the $p$-group on the standard indecomposable projective module for the algebra (field name `PCgenMats`).

**(b)**
The matrices of the minimal generators of the p-group on the standard indecomposable projective module for the algebra (field name `MingenMats`).

**(c)**
The algebra $A$ (field name `Algebra`).

<a id="function-compactprojectiveresolutionpgroup-modalgbas-rngintelt"></a>
##### `CompactProjectiveResolutionPGroup(M, n): ModAlgBas, RngIntElt -> Rec`

<a id="function-compactprojectiveresolution-modalgbas-rngintelt"></a>
##### `CompactProjectiveResolution(M, n): ModAlgBas, RngIntElt -> Rec`

Computes the projective resolution of the module $M$ out to $n$ steps. The function returns a record with the fields:

**(a)**
The list of the ranks of the projective modules in the resolution (field name `BettiNumbers`).

**(b)**
The record of the boundary maps (field name `ResolutionRecord`).

**(c)**
The module $M$ (field name `Module`).

**(d)**
The augmentation map (field name `AugmentationMap`).

**(e)**
The type of the resolution, whether projective or injective (field name `Typ`).

<a id="function-projectiveresolutionpgroup-rec"></a>
##### `ProjectiveResolutionPGroup(PR): Rec -> ModCpx`

The projective resolution as a complex of modules over the basic algebra of the group algebra, computed from the compact projective resolution $PR$.

<a id="function-projectiveresolution-modalgbas-rngintelt"></a>
##### `ProjectiveResolution(M, n): ModAlgBas, RngIntElt -> ModCpx, ModMatFldElt`

The projective resolution of the module $M$ computed as a complex out to $n$ steps. The function also returns the augmentation map.

<a id="function-projectiveresolution-rec"></a>
##### `ProjectiveResolution(PR): Rec -> ModCpx, ModMatFldElt`

The projective resolution computed from a compact projective resolution $PR$ as a complex. The function also returns the augmentation map.

#### Cohomology Generators

<a id="function-allcompactchainmaps-rec"></a>
##### `AllCompactChainMaps(PR): Rec -> Rec`

Creates the data on the chain maps for all generators of the cohomology of the simple module $k$ in degrees within the limits of the compact projective resolution $PR$ of the simple module. The function returns a record having the following information.

**(a)**
The record of the chain maps of the generators of cohomology (field name `ChainMapRecord`).

**(b)**
The sequence of sizes of the chain map record (field name `ChainSizes`).

**(c)**
The degrees of the chain maps (field name `ChainDegrees`).

**(d)**
The list of cocycles representing the generators (field name `Cocycles`).

**(e)**
The record of the products of the generators (field name `ProductRecord`).

**(f)**
The locations of the products of the generators (field name `ProductLocations`). Much of the information is for use in the computation of the cohomology ring.

<a id="function-cohomologyelementtochainmap-modcpx-rngintelt-rngintelt"></a>
##### `CohomologyElementToChainMap(P, d, n): ModCpx, RngIntElt, RngIntElt -> MapChn`

Creates a chain map from the projective resolution $P$ to itself for the element number $n$ in degree $d$ of cohomology.

<a id="function-cohomologyelementtocompactchainmap-rec-rngintelt-rngintelt"></a>
##### `CohomologyElementToCompactChainMap(PR, d, n): Rec, RngIntElt, RngIntElt -> ModMatFldElt`

Creates a chain map in compact form from the compact projective resolution $PR$ to itself for the element number $n$ in degree $d$ of cohomology.

#### Cohomology Rings

<a id="function-cohomologyring-modalgbas-rngintelt"></a>
##### `CohomologyRing(k, n): ModAlgBas, RngIntElt -> Rec`

<a id="function-cohomologyring-rec-rec"></a>
##### `CohomologyRing(PR, AC): Rec, Rec -> Rec`

The cohomology ring of the unique simple module $k$ for the basic algebra of the group algebra of a $p$-group. The input can be given either as the module $k$ and the number of steps $n$ or as the compact projective resolution $PR$ of $k$ together with $AC$, the calculation of the chain map generators of the cohomology. In the former case the compact resolution and the chain map of the generators are computed in the process. The ring is returned as a record having the following fields:

**(a)**
The polynomial ring or free graded-commutative $k$-algebra $R$ generated by the cohomology generators (field name `PolRing`).

**(b)**
The ideal of relations in $R$ satisfied by the cohomology generators (field name `RelationsIdeal`).

**(c)**
The list of relations that have been computed (field name `ComputedRelations`).

**(d)**
The chain maps giving the tops of the monomial in the cohomology generators (field name `MonomialData`).

**(e)**
The number of computed steps in the resolution (field name `NumberOfSteps`).

<a id="function-minimalrelations-rec"></a>
##### `MinimalRelations(R): Rec -> SeqEnum`

A minimal set of relations generating the relations ideal of a cohomology ring $R$.

#### Restrictions and Inflations

<a id="function-restrictiondata-algbasgrpp-algbasgrpp"></a>
##### `RestrictionData(A, B): AlgBasGrpP, AlgBasGrpP -> ModMatFldElt, ModMatFldElt, SeqEnum`

Assuming that $A$ is the basic algebra of a $p$-group $G$ and that $B$ is the basic algebra of a subgroup of $G$, the function returns the change of basis matrix that make the standard free module for $A$ into a direct sum of standard free modules for $B$. It also returns the inverse of the matrix and a set of coset representatives of the `PCGroup(B)` in `PCGroup(A)`.

<a id="function-restrictresolution-rec-rec"></a>
##### `RestrictResolution(PR, RD): Rec, Rec -> ModCpx`

Takes the compact projective resolution $PR$ for the trivial module of $G$ and the resolution data $RD$ for the basic algebra of a subgroup $H$ and returns the restriction of the resolution to a complex of modules over the basic algebra for $H$.

<a id="function-restrictionchainmap-rec-rec"></a>
##### `RestrictionChainMap(P1, P2): Rec, Rec -> MapChn`

Computes the chain map from the resolution $P2$ of the simple module for the basic algebra of a subgroup $H$ of a group $G$ to the restriction to $H$ of the resolution $P1$ of the simple module for the basic algebra of $G$. The inputs $P1$ and $P2$ must be in compact form.

<a id="function-restrictionofgenerators-rec-rec-rec-rec-rec"></a>
##### `RestrictionOfGenerators(PR1, PR2, AC1, AC2, REL2): Rec, Rec, Rec, Rec, Rec -> SeqEnum`

Computes the sequence of images of the generators of the cohomology ring of $G$ restricted to a subgroup $H$. The input is the projective resolutions and cohomology generators for the basic algebra of $G$ ($PR1$ and $AC1$) and for the basic algebra of the subgroup ($PR2$ and $AC2$), as well as the cohomology relations for the subgroup, $REL2$.

<a id="function-inflationmap-rec-rec-rec-rec-rec"></a>
##### `InflationMap(PR2, PR1, AC2, AC1, REL1, theta): Rec, Rec, Rec, Rec, Rec -> SeqEnum`

Returns the images of the generators of the cohomology ring of a quotient group $Q$ in the cohomology ring of a group $G$. The input $\theta$ is the quotient map $G \rightarrow Q$. Other input is the projective resolutions and cohomology generators for the basic algebra of $G$ ($PR1$ and $AC1$) and for the quotient group $Q$ ($PR2$ and $AC2$) as well as the cohomology relations for $G$, $REL1$.

<a id="example-ex-9fb5b5"></a>
##### `Example: Restriction and Inflation of Cohomology (ex-9fb5b5)`

We create the cohomology ring of a group $G$ of order 64 and find a cyclic subgroup $Z$ of the center of $G$. We compute the restriction of the cohomology of $G$ to the cohomology of $Z$ and also the inflation of the cohomology of $G/Z$ to the cohomology ring of $G$.

```magma
> SetSeed(1);
> G := SmallGroup(64,7);
> Z := sub<G| Random(Center(G))>;
> G;
GrpPC : G of order 64 = 2^6
PC-Relations:
    G.1^2 = G.4,
    G.2^2 = G.5,
    G.3^2 = G.5,
    G.4^2 = G.6,
    G.2^G.1 = G.2 * G.3,
    G.3^G.1 = G.3 * G.5,
    G.3^G.2 = G.3 * G.5
> #Z, [G!Z.i: i in [1 .. Ngens(Z)]];
4 [ G.4 ]
```

So we see that $Z$ has order 4 and is generated by the element $G.4$. Now construct the quotient and the basic Algebras.

```magma
> Q, mu := quo<G|Z>;
> A := BasicAlgebra(G);
> B := BasicAlgebra(Q);
> C := BasicAlgebra(Z);
```

Next we want the simple modules and the cohomology rings. We compute the cohomology out to 17 steps which should be more than enough to get the generators and relations.

```magma
> k := SimpleModule(A,1);
> kk := SimpleModule(B,1);
> kkk := SimpleModule(C,1);
> time R := CohomologyRing(k,17);
Time: 2.060
> time S := CohomologyRing(kk,17);
Time: 0.140
> time T := CohomologyRing(kkk,17);
Time: 0.060
```

The structure of the cohomology rings can be read from the following outputs.

```magma
> R`RelationsIdeal,S`RelationsIdeal,T`RelationsIdeal;

First the cohomology ring for $G$.

Ideal of Graded Polynomial ring of rank 6 over GF(2)
Lexicographical Order
Variables: $.1, $.2, $.3, $.4, $.5, $.6
Variable weights: 1 1 2 2 3 4
Basis:
[
    $.1^2,
    $.1*$.2,
    $.2^3,
    $.1*$.3,
    $.2*$.5,
    $.3^2,
    $.1*$.5 + $.2^2*$.3,
    $.3*$.5,
    $.5^2
]
```

Now the cohomology ring for $Q$.

```magma
Ideal of Graded Polynomial ring of rank 4 over GF(2)
Lexicographical Order
Variables: $.1, $.2, $.3, $.4
Variable weights: 1 1 3 4
Basis:
[
    $.1*$.2,
    $.1^3,
    $.1*$.3,
    $.2^2*$.4 + $.3^2
]
```

And finally the cohomology ring for $Z$.

```magma
Ideal of Graded Polynomial ring of rank 2 over GF(2)
Lexicographical Order
Variables: $.1, $.2
Variable weights: 1 2
Basis:
[
    $.1^2
]
```

Next we require the inputs for the restriction and inflation maps.

```magma
> Pr1 := k`CompactProjectiveResolution;
> Pr2 := kk`CompactProjectiveResolution;
> Pr3 := kkk`CompactProjectiveResolution;
> Ac1 := k`AllCompactChainMaps;
> Ac2 := kk`AllCompactChainMaps;
> Ac3 := kkk`AllCompactChainMaps;
```

Now the inflation map from $Q$ to $G$ sends the generators of the cohomology of $Q$ to the given list of elements in the cohomology ring of $G$.

```magma
> inf := InflationMap(Pr2,Pr1,Ac2,Ac1,R,mu);
> inf;
[
    $.2,
    $.1,
    $.5,
    $.6
]
```

The restriction map from the cohomology ring of $G$ to the cohomology ring of $Z$ sends the generators of $R$ to the corresponding elements in the computed sequence.

```magma
> res := RestrictionOfGenerators(Pr1,Pr3,Ac1,Ac3,T);
> res;
[
    0,
    0,
    0,
    $.2,
    0,
    0
]
```

Finally, a set of minimal relations is determined for the cohomology ring $R$.

```magma
> MinimalRelations(R);
[
    $.1^2,
    $.1*$.2,
    $.2^3,
    $.1*$.3,
    $.2*$.5,
    $.3^2,
    $.1*$.5 + $.2^2*$.3,
    $.3*$.5,
    $.5^2
]
```

### A-infinity Algebra Structures on Group Cohomology

As described in [[Kel01](https://docs.magma-maths.org/references.md#cite-keller2001), [Kel02](https://docs.magma-maths.org/references.md#cite-keller2002)], an $A\infty$-algebra structure can be induced on $H^{*}A$ for any differential graded algebra $A$. Consider $\hbox{Ext}^{*}_R(S,S)$, for $R$ a quiver algebra quotient and $S$ the direct sum of all simple $R$-modules. Regarded as the homology of the endomorphism algebra of a projective resolution of $S$, Keller further demonstrates how this additional algebraic structure allows recovery of $R$ from $\hbox{Ext}^{*}_R(S,S)$.

An $A\infty$-algebra structure on a vector space $V$ consists of higher structural operations $m_1,\dots$ defined as $m_i:V^{\otimes i}\to V$ fulfilling the Stasheff axioms for all $n$:

$$
\sum_{i+j-1=n,0\leq k\leq n-j}\pm
m_i(a_1,\dots,a_{k-1},m_j(a_k,\dots,a_{k+j}),a_{k+j+1},\dots,a_n) = 0
$$

An $A\infty$-algebra homomorphism from an $A\infty$-algebra $A$ to an $A\infty$-algebra $B$ is a family $f_i$ of maps $A^{\tensor i}\to B$ such that the homomorphism axioms hold for all $n$:

$$
\begin{aligned}
&\sum_{i+j-1=n,0\leq k\leq n-j} \pm f_i(a_1,\dots,a_{k-1},m_j(a_k,\dots,a_{k+j}),a_{k+j+1},\dots,a_n)\\
&\qquad= \sum_{i_1+\dots+i_r=n} \pm m_r(f_{i_1}(a_1,\dots,a_{i_1}),\dots,f_{i_r}(a_{n-i_r+1},\dots,a_n))
\end{aligned}
$$

According to a theorem fundamental to the algebraic uses of $A\infty$-techniques, for a differential graded algebra $A$, there is an $A\infty$-structure on $H^{*}A$ and an $A\infty$-algebra homomorphism $f:H^{*}A\to A$ such that $f_1$ is a quasiisomorphism of differential graded algebras, and induced by the identity map on $H^{*}A$.

A blackbox method of calculation can be based on Kadeishvilis’ proof of this statement, using the homomorphism axioms to recursively calculate any specific values that are needed, and choosing the $m_i$ and $f_i$ in such a way as not to violate the axioms. The following package implements this method for the special case of $\hbox{Ext}^{*}_{kG}(k,k)$ for $G$ a $p$-group, $k$ a prime field of characteristic $p$ and also the one-dimensional unique simple $kG$-module.

<a id="function-ainfinityrecord-grp-rngintelt"></a>
#### `AInfinityRecord(G, n): Grp, RngIntElt -> Rec`

Constructs a record carrying all relevant information to calculate $A\infty$-operations on a group cohomology ring. Among the data carried can be found the cohomology ring in `R`, the cohomology ring quotient in `S`, the projective resolution used in `P`, the simple module resolved in `k`, and the basic algebra in `A`.

<a id="function-masseyproduct-rec-seqenum-rngelt"></a>
#### `MasseyProduct(Aoo, terms): Rec, SeqEnum[RngElt] -> RngElt`

<a id="function-highproduct-rec-seqenum-rngelt"></a>
#### `HighProduct(Aoo, terms): Rec, SeqEnum[RngElt] -> RngElt`

Given an $A\infty$ object $Aoo$ corresponding to a group cohomology ring, this intrinsic calculates the structure map $m_i(t_1\otimes\dots\otimes t_i)$, where the $i$ give the length of terms, and $t_1,\dots,t_i$ are the elements of terms.

<a id="function-highmap-rec-seqenum-rngelt"></a>
#### `HighMap(Aoo, terms): Rec, SeqEnum[RngElt] -> MapChn`

Given an $A\infty$ object $Aoo$ corresponding to a group cohomology ring, this intrinsic calculates the value of an $A\infty$-quasiisomorphism $f$ at the point $t_1\otimes\dots\otimes t_i$, where the $i$ gives the length of terms, and $t_1,\dots,t_i$ are the elements of terms.

<a id="example-ex-b55050"></a>
#### `Example: A-infinity Structure in Characteristic 2 (ex-b55050)`

The $A\infty$-structures on the cohomology rings of cyclic $p$-groups are well known examples in the literature: the $A\infty$-structure on $H^{*}(C_n,F_2)$ has one single higher structure nontrivial operation, namely $m_n$, which takes any $n$-tuple of odd coclasses to the even coclass of appropriate degree.

In order to verify this for a specific example, we start by constructing an $A\infty$ record that contains all relevant information for the cohomology ring.

```magma
> Aoo := AInfinityRecord(CyclicGroup(4),10);
> S<x,y> := Aoo`S;
> HighProduct(Aoo,[x,x,x,x]);
y
> HighMap(Aoo,[x,x,x,x]);
Basic algebra chain map of degree -1
```

<a id="example-ex-21e1bf"></a>
#### `Example: A-infinity Structure in Characteristic 3 (ex-21e1bf)`

The code as written handles odd characteristics well, with the sign choices featured in Kadeishvilis article [[Kad80](https://docs.magma-maths.org/references.md#cite-kadeishvili80)] embedded in the code.

```magma
> Aoo := AInfinityRecord(CyclicGroup(3),10);
> S<x,y> := Aoo`S;
> HighProduct(Aoo,[x,x,x]);
y
> HighMap(Aoo,[x,x,x]);
Basic algebra chain map of degree -1
```

#### Homological Algebra Toolkit

For the computation of $A\infty$-structures, several methods are used that would invite a wider use in a generic homological algebra toolkit.

<a id="function-actionmatrix-algbas-mtrx"></a>
##### `ActionMatrix(A, x): AlgBas, Mtrx -> ModMatFldElt`

Produces a matrix of the right action of the Basic algebra element described by $x$ in the Basic algebra $A$.

<a id="function-cohomologyringquotient-rec"></a>
##### `CohomologyRingQuotient(CR): Rec -> Rng, Map`

Computes the actual cohomology ring as a quotient ring of a multivariate polynomial ring from a cohomology ring record.

<a id="function-lifttochainmap-modcpx-mtrx-rngintelt"></a>
##### `LiftToChainmap(P, f, d): ModCpx, Mtrx, RngIntElt -> MapChn`

Lifts the function described by $f$ to a chain map from $P$ to $P$ of degree $d$.

<a id="function-nullhomotopy-mapchn"></a>
##### `NullHomotopy(f): MapChn -> MapChn`

Constructs a null homotopy of the null homotopic chain map $f$. If $f$ is not null homotopic, the function will throw an error message, since in that case some of the equations encountered on the way are not solvable.

<a id="function-isnullhomotopy-mapchn-mapchn"></a>
##### `IsNullHomotopy(f, H): MapChn, MapChn -> BoolElt`

Confirms that $H$ is a null homotopy of $f$, in other words that $f=dH-Hd$, with $d$ the differential of the corresponding chain complexes.

<a id="function-chainmaptocohomology-mapchn-rec"></a>
##### `ChainmapToCohomology(f, CR): MapChn, Rec -> RngElt`

Takes a chain map $f$ and returns the element in the cohomology quotient ring to which the chain map corresponds.

<a id="function-cohomologytochainmap-rngelt-rec-modcpx"></a>
##### `CohomologyToChainmap(xi, CR, P): RngElt, Rec, ModCpx -> MapChn`

Takes an element $xi$ of a cohomology quotient ring of the cohomology ring record $CR$ and a projective resolution corresponding to that cohomology ring, and returns a chain map in the coclass represented by $xi$.

<a id="example-ex-ca2dae"></a>
##### `Example: Null Homotopies for a Cyclic Group (ex-ca2dae)`

To illustrate the code that generates null homotopies, we consider the cohomology ring of a cyclic group, and pick out chain map representatives for the degree $1$ coclass. Although this squares to zero, the corresponding chainmaps do not compose to the zero chainmap.

```magma
> A := BasicAlgebra(CyclicGroup(4));
> k := SimpleModule(A,1);
> P := ProjectiveResolution(k,5);
> R := CohomologyRing(k,5);
> S<x,y> := CohomologyRingQuotient(R);
> xi := CohomologyToChainmap(x,R,P);
> x*x;
0
> IsZero(xi*xi);
false
> ModuleMaps(xi*xi);
[*
    [0 0 1 0]
    [0 0 0 1]
    [0 0 0 0]
    [0 0 0 0],

    [0 0 1 0]
    [0 0 0 1]
    [0 0 0 0]
    [0 0 0 0],

    [0 0 1 0]
    [0 0 0 1]
    [0 0 0 0]
    [0 0 0 0],

    [0 0 1 0]
    [0 0 0 1]
    [0 0 0 0]
    [0 0 0 0]
*]
> H := NullHomotopy(xi*xi);
> ModuleMaps(H);
[*
    [0 0 0 0]
    [0 0 0 0]
    [0 0 0 0]
    [0 0 0 0],

    [0 1 0 0]
    [0 0 1 0]
    [0 0 0 1]
    [0 0 0 0],

    [0 0 0 0]
    [0 0 0 0]
    [0 0 0 0]
    [0 0 0 0],

    [0 1 0 0]
    [0 0 1 0]
    [0 0 0 1]
    [0 0 0 0],

    [0 0 0 0]
    [0 0 0 0]
    [0 0 0 0]
    [0 0 0 0]
*]
> IsNullHomotopy(xi*xi,H);
true
```

<a id="alg-quat"></a>
<a id="chapalgquat"></a>
## Quaternion Algebras

- [Introduction](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/introduction.md)
- [Creation of Quaternion Algebras](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/creation.md)
  - [`QuaternionAlgebra< K | a, b >: Rng, RngElt, RngElt → AlgQuat`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/creation.md#constructor-constructor-quaternionalgebra-rng-rngelt-rngelt-algquat)
  - [`AssignNames(~A, S): AlgQuat, [MonStgElt]`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/creation.md#procedure-assignnames-algquat-monstgelt-ref)
  - [Example: Creating a Quaternion Algebra](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/creation.md#example-ex-24b190)
  - [Example: Quaternion Algebra in Characteristic 2](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/creation.md#example-ex-c9a2d5)
  - [`QuaternionAlgebra(N): RngIntElt → AlgQuat`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/creation.md#function-quaternionalgebra-rngintelt)
  - [`QuaternionAlgebra(N): RngUPolElt → AlgQuat`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/creation.md#function-quaternionalgebra-rngupolelt)
  - [`QuaternionAlgebra(I): RngOrdIdl → AlgQuat`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/creation.md#function-quaternionalgebra-rngordidl)
  - [`QuaternionAlgebra(I, S): RngOrdIdl, [PlcNumElt] → AlgQuat`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/creation.md#function-quaternionalgebra-rngordidl-plcnumelt)
  - [`QuaternionAlgebra(S): [PlcNumElt] → AlgQuat`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/creation.md#function-quaternionalgebra-plcnumelt)
  - [Example: Quaternion Algebras over a Number Field](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/creation.md#example-ex-b19daa)
  - [`QuaternionAlgebra(D1, D2, T): RngIntElt, RngIntElt, RngIntElt → AlgQuat`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/creation.md#function-quaternionalgebra-rngintelt-rngintelt-rngintelt)
  - [Example: Quaternion Algebras with Given Ramification](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/creation.md#example-ex-359d98)
- [Creation of Quaternion Orders](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-creation.md)
  - [Creation of Orders from Elements](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-creation.md#creation-of-orders-from-elements)
    - [`QuaternionOrder(S): [AlgQuatElt] → AlgQuatOrd`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-creation.md#function-quaternionorder-algquatelt)
    - [`QuaternionOrder(R, S): Rng, [AlgQuatElt] → AlgQuatOrd`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-creation.md#function-quaternionorder-rng-algquatelt)
    - [`Order(R, S): Rng, [AlgQuatElt] → AlgQuatOrd`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-creation.md#function-order-rng-algquatelt)
    - [Example: Orders from Sequences of Elements](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-creation.md#example-ex-b0f32f)
  - [Creation of Maximal Orders](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-creation.md#creation-of-maximal-orders)
    - [`MaximalOrder(A): AlgQuat[FldRat] → AlgQuatOrd`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-creation.md#function-maximalorder-algquat-fldrat)
    - [`MaximalOrder(A): AlgQuat[FldFunRat] → AlgQuatOrd`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-creation.md#function-maximalorder-algquat-fldfunrat)
    - [`MaximalOrder(A): AlgQuat[FldOrd] → AlgAssVOrd`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-creation.md#function-maximalorder-algquat-fldord)
    - [`MaximalOrder(A): AlgQuat[FldNum] → AlgAssVOrd`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-creation.md#function-maximalorder-algquat-fldnum)
    - [Example: Maximal Order in an Unramified Algebra](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-creation.md#example-ex-9b04e9)
    - [`MaximalOrder(O): AlgQuatOrd → AlgQuat`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-creation.md#function-maximalorder-algquatord)
    - [`MaximalOrder(O): AlgAssVOrd[RngOrd] → AlgAssVOrd`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-creation.md#function-maximalorder-algassvord-rngord)
    - [`pMaximalOrder(O, p): AlgQuatOrd, RngElt → AlgQuatOrd, RngIntElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-creation.md#function-pmaximalorder-algquatord-rngelt)
    - [`pMaximalOrder(O, p): AlgAssVOrd, RngOrdIdl → AlgAssVOrd, RngIntElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-creation.md#function-pmaximalorder-algassvord-rngordidl)
    - [`TameOrder(A): AlgQuat[FldAlg] → AlgAssVOrd`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-creation.md#function-tameorder-algquat-fldalg)
  - [Creation of Orders with given Discriminant](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-creation.md#creation-of-orders-with-given-discriminant)
    - [`Order(O, N): AlgQuatOrd, RngElt → AlgQuatOrd`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-creation.md#function-order-algquatord-rngelt)
    - [`Order(O, N): AlgAssVOrd, RngOrdIdl → AlgAssVOrd`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-creation.md#function-order-algassvord-rngordidl)
    - [`GorensteinClosure(O): AlgAssVOrd → AlgAssVOrd, .`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-creation.md#function-algquat-gorensteinclosure)
    - [Example: Eichler Order over a Function Field](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-creation.md#example-ex-966516)
  - [Creation of Orders with given Discriminant over the Integers](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-creation.md#creation-of-orders-with-given-discriminant-over-the-integers)
    - [`QuaternionOrder(A, M): AlgQuat[FldRat], RngIntElt → AlgQuatOrd`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-creation.md#function-quaternionorder-algquat-fldrat-rngintelt)
    - [`QuaternionOrder(N): RngIntElt → AlgQuatOrd`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-creation.md#function-quaternionorder-rngintelt)
    - [`QuaternionOrder(N, M): RngIntElt, RngIntElt → AlgQuatOrd`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-creation.md#function-quaternionorder-rngintelt-rngintelt)
    - [`QuaternionOrder(D1, D2, T): RngIntElt, RngIntElt, RngIntElt → AlgQuat`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-creation.md#function-quaternionorder-rngintelt-rngintelt-rngintelt)
    - [Example: Eichler Orders over the Integers](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-creation.md#example-ex-f04e9e)
- [Elements of Quaternion Algebras](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/elements.md)
  - [Creation of Elements](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/elements.md#creation-of-elements)
    - [`A ! 0: AlgQuat, RngIntElt → AlgQuatElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/elements.md#operation-op-algquat-rngintelt)
    - [`Zero(A): AlgQuat → AlgQuatElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/elements.md#function-zero-algquat)
    - [`A ! 1: AlgQuat, RngIntElt → AlgQuatElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/elements.md#operation-op-algquat-rngintelt-2)
    - [`One(A): AlgQuat → AlgQuatElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/elements.md#function-one-algquat)
    - [`A . i: AlgQuat, RngIntElt → AlgQuatElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/elements.md#operation-operation-algquat-rngintelt-algquatelt)
    - [`Name(A, i): AlgQuat, RngIntElt → AlgQuatElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/elements.md#function-name-algquat-rngintelt)
    - [`A ! x: AlgQuat, Any → AlgQuatElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/elements.md#operation-op-algquat-any)
  - [Arithmetic of Elements](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/elements.md#arithmetic-of-elements)
    - [`x + y: AlgQuatElt, AlgQuatElt → AlgQuatElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/elements.md#operation-op-plus-algquatelt-algquatelt)
    - [`x - y: AlgQuatElt, AlgQuatElt → AlgQuatElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/elements.md#operation-op-minus-algquatelt-algquatelt)
    - [`x * y: AlgQuatElt, AlgQuatElt → AlgQuatElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/elements.md#operation-op-times-algquatelt-algquatelt)
    - [`x / y: AlgQuatElt, AlgQuatElt → AlgQuatElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/elements.md#operation-op-div-algquatelt-algquatelt)
    - [`x / y: AlgQuatOrdElt, AlgQuatOrdElt → AlgQuatElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/elements.md#operation-op-div-algquatordelt-algquatordelt)
    - [`x eq y: AlgQuatElt, AlgQuatElt → BoolElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/elements.md#operation-op-eq-algquatelt-algquatelt)
    - [`x ne y: AlgQuatElt, AlgQuatElt → BoolElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/elements.md#operation-op-ne-algquatelt-algquatelt)
    - [`x in A: AlgQuatElt, AlgQuat → BoolElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/elements.md#operation-op-in-algquatelt-algquat)
    - [`x notin A: AlgQuatElt, AlgQuat → BoolElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/elements.md#operation-op-notin-algquatelt-algquat)
    - [`Conjugate(x): AlgQuatElt → AlgQuatElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/elements.md#function-conjugate-algquatelt)
    - [`Conjugate(x): AlgQuatOrdElt → AlgQuatOrdElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/elements.md#function-conjugate-algquatordelt)
    - [`Conjugate(x): AlgAssVOrdElt → AlgAssVOrdElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/elements.md#function-conjugate-algassvordelt)
    - [`ElementToSequence(x): AlgQuatElt → SeqEnum`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/elements.md#function-elementtosequence-algquatelt)
    - [`Eltseq(x): AlgQuatElt → SeqEnum`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/elements.md#function-eltseq-algquatelt)
    - [`Coordinates(x): AlgQuatElt → SeqEnum`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/elements.md#function-coordinates-algquatelt)
    - [`Norm(x): AlgQuatElt → FldElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/elements.md#function-norm-algquatelt)
    - [`Norm(x): AlgQuatOrdElt → RngElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/elements.md#function-norm-algquatordelt)
    - [`Trace(x): AlgQuatElt → FldElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/elements.md#function-trace-algquatelt)
    - [`Trace(x): AlgQuatOrdElt → RngElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/elements.md#function-trace-algquatordelt)
    - [`CharacteristicPolynomial(x): AlgQuatElt → RngUPolElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/elements.md#function-characteristicpolynomial-algquatelt)
    - [`CharacteristicPolynomial(x): AlgQuatOrdElt → RngUPolElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/elements.md#function-characteristicpolynomial-algquatordelt)
    - [`MinimalPolynomial(x): AlgQuatElt → RngUPolElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/elements.md#function-minimalpolynomial-algquatelt)
    - [Example: Reduced Trace and Norm of an Element](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/elements.md#example-ex-317c57)
- [Attributes of Quaternion Algebras](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/algebra-attributes.md)
  - [`BaseField(A): AlgQuat → Fld`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/algebra-attributes.md#function-basefield-algquat)
  - [`BaseRing(A): AlgQuat → Fld`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/algebra-attributes.md#function-basering-algquat)
  - [`Basis(A): AlgQuat → SeqEnum`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/algebra-attributes.md#function-basis-algquat)
  - [`RamifiedPrimes(A): AlgQuat → SeqEnum`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/algebra-attributes.md#function-ramifiedprimes-algquat)
  - [Example: Ramified Primes](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/algebra-attributes.md#example-ex-4e1f00)
  - [`RamifiedPlaces(A): AlgQuat → SeqEnum, SeqEnum`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/algebra-attributes.md#function-ramifiedplaces-algquat)
  - [`FactoredDiscriminant(A): AlgQuat → SeqEnum, SeqEnum`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/algebra-attributes.md#function-factoreddiscriminant-algquat)
  - [Example: Ramified Primes over a Function Field](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/algebra-attributes.md#example-ex-642861)
  - [`Discriminant(A): AlgQuat[FldRat] → RngIntElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/algebra-attributes.md#function-discriminant-algquat-fldrat)
  - [`Discriminant(A): AlgQuat[FldFunRat] → RngUPolElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/algebra-attributes.md#function-discriminant-algquat-fldfunrat)
  - [`Discriminant(A): AlgQuat[FldAlg] → RngOrdIdl, SeqEnum`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/algebra-attributes.md#function-discriminant-algquat-fldalg)
  - [`StandardForm(A): AlgQuat → RngElt, RngElt, AlgQuat, Map`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/algebra-attributes.md#function-standardform-algquat)
- [Hilbert Symbols and Embeddings](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/hilbert-symbols.md)
  - [`HilbertSymbol(a, b, p): FldRatElt, FldRatElt, RngIntElt → RngIntElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/hilbert-symbols.md#function-hilbertsymbol-fldratelt-fldratelt-rngintelt)
  - [`HilbertSymbol(a, b, p): FldFunRatElt, FldFunRatElt, RngElt p → RngIntElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/hilbert-symbols.md#function-hilbertsymbol-fldfunratelt-fldfunratelt-rngelt-p)
  - [`HilbertSymbol(a, b, p): FldNumElt, FldNumElt, RngOrdIdl → RngIntElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/hilbert-symbols.md#function-hilbertsymbol-fldnumelt-fldnumelt-rngordidl)
  - [`HilbertSymbol(A, p): AlgQuat[FldRat], RngIntElt → RngIntElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/hilbert-symbols.md#function-hilbertsymbol-algquat-fldrat-rngintelt)
  - [`HilbertSymbol(A, p): AlgQuat[FldFunRat], RngElt → RngIntElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/hilbert-symbols.md#function-hilbertsymbol-algquat-fldfunrat-rngelt)
  - [`HilbertSymbol(A, p): AlgQuat, RngOrdIdl → RngIntElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/hilbert-symbols.md#function-hilbertsymbol-algquat-rngordidl)
  - [`IsRamified(p, A): RngElt, AlgQuat → BoolElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/hilbert-symbols.md#function-isramified-rngelt-algquat)
  - [`IsUnramified(p, A): RngElt, AlgQuat → BoolElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/hilbert-symbols.md#function-isunramified-rngelt-algquat)
  - [`IsRamified(p, A): RngUPol, AlgQuat[FldFunRat] → BoolElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/hilbert-symbols.md#function-isramified-rngupol-algquat-fldfunrat)
  - [`IsUnramified(p, A): RngUPol, AlgQuat[FldFunRat] → BoolElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/hilbert-symbols.md#function-isunramified-rngupol-algquat-fldfunrat)
  - [`IsRamified(p, A): RngOrdIdl, AlgQuat[FldAlg] → BoolElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/hilbert-symbols.md#function-isramified-rngordidl-algquat-fldalg)
  - [`IsUnramified(p, A): RngOrdIdl, AlgQuat[FldAlg] → BoolElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/hilbert-symbols.md#function-isunramified-rngordidl-algquat-fldalg)
  - [Example: Hilbert Symbols over the Rationals](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/hilbert-symbols.md#example-ex-9d678c)
  - [`pMatrixRing(A, p): AlgQuat, RngOrdIdl → AlgMat, Map, Map`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/hilbert-symbols.md#function-pmatrixring-algquat-rngordidl)
  - [`pMatrixRing(A, p): AlgQuat, RngElt → AlgMat, Map, Map`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/hilbert-symbols.md#function-pmatrixring-algquat-rngelt)
  - [`pMatrixRing(O, p): AlgAssVOrd, RngOrdIdl → AlgMat, Map, Map`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/hilbert-symbols.md#function-pmatrixring-algassvord-rngordidl)
  - [`pMatrixRing(O, p): AlgQuatOrd, RngElt → AlgMat, Map, Map`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/hilbert-symbols.md#function-pmatrixring-algquatord-rngelt)
  - [`pMatrixRing(O, p): AlgQuatOrd[RngInt], RngInt → AlgMat, Map, Map`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/hilbert-symbols.md#function-pmatrixring-algquatord-rngint-rngint)
  - [`IsSplittingField(K, A): Fld, AlgQuat → BoolElt, AlgQuatElt, Map`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/hilbert-symbols.md#function-issplittingfield-fld-algquat)
  - [`HasEmbedding(K, A): Fld, AlgQuat → BoolElt, AlgQuatElt, Map`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/hilbert-symbols.md#function-hasembedding-fld-algquat)
  - [`Embed(K, A): Fld, AlgQuat → AlgQuatElt, Map`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/hilbert-symbols.md#function-embed-fld-algquat)
  - [`Embed(Oc, O): RngOrd, AlgAssVOrd → AlgAssVOrdElt, Map`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/hilbert-symbols.md#function-embed-rngord-algassvord)
  - [Example: Embedding a Field in a Quaternion Algebra](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/hilbert-symbols.md#example-ex-06ae1e)
- [Predicates on Algebras](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/predicates.md)
  - [`IsDefinite(A): AlgQuat → BoolElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/predicates.md#function-isdefinite-algquat)
  - [`IsIndefinite(A): AlgQuat → BoolElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/predicates.md#function-isindefinite-algquat)
- [Recognition Functions](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/matrix-ring-test.md)
  - [`IsMatrixRing(A): AlgQuat → BoolElt, AlgMat, Map`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/matrix-ring-test.md#function-ismatrixring-algquat)
  - [`MatrixRing(A, eps): AlgQuat, AlgQuatElt → AlgMat, Map`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/matrix-ring-test.md#function-matrixring-algquat-algquatelt)
  - [`MatrixAlgebra(A, eps): AlgQuat, AlgQuatElt → AlgMat, Map`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/matrix-ring-test.md#function-matrixalgebra-algquat-algquatelt)
  - [Example: Isomorphism with a Matrix Ring](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/matrix-ring-test.md#example-ex-696aa7)
  - [`IsQuaternionAlgebra(B): AlgAss → BoolElt, AlgQuat, Map`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/matrix-ring-test.md#function-isquaternionalgebra-algass)
  - [`IsQuaternionAlgebra(B): AlgMat → BoolElt, AlgQuat, Map`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/matrix-ring-test.md#function-isquaternionalgebra-algmat)
  - [Example: Recognising a Quaternion Algebra](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/matrix-ring-test.md#example-ex-52731a)
  - [`MatrixRepresentation(A): AlgQuat → Map`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/matrix-ring-test.md#function-matrixrepresentation-algquat)
  - [`MatrixRepresentation(R): AlgQuatOrd → Map`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/matrix-ring-test.md#function-matrixrepresentation-algquatord)
- [Attributes of Orders](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-attributes.md)
  - [`Algebra(S): AlgQuatOrd → AlgQuat`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-attributes.md#function-algebra-algquatord)
  - [`QuaternionAlgebra(S): AlgQuatOrd → AlgQuat`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-attributes.md#function-quaternionalgebra-algquatord)
  - [`BasisMatrix(S): AlgQuatOrd → AlgMatElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-attributes.md#function-basismatrix-algquatord)
  - [`EmbeddingMatrix(S): AlgQuatOrd → AlgMatElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-attributes.md#function-embeddingmatrix-algquatord)
  - [`Discriminant(S): AlgQuatOrd → RngElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-attributes.md#function-discriminant-algquatord)
  - [`FactoredDiscriminant(S): AlgQuatOrd → SeqEnum`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-attributes.md#function-factoreddiscriminant-algquatord)
  - [`Conductor(S): AlgQuatOrd → RngElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-attributes.md#function-conductor-algquatord)
  - [`Level(S): AlgQuatOrd → RngElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-attributes.md#function-level-algquatord)
  - [`Normalizer(S): AlgAssVOrd → Grp, Map`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-attributes.md#function-normalizer-algassvord)
- [Predicates of Orders](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-pred.md)
  - [`IsMaximal(O): AlgAssVOrd → BoolElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-pred.md#function-ismaximal-algassvord)
  - [`IspMaximal(O, p): AlgAssVOrd, RngOrdIdl → BoolElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-pred.md#function-ispmaximal-algassvord-rngordidl)
  - [`IspMaximal(O, p): AlgQuatOrd, RngElt → BoolElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-pred.md#function-ispmaximal-algquatord-rngelt)
  - [`IsEichler(O): AlgAssVOrd → BoolElt, AlgAssVOrd, AlgAssVOrd`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-pred.md#function-iseichler-algassvord)
  - [`IsEichler(O, p): AlgAssVOrd, RngOrdIdl → BoolElt, AlgAssVOrd, AlgAssVOrd`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-pred.md#function-iseichler-algassvord-rngordidl)
  - [`IsEichler(O, p): AlgQuatOrd, RngElt → BoolElt, AlgQuatOrd, AlgQuatOrd`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-pred.md#function-iseichler-algquatord-rngelt)
  - [`EichlerInvariant(O, p): AlgAssVOrd, RngOrdIdl → RngIntElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-pred.md#function-eichlerinvariant-algassvord-rngordidl)
  - [`EichlerInvariant(O, p): AlgQuatOrd, RngElt → RngIntElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-pred.md#function-eichlerinvariant-algquatord-rngelt)
  - [`IsHereditary(O): AlgAssVOrd → BoolElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-pred.md#function-ishereditary-algassvord)
  - [`IsHereditary(O, p): AlgAssVOrd, RngOrdIdl → BoolElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-pred.md#function-ishereditary-algassvord-rngordidl)
  - [`IsHereditary(O, p): AlgQuatOrd, RngElt → BoolElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-pred.md#function-ishereditary-algquatord-rngelt)
  - [`IsGorenstein(O): AlgAssVOrd → BoolElt, .`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-pred.md#function-isgorenstein-algassvord)
  - [`IsGorenstein(O, p): AlgAssVOrd, RngOrdIdl → BoolElt, RngIntElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-pred.md#function-isgorenstein-algassvord-rngordidl)
  - [`IsGorenstein(O, p): AlgQuatOrd, RngElt → BoolElt, RngIntElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-pred.md#function-isgorenstein-algquatord-rngelt)
  - [`IsBass(O): AlgAssVOrd → BoolElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-pred.md#function-isbass-algassvord)
  - [`IsBass(O, p): AlgAssVOrd, RngOrdIdl → BoolElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-pred.md#function-isbass-algassvord-rngordidl)
  - [`IsBass(O, p): AlgQuatOrd, RngElt → BoolElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-pred.md#function-isbass-algquatord-rngelt)
  - [`IsSameType(O1, O2): AlgAssVOrd, AlgAssVOrd → BoolElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-pred.md#function-issametype-algassvord-algassvord)
- [Operations with Orders](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-ops.md)
  - [`O1 meet O2: AlgQuatOrd[RngInt], AlgQuatOrd[RngInt] → AlgQuatOrd`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-ops.md#operation-op-meet-algquatord-rngint-algquatord-rngint)
  - [`O1 meet O2: AlgQuatOrd[RngUPol], AlgQuatOrd[RngUPol] → AlgQuatOrd`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-ops.md#operation-op-meet-algquatord-rngupol-algquatord-rngupol)
  - [`O1 meet O2: AlgAssVOrd, AlgAssVOrd → AlgAssVOrd`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-ops.md#operation-op-meet-algassvord-algassvord)
  - [`O ^ x: AlgQuatOrd, AlgQuatElt → AlgQuatOrd`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-ops.md#operation-op-pow-algquatord-algquatelt)
  - [`O ^ x: AlgAssVOrd, AlgAssElt → AlgAssvOrd`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-ops.md#operation-op-pow-algassvord-algasselt)
- [Ideal Theory of Orders](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/ideal-theory.md)
  - [Creation and Access Functions](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/ideal-theory.md#creation-and-access-functions)
    - [`LeftIdeal(S, X): AlgQuatOrd, [AlgQuatElt] → AlgQuatOrdIdl`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/ideal-theory.md#function-leftideal-algquatord-algquatelt)
    - [`lideal<S | X>: AlgQuatOrd, [AlgQuatElt] → AlgQuatOrdIdl`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/ideal-theory.md#constructor-constructor-lideal-algquatord-algquatelt-algquatordidl)
    - [`RightIdeal(S, X): AlgQuatOrd, [AlgQuatElt] → AlgQuatOrdIdl`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/ideal-theory.md#function-rightideal-algquatord-algquatelt)
    - [`rideal<S | X>: AlgQuatOrd, [AlgQuatElt] → AlgQuatOrd`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/ideal-theory.md#constructor-constructor-rideal-algquatord-algquatelt-algquatord)
    - [`ideal<S | X>: AlgQuatOrd, [AlgQuatElt] → AlgQuatOrdIdl`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/ideal-theory.md#constructor-constructor-ideal-algquatord-algquatelt-algquatordidl)
    - [`PrimeIdeal(S, p): AlgQuatOrd, RngElt → AlgQuatOrdIdl`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/ideal-theory.md#function-primeideal-algquatord-rngelt)
    - [`CommutatorIdeal(S): AlgQuatOrd → AlgQuatOrdIdl`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/ideal-theory.md#function-commutatorideal-algquatord)
    - [`CommutatorIdeal(S): AlgAssVOrd → AlgAssVOrdIdl`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/ideal-theory.md#function-commutatorideal-algassvord)
    - [`MaximalLeftIdeals(O, p): AlgQuatOrd, RngElt → [AlgQuatOrdIdl]`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/ideal-theory.md#function-maximalleftideals-algquatord-rngelt)
    - [`MaximalLeftIdeals(O, p): AlgAssVOrd, RngOrdIdl → [AlgAssVOrdIdl]`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/ideal-theory.md#function-maximalleftideals-algassvord-rngordidl)
    - [`MaximalRightIdeals(O, p): AlgQuatOrd, RngElt → [AlgQuatOrdIdl]`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/ideal-theory.md#function-maximalrightideals-algquatord-rngelt)
    - [`MaximalRightIdeals(O, p): AlgAssVOrd, RngOrdIdl → [AlgAssVOrdIdl]`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/ideal-theory.md#function-maximalrightideals-algassvord-rngordidl)
    - [Example: Two-Sided Prime Ideals](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/ideal-theory.md#example-ex-4a8cb2)
    - [Example: Norm and Basis of an Ideal](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/ideal-theory.md#example-ex-1b3844)
    - [`LeftOrder(I): AlgQuatOrdIdl → AlgQuatOrd`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/ideal-theory.md#function-leftorder-algquatordidl)
    - [`LeftOrder(I): AlgAssVOrdIdl[RngOrd] → AlgAssVOrd`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/ideal-theory.md#function-leftorder-algassvordidl-rngord)
    - [`RightOrder(I): AlgQuatOrdIdl → AlgQuatOrd`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/ideal-theory.md#function-rightorder-algquatordidl)
    - [`RightOrder(I): AlgAssVOrdIdl[RngOrd] → AlgAssVOrd`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/ideal-theory.md#function-rightorder-algassvordidl-rngord)
    - [Example: Left and Right Orders of an Ideal](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/ideal-theory.md#example-ex-c0479d)
  - [Enumeration of Ideal Classes](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/ideal-theory.md#enumeration-of-ideal-classes)
    - [`Mass(S): AlgAssVOrd → FldRatElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/ideal-theory.md#function-mass-algassvord)
    - [`LeftIdealClasses(S): AlgQuatOrd → [AlgQuatOrdIdl]`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/ideal-theory.md#function-leftidealclasses-algquatord)
    - [`LeftIdealClasses(S): AlgAssVOrd[RngOrd] → [AlgAssVOrdIdl]`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/ideal-theory.md#function-leftidealclasses-algassvord-rngord)
    - [`RightIdealClasses(S): AlgQuatOrd → [AlgQuatOrdIdl]`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/ideal-theory.md#function-rightidealclasses-algquatord)
    - [`RightIdealClasses(S): AlgAssVOrd[RngOrd] → [AlgAssVOrdIdl]`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/ideal-theory.md#function-rightidealclasses-algassvord-rngord)
    - [`TwoSidedIdealClasses(S): AlgQuatOrd → [AlgQuatOrdIdl]`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/ideal-theory.md#function-twosidedidealclasses-algquatord)
    - [`TwoSidedIdealClasses(S : Support): AlgAssVOrd[RngOrd] → [AlgAssVOrdIdl]`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/ideal-theory.md#function-twosidedidealclasses-algassvord-rngord)
    - [`TwoSidedIdealClassGroup(S : Support): AlgAssVOrd → GrpAb, Map`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/ideal-theory.md#function-twosidedidealclassgroup-algassvord)
    - [`ConjugacyClasses(S): AlgAssVOrd → SeqEnum`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/ideal-theory.md#function-conjugacyclasses-algassvord)
    - [Example: Left Ideal Classes of a Maximal Order](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/ideal-theory.md#example-ex-092c7e)
    - [Example: Ideal Classes over a Totally Real Field](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/ideal-theory.md#example-ex-81fcc0)
    - [Example: Ideal Classes with a Nontrivial Class Group](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/ideal-theory.md#example-ex-d6b8cf)
  - [Operations on Ideals](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/ideal-theory.md#operations-on-ideals)
    - [`I * J: AlgAssVOrdIdl, AlgAssVOrdIdl → AlgAssVOrdIdl`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/ideal-theory.md#operation-op-times-algassvordidl-algassvordidl)
    - [`I meet J: AlgQuatOrdIdl, AlgQuatOrdIdl → AlgQuatOrdIdl`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/ideal-theory.md#operation-op-meet-algquatordidl-algquatordidl)
    - [`Conjugate(I): AlgQuatOrdIdl → AlgQuatOrdIdl`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/ideal-theory.md#function-conjugate-algquatordidl)
    - [`Conjugate(I): AlgAssVOrdIdl → AlgAssVOrdIdl`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/ideal-theory.md#function-conjugate-algassvordidl)
    - [`Norm(I): AlgQuatOrdIdl → RngElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/ideal-theory.md#function-norm-algquatordidl)
    - [`Norm(I): AlgAssVOrdIdl → RngOrdFracIdl`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/ideal-theory.md#function-norm-algassvordidl)
    - [`Factorization(I): AlgQuatOrdIdl → SeqEnum`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/ideal-theory.md#function-factorization-algquatordidl)
    - [`Factorization(I): AlgAssVOrdIdl → SeqEnum`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/ideal-theory.md#function-factorization-algassvordidl)
- [Norm Spaces and Basis Reduction](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/norm-space.md)
  - [`NormSpace(A): AlgQuat → ModTupFld, Map`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/norm-space.md#function-normspace-algquat)
  - [`NormSpace(S): AlgQuatOrd → ModTupRng, Map`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/norm-space.md#function-normspace-algquatord)
  - [`NormModule(S): AlgQuatOrd → ModTupRng, Map`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/norm-space.md#function-normmodule-algquatord)
  - [`GramMatrix(S): AlgQuatOrd → AlgMatElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/norm-space.md#function-grammatrix-algquatord)
  - [`GramMatrix(I): AlgQuatOrdIdl → AlgMatElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/norm-space.md#function-grammatrix-algquatordidl)
  - [`ReducedGramMatrix(S): AlgQuatOrd[RngInt] → AlgMatElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/norm-space.md#function-reducedgrammatrix-algquatord-rngint)
  - [`ReducedGramMatrix(S): AlgQuatOrdIdl[RngInt] → AlgMatElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/norm-space.md#function-reducedgrammatrix-algquatordidl-rngint)
  - [`ReducedBasis(S): AlgQuatOrd[RngInt] → SeqEnum`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/norm-space.md#function-reducedbasis-algquatord-rngint)
  - [`ReducedBasis(S): AlgQuatOrdIdl[RngInt] → SeqEnum`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/norm-space.md#function-reducedbasis-algquatordidl-rngint)
  - [Example: Minkowski Reduction of Quaternion Ideals](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/norm-space.md#example-ex-dbe93f)
  - [`ReducedGramMatrix(S): AlgQuatOrd[RngUPol] → AlgMatElt, SeqEnum`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/norm-space.md#function-reducedgrammatrix-algquatord-rngupol)
  - [`ReducedGramMatrix(S): AlgQuatOrdIdl[RngUPol] → AlgMatElt, SeqEnum`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/norm-space.md#function-reducedgrammatrix-algquatordidl-rngupol)
  - [`ReducedBasis(S): AlgQuatOrd[RngUPol] → SeqEnum`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/norm-space.md#function-reducedbasis-algquatord-rngupol)
  - [`ReducedBasis(S): AlgQuatOrdIdl[RngUPol] → SeqEnum`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/norm-space.md#function-reducedbasis-algquatordidl-rngupol)
  - [`ReducedBasis(O): AlgAssVOrd[RngOrd] → [AlgAssVElt]`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/norm-space.md#function-reducedbasis-algassvord-rngord)
  - [`ReducedBasis(I): AlgAssVOrdIdl[RngOrd] → [AlgAssVOrdElt]`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/norm-space.md#function-reducedbasis-algassvordidl-rngord)
  - [`OptimizedRepresentation(O): AlgAssVOrd → AlgQuat, Map`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/norm-space.md#function-optimizedrepresentation-algassvord)
  - [`OptimisedRepresentation(O): AlgAssVOrd → AlgQuat, Map`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/norm-space.md#function-optimisedrepresentation-algassvord)
  - [`OptimizedRepresentation(A): AlgQuat → AlgQuat, Map`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/norm-space.md#function-optimizedrepresentation-algquat)
  - [`OptimisedRepresentation(A): AlgQuat → AlgQuat, Map`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/norm-space.md#function-optimisedrepresentation-algquat)
  - [`Enumerate(O, A, B): AlgQuatOrd[RngInt], RngIntElt, RngIntElt → [AlgQuatOrdElt]`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/norm-space.md#function-enumerate-algquatord-rngint-rngintelt-rngintelt)
  - [`Enumerate(O, B): AlgQuatOrd[RngInt], RngIntElt → [AlgQuatOrdElt]`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/norm-space.md#function-enumerate-algquatord-rngint-rngintelt)
  - [`Enumerate(O, A, B): AlgQuatOrdIdl[RngInt], RngElt, RngElt → [AlgQuatElt]`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/norm-space.md#function-enumerate-algquatordidl-rngint-rngelt-rngelt)
  - [`Enumerate(O, B): AlgQuatOrd[RngInt], RngElt → [AlgQuatElt]`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/norm-space.md#function-enumerate-algquatord-rngint-rngelt)
  - [`Enumerate(O, A, B): AlgAssVOrd[RngOrd], RngElt, RngElt → [AlgAssVOrdElt]`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/norm-space.md#function-enumerate-algassvord-rngord-rngelt-rngelt)
  - [`Enumerate(O, B): AlgAssVOrd[RngOrd], RngElt → [AlgAssVOrdElt]`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/norm-space.md#function-enumerate-algassvord-rngord-rngelt)
  - [`Enumerate(O, B): AlgAssVOrd[RngOrd], [RngElt] → [AlgAssVOrdElt]`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/norm-space.md#function-enumerate-algassvord-rngord-rngelt-2)
  - [`Enumerate(I, B): AlgAssVOrdIdl[RngOrd], [RngElt] → [AlgAssVOrdElt]`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/norm-space.md#function-enumerate-algassvordidl-rngord-rngelt)
- [Isomorphisms](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/isomorphisms.md)
  - [Isomorphisms of Algebras](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/isomorphisms.md#isomorphisms-of-algebras)
    - [`IsIsomorphic(A, B): AlgQuat, AlgQuat → BoolElt, Map`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/isomorphisms.md#function-isisomorphic-algquat-algquat)
  - [Isomorphisms of Orders](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/isomorphisms.md#isomorphisms-of-orders)
    - [`IsIsomorphic(S, T): AlgQuatOrd, AlgQuatOrd → BoolElt, Map, AlgQuatElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/isomorphisms.md#function-isisomorphic-algquatord-algquatord)
    - [`IsIsomorphic(S, T): AlgAssVOrd[RngOrd], AlgAssVOrd[RngOrd] → BoolElt, Map, AlgQuatElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/isomorphisms.md#function-isisomorphic-algassvord-rngord-algassvord-rngord)
    - [`IsConjugate(S, T): AlgAssVOrd, AlgAssVOrd → BoolElt, Map, AlgQuatElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/isomorphisms.md#function-isconjugate-algassvord-algassvord)
    - [`Isomorphism(S, T): AlgQuatOrd, AlgQuatOrd → Map`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/isomorphisms.md#function-isomorphism-algquatord-algquatord)
  - [Isomorphisms of Ideals](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/isomorphisms.md#isomorphisms-of-ideals)
    - [`IsIsomorphic(I, J): AlgAssVOrdIdl, AlgAssVOrdIdl → BoolElt, AlgAssVElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/isomorphisms.md#function-isisomorphic-algassvordidl-algassvordidl)
    - [`IsPrincipal(I): AlgAssVOrdIdl → BoolElt, AlgQuatElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/isomorphisms.md#function-isprincipal-algassvordidl)
    - [`IsLeftIsomorphic(I, J): AlgQuatOrdIdl, AlgQuatOrdIdl → BoolElt, Map, AlgQuatElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/isomorphisms.md#function-isleftisomorphic-algquatordidl-algquatordidl)
    - [`IsRightIsomorphic(I, J): AlgQuatOrdIdl, AlgQuatOrdIdl → BoolElt, Map, AlgQuatElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/isomorphisms.md#function-isrightisomorphic-algquatordidl-algquatordidl)
    - [`IsLeftIsomorphic(I, J): AlgAssVOrdIdl[RngOrd], AlgAssVOrdIdl[RngOrd] → BoolElt, AlgQuatElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/isomorphisms.md#function-isleftisomorphic-algassvordidl-rngord-algassvordidl-rngord)
    - [`IsRightIsomorphic(I, J): AlgAssVOrdIdl[RngOrd], AlgAssVOrdIdl[RngOrd] → BoolElt, AlgQuatElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/isomorphisms.md#function-isrightisomorphic-algassvordidl-rngord-algassvordidl-rngord)
    - [`LeftIsomorphism(I, J): AlgQuatOrdIdl, AlgQuatOrdIdl → Map, AlgQuatElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/isomorphisms.md#function-leftisomorphism-algquatordidl-algquatordidl)
    - [`RightIsomorphism(I, J): AlgQuatOrdIdl, AlgQuatOrdIdl → Map, AlgQuatElt`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/isomorphisms.md#function-rightisomorphism-algquatordidl-algquatordidl)
  - [Examples](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/isomorphisms.md#examples)
    - [Example: Isomorphism of Quaternion Algebras](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/isomorphisms.md#example-ex-f5c0d5)
    - [Example: Isomorphic Right Orders of Ideals](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/isomorphisms.md#example-ex-50db58)
    - [Example: Isomorphisms of Right Ideals](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/isomorphisms.md#example-ex-03d026)
    - [Example: Ideal Isomorphisms over a Number Ring](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/isomorphisms.md#example-ex-0c04cb)
- [Units and Unit Groups](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/unit-group.md)
  - [`NormOneGroup(S): AlgAssVOrd → GrpPerm, Map`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/unit-group.md#function-normonegroup-algassvord)
  - [`NormOneGroup(S): AlgQuatOrd → GrpAb, Map`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/unit-group.md#function-normonegroup-algquatord)
  - [`Units(S): AlgQuatOrd → SeqEnum`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/unit-group.md#function-units-algquatord)
  - [`Units(S): AlgAssVOrd → SeqEnum`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/unit-group.md#function-units-algassvord)
  - [`MultiplicativeGroup(S): AlgQuatOrd[RngInt] → GrpPerm, Map`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/unit-group.md#function-multiplicativegroup-algquatord-rngint)
  - [`UnitGroup(S): AlgQuatOrd[RngInt] → GrpPerm, Map`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/unit-group.md#function-unitgroup-algquatord-rngint)
  - [`MultiplicativeGroup(S): AlgQuatOrd[RngUPol] → GrpAb, Map`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/unit-group.md#function-multiplicativegroup-algquatord-rngupol)
  - [`UnitGroup(S): AlgQuatOrd[RngUPol] → GrpAb, Map`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/unit-group.md#function-unitgroup-algquatord-rngupol)
  - [`MultiplicativeGroup(S): AlgAssVOrd[RngOrd] → GrpPerm, Map`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/unit-group.md#function-multiplicativegroup-algassvord-rngord)
  - [`UnitGroup(S): AlgAssVOrd[RngOrd] → GrpPerm, Map`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/unit-group.md#function-unitgroup-algassvord-rngord)
  - [Example: Unit Groups over the Rationals](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/unit-group.md#example-ex-410b55)
  - [Example: Unit Groups over a Number Ring](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/unit-group.md#example-ex-b816c0)
- [Bibliography](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/bibliography.md)

<a id="algquat-important-warning"></a>
<a id="id1"></a>
### Introduction

A quaternion algebra $A$ over a field $K$ is a central simple algebra of dimension four over $K$, or equivalently when $K$ does not have characteristic $2$, an algebra generated by elements $i,j$ which satisfy

$$
i^2=a,\ j^2=b,\ ji=-ij
$$

with $a,b \in K^*$. A quaternion algebra in Magma is a specialized type `AlgQuat`, which is a subtype of associative algebra `AlgAss` defined over a field. Magma can recognize if an associative algebra $A$ is a quaternion algebra and will return a standard representation for $A$ with $a,b$ as above.

Examples of quaternion algebras include the ring $M_2(K)$ of $2 \times 2$-matrices over $K$ with $a=b=1$, as well as the division ring of Hamiltonians over $K={\mathbb{R}}$ with $a=b=-1$. Every quaternion algebra over a finite field or an algebraically closed field is isomorphic to $M_2(K)$. Over a local field, there is a unique quaternion algebra (up to isomorphism) which is a division ring.

Every quaternion algebra $A$ over $K$ not isomorphic to $M_2(K)$ is a division algebra. Finding a zerodivisor in $A$ is computationally equivalent to the problem of finding a $K$-rational point on a conic. Given a zerodivisor in $A$, Magma will compute an explicit isomorphism $A \to M_2(K)$. If $L$ is an extension field of $K$, then $A_L=A \otimes_K L$ is a quaternion algebra over $L$, and we say $L$ is a *splitting field* if $A_L \cong M_2(L)$. If $[L:K]=2$, then $L$ is a splitting field if and only if there exists a $K$-embedding $L \hookrightarrow A$, and such an embedding can be computed in Magma.

Further functionality is available for quaternion algebras $A$ defined over number fields $K$. Such an algebra is said to be *unramified* at a noncomplex place $v$ of $K$ if $K_v$ is a splitting field for $A$, otherwise $A$ is *ramified* at $v$. Testing if an algebra is ramified at a place is encoded in the *Hilbert symbol*, which can be computed for any such algebra. The set $S$ of ramified places of an algebra is finite and of even cardinality, and conversely, given such a set $S$ there exists a quaternion algebra which is ramified only at $S$. One may compute the set of ramified places of $A$ as well as constructing an algebra given its ramification set.

In Magma, there are algorithms for quaternion algebras which are analogous to those for number fields—computation of the ring of integers, class group, and unit group. One may compute a maximal order $O \subset A$, a $p$-maximal order for a prime $p$ of $K$, and orders with given index in a maximal order. Secondly, a representative set of (right) ideal classes in $O$ can be enumerated, and one can test if two ideals are isomorphic (hence if a given ideal is principal). Finally, for a definite quaternion algebra (defined over a totally real field), one may compute the group of units of norm $1$ in $O$. Over ${\mathbb{Q}}$, these functions tie into machinery for constructing the Brandt module, with applications to modular forms.

Orders for quaternion algebras over the rational numbers and over rational function fields in Magma have type `AlgQuatOrd` and ideals have type `AlgQuatOrdIdl`. Over other number rings, orders have the general type `AlgAssVOrd` and ideals `AlgAssVOrdIdl` which is also the type for used for associative orders, see Section [Orders](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#secalgassvord) for information about these orders. The types `AlgQuatOrd`, `AlgQuatOrdElt`, and `AlgQuatOrdIdl` inherit from the types `AlgAssVOrd`, `AlgAssVOrdElt`, and `AlgAssVOrdIdl` respectively.

The main reference for material in this chapter is the book of Vignéras [[Vig80](https://docs.magma-maths.org/references.md#cite-vigneras80)]. Most nontrivial algorithms for quaternion algebras over the rationals and over number fields are described in [[KV10](https://docs.magma-maths.org/references.md#cite-kirschmer-voight)].

**IMPORTANT WARNING.**

In Magma, the rationals are *not* considered to be a number field (the type `FldRat` is not a subtype of `FldNum`). Much of the functionality for quaternion algebras, and particularly for orders in quaternion algebras, is implemented only for algebras whose base field is a `FldNum` (while some, but not all, also works for algebras over the `FldRat`). To compute with algebras over ${\mathbb{Q}}$, in many cases the best solution is to create ${\mathbb{Q}}$ as a number field at the outset, using `RationalsAsNumberField()`, and create the algebra over this field instead of `Rationals()`.

### Creation of Quaternion Algebras

A general constructor for a quaternion algebra over any field $K$ creates a model in terms of two generators $x$ and $y$ and three relations

$$
x^2 = a, \quad y^2 = b, \quad yx = -xy
$$

with $a,b \in K^*$ if $K$ has characteristic different from $2$, and

$$
x^2 + x = a, \quad y^2 = b, \quad yx = (x+1)y
$$

if $K$ has characteristic $2$. The printing names $i$, $j$, and $k$ are assigned to the generators $x$, $y$, and $xy$ by default, unless the user assigns alternatives (see the function `AssignNames` below, or the example which follows).

Special constructors are provided for quaternion algebras over ${\mathbb{Q}}$, which return an algebra with a more general set of three defining quadratic relations. In general, the third generator need not be the product of the first two. This allows the creation of a quaternion algebra $A$ such that the default generators $\{1,i,j,k\}$ form a basis for a maximal order.

<a id="constructor-constructor-quaternionalgebra-rng-rngelt-rngelt-algquat"></a>
#### `QuaternionAlgebra< K | a, b >: Rng, RngElt, RngElt -> AlgQuat`

For $a,b \in K^*$, this function creates the quaternion algebra $A$ over the field $K$ on generators $i$ and $j$ with relations $i^2 = a$, $j^2 = b$, and $ji = -ij$ or $ji=(i+1)j$, as ${\rm char}(K) \neq 2$ or ${\rm char}(K)=2$, respectively. A third generator is set to $k = ij$. The field $K$ may be of any Magma field type; for inexact fields, such as local fields, one should expect unstable results since one cannot test deterministically for element equality.

<a id="procedure-assignnames-algquat-monstgelt-ref"></a>
#### `AssignNames(~A, S): AlgQuat, [MonStgElt]`

Given a quaternion algebra $A$ and sequence $S$ of strings of length 3, this function assigns the strings to the generators of $A$, i.e. the basis elements not equal to 1. This function is called by the bracket operators `< >` at the time of creation of a quaternion algebra.

<a id="example-ex-24b190"></a>
#### `Example: Creating a Quaternion Algebra (ex-24b190)`

A general quaternion algebra can be created as follows. Note that the brackets `< >` can be used to give any convenient names to the generators of the ring.

```magma
> A<x,y,z> := QuaternionAlgebra< RationalField() | -1, -7 >;
> x^2;
-1
> y^2;
-7
> x*y;
z
```

In the case of this constructor the algebra generators are of trace zero and are pairwise anticommuting. This contrasts with some of the special constructors for quaternion algebras over the rationals described below.

<a id="example-ex-c9a2d5"></a>
#### `Example: Quaternion Algebra in Characteristic 2 (ex-c9a2d5)`

Similarly, we have the following for characteristic $2$.

```magma
> A<i,j> := QuaternionAlgebra< GF(2) | 1, 1 >;
> i^2;
1 + i
> j^2;
1
```

<a id="function-quaternionalgebra-rngintelt"></a>
#### `QuaternionAlgebra(N): RngIntElt -> AlgQuat`

```magma
Al       : MonStgElt                    Default: "TraceValues"
Optimized: BoolElt                      Default: true
```

Given a positive squarefree integer $N$, this function returns a rational quaternion algebra of discriminant $N$. If the optional parameter `Al` is set to `"Random"`, or $N$ is the product of an even number of primes (i.e. the algebra is indefinite), then a faster, probabilistic algorithm is used. If `Al` is set to `"TraceValues"` and $N$ is a product of an odd number of primes, then an algebra basis is computed which also gives a basis for a maximal order (of discriminant $N$). If `Optimized` is `true` then an optimized representation of the algebra is returned.

<a id="function-quaternionalgebra-rngupolelt"></a>
#### `QuaternionAlgebra(N): RngUPolElt -> AlgQuat`

Given a squarefree polynomial $N \in {\mathbb{F}}_q[x]$ for some odd $q$, this function returns a quaternion algebra over ${\mathbb{F}}_q(x)$ of discriminant $N$.

<a id="function-quaternionalgebra-rngordidl"></a>
#### `QuaternionAlgebra(I): RngOrdIdl -> AlgQuat`

```magma
Optimized: BoolElt                    Default: true
```

Given an ideal $I$ of a number field $F$ with an even number of prime ideal factors, the function returns the quaternion algebra $A$ over $F$ which is ramified exactly at the primes dividing $I$. The ideal $I$ is not required to be squarefree, so $A$ will be ramified at the radical of $I$. If `Optimized` is `true` then an optimized representation of the algebra is returned.

<a id="function-quaternionalgebra-rngordidl-plcnumelt"></a>
#### `QuaternionAlgebra(I, S): RngOrdIdl, [PlcNumElt] -> AlgQuat`

```magma
Optimized: BoolElt                    Default: true
```

Given an ideal $I$ and a subset $S$ of real places of a number field $F$ such that the number of prime ideal divisors of $I$ has the same parity as $S$, the function returns the quaternion algebra which is ramified exactly at the primes dividing $I$ and at the real places specified by the set $S$. If `Optimized` is `true` then an optimized representation of the algebra is returned.

<a id="function-quaternionalgebra-plcnumelt"></a>
#### `QuaternionAlgebra(S): [PlcNumElt] -> AlgQuat`

```magma
Optimized: BoolElt                    Default: true
```

Given an even set $S$ of noncomplex places of a number field $F$, this function returns the quaternion algebra which is ramified exactly at $S$. If `Optimized` is `true` then an optimized representation of the algebra is returned.

<a id="example-ex-b19daa"></a>
#### `Example: Quaternion Algebras over a Number Field (ex-b19daa)`

We illustrate the above constructors in the case of a general number field.

```magma
> P<x> := PolynomialRing(Rationals());
> F<b> := NumberField(x^3-3*x-1);
> Foo := InfinitePlaces(F);
> Z_F := MaximalOrder(F);
> I := ideal<Z_F | 6>;
> A := QuaternionAlgebra(I);
> FactoredDiscriminant(A);
[
    Prime Ideal of Z_F
    Two element generators:
        [3, 0, 0]
        [2, 1, 0],
    Principal Prime Ideal of Z_F
    Generator:
        [2, 0, 0]
]
[]
> A := QuaternionAlgebra(ideal<Z_F | 1>, Foo[1..2]);
> FactoredDiscriminant(A);
[]
[ 1st place at infinity, 2nd place at infinity ]
```

<a id="function-quaternionalgebra-rngintelt-rngintelt-rngintelt"></a>
#### `QuaternionAlgebra(D1, D2, T): RngIntElt, RngIntElt, RngIntElt -> AlgQuat`

This intrinsic creates the rational quaternion algebra $\Q\langle i,j\rangle$, where $\Z[i]$ and $\Z[j]$ are quadratic suborders of discriminant $D_1$ and $D_2$, respectively, and $\Z[ij-ji]$ is a quadratic suborder of discriminant $D_3 = D_1 D_2 - T^2$. The values $D_1 D_2$ and $T$ must have the same parity and $D_1$, $D_2$, and $D_3$ must each be the discriminant of some quadratic order, i.e. nonsquare integers congruent to $0$ or $1$ modulo $4$.

<a id="example-ex-359d98"></a>
#### `Example: Quaternion Algebras with Given Ramification (ex-359d98)`

The above constructor is quite powerful for constructing quaternion algebras with given ramification. For any $i$ and $j$, a commutator element such as $ij-ji$ has trace zero, so in the above constructor, the minimal polynomial of this element is $x^2 + n$, where $n = (D_1 D_2 - T^2)/4$.

In the following example we construct such a ring, and demonstrate some of the relations satisfied in this algebra. Note that the minimal polynomial is an element of the commutative polynomial ring over the base field of the algebra.

In particular, we note that the algebra is not in standard form.

```magma
> A<i,j,k> := QuaternionAlgebra(-7,-47,1);
> PQ<x> := PolynomialRing(RationalField());
> MinimalPolynomial(i);
x^2 - x + 2
> MinimalPolynomial(j);
x^2 - x + 12
> MinimalPolynomial(k);
x^2 - x + 24
> i*j;
k
> i*j eq -j*i;
false
```

From their minimal polynomials, we see that the algebra generators $i$, $j$, and $k$ generate commutative subfields of discriminants $-7$, $-47$, and $-95$. The value $82 = (D_1 D_2 - T^2)/4$, however, is a more important invariant of the ring. We give a preview of the later material by demonstrating the functionality for computing the determinant and ramified primes of an algebra over ${\mathbb{Q}}$.

```magma
> MinimalPolynomial(i*j-j*i);
x^2 + 82
> Discriminant(A);
41
> RamifiedPrimes(A);
[ 41 ]
```

A ramified prime must be inert or ramified in every subfield and must divide the norm of any commutator element $xy-yx$.

```magma
> x := i;
> y := j;
> Norm(x*y-y*x);
82
> Factorization(82);
[ <2, 1>, <41, 1> ]
> x := i-k;
> y := i+j+k;
> Norm(x*y-y*x);
1640
> Factorization(1640);
[ <2, 3>, <5, 1>, <41, 1> ]
> KroneckerSymbol(-7,2), KroneckerSymbol(-47,2), KroneckerSymbol(-95,2);
1 1 1
> KroneckerSymbol(-7,41), KroneckerSymbol(-47,41), KroneckerSymbol(-95,41);
-1 -1 -1
```

The fact that the latter Kronecker symbols are $-1$, indicating that $41$ is inert in the quadratic fields of discriminants $-7$, $-47$, and $-95$, proves that $41$ is a ramified prime, and $2$ is not.

### Creation of Quaternion Orders

Let $R$ be a ring with field of fractions $K$, and let $A$ be a quaternion algebra over $K$. An $R$-*order* in $A$ is a subring $O \subset A$ which is a $R$-submodule of $A$ with $O\cdot K = A$. An order is *maximal* if it is not properly contained in any other order.

One can create orders for number rings $R$, for $R = \Z$, or for $R=k[x]$ with $k$ a field. Unlike commutative orders, it is important to note that maximal orders $O$ of quaternion algebras are no longer unique: for any $x \in A$ not in the normalizer of $O$, we have another maximal order given by $O'=x^{-1} O x \neq O$.

When $R={\mathbb{Z}}$ or $R=k[x]$, the order $O$ has type `AlgQuatOrd`. When $R$ inherits from type `RngOrd` (a number ring), the order $O$ has type `AlgAssVOrd`; see Section [Orders](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#secalgassvord) for more information on constructors and general procedures for these orders.

See above ([Introduction](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/introduction.md#algquat-important-warning)) for an important warning regarding quaternion algebras over the rationals.

#### Creation of Orders from Elements

The creation of orders from elements of number rings is covered in Section [Orders](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#secalgassvord). The creation of quaternion orders over the integers and univariate polynomial rings is covered in this section.

<a id="function-quaternionorder-algquatelt"></a>
##### `QuaternionOrder(S): [AlgQuatElt] -> AlgQuatOrd`

```magma
IsBasis: BoolElt                    Default: false
```

Given $S$ a sequence of elements in a quaternion algebra defined over ${\mathbb{Q}}$ or ${\mathbb{F}}_q(X)$, this function returns the order generated by $S$ over ${\mathbb{Z}}$ or ${\mathbb{F}}_q[X]$. If the set $S$ does not generate an order, an error will be returned. If the parameter `IsBasis` is set to `true` then $S$ will be used as the basis of the order returned.

<a id="function-quaternionorder-rng-algquatelt"></a>
##### `QuaternionOrder(R, S): Rng, [AlgQuatElt] -> AlgQuatOrd`

<a id="function-order-rng-algquatelt"></a>
##### `Order(R, S): Rng, [AlgQuatElt] -> AlgQuatOrd`

```magma
Check: BoolElt                    Default: true
```

Given a ring $R$ and a sequence $S$ of elements of a quaternion algebra over ${\mathbb{Q}}$ or ${\mathbb{F}}_q(X)$, this function returns the $R$-order with basis $S$. The sequence must have length four.

<a id="example-ex-b0f32f"></a>
##### `Example: Orders from Sequences of Elements (ex-b0f32f)`

First we construct an order over a polynomial ring.

```magma
> K<t> := FunctionField(FiniteField(7));
> A<i,j,k> := QuaternionAlgebra< K | t, t^2+t+1 >;
> O := QuaternionOrder( [i,j] );
> Basis(O);
[1, i, j, k ]
```

Next we demonstrate how to construct orders in quaternion algebras generated by a given sequence of elements. When provided with a sequence of elements of a quaternion algebra over ${\mathbb{Q}}$, Magma reduces the sequence so as to form a basis. When provided with the ring over which these elements are to be interpreted, the sequence must be a basis with initial element $1$, and the order having this basis is constructed.

```magma
> A<i,j,k> := QuaternionAlgebra< RationalField() | -1, -3 >;
> B := [ 1, 1/2 + 1/2*j, i, 1/2*i + 1/2*k ];
> O := QuaternionOrder(B);
> Basis(O);
[ 1, 1/2*i + 1/2*k, 1/2 - 1/2*j, -1/2*i + 1/2*k ]
> S := QuaternionOrder(Integers(),B);
> Basis(S);
[ 1, 1/2 + 1/2*j, i, 1/2*i + 1/2*k ]
```

#### Creation of Maximal Orders

<a id="function-maximalorder-algquat-fldrat"></a>
##### `MaximalOrder(A): AlgQuat[FldRat] -> AlgQuatOrd`

<a id="function-maximalorder-algquat-fldfunrat"></a>
##### `MaximalOrder(A): AlgQuat[FldFunRat] -> AlgQuatOrd`

<a id="function-maximalorder-algquat-fldord"></a>
##### `MaximalOrder(A): AlgQuat[FldOrd] -> AlgAssVOrd`

<a id="function-maximalorder-algquat-fldnum"></a>
##### `MaximalOrder(A): AlgQuat[FldNum] -> AlgAssVOrd`

A maximal order is constructed in the quaternion algebra $A$. The algebra $A$ must be defined over a field $K$ where $K$ is either a number field, ${\mathbb{Q}}$, ${\mathbb{F}}_q(X)$ with $q$ odd, or the field of fractions of a number ring. Over ${\mathbb{F}}_q(X)$ we use the standard algorithm [[Fri97](https://docs.magma-maths.org/references.md#cite-fr1), [IR93](https://docs.magma-maths.org/references.md#cite-ivanyos-ronyai)]. Over the rationals or over a number field, we use a variation of this algorithm optimized for the case of quaternion algebras. First, a factorization of the discriminant of a tame order (see below) is computed. Then, for each prime $p$ dividing the discriminant, a $p$-maximal order compatible with the existing order is computed. The method used corresponds to Algorithm 4.3.8 in [[Voi05](https://docs.magma-maths.org/references.md#cite-voight1)]. See also [[Voi11](https://docs.magma-maths.org/references.md#cite-voight3)].

<a id="example-ex-9b04e9"></a>
##### `Example: Maximal Order in an Unramified Algebra (ex-9b04e9)`

The following is an example of a quaternion algebra which is unramified at all finite primes.

```magma
> P<x> := PolynomialRing(Rationals());
> F<b> := NumberField(x^3-3*x-1);
> A<alpha,beta,alphabeta> := QuaternionAlgebra<F | -3,b>;
> O := MaximalOrder(A);
> Factorization(Discriminant(O));
[]
```

Hence the algebra $A$ has a maximal order of discriminant $1$, or equivalently, $A$ is unramified at all finite places of $F$.

Since we are working over a general order of a number field, we can no longer guarantee that an order will have a free basis, so it must be represented by a pseudomatrix. For more on pseudomatrices, see Section [Pseudo Matrices](https://docs.magma-maths.org/Modules/ModulesOverDedekindDomains/pmat.md#secpmat).

```magma
> Z_F := BaseRing(O);
> PseudoBasis(O);
[
    <Principal Ideal of Z_F
    Generator:
        Z_F.1, Z_F.1>,
    <Fractional Ideal of Z_F
    Two element generators:
        Z_F.1
        2/3*Z_F.1 + 1/6*Z_F.2 + 1/6*Z_F.3, 3/1*Z_F.1 + i>,
    <Principal Ideal of Z_F
    Generator:
        Z_F.1, j>,
    <Fractional Ideal of Z_F
    Two element generators:
        Z_F.1
        11/2*Z_F.1 + 1/6*Z_F.2 + 35/6*Z_F.3, 3/1*Z_F.1 - i + 3/1*Z_F.1*j + k>
]
```

The wide applicability of the above algorithm, is demonstrated by examining a “random” quaternion algebra over a “random” quadratic number field.

```magma
> for c := 1 to 10 do
>   D := Random([d : d in [-100..100] | not IsSquare(d)]);
>   K<w> := NumberField(x^2-D);
>   Z_K := MaximalOrder(K);
>   K<K1,w> := FieldOfFractions(Z_K);
>   a := Random([i : i in [-50..50] | i ne 0]) + Random([-50..50])*w;
>   b := Random([i : i in [-50..50] | i ne 0]) + Random([-50..50])*w;
>   printf "D = %o, a = %o, b = %o\n", D, a, b;
>   A := QuaternionAlgebra<K | a,b>;
>   O := MaximalOrder(A);
>   ds := [<pp[1],pp[2],HilbertSymbol(A,pp[1])> :
>            pp in Factorization(Discriminant(O))];
>   print ds;
>   for d in ds do
>     if d[3] eq 1 then
>       break c;
>     end if;
>   end for;
> end for;
D = 5, a = -46/1*K1 + 25/1*w, b = -10/1*K1 - 7/1*w
[
    <Prime Ideal of Z_K
    Two element generators:
        [31, 0]
        [5, 2], 2, -1>,
    <Prime Ideal of Z_K
    Two element generators:
        [11, 0]
        [6, 2], 2, -1>
]
...
```

For each such “random” quaternion algebra, we verify that the Hilbert symbol evaluated at each prime dividing the discriminant of the maximal order is $-1$, indicating that the algebra is indeed ramified at the prime.

<a id="function-maximalorder-algquatord"></a>
##### `MaximalOrder(O): AlgQuatOrd -> AlgQuat`

<a id="function-maximalorder-algassvord-rngord"></a>
##### `MaximalOrder(O): AlgAssVOrd[RngOrd] -> AlgAssVOrd`

For $O$ a quaternion order defined over $\Z$, $\F_q[X]$ with $q$ odd, or a number ring, this function returns a maximal order containing $O$.

<a id="function-pmaximalorder-algquatord-rngelt"></a>
##### `pMaximalOrder(O, p): AlgQuatOrd, RngElt -> AlgQuatOrd, RngIntElt`

<a id="function-pmaximalorder-algassvord-rngordidl"></a>
##### `pMaximalOrder(O, p): AlgAssVOrd, RngOrdIdl -> AlgAssVOrd, RngIntElt`

For $O$ a quaternion order defined over $\Z$, $\F_q[X]$ with $q$ odd, or a number ring and a prime (ideal) $p$, this function returns a $p$-maximal order $O'$ containing the order $O$. The $p$-adic valuation of the discriminant of $O'$ (which is either $0$ or $1$) is returned as a second return value.

<a id="function-tameorder-algquat-fldalg"></a>
##### `TameOrder(A): AlgQuat[FldAlg] -> AlgAssVOrd`

Given a quaternion algebra $A$, this function returns an order $O$ having the property that the odd reduced discriminant of $O$ is squarefree. The algebra $A$ must be defined over a number field or field of fractions of a number ring. The algorithm ignores even primes and does not test the remaining odd primes for maximality.

#### Creation of Orders with given Discriminant

The following two functions together with the maximal order algorithms of the previous subsection allow the construction of arbitrary Eichler orders.

<a id="function-order-algquatord-rngelt"></a>
##### `Order(O, N): AlgQuatOrd, RngElt -> AlgQuatOrd`

Given an order $O$ in a quaternion algebra $A$ over the rationals or ${\mathbb{F}}_q(x)$ with $q$ odd, and some element $N$ in the base ring of $O$, this function returns a suborder $O'$ of $O$ having index $N$. Currently, $N$ and the level of $O$ must be coprime and $N$ must have valuation at most $1$ at each ramified prime of $A$. The order $O'$ is locally Eichler at all prime divisors of $N$ that are not ramified in $A$. In particular, if $O$ is Eichler and $N$ is coprime to the discriminant of $A$, so is $O'$.

<a id="function-order-algassvord-rngordidl"></a>
##### `Order(O, N): AlgAssVOrd, RngOrdIdl -> AlgAssVOrd`

Given a maximal quaternion order $O$ over a number ring, this function returns an Eichler order of level $N$ inside $O$.

<a id="function-algquat-gorensteinclosure"></a>
##### `GorensteinClosure(O): AlgAssVOrd -> AlgAssVOrd, .`

Let $O$ be a quaternion order over $R$. There exists a unique Gorenstein order $\Lambda$ over $R$ such that $\Lambda$ is generated by $1$ and $bO$ for some integral ideal $b$ of $R$. The order $\Lambda$ and the ideal $b$ are called the Gorenstein closure and the Brandt invariant of $O$ respectively.

The first return value of this intrinsic is the Gorenstein closure of $O$.

The second return value is either a positive or monic generator of $b$ or $b$ itself depending on whether $R$ is $\Z$, $\F_q[x]$, or a number ring.

<a id="example-ex-966516"></a>
##### `Example: Eichler Order over a Function Field (ex-966516)`

First we construct a quaternion algebra $A$ over ${\mathbb{F}}_5(x)$ ramified at $x^2+x+1$, then a maximal order $M$ in $A$ and finally an Eichler $O$ order of discriminant $(x^2+x+1)(x^3+x+1)^5$.

```magma
> P<x> := PolynomialRing(GF(5));
> A := QuaternionAlgebra(x^2+x+1);
> M := MaximalOrder(A);
> O := Order(M, (x^3+x+1)^5);
> FactoredDiscriminant(O);
[
    <x^2 + x + 1, 1>,
    <x^3 + x + 1, 5>
]
```

#### Creation of Orders with given Discriminant over the Integers

When constructing quaternion orders over the integers, several shortcuts are available.

<a id="function-quaternionorder-algquat-fldrat-rngintelt"></a>
##### `QuaternionOrder(A, M): AlgQuat[FldRat], RngIntElt -> AlgQuatOrd`

Given a quaternion algebra $A$ and a positive integer $M$, this function returns an order of index $M$ in a maximal order of the quaternion algebra $A$ defined over ${\mathbb{Q}}$. The second argument $M$ can have at most valuation $1$ at any ramified prime of $A$.

<a id="function-quaternionorder-rngintelt"></a>
##### `QuaternionOrder(N): RngIntElt -> AlgQuatOrd`

<a id="function-quaternionorder-rngintelt-rngintelt"></a>
##### `QuaternionOrder(N, M): RngIntElt, RngIntElt -> AlgQuatOrd`

Given positive integers $N$ and $M$, this function returns an order of index $M$ in a maximal order of the rational quaternion algebra $A$ of discriminant $N$. The discriminant $N$ must be a product of an odd number of distinct primes, and the argument $M$ can be at most of valuation 1 at any prime dividing $N$. If $M$ is omitted, the integer $M$ defaults to $1$, i.e., the function will return a maximal order.

<a id="function-quaternionorder-rngintelt-rngintelt-rngintelt"></a>
##### `QuaternionOrder(D1, D2, T): RngIntElt, RngIntElt, RngIntElt -> AlgQuat`

This intrinsic constructs the quaternion order ${\mathbb{Z}}\langle x,y\rangle$, where ${\mathbb{Z}}[x]$ and ${\mathbb{Z}}[y]$ are quadratic subrings of discriminant $D_1$ and $D_2$, respectively, and ${\mathbb{Z}}[xy - yx]$ is a quadratic subring of discriminant $D_1 D_2 - T^2$.

Note that the container algebra of such a quaternion order is **not** usually in standard form (see the example below).

<a id="example-ex-f04e9e"></a>
##### `Example: Eichler Orders over the Integers (ex-f04e9e)`

The above constructors permit the construction of Eichler orders over ${\mathbb{Z}}$, if the discriminant $N$ and the index $M$ are coprime. More generally they allow the construction of an order whose index in an Eichler order divides the discriminant.

```magma
> A := QuaternionOrder(103,2);
> Discriminant(A);
206
> Factorization($1);
[ <2, 1>, <103, 1> ]
> _<x> := PolynomialRing(Rationals());
> [MinimalPolynomial(A.i) : i in [1..4]];
[
    x - 1,
    x^2 + 1,
    x^2 - x + 52,
    x^2 + 104
]
```

The constructor `QuaternionOrder(D1, D2, T)` may return an order whose container algebra is not in standard form.

```magma
> A := QuaternionOrder(-4, 5, 2);
> B := Algebra(A);
> B.1 * B.2 eq - B.2 * B.1;
false
```

### Elements of Quaternion Algebras

For more information about elements of orders of associative algebras, see Section [Orders](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#secalgassvord).

#### Creation of Elements

<a id="operation-op-algquat-rngintelt"></a>
##### `A ! 0: AlgQuat, RngIntElt -> AlgQuatElt`

<a id="function-zero-algquat"></a>
##### `Zero(A): AlgQuat -> AlgQuatElt`

The zero element of the quaternion algebra $A$.

<a id="operation-op-algquat-rngintelt-2"></a>
##### `A ! 1: AlgQuat, RngIntElt -> AlgQuatElt`

<a id="function-one-algquat"></a>
##### `One(A): AlgQuat -> AlgQuatElt`

The identity element of the quaternion algebra $A$.

<a id="operation-operation-algquat-rngintelt-algquatelt"></a>
##### `A . i: AlgQuat, RngIntElt -> AlgQuatElt`

<a id="function-name-algquat-rngintelt"></a>
##### `Name(A, i): AlgQuat, RngIntElt -> AlgQuatElt`

Given a quaternion algebra $A$ and an integer $1\le i\le 3$, returns the $i$th generator of $A$ as an algebra over the base ring. Note that the element $1$ is always the first element of a basis, and is never returned as a generating element.

<a id="operation-op-algquat-any"></a>
##### `A ! x: AlgQuat, Any -> AlgQuatElt`

Return an element of the quaternion algebra $A$ described by $x$, where $x$ may be an algebra element, a module element, a sequence, an element of an order of an associative algebra or be coercible into the coefficient ring of $A$.

#### Arithmetic of Elements

<a id="operation-op-plus-algquatelt-algquatelt"></a>
##### `x + y: AlgQuatElt, AlgQuatElt -> AlgQuatElt`

The sum of $x$ and $y$.

<a id="operation-op-minus-algquatelt-algquatelt"></a>
##### `x - y: AlgQuatElt, AlgQuatElt -> AlgQuatElt`

The difference of $x$ and $y$.

<a id="operation-op-times-algquatelt-algquatelt"></a>
##### `x * y: AlgQuatElt, AlgQuatElt -> AlgQuatElt`

The product of $x$ and $y$.

<a id="operation-op-div-algquatelt-algquatelt"></a>
##### `x / y: AlgQuatElt, AlgQuatElt -> AlgQuatElt`

<a id="operation-op-div-algquatordelt-algquatordelt"></a>
##### `x / y: AlgQuatOrdElt, AlgQuatOrdElt -> AlgQuatElt`

The quotient of $x$ by the unit $y$ in the quaternion algebra.

<a id="operation-op-eq-algquatelt-algquatelt"></a>
##### `x eq y: AlgQuatElt, AlgQuatElt -> BoolElt`

Returns `true` if the elements $x$ and $y$ are equal; otherwise `false`.

<a id="operation-op-ne-algquatelt-algquatelt"></a>
##### `x ne y: AlgQuatElt, AlgQuatElt -> BoolElt`

Returns `true` if and only if the elements $x$ and $y$ are not equal.

<a id="operation-op-in-algquatelt-algquat"></a>
##### `x in A: AlgQuatElt, AlgQuat -> BoolElt`

Returns `true` if and only if $x$ is in the algebra $A$.

<a id="operation-op-notin-algquatelt-algquat"></a>
##### `x notin A: AlgQuatElt, AlgQuat -> BoolElt`

Returns `true` if and only if $x$ is not in the algebra $A$.

<a id="function-conjugate-algquatelt"></a>
##### `Conjugate(x): AlgQuatElt -> AlgQuatElt`

<a id="function-conjugate-algquatordelt"></a>
##### `Conjugate(x): AlgQuatOrdElt -> AlgQuatOrdElt`

<a id="function-conjugate-algassvordelt"></a>
##### `Conjugate(x): AlgAssVOrdElt -> AlgAssVOrdElt`

The conjugate $\bar{x}$ of the element $x$ of a quaternion algebra, defined so that the reduced trace and reduced norm are $\bar{x}+x$ and $\bar{x}x$, respectively.

<a id="function-elementtosequence-algquatelt"></a>
##### `ElementToSequence(x): AlgQuatElt -> SeqEnum`

<a id="function-eltseq-algquatelt"></a>
##### `Eltseq(x): AlgQuatElt -> SeqEnum`

<a id="function-coordinates-algquatelt"></a>
##### `Coordinates(x): AlgQuatElt -> SeqEnum`

Given an element $x$ of a quaternion algebra or order, this function returns the sequence of coordinates of $x$ in terms of the basis of its parent.

<a id="function-norm-algquatelt"></a>
##### `Norm(x): AlgQuatElt -> FldElt`

<a id="function-norm-algquatordelt"></a>
##### `Norm(x): AlgQuatOrdElt -> RngElt`

The reduced norm ${\rm N}(x)$ of the element $x$ of a quaternion algebra, defined so that the characteristic polynomial for $x$ is $x^2 - {\operatorname{Tr}}(x)x + {\rm N}(x) = 0$, where ${\operatorname{Tr}}(x)$ is the reduced trace.

<a id="function-trace-algquatelt"></a>
##### `Trace(x): AlgQuatElt -> FldElt`

<a id="function-trace-algquatordelt"></a>
##### `Trace(x): AlgQuatOrdElt -> RngElt`

The reduced trace ${\operatorname{Tr}}(x)$ of the element $x$ of a quaternion algebra, defined so that the characteristic polynomial for $x$ is $x^2 - {\operatorname{Tr}}(x)x + {\rm N}(x) = 0$, where ${\rm N}(x)$ is the reduced norm.

<a id="function-characteristicpolynomial-algquatelt"></a>
##### `CharacteristicPolynomial(x): AlgQuatElt -> RngUPolElt`

<a id="function-characteristicpolynomial-algquatordelt"></a>
##### `CharacteristicPolynomial(x): AlgQuatOrdElt -> RngUPolElt`

The characteristic polynomial of degree $2$ for the element $x$ of a quaternion algebra over the base ring of its parent.

<a id="function-minimalpolynomial-algquatelt"></a>
##### `MinimalPolynomial(x): AlgQuatElt -> RngUPolElt`

The minimal polynomial of degree $1$ or $2$ for the element $x$ of a quaternion algebra over the base ring of its parent.

<a id="example-ex-317c57"></a>
##### `Example: Reduced Trace and Norm of an Element (ex-317c57)`

We demonstrate the relation between characteristic polynomial, and reduced trace and norm in the following example.

```magma
> A := QuaternionAlgebra< RationalField() | -17, -271 >;
> x := A![1,-2,3,0];
> Trace(x);
2
> Norm(x);
2508
> x^2 - Trace(x)*x + Norm(x);
0
```

Note that trace and norm of an element $x$ of any algebra can be defined as the trace and norm of the linear operator corresponding to right-multiplication by $x$. The reduced trace and norm in a quaternion algebra $A$ are taken instead to be the corresponding trace and determinant in any two-dimensional matrix representation of $A$, or equivalently, the sum and product of an element with its conjugate. The definition of norm and trace used for a general algebra can be realised in a quaternion algebra by the following code.

```magma
> P<X> := PolynomialRing(RationalField());
> M := RepresentationMatrix(x, A);
> M;
[   1   -2    3    0]
[  34    1    0    3]
[-813    0    1    2]
[   0 -813  -34    1]
> Trace(M);
4
> Factorization(CharacteristicPolynomial(M));
[
    <X^2 - 2*X + 2508, 2>
]
```

The general definition of trace (for the algebra) is twice the reduced trace, and the general definition of norm is the square of the reduced norm.

<a id="algebra-attributes"></a>
<a id="sec-assign-names"></a>
### Attributes of Quaternion Algebras

<a id="function-basefield-algquat"></a>
#### `BaseField(A): AlgQuat -> Fld`

<a id="function-basering-algquat"></a>
#### `BaseRing(A): AlgQuat -> Fld`

The base field of the quaternion algebra $A$.

<a id="function-basis-algquat"></a>
#### `Basis(A): AlgQuat -> SeqEnum`

The basis of the algebra $A$.

<a id="function-ramifiedprimes-algquat"></a>
#### `RamifiedPrimes(A): AlgQuat -> SeqEnum`

Given a quaternion algebra $A$ over ${\mathbb{Q}}$ or ${\mathbb{F}}_q(X)$ with $q$ odd, this function returns a list of primes or normalized irreducible polynomials corresponding to the finite ramified places of $A$.

<a id="example-ex-4e1f00"></a>
#### `Example: Ramified Primes (ex-4e1f00)`

The sequence of ramified primes of a quaternion algebra $A$ over ${\mathbb{Q}}$ determines the isomorphism class of the algebra.

```magma
> A := QuaternionAlgebra(-436,-503,22);
> RamifiedPrimes(A);
[ 17 ]
```

Provided the discriminant is of a size which can be factored, the ramified primes are determined efficiently using Hilbert symbols.

<a id="function-ramifiedplaces-algquat"></a>
#### `RamifiedPlaces(A): AlgQuat -> SeqEnum, SeqEnum`

<a id="function-factoreddiscriminant-algquat"></a>
#### `FactoredDiscriminant(A): AlgQuat -> SeqEnum, SeqEnum`

Given a quaternion algebra $A$ over ${\mathbb{Q}}$ or ${\mathbb{F}}_q(X)$ with $q$ odd or a number field, this function returns the finite as well as infinite places where $A$ is ramified.

Note: The first return value of these functions is always a list of ideals, even if the algebra is given over ${\mathbb{Q}}$ or ${\mathbb{F}}_q(X)$.

<a id="example-ex-642861"></a>
#### `Example: Ramified Primes over a Function Field (ex-642861)`

This example shows the (minor) difference between `RamifiedPrimes` and `RamifiedPlaces`.

```magma
> F<x> := RationalFunctionField( GF(5) );
> A := QuaternionAlgebra< F | 2, x >;
> R<x>:= Integers(F);
> RamifiedPrimes(A);
[ x ]
> RamifiedPlaces(A);
[
    Ideal of Univariate Polynomial Ring in x over GF(5) generated by x
]
[ Infinity ]
```

<a id="function-discriminant-algquat-fldrat"></a>
#### `Discriminant(A): AlgQuat[FldRat] -> RngIntElt`

<a id="function-discriminant-algquat-fldfunrat"></a>
#### `Discriminant(A): AlgQuat[FldFunRat] -> RngUPolElt`

<a id="function-discriminant-algquat-fldalg"></a>
#### `Discriminant(A): AlgQuat[FldAlg] -> RngOrdIdl, SeqEnum`

The reduced discriminant of a quaternion algebra $A$ over $\Q$, $\F_q(X)$ with $q$ odd, or a number field. In the first two cases, the functions return the product of the ramified primes. Over number fields, they return the product of the ramified prime ideals as well as the sequence of ramified infinite places.

<a id="function-standardform-algquat"></a>
#### `StandardForm(A): AlgQuat -> RngElt, RngElt, AlgQuat, Map`

Returns integers $a$ and $b$ in the base field $F$ of the given quaternion algebra $A$ such that there exists elements $i,j \in A$ where $i^2=a$, $j^2=b$, and $ji=-ij$. The third object returned is the standard quaternion algebra $B=$ `QuaternionAlgebra<F|a,b>`, and the fourth object is the homomorphism from $A$ to $B$.

### Hilbert Symbols and Embeddings

Let $A$ be a quaternion algebra over $Q$, ${\mathbb{F}}_q(X)$ (with $q$ odd) or a number field $F$ with defining elements $a,b$, and let $v$ be a place of $F$. If $v$ is unramified in $A$ (i.e. $A \otimes_F F_v \cong M_2(F_v)$, we define the *Hilbert symbol* $(a,b)_v$ to be $1$, and otherwise we define $(a,b)_v=-1$.

<a id="function-hilbertsymbol-fldratelt-fldratelt-rngintelt"></a>
#### `HilbertSymbol(a, b, p): FldRatElt, FldRatElt, RngIntElt -> RngIntElt`

<a id="function-hilbertsymbol-fldfunratelt-fldfunratelt-rngelt-p"></a>
#### `HilbertSymbol(a, b, p): FldFunRatElt, FldFunRatElt, RngElt p -> RngIntElt`

<a id="function-hilbertsymbol-fldnumelt-fldnumelt-rngordidl"></a>
#### `HilbertSymbol(a, b, p): FldNumElt, FldNumElt, RngOrdIdl -> RngIntElt`

<a id="function-hilbertsymbol-algquat-fldrat-rngintelt"></a>
#### `HilbertSymbol(A, p): AlgQuat[FldRat], RngIntElt -> RngIntElt`

<a id="function-hilbertsymbol-algquat-fldfunrat-rngelt"></a>
#### `HilbertSymbol(A, p): AlgQuat[FldFunRat], RngElt -> RngIntElt`

<a id="function-hilbertsymbol-algquat-rngordidl"></a>
#### `HilbertSymbol(A, p): AlgQuat, RngOrdIdl -> RngIntElt`

```magma
Al: MonStgElt                    Default: "NormResidueSymbol"
```

Computes the Hilbert symbol for the quaternion algebra $A$ over $F$, namely $(a,b)_p$, where $a,b \in F$ and $p$ is either a prime (if $a,b \in {\mathbb{Q}}$ or ${\mathbb{F}}_q(X)$) or a prime ideal. If $a,b \in {\mathbb{Q}}$, by default table-lookup is used to compute the Hilbert symbol; one can optionally insist on using the full algorithm by setting the parameter `Al` to the value `"Evaluate"`.

<a id="function-isramified-rngelt-algquat"></a>
#### `IsRamified(p, A): RngElt, AlgQuat -> BoolElt`

<a id="function-isunramified-rngelt-algquat"></a>
#### `IsUnramified(p, A): RngElt, AlgQuat -> BoolElt`

<a id="function-isramified-rngupol-algquat-fldfunrat"></a>
#### `IsRamified(p, A): RngUPol, AlgQuat[FldFunRat] -> BoolElt`

<a id="function-isunramified-rngupol-algquat-fldfunrat"></a>
#### `IsUnramified(p, A): RngUPol, AlgQuat[FldFunRat] -> BoolElt`

<a id="function-isramified-rngordidl-algquat-fldalg"></a>
#### `IsRamified(p, A): RngOrdIdl, AlgQuat[FldAlg] -> BoolElt`

<a id="function-isunramified-rngordidl-algquat-fldalg"></a>
#### `IsUnramified(p, A): RngOrdIdl, AlgQuat[FldAlg] -> BoolElt`

Returns `true` if and only if the prime or prime ideal $p$ is ramified (unramified) in the quaternion algebra $A$.

<a id="example-ex-9d678c"></a>
#### `Example: Hilbert Symbols over the Rationals (ex-9d678c)`

We first verify the correctness of all Hilbert symbols over the rationals.

```magma
> QQ := Rationals();
> for a,b in [1..8] do
>   bl := HilbertSymbol(QQ ! a, QQ ! b,2 : Al := "Evaluate")
>                eq NormResidueSymbol(a,b,2);
>   print <a,b,bl>;
>   if not bl then
>     break a;
>   end if;
> end for;
<1, 1, true>
<1, 2, true>
<1, 3, true>
...
```

For a second test, we input a quaternion algebra which is unramified at all finite places.

```magma
> P<x> := PolynomialRing(Rationals());
> F<b> := NumberField(x^3-3*x-1);
> Z_F := MaximalOrder(F);
> A := QuaternionAlgebra<F | -3,b>;
> symbols := [];
> for p in [p : p in [2..100] | IsPrime(p)] do
>   pps := Decomposition(Z_F,p);
>   for pp in pps do
>     Append(~symbols,HilbertSymbol(A,pp[1]));
>   end for;
> end for;
> symbols;
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
```

Finally, we test “random” quaternion algebras over quadratic extensions at even primes, the hardest case. We use the fact that the quaternion algebra $(a,b)$ is ramified at a prime ideal $p$ if and only if $b$ is a norm from the extension $F(\sqrt{a})$, so we can test this condition using `IsLocalNorm`. Note that this takes substantially more time.

```magma
> for c in [2,-2,6,-6,-1,3,-3] do
>   K<s> := NumberField(x^2-c);
>   Z_K := MaximalOrder(K);
>   Z_Kmod8, f8 := quo<Z_K | 8>;
>   PPK<xK> := PolynomialRing(K);
>   for i := 1 to 10 do
>     S := [x+y*Z_K.2 : x,y in [0..7] | x*y ne 0];
>     a := Random(S);
>     b := Random(S);
>     A := QuaternionAlgebra<K | a,b>;
>     for pp in Decomposition(Z_K,2) do
>       hsym := HilbertSymbol(A,pp[1]);
>       if not IsIrreducible(xK^2-a) then
>         print <c, a, b, hsym eq 1>;
>         if hsym ne 1 then
>           break c;
>         end if;
>       else
>         lclsym := IsLocalNorm(AbelianExtension(ext<K | xK^2-a>),Z_K ! b,pp[1]);
>         bl := (hsym eq 1) eq lclsym;
>         print <c, a, b, bl>;
>         if not bl then
>           break c;
>         end if;
>       end if;
>     end for;
>   end for;
> end for;
<2, 5/1*Z_K.1 + 3/1*Z_K.2, Z_K.1 + 7/1*Z_K.2, true>
<2, 6/1*Z_K.1 + 4/1*Z_K.2, 4/1*Z_K.1 + Z_K.2, true>
<2, 7/1*Z_K.1 + Z_K.2, 2/1*Z_K.1 + 2/1*Z_K.2, true>
...
```

<a id="function-pmatrixring-algquat-rngordidl"></a>
#### `pMatrixRing(A, p): AlgQuat, RngOrdIdl -> AlgMat, Map, Map`

<a id="function-pmatrixring-algquat-rngelt"></a>
#### `pMatrixRing(A, p): AlgQuat, RngElt -> AlgMat, Map, Map`

<a id="function-pmatrixring-algassvord-rngordidl"></a>
#### `pMatrixRing(O, p): AlgAssVOrd, RngOrdIdl -> AlgMat, Map, Map`

<a id="function-pmatrixring-algquatord-rngelt"></a>
#### `pMatrixRing(O, p): AlgQuatOrd, RngElt -> AlgMat, Map, Map`

<a id="function-pmatrixring-algquatord-rngint-rngint"></a>
#### `pMatrixRing(O, p): AlgQuatOrd[RngInt], RngInt -> AlgMat, Map, Map`

```magma
Precision: RngIntElt                    Default: 
```

Let $A$ be a quaternion algebra $A$ over a field $F$ where $F$ is the rationals, a number field, or $\F_q(x)$ with $q$ odd. Given $A$ and a prime (ideal) p of the ring of integers $R$ of $F$ such that $p$ is unramified in $A$, this function returns the matrix ring over the completion $F_p$ of $F$ at $p$, a map from $A \to M_2(F_p)$, and the embedding $F \to F_p$.

Given a $p$-maximal order $O$ in $A$, the map from $A \to M_2(F_p)$ induces a map from $O \to <Meta>-_2(R_p)$.

<a id="function-issplittingfield-fld-algquat"></a>
#### `IsSplittingField(K, A): Fld, AlgQuat -> BoolElt, AlgQuatElt, Map`

<a id="function-hasembedding-fld-algquat"></a>
#### `HasEmbedding(K, A): Fld, AlgQuat -> BoolElt, AlgQuatElt, Map`

```magma
ComputeEmbedding: BoolElt                    Default: false
```

Given a quaternion algebra $A$ defined over ${\mathbb{Q}}$, ${\mathbb{F}}_q(X)$ (with $q$ odd) or a number field $F$ and $K$ a quadratic extension of $F$, the function returns `true` if and only if there exists an embedding $K \to A$ over $F$. This is done by comparison of ramified places in $K$ and $A$ (see [[Vig80](https://docs.magma-maths.org/references.md#cite-vigneras80), Cor. III.3.5]). If no embedding exists, the second return value will be a witness place. If an embedding exists and the optional argument `ComputeEmbedding` is set to `true`, the second and third return values contain the result of a call to `Embed` as described below.

<a id="function-embed-fld-algquat"></a>
#### `Embed(K, A): Fld, AlgQuat -> AlgQuatElt, Map`

```magma
Al: MonStgElt                    Default: "NormEquation"
```

Given a quaternion algebra $A$ defined over ${\mathbb{Q}}$, ${\mathbb{F}}_q(X)$ (with $q$ odd) or a number field $F$ and $K$ a quadratic extension of $F$, returns an embedding $K \to A$ over $F$, given as an element of $A$, the image of the primitive generator of $K$, and the map $K \to A$.

The algorithm by default involves solving a relative norm equation. Alternatively, a naive search algorithm may be selected by setting the optional parameter `Al:="Search"`.

If there is no embedding, a runtime error occurs (or the `"Search"` runs forever). To check whether an embedding exists, use `HasEmbedding` (see immediately above).

<a id="function-embed-rngord-algassvord"></a>
#### `Embed(Oc, O): RngOrd, AlgAssVOrd -> AlgAssVOrdElt, Map`

```magma
Al: MonStgElt                    Default: "NormEquation"
```

Given a quadratic order $O_c$ with base number ring $R$ and a quaternion order $O$ with base ring $R$, the function computes an embedding $O_c \hookrightarrow O$ over $R$. It returns the image of the second generator `Oc.2` of `Oc`; secondly it returns the embedding map $O_c \to O$.

The algorithm by default involves solving a relative norm equation. Alternatively, a naive search algorithm may be selected by setting the optional parameter `Al:="Search"`.

*Notes.* Let $K$ be the number field containing $Oc$.

*(i)* `Oc.1, Oc.2` are the generators of $Oc$ as a module, and `Oc.2` is unrelated to `K.1`, where $K$ is the number field containing $Oc$.

*(ii)* To check whether an embedding of $K$ into the algebra exists, one can use `HasEmbedding(K, Algebra(O) : ComputeEmbedding:=false`).

<a id="example-ex-06ae1e"></a>
#### `Example: Embedding a Field in a Quaternion Algebra (ex-06ae1e)`

```magma
> F<b> := NumberField(Polynomial([1,-3,0,1]));
> A := QuaternionAlgebra<F | -3, b>;
> K := ext<F | Polynomial([2,-1,1])>;
> mu, iota := Embed(K, A);
> mu;
1/2 + 1/6*(-2*b^2 + 2*b + 7)*i + 1/2*(2*b^2 + b - 6)*j + 1/6*(-2*b^2 - b + 4)*k
> MinimalPolynomial(mu);
$.1^2 - $.1 + 2
> iota(K.1) eq mu;
true
```

### Predicates on Algebras

A quaternion algebra $A$ over a number field $F$ with $[F:{\mathbb{Q}}]=h$ is *definite* (or *totally definite*) if $F$ is totally real and $A \otimes_{{\mathbb{Q}}} {\mathbb{R}}\cong H^h$, where $H$ is the division ring of real Hamiltonians, otherwise $A$ is *indefinite*.

A quaternion algebra $A$ over ${\mathbb{F}}_q(X)$ is called *definite* if the place corresponding to the degree valuation is ramified.

<a id="function-isdefinite-algquat"></a>
#### `IsDefinite(A): AlgQuat -> BoolElt`

<a id="function-isindefinite-algquat"></a>
#### `IsIndefinite(A): AlgQuat -> BoolElt`

Given a quaternion algebra $A$ over a number field, $\Q$, or $\F_q(X)$ with $q$ odd, returns `true` if and only if $A$ is a (totally) definite or indefinite quaternion algebra, respectively.

### Recognition Functions

A quaternion algebra $A$ over a field $K$ is isomorphic to the matrix ring $M_2(K)$ if and only if there exists a zerodivisor $\epsilon$ in $A$. Given such an $\epsilon$, we can exhibit an explicit isomorphism; otherwise a zerodivisor will be computed first by finding a point on a conic (see [[Vig80](https://docs.magma-maths.org/references.md#cite-vigneras80), Cor. I.2.4]).

Given an associative algebra, we also have an algorithm to recognize if the algebra is a quaternion algebra, and, if so, return an isomorphism to a quaternion algebra in standard form.

<a id="function-ismatrixring-algquat"></a>
#### `IsMatrixRing(A): AlgQuat -> BoolElt, AlgMat, Map`

```magma
Isomorphism: BoolElt                    Default: false
```

Returns `true` if and only if the quaternion algebra $A$ with base field $F$ is isomorphic to $M_2(F)$, or equivalently if $A$ has no ramified places. The field $F$ has to be ${\mathbb{Q}}$, ${\mathbb{F}}_q(X)$ (with $q$ odd) or a number field.

If $A$ is isomorphic to $M_2(F)$ and `Isomorphism` is set to `true`, then $M_2(F)$ and an isomorphism $A \to M_2(F)$ are also returned.

<a id="function-matrixring-algquat-algquatelt"></a>
#### `MatrixRing(A, eps): AlgQuat, AlgQuatElt -> AlgMat, Map`

<a id="function-matrixalgebra-algquat-algquatelt"></a>
#### `MatrixAlgebra(A, eps): AlgQuat, AlgQuatElt -> AlgMat, Map`

Given a quaternion algebra $A$ and a zerodivisor $\epsilon \in A$, the function returns the matrix algebra $M_2(F)$ and an isomorphism $A \to M_2(F)$.

<a id="example-ex-696aa7"></a>
#### `Example: Isomorphism with a Matrix Ring (ex-696aa7)`

```magma
> A := QuaternionAlgebra<Rationals() | -1, 1>;
> eps := A.3-1;
> MinimalPolynomial(eps), Norm(eps);
x^2 + 2*x
0
```

Thus, since $\epsilon$ has reduced norm $0$, it is a zerodivisor: indeed, $\epsilon(\epsilon+2)=0$.

```magma
> M2F, phi := MatrixRing(A,eps);
> [<MinimalPolynomial(A.i), MinimalPolynomial(phi(A.i))> : i in [1..3]];
[
    <x^2 + 1, x^2 + 1>,
    <x^2 - 1, x^2 - 1>,
    <x^2 - 1, x^2 - 1>
]
```

<a id="function-isquaternionalgebra-algass"></a>
#### `IsQuaternionAlgebra(B): AlgAss -> BoolElt, AlgQuat, Map`

<a id="function-isquaternionalgebra-algmat"></a>
#### `IsQuaternionAlgebra(B): AlgMat -> BoolElt, AlgQuat, Map`

Returns `true` if and only if the associative algebra $B$ is a quaternion algebra; if true, it returns the associated quaternion algebra $A$ in standard form and an algebra homomorphism from $B$ to $A$. The algorithm used is [[Voi05](https://docs.magma-maths.org/references.md#cite-voight1), Algorithm 4.2.9].

<a id="example-ex-52731a"></a>
#### `Example: Recognising a Quaternion Algebra (ex-52731a)`

We create an associative algebra which is known to be a quaternion algebra $A$ and then recover $A$ (or an isomorphic algebra).

```magma
> A := AssociativeAlgebra(QuaternionAlgebra<Rationals() | -1,1>);
> vecs := [&+[Random(10)*A.i : i in [1..4]] : j in [1..4]];
> Mchange := Matrix(Rationals(),4,4,&cat[Eltseq(vecs[i]) : i in [1..4]]);
> Mchange := Mchange^(-1);
> seq := [<i,j,k,((vecs[i]*vecs[j])*Mchange)[k]> : i,j,k in [1..4]];
> A := AssociativeAlgebra<Rationals(),4 | seq>;
> bl, Aquat, phi := IsQuaternionAlgebra(A);
> bl;
true
> Aquat;
Quaternion Algebra with base ring Rational Field
> Aquat.1^2, Aquat.2^2;
25 -3924/25
> phi;
Mapping from: AlgAss: A to AlgQuat: Aquat given by a rule
```

We now verify the functionality when a zerodivisor is encountered.

```magma
> A := Algebra(MatrixAlgebra(Rationals(),2));
> IsQuaternionAlgebra(A);
true Quaternion Algebra with base ring Rational Field
Mapping from: AlgAss: A to Quaternion Algebra with base ring Rational Field
given by a rule
```

The algebra $k<x,y>$ with $x^2=y^2=xy+yx=0$ is not semisimple; the ideal generated by $x,y$ is a nontrivial two-sided ideal. Similarly, a commutative algebra is not a quaternion algebra.

```magma
> A := Algebra(FPAlgebra<Rationals(), x,y | x^2, y^2, x*y+y*x>);
> IsQuaternionAlgebra(A);
false
> A := Algebra(FPAlgebra<Rationals(), x | x^4+x^2+1>);
> IsQuaternionAlgebra(A);
false
```

In characteristic $2$, the algorithm also performs correctly, both for an associative but non-quaternion algebra and for the “universal” example of a quaternion algebra.

```magma
> A := Algebra(FPAlgebra<GF(2), x,y | x^2, y^2, x*y+y*x+1>);
> IsQuaternionAlgebra(A);
false
> F<a,b,x,y,z,w> := FieldOfFractions(PolynomialRing(GF(2),6));
> M := [[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1],
>       [0,1,0,0],[a,1,0,0],[0,0,0,1],[0,0,a,1],
>       [0,0,1,0],[0,0,1,1],[b,0,0,0],[b,b,0,0],
>       [0,0,0,1],[0,0,a,0],[0,b,0,0],[a*b,0,0,0]];
> A<alpha,beta> := AssociativeAlgebra<F,4 | M>;
> alpha^2+alpha+a;
(0 0 0 0)
> beta^2+b;
(0 0 0 0)
>
> bl, Aquat, phi := IsQuaternionAlgebra(A);
> bl;
true
> Aquat;
Quaternion Algebra with base ring Multivariate rational function field of
rank 6 over GF(2)
> theta := phi(x+y*alpha+z*beta+w*alpha*beta);
> Trace(theta);
y
> Norm(theta);
a*b*w^2 + a*y^2 + b*z^2 + b*z*w + x^2 + x*y
```

<a id="function-matrixrepresentation-algquat"></a>
#### `MatrixRepresentation(A): AlgQuat -> Map`

<a id="function-matrixrepresentation-algquatord"></a>
#### `MatrixRepresentation(R): AlgQuatOrd -> Map`

Given a quaternion algebra $A$ over ${\mathbb{Q}}$ or a quaternion order $R$ over ${\mathbb{Z}}$, this function returns a $2 \times 2$-matrix representation of $A$, defined over a quadratic extension.

### Attributes of Orders

For further information about orders of associative algebras, see Section [Orders](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#secalgassvord).

For a quaternion order $S$ over ${\mathbb{Z}}$ or ${\mathbb{F}}_q[X]$, Magma additionally defines the following functions.

<a id="function-algebra-algquatord"></a>
#### `Algebra(S): AlgQuatOrd -> AlgQuat`

<a id="function-quaternionalgebra-algquatord"></a>
#### `QuaternionAlgebra(S): AlgQuatOrd -> AlgQuat`

The quaternion algebra for which $S$ is an order.

<a id="function-basismatrix-algquatord"></a>
#### `BasisMatrix(S): AlgQuatOrd -> AlgMatElt`

<a id="function-embeddingmatrix-algquatord"></a>
#### `EmbeddingMatrix(S): AlgQuatOrd -> AlgMatElt`

Returns the basis matrix of the quaternion order $S$ over ${\mathbb{Z}}$ or ${\mathbb{F}}_q[X]$. The rows of the matrix give the basis elements of $S$ with respect to the basis of the container algebra.

<a id="function-discriminant-algquatord"></a>
#### `Discriminant(S): AlgQuatOrd -> RngElt`

Given an order $S$ over ${\mathbb{Z}}$ or ${\mathbb{F}}_q[X]$, this function returns the reduced discriminant of $S$ as a positive integer or a normalized polynomial.

<a id="function-factoreddiscriminant-algquatord"></a>
#### `FactoredDiscriminant(S): AlgQuatOrd -> SeqEnum`

Given a quaternion order $S$, this function returns the factorisation of the reduced discriminant of $S$ (that is, `Factorization(Discriminant(S))`).

<a id="function-conductor-algquatord"></a>
#### `Conductor(S): AlgQuatOrd -> RngElt`

<a id="function-level-algquatord"></a>
#### `Level(S): AlgQuatOrd -> RngElt`

Given an order $S$ over ${\mathbb{Z}}$ or ${\mathbb{F}}_q[X]$ in a quaternion algebra $A$, this function returns the reduced index of $S$ in a maximal order of $A$ containing it. Together with the reduced discriminant of the order, this serves to classify the local isomorphism class of an Eichler order.

<a id="function-normalizer-algassvord"></a>
#### `Normalizer(S): AlgAssVOrd -> Grp, Map`

Let $S$ be an order in a definite quaternion algebra $A$ over a field $F$ where $F$ is the rationals, $\F_q(t)$, or a number field. This function returns a matrix group $G$ isomorphic to the normalizer of $S$ in $A^*$ modulo $F^*$. A homomorphism from $G$ to $A^*$ is also returned.

### Predicates of Orders

Let $O$ be a quaternion order with base ring ${\mathbb{Z}}$, ${\mathbb{F}}_q[X]$ with $q$ odd, or a number ring. Then Magma can test the following predicates.

<a id="function-ismaximal-algassvord"></a>
#### `IsMaximal(O): AlgAssVOrd -> BoolElt`

Returns `true` if and only if the order $O$ is maximal.

<a id="function-ispmaximal-algassvord-rngordidl"></a>
#### `IspMaximal(O, p): AlgAssVOrd, RngOrdIdl -> BoolElt`

<a id="function-ispmaximal-algquatord-rngelt"></a>
#### `IspMaximal(O, p): AlgQuatOrd, RngElt -> BoolElt`

Returns `true` if and only if the order $O$ is maximal at the prime or prime ideal $p$.

<a id="function-iseichler-algassvord"></a>
#### `IsEichler(O): AlgAssVOrd -> BoolElt, AlgAssVOrd, AlgAssVOrd`

```magma
MaximalOrders: BoolElt                    Default: false
```

Returns `true` if and only if the order $O$ is *Eichler*, that is an intersection of two (not necessarily distinct) maximal orders. The function calls the `EichlerInvariant` intrinsic explained below.

If the optional argument `MaximalOrders` is set to `true`, the algorithm also returns two maximal orders such that $O$ is their intersection.

<a id="function-iseichler-algassvord-rngordidl"></a>
#### `IsEichler(O, p): AlgAssVOrd, RngOrdIdl -> BoolElt, AlgAssVOrd, AlgAssVOrd`

<a id="function-iseichler-algquatord-rngelt"></a>
#### `IsEichler(O, p): AlgQuatOrd, RngElt -> BoolElt, AlgQuatOrd, AlgQuatOrd`

```magma
MaximalOrders: BoolElt                    Default: false
```

Returns `true` if and only if the completion of the order $O$ at the prime (ideal) $p$ is *Eichler*.

If the optional argument `MaximalOrders` is set to `true`, the algorithm also returns two $p$-maximal orders such that $O$ is their intersection.

<a id="function-eichlerinvariant-algassvord-rngordidl"></a>
#### `EichlerInvariant(O, p): AlgAssVOrd, RngOrdIdl -> RngIntElt`

<a id="function-eichlerinvariant-algquatord-rngelt"></a>
#### `EichlerInvariant(O, p): AlgQuatOrd, RngElt -> RngIntElt`

Returns the local Eichler invariant of $O$ at some prime (ideal) $p$ which divides the discriminant of $O$. Let $R$ be the base ring of $O$ and let $J$ be the Jacobson radical of the $R/p$-algebra $O/pO$. If $J$ has dimension $3$ then the Eichler invariant is defined to be $0$. Otherwise the quotient of $O/pO$ by $J$ is either isomorphic to a direct sum of two copies of $R/p$ or a quadratic field extension of $R/p$. In the first case the Eichler invariant is $1$, in the latter it is $-1$.

<a id="function-ishereditary-algassvord"></a>
#### `IsHereditary(O): AlgAssVOrd -> BoolElt`

Returns `true` if and only if the order $O$ is a hereditary order in a quaternion algebra $A$. That is, every lattice in $A$ of full rank such that $O$ is contained in its left order is a projective left $O$-module. The hereditary orders are precisely those with squarefree discriminant.

<a id="function-ishereditary-algassvord-rngordidl"></a>
#### `IsHereditary(O, p): AlgAssVOrd, RngOrdIdl -> BoolElt`

<a id="function-ishereditary-algquatord-rngelt"></a>
#### `IsHereditary(O, p): AlgQuatOrd, RngElt -> BoolElt`

Returns `true` if and only if the completion of the order $O$ at the prime (ideal) $p$ is *hereditary*.

<a id="function-isgorenstein-algassvord"></a>
#### `IsGorenstein(O): AlgAssVOrd -> BoolElt, .`

Returns `true` if and only if the order $O$ is a Gorenstein order. That is, the dual of $O$ with respect to the trace bilinear form is a projective $O$-module. The second return value is the Brandt invariant of $O$ as in the [`GorensteinClosure`](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/order-creation.md#function-algquat-gorensteinclosure) intrinsic.

<a id="function-isgorenstein-algassvord-rngordidl"></a>
#### `IsGorenstein(O, p): AlgAssVOrd, RngOrdIdl -> BoolElt, RngIntElt`

<a id="function-isgorenstein-algquatord-rngelt"></a>
#### `IsGorenstein(O, p): AlgQuatOrd, RngElt -> BoolElt, RngIntElt`

Returns `true` if and only if the completion of the order $O$ at the prime (ideal) $p$ is *Gorenstein*. The second return value is the valuation of the Brandt invariant of $O$ at $p$.

<a id="function-isbass-algassvord"></a>
#### `IsBass(O): AlgAssVOrd -> BoolElt`

Returns `true` if and only if the order $O$ is a Bass order, i.e. every order which contains $O$ is Gorenstein.

<a id="function-isbass-algassvord-rngordidl"></a>
#### `IsBass(O, p): AlgAssVOrd, RngOrdIdl -> BoolElt`

<a id="function-isbass-algquatord-rngelt"></a>
#### `IsBass(O, p): AlgQuatOrd, RngElt -> BoolElt`

Returns `true` if and only if the completion of the order $O$ at the prime (ideal) $p$ is *Bass*.

<a id="function-issametype-algassvord-algassvord"></a>
#### `IsSameType(O1, O2): AlgAssVOrd, AlgAssVOrd -> BoolElt`

Returns `true` if and only if the two quaternion orders $O1$ and $O2$ are of the same *type* which means that they are locally isomorphic. The orders must be over the ring of integers or a number ring.

### Operations with Orders

<a id="operation-op-meet-algquatord-rngint-algquatord-rngint"></a>
#### `O1 meet O2: AlgQuatOrd[RngInt], AlgQuatOrd[RngInt] -> AlgQuatOrd`

<a id="operation-op-meet-algquatord-rngupol-algquatord-rngupol"></a>
#### `O1 meet O2: AlgQuatOrd[RngUPol], AlgQuatOrd[RngUPol] -> AlgQuatOrd`

<a id="operation-op-meet-algassvord-algassvord"></a>
#### `O1 meet O2: AlgAssVOrd, AlgAssVOrd -> AlgAssVOrd`

This returns the order obtained by intersecting the quaternion orders $O_1$ and $O_2$.

<a id="operation-op-pow-algquatord-algquatelt"></a>
#### `O ^ x: AlgQuatOrd, AlgQuatElt -> AlgQuatOrd`

<a id="operation-op-pow-algassvord-algasselt"></a>
#### `O ^ x: AlgAssVOrd, AlgAssElt -> AlgAssvOrd`

This returns the conjugate of the order $O$ by an element $x$ in the associative algebra $A$ for which $O$ is an order (in other words the order $x^{-1} O x$).

### Ideal Theory of Orders

The right (or left) ideals of an $R$-order $O$ in a quaternion algebra $A$ defined over a number field fall into finitely many isomorphism classes. Already, for the case of number rings, it is a computationally difficult problem to compute the class group, and due to the noncommutativity of quaternion algebras, the problem of enumerating ideal classes of quaternion orders is even more difficult because this set does not have the structure of a group.

All orders in this section are required to be *Eichler*. The reader should recall that this includes the maximal orders.

The algorithms underpinning the intrinsics described in this section, in particular, those for determining ideal classes, are described in [[KV10](https://docs.magma-maths.org/references.md#cite-kirschmer-voight)]. The methods depend on whether $A$ is definite or indefinite. For a definite algebra, we use a variation of Kneser’s neighbouring method together with Eichler’s mass formula (see [[Vig80](https://docs.magma-maths.org/references.md#cite-vigneras80), Chapter 5] and [[DG88](https://docs.magma-maths.org/references.md#cite-denert88)]) to construct sufficient ideals to represent all ideal classes. We then test if two right (or left) ideals $I, J$ are isomorphic (Section [Isomorphisms of Ideals](https://docs.magma-maths.org/Algebras/QuaternionAlgebras/isomorphisms.md#algquatisoideals)).

For an indefinite quaternion algebra, we use a theorem of Eichler [[Rei03](https://docs.magma-maths.org/references.md#cite-reiner-mo), Th. 35.14] which states that the reduced norm gives rise to a bijection of sets between the class groups of the order and the number ring. (Over ${\mathbb{Z}}$ or ${\mathbb{F}}_q[X]$, therefore, every ideal of an indefinite quaternion order is principal.) We may compute representative ideals $I$ of $O$ whose reduced norm is in a specified ideal class. We then reduce the problem of testing for an isomorphism $I \cong J$ between two ideals to the similar problem over $R$. Here, the problem of explicitly computing such an isomorphism is much less difficult, as an order (or ideal) will have infinitely many elements of bounded norm, and in most cases a search amongst reduced bases will find a desired element.

Ideals of quaternion orders belong to the types `AlgQuatOrdIdl` and `AlgAssVOrdIdl` according as to whether the order $O$ is defined over ${\mathbb{Z}}$ or ${\mathbb{F}}_q[X]$ (both of type `AlgQuatOrd`) or over a number ring (of type `AlgAssVOrd`). For more on the constructions and functions for ideals of the latter type, see Section [Orders](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#secalgassvord).

#### Creation and Access Functions

<a id="function-leftideal-algquatord-algquatelt"></a>
##### `LeftIdeal(S, X): AlgQuatOrd, [AlgQuatElt] -> AlgQuatOrdIdl`

<a id="constructor-constructor-lideal-algquatord-algquatelt-algquatordidl"></a>
##### `lideal<S | X>: AlgQuatOrd, [AlgQuatElt] -> AlgQuatOrdIdl`

<a id="function-rightideal-algquatord-algquatelt"></a>
##### `RightIdeal(S, X): AlgQuatOrd, [AlgQuatElt] -> AlgQuatOrdIdl`

<a id="constructor-constructor-rideal-algquatord-algquatelt-algquatord"></a>
##### `rideal<S | X>: AlgQuatOrd, [AlgQuatElt] -> AlgQuatOrd`

<a id="constructor-constructor-ideal-algquatord-algquatelt-algquatordidl"></a>
##### `ideal<S | X>: AlgQuatOrd, [AlgQuatElt] -> AlgQuatOrdIdl`

These intrinsics construct a left, right, or two-sided ideal of the order $S$ generated by the sequence $X$, which should contain elements that are coercible into the algebra of $S$.

In the case of the constructors `lideal< | >` and `rideal< | >`, the right hand side may also be a matrix or pseudo-matrix giving the basis of the ideal with respect to the basis of $S$.

<a id="function-primeideal-algquatord-rngelt"></a>
##### `PrimeIdeal(S, p): AlgQuatOrd, RngElt -> AlgQuatOrdIdl`

Given a quaternion order $S$ over ${\mathbb{Z}}$ or ${\mathbb{F}}_q[X]$, the function returns the unique two-sided (integral) prime ideal $P$ of $S$ over the prime $p$ of ${\mathbb{Z}}$ or ${\mathbb{F}}_q[X]$. If $p$ exactly divides the discriminant of $S$, then $P$ properly contains $pS$ and need not be principal, and otherwise $P$ is equal to $pS$.

<a id="function-commutatorideal-algquatord"></a>
##### `CommutatorIdeal(S): AlgQuatOrd -> AlgQuatOrdIdl`

<a id="function-commutatorideal-algassvord"></a>
##### `CommutatorIdeal(S): AlgAssVOrd -> AlgAssVOrdIdl`

The two-sided ideal of the quaternion order $S$ generated by elements of the form $xy - yx$.

<a id="function-maximalleftideals-algquatord-rngelt"></a>
##### `MaximalLeftIdeals(O, p): AlgQuatOrd, RngElt -> [AlgQuatOrdIdl]`

<a id="function-maximalleftideals-algassvord-rngordidl"></a>
##### `MaximalLeftIdeals(O, p): AlgAssVOrd, RngOrdIdl -> [AlgAssVOrdIdl]`

<a id="function-maximalrightideals-algquatord-rngelt"></a>
##### `MaximalRightIdeals(O, p): AlgQuatOrd, RngElt -> [AlgQuatOrdIdl]`

<a id="function-maximalrightideals-algassvord-rngordidl"></a>
##### `MaximalRightIdeals(O, p): AlgAssVOrd, RngOrdIdl -> [AlgAssVOrdIdl]`

The integral ideals of norm $p$ with left or right order $O$.

<a id="example-ex-4a8cb2"></a>
##### `Example: Two-Sided Prime Ideals (ex-4a8cb2)`

We demonstrate the construction of the 2-sided prime ideals and their relationship with the commutator ideal.

```magma
> S := QuaternionOrder(2*5*11);
> P := PrimeIdeal(S, 2);
> I := ideal< S | [2] cat [ x*y-y*x : x, y in Basis(S) ] >;
> P eq I;
true
> Q := PrimeIdeal(S, 5);
> R := PrimeIdeal(S, 11);
> P*Q*R eq CommutatorIdeal(S);
true
```

By way of explanation, we note that the composition of ideals is well-defined, since each of these ideals is a 2-sided ideal for $S$, that is, a left ideal whose right order is also $S$. The collection of all prime ideals over the ramified primes of a maximal order forms an elementary $2$-abelian class group, and the commutator ideal is the product of these prime ideals.

<a id="example-ex-1b3844"></a>
##### `Example: Norm and Basis of an Ideal (ex-1b3844)`

First we create an integral ideal $I$ of norm 2.

```magma
> QQ:= Rationals();
> A<i,j> := QuaternionAlgebra< QQ | -1, -11 >;
> S := MaximalOrder(A);
> P<x> := PolynomialRing(QQ);
> P ! MinimalPolynomial(i);
x^2 + 1
> I := lideal< S | 2, 1+i >;
> Norm(I);
2
> I in MaximalLeftIdeals(S, 2);
true
```

We now examine the basis of the ideal $I$.

```magma
> Basis(I);
[ 2, 1 + i, i + k, 3/2 + 1/2*i + 1/2*j + 1/2*k ]
> [ Eltseq(x) : x in Basis(I) ];
[
    [ 2, 0, 0, 0 ],
    [ 1, 1, 0, 0 ],
    [ 0, 1, 0, 1 ],
    [ 3/2, 1/2, 1/2, 1/2 ]
]
> BasisMatrix(I, A);
[  2   0   0   0]
[  1   1   0   0]
[  0   1   0   1]
[3/2 1/2 1/2 1/2]
```

If the ideal $I$ is printed, the rational coordinates with respect to the basis of the quaternion order $S$ will be shown, We can get this base change matrix if we call `BasisMatrix` with no additional parameters.

```magma
> I;
Left Ideal with basis Pseudo-matrix over Integer Ring
[2 0 0 0]
[1 1 0 0]
[0 0 2 0]
[1 0 1 1]
> BasisMatrix(I);
[2 0 0 0]
[1 1 0 0]
[0 0 2 0]
[1 0 1 1]
```

<a id="function-leftorder-algquatordidl"></a>
##### `LeftOrder(I): AlgQuatOrdIdl -> AlgQuatOrd`

<a id="function-leftorder-algassvordidl-rngord"></a>
##### `LeftOrder(I): AlgAssVOrdIdl[RngOrd] -> AlgAssVOrd`

Given an ideal $I$ of a quaternion order defined over $\Z$, $\F_q[X]$, or a number ring, this function returns the left order of $I$, defined as the ring of all elements of the quaternion algebra of $I$ mapping $I$ to itself under left multiplication.

<a id="function-rightorder-algquatordidl"></a>
##### `RightOrder(I): AlgQuatOrdIdl -> AlgQuatOrd`

<a id="function-rightorder-algassvordidl-rngord"></a>
##### `RightOrder(I): AlgAssVOrdIdl[RngOrd] -> AlgAssVOrd`

Given an ideal $I$ of a quaternion order defined over $\Z$, $\F_q[X]$, or a number ring, this function returns the right order of $I$, defined as the ring of all elements of the quaternion algebra of $I$ mapping $I$ to itself under right multiplication.

<a id="example-ex-c0479d"></a>
##### `Example: Left and Right Orders of an Ideal (ex-c0479d)`

```magma
> K := NumberField(Polynomial([5,0,1]));
> K;
Number Field with defining polynomial $.1^2 + 5 over the Rational Field
> A := QuaternionAlgebra<K | 3, K.1>;
> O := MaximalOrder(A);
> I := lideal<O | O.2, Norm(O.2)>;
> Norm(I);
Principal Ideal
Generator:
    2/1*$.1
> LeftOrder(I) eq O;
true
> RightOrder(I) eq O;
true
```

#### Enumeration of Ideal Classes

The tools provided for calculating ideal classes in the case of a maximal or, more generally, an Eichler order $S$ in a quaternion algebra over ${\mathbb{Q}}$, ${\mathbb{F}}_q(X)$ (with $q$ odd) or a number field are described in this section.

<a id="function-mass-algassvord"></a>
##### `Mass(S): AlgAssVOrd -> FldRatElt`

Given a definite order $S$ over $R$, this function returns the mass $\sum_i 1 / [L(I_i)^*:R^*]$ where $I_1, \dots, I_h$ represent the isomorphism classes of invertible right ideal of $S$ and $L(I_i)$ denotes the left order of $I_i$.

<a id="function-leftidealclasses-algquatord"></a>
##### `LeftIdealClasses(S): AlgQuatOrd -> [AlgQuatOrdIdl]`

<a id="function-leftidealclasses-algassvord-rngord"></a>
##### `LeftIdealClasses(S): AlgAssVOrd[RngOrd] -> [AlgAssVOrdIdl]`

<a id="function-rightidealclasses-algquatord"></a>
##### `RightIdealClasses(S): AlgQuatOrd -> [AlgQuatOrdIdl]`

<a id="function-rightidealclasses-algassvord-rngord"></a>
##### `RightIdealClasses(S): AlgAssVOrd[RngOrd] -> [AlgAssVOrdIdl]`

```magma
Support: [RngOrdIdl]                    Default: 
```

These intrinsics find representatives for the left or right locally free ideal classes of $S$, where $S$ is an order in a quaternion algebra $A$ defined over ${\mathbb{Q}}$, ${\mathbb{F}}_q(X)$ (with $q$ odd) or a number field. The algorithms are guaranteed to work correctly only when $S$ is a maximal order or an Eichler order.

For definite algebras, the support of the returned ideals may be specified using parameter `Support`; this should be a sequence of primes or prime ideals in the base ring which generate the narrow class group and which do not ramify in $A$. In this case, the routine will find ideal class representatives whose norms are divisible only by primes in the specified support. The algorithm usually runs faster if the support is either not specified or if the support includes the prime divisors of the discriminant of $S$.

For indefinite algebras, the representatives are obtained from a ray class group of the base field.

<a id="function-twosidedidealclasses-algquatord"></a>
##### `TwoSidedIdealClasses(S): AlgQuatOrd -> [AlgQuatOrdIdl]`

<a id="function-twosidedidealclasses-algassvord-rngord"></a>
##### `TwoSidedIdealClasses(S : Support): AlgAssVOrd[RngOrd] -> [AlgAssVOrdIdl]`

```magma
Support: [RngOrdIdl]                    Default: 
```

Given an order $S$ in a quaternion algebra, this function returns a sequence containing representatives for the two-sided locally free ideal classes of $S$. The algorithm is only guaranteed to work when $S$ is a maximal order or an Eichler order.

If the optional argument `Support` is specified, Magma tries to construct representatives that have norm divisible by primes or prime ideals in the specified support. If this is not possible, the set specified using parameter `Support` will be enlarged by the prime divisors of the discriminant of $S$. If this enlarged set is still not large enough (which can only happen if the set does not generate the class of group of the base ring of $S$) an error will be raised.

<a id="function-twosidedidealclassgroup-algassvord"></a>
##### `TwoSidedIdealClassGroup(S : Support): AlgAssVOrd -> GrpAb, Map`

```magma
Support: [RngOrdIdl]                    Default: 
```

Given an order $S$ in a quaternion algebra, this returns the two-sided ideal class group of $S$ as an abstract abelian group, together with a map from the group to the set of two-sided ideal classes of $S$. Inverses with respect to this map can be calculated in a very efficient way and thus may be used to compute discrete logarithms. The algorithm is only guaranteed to work when $S$ is a maximal order or an Eichler order.

The optional parameter `Support` may be used to specify a support: this should be a sequence of primes or prime ideals in the base ring which generate the narrow class group and which do not ramify in the parent algebra.

<a id="function-conjugacyclasses-algassvord"></a>
##### `ConjugacyClasses(S): AlgAssVOrd -> SeqEnum`

Given an order $S$ in a quaternion algebra $A$, this function returns representatives for the conjugacy classes of orders in $A$ having the same type as $S$. In particular, if $S$ is an Eichler order of level $N$, then a system of representatives for the conjugacy classes of Eichler orders of level $N$ is $A$ is returned.

If $A$ is definite and the base ring of $S$ is the ring of integers or a number ring, then $S$ can be any order. In all other cases $S$ must be an Eichler order.

For definite algebras, the algorithm involves computing the right ideal classes (in fact, the two problems are computationally equivalent in practice).

<a id="example-ex-092c7e"></a>
##### `Example: Left Ideal Classes of a Maximal Order (ex-092c7e)`

In the following example we construct a maximal order in the quaternion algebra ramified at $37$, and enumerate its left ideal classes.

```magma
> S := QuaternionOrder(37);
> ideals := LeftIdealClasses(S);
> [ Basis(I) : I in ideals ];
[
  [ 1, i, j, k ],
  [ 2, 2*i, 1 + i + j, i + k ],
  [ 2, 2*i, i + j, k ]
]
```

We now compute the right orders of the two nontrivial left ideal classes.

```magma
> _, I, J := Explode(ideals);
> R1 := RightOrder(I);
> R2 := RightOrder(J);
> IsIsomorphic(R1,R2);
true
```

Although the ideals $I$ and $J$ are non-isomorphic left ideals over $S$, they have isomorphic right orders. In the example following the next section we explore this phenomenon further.

<a id="example-ex-81fcc0"></a>
##### `Example: Ideal Classes over a Totally Real Field (ex-81fcc0)`

In this example, we enumerate ideal classes for a definite quaternion algebra (over a totally real field).

```magma
> P<x> := PolynomialRing(Rationals());
> F<b> := NumberField(x^3-3*x-1);
> Z_F := MaximalOrder(F);
> Foo := InfinitePlaces(F);
> pp := Decomposition(Z_F, 17)[1][1];
> A := QuaternionAlgebra(pp, Foo);
> O := MaximalOrder(A);
> time Rideals := RightIdealClasses(O);
Time: 0.870
> #Rideals;
2
```

<a id="example-ex-d6b8cf"></a>
##### `Example: Ideal Classes with a Nontrivial Class Group (ex-d6b8cf)`

In this example the classgroup of the base field is not trivial and there are some ramified prime ideals in the algebra. Hence we expect nontrivial two-sided ideal classes.

```magma
> K:= QuadraticField(401);
> A:= QuaternionAlgebra< K | -1, -1>;
> RamifiedPlaces(A);
[
    Prime Ideal
    Two element generators:
        2
        $.2 + 1,
    Prime Ideal
    Two element generators:
        2
        $.2 + 2
]
[ 1st place at infinity, 2nd place at infinity ]
> M:= MaximalOrder(A);
> #TwoSidedIdealClasses(M);
10
> time #RightIdealClasses(M);
140
Time: 6.470
```

#### Operations on Ideals

In addition to operations on ideals of orders over more general rings (see Section [Orders](https://docs.magma-maths.org/Algebras/AssociativeAlgebras/alg_ass_ord.md#secalgassvord)), the following operations are defined for ideals of quaternion orders over $\Z$, $\F_q[X]$, and number rings.

<a id="operation-op-times-algassvordidl-algassvordidl"></a>
##### `I * J: AlgAssVOrdIdl, AlgAssVOrdIdl -> AlgAssVOrdIdl`

The composite of $I$ and $J$, where the right order of $I$ equals the left order of $J$.

<a id="operation-op-meet-algquatordidl-algquatordidl"></a>
##### `I meet J: AlgQuatOrdIdl, AlgQuatOrdIdl -> AlgQuatOrdIdl`

Given ideals or orders $I$ and $J$, this function returns the intersection $I \cap J$.

<a id="function-conjugate-algquatordidl"></a>
##### `Conjugate(I): AlgQuatOrdIdl -> AlgQuatOrdIdl`

<a id="function-conjugate-algassvordidl"></a>
##### `Conjugate(I): AlgAssVOrdIdl -> AlgAssVOrdIdl`

Given an ideal $I$ (of a quaternion algebra), this function returns the conjugate ideal.

<a id="function-norm-algquatordidl"></a>
##### `Norm(I): AlgQuatOrdIdl -> RngElt`

<a id="function-norm-algassvordidl"></a>
##### `Norm(I): AlgAssVOrdIdl -> RngOrdFracIdl`

Given an ideal $I$ over ${\mathbb{Z}}$, this function returns the reduced norm of the ideal, defined as the positive generator of the image of the reduced norm map in ${\mathbb{Q}}$.

Given an ideal $I$ over ${\mathbb{F}}_q[X]$, this function returns the reduced norm of the ideal, defined as the normalized generator of the image of the reduced norm map in ${\mathbb{F}}_q(X)$.

Given an ideal $I$ over a commutative order, this function returns the reduced norm of $I$ as a fractional ideal of the order.

<a id="function-factorization-algquatordidl"></a>
##### `Factorization(I): AlgQuatOrdIdl -> SeqEnum`

<a id="function-factorization-algassvordidl"></a>
##### `Factorization(I): AlgAssVOrdIdl -> SeqEnum`

Given a two-sided ideal $I$ of an hereditary order $O$, this function returns the unique factorization of I into two-sided $O$-ideals. The result is a sequence of tuples. The first entry of each tuple is a two-sided ideal of $O$, the second is its exponent. (If the base ring of $I$ is ${\mathbb{F}}_q[X]$, then $q$ is currently required to be odd.)

### Norm Spaces and Basis Reduction

For definite quaternion orders or ideals one can compute reduced bases and Gram matrices.

If the base ring of the order or ideal is ${\mathbb{Z}}$ or ${\mathbb{F}}_q[X]$ with $q$ odd, the Gram matrices can be made unique up to isomorphism. In fact, in these cases, the isomorphism testing of ideals and orders is based on this reduction.

<a id="function-normspace-algquat"></a>
#### `NormSpace(A): AlgQuat -> ModTupFld, Map`

Given a quaternion algebra $A$ over any field $F$ not of characteristic $2$, this function returns the underlying $F$-space with inner product the norm form. A map from $A$ into the structure is returned as second value.

<a id="function-normspace-algquatord"></a>
#### `NormSpace(S): AlgQuatOrd -> ModTupRng, Map`

<a id="function-normmodule-algquatord"></a>
#### `NormModule(S): AlgQuatOrd -> ModTupRng, Map`

Given a quaternion order $S$ over ${\mathbb{Z}}$ or ${\mathbb{F}}_q[X]$ (with $q$ odd), this function returns the underlying module over its base ring, with inner product respect to the norm. A map from $O$ into the structure is returned as second value.

<a id="function-grammatrix-algquatord"></a>
#### `GramMatrix(S): AlgQuatOrd -> AlgMatElt`

<a id="function-grammatrix-algquatordidl"></a>
#### `GramMatrix(I): AlgQuatOrdIdl -> AlgMatElt`

The Gram matrix of the quaternion order $S$ or ideal $I$ over ${\mathbb{Z}}$ or ${\mathbb{F}}_q[X]$ with respect to the norm on the basis for $S$.

<a id="function-reducedgrammatrix-algquatord-rngint"></a>
#### `ReducedGramMatrix(S): AlgQuatOrd[RngInt] -> AlgMatElt`

<a id="function-reducedgrammatrix-algquatordidl-rngint"></a>
#### `ReducedGramMatrix(S): AlgQuatOrdIdl[RngInt] -> AlgMatElt`

Given an order or ideal $S$ over ${\mathbb{Z}}$ in a definite quaternion algebra, this function returns the Gram matrix $G$ of the corresponding lattice.

The quaternion ideal machinery makes use of a Minkowski basis reduction algorithm which returns a unique normalized reduced Gram matrix $G$ for any definite quaternion ideal. This forms the core of the isomorphism testing for quaternion ideals.

<a id="function-reducedbasis-algquatord-rngint"></a>
#### `ReducedBasis(S): AlgQuatOrd[RngInt] -> SeqEnum`

<a id="function-reducedbasis-algquatordidl-rngint"></a>
#### `ReducedBasis(S): AlgQuatOrdIdl[RngInt] -> SeqEnum`

Given an order or ideal $S$ over ${\mathbb{Z}}$ in a definite quaternion algebra, this function returns some basis $B$ of $S$ the Gram matrix $G$ of the corresponding lattice associated with $S$. Note that while there exists a unique Minkowski-reduced Gram matrix $G$, the basis $B$ is not unique.

<a id="example-ex-dbe93f"></a>
#### `Example: Minkowski Reduction of Quaternion Ideals (ex-dbe93f)`

Recall that Minkowski basis reduction is used which returns a unique normalized reduced Gram matrix $G$ for any definite quaternion ideal. This forms the core of the isomorphism testing for quaternion ideals. We illustrate this by applying it to representatives of the set of left ideal classes of an order.

```magma
> A := QuaternionOrder(19,2);
> ideals := LeftIdealClasses(A);
> #ideals;
5
> [ (1/Norm(I))*ReducedGramMatrix(I) : I in ideals ];
[
    [ 2  0  1  1]
    [ 0  2  1  1]
    [ 1  1 20  1]
    [ 1  1  1 20],

    [6 0 1 3]
    [0 6 3 1]
    [1 3 8 1]
    [3 1 1 8],

    [6 0 1 3]
    [0 6 3 1]
    [1 3 8 1]
    [3 1 1 8],

    [ 4  0  1 -1]
    [ 0  4  1  1]
    [ 1  1 10  0]
    [-1  1  0 10],

    [ 4  0  1 -1]
    [ 0  4  1  1]
    [ 1  1 10  0]
    [-1  1  0 10]
]
```

<a id="function-reducedgrammatrix-algquatord-rngupol"></a>
#### `ReducedGramMatrix(S): AlgQuatOrd[RngUPol] -> AlgMatElt, SeqEnum`

<a id="function-reducedgrammatrix-algquatordidl-rngupol"></a>
#### `ReducedGramMatrix(S): AlgQuatOrdIdl[RngUPol] -> AlgMatElt, SeqEnum`

<a id="function-reducedbasis-algquatord-rngupol"></a>
#### `ReducedBasis(S): AlgQuatOrd[RngUPol] -> SeqEnum`

<a id="function-reducedbasis-algquatordidl-rngupol"></a>
#### `ReducedBasis(S): AlgQuatOrdIdl[RngUPol] -> SeqEnum`

```magma
Canonical: BoolElt                    Default: false
```

Given an order or ideal $S$ over ${\mathbb{F}}_q[X]$ in a quaternion algebra $A$, this function returns a Gram matrix and/or a basis of $S$ whose Gram matrix is in dominant diagonal form (see the function `DominantDiagonalForm` in Section [Automorphism Group and Isometry Testing over ${\mathbb{F}}_q[t]$](https://docs.magma-maths.org/LatticesQuadraticForms/LatticesWithGroupAction/auto-isom.md#auto-isom-fqt)). The Gram matrix will not be unique unless $A$ is definite and `Canonical` is set to `true`.

<a id="function-reducedbasis-algassvord-rngord"></a>
#### `ReducedBasis(O): AlgAssVOrd[RngOrd] -> [AlgAssVElt]`

<a id="function-reducedbasis-algassvordidl-rngord"></a>
#### `ReducedBasis(I): AlgAssVOrdIdl[RngOrd] -> [AlgAssVOrdElt]`

Returns a “reduced” basis for the order $O$ or the ideal $I$ over some number ring. If $O$ or $I$ arise from a definite quaternion algebra, then this basis is LLL-reduced with respect to the norm form; otherwise, the basis is reduced with respect to a Minkowski-like embedding (see [[KV10](https://docs.magma-maths.org/references.md#cite-kirschmer-voight), Section 4]).

<a id="function-optimizedrepresentation-algassvord"></a>
#### `OptimizedRepresentation(O): AlgAssVOrd -> AlgQuat, Map`

<a id="function-optimisedrepresentation-algassvord"></a>
#### `OptimisedRepresentation(O): AlgAssVOrd -> AlgQuat, Map`

Given an order $O$ contained in a quaternion algebra $A$ over ${\mathbb{Q}}$ or a number field $F$, this function returns a new quaternion algebra $A'$ such that $A' = ((a, b)/F)$ where $a$ and $b$ are small (with respect to $O$), and, as second return value, an isomorphism $A \to A'$.

<a id="function-optimizedrepresentation-algquat"></a>
#### `OptimizedRepresentation(A): AlgQuat -> AlgQuat, Map`

<a id="function-optimisedrepresentation-algquat"></a>
#### `OptimisedRepresentation(A): AlgQuat -> AlgQuat, Map`

Given a quaternion algebra $A$ over ${\mathbb{Q}}$ or a number field $F$, this function returns a new quaternion algebra $A'$ such that $A' = ((a, b)/F)$ where $a$ and $b$ are small. An isomorphism $A \to A'$ is returned as second value.

<a id="function-enumerate-algquatord-rngint-rngintelt-rngintelt"></a>
#### `Enumerate(O, A, B): AlgQuatOrd[RngInt], RngIntElt, RngIntElt -> [AlgQuatOrdElt]`

<a id="function-enumerate-algquatord-rngint-rngintelt"></a>
#### `Enumerate(O, B): AlgQuatOrd[RngInt], RngIntElt -> [AlgQuatOrdElt]`

<a id="function-enumerate-algquatordidl-rngint-rngelt-rngelt"></a>
#### `Enumerate(O, A, B): AlgQuatOrdIdl[RngInt], RngElt, RngElt -> [AlgQuatElt]`

<a id="function-enumerate-algquatord-rngint-rngelt"></a>
#### `Enumerate(O, B): AlgQuatOrd[RngInt], RngElt -> [AlgQuatElt]`

The sequence of all elements $x$ (up to sign) in the definite quaternion order $O$ or ideal $I$ over ${\mathbb{Z}}$ such that the reduced norm of $x$ lies in the interval $[A, \ldots B]$ or $[0, \ldots B]$, respectively.

<a id="function-enumerate-algassvord-rngord-rngelt-rngelt"></a>
#### `Enumerate(O, A, B): AlgAssVOrd[RngOrd], RngElt, RngElt -> [AlgAssVOrdElt]`

<a id="function-enumerate-algassvord-rngord-rngelt"></a>
#### `Enumerate(O, B): AlgAssVOrd[RngOrd], RngElt -> [AlgAssVOrdElt]`

<a id="function-enumerate-algassvord-rngord-rngelt-2"></a>
#### `Enumerate(O, B): AlgAssVOrd[RngOrd], [RngElt] -> [AlgAssVOrdElt]`

<a id="function-enumerate-algassvordidl-rngord-rngelt"></a>
#### `Enumerate(I, B): AlgAssVOrdIdl[RngOrd], [RngElt] -> [AlgAssVOrdElt]`

The sequence of elements $x$ (up to sign) in the definite quaternion order $O$ or ideal $I$ over a number ring such that the absolute trace of the norm of $x$ lies in the interval $[A, \ldots B]$ or $[0, \ldots B]$, respectively.

### Isomorphisms

#### Isomorphisms of Algebras

Two quaternion algebras $A, B$ over a common field $F$ are isomorphic algebras if and only if they share the same ramified places. Finding an explicit isomorphism is much harder. Currently Magma embeds the first standard generator of $A$ into $B$ and then finds another element perpendicular to that image having the correct minimal polynomial. In particular, this requires the construction of two points on a conic (or equivalently, the solution of two norm equations) over quadratic extensions of $F$.

<a id="function-isisomorphic-algquat-algquat"></a>
##### `IsIsomorphic(A, B): AlgQuat, AlgQuat -> BoolElt, Map`

```magma
Isomorphism: BoolElt                    Default: false
```

Given two quaternion algebras $A,B$ over $\Q$, $\F_q(X)$ with $q$ odd, or a number field, this function returns `true` if and only if they are isomorphic.

If the algebras are isomorphic and `Isomorphism` is set to true, an isomorphism $A \to B$ is also returned.

#### Isomorphisms of Orders

Two orders $S, T$ in a quaternion algebra $A$ are isomorphic if and only if they are conjugate in $A$.

In a definite algebra, we use the fact that this conjugation induces an isometry of the quadratic ${\mathbb{Z}}$- or ${\mathbb{F}}_q[X]$-modules $S$ and $T$ equipped with the (absolute) norm form. Over an indefinite algebra, we use the fact that any connecting ideal $I$ having left order $S$ and right order $T$ must be isomorphic to a right ideal of $T$. See [[KV10](https://docs.magma-maths.org/references.md#cite-kirschmer-voight)] for details.

<a id="function-isisomorphic-algquatord-algquatord"></a>
##### `IsIsomorphic(S, T): AlgQuatOrd, AlgQuatOrd -> BoolElt, Map, AlgQuatElt`

<a id="function-isisomorphic-algassvord-rngord-algassvord-rngord"></a>
##### `IsIsomorphic(S, T): AlgAssVOrd[RngOrd], AlgAssVOrd[RngOrd] -> BoolElt, Map, AlgQuatElt`

<a id="function-isconjugate-algassvord-algassvord"></a>
##### `IsConjugate(S, T): AlgAssVOrd, AlgAssVOrd -> BoolElt, Map, AlgQuatElt`

```magma
FindElement    : BoolElt                          Default: false
ConnectingIdeal: AlgAssVOrdIdl                    Default: 
```

Given orders $S$ and $T$ in a quaternion algebra $A$ over ${\mathbb{Q}}$, ${\mathbb{F}}_q(X)$ (with $q$ odd) or a number field, this function returns `true` if and only if $S$ and $T$ are isomorphic.

For indefinite algebras, the orders are currently required to be maximal.

If `FindElement` is set, the second return value is an isomorphism from $S$ to $T$ and the third return value is an element $a$ with $T = a^{-1} S a$, inducing the isomorphism. For indefinite algebras, this search is expensive and may sometimes fail (as in `IsIsomorphic` for ideals, see below).

For indefinite algebras defined over number fields, part of the computation may be faster when a connecting ideal is specified using the parameter `ConnectingIdeal`; this should be an ideal with left order $S$ and right order $T$.

<a id="function-isomorphism-algquatord-algquatord"></a>
##### `Isomorphism(S, T): AlgQuatOrd, AlgQuatOrd -> Map`

Given two isomorphic definite quaternion orders $S, T$ over ${\mathbb{Z}}$ or ${\mathbb{F}}_q[X]$ (with $q$ odd), this function returns an algebra isomorphism. For orders over number rings the intrinsic `IsIsomorphic` should be used with the optional argument `FindElement` set.

<a id="isomorphisms-ideals"></a>
<a id="algquatisoideals"></a>
#### Isomorphisms of Ideals

Two right (left) ideals $I, J$ of an order $O$ in a quaternion algebra $A$ are isomorphic $O$-modules if and only if $xI=J$ ($Ix=J$) for some $x \in A^*$.

To decide whether $I$ and $J$ are isomorphic, we test whether the *colon ideal* $(J:I) = \{x \in A: xI \subset J\}$ (similarly defined if $I, J$ are left ideals) is principal, or not.

Over ${\mathbb{Z}}$, to accomplish this task we compute a Minkowski-reduced Gram matrix of $(J:I)$ which produces an element of smallest norm. Over ${\mathbb{F}}_q[X]$ we compute a Gram matrix which has dominant diagonal form (see [[Ger03](https://docs.magma-maths.org/references.md#cite-forms-fqx)]) which also produces a suitable element. Over other number rings $R$, we search $(J:I)$ for an element of the required norm by computing a reduced basis. This method runs very quickly for “reasonably small” input. (See [[DD08](https://docs.magma-maths.org/references.md#cite-dembele-donnelly), [KV10](https://docs.magma-maths.org/references.md#cite-kirschmer-voight)] for further details.)

<a id="function-isisomorphic-algassvordidl-algassvordidl"></a>
##### `IsIsomorphic(I, J): AlgAssVOrdIdl, AlgAssVOrdIdl -> BoolElt, AlgAssVElt`

Given ideals $I$ and $J$ of the same order $O$ in a quaternion algebra $A$ over ${\mathbb{Q}}$, ${\mathbb{F}}_q(X)$ (with $q$ odd) or a number field, this function returns `true` if and only if the quaternion ideals $I$ and $J$ are isomorphic (left or right) $O$-ideals. If $I$ and $J$ are isomorphic, there exists some $x\in A$ such that $xI=J$ (in the case of right $O$-ideals) or $Ix=J$ (for left ideals). For definite algebras, such an element $x$ is always returned. For indefinite algebras over ${\mathbb{Z}}$ or a number ring, a search for such an element is made, and if one is found then it is returned.

<a id="function-isprincipal-algassvordidl"></a>
##### `IsPrincipal(I): AlgAssVOrdIdl -> BoolElt, AlgQuatElt`

Given a left (or right) ideal $I$ over ${\mathbb{Z}}, {\mathbb{F}}_q[X]$ or a number ring, this function returns `true` if and only if $I$ is a principal ideal; if so, a generator is returned as the second value.

<a id="function-isleftisomorphic-algquatordidl-algquatordidl"></a>
##### `IsLeftIsomorphic(I, J): AlgQuatOrdIdl, AlgQuatOrdIdl -> BoolElt, Map, AlgQuatElt`

<a id="function-isrightisomorphic-algquatordidl-algquatordidl"></a>
##### `IsRightIsomorphic(I, J): AlgQuatOrdIdl, AlgQuatOrdIdl -> BoolElt, Map, AlgQuatElt`

Given two definite ideals over ${\mathbb{Z}}$ or ${\mathbb{F}}_q[X]$ (with $q$ odd) with the same left (or right) order $S$, this function returns `true` if and only if they are isomorphic as $S$-modules. The isomorphism and the transforming scalar in the quaternion algebra are returned as second and third values if `true`.

<a id="function-isleftisomorphic-algassvordidl-rngord-algassvordidl-rngord"></a>
##### `IsLeftIsomorphic(I, J): AlgAssVOrdIdl[RngOrd], AlgAssVOrdIdl[RngOrd] -> BoolElt, AlgQuatElt`

<a id="function-isrightisomorphic-algassvordidl-rngord-algassvordidl-rngord"></a>
##### `IsRightIsomorphic(I, J): AlgAssVOrdIdl[RngOrd], AlgAssVOrdIdl[RngOrd] -> BoolElt, AlgQuatElt`

Given two left (or right) ideals $I$ and $J$ over a number ring, with the same left order $O$, this function returns `true` if and only if they are isomorphic as $O$-modules. The isomorphism is given by multiplication as a second return value.

<a id="function-leftisomorphism-algquatordidl-algquatordidl"></a>
##### `LeftIsomorphism(I, J): AlgQuatOrdIdl, AlgQuatOrdIdl -> Map, AlgQuatElt`

Given two isomorphic left ideals over a definite order $S$ over ${\mathbb{Z}}$ or ${\mathbb{F}}_q[X]$, this function returns the $S$-module isomorphism between them, followed by the quaternion algebra element which defines the isomorphism by right-multiplication.

<a id="function-rightisomorphism-algquatordidl-algquatordidl"></a>
##### `RightIsomorphism(I, J): AlgQuatOrdIdl, AlgQuatOrdIdl -> Map, AlgQuatElt`

Given two isomorphic right ideals over a definite order $S$ over ${\mathbb{Z}}$ or ${\mathbb{F}}_q[X]$, this function returns the $S$-module isomorphism between them, followed by the quaternion algebra element which defines the isomorphism by left-multiplication.

#### Examples

<a id="example-ex-f5c0d5"></a>
##### `Example: Isomorphism of Quaternion Algebras (ex-f5c0d5)`

In this example, we create two quaternion algebras over $\F_7$, show that they are isomorphic, and find an isomorphism between them.

```magma
> F<x> := RationalFunctionField( GF(7) );
> Q1 := QuaternionAlgebra< F | (x^2+x-1)*(x+1), x >;
> a := x^3 + x^2 + 3;
> b := x^13 + 4*x^11 + 2*x^10 + x^9 + 6*x^8 + 4*x^5 + 3*x^4 + x;
> Q2:= QuaternionAlgebra< F | a, b >;
> ok, phi:= IsIsomorphic(Q1, Q2 : Isomorphism);
> ok;
true
> forall{ <x,y> : x,y in Basis(Q1) |  phi(x*y) eq phi(x)*phi(y) };
true
```

<a id="example-ex-50db58"></a>
##### `Example: Isomorphic Right Orders of Ideals (ex-50db58)`

In this example, we create two ideals, show that they have isomorphic right orders, and then explicitly exhibit the isomorphism.

```magma
> A := QuaternionAlgebra(37);
> S := MaximalOrder(A);
> ideals := LeftIdealClasses(S);
> _, I, J := Explode(ideals);
> R := RightOrder(I);
> Q := RightOrder(J);
> IsIsomorphic(R,Q);
true
```

Now we find an element $pi$ which conjugates R to Q, and then check that it has this property.

```magma
> _, pi := Isomorphism(R,Q);
> J := lideal< S | [ x*pi : x in Basis(J) ] >;
> RightOrder(J) eq R;
true
```

<a id="example-ex-03d026"></a>
##### `Example: Isomorphisms of Right Ideals (ex-03d026)`

We construct two non-isomorphic left ideals with the same left and right orders, then investigate their isomorphisms as right ideals.

```magma
> S := QuaternionOrder(37);
> ideals := LeftIdealClasses(S);
> _, I, J := Explode(ideals);
> R := RightOrder(I);
> _, pi := Isomorphism(R,RightOrder(J));
> J := lideal< S | [ x*pi : x in Basis(J) ] >;
> IsLeftIsomorphic(I,J);
false
> IsRightIsomorphic(I,J);
true Mapping from: AlgQuatOrd: I to AlgQuatOrd: J given by a rule [no inverse]
1 + i - 2*k
> h, x := RightIsomorphism(I,J);
> y := [1,2,-1,3];
> y := &+[y[i]*b[i] : i in [1 .. 4]] where b is Basis(I);
> h(y);
[-73  15  31   4]
> x*y;
-73 + 15*i + 31*j + 4*k
```

The existence of an isomorphism as a right ideal is due to the fact that the two-sided ideals of $R$ do not have non-isomorphic counterparts in S.

```magma
> TwoSidedIdealClasses(R);
[ Ideal with basis Pseudo-matrix over Integer Ring
1 * [1 0 0 0]
[0 1 0 0]
[0 0 1 0]
[0 0 0 1]
, Ideal with basis Pseudo-matrix over Integer Ring
1 * [37  0 32 18]
[ 0 37 10  2]
[ 0  0  1  0]
[ 0  0  0  1]
 ]
> TwoSidedIdealClasses(S);
[ Ideal with basis Pseudo-matrix over Integer Ring
1 * [1 0 0 0]
[0 1 0 0]
[0 0 1 0]
[0 0 0 1]
 ]
```

Thus while `Conjugate(I)*J` is in the non-principal $R$-ideal class, the ideal `I*Conjugate(J)` represents the unique principal ideal class of $S$.

<a id="example-ex-0c04cb"></a>
##### `Example: Ideal Isomorphisms over a Number Ring (ex-0c04cb)`

We exhibit isomorphism testing for ideals of orders over number rings.

```magma
> P<x> := PolynomialRing(Rationals());
> F<b> := NumberField(x^3-3*x-1);
> Z_F := MaximalOrder(F);
> F := FieldOfFractions(Z_F);
> A<alpha,beta,alphabeta> := QuaternionAlgebra<F | -3, b>;
> O := Order([alpha,beta,alphabeta]);
> O;
Order of Quaternion Algebra with base ring F
with coefficient ring Maximal Equation Order with defining polynomial x^3 - 3*x
    - 1 over its ground order
> I := ideal<O | 2>;
> I eq (I + ideal<O | 2>);
true
> I eq (I + ideal<O | 3>);
false
>
> Foo := InfinitePlaces(F);
> A := QuaternionAlgebra(ideal<Z_F | 2*3*5>, Foo);
> IsDefinite(A);
true
> O := MaximalOrder(A);
> I := rideal<O | Norm(O.2), O.2>;
> J := rideal<O | Norm(O.3), O.3>;
> IsIsomorphic(I, J);
true (F.2 + F.3) + (27/9190*F.1 - 143/9190*F.2 - 73/9190*F.3)*i +
(-251/27570*F.1 + 7/2757*F.2 + 10/2757*F.3)*k
```

### Units and Unit Groups

Let $S$ be a definite quaternion order over ${\mathbb{Z}}$, ${\mathbb{F}}_q[X]$ with $q$ odd, or a number ring. In the first two cases, the unit group of $S$ is finite and can be read off any reduced Gram matrix of $S$. If the base ring of $S$ is some number ring $R$, then an explicit description of the finite quotient $S^*/R^*$ is given in [[Vig76](https://docs.magma-maths.org/references.md#cite-vigneras76)].

<a id="function-normonegroup-algassvord"></a>
#### `NormOneGroup(S): AlgAssVOrd -> GrpPerm, Map`

<a id="function-normonegroup-algquatord"></a>
#### `NormOneGroup(S): AlgQuatOrd -> GrpAb, Map`

```magma
ModScalars: BoolElt                    Default: false
```

Returns a group $G$ isomorphic to the group $S_1$ of elements in $S$ with reduced norm $1$ (unless `ModScalars` is set, in which case $G$ is isomorphic to $S_1$ modulo $\{\pm 1\}$).

The second object returned is a map from $G$ to $S$ expressing the isomorphism.

<a id="function-units-algquatord"></a>
#### `Units(S): AlgQuatOrd -> SeqEnum`

<a id="function-units-algassvord"></a>
#### `Units(S): AlgAssVOrd -> SeqEnum`

This intrinsic computes the set of units $S^*$ for the definite order $S$. When the base ring of $S$ is $Z$ or ${\mathbb{F}}_q[X]$, the returned sequence contains all units of $S$; when the base field is a number field, the returned sequence contains representatives modulo the unit group of the base ring (since the unit group is infinite in general).

<a id="function-multiplicativegroup-algquatord-rngint"></a>
#### `MultiplicativeGroup(S): AlgQuatOrd[RngInt] -> GrpPerm, Map`

<a id="function-unitgroup-algquatord-rngint"></a>
#### `UnitGroup(S): AlgQuatOrd[RngInt] -> GrpPerm, Map`

<a id="function-multiplicativegroup-algquatord-rngupol"></a>
#### `MultiplicativeGroup(S): AlgQuatOrd[RngUPol] -> GrpAb, Map`

<a id="function-unitgroup-algquatord-rngupol"></a>
#### `UnitGroup(S): AlgQuatOrd[RngUPol] -> GrpAb, Map`

<a id="function-multiplicativegroup-algassvord-rngord"></a>
#### `MultiplicativeGroup(S): AlgAssVOrd[RngOrd] -> GrpPerm, Map`

<a id="function-unitgroup-algassvord-rngord"></a>
#### `UnitGroup(S): AlgAssVOrd[RngOrd] -> GrpPerm, Map`

This intrinsic computes the unit group $S^*$ of the definite quaternion order $S$. The function returns an abstract group $G$, and a map from $G$ to $S$. When the base ring of $S$ is $Z$ or ${\mathbb{F}}_q[X]$, $G$ represents the full group of units of $S$; when the base field is a number field, $G$ represents the unit group of $S$ modulo the unit group of the base ring (since the unit group is infinite in general).

<a id="example-ex-410b55"></a>
#### `Example: Unit Groups over the Rationals (ex-410b55)`

The following example illustrates the unit group computation for an order in a definite quaternion algebra over ${\mathbb{Q}}$.

```magma
> A := QuaternionAlgebra< RationalField() | -1, -1 >;
> S1 := MaximalOrder(A);
> S2 := QuaternionOrder(A,2);
> G1, h1 := UnitGroup(S1);
> #G1;
24
> [ A | h1(g) : g in G1 ];
[ 1, -1, -j, -k, i, -1/2 + 1/2*i - 1/2*j - 1/2*k, 1/2 + 1/2*i - 1/2*j + 1/2*k,
-1/2 - 1/2*i - 1/2*j + 1/2*k, -1/2 + 1/2*i + 1/2*j + 1/2*k, 1/2 - 1/2*i - 1/2*j
- 1/2*k, 1/2 + 1/2*i + 1/2*j - 1/2*k, 1/2 - 1/2*i + 1/2*j + 1/2*k, -1/2 - 1/2*i
+ 1/2*j - 1/2*k, 1/2 - 1/2*i + 1/2*j - 1/2*k, -1/2 + 1/2*i + 1/2*j - 1/2*k, 1/2
+ 1/2*i - 1/2*j - 1/2*k, -1/2 - 1/2*i - 1/2*j - 1/2*k, 1/2 + 1/2*i + 1/2*j +
1/2*k, -1/2 - 1/2*i + 1/2*j + 1/2*k, -1/2 + 1/2*i - 1/2*j + 1/2*k, 1/2 - 1/2*i -
1/2*j + 1/2*k, k, -i, j ]
> G2, h2 := UnitGroup(S2);
> #G2;
8
> [ A | h2(g) : g in G2 ];
[ 1, -1, -j, j, k, -k, -i, i ]
```

The unit groups of orders in indefinite quaternion algebras $A$ are infinite arithmetic groups, which are twisted analogues of the groups ${\operatorname{SL}}_2({\mathbb{Z}})$ and their families of subgroups. These are studied in relation to their actions on the upper half complex plane, via an embedding in ${\operatorname{GL}}_2({\mathbb{R}})$ provided by some isomorphism $A\otimes{\mathbb{R}}\cong M_2({\mathbb{R}})$.

<a id="example-ex-b816c0"></a>
#### `Example: Unit Groups over a Number Ring (ex-b816c0)`

Now we exhibit unit group computations over a number ring.

```magma
> P<x> := PolynomialRing(Rationals());
> F := NumberField(x^3-3*x-1);
> Z_F := MaximalOrder(F);
> Foo := InfinitePlaces(F);
```

We use `SetSeed` since the following line makes random choices.

```magma
> SetSeed(1);
> A := QuaternionAlgebra(ideal<Z_F | 2>, Foo);
> IsDefinite(A);
true
> O := MaximalOrder(A);
> U, h := UnitGroup(O);
> U;
Permutation group U acting on a set of cardinality 12
Order = 12 = 2^2 * 3
    Id(U)
    (1, 2, 4)(3, 6, 7)(5, 9, 10)(8, 12, 11)
    (1, 3)(2, 5)(4, 8)(6, 11)(7, 9)(10, 12)
> #Units(O);
12
```

<a id="star-algebras"></a>
<a id="chapstaralgebras"></a>
## Algebras with Involution

- [Introduction](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/introduction.md)
- [Algebras with Involution](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/star-algebras.md)
  - [Reflexive Forms](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/star-algebras.md#reflexive-forms)
    - [`IsometryGroup(F : parameters): AlgMatElt → GrpMat`](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/star-algebras.md#function-isometrygroup-algmatelt)
    - [`SimilarityGroup(F : parameters): AlgMatElt → GrpMat`](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/star-algebras.md#function-similaritygroup-algmatelt)
  - [Systems of Reflexive Forms](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/star-algebras.md#systems-of-reflexive-forms)
    - [`PGroupToForms(G): GrpPC → SeqEnum`](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/star-algebras.md#function-pgrouptoforms-grppc)
    - [`PGroupToForms(G,p): GrpPC, RngIntElt → SeqEnum`](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/star-algebras.md#function-pgrouptoforms-grppc-rngintelt)
    - [`PGroupToForms(G): GrpMat → SeqEnum`](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/star-algebras.md#function-pgrouptoforms-grpmat)
    - [`PGroupToForms(G,p): GrpMat, RngIntElt → SeqEnum`](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/star-algebras.md#function-pgrouptoforms-grpmat-rngintelt)
    - [Example: Reflexive Forms from a p-Group](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/star-algebras.md#example-ex-32c4d8)
  - [Basic Attributes of $\ast$-Algebras](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/star-algebras.md#basic-attributes-of-ast-algebras)
    - [`IsStarAlgebra(A): AlgMat → BoolElt`](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/star-algebras.md#function-isstaralgebra-algmat)
    - [`IsStarAlgebra(A): AlgGrp → BoolElt`](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/star-algebras.md#function-isstaralgebra-alggrp)
    - [`Star(A): AlgMat → Map`](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/star-algebras.md#function-star-algmat)
    - [`Star(A): AlgGrp → Map`](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/star-algebras.md#function-star-alggrp)
  - [Adjoint Algebras](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/star-algebras.md#adjoint-algebras)
    - [`AdjointAlgebra(S : parameters): SeqEnum → AlgMat`](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/star-algebras.md#function-adjointalgebra-seqenum)
    - [Example: Adjoint Algebra of a Pair of Forms](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/star-algebras.md#example-ex-2cfb50)
  - [Group Algebras](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/star-algebras.md#group-algebras)
    - [`StarOnGroupAlgebra(A): AlgGrp → Map`](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/star-algebras.md#function-starongroupalgebra-alggrp)
    - [`GroupAlgebraAsStarAlgebra(R, G): Rng, Grp → AlgGrp`](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/star-algebras.md#function-groupalgebraasstaralgebra-rng-grp)
    - [Example: Group Algebra as a Star-Algebra](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/star-algebras.md#example-ex-d8cda9)
    - [Example: Attaching an Involution to a Group Algebra](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/star-algebras.md#example-ex-fb1bbd)
  - [Simple $\ast$-Algebras](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/star-algebras.md#simple-ast-algebras)
    - [`SimpleStarAlgebra(name, d, K): MonStgElt, RngIntElt, FldFin → AlgMat`](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/star-algebras.md#function-simplestaralgebra-monstgelt-rngintelt-fldfin)
    - [Example: Simple Star-Algebra of Exchange Type](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/star-algebras.md#example-ex-bf2207)
- [Decompositions of $\ast$-Algebras](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/decompositions.md)
  - [`WedderburnDecomposition(A): AlgMat → AlgMat, AlgMat`](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/decompositions.md#function-wedderburndecomposition-algmat)
  - [`WedderburnDecomposition(A): AlgGrp → AlgGrpSub, AlgGrpSub`](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/decompositions.md#function-wedderburndecomposition-alggrp)
  - [`TaftDecomposition(A): AlgMat → AlgMat, AlgMat`](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/decompositions.md#function-taftdecomposition-algmat)
  - [`TaftDecomposition(A): AlgGrp → AlgGrpSub, AlgGrpSub`](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/decompositions.md#function-taftdecomposition-alggrp)
  - [Example: Taft Decomposition of a Group Algebra](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/decompositions.md#example-ex-d6a904)
- [Recognition of $\ast$-Algebras](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/recognition.md)
  - [Recognition of Simple $\ast$-Algebras](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/recognition.md#recognition-of-simple-ast-algebras)
    - [`RecogniseClassicalSSA(A): AlgMat → BoolElt, AlgMat, Map, Map`](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/recognition.md#function-recogniseclassicalssa-algmat)
    - [`RecogniseExchangeSSA(A): AlgMat → BoolElt, AlgMat, Map, Map`](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/recognition.md#function-recogniseexchangessa-algmat)
    - [Example: Recognising a Simple Star-Algebra](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/recognition.md#example-ex-f5d034)
  - [Recognition of Arbitrary $\ast$-Algebras](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/recognition.md#recognition-of-arbitrary-ast-algebras)
    - [`RecogniseStarAlgebra(A): AlgMat → BoolElt`](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/recognition.md#function-recognisestaralgebra-algmat)
    - [`RecogniseStarAlgebra(A): AlgGrp → BoolElt`](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/recognition.md#function-recognisestaralgebra-alggrp)
    - [`IsSimpleStarAlgebra(A): AlgMat → BoolElt`](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/recognition.md#function-issimplestaralgebra-algmat)
    - [`IsSimpleStarAlgebra(A): AlgGrp → BoolElt`](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/recognition.md#function-issimplestaralgebra-alggrp)
    - [`SimpleParameters(A): AlgMat → SeqEnum`](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/recognition.md#function-simpleparameters-algmat)
    - [`SimpleParameters(A): AlgGrp → SeqEnum`](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/recognition.md#function-simpleparameters-alggrp)
    - [`NormGroup(A): AlgMat → GrpMat`](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/recognition.md#function-normgroup-algmat)
    - [Example: Distinguishing Dihedral and Quaternion Group Algebras](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/recognition.md#example-ex-9f1ea0)
    - [Example: Distinguishing Two p-Groups of Class 2](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/recognition.md#example-ex-31ccc3)
- [Intersections of Classical Groups](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/isometry.md)
  - [`IsometryGroup(S : parameters): SeqEnum → GrpMat`](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/isometry.md#function-isometrygroup-seqenum)
  - [Example: Isometry Group of Forms from a p-Group](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/isometry.md#example-ex-575942)
  - [`ClassicalIntersection(S): SeqEnum → GrpMat`](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/isometry.md#function-classicalintersection-seqenum)
  - [Example: Intersecting Two Classical Groups](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/isometry.md#example-ex-95a8b7)
- [Bibliography](https://docs.magma-maths.org/Algebras/AlgebrasWithInvolution/bibliography.md)

### Introduction

In this chapter we describe techniques for computing with $*$*-algebras*, namely algebras equipped with an anti-automorphism $x\mapsto x^*$ of order at most 2 (an *involution* or *star*). For further information on involutions and the structure of $*$-algebras see [[Alb61](https://docs.magma-maths.org/references.md#cite-albert)] and [[KMRT98](https://docs.magma-maths.org/references.md#cite-involutions)].

The principal application of these techniques is currently to isometry groups of systems of reflexive forms (and the intimately related study of intersections of classical groups). However, it is also possible to use the techniques to compute with group algebras of moderate dimension.

To any set of reflexive forms defined on a common vector space (a *system of forms*) one may associate a matrix $*$-algebra called the *adjoint algebra* of the system. The group of units of this adjoint algebra contains a natural subgroup of *unitary elements*, namely those elements $x$ satisfying the condition $x^*=x^{-1}$. The group of unitary elements coincides with the group of isometries of the system of forms, which is also the intersection of the general classical groups associated with these forms.

The StarAlgebras package provides functions that enable the user to investigate the structure of $*$-algebras. It also provides functions to compute and determine the structure of the group of isometries of a system of reflexive forms, and to compute intersections of arbitrary collections of classical groups defined on a common vector space.

The algorithms are mainly due to Peter Brooksbank and James Wilson [[BW12a](https://docs.magma-maths.org/references.md#cite-brooksbankwilson1), [BW12c](https://docs.magma-maths.org/references.md#cite-brooksbankwilson2)].

### Algebras with Involution

This section introduces two general constructions for $*$-algebras:

**(i)**
The algebra of adjoints of a system of reflexive (alternating, reflexive, or Hermitian) forms $[\phi_1,\ldots,\phi_e]$ defined on a common vector space $V$.

**(ii)**
The group algebra $K[G]$, where $K$ is any ring and $G$ is a finite group.

We also provide a constructor function for simple $*$-algebras.

#### Reflexive Forms

A *reflexive form* on a $K$-vector space $V$ is a bilinear function $\phi\colon V\times V\to K$ such that, whenever $\phi(u,v)=0$ for $u,v\in V$, we also have $\phi(v,u)=0$. Reflexive forms $\phi$ and $\psi$ on $V$ are *isometric* if $\phi(u,v)=\psi(u,v)$ for all $u,v\in V$; they are *similar* if there exists $a\in K$ such that $\phi$ and $a\psi$ are isometric. The *radical* of a reflexive form $\phi$ is the subspace ${\rm rad}\phi=\{u\in V\colon\phi(u,V)=0\}$, and $\phi$ is *nondegenerate* if ${\rm rad}\phi=0$.

A fundamental result of Birkhoff and von Neumann states that there are three similarity classes of reflexive forms: *alternating*, *symmetric*, and *Hermitian*. Each such form $\phi$ is represented by a matrix and an automorphism of $K$. Specifically, regarding $V$ as the space of row vectors, we specify $F$ and $\alpha$ such that $\phi(u,v)=u^{\alpha}Fv^{{\rm tr}}$, where $\alpha$ is the identity if $\phi$ is bilinear, or the automorphism $x\mapsto \overline{x}$ of order 2 if $\phi$ is Hermitian. Thus a matrix $g\in {\rm GL}(d,K)$ is an *isometry* (respectively *similarity*) of the reflexive form if $g^{\alpha}Fg^{{\rm tr}}=F$ (respectively $g^{\alpha}Fg^{{\rm tr}}=aF$).

<a id="function-isometrygroup-algmatelt"></a>
##### `IsometryGroup(F : parameters): AlgMatElt -> GrpMat`

```magma
Auto: RngIntElt                    Default: 0
```

The group of isometries of the (possibly degenerate) reflexive form represented by the matrix $F$ with entries in a finite field ${\bf F}_{p^e}$. The field automorphism associated with $F$ is specified by the parameter `Auto`, which represents the exponent $f$ in the map $x\mapsto x^{p^f}$. The default is that $F$ is bilinear on its base ring.

<a id="function-similaritygroup-algmatelt"></a>
##### `SimilarityGroup(F : parameters): AlgMatElt -> GrpMat`

```magma
Auto: RngIntElt                    Default: 0
```

The group of similarities of the (possibly degenerate) reflexive form represented by the matrix $F$ with entries in a finite field ${\bf F}_{p^e}$. The field automorphism associated with $F$ is specified by the parameter `Auto`, which represents the exponent $f$ in the map $x\mapsto x^{p^f}$. The default is that $F$ is bilinear on its base ring.

#### Systems of Reflexive Forms

A *system of forms* is a sequence $[\phi_1,\ldots,\phi_e]$, where each $\phi_i$ is a reflexive form on a common $K$-vector space $V$. The radical of a system of forms is the intersection of the radicals of the individual forms in the system; A system is *nondegenerate* if its radical is zero.

A classical group on a $K$-vector space $V$ preserves a reflexive form on $V$ that is unique up to similarity. Hence systems of forms arise naturally from sets of classical groups having $V$ as their common defining module.

Systems of forms also arise naturally from the study of $p$-groups. Let $G$ be a finite $p$-group. Let $G=\gamma_1(G)>\gamma_2(G)>\ldots >\gamma_m(G)=1$ denote the lower central series of $G$, and let $1=\zeta_1(G)<\zeta_2(G)<\ldots<\zeta_n(G)=G$ denote its upper central series. Let $\Phi(G)$ be the Frattini subgroup of $G$, and put $N:=\langle\Phi(G),\zeta_{n-1}(G)\rangle$. Then $V=G/N$ and $W=\gamma_2(G)/\gamma_3(G)$ are ${\rm GF}(p)$-vector spaces and commutation in $G$ induces a bilinear map $V\times V\to W$. One now obtains a system of forms associated to $G$ by choosing bases for $V$ and $W$.

Just as matrices are useful representations of bilinear forms, so are systems of forms convenient computational models for *bilinear maps*.

<a id="function-pgrouptoforms-grppc"></a>
##### `PGroupToForms(G): GrpPC -> SeqEnum`

<a id="function-pgrouptoforms-grppc-rngintelt"></a>
##### `PGroupToForms(G, p): GrpPC, RngIntElt -> SeqEnum`

Return a system of forms associated to the $p$-group $G$, which must be of type `GrpPC`.

<a id="function-pgrouptoforms-grpmat"></a>
##### `PGroupToForms(G): GrpMat -> SeqEnum`

<a id="function-pgrouptoforms-grpmat-rngintelt"></a>
##### `PGroupToForms(G, p): GrpMat, RngIntElt -> SeqEnum`

Return a system of forms associated to the matrix group $G$, which must be a class 2 $p$-group.

<a id="example-ex-32c4d8"></a>
##### `Example: Reflexive Forms from a p-Group (ex-32c4d8)`

We construct a system of forms associated to a Sylow $7$-subgroup of ${\rm GL}(3,7)$.

```magma
> S := ClassicalSylow(GL (3, 7), 7);
> G := PCGroup(S);
> Forms := PGroupToForms(G);
> Forms;
[
    [0 1]
    [6 0]
]
```

Now we apply the same construction working directly with the matrix group as a $p$-group of class 2.

```magma
> Forms := PGroupToForms(S);
> Forms;
[
    [0 1]
    [6 0]
]
```

It is preferable to input a PC-group if such a representation can readily be obtained. The option to use a matrix group for $p$-groups of class 2 enables the user to construct an associated system of forms in situations where it requires considerably more time to first construct a PC-representation.

#### Basic Attributes of $\ast$-Algebras

Using the following functions one can ascertain whether or not a given algebra has an assigned involution, and also access the map if it has.

<a id="function-isstaralgebra-algmat"></a>
##### `IsStarAlgebra(A): AlgMat -> BoolElt`

<a id="function-isstaralgebra-alggrp"></a>
##### `IsStarAlgebra(A): AlgGrp -> BoolElt`

Return `true` if and only if $A$ has an assigned involution.

<a id="function-star-algmat"></a>
##### `Star(A): AlgMat -> Map`

<a id="function-star-alggrp"></a>
##### `Star(A): AlgGrp -> Map`

Return the involution associated to the $*$-algebra $A$.

#### Adjoint Algebras

Let $S=[\phi_1,\ldots,\phi_e]$ be a system of reflexive forms on a $K$-vector space $V$. Let $R$ denote the algebra ${\rm End}_K(V)$ and $R^{{\rm op}}$ denote its opposite ring. Then the *algebra of adjoints* of $S$ is defined as follows:

$$
{\rm Adj}(S) =
\{(x,y)\in R\times R^{{\rm op}}\colon
\phi_i(ux,v)=\phi_i(u,yv)~\forall
u,v\in V,~\forall i\in\{1,\ldots,e\}\}.
$$

As the $\phi_i$ are reflexive forms, $(x,y)\in {\rm Adj}(S)$ if and only if $(y,x)\in {\rm Adj}(S)$. If $S$ is nondegenerate, then $y$ is uniquely determined by $x$; thus we identify ${\rm Adj}(S)$ with its projection onto $R$ and the assignment $x^*:=y$ equips ${\rm Adj}(S)$ with an involution.

The function to compute ${\rm Adj}(S)$ is an implementation of the algorithms in [[BW12a](https://docs.magma-maths.org/references.md#cite-brooksbankwilson1), Proposition 5.1] and [[BW12c](https://docs.magma-maths.org/references.md#cite-brooksbankwilson2), Section 5].

<a id="function-adjointalgebra-seqenum"></a>
##### `AdjointAlgebra(S : parameters): SeqEnum -> AlgMat`

```magma
Autos: SeqEnum                    Default: [0,..,0]
```

Given a sequence $S$ containing a nondegenerate system of reflexive forms, this function returns the $*$-algebra of adjoints of the forms in $S$. The parameter `Autos` is used to specify a list of Frobenius exponents associated with the given forms. By default all forms are considered to be bilinear over their common base ring, which must be a finite field. Note that the individual forms in the system are allowed to be degenerate.

<a id="example-ex-2cfb50"></a>
##### `Example: Adjoint Algebra of a Pair of Forms (ex-2cfb50)`

We construct the algebra of adjoints of a particular pair of forms on a vector space of dimension 3 over ${\rm GF}(5^2)$. The matrices have entries in ${\rm GF}(5)$ but we regard them as forms over the larger field, and define the first (symmetric) form to be Hermitian over the larger field.

```magma
> MA := MatrixAlgebra(GF (25), 3);
> F := MA![1,2,0,2,3,4,0,4,1];
> G := MA![0,1,0,4,0,0,0,0,0];
> A := AdjointAlgebra([F, G] : Autos := [1, 0]);
> IsStarAlgebra(A);
true
> Degree(A);
6
> BaseRing(A);
Finite field of size 5
```

Observe that the function has converted the given system of forms to a new system over ${\rm GF}(5)$ and returned an algebra of degree 6 over the subfield. Now we access the involution on $A$ and apply it to a generator of $A$.

```magma
> star := Star(A);
> A.3;
[1 0 2 0 2 0]
[0 1 0 2 0 2]
[1 0 4 0 4 0]
[0 1 0 4 0 4]
[0 0 0 0 0 0]
[0 0 0 0 0 0]
> A.3@star;
[4 0 3 0 3 0]
[0 4 0 3 0 3]
[4 0 1 0 1 0]
[0 4 0 1 0 1]
[0 0 0 0 0 0]
[0 0 0 0 0 0]
```

#### Group Algebras

If $G$ is a finite group and $R$ is any ring, then the group algebra $A=R[G]$ possesses a natural involution. Thus each group algebra may be regarded as a $*$-algebra.

<a id="function-starongroupalgebra-alggrp"></a>
##### `StarOnGroupAlgebra(A): AlgGrp -> Map`

The natural involution on the group algebra $A$ induced by inversion on the underlying group. Specifically, if $a=\sum_{g\in G}\alpha_gg\in A$, then $a^*=\sum_{g\in G}\alpha_gg^{-1}$.

<a id="function-groupalgebraasstaralgebra-rng-grp"></a>
##### `GroupAlgebraAsStarAlgebra(R, G): Rng, Grp -> AlgGrp`

Construct the group algebra $R[G]$ equipped with the natural involution afforded by inversion in $G$.

<a id="example-ex-d8cda9"></a>
##### `Example: Group Algebra as a Star-Algebra (ex-d8cda9)`

We construct the group algebra $Z[S_3]$ as a $*$-algebra.

```magma
> G := SymmetricGroup(3);
> K := Integers();
> A := GroupAlgebraAsStarAlgebra(K, G);
> IsStarAlgebra(A);
true
```

Now access the involution on $A$ and apply it to an element of $A$.

```magma
> star := Star(A);
> a := A![0,0,1,0,3,0];
> a;
(1, 3, 2) + 3*(1, 2)
> a@star;
(1, 2, 3) + 3*(1, 2)
```

<a id="example-ex-fb1bbd"></a>
##### `Example: Attaching an Involution to a Group Algebra (ex-fb1bbd)`

Alternatively, $Z[S_3]$ can be constructed using the standard constructor and the involution can be attached later.

```magma
> A := GroupAlgebra(K, G);
> IsStarAlgebra(A);
false
> StarOnGroupAlgebra(A);
Mapping from: AlgGrp: A to AlgGrp: A given by a rule [no inverse]
> IsStarAlgebra(A);
true
```

#### Simple $\ast$-Algebras

The Artinian *simple* $*$*-algebras* – those having no proper $*$-invariant ideals – were classified by Albert [[Alb61](https://docs.magma-maths.org/references.md#cite-albert)]. They come in two basic flavours: *classical* and *exchange*. The classical types are simple as algebras and arise as adjoints of nondegenerate reflexive forms. A simple $*$-algebra of exchange type is a direct sum of two isomorphic simple algebras where the involution interchanges the two factors. Naturally extending the Magma classification of reflexive forms (see the manual entry for the function `ClassicalForms`) a simple $*$-algebra $S$ is assigned a `name` as follows:

- `"symplectic"` if $S$ is defined by an alternating form;
- `"orthogonalcircle"` if $S$ is defined by a symmetric form in odd dimension;
- `"orthogonalplus"` if $S$ is defined by a symmetric form of maximal Witt index;
- `"orthogonalminus"` if $S$ is defined by a symmetric form of non-maximal Witt index;
- `"unitary"` if $S$ is defined by an Hermitian form; and
- `"exchange"` if $S$ has exchange type.

Every simple $*$-algebra is isomorphic to a standard simple $*$-algebra having one of these six names defined naturally on a suitable vector space.

We note that involutions on simple $*$-algebras are often classified as being “of the first kind” or “of the second kind” according to whether or not they induce the identity on the center of the algebra. Thus, involutions of the second kind are unitary and exchange, and the others are all involutions of the first kind [[KMRT98](https://docs.magma-maths.org/references.md#cite-involutions)].

<a id="function-simplestaralgebra-monstgelt-rngintelt-fldfin"></a>
##### `SimpleStarAlgebra(name, d, K): MonStgElt, RngIntElt, FldFin -> AlgMat`

Given a `name`, a positive integer $d$, and a field $K$, this function constructs the standard copy of the simple $*$-algebra of type `name` defined naturally on a $K$-vector space of dimension $d$.

<a id="example-ex-bf2207"></a>
##### `Example: Simple Star-Algebra of Exchange Type (ex-bf2207)`

We construct the standard copy of the simple $*$-algebra of exchange type on the vector space of dimension 4 over ${\rm GF} (16)$.

```magma
> K := GF(16);
> S := SimpleStarAlgebra("exchange", 4, K);
> Dimension(S);
8
> IsStarAlgebra(S);
true;
> w := K.1;
> s := S.1 * S.2 + w * S.1;
> s;
[   K.1      1      0      0]
[     0      0      0      0]
[     0      0      0      0]
[     0      0      0      0]
> star := Star(S);
> s@star;
[     0      0      0      0]
[     0      0      0      0]
[     0      0    K.1      0]
[     0      0      1      0]
```

### Decompositions of $\ast$-Algebras

Every finite-dimensional $K$-algebra $A$ has a decomposition $A=J\oplus W$, where $J$ is the Jacobson radical of $A$ and $W$ is a semisimple subring of $A$. We refer to such decompositions as *Wedderburn decompositions*. The procedure that computes Wedderburn decompositions is adapted from an analogous Magma function written by W. de Graaf for algebras defined by structure constants.

If $A$ is a $*$-algebra and the characteristic of $K$ is not 2, then it follows from a result of Taft [[Taf57](https://docs.magma-maths.org/references.md#cite-taft)] that $A$ has a Wedderburn decomposition of the form $A=J\oplus T$ in which $T$ is invariant under the involution of $A$. We refer to such decompositions as *Taft decompositions*. The procedure that computes Taft decompositions is based on Taft’s original proof, and is described in [[BW12a](https://docs.magma-maths.org/references.md#cite-brooksbankwilson1), Proposition 4.3].

<a id="function-wedderburndecomposition-algmat"></a>
#### `WedderburnDecomposition(A): AlgMat -> AlgMat, AlgMat`

<a id="function-wedderburndecomposition-alggrp"></a>
#### `WedderburnDecomposition(A): AlgGrp -> AlgGrpSub, AlgGrpSub`

A Wedderburn decomposition is constructed for the $*$-algebra $A$. Specifically, the Jacobson radical, $J$, of $A$, and a semisimple complement, $W$, to $J$ in $A$ are computed. Here $A$ may be either a matrix algebra or a group algebra over any field.

<a id="function-taftdecomposition-algmat"></a>
#### `TaftDecomposition(A): AlgMat -> AlgMat, AlgMat`

<a id="function-taftdecomposition-alggrp"></a>
#### `TaftDecomposition(A): AlgGrp -> AlgGrpSub, AlgGrpSub`

A Taft decomposition is constructed for the $*$-algebra $A$. Specifically, the Jacobson radical, $J$, of $A$ and a $*$-invariant Wedderburn complement to $J$ in $A$ are computed. This function requires that the base ring of $A$ has characteristic different from 2. Here $A$ may be either a matrix $*$-algebra or a group algebra.

<a id="example-ex-d6a904"></a>
#### `Example: Taft Decomposition of a Group Algebra (ex-d6a904)`

We compute a Wedderburn decomposition of the group algebra ${\rm GF (5)}[A_5]$ equipped with its natural involution.

```magma
> K := GF(5);
> G := AlternatingGroup(5);
> A := GroupAlgebraAsStarAlgebra(K, G);
> J, W := WedderburnDecomposition(A);
```

We check dimensions and the $*$-invariance of $T$.

```magma
> Dimension(J); Dimension(W);
25
35
> forall { i : i in [1..Ngens (W)] | W.i@Star(A) in W };
false
```

Now find a $*$-invariant decomposition.

```magma
> J, T := TaftDecomposition(A);
> Dimension(J); Dimension(W);
25
35
> forall { i : i in [1..Ngens(T)] | T.i@Star(A) in T };
true
```

### Recognition of $\ast$-Algebras

In this section we describe methods that facilitate structural examinations of $*$-algebras. *All of the functions in this section require that the base ring of the given algebra is a finite field of odd order.* The functions are implementations of the methods described in [[BW12a](https://docs.magma-maths.org/references.md#cite-brooksbankwilson1), Sections 4.2 and 4.3].

#### Recognition of Simple $\ast$-Algebras

If $A$ is a simple $*$-algebra, then we *constructively recognise* $A$ by finding an explicit inverse isomorphisms between $A$ and the standard copy of the simple $*$-algebra which is isomorphic to $A$. The latter is the output of the function `SimpleStarAlgebra` with the appropriate input parameters.

<a id="function-recogniseclassicalssa-algmat"></a>
##### `RecogniseClassicalSSA(A): AlgMat -> BoolElt, AlgMat, Map, Map`

Given a matrix $*$-algebra $A$, this function first decides whether or not $A$ is a simple $*$-algebra of classical type. If it is, the standard $*$-algebra, $T$, corresponding to $A$, a $*$-isomorphism from $A$ to $T$, and its inverse from $T$ to $A$ are returned.

<a id="function-recogniseexchangessa-algmat"></a>
##### `RecogniseExchangeSSA(A): AlgMat -> BoolElt, AlgMat, Map, Map`

Given a matrix $*$-algebra $A$, this function first decides whether or not $A$ is a simple $*$-algebra of exchange type. If it is, the standard $*$-algebra, $T$, corresponding to $A$, a $*$-isomorphism from $A$ to $T$, and its inverse from $T$ to $A$ are returned.

<a id="example-ex-f5d034"></a>
##### `Example: Recognising a Simple Star-Algebra (ex-f5d034)`

We build a particular simple $*$-algebra of symplectic type and recognise it constructively.

```magma
> MA := MatrixAlgebra(GF(7), 4);
> F := MA![0,1,3,4,6,0,0,1,4,0,0,2,3,6,5,0];
> F;
[0 1 3 4]
[6 0 0 1]
[4 0 0 2]
[3 6 5 0]
> A := AdjointAlgebra([F]);
> isit, T, f, g := RecogniseClassicalSSA(A);
> isit;
true;
```

A quick check that $f$ is, as claimed, a $*$-isomorphism.

```magma
> (A.1 + A.2)@f eq (A.1@f) + (A.2@f);
true
> (A.1 * A.2)@f eq (A.1@f) * (A.2@f);
true
> (A.2@Star(A))@f eq (A.2@f)@Star(T);
true
```

#### Recognition of Arbitrary $\ast$-Algebras

If $A$ is an arbitrary $*$-algebra, then we constructively recognise $A$ as follows:

**(i)**
Find a decomposition $A=J\oplus T$, where $J$ is the Jacobson radical of $A$ and $T$ is a $*$-invariant semisimple complement to $J$ in $A$;

**(ii)**
Find a decomposition $T=I_1\oplus\ldots\oplus I_t$ of $T$ into minimal $*$-ideals; and

**(iii)**
For each $j\in\{1,\ldots,t\}$ constructively recognise the simple $*$-algebra $I_j$.

<a id="function-recognisestaralgebra-algmat"></a>
##### `RecogniseStarAlgebra(A): AlgMat -> BoolElt`

<a id="function-recognisestaralgebra-alggrp"></a>
##### `RecogniseStarAlgebra(A): AlgGrp -> BoolElt`

Constructively recognise the $*$-algebra $A$ given as a matrix $*$-algebra or a group algebra.

There are several functions available that permit easy access to structural information about a $*$-algebra that has been constructively recognised. (In fact all of these functions also initiate a constructive recognition of the input $*$-algebra if the recognition has not already been carried out.) For all of the access functions $A$ can be either a matrix $*$-algebra or a group algebra.

<a id="function-issimplestaralgebra-algmat"></a>
##### `IsSimpleStarAlgebra(A): AlgMat -> BoolElt`

<a id="function-issimplestaralgebra-alggrp"></a>
##### `IsSimpleStarAlgebra(A): AlgGrp -> BoolElt`

Return `true` if and only if $A$ is a simple $*$-algebra.

<a id="function-simpleparameters-algmat"></a>
##### `SimpleParameters(A): AlgMat -> SeqEnum`

<a id="function-simpleparameters-alggrp"></a>
##### `SimpleParameters(A): AlgGrp -> SeqEnum`

Given a $*$-algebra $A$, this function returns the parameters that determine (up to $*$-isomorphism) the minimal $*$-ideals of the semisimple quotient $A/J$, where $J$ is the Jacobson radical of $A$. The parameters are returned in the form of a sequence.

<a id="function-normgroup-algmat"></a>
##### `NormGroup(A): AlgMat -> GrpMat`

Given a $*$-algebra $A$, this function returns the group of unitary elements of $A$, namely the group consisting of all units in $A$ satisfying the condition $x^*=x^{-1}$. The function is based on methods described in [[BW12a](https://docs.magma-maths.org/references.md#cite-brooksbankwilson1), Section 5].

<a id="example-ex-9f1ea0"></a>
##### `Example: Distinguishing Dihedral and Quaternion Group Algebras (ex-9f1ea0)`

Our first example illustrates how the $*$-algebra machinery may be used to distinguish between group algebras over ${\rm GF}(5)$ for the dihedral and quaternion groups of order 8. Those group algebras are isomorphic as algebras, but the example shows that they are nonisomorphic as $*$-algebras.

```magma
> K := GF(5);
> G1 := SmallGroup(8, 3);
> G2 := SmallGroup(8, 4);
> A1 := GroupAlgebraAsStarAlgebra(K, G1);
> A2 := GroupAlgebraAsStarAlgebra(K, G2);
> J1, T1 := TaftDecomposition(A1);
> J2, T2 := TaftDecomposition(A2);
> Dimension(J1); Dimension(J2);
0
0
```

Thus (as we know from Maschke’s theorem) both ${\rm GF}(5)[D_8]$ and ${\rm GF}(5)[Q_8]$ are semisimple. We now recognise them as $*$-algebras and examine their minimal $*$-ideals.

```magma
> RecogniseStarAlgebra(A1);
true
> RecogniseStarAlgebra(A2);
true
> SimpleParameters(A1);
[ <"orthogonalcircle", 1, 5>, <"orthogonalcircle", 1, 5>,
<"orthogonalcircle", 1, 5>, <"orthogonalcircle", 1, 5>,
<"orthogonalplus", 2, 5> ]
> SimpleParameters(A2);
[ <"orthogonalcircle", 1, 5>, <"orthogonalcircle", 1, 5>,
<"orthogonalcircle", 1, 5>, <"orthogonalcircle", 1, 5>,
<"symplectic", 2, 5>
]
```

Both group algebras decompose into four 1-dimensional $*$-ideals, and one 4-dimensional $*$-ideal. However, the latter has type `"orthogonalplus"` for ${\rm GF}(5)[D_8]$, but type `"symplectic"` for ${\rm GF}(5)[Q_8]$.

<a id="example-ex-31ccc3"></a>
##### `Example: Distinguishing Two p-Groups of Class 2 (ex-31ccc3)`

Our second example shows how to use $*$-algebra functions to distinguish between two $p$-groups of class 2 and order $43^6$. The first group is a Sylow 43-subgroup of ${\rm GL}(3,43^2)$.

```magma
> P1 := ClassicalSylow(GL(3, 43^2), 43);
> Forms1 := PGroupToForms(P1);
> A1 := AdjointAlgebra(Forms1);
> RecogniseStarAlgebra(A1);
true
> SimpleParameters(A1);
[ <"symplectic", 2, 1849> ]
```

The second group is constructed as a subgroup of ${\rm GL}(3,{\rm GF}(43)[x]/(x^2))$.

```magma
> R<x> := PolynomialRing(GF(43));
> S, f := quo< R | x^2 >;
> G := GL(3, S);
> Ua := G![1,1,0,0,1,0,0,0,1];
> Wa := G![1,0,0,0,1,1,0,0,1];
> Ub := G![1,x@f,0,0,1,0,0,0,1];
> Wb := G![1,0,0,0,1,x@f,0,0,1];
> P2 := sub< G | [ Ua, Wa, Ub, Wb ] >;
> Forms2 := PGroupToForms(P2);
> A2 := AdjointAlgebra(Forms2);
> RecogniseStarAlgebra(A2);
true
> SimpleParameters(A2);
[ <"symplectic", 2, 43> ]
```

Since $A_1$ and $A_2$ are non-isomorphic $*$-algebras, it follows that $P_1$ and $P_2$ are non-isomorphic groups.

### Intersections of Classical Groups

The main application of the $*$-algebra machinery is to the study of the group preserving each form in a system of forms; the so-called *isometry group* of the system. An essentially equivalent (but perhaps more familiar) problem is that of computing the intersection of a set of classical groups defined on a common vector space. The main functions are implementations of the algorithms presented in [[BW12a](https://docs.magma-maths.org/references.md#cite-brooksbankwilson1), Theorem 1.2] and [[BW12c](https://docs.magma-maths.org/references.md#cite-brooksbankwilson2), Theorem 1.1].

<a id="function-isometrygroup-seqenum"></a>
#### `IsometryGroup(S : parameters): SeqEnum -> GrpMat`

```magma
Autos           : SeqEnum                    Default: [0,..,0]
DisplayStructure: BoolElt                    Default: false
```

Given a sequence $S$ containing a system of reflexive forms, this function returns the group of isometries of the system. In addition to allowing the individual forms to be degenerate, the function handles degenerate systems.

The field automorphisms associated to the individual forms are specified using the parameter `Autos`; the default is that all forms in the system are bilinear over their common base ring. As well as finding generators for the isometry group, the procedure determines the structure of this group. The parameter `DisplayStructure` may be used to display this structure.

<a id="example-ex-575942"></a>
#### `Example: Isometry Group of Forms from a p-Group (ex-575942)`

We compute the isometry group of the system of forms associated to a particular $p$-group.

```magma
> G := ClassicalSylow(Sp (4, 5^2), 5);
> S := PGroupToForms(G);
> Parent(S[1]);
Full Matrix Algebra of degree 6 over GF(5)
> I := IsometryGroup(S : DisplayStructure := true);
   G
   |   GL ( 1 , 5 ^ 1 )
   *
   |   5 ^ 4    (unipotent radical)
   1
> #I;
2500
```

<a id="function-classicalintersection-seqenum"></a>
#### `ClassicalIntersection(S): SeqEnum -> GrpMat`

Given a sequence $S$ containing a number of classical groups, each one of which preserves (up to similarity) a unique nondegenerate reflexive form on a common finite vector space $V$, this function returns the intersection of the groups. It is not required that a classical group $G$ in $S$ be the full group of isometries.

<a id="example-ex-95a8b7"></a>
#### `Example: Intersecting Two Classical Groups (ex-95a8b7)`

In our final example we intersect two quasisimple classical groups. First we construct a symplectic group ${\rm Sp}(F_1)$ for a particular skew-symmetric matrix $F_1$.

```magma
> K := GF(3);
> M := UpperTriangularMatrix
>        (K,[0,2,1,0,1,2,1,1,1,2,0,0,1,2,1,0,1,0,1,2,2]);
> F1 := M - Transpose(M);
> G1 := IsometryGroup(F1);
```

First check that G1 is a group of isometries.

```magma
> forall{ g : g in Generators(G1) | g*F1*Transpose(g) eq F1 };
true
```

Next we construct a quasisimple orthogonal group $\Omega^-(F_2)$ for a particular symmetric matrix $F_2$.

```magma
> F2 := SymmetricMatrix
>         (K, [1,2,0,1,2,2,1,0,2,2,1,0,0,0,1,2,1,1,0,1,0]);
> C := TransformForm(F2, "orthogonalminus");
> G := OmegaMinus(6, 3);
> G2 := G^(C^-1);
```

First check that G2 is a group of isometries.

```magma
> forall { g : g in Generators(G2) | g*F2*Transpose(g) eq F2 };
true
```

Finally compute the intersection of $G_1$ and $G_2$ and ask for the order of this intersection group.

```magma
> I := ClassicalIntersection([G1, G2]);
> #I;
14
```

<a id="cliff-alg"></a>
<a id="algclff"></a>
## Clifford Algebras

- [Introduction](https://docs.magma-maths.org/Algebras/CliffordAlgebras/introduction.md)
- [Clifford Algebras](https://docs.magma-maths.org/Algebras/CliffordAlgebras/creation.md)
  - [`CliffordAlgebra(Q): AlgMatElt → AlgClff, ModTupFld, Map`](https://docs.magma-maths.org/Algebras/CliffordAlgebras/creation.md#function-cliffordalgebra-algmatelt)
  - [`CliffordAlgebra(V): ModTupFld → AlgClff, Map`](https://docs.magma-maths.org/Algebras/CliffordAlgebras/creation.md#function-cliffordalgebra-modtupfld)
  - [Example: Quaternions as a Clifford Algebra](https://docs.magma-maths.org/Algebras/CliffordAlgebras/creation.md#example-ex-22ab1c)
  - [Print Names for Generators](https://docs.magma-maths.org/Algebras/CliffordAlgebras/creation.md#print-names-for-generators)
    - [`AssignNames(~C, S): AlgClff, [ MonStgElt ]`](https://docs.magma-maths.org/Algebras/CliffordAlgebras/creation.md#procedure-assignnames-algclff-monstgelt-ref)
    - [`Name(C, i): AlgClff, RngIntElt → AlgClffElt`](https://docs.magma-maths.org/Algebras/CliffordAlgebras/creation.md#function-name-algclff-rngintelt)
    - [`AsPolynomial(v): AlgClffElt`](https://docs.magma-maths.org/Algebras/CliffordAlgebras/creation.md#procedure-aspolynomial-algclffelt)
    - [Example: Naming Clifford Algebra Generators](https://docs.magma-maths.org/Algebras/CliffordAlgebras/creation.md#example-ex-dfadc4)
    - [Example: Changing Print Names of Generators](https://docs.magma-maths.org/Algebras/CliffordAlgebras/creation.md#example-ex-436f79)
  - [Elements of a Clifford Algebra](https://docs.magma-maths.org/Algebras/CliffordAlgebras/creation.md#elements-of-a-clifford-algebra)
    - [`elt< C | r₁, r₂, ..., rₘ >: AlgClff, RngElt, RngElt, ..., RngElt → AlgClffElt`](https://docs.magma-maths.org/Algebras/CliffordAlgebras/creation.md#constructor-constructor-elt-algclff-rngelt-rngelt-rngelt-algclffelt)
    - [`C ! L: AlgClff, SeqEnum[RngElt] → AlgGenElt`](https://docs.magma-maths.org/Algebras/CliffordAlgebras/creation.md#operation-op-algclff-seqenum-rngelt)
    - [`SeqToClifford(C, ss): AlgClff, SeqEnum → AlgClffElt`](https://docs.magma-maths.org/Algebras/CliffordAlgebras/creation.md#function-seqtoclifford-algclff-seqenum)
    - [`SeqFromClifford(v): AlgClffElt → SeqEnum`](https://docs.magma-maths.org/Algebras/CliffordAlgebras/creation.md#function-seqfromclifford-algclffelt)
    - [Example: Monomial Representation of an Element](https://docs.magma-maths.org/Algebras/CliffordAlgebras/creation.md#example-ex-3fca24)
    - [`BasisProduct(C, i, j): AlgClff, RngIntElt, RngIntElt → AlgGenElt`](https://docs.magma-maths.org/Algebras/CliffordAlgebras/creation.md#function-basisproduct-algclff-rngintelt-rngintelt)
    - [`BasisProduct(C, L): AlgClff, SeqEnum → AlgGenElt`](https://docs.magma-maths.org/Algebras/CliffordAlgebras/creation.md#function-basisproduct-algclff-seqenum)
    - [`BasisElement(C, S): AlgClff, SetEnum → AlgClffElt`](https://docs.magma-maths.org/Algebras/CliffordAlgebras/creation.md#function-basiselement-algclff-setenum)
- [The Main Involutions](https://docs.magma-maths.org/Algebras/CliffordAlgebras/involutions.md)
  - [`MainInvolution(C): AlgClff → Map`](https://docs.magma-maths.org/Algebras/CliffordAlgebras/involutions.md#function-maininvolution-algclff)
  - [`MainAntiautomorphism(C): AlgClff → Map`](https://docs.magma-maths.org/Algebras/CliffordAlgebras/involutions.md#function-mainantiautomorphism-algclff)
- [Clifford Algebra Structure](https://docs.magma-maths.org/Algebras/CliffordAlgebras/operations.md)
  - [`HomogeneousComponent(v,k): AlgClffElt, RngIntElt → AlgClffElt`](https://docs.magma-maths.org/Algebras/CliffordAlgebras/operations.md#function-homogeneouscomponent-algclffelt-rngintelt)
  - [Example: Homogeneous Components of an Element](https://docs.magma-maths.org/Algebras/CliffordAlgebras/operations.md#example-ex-40ad8c)
  - [`EvenSubalgebra(C : parameters): AlgClff → AlgAss, Map`](https://docs.magma-maths.org/Algebras/CliffordAlgebras/operations.md#function-evensubalgebra-algclff)
  - [Example: Quaternions as an Even Subalgebra](https://docs.magma-maths.org/Algebras/CliffordAlgebras/operations.md#example-ex-521a9d)
  - [`Centre(C): AlgClff → AlgAss, Map`](https://docs.magma-maths.org/Algebras/CliffordAlgebras/operations.md#function-centre-algclff)
  - [`Center(C): AlgClff → AlgAss, Map`](https://docs.magma-maths.org/Algebras/CliffordAlgebras/operations.md#function-center-algclff)
  - [Example: Even Dimension with Maximal Witt Index](https://docs.magma-maths.org/Algebras/CliffordAlgebras/operations.md#example-ex-d39588)
  - [Example: Even Dimension with Non-Maximal Witt Index](https://docs.magma-maths.org/Algebras/CliffordAlgebras/operations.md#example-ex-04b7d8)
  - [Example: Clifford Algebra in Odd Dimension](https://docs.magma-maths.org/Algebras/CliffordAlgebras/operations.md#example-ex-a8b683)
- [Vector and Spin Representations](https://docs.magma-maths.org/Algebras/CliffordAlgebras/spin.md)
  - [The Clifford Group](https://docs.magma-maths.org/Algebras/CliffordAlgebras/spin.md#the-clifford-group)
    - [`VectorAction(g): AlgClffElt → AlgMatElt`](https://docs.magma-maths.org/Algebras/CliffordAlgebras/spin.md#function-vectoraction-algclffelt)
    - [Example: Reflections from the Clifford Group](https://docs.magma-maths.org/Algebras/CliffordAlgebras/spin.md#example-ex-6e1ea1)
  - [Siegel Transformations and Spin Groups](https://docs.magma-maths.org/Algebras/CliffordAlgebras/spin.md#siegel-transformations-and-spin-groups)
    - [Example: Siegel Transformations](https://docs.magma-maths.org/Algebras/CliffordAlgebras/spin.md#example-ex-c93d8c)
    - [Example: Spin Preimages of Standard Generators](https://docs.magma-maths.org/Algebras/CliffordAlgebras/spin.md#example-ex-1c9644)
  - [Spin Representations](https://docs.magma-maths.org/Algebras/CliffordAlgebras/spin.md#spin-representations)
    - [`ActionMatrix(S, s): AlgAss, AlgAssElt → AlgMatElt`](https://docs.magma-maths.org/Algebras/CliffordAlgebras/spin.md#function-actionmatrix-algass-algasselt)
    - [Example: Minimal Right Ideals of the Even Subalgebra](https://docs.magma-maths.org/Algebras/CliffordAlgebras/spin.md#example-ex-b3def3)
    - [Example: Constructing a Spin Representation](https://docs.magma-maths.org/Algebras/CliffordAlgebras/spin.md#example-ex-d57a8d)
- [Bibliography](https://docs.magma-maths.org/Algebras/CliffordAlgebras/bibliography.md)

<a id="sectalgclffintro"></a>
<a id="id1"></a>
### Introduction

Given a quadratic form $Q$ defined on a vector space $V$ over a field $F$, the Clifford algebra of $Q$ is an associative $F$-algebra $C$ with a vector space homomorphism $f : V\to C$ such that $f(v)^2 = Q(v)$ for all $v\in V$. Furthermore, the triple $(C,V,f)$ has the universal property that if $A$ is any associative algebra with a homomorphism $g : V \to A$ such that $g(v)^2 = Q(v)$ for all $v\in V$, then there is a unique algebra homomorphism $h : C \to A$ such that $hf = g$. It can be shown that $f$ is injective and therefore we may identify $V$ with its image in $C$. If the dimension of $V$ is $n$, then the dimension of $C$ is $2^n$. We shall refer to $V$ as the *quadratic space* of $C$.

The primary references for quadratic forms and Clifford algebras are [[Che97](https://docs.magma-maths.org/references.md#cite-chev-1954)] and [[Art57](https://docs.magma-maths.org/references.md#cite-artin-1957)]. A more recent account, with applications is [[Lou01](https://docs.magma-maths.org/references.md#cite-lounesto-2001)].

### Clifford Algebras

Clifford algebras are represented in Magma as structure constant algebras and therefore many of the functions described in Chapter [Algebras](https://docs.magma-maths.org/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](https://docs.magma-maths.org/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$.

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

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

<a id="example-ex-22ab1c"></a>
#### `Example: Quaternions as a Clifford Algebra (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.

<a id="procedure-assignnames-algclff-monstgelt-ref"></a>
##### `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.

<a id="function-name-algclff-rngintelt"></a>
##### `Name(C, i): AlgClff, RngIntElt -> AlgClffElt`

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

<a id="procedure-aspolynomial-algclffelt"></a>
##### `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$.

<a id="example-ex-dfadc4"></a>
##### `Example: Naming Clifford Algebra Generators (ex-dfadc4)`

The generator assignment construction (see Section [Generator Assignment](https://docs.magma-maths.org/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
```

<a id="example-ex-436f79"></a>
##### `Example: Changing Print Names of Generators (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

<a id="constructor-constructor-elt-algclff-rngelt-rngelt-rngelt-algclffelt"></a>
##### `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$.

<a id="operation-op-algclff-seqenum-rngelt"></a>
##### `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$.

<a id="function-seqtoclifford-algclff-seqenum"></a>
##### `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$.

<a id="function-seqfromclifford-algclffelt"></a>
##### `SeqFromClifford(v): AlgClffElt -> SeqEnum`

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

<a id="example-ex-3fca24"></a>
##### `Example: Monomial Representation of an Element (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
```

<a id="function-basisproduct-algclff-rngintelt-rngintelt"></a>
##### `BasisProduct(C, i, j): AlgClff, RngIntElt, RngIntElt -> AlgGenElt`

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

<a id="function-basisproduct-algclff-seqenum"></a>
##### `BasisProduct(C, L): AlgClff, SeqEnum -> AlgGenElt`

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

<a id="function-basiselement-algclff-setenum"></a>
##### `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$.

### The Main Involutions

Let $C$ be a Clifford algebra of a quadratic space $V$ and suppose that $e_1$, $e_2$, …, $e_n$ is a basis for $V$. Let $C_+$ be the subspace of linear combinations of products of an even number of basis elements and let $C_-$ be the subspace of linear combinations of products of an odd number of basis elements. Then $C_+$ is a subalgebra and $C$ is the direct sum of $C_+$ and $C_-$. The *main involution* of $C$ is the automorphism $J$ such that $J(u) = u$ if $u\in C_+$ and $J(u) = -u$ if $u\in C_-$.

<a id="function-maininvolution-algclff"></a>
#### `MainInvolution(C): AlgClff -> Map`

The main involution of the Clifford algebra C.

The mapping $C \to C$ which reverses the multiplication is an antiautomorphism whose square is the identity; it is called the *main antiautomorphism* of $C$.

<a id="function-mainantiautomorphism-algclff"></a>
#### `MainAntiautomorphism(C): AlgClff -> Map`

The main antiautomorphism of $C$. The first time this function is invoked it sets the attribute `antiAutMat` of $C$ to the matrix defining this map.

### Clifford Algebra Structure

Clifford algebras are associative structure constant algebras and therefore the intrinsics in chapters on structure constant algebras and associative algebras may be used with Clifford algebra arguments.

<a id="function-homogeneouscomponent-algclffelt-rngintelt"></a>
#### `HomogeneousComponent(v, k): AlgClffElt, RngIntElt -> AlgClffElt`

The homogeneous component of degree $k$ of the Clifford algebra element $v$.

<a id="example-ex-40ad8c"></a>
#### `Example: Homogeneous Components of an Element (ex-40ad8c)`

```magma
> F := GF(5);
> C,V,f := CliffordAlgebra(IdentityMatrix(F,4));
> v := (f(V.1)*f(V.2)+3*f(V.2))*(f(V.3)+f(V.4));
> AsPolynomial(HomogeneousComponent(v,2));
3*e1*e3 + 3*e2*e4
```

<a id="function-evensubalgebra-algclff"></a>
#### `EvenSubalgebra(C : parameters): AlgClff -> AlgAss, Map`

The even subalgebra $C_+$ of the Clifford algebra $C$. This is the algebra of fixed points of the main involution. The second return value of this function is the canonical embedding of $C_+$ in $C$.

<a id="example-ex-521a9d"></a>
#### `Example: Quaternions as an Even Subalgebra (ex-521a9d)`

A (generalised) quaternion algebra can also be realised as the even subalgebra of a Clifford algebra.

```magma
> F<a,b> := RationalFunctionField(Rationals(),2);
> Q := DiagonalMatrix(F,[1,-a,-b]);
> C,V,f := CliffordAlgebra(Q);
> E, h := EvenSubalgebra(C);
> i := E.2;
> j := E.3;
> i^2;
(a 0 0 0)
> j^2;
(b 0 0 0)
> i*j eq -j*i;
true
```

<a id="function-centre-algclff"></a>
#### `Centre(C): AlgClff -> AlgAss, Map`

<a id="function-center-algclff"></a>
#### `Center(C): AlgClff -> AlgAss, Map`

The centre of the Clifford algebra $C$. The second return value is the embedding in $C$.

The following examples illustrate the fact that over a finite field $F$ a Clifford algebra $C$ of a non-degenerate quadratic form $Q$ is either a simple algebra or the direct sum of two simple algebras. Furthermore, the same is true of its even subalgebra $E$. Let $V$ denote the quadratic space of $Q$.

<a id="example-ex-d39588"></a>
#### `Example: Even Dimension with Maximal Witt Index (ex-d39588)`

If the dimension of $V$ is $2m$ and the Witt index of $Q$ is $m$, then $C$ is a central simple algebra.

```magma
> F := GF(3);
> Q := StandardQuadraticForm(6,F);
> C,V,f := CliffordAlgebra(Q);
> WittIndex(V);
3
> IsSimple(C);
true
> #Centre(C);
3
```

The even subalgebra $E$ of $C$ is the direct sum of two simple ideals $E(1-z)$ and $E(1+z)$, where $z^2 = 1$ and $z$ anticommutes with every element of $V$.

```magma
> E,h := EvenSubalgebra(C);
> IsSimple(E);
false
> #MinimalIdeals(E);
2
> Z := Centre(E); Z;
Associative Algebra of dimension 2 with base ring GF(3)
> #{ z : z in Z | IsUnit(z) };
4
> exists(z){ z : z in Z | z^2 eq One(E) and
>   forall{ v : v in V | f(v)*h(z) eq - h(z)*f(v) } };
true
> E1 := ideal< E | 1-z >;
> IsSimple(E1);
true
> E2 := ideal< E | 1+z >;
> IsSimple(E2);
true
```

<a id="example-ex-04b7d8"></a>
#### `Example: Even Dimension with Non-Maximal Witt Index (ex-04b7d8)`

If $\dim V = 2m$ and the Witt index of $Q$ is $m-1$, the even subalgebra of $C$ is a simple algebra whose centre is a quadratic extension of $F$.

```magma
> F := GF(3);
> Q := StandardQuadraticForm(6,F : Minus);
> C,V,f := CliffordAlgebra(Q);
> WittIndex(V);
2
> IsSimple(C);
true
> #Centre(C);
3
> E := EvenSubalgebra(C);
> IsSimple(E);
true
> Z := Centre(E); Z;
Associative Algebra of dimension 2 with base ring GF(3)
> #{ z : z in Z | IsUnit(z) };
8
```

<a id="example-ex-a8b683"></a>
#### `Example: Clifford Algebra in Odd Dimension (ex-a8b683)`

If $\dim V = 2m+1$ and the Witt index of $Q$ is $m$, the even subalgebra is central simple and $C$ is the either simple or the direct sum of two simple algebras.

```magma
> F := GF(3);
> Q := StandardQuadraticForm(5,F);
> C,V,f := CliffordAlgebra(Q);
> WittIndex(V);
2
> IsSimple(C);
false
> Z := Centre(C); Z;
Associative Algebra of dimension 2 with base ring GF(3)
> #{ z : z in Z | IsUnit(z) };
4
> E := EvenSubalgebra(C);
> IsSimple(E);
true
```

In this example the Clifford algebra is the direct sum of two simple ideals. But it is possible that the Clifford algebra of a scalar multiple of $Q$ is a simple algebra over a quadratic extension of the base field.

```magma
> C,V,f := CliffordAlgebra(2*Q);
> IsSimple(C);
true
> #Z,#{ z : z in Centre(C) | IsUnit(z) };
9 8
```

The non-zero elements of $Z$ are invertible and hence $Z$ is a field, namely ${\bf F}_{9}$.

### Vector and Spin Representations

Throughout this section, let $Q$ be a quadratic form of Witt index $r$ on a vector space $V$ over a finite field $F$ such that the polar form of $Q$ is non-degenerate and let $C$ denote the Clifford algebra of $Q$.

#### The Clifford Group

The Clifford group of $C$ is

$$
\Gamma = \{\, s \in C \mid s\text{ is a unit and }s^{-1}vs \in V\text{
  for all }v\in V\,\}
$$

and the *vector representation* of $\Gamma$ is the homomorphism $\chi : \Gamma \to {\operatorname{GL}}(V)$ such that for $s\in \Gamma$, $\chi(s)$ is the linear transformation sending $v\in V$ to $s^{-1}vs$. In fact, $\chi(\Gamma)$ is a subgroup of the orthogonal group $O(V,Q)$. Except when the Witt index of $Q$ is 2 and $V$ is a space of dimension 4 over ${\bf F}_{2}$, if $\dim V$ is even, $\chi(\Gamma) = O(V,Q)$ and if $\dim V$ is odd, $\chi(\Gamma) = {\operatorname{SO}}(V,Q)$. (See [[Che97](https://docs.magma-maths.org/references.md#cite-chev-1954)] for further details.)

<a id="function-vectoraction-algclffelt"></a>
##### `VectorAction(g): AlgClffElt -> AlgMatElt`

The matrix of the Clifford group element $g\in \Gamma$ acting on the quadratic space $V$ by conjugation.

<a id="example-ex-6e1ea1"></a>
##### `Example: Reflections from the Clifford Group (ex-6e1ea1)`

If $v$ is a non-singular element of $V$, the negative of the linear transformation $\chi(v)$ is the reflection in the hyperplane orthogonal to $v$.

```magma
> F := GF(3);
> Q := StandardQuadraticForm(6,F);
> C, V, f := CliffordAlgebra(Q);
> v := V![2,0,2,0,0,1];
```

In order to ensure $v$ is non-singular we check its quadratic norm.

```magma
> QuadraticNorm(v);
2
> A := VectorAction(f(v));
> -A eq OrthogonalReflection(v);
true
```

#### Siegel Transformations and Spin Groups

The special Clifford group is $\Gamma^+ = \Gamma\cap C_+$ and $\chi(\Gamma^+) = {\operatorname{SO}}(V,Q)$. If $\alpha$ is the main anti-automorphism of $C$, the *spin group* of $Q$ is

$$
{\operatorname{Spin}}(V,Q) = \{\,s\in \Gamma^+ \mid \alpha(s)s = 1\,\}.
$$

Given the polar form $\beta$ of $Q$ and linearly independent vectors $u,v \in V$ such that $u$ is singular and $\beta(u,v) = 0$, the *Siegel transformation* defined by $u$ and $v$ (see Chapter [Polar Spaces](https://docs.magma-maths.org/MatricesLinearAlgebra/PolarSpaces/index-polar-spaces.md#chappolarspace)) is the isometry $\rho_{u,v}$ defined by

$$
x \rho_{u,v} = x + \beta(x,v)u - \beta(x,u)v - Q(v)\beta(x,u) u.
$$

In the Clifford algebra of $Q$, the conditions on $u$ and $v$ become $u^2 = 0$ and $uv + vu = 0$. Thus $uv - 1\in {\operatorname{Spin}}(V,Q)$ and $\chi(uv-1) = \rho_{u,v}$. Except for $\Omega^+(4,2)$ the group $\Omega(V,Q)$ is generated by Siegel transformations and thus $\chi :{\operatorname{Spin}}(V,Q) \to \Omega(V,Q)$ is onto; its kernel is $\{\pm 1\}$.

<a id="example-ex-c93d8c"></a>
##### `Example: Siegel Transformations (ex-c93d8c)`

We verify that a Siegel transformation $\rho_{u,v}$ can be obtained as the vector representation of $uv-1$.

```magma
> F := GF(3);
> Q := StandardQuadraticForm(6,F);
> C, V, f := CliffordAlgebra(Q);
> u := V.1;
> v := V.5;
> VectorAction(f(u)*f(v) - One(C)) eq SiegelTransformation(u,v);
true
```

Regarding $\Omega(V,Q)$ as a group of Lie type, the subgroups $X_{u,v} = \langle\, \rho_{tu,v} \mid t \in F \,\rangle$ are root groups. (If $\dim V = 2r$, we consider only the groups for which both $u$ and $v$ are singular.) In Magma, the generators of the groups $\Omega(V,Q)$ are defined in terms of root elements (see [[RT98](https://docs.magma-maths.org/references.md#cite-rylands-taylor)]).

<a id="example-ex-1c9644"></a>
##### `Example: Spin Preimages of Standard Generators (ex-1c9644)`

When $F = {\bf F}_{q}$ and $\dim V = 2r$ we construct the elements of ${\operatorname{Spin}}(V,Q)$ which map onto the standard generators of $\Omega^+(2r,q)$.

```magma
> q := 3;
> r := 4;
> K := GF(3);
> Q := StandardQuadraticForm(2*r,K);
> C,V,f := CliffordAlgebra(Q);
```

The root element $x_{\alpha_k}(t)$ indexed by the $k$th simple root is given by the following function.

```magma
> x := func< k,t |
>   k eq 1 select VectorAction(f(t*V.(r+2))*f(V.(r+1))-One(C))
>   else VectorAction(f(t*V.(r-k+2))*f(V.(r+k))-One(C)) >;
```

It turns out that our choice of $Q$ ensures that the matrices of the negative root elements are the transposed matrices of the corresponding positive roots.

```magma
> n := func< k, t | x(k,t)*Transpose(x(k,-t^-1))*x(k,t) >;
> h := func< k, t | n(k,t)*n(k,-1) >;
> w := n(1,1)*n(2,1)*n(3,1)*n(4,1);
> xi := PrimitiveElement(K);
> G := OmegaPlus(2*r,q);
> G.1 eq h(2,xi);
true
> G.2 eq Transpose(x(1,1))*x(3,1)*w;
true
```

Note that the vector representation of ${\operatorname{Spin}}(V,Q)$ is not faithful.

```magma
> VectorAction(-One(C)) eq IdentityMatrix(K,2*r);
true
```

#### Spin Representations

If the dimension of $V$ is $2r$, the Clifford algebra $C$ of $Q$ is simple and hence all irreducible representations are equivalent. We may take the representation space to be a minimal right ideal $S$ of $C$. The elements of $S$ are *spinors* and the representation itself is the *spin representation*. The restrictions of this representation to the groups $\Gamma$, $\Gamma^+$, and $\Spin(V,Q)$ are also called spin representations. The spin representation of $\Gamma$ is irreducible except when the field has order 2, $r = 1$ and the Witt index is 1.

<a id="function-actionmatrix-algass-algasselt"></a>
##### `ActionMatrix(S, s): AlgAss, AlgAssElt -> AlgMatElt`

The matrix representing the action of $s$ on the right ideal $S$ of an associative algebra $A$ and $s$ is an element of $A$.

<a id="example-ex-b3def3"></a>
##### `Example: Minimal Right Ideals of the Even Subalgebra (ex-b3def3)`

```magma
> F := GF(5);
> Q := StandardQuadraticForm(4,F);
> C,V,f := CliffordAlgebra(Q);
> E, h := EvenSubalgebra(C);
> IsSimple(E);
false
> S := MinimalRightIdeals(E)[1];
> s := (f(V.1+V.4)*f(V.2+V.3))@@h;
> ActionMatrix(S,s);
[0 4]
[1 0]
```

<a id="example-ex-d57a8d"></a>
##### `Example: Constructing a Spin Representation (ex-d57a8d)`

The Magma functions `Spin`, `SpinPlus`, and `SpinMinus` construct the groups using highest weight representations of the corresponding group of Lie type. But in this example we construct the spin representation of $\Spin^+(8,3)$ by working directly with the Clifford algebra.

```magma
> q := 3;
> r := 4;
> K := GF(3);
> Q := StandardQuadraticForm(2*r,K);
> C,V,f := CliffordAlgebra(Q);
```

We adapt the code from Example [Spin Preimages of Standard Generators](https://docs.magma-maths.org/Algebras/CliffordAlgebras/spin.md#example-ex-1c9644).

The root element $x_{\alpha_k}(t)$ indexed by the $k$th simple root is given by the Magma function `x(k,t)` and the corresponding negative root element is `y(k,t)`.

```magma
> x := func< k,t |
>   k eq 1 select f(t*V.(r+2))*f(V.(r+1))-One(C)
>   else f(t*V.(r-k+2))*f(V.(r+k))-One(C) >;
> y := func< k,t |
>   k eq 1 select f(t*V.r)*f(V.(r-1))-One(C)
>   else f(t*V.(r-k+1))*f(V.(r+k-1))-One(C) >;
```

The other functions are the same as before.

```magma
> n := func< k, t | x(k,t)*y(k,-t^-1)*x(k,t) >;
> h := func< k, t | n(k,t)*n(k,-1) >;
> w := n(1,1)*n(2,1)*n(3,1)*n(4,1);
```

The spin representation space is a minimal right ideal of the Clifford algebra.

```magma
> S := MinimalRightIdeals(C : Limit := 1)[1];
> Dimension(S);
16
> X := sub<GL(16,K) | ActionMatrix(S,h(2,2)), ActionMatrix(S,y(1,1)*x(3,1)*w) >;
> LieType(X,3);
true <"D", 4, 3>
> LMGOrder(X);
19808719257600
> Z := LMGCentre(X);
> #Z, IsElementaryAbelian(Z);
4 true
> SS := SpinPlus(8,K);
> #SS;
19808719257600
```

The spin representation of ${\operatorname{Spin}}^+(8,3)$ is the direct sum of two *half spin* representations, neither of which is faithful. The half spin spaces are minimal ideals of the even subalgebra of $C$.

```magma
> E, phi := EvenSubalgebra(C);
> T := MinimalRightIdeals(E : Limit := 1)[1];
> Dimension(T);
8
> Y := sub<GL(8,K) | ActionMatrix(T,h(2,2)@@phi),
>                    ActionMatrix(T,(y(1,1)*x(3,1)*w)@@phi) >;
> LieType(Y,3);
true <"D", 4, 3>
> LMGOrder(Y);
9904359628800
```

<a id="non-associative-algebras"></a>
## Non–Associative Algebras

A number of constructions for non-associative algebras are given in this chapter. The types of algebra currently available are constructed using the exceptional tensor machinery provided by the Multilinear Algebra package developed by Josh Maglione and James Wilson. A few supporting functions for nonassociative algebras are also provided.

- [Composition Algebras](https://docs.magma-maths.org/Algebras/NonAssociativeAlgebras/Composition-algebras.md)
  - [`CompositionAlgebra(K, a): Fld, [FldElt] → AlgGen`](https://docs.magma-maths.org/Algebras/NonAssociativeAlgebras/Composition-algebras.md#function-compositionalgebra-fld-fldelt)
  - [`CompositionAlgebra(K, a): Fld, [RngIntElt] → AlgGen`](https://docs.magma-maths.org/Algebras/NonAssociativeAlgebras/Composition-algebras.md#function-compositionalgebra-fld-rngintelt)
  - [`OctonionAlgebra(K, a, b, c): Fld, FldElt, FldElt, FldElt → AlgGen`](https://docs.magma-maths.org/Algebras/NonAssociativeAlgebras/Composition-algebras.md#function-octonionalgebra-fld-fldelt-fldelt-fldelt)
  - [`OctonionAlgebra(K, a, b, c): Fld, RngIntElt, RngIntElt, RngIntElt → AlgGen`](https://docs.magma-maths.org/Algebras/NonAssociativeAlgebras/Composition-algebras.md#function-octonionalgebra-fld-rngintelt-rngintelt-rngintelt)
  - [`SplitOctonionAlgebra(K): Fld → AlgGen`](https://docs.magma-maths.org/Algebras/NonAssociativeAlgebras/Composition-algebras.md#function-splitoctonionalgebra-fld)
  - [Example: Triality in Octonion Algebras](https://docs.magma-maths.org/Algebras/NonAssociativeAlgebras/Composition-algebras.md#example-ex-7d5c5a)
- [Jordan Algebras](https://docs.magma-maths.org/Algebras/NonAssociativeAlgebras/Jordan-algebras.md)
  - [`JordanTripleProduct(J): AlgGen → TenSpcElt`](https://docs.magma-maths.org/Algebras/NonAssociativeAlgebras/Jordan-algebras.md#function-jordantripleproduct-alggen)
  - [`JordanSpinAlgebra(F): TenSpcElt → AlgGen`](https://docs.magma-maths.org/Algebras/NonAssociativeAlgebras/Jordan-algebras.md#function-jordanspinalgebra-tenspcelt)
  - [`JordanSpinAlgebra(F): Any → AlgGen`](https://docs.magma-maths.org/Algebras/NonAssociativeAlgebras/Jordan-algebras.md#function-jordanspinalgebra-any)
  - [Example: Basic Properties of Jordan Algebras](https://docs.magma-maths.org/Algebras/NonAssociativeAlgebras/Jordan-algebras.md#example-ex-359672)
  - [`ExceptionalJordanCSA(O): AlgGen → AlgGen`](https://docs.magma-maths.org/Algebras/NonAssociativeAlgebras/Jordan-algebras.md#function-exceptionaljordancsa-alggen)
  - [`ExceptionalJordanCSA(K): Fld → AlgGen`](https://docs.magma-maths.org/Algebras/NonAssociativeAlgebras/Jordan-algebras.md#function-exceptionaljordancsa-fld)
  - [Example: Lie Algebra F4 from a Jordan Algebra](https://docs.magma-maths.org/Algebras/NonAssociativeAlgebras/Jordan-algebras.md#example-ex-af7b0b)
- [Invariants](https://docs.magma-maths.org/Algebras/NonAssociativeAlgebras/Invariants-of-nonassociative-algebras.md)
  - [`Center(A): Alg → Alg`](https://docs.magma-maths.org/Algebras/NonAssociativeAlgebras/Invariants-of-nonassociative-algebras.md#function-center-alg)
  - [`Centre(A): Alg → Alg`](https://docs.magma-maths.org/Algebras/NonAssociativeAlgebras/Invariants-of-nonassociative-algebras.md#function-centre-alg)
  - [`Centroid(A): Alg → AlgMat`](https://docs.magma-maths.org/Algebras/NonAssociativeAlgebras/Invariants-of-nonassociative-algebras.md#function-centroid-alg)
  - [Example: Center and Centroid of an Algebra](https://docs.magma-maths.org/Algebras/NonAssociativeAlgebras/Invariants-of-nonassociative-algebras.md#example-ex-ebe4ae)
  - [`LeftNucleus(A): Alg → AlgMat`](https://docs.magma-maths.org/Algebras/NonAssociativeAlgebras/Invariants-of-nonassociative-algebras.md#function-leftnucleus-alg)
  - [`RightNucleus(A): Alg → AlgMat`](https://docs.magma-maths.org/Algebras/NonAssociativeAlgebras/Invariants-of-nonassociative-algebras.md#function-rightnucleus-alg)
  - [`MidNucleus(A): Alg → AlgMat`](https://docs.magma-maths.org/Algebras/NonAssociativeAlgebras/Invariants-of-nonassociative-algebras.md#function-midnucleus-alg)
  - [`DerivationAlgebra(A): Alg → AlgMatLie`](https://docs.magma-maths.org/Algebras/NonAssociativeAlgebras/Invariants-of-nonassociative-algebras.md#function-derivationalgebra-alg)
  - [Example: Derivation Algebra of the Octonions](https://docs.magma-maths.org/Algebras/NonAssociativeAlgebras/Invariants-of-nonassociative-algebras.md#example-ex-8c0a5c)
  - [Example: Further Invariants of Nonassociative Algebras](https://docs.magma-maths.org/Algebras/NonAssociativeAlgebras/Invariants-of-nonassociative-algebras.md#example-ex-a850f6)
- [Generic Operations](https://docs.magma-maths.org/Algebras/NonAssociativeAlgebras/Generics-for-nonassociative-algebras.md)
  - [Nonassociative Algebras with Involutions](https://docs.magma-maths.org/Algebras/NonAssociativeAlgebras/Generics-for-nonassociative-algebras.md#nonassociative-algebras-with-involutions)
    - [`IsStarAlgebra(A): AlgGen → BoolElt`](https://docs.magma-maths.org/Algebras/NonAssociativeAlgebras/Generics-for-nonassociative-algebras.md#function-isstaralgebra-alggen)
    - [`Star(A): AlgGen → Map`](https://docs.magma-maths.org/Algebras/NonAssociativeAlgebras/Generics-for-nonassociative-algebras.md#function-star-alggen)
    - [Example: Involutions of an Octonion Algebra](https://docs.magma-maths.org/Algebras/NonAssociativeAlgebras/Generics-for-nonassociative-algebras.md#example-ex-ffb750)
  - [Operations on Power Associative Algebras](https://docs.magma-maths.org/Algebras/NonAssociativeAlgebras/Generics-for-nonassociative-algebras.md#operations-on-power-associative-algebras)
    - [`GenericMinimalPolynomial(x): AlgGenElt → FldElt`](https://docs.magma-maths.org/Algebras/NonAssociativeAlgebras/Generics-for-nonassociative-algebras.md#function-genericminimalpolynomial-alggenelt)
    - [`GenericNorm(x): AlgGenElt → FldElt`](https://docs.magma-maths.org/Algebras/NonAssociativeAlgebras/Generics-for-nonassociative-algebras.md#function-genericnorm-alggenelt)
    - [`GenericTrace(x): AlgGenElt → FldElt`](https://docs.magma-maths.org/Algebras/NonAssociativeAlgebras/Generics-for-nonassociative-algebras.md#function-generictrace-alggenelt)
    - [`GenericTracelessSubspaceBasis(A): AlgGen → Any`](https://docs.magma-maths.org/Algebras/NonAssociativeAlgebras/Generics-for-nonassociative-algebras.md#function-generictracelesssubspacebasis-alggen)
    - [Example: Generic Trace of a Quaternion](https://docs.magma-maths.org/Algebras/NonAssociativeAlgebras/Generics-for-nonassociative-algebras.md#example-ex-099024)
- [Bibliography](https://docs.magma-maths.org/Algebras/NonAssociativeAlgebras/bibliography.md)

### Composition Algebras

<a id="function-compositionalgebra-fld-fldelt"></a>
#### `CompositionAlgebra(K, a): Fld, [FldElt] -> AlgGen`

<a id="function-compositionalgebra-fld-rngintelt"></a>
#### `CompositionAlgebra(K, a): Fld, [RngIntElt] -> AlgGen`

Constructs the composition algebra with specified parameters. The algebra returned has an involution.

The method is modestly intentional choosing Magma’s favored representation of the individually classified algebras according to Hurwitz’s theorem. In the case of fields the type returned is an algebra with involution, possibly the identity.

<a id="function-octonionalgebra-fld-fldelt-fldelt-fldelt"></a>
#### `OctonionAlgebra(K, a, b, c): Fld, FldElt, FldElt, FldElt -> AlgGen`

<a id="function-octonionalgebra-fld-rngintelt-rngintelt-rngintelt"></a>
#### `OctonionAlgebra(K, a, b, c): Fld, RngIntElt, RngIntElt, RngIntElt -> AlgGen`

Octonion algebra with involution given by the specified parameters. This builds the Cayley-Dickson algebra over the quaternion algebra $\left(a\over{b}{K}\right)$. In particular, Magma’s implementation of quaternion algebras is applied.

<a id="function-splitoctonionalgebra-fld"></a>
#### `SplitOctonionAlgebra(K): Fld -> AlgGen`

Returns the split octonion algebra over the field $F$.

<a id="example-ex-7d5c5a"></a>
#### `Example: Triality in Octonion Algebras (ex-7d5c5a)`

The following example demonstrates some of the mechanics by exploring the concept of triality [[Sch66](https://docs.magma-maths.org/references.md#cite-schafer), III.8].

The Cartan-Jacobson theorem asserts that for fields of characteristic other than 2 and 3, the derivation algebra of an octonion algebra is of Lie type $G_2$.

```magma
> O := OctonionAlgebra(GF(7),-1,-1,-1);
> L := DerivationAlgebra(O);   // Derivations as an algebra.
> SemisimpleType(L);
G2
```

Cartan’s triality obtains $G_2$ from $D_4$ by relaxing to derivations of the octonions as a generic tensor, rather than as an algebra. This is done computationally by changing the category of the octonion product from an algebra to a tensor.

```magma
> T := Tensor(O);
> T := ChangeTensorCategory(T,HomotopismCategory(3));
> M := DerivationAlgebra(T);  // Derivations as a tensor.
> SemisimpleType(M/SolvableRadical(M));
D4
```

### Jordan Algebras

<a id="function-jordantripleproduct-alggen"></a>
#### `JordanTripleProduct(J): AlgGen -> TenSpcElt`

Returns the tensor describing the Jordan triple product.

<a id="function-jordanspinalgebra-tenspcelt"></a>
#### `JordanSpinAlgebra(F): TenSpcElt -> AlgGen`

<a id="function-jordanspinalgebra-any"></a>
#### `JordanSpinAlgebra(F): Any -> AlgGen`

Returns the special Jordan algebra of spin type for given symmetric form.

<a id="example-ex-359672"></a>
#### `Example: Basic Properties of Jordan Algebras (ex-359672)`

Jordan algebras have suggestive analogues of commutative associative algebras, but experimenting shows serious differences.

```magma
> F := IdentityMatrix(Rationals(),2);
> J := JordanSpinAlgebra(F);
> T := Tensor(J);
> R := AsMatrices( T, 2,0);
> R[1];   // Is J.1 the identity?
[1 0 0]
[0 1 0]
[0 0 1]
> J.2*J.2 eq J.1;  // J.2^2=1?
true
> J.2*J.3 eq 0;  // Yet J.2 is a zero-divisor.
true
> e := (1/2)*(J.1+J.2);
> e^2 eq e;  // An idempotent of J?
true
```

Pierce decompositions in Jordan algebras have the usual 0 and 1 eigenspaces but an additional 1/2-eigenspace emerges as well.

```magma
> Re := (1/2)*(R[1]+R[2]);
> Eigenvalues(Re);
{ <1, 1>, <1/2, 1>, <0, 1> }
```

<a id="function-exceptionaljordancsa-alggen"></a>
#### `ExceptionalJordanCSA(O): AlgGen -> AlgGen`

<a id="function-exceptionaljordancsa-fld"></a>
#### `ExceptionalJordanCSA(K): Fld -> AlgGen`

The exception central simple Jordan algebra over the given octonions. If a field is supplied instead then the split octonion algebra over the field is used.

<a id="example-ex-af7b0b"></a>
#### `Example: Lie Algebra F4 from a Jordan Algebra (ex-af7b0b)`

In characteristic not $2$ or $3$, the exceptional central simple Jordan algebra can be used to construct the exceptional Lie algebra of type $F_4$.

```magma
> J := ExceptionalJordanCSA(Rationals());
> T := Tensor(J);
> T := ChangeTensorCategory(T, HomotopismCategory(3));
> D := DerivationAlgebra(T);
> _, D2 := Induce(D, 2);           // Represent D on U2.
> F4 := D2*D2;                  // Commutator.
> SemisimpleType(F4);
F4
> F4;               // F4 represented on a 27-dim module.
Matrix Lie Algebra of degree 27 over Rational Field
```

### Invariants

Converting an algebra to a tensor enables Magma to compute standard invariants of any algebra. We note that there are known errors for ${\mathbb{R}}$ and ${\mathbb{C}}$ due to the numerical stability of the linear algebra involved in the computations.

<a id="function-center-alg"></a>
#### `Center(A): Alg -> Alg`

<a id="function-centre-alg"></a>
#### `Centre(A): Alg -> Alg`

Returns the center of the algebra $A$.

<a id="function-centroid-alg"></a>
#### `Centroid(A): Alg -> AlgMat`

Returns the centroid of the $K$-algebra $A$ as a subalgebra of $\rm{End}_K(A)$.

<a id="example-ex-ebe4ae"></a>
#### `Example: Center and Centroid of an Algebra (ex-ebe4ae)`

We will construct a representation of $\rm{SL}_2(9)$ in $\rm{Mat}_4({\bf F}_{3})$. First we construct $\rm{GL}_2(9)$ from $\rm{Mat}_4({\bf F}_{3})$.

```magma
> M := MatrixAlgebra(GF(3), 4);
> f := ConwayPolynomial(3, 2);
> C := CompanionMatrix(f);
> I := IdentityMatrix(GF(3), 2);
> A := sub< M | [InsertBlock(M!0, X, i, j) :
>     X in [I, C], i in [1, 3], j in [1, 3]] >;
> T := CommutatorTensor(A);
> T;
Tensor of valence 3, U2 x U1 >-> U0
U2 : Full Vector space of degree 8 over GF(3)
U1 : Full Vector space of degree 8 over GF(3)
U0 : Full Vector space of degree 8 over GF(3)
> GL2 := HeisenbergAlgebra(T);
> GL2;
Algebra of dimension 8 with base ring GF(3)
```

Our Lie algebra is not simple as it has a nontrivial center, so we will obtain $\rm{SL}_2$ by factoring out the center. Note that our algebras are over the prime field ${\bf F}_{3}$, so the center is 2-dimensional (over ${\bf F}_{3}$). Notice that $\rm{SL}_2(9)$ has a trivial center but has a 2-dimensional centroid.

```magma
> SL2 := GL2/Center(GL2);
> SL2;
Algebra of dimension 6 with base ring GF(3)
> Center(SL2);
Algebra of dimension 0 with base ring GF(3)
> Centroid(SL2);
Matrix Algebra of degree 6 with 2 generators over GF(3)
```

<a id="function-leftnucleus-alg"></a>
#### `LeftNucleus(A): Alg -> AlgMat`

<a id="function-rightnucleus-alg"></a>
#### `RightNucleus(A): Alg -> AlgMat`

<a id="function-midnucleus-alg"></a>
#### `MidNucleus(A): Alg -> AlgMat`

Returns the nucleus of the algebra $A$ as a subalgebra of the enveloping algebra of right multiplication ${\cal R}(A)$.

<a id="function-derivationalgebra-alg"></a>
#### `DerivationAlgebra(A): Alg -> AlgMatLie`

Returns the derivation algebra of the algebra $A$ as a Lie subalgebra of $\rm{End}_K(A)$.

<a id="example-ex-8c0a5c"></a>
#### `Example: Derivation Algebra of the Octonions (ex-8c0a5c)`

We will compute the derivation algebra of the (rational) octonions $O$ and also the 27 dimension exceptional Jordan algebra ${\cal H}_3( O )$. Because the intrinsics use exact linear algebra, we do not use the more familiar field ${\mathbb{C}}$ in this context. First we consider $O$. We verify that $\rm{Der}( O )\cong G_2$.

```magma
> A := OctonionAlgebra(Rationals(), -1, -1, -1);
> A;
Algebra of dimension 8 with base ring Rational Field
> D := DerivationAlgebra(A);
> D;
Matrix Lie Algebra of degree 8 over Rational Field
> SemisimpleType(D);
G2
```

Now we will just briefly perform a sanity check and verify that `D` acts as it should.

```magma
> a := Random(Basis(A));
> b := Random(Basis(A));
> del := Random(Basis(D));
> (a*b)*del eq (a*del)*b + a*(b*del);
true
```

Finally, we construct ${\cal H}_3( O )$ the $3\times 3$ Hermitian matrices, and we verify that $\rm{Der}({\cal H}_3( O )\cong F_4$.

```magma
> J := ExceptionalJordanCSA(A);
> J;
Algebra of dimension 27 with base ring Rational Field
> D_J := DerivationAlgebra(J);
> Dimension(D_J);
52
> SemisimpleType(D_J);
F4
```

<a id="example-ex-a850f6"></a>
#### `Example: Further Invariants of Nonassociative Algebras (ex-a850f6)`

We demonstrate further how to use these functions to get invariants of nonassociative algebras. First, we will obtain the derivation Lie algebra of the Octonions, which are of type $G_2$.

```magma
> A := OctonionAlgebra(GF(7),-1,-1,-1);
> A;
Algebra of dimension 8 with base ring GF(7)
> D := DerivationAlgebra(A);
> D.1;
[0 0 0 0 0 0 0 0]
[0 0 6 0 6 3 2 1]
[0 1 0 3 4 1 1 3]
[0 0 4 0 6 4 2 3]
[0 1 3 1 0 6 2 0]
[0 4 6 3 1 0 6 2]
[0 5 6 5 5 1 0 4]
[0 6 4 4 0 5 3 0]
> Dimension(D);
14
> SemisimpleType(D);
G2
```

Now we will show that the left, mid, and right nuclei are all one dimensional. All of which are generated by $R_1$, multiplication by $1_A$.

```magma
> Z := Center(A);
> Z;
Algebra of dimension 1 with base ring GF(7)
>
> L := LeftNucleus(A);
> L;
Matrix Algebra of degree 8 with 1 generator over GF(7)
> L.1;
[1 0 0 0 0 0 0 0]
[0 1 0 0 0 0 0 0]
[0 0 1 0 0 0 0 0]
[0 0 0 1 0 0 0 0]
[0 0 0 0 1 0 0 0]
[0 0 0 0 0 1 0 0]
[0 0 0 0 0 0 1 0]
[0 0 0 0 0 0 0 1]
>
> L eq MidNucleus(A);
true
> L eq RightNucleus(A);
true
```

### Generic Operations

#### Nonassociative Algebras with Involutions

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

Decides if algebra has an involution, i.e. a $*$-algebra.

<a id="function-star-alggen"></a>
##### `Star(A): AlgGen -> Map`

Returns involution of given $*$-algebra.

<a id="example-ex-ffb750"></a>
##### `Example: Involutions of an Octonion Algebra (ex-ffb750)`

We demonstrate the functions dealing with involutions of nonassociative algebras.

```magma
> A := OctonionAlgebra(Rationals(),-1,-1,-1);
> IsStarAlgebra(A);
true
>
> s := Star(A);
> A.1; // A.1 is the mult. id.
(1 0 0 0 0 0 0 0)
> A.1 @ s;
(1 0 0 0 0 0 0 0)
>
> A.2;
(0 1 0 0 0 0 0 0)
> A.2 @ s;
( 0 -1  0  0  0  0  0  0)
```

#### Operations on Power Associative Algebras

The following operations are defined for nonassociative algebras for which $x*(x*x)=(x*x)*x$.

<a id="function-genericminimalpolynomial-alggenelt"></a>
##### `GenericMinimalPolynomial(x): AlgGenElt -> FldElt`

The generic minimum polynomial of an element in a power associative algebra.

<a id="function-genericnorm-alggenelt"></a>
##### `GenericNorm(x): AlgGenElt -> FldElt`

The generic norm of an element in a power associative algebra.

<a id="function-generictrace-alggenelt"></a>
##### `GenericTrace(x): AlgGenElt -> FldElt`

The generic trace of an element in a power associative algebra.

<a id="function-generictracelesssubspacebasis-alggen"></a>
##### `GenericTracelessSubspaceBasis(A): AlgGen -> Any`

Given a power associative algebra return a basis for the elements of generic trace 0.

<a id="example-ex-099024"></a>
##### `Example: Generic Trace of a Quaternion (ex-099024)`

The trace $x+\bar{x}$ of a quaternion doubles the rational component, producing degenerate behavior in characteristic $2$. The generic trace avoids this.

```magma
> Q := QuaternionAlgebra(Rationals(), 1,1);
> Trace(Q!1);
2
> GenericTrace(Q!1);
1
> Q := QuaternionAlgebra(GF(2), 1,1);
> Trace(Q!1);
0
> GenericTrace(Q!1);
1
```

The generic minimum polynomial of an element $x$ in power associative algebra need only be a factor of the minimal polynomial of its right regular matrix $yR_x:=x*y$.

```magma
> J := ExceptionalJordanCSA(GF(5));
> p := GenericMinimumPolynomial(J.3+J.12);
> Rx := AsMatrices(Tensor(J), 2,0);     // yR_x = y*x.
> q := MinimalPolynomial(Rx[3]+Rx[12]);
> Degree(p);
3
> Degree(q);
6
> q mod p;
0
```
