Module: sage.rings.complex_field
Field of Arbitrary Precision Complex Numbers
Author: William Stein (2006-01-26): complete rewrite
Module-level Functions
[prec=53], [names=None]) |
Return the complex field with real and imaginary parts having prec *bits* of precision.
sage: ComplexField() Complex Field with 53 bits of precision sage: ComplexField(100) Complex Field with 100 bits of precision sage: ComplexField(100).base_ring() Real Field with 100 bits of precision sage: i = ComplexField(200).gen() sage: i^2 -1.0000000000000000000000000000000000000000000000000000000000
x) |
) |
Class: ComplexField_class
sage: C = ComplexField(); C Complex Field with 53 bits of precision sage: Q = RationalField() sage: C(1/3) 0.333333333333333 sage: C(1/3, 2) 0.333333333333333 + 2.00000000000000*I sage: C(RQDF.pi()) 3.14159265358979 sage: C(RQDF.log2(), RQDF.e()) 0.693147180559945 + 2.71828182845905*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.333333333333333 sage: S = PolynomialRing(Q, 'x') sage: C(S.gen()) Traceback (most recent call last): ... TypeError: unable to coerce to a ComplexNumber
This illustrates precision.
sage: CC = ComplexField(10); CC(1/3, 2/3) 0.33 + 0.67*I sage: CC Complex Field with 10 bits of precision sage: CC = ComplexField(100); CC Complex Field with 100 bits of precision sage: z = CC(1/3, 2/3); z 0.33333333333333333333333333333 + 0.66666666666666666666666666667*I
We can load and save complex numbers and the complex field.
sage: loads(z.dumps()) == z True sage: loads(CC.dumps()) == CC True sage: k = ComplexField(100) sage: loads(dumps(k)) == k True
This illustrates basic properties of a complex field.
sage: CC = ComplexField(200) sage: CC.is_field() True sage: CC.characteristic() 0 sage: CC.precision() 200 sage: CC.variable_name() 'I' sage: CC == ComplexField(200) True sage: CC == ComplexField(53) False sage: CC == 1.1 False
self, [prec=53]) |
Functions: characteristic,
construction,
gen,
is_exact,
is_field,
is_finite,
ngens,
pi,
prec,
precision,
scientific_notation,
zeta
self) |
Returns the functorial construction of self, namely, algebraic closure of the real field with the same precision.
sage: c, S = CC.construction(); S Real Field with 53 bits of precision sage: CC == c(S) True
self) |
Return True, since the complex numbers are a field.
sage: CC.is_field() True
self) |
Return False, since the complex numbers are infinite.
sage: CC.is_finite() False
self, [n=2]) |
Return a primitive
-th root of unity.
Input:
Special Functions: __call__,
__cmp__,
__init__,
__reduce__,
_coerce_impl,
_latex_,
_real_field,
_repr_
self, x, [im=None]) |
sage: CC(2) 2.00000000000000 sage: CC(CC.0) 1.00000000000000*I sage: CC('1+I') 1.00000000000000 + 1.00000000000000*I sage: CC(2,3) 2.00000000000000 + 3.00000000000000*I sage: CC(QQ[I].gen()) 1.00000000000000*I sage: CC.gen() + QQ[I].gen() Traceback (most recent call last): ... TypeError: unsupported operand parent(s) for '+': 'Complex Field with 53 bits of precision' and 'Number Field in I with defining polynomial x^2 + 1'
self, x) |
Return the canonical coerce of x into this complex field, if it is defined, otherwise raise a TypeError.
The rings that canonicaly coerce to the MPFS complex field are: * this MPFR complex field, or any other of higher precision * anything that canonically coerces to the mpfr real field with this prec
sage: ComplexField(200)(1) + RealField(90)(1) 2.0000000000000000000000000
See About this document... for information on suggesting changes.