Creation Functions
Creation of Structures
The ring of integers is automatically created when Magma is first loaded. The ring may be formally created (and, if desired, assigned to a variable) using the function IntegerRing(). Subrings of \({\mathbb{Z}}\) are always ideals; see the section on ideals for details.
Creation of Elements
Since the ring of integers is present when Magma is started up, integers typed into Magma without any explicit context will be regarded as elements of the ring of integers. Integers can be specified using decimal, hexadecimal, and binary notation.
- a₁a₂...aᵣ
Given a succession of decimal digits \(a_1, \ldots, a_r\), create the corresponding integer. Leading zeros will be ignored.
- 0xa₁a₂...aᵣ
Given a succession of hexadecimal digits \(a_1, \ldots, a_r\), create the corresponding integer. Leading zeros will be ignored.
- 0ba₁a₂...aᵣ
Given a succession of binary digits \(a_1, \ldots, a_r\), create the corresponding integer. Leading zeros will be ignored.
- elt< Z | a₁a₂...aᵣ >: RngInt, RngIntElt -> RngIntElt
Given a succession of decimal digits \(a_1, \ldots, a_r\), create the corresponding integer as an element of \(Z\).
- elt< Z | 0xa₁a₂...aᵣ >: RngInt, RngIntElt -> RngIntElt
Given a succession of hexadecimal digits \(a_1, \ldots, a_r\), create the corresponding integer as an element of \(Z\).
- elt< Z | 0ba₁a₂...aᵣ >: RngInt, RngIntElt -> RngIntElt
Given a succession of binary digits \(a_1, \ldots, a_r\), create the corresponding integer as an element of \(Z\).
- Z ! a: RngInt, RngElt -> RngIntElt
- Z ! [a]: RngInt, [RngElt] -> RngIntElt
Coerce the ring element \(a\) into the ring of integers \(Z\). The element \(a\) is allowed to be an element of the ring of integers modulo \(m\) (in which case the result \(r\) satisfies \(0 \leq r < m\)), or an element of a finite field (in which case the result \(r\) satisfies \(0 \leq r < p\) if \(a\) is in the prime field, of characteristic \(p\), and an error otherwise), or an element of the integers, rationals, a quadratic field, a cyclotomic field, or a number field (in which cases the result is the obvious integer if \(a\) is integral and an error otherwise).
- Example: Creating Integers (ex-2fa3b0)
Run in calculator (opens in a new tab)
> Z := IntegerRing(); > n := 1234567890; > n in Z; true > m := elt< Z | 1234567890 >; > m eq n; true > l := Z ! elt< QuadraticField(3) | 1234567890, 0>; > l; 1234567890 > k := elt< Z | 0x499602D2 >; 1234567890 > b := 0b1001001100101100000001011010010; > b eq n; true > c := elt< Z | 0b1001001100101100000001011010010 >; > c eq n; true
- One(Z): RngInt -> RngIntElt
- Identity(Z): RngInt -> RngIntElt
- Zero(Z): RngInt -> RngIntElt
- Representative(Z): RngInt -> RngIntElt
These generic functions (cf. Chapter Introduction to Rings) create \(1\), \(1\), \(0\), and \(0\) respectively, in the integer ring \({\mathbb{Z}}\).
Printing of Elements
Magma supports the printing of integers in both decimal and hexadecimal form. The default print method is to print integers in base 10; base 16 printing is performed using the Hex print level.
Element Conversions
- FactorizationToInteger(s): [ <RngIntElt, RngIntElt> ] -> RngIntElt
- FactorisationToInteger(s): [ <RngIntElt, RngIntElt> ] -> RngIntElt
- Facint(s): [ <RngIntElt, RngIntElt> ] -> RngIntElt
Given a sequence of two-element tuples \(s=[ <p_1, k_1>, ..., <p_r, k_r> ]\) containing pairs of integers \(<p_i, k_i>\), \(1 \leq i \leq r\), with \(k_i\) non-negative, this function returns the integer \(p_1^{k_1} \cdots p_r^{k_r}\). It is normally used for converting a factorization sequence to the corresponding integer.
- IntegerToSequence(n, b): RngIntElt, RngIntElt -> [RngIntElt]
- Intseq(n, b): RngIntElt, RngIntElt -> [RngIntElt]
Given a non-negative integer \(n\) and a positive integer \(b\geq 2\), return the unique base \(b\) representation of \(n\) in the form of a sequence \(Q\). That is, if \(n = a_0b^0 + a_1b^1 + \ldots + a_{k-1}b^{k-1}\) with \(0\leq a_i<b\) and \(a_{k-1}> 0\), then \(Q = [ a_0, a_1, \ldots, a_{k-1} ]\). (If \(n=0\), then \(Q=[\,]\).)
- SequenceToInteger(s, b): [RngIntElt], RngIntElt -> RngIntElt
- Seqint(s, b): [RngIntElt], RngIntElt -> RngIntElt
Given a positive integer \(b\geq 2\) and a sequence \(Q = [ a_0, \ldots, a_{k-1} ]\) of non-negative integers such that \(0 \leq a_i < b\), return the integer \(n = a_0b^0 + a_1b^1 + \ldots + a_{k-1}b^{k-1}\). If \(Q\) is the empty sequence, the integer zero is returned. This function performs the inverse operation of the base \(b\) representation.
- IntegerToString(n): RngIntElt -> ModStgElt
Create the string consisting of the decimal digits of the integer \(n\). In the case in which \(n\) is negative the first character will be the minus sign.
- IntegerToString(n, b): RngIntElt, RngIntElt -> ModStgElt
Create the string consisting of the digits of the integer \(n\) in base \(b\). In the case in which \(n\) is negative the first character will be the minus sign. The base \(b\) can be between 2 and 36. For \(b \le 10\), the digits are represented numerically. For \(b > 10\), the digits are represented both numerically and alphabetically, so that, 10 is ‘A’, 11 is ‘B’, et cetera.