---
title: "Elements"
canonical: "https://docs.magma-maths.org/v2.30-1/FinitelyPresentedGroups/AbelianGroups/elements.html"
source: "https://docs.magma-maths.org/v2.30-1/FinitelyPresentedGroups/AbelianGroups/elements.md"
part: "Finitely Presented Groups"
chapter: "Abelian Groups"
breadcrumbs:
  - {"title": "Magma Handbook", "source": "https://docs.magma-maths.org/v2.30-1/index.md"}
  - {"title": "Finitely Presented Groups", "source": "https://docs.magma-maths.org/v2.30-1/FinitelyPresentedGroups/index-finitely-presented-groups.md"}
  - {"title": "Abelian Groups", "source": "https://docs.magma-maths.org/v2.30-1/FinitelyPresentedGroups/AbelianGroups/index-abelian-groups.md"}
prev: {"title": "Construction of a Generic Abelian Group", "source": "https://docs.magma-maths.org/v2.30-1/FinitelyPresentedGroups/AbelianGroups/generic-abelian.md"}
next: {"title": "Construction of Subgroups and Quotient Groups", "source": "https://docs.magma-maths.org/v2.30-1/FinitelyPresentedGroups/AbelianGroups/subgroup-quotient.md"}
intrinsics:
  - {"name": "!", "signature": "A ! [a₁, ... ,aₙ]: GrpAb, [RngIntElt] -> GrpAbElt"}
  - {"name": "!", "signature": "A ! [a₁, ... ,aₙ]: GrpAbGen, [RngIntElt] -> GrpAbGenElt"}
  - {"name": "!", "signature": "A ! e: GrpAbGen, Elt -> GrpAbGenElt"}
  - {"name": "!", "signature": "A ! g: GrpAbGen, GrpAbGenElt -> GrpAbGenElt"}
  - {"name": "!", "signature": "A ! n: GrpAb, RngIntElt -> GrpAbElt"}
  - {"name": "Random", "signature": "Random(A): GrpAbGen -> GrpAbGenElt"}
  - {"name": "Identity", "signature": "Identity(A): GrpAb -> GrpAbElt"}
  - {"name": "Id", "signature": "Id(A): GrpAb -> GrpAbElt"}
  - {"name": "!", "signature": "A ! 0: GrpAb, RngIntElt -> GrpAbElt"}
  - {"name": "Representation", "signature": "Representation(g): GrpAbGenElt -> [RngIntElt]"}
  - {"name": "ElementToSequence", "signature": "ElementToSequence(g): GrpAbGenElt -> [RngIntElt]"}
  - {"name": "Eltseq", "signature": "Eltseq(g): GrpAbGenElt -> [RngIntElt]"}
  - {"name": "UserRepresentation", "signature": "UserRepresentation(g): GrpAbGenElt -> [RngIntElt]"}
  - {"name": "Representation", "signature": "Representation(S, g): SeqEnum, GrpAbGenElt -> [RngIntElt], RngIntElt"}
  - {"name": "+", "signature": "u + v: GrpAbElt, GrpAbElt -> GrpAbElt"}
  - {"name": "-", "signature": "- u: GrpAbElt -> GrpAbElt"}
  - {"name": "-", "signature": "u - v: GrpAbElt, GrpAbElt -> GrpAbElt"}
  - {"name": "*", "signature": "m * u: RngIntElt, GrpAbElt -> GrpAbElt"}
  - {"name": "*", "signature": "u * m: GrpAb, RngIntElt -> GrpAbElt"}
examples:
  - "ex-f86c65"
---

# Elements

## Construction of Elements

Unless otherwise stated, the operations in this section apply to fp-abelian groups and generic abelian groups.

<a id="operation-op-grpab-rngintelt"></a>
### `A ! [a₁, ... ,aₙ]: GrpAb, [RngIntElt] -> GrpAbElt`

<a id="operation-op-grpabgen-rngintelt"></a>
### `A ! [a₁, ... ,aₙ]: GrpAbGen, [RngIntElt] -> GrpAbGenElt`

Given an abelian group $A$ with generators $e_1, \ldots, e_r$ and a sequence $Q = [a_1, \cdots, a_r]$ of integers, construct the element $a_1 e_1 + \cdots + a_r e_r$ of $A$.

<a id="operation-op-grpabgen-elt"></a>
### `A ! e: GrpAbGen, Elt -> GrpAbGenElt`

Given a generic abelian group $A$ and an element $e$ of the domain over which it is defined, return $e$ as an element of $A$. If $A$ is a proper subset of its underlying domain, then $e$ must be a linear combination of the generators (which may be user-supplied) of $A$.

<a id="operation-op-grpabgen-grpabgenelt"></a>
### `A ! g: GrpAbGen, GrpAbGenElt -> GrpAbGenElt`

Given a generic abelian group $A$ and an element $g$ of the underlying set $X$ of $A$, return $g$ as an element of $A$.

<a id="operation-op-grpab-rngintelt-2"></a>
### `A ! n: GrpAb, RngIntElt -> GrpAbElt`

Given an abelian group $A$ with exactly one generator $x$, construct the element $n x$.

<a id="function-random-grpabgen"></a>
### `Random(A): GrpAbGen -> GrpAbGenElt`

Given either a finite fp-abelian group or a generic abelian group $A$, return a random element of $A$.

<a id="function-identity-grpab"></a>
### `Identity(A): GrpAb -> GrpAbElt`

<a id="function-id-grpab"></a>
### `Id(A): GrpAb -> GrpAbElt`

<a id="operation-op-grpab-rngintelt-3"></a>
### `A ! 0: GrpAb, RngIntElt -> GrpAbElt`

Construct the identity element (empty word) for the abelian group $A$.

Let $A$ be a generic abelian group defined in the universe $U$ of $A$. If $g$ is an element of $A$, then $U!g$ is an element of $U$.

## Representation of an Element

An element $g$ of an abelian group $A$ can be represented as a linear combination with respect to a given generating sequence. The coefficients appearing in this linear combination provide an alternative representation for $g$. If $A$ is a fp-group, the generating set will be the one on which the group was defined. In the case of a generic group, the generating set can either be that obtained when constructing a presentation for $A$ or a user-supplied generating set.

<a id="function-representation-grpabgenelt"></a>
### `Representation(g): GrpAbGenElt -> [RngIntElt]`

<a id="function-elementtosequence-grpabgenelt"></a>
### `ElementToSequence(g): GrpAbGenElt -> [RngIntElt]`

<a id="function-eltseq-grpabgenelt"></a>
### `Eltseq(g): GrpAbGenElt -> [RngIntElt]`

Let $A$ be an abelian group with generating set $e_1, \ldots, e_n$ and suppose $g$ is an element of $A$, where $g = a_1 e_1 + \ldots + a_n e_n$. These functions return the sequence $Q$ of $n$ integers defined by $Q[i] = {a_i}$, for $i = 1,\ldots,n$. Moreover, each $a_i$, $i = 1,\ldots,n$, is the integer residue modulus the order of the $i$th generator.

<a id="function-userrepresentation-grpabgenelt"></a>
### `UserRepresentation(g): GrpAbGenElt -> [RngIntElt]`

Let $A$ be a generic abelian group with a user-supplied set of generators $u_1, \ldots, u_n$ and suppose $g$ is an element of $A$, where $g = a_1 u_1 + \ldots + a_n u_n$. This function returns the sequence $Q$ of $n$ integers defined by $Q[i] = {a_i}$, for $i = 1,\ldots,n$. Moreover, each $a_i$, $i = 1,\ldots,n$, is the integer residue modulus the order of the $i$th generator.

<a id="function-representation-seqenum-grpabgenelt"></a>
### `Representation(S, g): SeqEnum, GrpAbGenElt -> [RngIntElt], RngIntElt`

Let $A$ be a generic abelian group and let $S = [s_1, \dots, s_m]$ be any sequence of elements of $A$. Assume $g$ is an element of $A$ such that $b g = a_1 s_1 + \ldots + a_m s_m$. This function returns as its first value the sequence $Q$ of $m$ integers defined by $Q[i] = {a_i}$, for $i = 1,\ldots,m$. The second value returned is the coefficient $b$ of $g$. Note that $b$ might not be 1.

<a id="example-ex-f86c65"></a>
### `Example: Creating and Representing Elements (ex-f86c65)`

We use the quadratic forms example considered above to illustrate these functions.

```magma
> Generators(QF);
[ <2,2,500001>, <206,-102,4867> ]
> g := QF ! [5, 6];
> g;
<837,-766,1370>
> Representation(g);
[ 1, 6 ]
>
> g := Random(QF);
> Representation(g);
[ 1, 270 ]
>
> UserRepresentation(g);
[ 377, 0, 515, 0, 0, 0, 0, 0, 0, 0 ]
>
> S := [];
> for i in [1..3] do
>     d := Random(QF);
>     Include(~S, d);
> end for;
> seq, coeff := Representation(S, g);
> seq; coeff;
[ -170, -3, 0 ]
1
```

## Arithmetic with Elements

If the generic abelian group $A$ has been constructed with the flag `UseRepresentation` set true, then arithmetic with elements of $A$ is trivial.

<a id="operation-op-plus-grpabelt-grpabelt"></a>
### `u + v: GrpAbElt, GrpAbElt -> GrpAbElt`

Given elements $u$ and $v$ belonging to the same abelian group $A$, return the sum of $u$ and $v$.

<a id="operation-operation-grpabelt-grpabelt"></a>
### `- u: GrpAbElt -> GrpAbElt`

The inverse of element $u$.

<a id="operation-op-minus-grpabelt-grpabelt"></a>
### `u - v: GrpAbElt, GrpAbElt -> GrpAbElt`

Given elements $u$ and $v$ belonging to the same abelian group $A$, return the sum of $u$ and the inverse of $v$.

<a id="operation-op-times-rngintelt-grpabelt"></a>
### `m * u: RngIntElt, GrpAbElt -> GrpAbElt`

<a id="operation-op-times-grpab-rngintelt"></a>
### `u * m: GrpAb, RngIntElt -> GrpAbElt`

Given an integer $m$, return the element $w+w+\cdots w$ ($|m|$ summands), where $w = u$, if $m$ is positive and $w = -u$ if $m$ is negative.
