This online help node and the nodes below it describe functions relating to the field of rational numbers Q. Note that most functions for rational integers are classified as integer functions.
The rational field Q is automatically created when Magma is started up. That means that in Q, unlike most other structures, arithmetic can be done without the need to create the structure explicitly first. The same is true for the ring of integers.
In order to be compatible with the other rings and fields, Q.1 will return 1.
Rational numbers are stored as pairs of numerator and denominator. Whenever a rational number is created, it will be put in reduced form (coprime numerator and denominator, positive denominator). It is well possible that a rational number has denominator 1, and thus represents a rational integer; in such cases it will however never automatically be converted into an integer (that is, its type will not be changed).
As a general rule, automatic coercion occurs between elements of Q and elements of any ring R of characteristic 0. That means, for example, that addition of any rational number and an element r of such ring can be performed without the need to coerce the elements first; the result will be in the larger of Q and R (usually R, unless R is a subring of Q such as Z). The most important exceptions to the above rule are those cases where the result would lie in a structure strictly larger than both Q and R. Examples of this are R=Z[x], and the result would generally be in Q(x), and R=OK, an order in a number field (and the result could be in K).
> 1/2 + elt< CyclotomicField(3) | 1,2>; 1/2*(4*zeta_3 + 3) > 1/2 - 0.12345; 0.37655 > 1/2 * 2; 1 > Parent(1/2 * 2); Rational Field > R<x> := PolynomialRing(Integers()); > // The following produces an error: > 1/2 + x; >> 1/2 + x; ^ Runtime error in '+': Bad argument types
Since homomorphisms are generally only allowed to be unitary, the specification of ring homomorphisms from Q=Q to a ring R is particularly simple: the image is completely determined by the image of 1, which we require to be 1 in R, so
suffices.
Note that Magma allows the user to define maps with hom that are not proper homomorphisms; this is sometimes useful, as the example below shows.
> Z11 := Integers(11); > Q := RationalField(); > h := hom< Q -> Z11 | >; > h(1/2); 6