本文整理汇总了Python中sage.rings.all.PowerSeriesRing类的典型用法代码示例。如果您正苦于以下问题:Python PowerSeriesRing类的具体用法?Python PowerSeriesRing怎么用?Python PowerSeriesRing使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PowerSeriesRing类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _e_bounds
def _e_bounds(self, n, prec):
p = self._p
prec = max(2,prec)
R = PowerSeriesRing(ZZ,'T',prec+1)
T = R(R.gen(),prec +1)
w = (1+T)**(p**n) - 1
return [infinity] + [valuation(w[j],p) for j in range(1,min(w.degree()+1,prec))]
示例2: local_coordinates_at_weierstrass
def local_coordinates_at_weierstrass(self, P, prec=20, name="t"):
"""
For a finite Weierstrass point on the hyperelliptic
curve y^2 = f(x), returns (x(t), y(t)) such that
(y(t))^2 = f(x(t)), where t = y is the local parameter.
INPUT:
- P a finite Weierstrass point on self
- prec: desired precision of the local coordinates
- name: gen of the power series ring (default: 't')
OUTPUT:
(x(t),y(t)) such that y(t)^2 = f(x(t)) and t = y
is the local parameter at P
EXAMPLES:
sage: R.<x> = QQ['x']
sage: H = HyperellipticCurve(x^5-23*x^3+18*x^2+40*x)
sage: A = H(4, 0)
sage: x, y = H.local_coordinates_at_weierstrass(A, prec=7)
sage: x
4 + 1/360*t^2 - 191/23328000*t^4 + 7579/188956800000*t^6 + O(t^7)
sage: y
t + O(t^7)
sage: B = H(-5, 0)
sage: x, y = H.local_coordinates_at_weierstrass(B, prec=5)
sage: x
-5 + 1/1260*t^2 + 887/2000376000*t^4 + O(t^5)
sage: y
t + O(t^5)
AUTHOR:
- Jennifer Balakrishnan (2007-12)
- Francis Clarke (2012-08-26)
"""
if P[1] != 0:
raise TypeError, "P = %s is not a finite Weierstrass point. Use local_coordinates_at_nonweierstrass instead!" % P
L = PowerSeriesRing(self.base_ring(), name)
t = L.gen()
pol = self.hyperelliptic_polynomials()[0]
pol_prime = pol.derivative()
b = P[0]
t2 = t ** 2
c = b + t2 / pol_prime(b)
c = c.add_bigoh(prec)
for _ in range(1 + log(prec, 2)):
c -= (pol(c) - t2) / pol_prime(c)
return (c, t.add_bigoh(prec))
示例3: zeta_series
def zeta_series(self, n, t):
"""
Return the zeta series.
Compute a power series approximation to the zeta function of a
scheme over a finite field.
INPUT:
- ``n`` -- the number of terms of the power series to
compute
- ``t`` -- the variable which the series should be
returned
OUTPUT:
A power series approximating the zeta function of self
EXAMPLES::
sage: P.<x> = PolynomialRing(GF(3))
sage: C = HyperellipticCurve(x^3+x^2+1)
sage: R.<t> = PowerSeriesRing(Integers())
sage: C.zeta_series(4,t)
1 + 6*t + 24*t^2 + 78*t^3 + 240*t^4 + O(t^5)
sage: (1+2*t+3*t^2)/(1-t)/(1-3*t) + O(t^5)
1 + 6*t + 24*t^2 + 78*t^3 + 240*t^4 + O(t^5)
Note that this function depends on count_points, which is only
defined for prime order fields::
sage: C.base_extend(GF(9,'a')).zeta_series(4,t)
Traceback (most recent call last):
...
NotImplementedError: Point counting only implemented for schemes over prime fields
"""
F = self.base_ring()
if not F.is_finite():
raise TypeError('zeta functions only defined for schemes over finite fields')
try:
a = self.count_points(n)
except AttributeError:
raise NotImplementedError('count_points() required but not implemented')
R = PowerSeriesRing(Rationals(), 'u')
u = R.gen()
temp = sum(a[i-1]*(u.O(n+1))**i/i for i in range(1,n+1))
temp2 = temp.exp()
return(temp2(t).O(n+1))
示例4: __init__
def __init__(self, group, prec):
r"""
Constructor for the Fourier expansion of some
(specific, basic) modular forms.
INPUT:
- ``group`` -- A Hecke triangle group (default: HeckeTriangleGroup(3)).
- ``prec`` -- An integer (default: 10), the default precision used
in calculations in the LaurentSeriesRing or PowerSeriesRing.
OUTPUT:
The constructor for Fourier expansion with the specified settings.
EXAMPLES::
sage: from sage.modular.modform_hecketriangle.series_constructor import JFSeriesConstructor
sage: JFC = JFSeriesConstructor()
sage: JFC
Power series constructor for Hecke modular forms for n=3 with (basic series) precision 10
sage: JFC.group()
Hecke triangle group for n = 3
sage: JFC.prec()
10
sage: JFC._series_ring
Power Series Ring in q over Rational Field
sage: JFSeriesConstructor(group=4)
Power series constructor for Hecke modular forms for n=4 with (basic series) precision 10
sage: JFSeriesConstructor(group=5, prec=12)
Power series constructor for Hecke modular forms for n=5 with (basic series) precision 12
sage: JFSeriesConstructor(group=infinity)
Power series constructor for Hecke modular forms for n=+Infinity with (basic series) precision 10
"""
self._group = group
self._prec = prec
FR = FractionField(PolynomialRing(ZZ,'p,d'))
self._series_ring = PowerSeriesRing(FR,'q',default_prec=self._prec)
#self._series_ring2 = PowerSeriesRing(QQ[['q']],'p',default_prec=self._prec)
self._qseries_ring = PowerSeriesRing(QQ,'q',default_prec=self._prec)
示例5: local_coordinates_at_nonweierstrass
def local_coordinates_at_nonweierstrass(self, P, prec=20, name='t'):
"""
For a non-Weierstrass point `P = (a,b)` on the hyperelliptic
curve `y^2 = f(x)`, return `(x(t), y(t))` such that `(y(t))^2 = f(x(t))`,
where `t = x - a` is the local parameter.
INPUT:
- ``P = (a, b)`` -- a non-Weierstrass point on self
- ``prec`` -- desired precision of the local coordinates
- ``name`` -- gen of the power series ring (default: ``t``)
OUTPUT:
`(x(t),y(t))` such that `y(t)^2 = f(x(t))` and `t = x - a`
is the local parameter at `P`
EXAMPLES::
sage: R.<x> = QQ['x']
sage: H = HyperellipticCurve(x^5-23*x^3+18*x^2+40*x)
sage: P = H(1,6)
sage: x,y = H.local_coordinates_at_nonweierstrass(P,prec=5)
sage: x
1 + t + O(t^5)
sage: y
6 + t - 7/2*t^2 - 1/2*t^3 - 25/48*t^4 + O(t^5)
sage: Q = H(-2,12)
sage: x,y = H.local_coordinates_at_nonweierstrass(Q,prec=5)
sage: x
-2 + t + O(t^5)
sage: y
12 - 19/2*t - 19/32*t^2 + 61/256*t^3 - 5965/24576*t^4 + O(t^5)
AUTHOR:
- Jennifer Balakrishnan (2007-12)
"""
d = P[1]
if d == 0:
raise TypeError("P = %s is a Weierstrass point. Use local_coordinates_at_weierstrass instead!"%P)
pol = self.hyperelliptic_polynomials()[0]
L = PowerSeriesRing(self.base_ring(), name)
t = L.gen()
L.set_default_prec(prec)
K = PowerSeriesRing(L, 'x')
pol = K(pol)
x = K.gen()
b = P[0]
f = pol(t+b)
for i in range((RR(log(prec)/log(2))).ceil()):
d = (d + f/d)/2
return t+b+O(t**(prec)), d + O(t**(prec))
示例6: MFSeriesConstructor
class MFSeriesConstructor(SageObject,UniqueRepresentation):
r"""
Constructor for the Fourier expansion of some
(specific, basic) modular forms.
The constructor is used by forms elements in case
their Fourier expansion is needed or requested.
"""
@staticmethod
def __classcall__(cls, group = HeckeTriangleGroup(3), prec=ZZ(10)):
r"""
Return a (cached) instance with canonical parameters.
.. NOTE:
For each choice of group and precision the constructor is
cached (only) once. Further calculations with different
base rings and possibly numerical parameters are based on
the same cached instance.
EXAMPLES::
sage: from sage.modular.modform_hecketriangle.series_constructor import MFSeriesConstructor
sage: MFSeriesConstructor() == MFSeriesConstructor(3, 10)
True
sage: MFSeriesConstructor(group=4).hecke_n()
4
sage: MFSeriesConstructor(group=5, prec=12).prec()
12
"""
if (group==infinity):
group = HeckeTriangleGroup(infinity)
else:
try:
group = HeckeTriangleGroup(ZZ(group))
except TypeError:
group = HeckeTriangleGroup(group.n())
prec=ZZ(prec)
# We don't need this assumption the precision may in principle also be negative.
# if (prec<1):
# raise Exception("prec must be an Integer >=1")
return super(MFSeriesConstructor,cls).__classcall__(cls, group, prec)
def __init__(self, group, prec):
r"""
Constructor for the Fourier expansion of some
(specific, basic) modular forms.
INPUT:
- ``group`` -- A Hecke triangle group (default: HeckeTriangleGroup(3)).
- ``prec`` -- An integer (default: 10), the default precision used
in calculations in the LaurentSeriesRing or PowerSeriesRing.
OUTPUT:
The constructor for Fourier expansion with the specified settings.
EXAMPLES::
sage: from sage.modular.modform_hecketriangle.series_constructor import MFSeriesConstructor
sage: MFC = MFSeriesConstructor()
sage: MFC
Power series constructor for Hecke modular forms for n=3 with (basic series) precision 10
sage: MFC.group()
Hecke triangle group for n = 3
sage: MFC.prec()
10
sage: MFC._series_ring
Power Series Ring in q over Rational Field
sage: MFSeriesConstructor(group=4)
Power series constructor for Hecke modular forms for n=4 with (basic series) precision 10
sage: MFSeriesConstructor(group=5, prec=12)
Power series constructor for Hecke modular forms for n=5 with (basic series) precision 12
sage: MFSeriesConstructor(group=infinity)
Power series constructor for Hecke modular forms for n=+Infinity with (basic series) precision 10
"""
self._group = group
self._prec = prec
self._series_ring = PowerSeriesRing(QQ,'q',default_prec=self._prec)
def _repr_(self):
r"""
Return the string representation of ``self``.
EXAMPLES::
sage: from sage.modular.modform_hecketriangle.series_constructor import MFSeriesConstructor
sage: MFSeriesConstructor(group=4)
Power series constructor for Hecke modular forms for n=4 with (basic series) precision 10
sage: MFSeriesConstructor(group=5, prec=12)
Power series constructor for Hecke modular forms for n=5 with (basic series) precision 12
"""
#.........这里部分代码省略.........
示例7: __init__
def __init__(self, group, base_ring, prec, fix_d, set_d, d_num_prec):
r"""
Constructor for the Fourier expansion of some
(specific, basic) modular forms.
INPUT:
- ``group`` - A Hecke triangle group (default: HeckeTriangleGroup(3)).
- ``base_ring`` - The base ring (default: ZZ)
- ``prec`` - An integer (default: 10), the default precision used
in calculations in the LaurentSeriesRing or PowerSeriesRing.
- ``fix_d`` - ``True`` or ``False`` (default: ``False``).
If ``fix_d == False`` the base ring of the power series
is (the fraction field) of the polynomial ring over the base
ring in one formal parameter ``d``.
If ``fix_d == True`` the formal parameter ``d`` is replaced
by its numerical value with numerical precision at least ``d_num_prec``
(or exact in case n=3, 4, 6). The base ring of the PowerSeriesRing
or LaurentSeriesRing is changed to a common parent of
``base_ring`` and the parent of the mentioned value ``d``.
- ``set_d`` - A number which replaces the formal parameter ``d``.
The base ring of the PowerSeriesRing or LaurentSeriesRing is
changed to a common parent of ``base_ring``
and the parent of the specified value for ``d``.
Note that in particular ``set_d=1`` will produce
rational Fourier expansions.
- ``d_num_prec`` - An integer, a lower bound for the precision of the
numerical value of ``d``.
OUTPUT:
The constructor for Fourier expansion with the specified settings.
EXAMPLES::
sage: MFC = MFSeriesConstructor()
sage: MFC
Power series constructor for Hecke modular forms for n=3, base ring=Integer Ring
with (basic series) precision 10 with formal parameter d
sage: MFC.group()
Hecke triangle group for n = 3
sage: MFC.prec()
10
sage: MFC.d().parent()
Fraction Field of Univariate Polynomial Ring in d over Integer Ring
sage: MFC._ZZseries_ring
Power Series Ring in q over Rational Field
sage: MFSeriesConstructor(set_d=CC(1))
Power series constructor for Hecke modular forms for n=3, base ring=Complex Field with 53 bits of precision
with (basic series) precision 10 with parameter d=1.00000000000000
sage: MFSeriesConstructor(group=4, fix_d=True)
Power series constructor for Hecke modular forms for n=4, base ring=Rational Field
with (basic series) precision 10 with parameter d=1/256
sage: MFSeriesConstructor(group=5, fix_d=True)
Power series constructor for Hecke modular forms for n=5, base ring=Real Field with 53 bits of precision
with (basic series) precision 10 with parameter d=0.00705223418128563
"""
self._group = group
self._base_ring = base_ring
self._prec = prec
self._fix_d = fix_d
self._set_d = set_d
self._d_num_prec = d_num_prec
if (set_d):
self._coeff_ring = FractionField(base_ring)
self._d = set_d
else:
self._coeff_ring = FractionField(PolynomialRing(base_ring,"d"))
self._d = self._coeff_ring.gen()
self._ZZseries_ring = PowerSeriesRing(QQ,'q',default_prec=self._prec)
self._qseries_ring = PowerSeriesRing(self._coeff_ring,'q',default_prec=self._prec)
示例8: MFSeriesConstructor
class MFSeriesConstructor(SageObject,UniqueRepresentation):
r"""
Constructor for the Fourier expansion of some
(specific, basic) modular forms.
The constructor is used by forms elements in case
their Fourier expansion is needed or requested.
"""
@staticmethod
def __classcall__(cls, group = HeckeTriangleGroup(3), base_ring = ZZ, prec=ZZ(10), fix_d=False, set_d=None, d_num_prec=ZZ(53)):
r"""
Return a (cached) instance with canonical parameters.
In particular in case ``fix_d = True`` or if ``set_d`` is
set then the ``base_ring`` is replaced by the common parent
of ``base_ring`` and the parent of ``set_d`` (resp. the
numerical value of ``d`` in case ``fix_d=True``).
EXAMPLES::
sage: MFSeriesConstructor() == MFSeriesConstructor(3, ZZ, 10, False, None, 53)
True
sage: MFSeriesConstructor(base_ring = CC, set_d=CC(1)) == MFSeriesConstructor(set_d=CC(1))
True
sage: MFSeriesConstructor(group=4, fix_d=True).base_ring() == QQ
True
sage: MFSeriesConstructor(group=5, fix_d=True).base_ring() == RR
True
"""
if (group==infinity):
group = HeckeTriangleGroup(infinity)
else:
try:
group = HeckeTriangleGroup(ZZ(group))
except TypeError:
group = HeckeTriangleGroup(group.n())
prec=ZZ(prec)
#if (prec<1):
# raise Exception("prec must be an Integer >=1")
fix_d = bool(fix_d)
if (fix_d):
n = group.n()
d = group.dvalue()
if (group.is_arithmetic()):
d_num_prec = None
set_d = 1/base_ring(1/d)
else:
d_num_prec = ZZ(d_num_prec)
set_d = group.dvalue().n(d_num_prec)
else:
d_num_prec = None
if (set_d is not None):
base_ring=(base_ring(1)*set_d).parent()
#elif (not base_ring.is_exact()):
# raise NotImplementedError
return super(MFSeriesConstructor,cls).__classcall__(cls, group, base_ring, prec, fix_d, set_d, d_num_prec)
def __init__(self, group, base_ring, prec, fix_d, set_d, d_num_prec):
r"""
Constructor for the Fourier expansion of some
(specific, basic) modular forms.
INPUT:
- ``group`` - A Hecke triangle group (default: HeckeTriangleGroup(3)).
- ``base_ring`` - The base ring (default: ZZ)
- ``prec`` - An integer (default: 10), the default precision used
in calculations in the LaurentSeriesRing or PowerSeriesRing.
- ``fix_d`` - ``True`` or ``False`` (default: ``False``).
If ``fix_d == False`` the base ring of the power series
is (the fraction field) of the polynomial ring over the base
ring in one formal parameter ``d``.
If ``fix_d == True`` the formal parameter ``d`` is replaced
by its numerical value with numerical precision at least ``d_num_prec``
(or exact in case n=3, 4, 6). The base ring of the PowerSeriesRing
or LaurentSeriesRing is changed to a common parent of
``base_ring`` and the parent of the mentioned value ``d``.
- ``set_d`` - A number which replaces the formal parameter ``d``.
The base ring of the PowerSeriesRing or LaurentSeriesRing is
changed to a common parent of ``base_ring``
and the parent of the specified value for ``d``.
Note that in particular ``set_d=1`` will produce
rational Fourier expansions.
- ``d_num_prec`` - An integer, a lower bound for the precision of the
numerical value of ``d``.
OUTPUT:
#.........这里部分代码省略.........
示例9: JFSeriesConstructor
class JFSeriesConstructor(SageObject,UniqueRepresentation):
r"""
Constructor for the Fourier expansion of some
(specific, basic) modular forms.
The constructor is used by forms elements in case
their Fourier expansion is needed or requested.
"""
@staticmethod
def __classcall__(cls, group = HeckeTriangleGroup(3), prec=ZZ(10)):
r"""
Return a (cached) instance with canonical parameters.
.. NOTE:
For each choice of group and precision the constructor is
cached (only) once. Further calculations with different
base rings and possibly numerical parameters are based on
the same cached instance.
EXAMPLES::
sage: from sage.modular.modform_hecketriangle.series_constructor import JFSeriesConstructor
sage: JFSeriesConstructor() == JFSeriesConstructor(3, 10)
True
sage: JFSeriesConstructor(group=4).hecke_n()
4
sage: JFSeriesConstructor(group=5, prec=12).prec()
12
"""
if (group==infinity):
group = HeckeTriangleGroup(infinity)
else:
try:
group = HeckeTriangleGroup(ZZ(group))
except TypeError:
group = HeckeTriangleGroup(group.n())
prec=ZZ(prec)
# We don't need this assumption the precision may in principle also be negative.
# if (prec<1):
# raise Exception("prec must be an Integer >=1")
return super(JFSeriesConstructor,cls).__classcall__(cls, group, prec)
def __init__(self, group, prec):
r"""
Constructor for the Fourier expansion of some
(specific, basic) modular forms.
INPUT:
- ``group`` -- A Hecke triangle group (default: HeckeTriangleGroup(3)).
- ``prec`` -- An integer (default: 10), the default precision used
in calculations in the LaurentSeriesRing or PowerSeriesRing.
OUTPUT:
The constructor for Fourier expansion with the specified settings.
EXAMPLES::
sage: from sage.modular.modform_hecketriangle.series_constructor import JFSeriesConstructor
sage: JFC = JFSeriesConstructor()
sage: JFC
Power series constructor for Hecke modular forms for n=3 with (basic series) precision 10
sage: JFC.group()
Hecke triangle group for n = 3
sage: JFC.prec()
10
sage: JFC._series_ring
Power Series Ring in q over Rational Field
sage: JFSeriesConstructor(group=4)
Power series constructor for Hecke modular forms for n=4 with (basic series) precision 10
sage: JFSeriesConstructor(group=5, prec=12)
Power series constructor for Hecke modular forms for n=5 with (basic series) precision 12
sage: JFSeriesConstructor(group=infinity)
Power series constructor for Hecke modular forms for n=+Infinity with (basic series) precision 10
"""
self._group = group
self._prec = prec
FR = FractionField(PolynomialRing(ZZ,'p,d'))
self._series_ring = PowerSeriesRing(FR,'q',default_prec=self._prec)
#self._series_ring2 = PowerSeriesRing(QQ[['q']],'p',default_prec=self._prec)
self._qseries_ring = PowerSeriesRing(QQ,'q',default_prec=self._prec)
def _repr_(self):
r"""
Return the string representation of ``self``.
EXAMPLES::
sage: from sage.modular.modform_hecketriangle.series_constructor import JFSeriesConstructor
sage: JFSeriesConstructor(group=4)
Power series constructor for Hecke modular forms for n=4 with (basic series) precision 10
#.........这里部分代码省略.........
示例10: series
def series(self, n=2, quadratic_twist=+1, prec=5):
r"""
Returns the `n`-th approximation to the `p`-adic L-series as a
power series in `T` (corresponding to `\gamma-1` with
`\gamma=1+p` as a generator of `1+p\ZZ_p`). Each coefficient
is a `p`-adic number whose precision is provably correct.
Here the normalization of the `p`-adic L-series is chosen such
that `L_p(J,1) = (1-1/\alpha)^2 L(J,1)/\Omega_J` where
`\alpha` is the unit root
INPUT:
- ``n`` - (default: 2) a positive integer
- ``quadratic_twist`` - (default: +1) a fundamental
discriminant of a quadratic field, coprime to the
conductor of the curve
- ``prec`` - (default: 5) maximal number of terms of the
series to compute; to compute as many as possible just
give a very large number for ``prec``; the result will
still be correct.
ALIAS: power_series is identical to series.
EXAMPLES:
sage: J = J0(188)[0]
sage: p = 7
sage: L = J.padic_lseries(p)
sage: L.is_ordinary()
True
sage: f = L.series(2)
sage: f[0]
O(7^20)
sage: f[1].norm()
3 + 4*7 + 3*7^2 + 6*7^3 + 5*7^4 + 5*7^5 + 6*7^6 + 4*7^7 + 5*7^8 + 7^10 + 5*7^11 + 4*7^13 + 4*7^14 + 5*7^15 + 2*7^16 + 5*7^17 + 7^18 + 7^19 + O(7^20)
"""
n = ZZ(n)
if n < 1:
raise ValueError, "n (=%s) must be a positive integer"%n
if not self.is_ordinary():
raise ValueError, "p (=%s) must be an ordinary prime"%p
# check if the conditions on quadratic_twist are satisfied
D = ZZ(quadratic_twist)
if D != 1:
if D % 4 == 0:
d = D//4
if not d.is_squarefree() or d % 4 == 1:
raise ValueError, "quadratic_twist (=%s) must be a fundamental discriminant of a quadratic field"%D
else:
if not D.is_squarefree() or D % 4 != 1:
raise ValueError, "quadratic_twist (=%s) must be a fundamental discriminant of a quadratic field"%D
if gcd(D,self._p) != 1:
raise ValueError, "quadratic twist (=%s) must be coprime to p (=%s) "%(D,self._p)
if gcd(D,self._E.conductor())!= 1:
for ell in prime_divisors(D):
if valuation(self._E.conductor(),ell) > valuation(D,ell) :
raise ValueError, "can not twist a curve of conductor (=%s) by the quadratic twist (=%s)."%(self._E.conductor(),D)
p = self._p
if p == 2 and self._normalize :
print 'Warning : For p=2 the normalization might not be correct !'
#verbose("computing L-series for p=%s, n=%s, and prec=%s"%(p,n,prec))
# bounds = self._prec_bounds(n,prec)
# padic_prec = max(bounds[1:]) + 5
padic_prec = 10
# verbose("using p-adic precision of %s"%padic_prec)
res_series_prec = min(p**(n-1), prec)
verbose("using series precision of %s"%res_series_prec)
ans = self._get_series_from_cache(n, res_series_prec,D)
if not ans is None:
verbose("found series in cache")
return ans
K = QQ
gamma = K(1 + p)
R = PowerSeriesRing(K,'T',res_series_prec)
T = R(R.gen(),res_series_prec )
#L = R(0)
one_plus_T_factor = R(1)
gamma_power = K(1)
teich = self.teichmuller(padic_prec)
p_power = p**(n-1)
# F = Qp(p,padic_prec)
verbose("Now iterating over %s summands"%((p-1)*p_power))
verbose_level = get_verbose()
count_verb = 0
alphas = self.alpha()
#print len(alphas)
Lprod = []
self._emb = 0
if len(alphas) == 2:
split = True
else:
#.........这里部分代码省略.........