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)
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

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)

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

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)

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

Sage can compute with power series over the symbolic ring.

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)

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)

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

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

Choose another implementation of the attached polynomial ring:

sage: R.<t> = PowerSeriesRing(ZZ)
sage: type(t.polynomial())
<... 'sage.rings.polynomial.polynomial_integer_dense_flint.Polynomial_integer_dense_flint'>
sage: S.<s> = PowerSeriesRing(ZZ, implementation='NTL')
sage: type(s.polynomial())
<... '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, trac ticket #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)

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 - (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
sage: 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
sage: S = PowerSeriesRing(QQ, 'x', default_prec = 15); S
Power Series Ring in x over Rational Field
sage: 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
sage: N = PowerSeriesRing(QQ,'w',num_gens=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

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

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

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

Power series ring over finite field:

sage: S = PowerSeriesRing(GF(65537),'x,y'); S
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
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()
    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)
    sage: f in R
    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
class sage.rings.power_series_ring.PowerSeriesRing_domain(base_ring, name=None, default_prec=None, sparse=False, implementation=None, category=None)

Bases: sage.rings.power_series_ring.PowerSeriesRing_generic, sage.rings.ring.IntegralDomain

fraction_field()

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
class sage.rings.power_series_ring.PowerSeriesRing_generic(base_ring, name=None, default_prec=None, sparse=False, implementation=None, category=None)

Bases: sage.structure.unique_representation.UniqueRepresentation, sage.rings.ring.CommutativeRing, sage.structure.nonexact.Nonexact

A power series ring.

base_extend(R)

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
change_ring(R)

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'))
Power Series Ring in T over Number Field in a with defining polynomial x^2 - 3 with a = 1.732050807568878?
change_var(var)

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
characteristic()

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
construction()

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
gen(n=0)

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
is_dense()

EXAMPLES:

sage: R.<t> = PowerSeriesRing(ZZ)
sage: t.is_dense()
True
sage: R.<t> = PowerSeriesRing(ZZ, sparse=True)
sage: t.is_dense()
False
is_exact()

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
is_field(proof=True)

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
is_finite()

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
is_sparse()

EXAMPLES:

sage: R.<t> = PowerSeriesRing(ZZ)
sage: t.is_sparse()
False
sage: R.<t> = PowerSeriesRing(ZZ, sparse=True)
sage: t.is_sparse()
True
laurent_series_ring()

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)
ngens()

Return the number of generators of this power series ring.

This is always 1.

EXAMPLES:

sage: R.<t> = ZZ[[]]
sage: R.ngens()
1
random_element(prec=None, *args, **kwds)

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)

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)

Further arguments are passed to the underlying base ring (trac ticket #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)
residue_field()

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))
sage: R.residue_field()
Finite Field of size 5
uniformizer()

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
variable_names_recursive(depth=None)

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')
class sage.rings.power_series_ring.PowerSeriesRing_over_field(base_ring, name=None, default_prec=None, sparse=False, implementation=None, category=None)

Bases: sage.rings.power_series_ring.PowerSeriesRing_domain

fraction_field()

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
sage.rings.power_series_ring.is_PowerSeriesRing(R)

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)
False
sage: is_PowerSeriesRing(QQ[['x']])
True
sage.rings.power_series_ring.unpickle_power_series_ring_v0(base_ring, name, default_prec, sparse)

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