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

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

## `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]$.

## `IsEtale(A): AlgMat -> BoolElt, AlgMatElt`

A $k$-algebra $A$ is étale ([[Bourbaki, 2003](../../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`.

## `Diagonalisation(Q): [AlgMatElt] -> [AlgMatElt], AlgMatElt`

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

## `Diagonalisation(A): AlgMat -> AlgMat, AlgMatElt`

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

## `Diagonalisation(M): AlgMatElt -> AlgMatElt, AlgMatElt`

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

## `IsDiagonalisable(M): AlgMatElt -> Boolelt, AlgMatElt, AlgMatElt`

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

## `Example: Diagonalization (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]

```

## `Example: Is Diagonalizablex (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]

```
