本文整理汇总了Python中sage.rings.all.ComplexField类的典型用法代码示例。如果您正苦于以下问题:Python ComplexField类的具体用法?Python ComplexField怎么用?Python ComplexField使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ComplexField类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: zeta_symmetric
def zeta_symmetric(s):
r"""
Completed function `\xi(s)` that satisfies
`\xi(s) = \xi(1-s)` and has zeros at the same points as the
Riemann zeta function.
INPUT:
- ``s`` - real or complex number
If s is a real number the computation is done using the MPFR
library. When the input is not real, the computation is done using
the PARI C library.
More precisely,
.. math::
xi(s) = \gamma(s/2 + 1) * (s-1) * \pi^{-s/2} * \zeta(s).
EXAMPLES::
sage: zeta_symmetric(0.7)
0.497580414651127
sage: zeta_symmetric(1-0.7)
0.497580414651127
sage: RR = RealField(200)
sage: zeta_symmetric(RR(0.7))
0.49758041465112690357779107525638385212657443284080589766062
sage: C.<i> = ComplexField()
sage: zeta_symmetric(0.5 + i*14.0)
0.000201294444235258 + 1.49077798716757e-19*I
sage: zeta_symmetric(0.5 + i*14.1)
0.0000489893483255687 + 4.40457132572236e-20*I
sage: zeta_symmetric(0.5 + i*14.2)
-0.0000868931282620101 + 7.11507675693612e-20*I
REFERENCE:
- I copied the definition of xi from
http://web.viu.ca/pughg/RiemannZeta/RiemannZetaLong.html
"""
if not (is_ComplexNumber(s) or is_RealNumber(s)):
s = ComplexField()(s)
R = s.parent()
if s == 1: # deal with poles, hopefully
return R(0.5)
return (s / 2 + 1).gamma() * (s - 1) * (R.pi() ** (-s / 2)) * s.zeta()
开发者ID:rwst,项目名称:sage,代码行数:54,代码来源:transcendental.py
示例2: map_to_complex_numbers
def map_to_complex_numbers(self, z, prec=None):
"""
Evaluate ``self`` at a point `z \in X_0(N)` where `z` is given by
a representative in the upper half plane, returning a point in
the complex numbers.
All computations are done with ``prec`` bits
of precision. If ``prec`` is not given, use the precision of `z`.
Use self(z) to compute the image of z on the Weierstrass equation
of the curve.
EXAMPLES::
sage: E = EllipticCurve('37a'); phi = E.modular_parametrization()
sage: tau = (sqrt(7)*I - 17)/74
sage: z = phi.map_to_complex_numbers(tau); z
0.929592715285395 - 1.22569469099340*I
sage: E.elliptic_exponential(z)
(...e-16 - ...e-16*I : ...e-16 + ...e-16*I : 1.00000000000000)
sage: phi(tau)
(...e-16 - ...e-16*I : ...e-16 + ...e-16*I : 1.00000000000000)
"""
if prec is None:
try:
prec = z.parent().prec()
except AttributeError:
prec = 53
CC = ComplexField(prec)
if z in QQ:
raise NotImplementedError
z = CC(z)
if z.imag() <= 0:
raise ValueError("Point must be in the upper half plane")
# TODO: for very small imaginary part, maybe try to transform under
# \Gamma_0(N) to a better representative?
q = (2 * CC.gen() * CC.pi() * z).exp()
# nterms'th term is less than 2**-(prec+10) (c.f. eclib code)
nterms = (-(prec + 10) / q.abs().log2()).ceil()
# Use Horner's rule to sum the integral of the form
enumerated_an = list(enumerate(self._E.anlist(nterms)))[1:]
lattice_point = 0
for n, an in reversed(enumerated_an):
lattice_point += an / n
lattice_point *= q
return lattice_point
开发者ID:mcognetta,项目名称:sage,代码行数:45,代码来源:modular_parametrization.py
示例3: _evalf_
def _evalf_(self, x, y, parent=None, algorithm='mpmath'):
"""
EXAMPLES::
sage: gamma_inc_lower(3,2.)
0.646647167633873
sage: gamma_inc_lower(3,2).n(200)
0.646647167633873081060005050275155...
sage: gamma_inc_lower(0,2.)
+infinity
"""
R = parent or s_parent(x)
# C is the complex version of R
# prec is the precision of R
if R is float:
prec = 53
C = complex
else:
try:
prec = R.precision()
except AttributeError:
prec = 53
try:
C = R.complex_field()
except AttributeError:
C = R
if algorithm == 'pari':
try:
v = ComplexField(prec)(x).gamma() - ComplexField(prec)(x).gamma_inc(y)
except AttributeError:
if not (is_ComplexNumber(x)):
if is_ComplexNumber(y):
C = y.parent()
else:
C = ComplexField()
x = C(x)
v = ComplexField(prec)(x).gamma() - ComplexField(prec)(x).gamma_inc(y)
else:
import mpmath
v = ComplexField(prec)(mpmath_utils.call(mpmath.gammainc, x, 0, y, parent=R))
if v.is_real():
return R(v)
else:
return C(v)
开发者ID:sagemath,项目名称:sage,代码行数:44,代码来源:gamma.py
示例4: __init__
def __init__(self, conductor, gammaV, weight, eps, \
poles=[], residues='automatic', prec=53,
init=None):
"""
Initialization of Dokchitser calculator EXAMPLES::
sage: L = Dokchitser(conductor=1, gammaV=[0], weight=1, eps=1, poles=[1], residues=[-1], init='1')
sage: L.num_coeffs()
4
"""
self.conductor = conductor
self.gammaV = gammaV
self.weight = weight
self.eps = eps
self.poles = poles
self.residues = residues
self.prec = prec
self.__CC = ComplexField(self.prec)
self.__RR = self.__CC._real_field()
self.__initialized = False
if init is not None:
self.init_coeffs(init)
开发者ID:mcognetta,项目名称:sage,代码行数:22,代码来源:dokchitser.py
示例5: hilbert_class_polynomial
def hilbert_class_polynomial(D, algorithm=None):
r"""
Returns the Hilbert class polynomial for discriminant `D`.
INPUT:
- ``D`` (int) -- a negative integer congruent to 0 or 1 modulo 4.
- ``algorithm`` (string, default None).
OUTPUT:
(integer polynomial) The Hilbert class polynomial for the
discriminant `D`.
ALGORITHM:
- If ``algorithm`` = "arb" (default): Use Arb's implementation which uses complex interval arithmetic.
- If ``algorithm`` = "sage": Use complex approximations to the roots.
- If ``algorithm`` = "magma": Call the appropriate Magma function (if available).
AUTHORS:
- Sage implementation originally by Eduardo Ocampo Alvarez and
AndreyTimofeev
- Sage implementation corrected by John Cremona (using corrected precision bounds from Andreas Enge)
- Magma implementation by David Kohel
EXAMPLES::
sage: hilbert_class_polynomial(-4)
x - 1728
sage: hilbert_class_polynomial(-7)
x + 3375
sage: hilbert_class_polynomial(-23)
x^3 + 3491750*x^2 - 5151296875*x + 12771880859375
sage: hilbert_class_polynomial(-37*4)
x^2 - 39660183801072000*x - 7898242515936467904000000
sage: hilbert_class_polynomial(-37*4, algorithm="magma") # optional - magma
x^2 - 39660183801072000*x - 7898242515936467904000000
sage: hilbert_class_polynomial(-163)
x + 262537412640768000
sage: hilbert_class_polynomial(-163, algorithm="sage")
x + 262537412640768000
sage: hilbert_class_polynomial(-163, algorithm="magma") # optional - magma
x + 262537412640768000
TESTS::
sage: all([hilbert_class_polynomial(d, algorithm="arb") == \
....: hilbert_class_polynomial(d, algorithm="sage") \
....: for d in range(-1,-100,-1) if d%4 in [0,1]])
True
"""
if algorithm is None:
algorithm = "arb"
D = Integer(D)
if D >= 0:
raise ValueError("D (=%s) must be negative"%D)
if not (D%4 in [0,1]):
raise ValueError("D (=%s) must be a discriminant"%D)
if algorithm == "arb":
import sage.libs.arb.arith
return sage.libs.arb.arith.hilbert_class_polynomial(D)
if algorithm == "magma":
magma.eval("R<x> := PolynomialRing(IntegerRing())")
f = str(magma.eval("HilbertClassPolynomial(%s)"%D))
return IntegerRing()['x'](f)
if algorithm != "sage":
raise ValueError("%s is not a valid algorithm"%algorithm)
from sage.quadratic_forms.binary_qf import BinaryQF_reduced_representatives
from sage.rings.all import RR, ZZ, ComplexField
from sage.functions.all import elliptic_j
# get all primitive reduced quadratic forms, (necessary to exclude
# imprimitive forms when D is not a fundamental discriminant):
rqf = BinaryQF_reduced_representatives(D, primitive_only=True)
# compute needed precision
#
# NB: [http://arxiv.org/abs/0802.0979v1], quoting Enge (2006), is
# incorrect. Enge writes (2009-04-20 email to John Cremona) "The
# source is my paper on class polynomials
# [http://hal.inria.fr/inria-00001040] It was pointed out to me by
# the referee after ANTS that the constant given there was
# wrong. The final version contains a corrected constant on p.7
# which is consistent with your example. It says:
# "The logarithm of the absolute value of the coefficient in front
#.........这里部分代码省略.........
开发者ID:mcognetta,项目名称:sage,代码行数:101,代码来源:cm.py
示例6: Dokchitser
#.........这里部分代码省略.........
12
sage: L.set_coeff_growth('2*n^(11/2)')
sage: L.num_coeffs()
11
Now we're ready to evaluate, etc.
::
sage: L(1)
0.0374412812685155
sage: L(1, 1.1)
0.0374412812685155
sage: L.taylor_series(1,3)
0.0374412812685155 + 0.0709221123619322*z + 0.0380744761270520*z^2 + O(z^3)
"""
def __init__(self, conductor, gammaV, weight, eps, \
poles=[], residues='automatic', prec=53,
init=None):
"""
Initialization of Dokchitser calculator EXAMPLES::
sage: L = Dokchitser(conductor=1, gammaV=[0], weight=1, eps=1, poles=[1], residues=[-1], init='1')
sage: L.num_coeffs()
4
"""
self.conductor = conductor
self.gammaV = gammaV
self.weight = weight
self.eps = eps
self.poles = poles
self.residues = residues
self.prec = prec
self.__CC = ComplexField(self.prec)
self.__RR = self.__CC._real_field()
if not init is None:
self.init_coeffs(init)
self.__init = init
else:
self.__init = False
def __reduce__(self):
D = copy.copy(self.__dict__)
if '_Dokchitser__gp' in D:
del D['_Dokchitser__gp']
return reduce_load_dokchitser, (D, )
def _repr_(self):
z = "Dokchitser L-series of conductor %s and weight %s"%(
self.conductor, self.weight)
return z
def __del__(self):
self.gp().quit()
def gp(self):
"""
Return the gp interpreter that is used to implement this Dokchitser
L-function.
EXAMPLES::
sage: E = EllipticCurve('11a')
sage: L = E.lseries().dokchitser()
sage: L(2)
0.546048036215014
开发者ID:drupel,项目名称:sage,代码行数:67,代码来源:dokchitser.py
注:本文中的sage.rings.all.ComplexField类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论