Power Series Rings

Power series rings are constructed in the standard Sage fashion. See also Multivariate Power Series Rings.

EXAMPLES:

Construct rings and elements:

sage: R.<t> = PowerSeriesRing(QQ)
sage: R.random_element(6)  # random
-4 - 1/2*t^2 - 1/95*t^3 + 1/2*t^4 - 12*t^5 + O(t^6)
>>> from sage.all import *
>>> R = PowerSeriesRing(QQ, names=('t',)); (t,) = R._first_ngens(1)
>>> R.random_element(Integer(6))  # random
-4 - 1/2*t^2 - 1/95*t^3 + 1/2*t^4 - 12*t^5 + O(t^6)

sage: R.<t,u,v> = PowerSeriesRing(QQ); R
Multivariate Power Series Ring in t, u, v over Rational Field
sage: p = -t + 1/2*t^3*u - 1/4*t^4*u + 2/3*v^5 + R.O(6); p
-t + 1/2*t^3*u - 1/4*t^4*u + 2/3*v^5 + O(t, u, v)^6
sage: p in R
True
>>> from sage.all import *
>>> R = PowerSeriesRing(QQ, names=('t', 'u', 'v',)); (t, u, v,) = R._first_ngens(3); R
Multivariate Power Series Ring in t, u, v over Rational Field
>>> p = -t + Integer(1)/Integer(2)*t**Integer(3)*u - Integer(1)/Integer(4)*t**Integer(4)*u + Integer(2)/Integer(3)*v**Integer(5) + R.O(Integer(6)); p
-t + 1/2*t^3*u - 1/4*t^4*u + 2/3*v^5 + O(t, u, v)^6
>>> p in R
True

The default precision is specified at construction, but does not bound the precision of created elements.

sage: R.<t> = PowerSeriesRing(QQ, default_prec=5)
sage: R.random_element(6)  # random
1/2 - 1/4*t + 2/3*t^2 - 5/2*t^3 + 2/3*t^5 + O(t^6)
>>> from sage.all import *
>>> R = PowerSeriesRing(QQ, default_prec=Integer(5), names=('t',)); (t,) = R._first_ngens(1)
>>> R.random_element(Integer(6))  # random
1/2 - 1/4*t + 2/3*t^2 - 5/2*t^3 + 2/3*t^5 + O(t^6)

Construct univariate power series from a list of coefficients:

sage: S = R([1, 3, 5, 7]); S
1 + 3*t + 5*t^2 + 7*t^3
>>> from sage.all import *
>>> S = R([Integer(1), Integer(3), Integer(5), Integer(7)]); S
1 + 3*t + 5*t^2 + 7*t^3

The default precision of a power series ring stays fixed and cannot be changed. To work with different default precision, create a new power series ring:

sage: R.<x> = PowerSeriesRing(QQ, default_prec=10)
sage: sin(x)
x - 1/6*x^3 + 1/120*x^5 - 1/5040*x^7 + 1/362880*x^9 + O(x^10)
sage: R.<x> = PowerSeriesRing(QQ, default_prec=15)
sage: sin(x)
x - 1/6*x^3 + 1/120*x^5 - 1/5040*x^7 + 1/362880*x^9 - 1/39916800*x^11
+ 1/6227020800*x^13 + O(x^15)
>>> from sage.all import *
>>> R = PowerSeriesRing(QQ, default_prec=Integer(10), names=('x',)); (x,) = R._first_ngens(1)
>>> sin(x)
x - 1/6*x^3 + 1/120*x^5 - 1/5040*x^7 + 1/362880*x^9 + O(x^10)
>>> R = PowerSeriesRing(QQ, default_prec=Integer(15), names=('x',)); (x,) = R._first_ngens(1)
>>> sin(x)
x - 1/6*x^3 + 1/120*x^5 - 1/5040*x^7 + 1/362880*x^9 - 1/39916800*x^11
+ 1/6227020800*x^13 + O(x^15)

An iterated example:

sage: R.<t> = PowerSeriesRing(ZZ)
sage: S.<t2> = PowerSeriesRing(R)
sage: S
Power Series Ring in t2 over Power Series Ring in t over Integer Ring
sage: S.base_ring()
Power Series Ring in t over Integer Ring
>>> from sage.all import *
>>> R = PowerSeriesRing(ZZ, names=('t',)); (t,) = R._first_ngens(1)
>>> S = PowerSeriesRing(R, names=('t2',)); (t2,) = S._first_ngens(1)
>>> S
Power Series Ring in t2 over Power Series Ring in t over Integer Ring
>>> S.base_ring()
Power Series Ring in t over Integer Ring

Sage can compute with power series over the symbolic ring.

sage: # needs sage.symbolic
sage: K.<t> = PowerSeriesRing(SR, default_prec=5)
sage: a, b, c = var('a,b,c')
sage: f = a + b*t + c*t^2 + O(t^3)
sage: f*f
a^2 + 2*a*b*t + (b^2 + 2*a*c)*t^2 + O(t^3)
sage: f = sqrt(2) + sqrt(3)*t + O(t^3)
sage: f^2
2 + 2*sqrt(3)*sqrt(2)*t + 3*t^2 + O(t^3)
>>> from sage.all import *
>>> # needs sage.symbolic
>>> K = PowerSeriesRing(SR, default_prec=Integer(5), names=('t',)); (t,) = K._first_ngens(1)
>>> a, b, c = var('a,b,c')
>>> f = a + b*t + c*t**Integer(2) + O(t**Integer(3))
>>> f*f
a^2 + 2*a*b*t + (b^2 + 2*a*c)*t^2 + O(t^3)
>>> f = sqrt(Integer(2)) + sqrt(Integer(3))*t + O(t**Integer(3))
>>> f**Integer(2)
2 + 2*sqrt(3)*sqrt(2)*t + 3*t^2 + O(t^3)

Elements are first coerced to constants in base_ring, then coerced into the PowerSeriesRing:

sage: R.<t> = PowerSeriesRing(ZZ)
sage: f = Mod(2, 3) * t; (f, f.parent())
(2*t, Power Series Ring in t over Ring of integers modulo 3)
>>> from sage.all import *
>>> R = PowerSeriesRing(ZZ, names=('t',)); (t,) = R._first_ngens(1)
>>> f = Mod(Integer(2), Integer(3)) * t; (f, f.parent())
(2*t, Power Series Ring in t over Ring of integers modulo 3)

We make a sparse power series.

sage: R.<x> = PowerSeriesRing(QQ, sparse=True); R
Sparse Power Series Ring in x over Rational Field
sage: f = 1 + x^1000000
sage: g = f*f
sage: g.degree()
2000000
>>> from sage.all import *
>>> R = PowerSeriesRing(QQ, sparse=True, names=('x',)); (x,) = R._first_ngens(1); R
Sparse Power Series Ring in x over Rational Field
>>> f = Integer(1) + x**Integer(1000000)
>>> g = f*f
>>> g.degree()
2000000

We make a sparse Laurent series from a power series generator:

sage: R.<t> = PowerSeriesRing(QQ, sparse=True)
sage: latex(-2/3*(1/t^3) + 1/t + 3/5*t^2 + O(t^5))
\frac{-\frac{2}{3}}{t^{3}} + \frac{1}{t} + \frac{3}{5}t^{2} + O(t^{5})
sage: S = parent(1/t); S
Sparse Laurent Series Ring in t over Rational Field
>>> from sage.all import *
>>> R = PowerSeriesRing(QQ, sparse=True, names=('t',)); (t,) = R._first_ngens(1)
>>> latex(-Integer(2)/Integer(3)*(Integer(1)/t**Integer(3)) + Integer(1)/t + Integer(3)/Integer(5)*t**Integer(2) + O(t**Integer(5)))
\frac{-\frac{2}{3}}{t^{3}} + \frac{1}{t} + \frac{3}{5}t^{2} + O(t^{5})
>>> S = parent(Integer(1)/t); S
Sparse Laurent Series Ring in t over Rational Field

Choose another implementation of the attached polynomial ring:

sage: R.<t> = PowerSeriesRing(ZZ)
sage: type(t.polynomial())                                                          # needs sage.libs.flint
<... 'sage.rings.polynomial.polynomial_integer_dense_flint.Polynomial_integer_dense_flint'>
sage: S.<s> = PowerSeriesRing(ZZ, implementation='NTL')                             # needs sage.libs.ntl
sage: type(s.polynomial())                                                          # needs sage.libs.ntl
<... 'sage.rings.polynomial.polynomial_integer_dense_ntl.Polynomial_integer_dense_ntl'>
>>> from sage.all import *
>>> R = PowerSeriesRing(ZZ, names=('t',)); (t,) = R._first_ngens(1)
>>> type(t.polynomial())                                                          # needs sage.libs.flint
<... 'sage.rings.polynomial.polynomial_integer_dense_flint.Polynomial_integer_dense_flint'>
>>> S = PowerSeriesRing(ZZ, implementation='NTL', names=('s',)); (s,) = S._first_ngens(1)# needs sage.libs.ntl
>>> type(s.polynomial())                                                          # needs sage.libs.ntl
<... 'sage.rings.polynomial.polynomial_integer_dense_ntl.Polynomial_integer_dense_ntl'>

AUTHORS:

  • William Stein: the code

  • Jeremy Cho (2006-05-17): some examples (above)

  • Niles Johnson (2010-09): implement multivariate power series

  • Simon King (2012-08): use category and coercion framework, Issue #13412

sage.rings.power_series_ring.PowerSeriesRing(base_ring, name=None, arg2=None, names=None, sparse=False, default_prec=None, order='negdeglex', num_gens=None, implementation=None)[source]

Create a univariate or multivariate power series ring over a given (commutative) base ring.

INPUT:

  • base_ring – a commutative ring

  • name, names – name(s) of the indeterminate

  • default_prec – the default precision used if an exact object must be changed to an approximate object in order to do an arithmetic operation. If left as None, it will be set to the global default (20) in the univariate case, and 12 in the multivariate case.

  • sparse – boolean (default: False); whether power series are represented as sparse objects

  • order – (default: negdeglex) term ordering, for multivariate case

  • num_gens – number of generators, for multivariate case

There is a unique power series ring over each base ring with given variable name. Two power series over the same base ring with different variable names are not equal or isomorphic.

EXAMPLES (Univariate):

sage: R = PowerSeriesRing(QQ, 'x'); R
Power Series Ring in x over Rational Field
>>> from sage.all import *
>>> R = PowerSeriesRing(QQ, 'x'); R
Power Series Ring in x over Rational Field

sage: S = PowerSeriesRing(QQ, 'y'); S
Power Series Ring in y over Rational Field
>>> from sage.all import *
>>> S = PowerSeriesRing(QQ, 'y'); S
Power Series Ring in y over Rational Field

sage: R = PowerSeriesRing(QQ, 10)
Traceback (most recent call last):
...
ValueError: variable name '10' does not start with a letter
>>> from sage.all import *
>>> R = PowerSeriesRing(QQ, Integer(10))
Traceback (most recent call last):
...
ValueError: variable name '10' does not start with a letter

sage: S = PowerSeriesRing(QQ, 'x', default_prec=15); S
Power Series Ring in x over Rational Field
sage: S.default_prec()
15
>>> from sage.all import *
>>> S = PowerSeriesRing(QQ, 'x', default_prec=Integer(15)); S
Power Series Ring in x over Rational Field
>>> S.default_prec()
15

EXAMPLES (Multivariate) See also Multivariate Power Series Rings:

sage: R = PowerSeriesRing(QQ, 't,u,v'); R
Multivariate Power Series Ring in t, u, v over Rational Field
>>> from sage.all import *
>>> R = PowerSeriesRing(QQ, 't,u,v'); R
Multivariate Power Series Ring in t, u, v over Rational Field

sage: N = PowerSeriesRing(QQ,'w',num_gens=5); N
Multivariate Power Series Ring in w0, w1, w2, w3, w4 over Rational Field
>>> from sage.all import *
>>> N = PowerSeriesRing(QQ,'w',num_gens=Integer(5)); N
Multivariate Power Series Ring in w0, w1, w2, w3, w4 over Rational Field

Number of generators can be specified before variable name without using keyword:

sage: M = PowerSeriesRing(QQ,4,'k'); M
Multivariate Power Series Ring in k0, k1, k2, k3 over Rational Field
>>> from sage.all import *
>>> M = PowerSeriesRing(QQ,Integer(4),'k'); M
Multivariate Power Series Ring in k0, k1, k2, k3 over Rational Field

Multivariate power series can be constructed using angle bracket or double square bracket notation:

sage: R.<t,u,v> = PowerSeriesRing(QQ, 't,u,v'); R
Multivariate Power Series Ring in t, u, v over Rational Field

sage: ZZ[['s,t,u']]
Multivariate Power Series Ring in s, t, u over Integer Ring
>>> from sage.all import *
>>> R = PowerSeriesRing(QQ, 't,u,v', names=('t', 'u', 'v',)); (t, u, v,) = R._first_ngens(3); R
Multivariate Power Series Ring in t, u, v over Rational Field

>>> ZZ[['s,t,u']]
Multivariate Power Series Ring in s, t, u over Integer Ring

Sparse multivariate power series ring:

sage: M = PowerSeriesRing(QQ,4,'k',sparse=True); M
Sparse Multivariate Power Series Ring in k0, k1, k2, k3 over
Rational Field
>>> from sage.all import *
>>> M = PowerSeriesRing(QQ,Integer(4),'k',sparse=True); M
Sparse Multivariate Power Series Ring in k0, k1, k2, k3 over
Rational Field

Power series ring over polynomial ring:

sage: H = PowerSeriesRing(PolynomialRing(ZZ,3,'z'), 4, 'f'); H
Multivariate Power Series Ring in f0, f1, f2, f3 over Multivariate
Polynomial Ring in z0, z1, z2 over Integer Ring
>>> from sage.all import *
>>> H = PowerSeriesRing(PolynomialRing(ZZ,Integer(3),'z'), Integer(4), 'f'); H
Multivariate Power Series Ring in f0, f1, f2, f3 over Multivariate
Polynomial Ring in z0, z1, z2 over Integer Ring

Power series ring over finite field:

sage: S = PowerSeriesRing(GF(65537),'x,y'); S                                   # needs sage.rings.finite_rings
Multivariate Power Series Ring in x, y over Finite Field of size
65537
>>> from sage.all import *
>>> S = PowerSeriesRing(GF(Integer(65537)),'x,y'); S                                   # needs sage.rings.finite_rings
Multivariate Power Series Ring in x, y over Finite Field of size
65537

Power series ring with many variables:

sage: R = PowerSeriesRing(ZZ, ['x%s'%p for p in primes(100)]); R                # needs sage.libs.pari
Multivariate Power Series Ring in x2, x3, x5, x7, x11, x13, x17, x19,
x23, x29, x31, x37, x41, x43, x47, x53, x59, x61, x67, x71, x73, x79,
x83, x89, x97 over Integer Ring
>>> from sage.all import *
>>> R = PowerSeriesRing(ZZ, ['x%s'%p for p in primes(Integer(100))]); R                # needs sage.libs.pari
Multivariate Power Series Ring in x2, x3, x5, x7, x11, x13, x17, x19,
x23, x29, x31, x37, x41, x43, x47, x53, x59, x61, x67, x71, x73, x79,
x83, x89, x97 over Integer Ring
  • Use inject_variables() to make the variables available for interactive use.

    sage: R.inject_variables()                                                      # needs sage.libs.pari
    Defining x2, x3, x5, x7, x11, x13, x17, x19, x23, x29, x31, x37,
    x41, x43, x47, x53, x59, x61, x67, x71, x73, x79, x83, x89, x97
    
    sage: f = x47 + 3*x11*x29 - x19 + R.O(3)                                        # needs sage.libs.pari
    sage: f in R                                                                    # needs sage.libs.pari
    True
    
    >>> from sage.all import *
    >>> R.inject_variables()                                                      # needs sage.libs.pari
    Defining x2, x3, x5, x7, x11, x13, x17, x19, x23, x29, x31, x37,
    x41, x43, x47, x53, x59, x61, x67, x71, x73, x79, x83, x89, x97
    
    >>> f = x47 + Integer(3)*x11*x29 - x19 + R.O(Integer(3))                                        # needs sage.libs.pari
    >>> f in R                                                                    # needs sage.libs.pari
    True
    

Variable ordering determines how series are displayed:

sage: T.<a,b> = PowerSeriesRing(ZZ,order='deglex'); T
Multivariate Power Series Ring in a, b over Integer Ring
sage: T.term_order()
Degree lexicographic term order
sage: p = - 2*b^6 + a^5*b^2 + a^7 - b^2 - a*b^3 + T.O(9); p
a^7 + a^5*b^2 - 2*b^6 - a*b^3 - b^2 + O(a, b)^9

sage: U = PowerSeriesRing(ZZ,'a,b',order='negdeglex'); U
Multivariate Power Series Ring in a, b over Integer Ring
sage: U.term_order()
Negative degree lexicographic term order
sage: U(p)
-b^2 - a*b^3 - 2*b^6 + a^7 + a^5*b^2 + O(a, b)^9
>>> from sage.all import *
>>> T = PowerSeriesRing(ZZ,order='deglex', names=('a', 'b',)); (a, b,) = T._first_ngens(2); T
Multivariate Power Series Ring in a, b over Integer Ring
>>> T.term_order()
Degree lexicographic term order
>>> p = - Integer(2)*b**Integer(6) + a**Integer(5)*b**Integer(2) + a**Integer(7) - b**Integer(2) - a*b**Integer(3) + T.O(Integer(9)); p
a^7 + a^5*b^2 - 2*b^6 - a*b^3 - b^2 + O(a, b)^9

>>> U = PowerSeriesRing(ZZ,'a,b',order='negdeglex'); U
Multivariate Power Series Ring in a, b over Integer Ring
>>> U.term_order()
Negative degree lexicographic term order
>>> U(p)
-b^2 - a*b^3 - 2*b^6 + a^7 + a^5*b^2 + O(a, b)^9
class sage.rings.power_series_ring.PowerSeriesRing_domain(base_ring, name=None, default_prec=None, sparse=False, implementation=None, category=None)[source]

Bases: PowerSeriesRing_generic, IntegralDomain

fraction_field()[source]

Return the Laurent series ring over the fraction field of the base ring.

This is actually not the fraction field of this ring, but its completion with respect to the topology defined by the valuation. When we are working at finite precision, these two fields are indistinguishable; that is the reason why we allow ourselves to make this confusion here.

EXAMPLES:

sage: R.<t> = PowerSeriesRing(ZZ)
sage: R.fraction_field()
Laurent Series Ring in t over Rational Field
sage: Frac(R)
Laurent Series Ring in t over Rational Field
>>> from sage.all import *
>>> R = PowerSeriesRing(ZZ, names=('t',)); (t,) = R._first_ngens(1)
>>> R.fraction_field()
Laurent Series Ring in t over Rational Field
>>> Frac(R)
Laurent Series Ring in t over Rational Field
class sage.rings.power_series_ring.PowerSeriesRing_generic(base_ring, name=None, default_prec=None, sparse=False, implementation=None, category=None)[source]

Bases: UniqueRepresentation, Parent, Nonexact

A power series ring.

base_extend(R)[source]

Return the power series ring over \(R\) in the same variable as self, assuming there is a canonical coerce map from the base ring of self to \(R\).

EXAMPLES:

sage: R.<T> = GF(7)[[]]; R
Power Series Ring in T over Finite Field of size 7
sage: R.change_ring(ZZ)
Power Series Ring in T over Integer Ring
sage: R.base_extend(ZZ)
Traceback (most recent call last):
...
TypeError: no base extension defined
>>> from sage.all import *
>>> R = GF(Integer(7))[['T']]; (T,) = R._first_ngens(1); R
Power Series Ring in T over Finite Field of size 7
>>> R.change_ring(ZZ)
Power Series Ring in T over Integer Ring
>>> R.base_extend(ZZ)
Traceback (most recent call last):
...
TypeError: no base extension defined
change_ring(R)[source]

Return the power series ring over \(R\) in the same variable as self.

EXAMPLES:

sage: R.<T> = QQ[[]]; R
Power Series Ring in T over Rational Field
sage: R.change_ring(GF(7))
Power Series Ring in T over Finite Field of size 7
sage: R.base_extend(GF(7))
Traceback (most recent call last):
...
TypeError: no base extension defined
sage: R.base_extend(QuadraticField(3,'a'))                                  # needs sage.rings.number_field
Power Series Ring in T over Number Field in a
 with defining polynomial x^2 - 3 with a = 1.732050807568878?
>>> from sage.all import *
>>> R = QQ[['T']]; (T,) = R._first_ngens(1); R
Power Series Ring in T over Rational Field
>>> R.change_ring(GF(Integer(7)))
Power Series Ring in T over Finite Field of size 7
>>> R.base_extend(GF(Integer(7)))
Traceback (most recent call last):
...
TypeError: no base extension defined
>>> R.base_extend(QuadraticField(Integer(3),'a'))                                  # needs sage.rings.number_field
Power Series Ring in T over Number Field in a
 with defining polynomial x^2 - 3 with a = 1.732050807568878?
change_var(var)[source]

Return the power series ring in variable var over the same base ring.

EXAMPLES:

sage: R.<T> = QQ[[]]; R
Power Series Ring in T over Rational Field
sage: R.change_var('D')
Power Series Ring in D over Rational Field
>>> from sage.all import *
>>> R = QQ[['T']]; (T,) = R._first_ngens(1); R
Power Series Ring in T over Rational Field
>>> R.change_var('D')
Power Series Ring in D over Rational Field
characteristic()[source]

Return the characteristic of this power series ring, which is the same as the characteristic of the base ring of the power series ring.

EXAMPLES:

sage: R.<t> = PowerSeriesRing(ZZ)
sage: R.characteristic()
0
sage: R.<w> = Integers(2^50)[[]]; R
Power Series Ring in w over Ring of integers modulo 1125899906842624
sage: R.characteristic()
1125899906842624
>>> from sage.all import *
>>> R = PowerSeriesRing(ZZ, names=('t',)); (t,) = R._first_ngens(1)
>>> R.characteristic()
0
>>> R = Integers(Integer(2)**Integer(50))[['w']]; (w,) = R._first_ngens(1); R
Power Series Ring in w over Ring of integers modulo 1125899906842624
>>> R.characteristic()
1125899906842624
construction()[source]

Return the functorial construction of self, namely, completion of the univariate polynomial ring with respect to the indeterminate (to a given precision).

EXAMPLES:

sage: R = PowerSeriesRing(ZZ, 'x')
sage: c, S = R.construction(); S
Univariate Polynomial Ring in x over Integer Ring
sage: R == c(S)
True
sage: R = PowerSeriesRing(ZZ, 'x', sparse=True)
sage: c, S = R.construction()
sage: R == c(S)
True
>>> from sage.all import *
>>> R = PowerSeriesRing(ZZ, 'x')
>>> c, S = R.construction(); S
Univariate Polynomial Ring in x over Integer Ring
>>> R == c(S)
True
>>> R = PowerSeriesRing(ZZ, 'x', sparse=True)
>>> c, S = R.construction()
>>> R == c(S)
True
gen(n=0)[source]

Return the generator of this power series ring.

EXAMPLES:

sage: R.<t> = PowerSeriesRing(ZZ)
sage: R.gen()
t
sage: R.gen(3)
Traceback (most recent call last):
...
IndexError: generator n>0 not defined
>>> from sage.all import *
>>> R = PowerSeriesRing(ZZ, names=('t',)); (t,) = R._first_ngens(1)
>>> R.gen()
t
>>> R.gen(Integer(3))
Traceback (most recent call last):
...
IndexError: generator n>0 not defined
gens()[source]

Return the generators of this ring.

EXAMPLES:

sage: R.<t> = PowerSeriesRing(ZZ)
sage: R.gens()
(t,)
>>> from sage.all import *
>>> R = PowerSeriesRing(ZZ, names=('t',)); (t,) = R._first_ngens(1)
>>> R.gens()
(t,)
is_dense()[source]

EXAMPLES:

sage: R.<t> = PowerSeriesRing(ZZ)
sage: t.is_dense()
True
sage: R.<t> = PowerSeriesRing(ZZ, sparse=True)
sage: t.is_dense()
False
>>> from sage.all import *
>>> R = PowerSeriesRing(ZZ, names=('t',)); (t,) = R._first_ngens(1)
>>> t.is_dense()
True
>>> R = PowerSeriesRing(ZZ, sparse=True, names=('t',)); (t,) = R._first_ngens(1)
>>> t.is_dense()
False
is_exact()[source]

Return False since the ring of power series over any ring is not exact.

EXAMPLES:

sage: R.<t> = PowerSeriesRing(ZZ)
sage: R.is_exact()
False
>>> from sage.all import *
>>> R = PowerSeriesRing(ZZ, names=('t',)); (t,) = R._first_ngens(1)
>>> R.is_exact()
False
is_field(proof=True)[source]

Return False since the ring of power series over any ring is never a field.

EXAMPLES:

sage: R.<t> = PowerSeriesRing(ZZ)
sage: R.is_field()
False
>>> from sage.all import *
>>> R = PowerSeriesRing(ZZ, names=('t',)); (t,) = R._first_ngens(1)
>>> R.is_field()
False
is_finite()[source]

Return False since the ring of power series over any ring is never finite.

EXAMPLES:

sage: R.<t> = PowerSeriesRing(ZZ)
sage: R.is_finite()
False
>>> from sage.all import *
>>> R = PowerSeriesRing(ZZ, names=('t',)); (t,) = R._first_ngens(1)
>>> R.is_finite()
False
is_sparse()[source]

EXAMPLES:

sage: R.<t> = PowerSeriesRing(ZZ)
sage: t.is_sparse()
False
sage: R.<t> = PowerSeriesRing(ZZ, sparse=True)
sage: t.is_sparse()
True
>>> from sage.all import *
>>> R = PowerSeriesRing(ZZ, names=('t',)); (t,) = R._first_ngens(1)
>>> t.is_sparse()
False
>>> R = PowerSeriesRing(ZZ, sparse=True, names=('t',)); (t,) = R._first_ngens(1)
>>> t.is_sparse()
True
laurent_series_ring()[source]

If this is the power series ring \(R[[t]]\), return the Laurent series ring \(R((t))\).

EXAMPLES:

sage: R.<t> = PowerSeriesRing(ZZ, default_prec=5)
sage: S = R.laurent_series_ring(); S
Laurent Series Ring in t over Integer Ring
sage: S.default_prec()
5
sage: f = 1 + t; g = 1/f; g
1 - t + t^2 - t^3 + t^4 + O(t^5)
>>> from sage.all import *
>>> R = PowerSeriesRing(ZZ, default_prec=Integer(5), names=('t',)); (t,) = R._first_ngens(1)
>>> S = R.laurent_series_ring(); S
Laurent Series Ring in t over Integer Ring
>>> S.default_prec()
5
>>> f = Integer(1) + t; g = Integer(1)/f; g
1 - t + t^2 - t^3 + t^4 + O(t^5)
ngens()[source]

Return the number of generators of this power series ring.

This is always 1.

EXAMPLES:

sage: R.<t> = ZZ[[]]
sage: R.ngens()
1
>>> from sage.all import *
>>> R = ZZ[['t']]; (t,) = R._first_ngens(1)
>>> R.ngens()
1
random_element(prec=None, *args, **kwds)[source]

Return a random power series.

INPUT:

  • prec – integer specifying precision of output (default: default precision of self)

  • *args, **kwds – passed on to the random_element method for the base ring

OUTPUT:

Power series with precision prec whose coefficients are random elements from the base ring, randomized subject to the arguments *args and **kwds.

ALGORITHM:

Call the random_element method on the underlying polynomial ring.

EXAMPLES:

sage: R.<t> = PowerSeriesRing(QQ)
sage: R.random_element(5)  # random
-4 - 1/2*t^2 - 1/95*t^3 + 1/2*t^4 + O(t^5)
sage: R.random_element(10)  # random
-1/2 + 2*t - 2/7*t^2 - 25*t^3 - t^4 + 2*t^5 - 4*t^7 - 1/3*t^8 - t^9 + O(t^10)
>>> from sage.all import *
>>> R = PowerSeriesRing(QQ, names=('t',)); (t,) = R._first_ngens(1)
>>> R.random_element(Integer(5))  # random
-4 - 1/2*t^2 - 1/95*t^3 + 1/2*t^4 + O(t^5)
>>> R.random_element(Integer(10))  # random
-1/2 + 2*t - 2/7*t^2 - 25*t^3 - t^4 + 2*t^5 - 4*t^7 - 1/3*t^8 - t^9 + O(t^10)

If given no argument, random_element uses default precision of self:

sage: T = PowerSeriesRing(ZZ,'t')
sage: T.default_prec()
20
sage: T.random_element()  # random
4 + 2*t - t^2 - t^3 + 2*t^4 + t^5 + t^6 - 2*t^7 - t^8 - t^9 + t^11
 - 6*t^12 + 2*t^14 + 2*t^16 - t^17 - 3*t^18 + O(t^20)
sage: S = PowerSeriesRing(ZZ,'t', default_prec=4)
sage: S.random_element()  # random
2 - t - 5*t^2 + t^3 + O(t^4)
>>> from sage.all import *
>>> T = PowerSeriesRing(ZZ,'t')
>>> T.default_prec()
20
>>> T.random_element()  # random
4 + 2*t - t^2 - t^3 + 2*t^4 + t^5 + t^6 - 2*t^7 - t^8 - t^9 + t^11
 - 6*t^12 + 2*t^14 + 2*t^16 - t^17 - 3*t^18 + O(t^20)
>>> S = PowerSeriesRing(ZZ,'t', default_prec=Integer(4))
>>> S.random_element()  # random
2 - t - 5*t^2 + t^3 + O(t^4)

Further arguments are passed to the underlying base ring (Issue #9481):

sage: SZ = PowerSeriesRing(ZZ,'v')
sage: SQ = PowerSeriesRing(QQ,'v')
sage: SR = PowerSeriesRing(RR,'v')

sage: SZ.random_element(x=4, y=6)  # random
4 + 5*v + 5*v^2 + 5*v^3 + 4*v^4 + 5*v^5 + 5*v^6 + 5*v^7 + 4*v^8
 + 5*v^9 + 4*v^10 + 4*v^11 + 5*v^12 + 5*v^13 + 5*v^14 + 5*v^15
 + 5*v^16 + 5*v^17 + 4*v^18 + 5*v^19 + O(v^20)
sage: SZ.random_element(3, x=4, y=6)  # random
5 + 4*v + 5*v^2 + O(v^3)
sage: SQ.random_element(3, num_bound=3, den_bound=100)  # random
1/87 - 3/70*v - 3/44*v^2 + O(v^3)
sage: SR.random_element(3, max=10, min=-10)  # random
2.85948321262904 - 9.73071330911226*v - 6.60414378519265*v^2 + O(v^3)
>>> from sage.all import *
>>> SZ = PowerSeriesRing(ZZ,'v')
>>> SQ = PowerSeriesRing(QQ,'v')
>>> SR = PowerSeriesRing(RR,'v')

>>> SZ.random_element(x=Integer(4), y=Integer(6))  # random
4 + 5*v + 5*v^2 + 5*v^3 + 4*v^4 + 5*v^5 + 5*v^6 + 5*v^7 + 4*v^8
 + 5*v^9 + 4*v^10 + 4*v^11 + 5*v^12 + 5*v^13 + 5*v^14 + 5*v^15
 + 5*v^16 + 5*v^17 + 4*v^18 + 5*v^19 + O(v^20)
>>> SZ.random_element(Integer(3), x=Integer(4), y=Integer(6))  # random
5 + 4*v + 5*v^2 + O(v^3)
>>> SQ.random_element(Integer(3), num_bound=Integer(3), den_bound=Integer(100))  # random
1/87 - 3/70*v - 3/44*v^2 + O(v^3)
>>> SR.random_element(Integer(3), max=Integer(10), min=-Integer(10))  # random
2.85948321262904 - 9.73071330911226*v - 6.60414378519265*v^2 + O(v^3)
residue_field()[source]

Return the residue field of this power series ring.

EXAMPLES:

sage: R.<x> = PowerSeriesRing(GF(17))
sage: R.residue_field()
Finite Field of size 17
sage: R.<x> = PowerSeriesRing(Zp(5))                                        # needs sage.rings.padics
sage: R.residue_field()                                                     # needs sage.rings.padics
Finite Field of size 5
>>> from sage.all import *
>>> R = PowerSeriesRing(GF(Integer(17)), names=('x',)); (x,) = R._first_ngens(1)
>>> R.residue_field()
Finite Field of size 17
>>> R = PowerSeriesRing(Zp(Integer(5)), names=('x',)); (x,) = R._first_ngens(1)# needs sage.rings.padics
>>> R.residue_field()                                                     # needs sage.rings.padics
Finite Field of size 5
uniformizer()[source]

Return a uniformizer of this power series ring if it is a discrete valuation ring (i.e., if the base ring is actually a field). Otherwise, an error is raised.

EXAMPLES:

sage: R.<t> = PowerSeriesRing(QQ)
sage: R.uniformizer()
t

sage: R.<t> = PowerSeriesRing(ZZ)
sage: R.uniformizer()
Traceback (most recent call last):
...
TypeError: The base ring is not a field
>>> from sage.all import *
>>> R = PowerSeriesRing(QQ, names=('t',)); (t,) = R._first_ngens(1)
>>> R.uniformizer()
t

>>> R = PowerSeriesRing(ZZ, names=('t',)); (t,) = R._first_ngens(1)
>>> R.uniformizer()
Traceback (most recent call last):
...
TypeError: The base ring is not a field
variable_names_recursive(depth=None)[source]

Return the list of variable names of this and its base rings.

EXAMPLES:

sage: R = QQ[['x']][['y']][['z']]
sage: R.variable_names_recursive()
('x', 'y', 'z')
sage: R.variable_names_recursive(2)
('y', 'z')
>>> from sage.all import *
>>> R = QQ[['x']][['y']][['z']]
>>> R.variable_names_recursive()
('x', 'y', 'z')
>>> R.variable_names_recursive(Integer(2))
('y', 'z')
class sage.rings.power_series_ring.PowerSeriesRing_over_field(base_ring, name=None, default_prec=None, sparse=False, implementation=None, category=None)[source]

Bases: PowerSeriesRing_domain

fraction_field()[source]

Return the fraction field of this power series ring, which is defined since this is over a field.

This fraction field is just the Laurent series ring over the base field.

EXAMPLES:

sage: R.<t> = PowerSeriesRing(GF(7))
sage: R.fraction_field()
Laurent Series Ring in t over Finite Field of size 7
sage: Frac(R)
Laurent Series Ring in t over Finite Field of size 7
>>> from sage.all import *
>>> R = PowerSeriesRing(GF(Integer(7)), names=('t',)); (t,) = R._first_ngens(1)
>>> R.fraction_field()
Laurent Series Ring in t over Finite Field of size 7
>>> Frac(R)
Laurent Series Ring in t over Finite Field of size 7
sage.rings.power_series_ring.is_PowerSeriesRing(R)[source]

Return True if this is a univariate power series ring. This is in keeping with the behavior of is_PolynomialRing versus is_MPolynomialRing.

EXAMPLES:

sage: from sage.rings.power_series_ring import is_PowerSeriesRing
sage: is_PowerSeriesRing(10)
doctest:warning...
DeprecationWarning: The function is_PowerSeriesRing is deprecated;
use 'isinstance(..., (PowerSeriesRing_generic, LazyPowerSeriesRing) and ....ngens() == 1)' instead.
See https://github.com/sagemath/sage/issues/38290 for details.
False
sage: is_PowerSeriesRing(QQ[['x']])
True
sage: is_PowerSeriesRing(LazyPowerSeriesRing(QQ, 'x'))
True
sage: is_PowerSeriesRing(LazyPowerSeriesRing(QQ, 'x, y'))
False
>>> from sage.all import *
>>> from sage.rings.power_series_ring import is_PowerSeriesRing
>>> is_PowerSeriesRing(Integer(10))
doctest:warning...
DeprecationWarning: The function is_PowerSeriesRing is deprecated;
use 'isinstance(..., (PowerSeriesRing_generic, LazyPowerSeriesRing) and ....ngens() == 1)' instead.
See https://github.com/sagemath/sage/issues/38290 for details.
False
>>> is_PowerSeriesRing(QQ[['x']])
True
>>> is_PowerSeriesRing(LazyPowerSeriesRing(QQ, 'x'))
True
>>> is_PowerSeriesRing(LazyPowerSeriesRing(QQ, 'x, y'))
False
sage.rings.power_series_ring.unpickle_power_series_ring_v0(base_ring, name, default_prec, sparse)[source]

Unpickle (deserialize) a univariate power series ring according to the given inputs.

EXAMPLES:

sage: P.<x> = PowerSeriesRing(QQ)
sage: loads(dumps(P)) == P  # indirect doctest
True
>>> from sage.all import *
>>> P = PowerSeriesRing(QQ, names=('x',)); (x,) = P._first_ngens(1)
>>> loads(dumps(P)) == P  # indirect doctest
True