Quadratic fields in Magma can be created as a special type as well as by using the general number field constructors. The advantage of the special quadratic fields is that some special (faster) algorithms have been or will be implemented to deal with them; the disadvantage is that they are not directly compatible with general number fields. The functions for the special quadratic fields (created with the QuadraticField function) are described here.
The categories involved are FldQuad, for fields, and RngQuad for their orders.
For every squarefree integer d (not 0 or 1) there is a unique quadratic field Q(sqrt(d)); for any integer k the field Q(sqrt(k^2d)) isomorphic to Q(sqrt(d)). Given any integer m, the function QuadraticField will create a structure corresponding to the quadratic field Q(sqrt(d)), where d is the squarefree kernel of m (d will have the same sign as m and its absolute value is the largest squarefree divisor of m). In Magma a list of quadratic fields currently present is maintained, and if Q(sqrt(d)) has been created before a reference on it will be returned: two fields with the same d are the same. The discriminant D of Q(sqrt(d)) will be D=d if d equiv1bmod4 and D=4d if d equiv2, 3bmod4.
Elements of Q(sqrt(d)) are represented by a common positive denominator b and two integer coefficients: alpha=(1/b)(x + y sqrt(d)).
The ring of integers of F=Q((sqrt(d)) will be O_F=Z + epsilon_dZ, where epsilon_d=cases( sqrt(d)&if d = 2, 3 mod 4, cr (1 + sqrt(d)/2)&if d = 1 mod 4.cr) Elements of O_F are represented by two integer coefficients alpha=x + yepsilon_d. The pair 1, epsilon_d forms an integral basis for F=Q(sqrt(d)), but note that we do not generally use that to represent elements of F (we use the basis 1, sqrt(d) instead.
For any positive integer f there is a suborder of conductor f in
O_F, whose elements are of the form x + y f epsilon_d, for any integers
x, y. The discriminant of the order of conductor f is f^2D, where
D is the field discriminant.
Coercion
In general, only integers and rational numbers will be automatically coerced
into quadratic fields when necessary. Elements of real quadratic
fields can be coerced into any real field, elements of imaginary quadratic
fields can be coerced into any complex field. Elements of quadratic fields can
be coerced into cyclotomic fields in which they are contained (but
automatic coercion of quadratic field elements and cyclotomic field elements
does not take place).
Homomorphisms
To specify a (unitary) ring homomorphism with domain Q=Q(sqrt(d)),
the image f of sqrt(d) would suffice. Hence homomorphisms can be
defined as follows. (This can in particular be used to move between
quadratic fields and general number fields.)
hom< Q -> F | f > : RngQuad, Rng, RngElt -> Map
Define the unitary ring homomorphism phi from Q=Q(sqrt(d)) to a ring F by phi(1)=1 and phi(sqrt(d))=f.
> Q<w> := QuadraticField(5); > F<z> := CyclotomicField(5); > C<c> := PolynomialRing(F); > Factorization(c^2-5); [ <c - 2*z^3 - 2*z^2 - 1, 1>, <c + 2*z^3 + 2*z^2 + 1, 1> ] > h := hom< Q -> F | -2*z^3 - 2*z^2 - 1 >; > h(w)^2; 5
Procedure to change the name of the generator of a quadratic field F or an order O in a quadratic field to the string s. By default, elements of the quadratic field Q(sqrt(d)) with m squarefree are printed in the form 1/b*(x + y*sqrtd), where d is a string denoting the integer d and b, x, y are integers; the effect of the above procedure is to replace the string sqrtm by the string s. Similarly, for an order O of conductor f in a quadratic field elements are printed by default in the format x + y*f*epsd, where epsd is the standard integral basis generator; the effect of the procedure is to replace the string f*epsd by the string s.This procedure only changes the name used in printing the elements of F or O, it does not make an assignment to an identifier s. To do this, use an assignment statement, or angle brackets when creating the field or order: F<s> := QuadraticField(-3);.
Note that since this is a procedure that modifies F or O, it is necessary to have a reference ~ in the call to this function.
Given a quadratic field F or one of its orders O, return the element which has the name attached to it, that is, return sqrt(d) in the field, or f epsilon_d in the order.[Next] [Prev] [Right] [____] [Up] [Index] [Root]