# Operations on Elements

See Chapter [Finitely Presented Groups](../../FinitelyPresentedGroups/FPGroups/index-fpgroups.md#chapgrpfp) for general functions for finitely presented groups or Chapter [Permutation Groups](../../FiniteGroups/PermutationGroups/index-permutation-groups.md#chapgrpperm) for general functions for permutation groups.

Unlike groups of type `GrpFP`, elements of a group of type `GrpFPCox` are always converted into the normal form of Section [The Normal Form for Words](introduction.md#subsectgrpcoxred).

## `Example: Word Arithmetic (ex-8999bf)`

Arithmetic with words.

```magma
> W<[s]> := CoxeterGroup(GrpFPCox, "G2");
> w1 := W![2,1,2,1,2] ;
> w1;
s[2] * s[1] * s[2] * s[1] * s[2]
> w2 := W![1,2,2,1,2,1];
> w2;
s[2] * s[1]
> w1 * w2;
s[1] * s[2] * s[1]
> W![1,2,1,2,1,2] eq W![2,1,2,1,2,1];
true

```

## `# w: GrpFPCoxElt -> RngIntElt`

## `Length(w): GrpFPCoxElt -> RngIntElt`

## `Length(W, w): GrpPermCox, GrpPermElt -> RngIntElt`

## `CoxeterLength(w): GrpFPCoxElt -> RngIntElt`

## `CoxeterLength(W, w): GrpPermCox, GrpPermElt -> RngIntElt`

The length of $w$ as an element of the Coxeter group $W$, ie. the number of positive roots of $W$ which become negative under the action of $w$. The # operator does not work for permutation Coxeter group elements.

## `LongestElement(W): GrpFPCox -> SeqEnum`

## `LongestElement(W): GrpPermCox -> GrpPermElt`

The unique longest element of the Coxeter group $W$.

## `CoxeterElement(W): GrpFPCox -> SeqEnum`

## `CoxeterElement(W): GrpPermCox -> GrpPermElt`

The Coxeter element of the Coxeter group $W$, ie. the product of the generators of $W$.

## `CoxeterNumber(W): GrpFPCox -> SeqEnum`

## `CoxeterNumber(W): GrpPermCox -> GrpPermElt`

The Coxeter number of the irreducible Coxeter group $W$ (see [[Carter, 1993](../../references.md#cite-carter-big), page 20]).

## `Example: Longest Coxeter Elements (ex-ba43d4)`

```magma
> W<[s]> := CoxeterGroup(GrpFPCox, "F4");
> LongestElement(W);
s[1] * s[2] * s[1] * s[3] * s[2] * s[1] * s[3] * s[2] * s[3] * s[4] * s[3] *
s[2] * s[1] * s[3] * s[2] * s[3] * s[4] * s[3] * s[2] * s[1] * s[3] * s[2] *
s[3] * s[4]
> CoxeterElement(W);
s[1] * s[2] * s[3] * s[4]
> W := CoxeterGroup("E8");
> Length(W, LongestElement(W));
120
> Length(W, CoxeterElement(W));
8

```

The Coxeter number can be described in a variety of ways.

```magma
> W := CoxeterGroup("D5");
> CoxeterNumber(W) eq Order(CoxeterElement(W));
true
> CoxeterNumber(W) eq #Roots(W) / Rank(W);
true
> R := RootDatum(W);
> CoxeterNumber(W) eq &+Eltseq(HighestRoot(R)) + 1;
true

```

## `LeftDescentSet(W, w): GrpFPCox, GrpFPCoxElt -> SetEnum`

## `LeftDescentSet(W, w): GrpPermCox, GrpPermElt -> SetEnum`

The set of indices $r$ of simple roots of the Coxeter group $W$ such that the length of the product $s_rw$ is less than that of the element $w$.

## `RightDescentSet(W, w): GrpFPCox, GrpFPCoxElt -> SetEnum`

## `RightDescentSet(W, w): GrpPermCox, GrpPermElt -> SetEnum`

The set of indices $r$ of simple roots of the Coxeter group $W$ such that the length of the product $ws_r$ is less than that of the element $w$.

## `Example: Descent Sets (ex-e2a89d)`

```magma
> W := CoxeterGroup("A5");
> x := W.1*W.2*W.4*W.5;
> LeftDescentSet(W, x);
{ 1, 4 }
> RightDescentSet(W, x);
{ 2, 5 }

```
