The rational field Q is automatically created when Magma is started up. Nevertheless, it may be necessary to formally create the rational field, for instance if it is to be used as the coefficient ring for a polynomial ring. There is a unique rational field structure in Magma, that is, multiple calls to the creation function RationalField() will return the same object (and not an isomorphic copy), so no memory will be wasted.
Create the field Q of rational numbers.
Create the field Z of rational integers.
The function FieldOfFractions returns the field Q when R is either the ring Z of rational integers, or the field Q itself.
Precision: RngIntElt Default: ∞
Computes the completion of Q at the integral prime ideal P together with the injection into the completion.The parameter Precision may be used to specify a particular precision.
Unlike elements of other structures, rational numbers and integers can be created as literals without the need to define the parent field Q or the parent ring Z first, since these structures are loaded whenever Magma is started up.
These generic functions create 1, 1, 0, and 0 respectively, in the rational field Q.
Given integers a and b != 0, form the rational number a/b (in reduced form). Of course a and be are allowed to be given as expressions defining integers.
The inverse function to Eltseq, returns Q!a.
Given the rational field Q, and integers a, b (with b != 0), construct the rational number a / b, in reduced form.
Given the rational field Q, and an integer a, create the rational number a=a/1 in Q. Also, any element from a quadratic, cyclotomic or number field (or an order of such) that is rational can be coerced into the rational field this way.
This function returns, in general, for a positive integer n and a cyclotomic field Q a primitive n-th root of unity in Q; if Q is the rational field, n must be 1 or 2, and the result will be 1 or -1 in Q accordingly.
This function returns a random rational number with random numerator in [ - u..u] and random denominator in [ 1..u], where u is the absolute value of m.