Module: sage.rings.complex_field
Author: William Stein (2006-01-26): complete rewrite
Module-level Functions
[prec=53]) |
x) |
Class: ComplexField_class
sage: C = ComplexField(); C Complex Field with 53 bits of precision sage: Q = RationalField() sage: C(1/3) 0.33333333333333331 sage: C(1/3, 2) 0.33333333333333331 + 2.0000000000000000*I
Note that the second argument is the number of *bits* of precision, not the number of digits of precision:
sage: C(1/3, 2) 0.33333333333333331 + 2.0000000000000000*I
We can also coerce rational numbers and integers into C, but coercing a polynomial in raising an exception.
sage: Q = RationalField() sage: C(1/3) 0.33333333333333331 sage: S = PolynomialRing(Q) sage: C(S.gen()) Traceback (most recent call last): ... TypeError: unable to coerce (x,0) to a ComplexNumber
This illustrates precision.
sage: CC = ComplexField(10); CC(1/3, 2/3) 0.33350 + 0.66699*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.33333333333333333333333333333346 + 0.66666666666666666666666666666693*I
We can load and save complex numbers and the complex field.
sage: loads(z.dumps()) == z True sage: loads(CC.dumps()) == CC 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() 'x' sage: CC == ComplexField(200) True sage: CC == ComplexField(53) False sage: CC == 1.1 False
self, [prec=53]) |
Functions: characteristic,
gen,
is_field,
is_finite,
ngens,
pi,
prec,
precision,
scientific_notation,
zeta
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: n -- an integer (default: 2) OUTPUT: a complex n-th root of unity.
Special Functions: __call__,
__cmp__,
_latex_,
_real_field,
_repr_
self, x, [im=None]) |
sage: CC(2) 2.0000000000000000 sage: CC(CC.0) 1.0000000000000000*I sage: CC('1+I') 1.0000000000000000 + 1.0000000000000000*I sage: CC(2,3) 2.0000000000000000 + 3.0000000000000000*I