|
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.
RealField(p) : RngIntElt -> FldRe
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.
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(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.
One(R) : FldRe -> FldReElt
One(R) : FldCom -> FldComElt
Identity(R) : FldRe -> FldReElt
Identity(R) : FldCom -> FldComElt
Zero(R) : FldRe -> FldReElt
Zero(R) : FldCom -> FldComElt
Representative(R) : FldRe -> FldReElt
Representative(R) : FldCom -> FldComElt
a . bEcPd : RngIntElt, RngIntElt, RngIntElt -> FldReElt
a.bec P d : RngIntElt, RngIntElt, RngIntElt -> FldReElt
a.bec p d : RngIntElt, RngIntElt, RngIntElt -> FldReElt
a.b E cpd : RngIntElt, RngIntElt, RngIntElt -> FldReElt
a.b e cpd : RngIntElt, RngIntElt, RngIntElt -> FldReElt
Given a succession of literal decimal digits a, a succession of literal
decimal digits b, a succession of literal decimal digits c, and an integer
d, construct the real number r=a.b x 10f.
If specified, the effect of d is to create r as an element of the real field of precision d.
If d is omitted (together with p or P),
the real number will be
created as an element of the default real field.
Both a and c may include a leading sign + or -;
leading zeroes in a and c are ignored.
If b consists entirely of zeroes it may be omitted together with
the . and if c is zero it may be omitted together with
E (or e).
But note that
if all of b, c and d 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.
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.
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.
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.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
[Next][Prev] [Right] [Left] [Up] [Index] [Root]
|