# Roots and Coroots

The roots are stored as an indexed set

$$
\{@\; \alpha_1,\dots,\alpha_N,\alpha_{N+1},\dots,\alpha_{2N} \; @\},
$$

where $\alpha_1,\dots,\alpha_N$ are the positive roots (in an order compatible with height), and $\alpha_{N+1},\dots,\alpha_{2N}$ are the corresponding negative roots (i.e. $\alpha_{i+N}=-\alpha_i$). The simple roots are $\alpha_1,\dots,\alpha_n$ where $n$ is the rank.

Many of these functions have an optional argument `Basis` which may take one of the following values

1. `"Standard"`: the standard basis for the (co)root space (this is the default); or

2. `"Root"`: the basis of simple (co)roots.

## Accessing Roots and Coroots

### `RootSpace(R): RootSys -> ModTupFld`

### `CorootSpace(R): RootSys -> ModTupFld`

The vector space containing the (co)roots of the root system $R$, i.e. $X$ (respectively, $Y$).

### `SimpleRoots(R): RootSys -> Mtrx`

### `SimpleCoroots(R): RootSys -> Mtrx`

The simple (co)roots of the root system $R$ as the rows of a matrix, i.e. $A$ (respectively, $B$).

### `Example: Root Space (ex-fe8350)`

```magma
> R := RootSystem("G2");
> RootSpace(R);
Full Vector space of degree 2 over Rational Field
> CorootSpace(R);
Full Vector space of degree 2 over Rational Field
> SimpleRoots(R);
[1 0]
[0 1]
> SimpleCoroots(R);
[ 2 -3]
[-1  2]
> CartanMatrix(R);
[ 2 -1]
[-3  2]

```

### `NumberOfPositiveRoots(R): RootSys -> RngIntElt`

### `NumPosRoots(R): RootSys -> RngIntElt`

The number of positive roots of the root system $R$. This is also the number of positive coroots. The total number of (co)roots is twice the number of positive (co)roots.

### `Roots(R): RootSys -> SetIndx`

### `Coroots(R): RootSys -> SetIndx`

```magma
Basis: MonStgElt                    Default: "Standard"
```

The indexed set of (co)roots of the root system $R$, i.e. $\{@\,\alpha_1,\dots\alpha_{2N}\,@\}$ (respectively, $\{@\,\alpha_1^\star,\dots\alpha_{2N}^\star\,@\}$).

### `PositiveRoots(R): RootSys -> SetIndx`

### `PositiveCoroots(R): RootSys -> SetIndx`

```magma
Basis: MonStgElt                    Default: "Standard"
```

The indexed set of positive (co)roots of the root system $R$, i.e. $\{@\,\alpha_1,\dots\alpha_N\,@\}$ (respectively, $\{@\,\alpha_1^\star,\dots\alpha_N^\star\,@\}$).

### `Root(R, r): RootSys, RngIntElt -> SetIndx`

### `Coroot(R, r): RootSys, RngIntElt -> SetIndx`

```magma
Basis: MonStgElt                    Default: "Standard"
```

The $r$th (co)root $\alpha_r$ (respectively, $\alpha_r^\star$) of the root system $R$.

### `RootPosition(R, v): RootSys, . -> SetIndx`

### `CorootPosition(R, v): RootSys, . -> SetIndx`

```magma
Basis: MonStgElt                    Default: "Standard"
```

If $v$ is a (co)root in the root system $R$, return its index; otherwise return 0. These functions will try to coerce $v$, which can be a vector or a sequence representing a vector, into the appropriate vector space; $v$ should be written with respect to the basis specified by the parameter `Basis`.

### `Example: Roots Coroots (ex-89c0a9)`

```magma
> A := Matrix(2,3, [1,-1,0, -1,1,-1]);
> B := Matrix(2,3, [1,-1,1, 0,1,-1]);
> R := RootSystem(A, B);
> Roots(R);
{@
    (1 -1  0),
    (-1  1 -1),
    (0  0 -1),
    (1 -1 -1),
    (2 -2 -1),
    (1 -1 -2),
    (-1  1  0),
    (1 -1  1),
    (0 0 1),
    (-1  1  1),
    (-2  2  1),
    (-1  1  2)
@}
> PositiveCoroots(R);
{@
    (1 -1  1),
    (0  1 -1),
    (1  2 -2),
    (2  1 -1),
    (1 0 0),
    (1  1 -1)
@}
> #Roots(R) eq 2*NumPosRoots(R);
true
> Root(R, 4);
(1 -1 -1)
> Root(R, 4 : Basis := "Root");
(2 1)
> RootPosition(R, [1,-1,-1]);
4
> RootPosition(R, [2,1] : Basis := "Root");
4

```

### `HighestRoot(R): RootSys -> .`

### `HighestCoroot(R): RootSys -> .`

```magma
Basis: MonStgElt                    Default: "Standard"
```

The unique (co)root of greatest height in the irreducible root system $R$.

### `HighestLongRoot(R): RootSys -> .`

### `HighestLongCoroot(R): RootSys -> .`

```magma
Basis: MonStgElt                    Default: "Standard"
```

The unique long (co)root of greatest height in the irreducible root system $R$.

### `HighestShortRoot(R): RootSys -> .`

### `HighestShortCoroot(R): RootSys -> .`

```magma
Basis: MonStgElt                    Default: "Standard"
```

The unique short (co)root of greatest height in the irreducible root system $R$.

### `Example: Heighest Roots (ex-77bd29)`

```magma
> R := RootSystem("G2");
> HighestRoot(R);
(3 2)
> HighestLongRoot(R);
(3 2)
> HighestShortRoot(R);
(2 1)

```

### `CoxeterForm(R): RootSys -> AlgMatElt`

### `DualCoxeterForm(R): RootSys -> AlgMatElt`

```magma
Basis: MonStgElt                    Default: "Standard"
```

The matrix of an inner product on the (co)root space of the root system $R$ which is invariant under the action of the (co)roots. This inner product is uniquely determined up to a constant on each irreducible component of $R$. The inner product is normalised so that the short roots in each crystallographic component have length one.

## Reflections

The root $\alpha$ acts on the root space via the reflection $s_\alpha$; the coroot $\alpha^\star$ acts on the coroot space via the coreflection $s_\alpha^\star$.

### `SimpleReflectionMatrices(R): RootSys -> []`

### `SimpleCoreflectionMatrices(R): RootSys -> []`

```magma
Basis: MonStgElt                    Default: "Standard"
```

The sequence of matrices giving the action of the simple (co)roots of the root system $R$ on the (co)root space, i.e. the matrices of $s_{\alpha_1},\dots,s_{\alpha_n}$ (respectively, $s_{\alpha_1}^\star,\dots,s_{\alpha_n}^\star$).

### `ReflectionMatrices(R): RootSys -> []`

### `CoreflectionMatrices(R): RootSys -> []`

```magma
Basis: MonStgElt                    Default: "Standard"
```

The sequence of matrices giving the action of the (co)roots of the root system $R$ on the (co)root space, i.e. the matrices of $s_{\alpha_1},\dots,s_{\alpha_{2N}}$ (respectively, $s_{\alpha_1}^\star,\dots,s_{\alpha_{2N}}^\star$).

### `ReflectionMatrix(R, r): RootSys, RngIntElt -> []`

### `CoreflectionMatrix(R, r): RootSys, RngIntElt -> []`

```magma
Basis: MonStgElt                    Default: "Standard"
```

The matrix giving the action of the $r$th (co)root of the root system $R$ on the (co)root space, i.e. the matrix of $s_{\alpha_r}$ (respectively, $s_{\alpha_r}^\star$).

### `SimpleReflectionPermutations(R): RootSys -> []`

The sequence of permutations giving the action of the simple (co)roots of the root system $R$ on the (co)roots. This action is the same for roots and coroots.

### `ReflectionPermutations(R): RootSys -> []`

The sequence of permutations giving the action of the (co)roots of the root system $R$ on the (co)roots. This action is the same for roots and coroots.

### `ReflectionPermutation(R, r): RootSys, RngIntElt -> []`

The permutation giving the action of the $r$th (co)root of the root system $R$ on the (co)roots. This action is the same for roots and coroots.

### `ReflectionWords(R): RootSys -> []`

The sequence of words in the simple reflections for all the reflections of the root system $R$. These words are given as sequences of integers. In other words, if $[a_1,\dots,a_l] = \hbox{\tt ReflectionWords(R)[r]}$, then $s_{\alpha_r} = s_{\alpha_{a_1}} \cdots s_{\alpha_{a_l}}$.

### `ReflectionWord(R, r): RootSys, RngIntElt -> []`

The word in the simple reflections for the $r$th reflection of the root system $R$. The word is given as a sequence of integers. In other words, if $[a_1,\dots,a_l] = \hbox{\tt ReflectionWord(R,r)}$, then $s_{\alpha_r} = s_{\alpha_{a_1}} \cdots s_{\alpha_{a_l}}$.

### `Example: Action (ex-a58034)`

```magma
> R := RootSystem("B3");
> mx := ReflectionMatrix(R, 4);
> perm := ReflectionPermutation(R, 4);
> wd := ReflectionWord(R, 4);
> RootPosition(R, Root(R,2) * mx) eq 2^perm;
true
> perm eq &*[ ReflectionPermutation(R, r) : r in wd ];
true
>
> mx := CoreflectionMatrix(R, 4);
> CorootPosition(R, Coroot(R,2) * mx) eq 2^perm;
true

```

## Operations and Properties for Roots and Coroot Indices

### `Sum(R, r, s): RootSys, RngIntElt, RngIntElt -> RngIntElt`

The index of the sum of the $r$th and $s$th roots in the crystallographic root system $R$, or 0 if the sum is not a root. In other words, if $t = \hbox{\tt Sum(R,r,s)} \ne 0$ then $\alpha_t=\alpha_r+\alpha_s$. We require $\alpha_r\ne\pm\alpha_s$.

### `IsPositive(R, r): RootSys, RngIntElt -> BoolElt`

Returns `true` if, and only if, the $r$th (co)root of the root system $R$ is a positive root.

### `IsNegative(R, r): RootSys, RngIntElt -> BoolElt`

Returns `true` if, and only if, the $r$th (co)root of the root system $R$ is a negative root.

### `Negative(R, r): RootSys, RngIntElt -> RngIntElt`

The index of the negative of the $r$th (co)root of the root system $R$. In other words, if $s = \hbox{\tt Negative(R,r)}$ then $\alpha_s=-\alpha_r$.

### `Example: Root Arithmetic (ex-8a578c)`

```magma
> R := RootSystem("G2");
> Sum(R, 1, Negative(R,5));
10
> IsPositive(R, 10);
false
> Negative(R, 10);
4
> P := PositiveRoots(R);
> P[1] - P[5] eq -P[4];
true

```

### `RootHeight(R, r): RootSys, RngIntElt -> RngIntElt`

### `CorootHeight(R, r): RootSys, RngIntElt -> RngIntElt`

The height of the $r$th (co)root of the root system $R$, i.e. the sum of the coefficients of $\alpha_r$ (respectively, $\alpha_r^\star$) with respect to the simple (co)roots.

### `RootNorms(R): RootSys -> [RngIntElt]`

### `CorootNorms(R): RootSys -> [RngIntElt]`

The sequence of squares of the lengths of the (co)roots of the root system $R$.

### `RootNorm(R, r): RootSys, RngIntElt -> RngIntElt`

### `CorootNorm(R, r): RootSys, RngIntElt -> RngIntElt`

The square of the length of the $r$th (co)root of the root system $R$.

### `IsLongRoot(R, r): RootSys, RngIntElt -> BoolElt`

Returns `true` if, and only if, the $r$th root of the root system $R$ is long. This only makes sense for irreducible crystallographic root systems. Note that for non-reduced root systems, the roots which are not indivisible are actually longer than the long ones.

### `IsShortRoot(R, r): RootSys, RngIntElt -> BoolElt`

Returns `true` if, and only if, the $r$th root of the root system $R$ is short. This only makes sense for irreducible crystallographic root systems.

### `IsIndivisibleRoot(R, r): RootSys, RngIntElt -> BoolElt`

Returns `true` if, and only if, the $r$th root of the root system $R$ is indivisible, ie, $\alpha_r/2$ is not a root.

### `LeftString(R, r, s): RootSys, RngIntElt, RngIntElt -> RngIntElt`

Indices in the crystallographic root system $R$ of the left string through $\alpha_s$ in the direction of $\alpha_r$, i.e. the indices of $\alpha_s-\alpha_r,\alpha_s-2\alpha_r,\dots,\alpha_s-p\alpha_r$. In other words, this returns the sequence $[r_1,\dots,r_p]$ where $\alpha_{r_i}=\alpha_s-i\alpha_r$ and $\alpha_s-(p+1)\alpha_r$ is not a root. We require that $\alpha_r\ne\pm\alpha_s$.

### `RightString(R, r, s): RootSys, RngIntElt, RngIntElt -> RngIntElt`

Indices in the crystallographic root system $R$ of the left string through $\alpha_s$ in the direction of $\alpha_r$, i.e. the indices of $\alpha_s+\alpha_r,\alpha_s+2\alpha_r,\dots,\alpha_s+q\alpha_r$. In other words, this returns the sequence $[r_1,\dots,r_q]$ where $\alpha_{r_i}=\alpha_s+i\alpha_r$ and $\alpha_s+(q+1)\alpha_r$ is not a root. We require that $\alpha_r\ne\pm\alpha_s$.

### `LeftStringLength(R, r, s): RootSys, RngIntElt, RngIntElt -> RngIntElt`

The largest $p$ such that $\alpha_s-p\alpha_r$ is a root. We require that the root system $R$ be crystallographic and $\alpha_s\ne\pm\alpha_r$.

### `RightStringLength(R, r, s): RootSys, RngIntElt, RngIntElt -> RngIntElt`

The largest $q$ such that $\alpha_s+q\alpha_r$ is a root. We require that the root system $R$ be crystallographic and $\alpha_s\ne\pm\alpha_r$.

### `Example: Root Operations (ex-e2515b)`

```magma
> R := RootSystem("G2");
> RootHeight(R, 5);
4
> F := CoxeterForm(R);
> v := Root(R, 5);
> (v*F, v) eq RootNorm(R, 5);
true
> IsLongRoot(R, 5);
true
> LeftString(R, 1, 5);
[ 4, 3, 2 ]
> roots := Roots(R);
> for i in [1..3] do
>   RootPosition(R, roots[5]-i*roots[1]);
> end for;
4
3
2
> R := RootSystem("BC2");
> Root(R,2), IsIndivisibleRoot(R,2);
(0 1) true
> Root(R,4), IsIndivisibleRoot(R,4);
(0 2) false

```

### `AdditiveOrder(R): RootSys -> SeqEnum`

An additive order on the positive roots of the root system $R$, i.e. a sequence containing the numbers $1,\dots,N$ in some order so that $\alpha_r+\alpha_s=\alpha_t$ implies $t$ is between $r$ and $s$. This is computed using the techniques of [[Papi, 1994](../../references.md#cite-papi)].

### `IsAdditiveOrder(R, Q): RootSys, [RngIntElt] -> BoolElt`

Returns `true` if, and only if, the sequence $Q$ gives an additive order on a set of positive roots of the root system $R$. $Q$ must be a sequence of integers in the range $[1..N]$, where $N$ is the number of positive roots of $R$, with no gaps or repeats.

### `Example: Additive Order (ex-20f94b)`

```magma
> R := RootSystem("A5");
> a := AdditiveOrder(R);
> Position(a, 2);
6
> Position(a, 3);
10
> Position(a, Sum(R, 2, 3));
7

```
