AUTHORS:
Then complex_field.py was copied to complex_interval_field.py and heavily modified:
Note
The ComplexIntervalField differs from ComplexField in that ComplexIntervalField only gives the digits with exact precision, then a ? signifying that that digit can have an error of +/-1.
Return the complex interval field with real and imaginary parts having prec bits of precision.
EXAMPLES:
sage: ComplexIntervalField()
Complex Interval Field with 53 bits of precision
sage: ComplexIntervalField(100)
Complex Interval Field with 100 bits of precision
sage: ComplexIntervalField(100).base_ring()
Real Interval Field with 100 bits of precision
sage: i = ComplexIntervalField(200).gen()
sage: i^2
-1
sage: i^i
0.207879576350761908546955619834978770033877841631769608075136?
Bases: sage.rings.ring.Field
The field of complex (interval) numbers.
EXAMPLES:
sage: C = ComplexIntervalField(); C
Complex Interval Field with 53 bits of precision
sage: Q = RationalField()
sage: C(1/3)
0.3333333333333334?
sage: C(1/3, 2)
0.3333333333333334? + 2*I
We can also coerce rational numbers and integers into C, but coercing a polynomial will raise an exception:
sage: Q = RationalField()
sage: C(1/3)
0.3333333333333334?
sage: S = PolynomialRing(Q, 'x')
sage: C(S.gen())
Traceback (most recent call last):
...
TypeError: unable to coerce to a ComplexIntervalFieldElement
This illustrates precision:
sage: CIF = ComplexIntervalField(10); CIF(1/3, 2/3)
0.334? + 0.667?*I
sage: CIF
Complex Interval Field with 10 bits of precision
sage: CIF = ComplexIntervalField(100); CIF
Complex Interval Field with 100 bits of precision
sage: z = CIF(1/3, 2/3); z
0.333333333333333333333333333334? + 0.666666666666666666666666666667?*I
We can load and save complex numbers and the complex interval field:
sage: cmp(loads(z.dumps()), z)
0
sage: loads(CIF.dumps()) == CIF
True
sage: k = ComplexIntervalField(100)
sage: loads(dumps(k)) == k
True
This illustrates basic properties of a complex (interval) field:
sage: CIF = ComplexIntervalField(200)
sage: CIF.is_field()
True
sage: CIF.characteristic()
0
sage: CIF.precision()
200
sage: CIF.variable_name()
'I'
sage: CIF == ComplexIntervalField(200)
True
sage: CIF == ComplexIntervalField(53)
False
sage: CIF == 1.1
False
sage: CIF = ComplexIntervalField(53)
sage: CIF.category()
Category of fields
sage: TestSuite(CIF).run()
Return the characteristic of the complex (interval) field, which is 0.
EXAMPLES:
sage: CIF.characteristic()
0
Return the generator of the complex (interval) field.
EXAMPLES:
sage: CIF.0
1*I
sage: CIF.gen(0)
1*I
The complex interval field is not exact.
EXAMPLES:
sage: CIF.is_exact()
False
Return True, since the complex numbers are a field.
EXAMPLES:
sage: CIF.is_field()
True
Return False, since the complex numbers are infinite.
EXAMPLES:
sage: CIF.is_finite()
False
The number of generators of this complex (interval) field as an
-algebra.
There is one generator, namely sqrt(-1).
EXAMPLES:
sage: CIF.ngens()
1
Returns as an element in the complex (interval) field.
EXAMPLES:
sage: ComplexIntervalField(100).pi()
3.14159265358979323846264338328?
Returns the precision of self (in bits).
EXAMPLES:
sage: CIF.prec()
53
sage: ComplexIntervalField(200).prec()
200
Returns the precision of self (in bits).
EXAMPLES:
sage: CIF.prec()
53
sage: ComplexIntervalField(200).prec()
200
Create a random element of self.
This simply chooses the real and imaginary part randomly, passing arguments and keywords to the underlying real interval field.
EXAMPLES:
sage: CIF.random_element()
0.15363619378561300? - 0.50298737524751780?*I
sage: CIF.random_element(10, 20)
18.047949821611205? + 10.255727028308920?*I
Passes extra positional or keyword arguments through:
sage: CIF.random_element(max=0, min=-5)
-0.079017286535590259? - 2.8712089896087117?*I
Set or return the scientific notation printing flag.
If this flag is True then complex numbers with this space as parent print using scientific notation.
EXAMPLES:
sage: CIF((0.025, 2))
0.025000000000000002? + 2*I
sage: CIF.scientific_notation(True)
sage: CIF((0.025, 2))
2.5000000000000002?e-2 + 2*I
sage: CIF.scientific_notation(False)
sage: CIF((0.025, 2))
0.025000000000000002? + 2*I
Returns a complex interval field with the given precision.
EXAMPLES:
sage: CIF.to_prec(150)
Complex Interval Field with 150 bits of precision
sage: CIF.to_prec(15)
Complex Interval Field with 15 bits of precision
sage: CIF.to_prec(53) is CIF
True
Return a primitive -th root of unity.
Todo
Implement ComplexIntervalFieldElement multiplicative order and set this output to have multiplicative order n.
INPUT:
OUTPUT:
A complex -th root of unity.
EXAMPLES:
sage: CIF.zeta(2)
-1
sage: CIF.zeta(5)
0.309016994374948? + 0.9510565162951536?*I
Check if x is a ComplexIntervalField.
EXAMPLES:
sage: from sage.rings.complex_interval_field import is_ComplexIntervalField as is_CIF
sage: is_CIF(CIF)
True
sage: is_CIF(CC)
False
Import the objects/modules after build (when needed).
TESTS:
sage: sage.rings.complex_interval_field.late_import()