# Finite Dimensional Affine Algebras

If an affine algebra is defined over a field and has finite dimension considered as a vector space over its coefficient field, extra special operations are available on its elements. Similar operations for affine algebras defined over general Euclidean rings will be supported in the future.

## `HasFiniteDimension(Q): RngMPolRes -> BoolElt`

Given an affine algebra $Q$ defined over a field, return whether $Q$ has finite dimension.

## `Dimension(Q): RngMPolRes -> RngIntElt`

Given a finite dimensional affine algebra $Q$ defined over a field, return the dimension of $Q$.

## `VectorSpace(Q): RngMPolRes -> ModTupFld, Map`

Given a finite dimensional affine algebra $Q$ defined over a field, construct the vector space $V$ isomorphic to $Q$, and return $V$ together with the isomorphism $f$ from $Q$ onto $V$.

## `MonomialBasis(Q): RngMPolRes -> [ RngMPolResElt ]`

Given a finite dimensional affine algebra $Q$ defined over a field, return the basis $B$ of monomials of $Q$. This is a sequence of monomials in $Q$ of length $d$, such that the image $f(B[i])=V.i$ where $V$ and $f$ are the return values of `VectorSpace` above.

## `MatrixAlgebra(Q): RngMPolRes -> AlgMat, Map`

Given a finite dimensional affine algebra $Q$ defined over a field, construct the matrix algebra $A$ isomorphic to $Q$, and return $A$ together with the isomorphism $f$ from $Q$ onto $A$.

## `RepresentationMatrix(f): RngMPolResElt -> AlgMatElt`

Given an element $f$ of a finite dimensional affine algebra $Q$ defined over a field, return the representation matrix of $f$, which is a $d$ by $d$ matrix over the coefficient field of $Q$ (where $d$ is the dimension of $Q$) which represents $f$.

## `IsUnit(f): RngMPolResElt -> BoolElt`

Given an element $f$ of a finite dimensional affine algebra $Q$ defined over a field, return whether $f$ is a unit.

## `IsNilpotent(f): RngMPolResElt -> BoolElt, RngIntElt`

Given an element $f$ of a finite dimensional affine algebra $Q$ defined over a field, return whether $f$ is nilpotent, and if so, return also the smallest $q$ such that $f^q = 0$.

## `MinimalPolynomial(f): RngMPolResElt -> RngUPol`

Given an element $f$ of a finite dimensional affine algebra $Q$ defined over a field, return the minimal polynomial of $f$ as a univariate polynomial over the coefficient field of $Q$.

## `Example: Minimal Polynomial (ex-caec0e)`

Suppose we wish to find the minimal polynomial of $\theta = \sqrt 2 + \root 3 \of 5$ over ${\mathbb{Q}}$. To do this we can just compute the minimal polynomial of (the coset of) $x + y$ over ${\mathbb{Q}}$ in the affine algebra $Q[x, y]/(x^2 - 2, y^3 - 5)$.

```magma
> Q := RationalField();
> A<x, y> := AffineAlgebra<Q, x, y | x^2 - 2, y^3 - 5>;
> UP<z> := PolynomialRing(Q);
> MinimalPolynomial(x + y);
z^6 - 6*z^4 - 10*z^3 + 12*z^2 - 60*z + 17

```
