[Next] [Prev] [Right] [Left] [Up] [Index] [Root]
Creation Functions

Creation Functions

We describe the creation of real and complex fields and their elements.

Subsections

Creation of Structures

At the time Magma is loaded, a version of the free real field is automatically created. This is used as default parents for literal reals and real values returned by Magma.

RealField(p) : RngIntElt -> FldRe
Given a positive integer p, create and return a version R of the real field R in which all calculations are correct to p' decimal digits, where p'=4.Ceiling((p/4)) is the smallest multiple of 4 greater than or equal to p.
RealField() : Null -> FldPr
Create the free real field.
ComplexField(p) : RngIntElt -> FldCom
Given a positive integer p, create and return a version C of the complex field C in which all calculations are correct to p' decimal digits, where p'=4.Ceiling((p/4)) is the smallest multiple of 4 greater than or equal to p.

The name i is given to sqrt(-1); this may be changed with AssignNames. Angle brackets may be used to assign sqrt(-1) to an identifier, e.g. C<i>:=ComplexField(20).

ComplexField() : Null -> FldPr
Create the free complex field.

The name i is given to sqrt(-1); this may be changed with AssignNames. Angle brackets may be used to assign sqrt(-1) to an identifier, e.g. C<i>:=ComplexField().


Example FldRe_CreateComplexField (H37E3)

It is convenient to use ( i) to define elements of a complex field. It is also possible to change the default printing of i, using AssignNames, as follows. Note that the latter procedure does not assign to an identifier, it only changes the printing.

> C<i> := ComplexField(32);
> Pi(C)+ 1/4*i;
3.1415926535897932384626433833 + 0.25 i
> AssignNames( C, ["k"]);
>  print Pi(C)+ 1/4*i;
3.1415926535897932384626433833 + 0.25 k
> k := Name(C, 1);
> Pi(C)+ 1/4*k;
3.1415926535897932384626433833 + 0.25*k

Creation of Elements

The following generic element constructions are available; they return the 1 and 0 element of a real or complex field.

One(R) : FldRe -> FldReElt
One(R) : FldCom -> FldComElt
One(R) : FldPr -> FldPrElt
Identity(R) : FldRe -> FldReElt
Identity(R) : FldCom -> FldComElt
Identity(R) : FldPr -> FldPrElt
Zero(R) : FldRe -> FldReElt
Zero(R) : FldCom -> FldComElt
Zero(R) : FldPr -> FldPrElt
Representative(R) : FldRe -> FldReElt
Representative(R) : FldCom -> FldComElt
Representative(R) : FldPr -> FldPrElt
d . eefpg : RngIntElt, RngIntElt, RngIntElt -> FldReElt
d . eEfPg : RngIntElt, RngIntElt, RngIntElt -> FldReElt
d.eef P g : RngIntElt, RngIntElt, RngIntElt -> FldReElt
d.eef p g : RngIntElt, RngIntElt, RngIntElt -> FldReElt
d.e E fpg : RngIntElt, RngIntElt, RngIntElt -> FldReElt
d.e e fpg : RngIntElt, RngIntElt, RngIntElt -> FldReElt
Given a succession of literal decimal digits d, a succession of literal decimal digits e, a succession of literal decimal digits f, and an integer g, construct the real number r=d.e x 10^f; the effect of g depends on the default real field: if the default real field has fixed precision, r will be created as an element of the real field of precision g' (where g' is the smallest multiple of 4 greater than or equal to g), but if the default real field is free then g determines the precision to which r is constructed as a free real number.

If g is omitted (together with p or P), the real number will be created as an element of the default real field. If the default field is the free real field, in the absence of p the maximum of the default precision and the number of decimal digits supplied is used in the creation of the free real number r.

Both d and f may include a leading sign + or -; leading zeroes in d and f are ignored. If e consists entirely of zeroes it may be omitted together with the . and if f is zero it may be omitted together with E (or e). But note that if all of e, f and g are omitted the result will be an integer.

elt<R | m, n> : FldRe, FldReElt, RngIntElt -> FldReElt
elt<R | m, n> : FldPr, FldPrElt, RngIntElt -> FldPrElt
Given the real field R, an element m coercible into R and an integer n, construct the real number m x 10^n in R.
elt<C | x, y> : FldCom, FldReElt, FldReElt -> FldComElt
C ! [x, y] : FldCom, [FldReElt, FldReElt] -> FldComElt
Given the complex field C and elements x and y coercible into the real field underlying C, construct the complex number x + y i.
R ! a : FldRe, RngElt -> FldReElt
R ! a : FldPr, RngElt -> FldPrElt
Given an integer, a rational number, a quadratic or cyclotomic number field element a, this returns an element from the real field R that best approximates a. An error results if a is a non-real quadratic or cyclotomic field element.

If R is a field of fixed precision r and a is an element of a real field S of fixed precision s then:

If R is a free real field and a is a fixed precision real number again an element in R approximating a as well as possible to the default precision of R is returned.
C ! a : FldCom, RngElt -> FldComElt
C ! a : FldPr, RngElt -> FldPrElt
Given an integer, a rational number, a quadratic or cyclotomic number field element a, this returns an element from the complex field C that best approximates a. The rules of coercion for the real and imaginary parts are the same as those for coercion into a real field.

Example FldRe_CreateElements (H37E4)

We create the real number 1.2345 in many ways. We assume that the default real field has not been changed.

> x := 1.2345;
> x, Parent(x); 
1.234499999999999999999999999 Field of Pari-style reals
> SetDefaultRealField(RealField(20));
> x1 := 1.2345;
> x1, Parent(x1);
1.2345 Real Field of Precision 20
> x2 := 12345e-4;
> x2, Parent(x2);
1.2345 Real Field of Precision 20
> x3 := 1.2345p50;
> x3, Parent(x3);
1.2345 Real Field of Precision 52
> x4 := 12345e-4p8;
> x4, Parent(x4);
1.2345 Real Field of Precision 8
> x5 := RealField(12) ! 1.2345;
> x5, Parent(x5);
1.2345 Real Field of Precision 12
> x6 := elt< RealField(100) | 12345, -4 >;
> x6, Parent(x6);
1.2345 Real Field of Precision 100

[Next] [Prev] [Right] [Left] [Up] [Index] [Root]