We describe the creation of real and complex fields and their elements.
At the time Magma is loaded, a real field
is automatically created. This is used as the default parent for literal reals and real values returned by Magma.
Bits: BoolElt Default: false
Given a positive integer p, create and return a version R of the real field R in which all calculations are correct to precision p. If the parameter Bits is true, then the precision p is specified as the number of binary digits. If Bits is false, then the precision is given as the number of decimal digits --- this is translated into a binary precision of ⌈log2 (10p) ⌉.
Return the default real field.
Bits: BoolElt Default: false
Given a positive integer p, create and return a version C of the complex field C in which all calculations are correct to precision p. If the parameter Bits is true, then the precision p is specified as the number of binary digits. If Bits is false, then the precision is given as the number of decimal digits --- this is translated into a binary precision of ⌈log2 (10p) ⌉.By default no name is given to Sqrt( - 1); this may be changed with AssignNames. Angle brackets, e.g. C<i> := ComplexField(20), may be used to assign Sqrt( - 1) to an identifier.
Return the default complex field.By default no name is given to Sqrt( - 1); this may be changed with AssignNames. Angle brackets, e.g. C<i> := ComplexField(), may be used to assign Sqrt( - 1) to an identifier.
Return the complex field which has real subfield R; in other words, return the complex field with the same precision as the real field R.
> C<i> := ComplexField(20); > Pi(C)+ 1/4*i; 3.1415926535897932385 + 0.25000000000000000000*i > AssignNames(~C, ["k"]); > Pi(C)+ 1/4*i; 3.1415926535897932385 + 0.25000000000000000000*k > k := Name(C, 1); > Pi(C)+ 1/4*k; 3.1415926535897932385 + 0.25000000000000000000*k
The following generic element constructions are available; they return the 1 and 0 element of a real or complex field, where any zero elements are the "positive zero" in MPFR.
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 10f. If specified, the effect of g is to create r as an element of the real field of precision g.If g is omitted (together with p or P), the real number will be created as an element of the default real field.
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.
Given the real field R, an element m coercible into R and an integer n, construct the real number m x 2n in R.
Given the complex field C and elements x and y coercible into the real field underlying C, construct the complex number x + y i.
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 precision r and a is an element of a real field S of precision s then:
- if a is an element of a real field S of precision s ≥r, then an element of R approximating a to r digits is returned;
- if a is an element of a real field S of precision s < r, then an element of R is returned approximating a, obtained by padding with zeroes until the required precision r is reached;
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.
> x := 1.2345; > x, Parent(x); 1.23450000000000000000000000000 Real field of precision 30 > SetDefaultRealField(RealField(20)); > x1 := 1.2345; > x1, Parent(x1); 1.2345000000000000000 Real field of precision 20 > x2 := 12345e-4; > x2, Parent(x2); 1.2345000000000000000 Real field of precision 20 > x3 := 1.2345p10; > x3, Parent(x3); 1.234500000 Real field of precision 10 > x4 := 12345e-4p8; > x4, Parent(x4); 1.2345000 Real field of precision 8 > x5 := RealField(12) ! 1.2345; > x5, Parent(x5); 1.23450000000 Real field of precision 12