---
title: "Construction of General Algebras and their Elements"
canonical: "https://docs.magma-maths.org/v2.30-1/Algebras/IntroductionToAlgebras/creation.html"
source: "https://docs.magma-maths.org/v2.30-1/Algebras/IntroductionToAlgebras/creation.md"
part: "Algebras"
chapter: "Algebras"
breadcrumbs:
  - {"title": "Magma Handbook", "source": "https://docs.magma-maths.org/v2.30-1/index.md"}
  - {"title": "Algebras", "source": "https://docs.magma-maths.org/v2.30-1/Algebras/index-algebras.md"}
  - {"title": "Algebras", "source": "https://docs.magma-maths.org/v2.30-1/Algebras/IntroductionToAlgebras/index-introduction-to-algebras.md"}
prev: {"title": "Introduction", "source": "https://docs.magma-maths.org/v2.30-1/Algebras/IntroductionToAlgebras/introduction.md"}
next: {"title": "Construction of Subalgebras, Ideals, and Quotient Algebras", "source": "https://docs.magma-maths.org/v2.30-1/Algebras/IntroductionToAlgebras/subs-quos.md"}
intrinsics:
  - {"name": "Algebra", "signature": "Algebra< R, n | Q >: Rng, RngIntElt, SeqEnum -> AlgGen"}
  - {"name": "AssociativeAlgebra", "signature": "AssociativeAlgebra< R, n | Q >: Rng, RngIntElt, SeqEnum -> AlgAss"}
  - {"name": "QuaternionAlgebra", "signature": "QuaternionAlgebra< K | a, b >: Rng, RngElt, RngElt -> AlgQuat"}
  - {"name": "LieAlgebra", "signature": "LieAlgebra< R, n | Q >: Rng, RngIntElt, SeqEnum -> AlgLie"}
  - {"name": "LieAlgebra", "signature": "LieAlgebra(A): AlgAss -> AlgLie"}
  - {"name": "GroupAlgebra", "signature": "GroupAlgebra(R, G): Rng, Grp -> AlgGrp"}
  - {"name": "MatrixAlgebra", "signature": "MatrixAlgebra(R, n): Rng, RngInt -> AlgMat"}
  - {"name": "Zero", "signature": "Zero(A): AlgGen -> AlgGenElt"}
  - {"name": "!", "signature": "A ! 0: AlgGen, RngIntElt -> AlgGenElt"}
  - {"name": "One", "signature": "One(A): AlgGen -> AlgGenElt"}
  - {"name": "!", "signature": "A ! 1: AlgGen, RngIntElt -> AlgGenElt"}
  - {"name": "Random", "signature": "Random(A): AlgGen -> AlgGenElt"}
---

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