Multivariate Power Series#

Construct and manipulate multivariate power series (in finitely many variables) over a given commutative ring. Multivariate power series are implemented with total-degree precision.

EXAMPLES:

Power series arithmetic, tracking precision:

sage: R.<s,t> = PowerSeriesRing(ZZ); R
Multivariate Power Series Ring in s, t over Integer Ring

sage: f = 1 + s + 3*s^2; f
1 + s + 3*s^2
sage: g = t^2*s + 3*t^2*s^2 + R.O(5); g
s*t^2 + 3*s^2*t^2 + O(s, t)^5
sage: g = t^2*s + 3*t^2*s^2 + O(s, t)^5; g
s*t^2 + 3*s^2*t^2 + O(s, t)^5
sage: f = f.O(7); f
1 + s + 3*s^2 + O(s, t)^7
sage: f += s; f
1 + 2*s + 3*s^2 + O(s, t)^7
sage: f*g
s*t^2 + 5*s^2*t^2 + O(s, t)^5
sage: (f-1)*g
2*s^2*t^2 + 9*s^3*t^2 + O(s, t)^6
sage: f*g - g
2*s^2*t^2 + O(s, t)^5

sage: f *= s; f
s + 2*s^2 + 3*s^3 + O(s, t)^8
sage: f%2
s + s^3 + O(s, t)^8
sage: (f%2).parent()
Multivariate Power Series Ring in s, t over Ring of integers modulo 2
>>> from sage.all import *
>>> R = PowerSeriesRing(ZZ, names=('s', 't',)); (s, t,) = R._first_ngens(2); R
Multivariate Power Series Ring in s, t over Integer Ring

>>> f = Integer(1) + s + Integer(3)*s**Integer(2); f
1 + s + 3*s^2
>>> g = t**Integer(2)*s + Integer(3)*t**Integer(2)*s**Integer(2) + R.O(Integer(5)); g
s*t^2 + 3*s^2*t^2 + O(s, t)^5
>>> g = t**Integer(2)*s + Integer(3)*t**Integer(2)*s**Integer(2) + O(s, t)**Integer(5); g
s*t^2 + 3*s^2*t^2 + O(s, t)^5
>>> f = f.O(Integer(7)); f
1 + s + 3*s^2 + O(s, t)^7
>>> f += s; f
1 + 2*s + 3*s^2 + O(s, t)^7
>>> f*g
s*t^2 + 5*s^2*t^2 + O(s, t)^5
>>> (f-Integer(1))*g
2*s^2*t^2 + 9*s^3*t^2 + O(s, t)^6
>>> f*g - g
2*s^2*t^2 + O(s, t)^5

>>> f *= s; f
s + 2*s^2 + 3*s^3 + O(s, t)^8
>>> f%Integer(2)
s + s^3 + O(s, t)^8
>>> (f%Integer(2)).parent()
Multivariate Power Series Ring in s, t over Ring of integers modulo 2

As with univariate power series, comparison of \(f\) and \(g\) is done up to the minimum precision of \(f\) and \(g\):

sage: f = 1 + t + s + s*t + R.O(3); f
1 + s + t + s*t + O(s, t)^3
sage: g = s^2 + 2*s^4 - s^5 + s^2*t^3 + R.O(6); g
s^2 + 2*s^4 - s^5 + s^2*t^3 + O(s, t)^6
sage: f == g
False
sage: g == g.add_bigoh(3)
True
sage: f < g
False
sage: f > g
True
>>> from sage.all import *
>>> f = Integer(1) + t + s + s*t + R.O(Integer(3)); f
1 + s + t + s*t + O(s, t)^3
>>> g = s**Integer(2) + Integer(2)*s**Integer(4) - s**Integer(5) + s**Integer(2)*t**Integer(3) + R.O(Integer(6)); g
s^2 + 2*s^4 - s^5 + s^2*t^3 + O(s, t)^6
>>> f == g
False
>>> g == g.add_bigoh(Integer(3))
True
>>> f < g
False
>>> f > g
True

Calling:

sage: f = s^2 + s*t + s^3 + s^2*t + 3*s^4 + 3*s^3*t + R.O(5); f
s^2 + s*t + s^3 + s^2*t + 3*s^4 + 3*s^3*t + O(s, t)^5
sage: f(t, s)
s*t + t^2 + s*t^2 + t^3 + 3*s*t^3 + 3*t^4 + O(s, t)^5
sage: f(t^2, s^2)
s^2*t^2 + t^4 + s^2*t^4 + t^6 + 3*s^2*t^6 + 3*t^8 + O(s, t)^10
>>> from sage.all import *
>>> f = s**Integer(2) + s*t + s**Integer(3) + s**Integer(2)*t + Integer(3)*s**Integer(4) + Integer(3)*s**Integer(3)*t + R.O(Integer(5)); f
s^2 + s*t + s^3 + s^2*t + 3*s^4 + 3*s^3*t + O(s, t)^5
>>> f(t, s)
s*t + t^2 + s*t^2 + t^3 + 3*s*t^3 + 3*t^4 + O(s, t)^5
>>> f(t**Integer(2), s**Integer(2))
s^2*t^2 + t^4 + s^2*t^4 + t^6 + 3*s^2*t^6 + 3*t^8 + O(s, t)^10

Substitution is defined only for elements of positive valuation, unless \(f\) has infinite precision:

sage: f(t^2, s^2 + 1)
Traceback (most recent call last):
...
TypeError: Substitution defined only for elements of positive valuation,
unless self has infinite precision.

sage: g = f.truncate()
sage: g(t^2, s^2 + 1)
t^2 + s^2*t^2 + 2*t^4 + s^2*t^4 + 4*t^6 + 3*s^2*t^6 + 3*t^8
sage: g(t^2, (s^2+1).O(3))
t^2 + s^2*t^2 + 2*t^4 + O(s, t)^5
>>> from sage.all import *
>>> f(t**Integer(2), s**Integer(2) + Integer(1))
Traceback (most recent call last):
...
TypeError: Substitution defined only for elements of positive valuation,
unless self has infinite precision.

>>> g = f.truncate()
>>> g(t**Integer(2), s**Integer(2) + Integer(1))
t^2 + s^2*t^2 + 2*t^4 + s^2*t^4 + 4*t^6 + 3*s^2*t^6 + 3*t^8
>>> g(t**Integer(2), (s**Integer(2)+Integer(1)).O(Integer(3)))
t^2 + s^2*t^2 + 2*t^4 + O(s, t)^5

0 has valuation +Infinity:

sage: f(t^2, 0)
t^4 + t^6 + 3*t^8 + O(s, t)^10
sage: f(t^2, s^2 + s)
s*t^2 + s^2*t^2 + t^4 + O(s, t)^5
>>> from sage.all import *
>>> f(t**Integer(2), Integer(0))
t^4 + t^6 + 3*t^8 + O(s, t)^10
>>> f(t**Integer(2), s**Integer(2) + s)
s*t^2 + s^2*t^2 + t^4 + O(s, t)^5

Substitution of power series with finite precision works too:

sage: f(s.O(2), t)
s^2 + s*t + O(s, t)^3
sage: f(f, f)
2*s^4 + 4*s^3*t + 2*s^2*t^2 + 4*s^5 + 8*s^4*t + 4*s^3*t^2 + 16*s^6 +
34*s^5*t + 20*s^4*t^2 + 2*s^3*t^3 + O(s, t)^7
sage: t(f, f)
s^2 + s*t + s^3 + s^2*t + 3*s^4 + 3*s^3*t + O(s, t)^5
sage: t(0, f) == s(f, 0)
True
>>> from sage.all import *
>>> f(s.O(Integer(2)), t)
s^2 + s*t + O(s, t)^3
>>> f(f, f)
2*s^4 + 4*s^3*t + 2*s^2*t^2 + 4*s^5 + 8*s^4*t + 4*s^3*t^2 + 16*s^6 +
34*s^5*t + 20*s^4*t^2 + 2*s^3*t^3 + O(s, t)^7
>>> t(f, f)
s^2 + s*t + s^3 + s^2*t + 3*s^4 + 3*s^3*t + O(s, t)^5
>>> t(Integer(0), f) == s(f, Integer(0))
True

The subs syntax works as expected:

sage: r0 = -t^2 - s*t^3 - 2*t^6 + s^7 + s^5*t^2 + R.O(10)
sage: r1 = s^4 - s*t^4 + s^6*t - 4*s^2*t^5 - 6*s^3*t^5 + R.O(10)
sage: r2 = 2*s^3*t^2 - 2*s*t^4 - 2*s^3*t^4 + s*t^7 + R.O(10)
sage: r0.subs({t: r2, s: r1})
-4*s^6*t^4 + 8*s^4*t^6 - 4*s^2*t^8 + 8*s^6*t^6 - 8*s^4*t^8 - 4*s^4*t^9
+ 4*s^2*t^11 - 4*s^6*t^8 + O(s, t)^15
sage: r0.subs({t: r2, s: r1}) == r0(r1, r2)
True
>>> from sage.all import *
>>> r0 = -t**Integer(2) - s*t**Integer(3) - Integer(2)*t**Integer(6) + s**Integer(7) + s**Integer(5)*t**Integer(2) + R.O(Integer(10))
>>> r1 = s**Integer(4) - s*t**Integer(4) + s**Integer(6)*t - Integer(4)*s**Integer(2)*t**Integer(5) - Integer(6)*s**Integer(3)*t**Integer(5) + R.O(Integer(10))
>>> r2 = Integer(2)*s**Integer(3)*t**Integer(2) - Integer(2)*s*t**Integer(4) - Integer(2)*s**Integer(3)*t**Integer(4) + s*t**Integer(7) + R.O(Integer(10))
>>> r0.subs({t: r2, s: r1})
-4*s^6*t^4 + 8*s^4*t^6 - 4*s^2*t^8 + 8*s^6*t^6 - 8*s^4*t^8 - 4*s^4*t^9
+ 4*s^2*t^11 - 4*s^6*t^8 + O(s, t)^15
>>> r0.subs({t: r2, s: r1}) == r0(r1, r2)
True

Construct ring homomorphisms from one power series ring to another:

sage: A.<a,b> = PowerSeriesRing(QQ)
sage: X.<x,y> = PowerSeriesRing(QQ)

sage: phi = Hom(A,X)([x,2*y]); phi
Ring morphism:
  From: Multivariate Power Series Ring in a, b over Rational Field
  To:   Multivariate Power Series Ring in x, y over Rational Field
  Defn: a |--> x
        b |--> 2*y

sage: phi(a+b+3*a*b^2 + A.O(5))
x + 2*y + 12*x*y^2 + O(x, y)^5
>>> from sage.all import *
>>> A = PowerSeriesRing(QQ, names=('a', 'b',)); (a, b,) = A._first_ngens(2)
>>> X = PowerSeriesRing(QQ, names=('x', 'y',)); (x, y,) = X._first_ngens(2)

>>> phi = Hom(A,X)([x,Integer(2)*y]); phi
Ring morphism:
  From: Multivariate Power Series Ring in a, b over Rational Field
  To:   Multivariate Power Series Ring in x, y over Rational Field
  Defn: a |--> x
        b |--> 2*y

>>> phi(a+b+Integer(3)*a*b**Integer(2) + A.O(Integer(5)))
x + 2*y + 12*x*y^2 + O(x, y)^5

Multiplicative inversion of power series:

sage: h = 1 + s + t + s*t + s^2*t^2 + 3*s^4 + 3*s^3*t + R.O(5)
sage: k = h^-1; k
1 - s - t + s^2 + s*t + t^2 - s^3 - s^2*t - s*t^2 - t^3 - 2*s^4 -
2*s^3*t + s*t^3 + t^4 + O(s, t)^5
sage: h*k
1 + O(s, t)^5

sage: f = 1 - 5*s^29 - 5*s^28*t + 4*s^18*t^35 + \
....: 4*s^17*t^36 - s^45*t^25 - s^44*t^26 + s^7*t^83 + \
....: s^6*t^84 + R.O(101)
sage: h = ~f; h
1 + 5*s^29 + 5*s^28*t - 4*s^18*t^35 - 4*s^17*t^36 + 25*s^58 + 50*s^57*t
+ 25*s^56*t^2 + s^45*t^25 + s^44*t^26 - 40*s^47*t^35 - 80*s^46*t^36
- 40*s^45*t^37 + 125*s^87 + 375*s^86*t + 375*s^85*t^2 + 125*s^84*t^3
- s^7*t^83 - s^6*t^84 + 10*s^74*t^25 + 20*s^73*t^26 + 10*s^72*t^27
+ O(s, t)^101
sage: h*f
1 + O(s, t)^101
>>> from sage.all import *
>>> h = Integer(1) + s + t + s*t + s**Integer(2)*t**Integer(2) + Integer(3)*s**Integer(4) + Integer(3)*s**Integer(3)*t + R.O(Integer(5))
>>> k = h**-Integer(1); k
1 - s - t + s^2 + s*t + t^2 - s^3 - s^2*t - s*t^2 - t^3 - 2*s^4 -
2*s^3*t + s*t^3 + t^4 + O(s, t)^5
>>> h*k
1 + O(s, t)^5

>>> f = Integer(1) - Integer(5)*s**Integer(29) - Integer(5)*s**Integer(28)*t + Integer(4)*s**Integer(18)*t**Integer(35) + Integer(4)*s**Integer(17)*t**Integer(36) - s**Integer(45)*t**Integer(25) - s**Integer(44)*t**Integer(26) + s**Integer(7)*t**Integer(83) + s**Integer(6)*t**Integer(84) + R.O(Integer(101))
>>> h = ~f; h
1 + 5*s^29 + 5*s^28*t - 4*s^18*t^35 - 4*s^17*t^36 + 25*s^58 + 50*s^57*t
+ 25*s^56*t^2 + s^45*t^25 + s^44*t^26 - 40*s^47*t^35 - 80*s^46*t^36
- 40*s^45*t^37 + 125*s^87 + 375*s^86*t + 375*s^85*t^2 + 125*s^84*t^3
- s^7*t^83 - s^6*t^84 + 10*s^74*t^25 + 20*s^73*t^26 + 10*s^72*t^27
+ O(s, t)^101
>>> h*f
1 + O(s, t)^101

AUTHORS:

  • Niles Johnson (07/2010): initial code

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

class sage.rings.multi_power_series_ring_element.MO(x)[source]#

Bases: object

Object representing a zero element with given precision.

EXAMPLES:

sage: R.<u,v> = QQ[[]]
sage: m = O(u, v)
sage: m^4
0 + O(u, v)^4
sage: m^1
0 + O(u, v)^1

sage: T.<a,b,c> = PowerSeriesRing(ZZ, 3)
sage: z = O(a, b, c)
sage: z^1
0 + O(a, b, c)^1
sage: 1 + a + z^1
1 + O(a, b, c)^1

sage: w = 1 + a + O(a, b, c)^2; w
1 + a + O(a, b, c)^2
sage: w^2
1 + 2*a + O(a, b, c)^2
>>> from sage.all import *
>>> R = QQ[['u, v']]; (u, v,) = R._first_ngens(2)
>>> m = O(u, v)
>>> m**Integer(4)
0 + O(u, v)^4
>>> m**Integer(1)
0 + O(u, v)^1

>>> T = PowerSeriesRing(ZZ, Integer(3), names=('a', 'b', 'c',)); (a, b, c,) = T._first_ngens(3)
>>> z = O(a, b, c)
>>> z**Integer(1)
0 + O(a, b, c)^1
>>> Integer(1) + a + z**Integer(1)
1 + O(a, b, c)^1

>>> w = Integer(1) + a + O(a, b, c)**Integer(2); w
1 + a + O(a, b, c)^2
>>> w**Integer(2)
1 + 2*a + O(a, b, c)^2
class sage.rings.multi_power_series_ring_element.MPowerSeries(parent, x=0, prec=+Infinity, is_gen=False, check=False)[source]#

Bases: PowerSeries

Multivariate power series; these are the elements of Multivariate Power Series Rings.

INPUT:

  • parent – A multivariate power series.

  • x – The element (default: 0). This can be another MPowerSeries object, or an element of one of the following:

    • the background univariate power series ring

    • the foreground polynomial ring

    • a ring that coerces to one of the above two

  • prec – (default: infinity) The precision

  • is_gen – (default: False) Is this element one of the generators?

  • check – (default: False) Needed by univariate power series class

EXAMPLES:

Construct multivariate power series from generators:

sage: S.<s,t> = PowerSeriesRing(ZZ)
sage: f = s + 4*t + 3*s*t
sage: f in S
True
sage: f = f.add_bigoh(4); f
s + 4*t + 3*s*t + O(s, t)^4
sage: g = 1 + s + t - s*t + S.O(5); g
1 + s + t - s*t + O(s, t)^5

sage: T = PowerSeriesRing(GF(3),5,'t'); T
Multivariate Power Series Ring in t0, t1, t2, t3, t4
 over Finite Field of size 3
sage: t = T.gens()
sage: w = t[0] - 2*t[1]*t[3] + 5*t[4]^3 - t[0]^3*t[2]^2; w
t0 + t1*t3 - t4^3 - t0^3*t2^2
sage: w = w.add_bigoh(5); w
t0 + t1*t3 - t4^3 + O(t0, t1, t2, t3, t4)^5
sage: w in T
True

sage: w = t[0] - 2*t[0]*t[2] + 5*t[4]^3 - t[0]^3*t[2]^2 + T.O(6)
sage: w
t0 + t0*t2 - t4^3 - t0^3*t2^2 + O(t0, t1, t2, t3, t4)^6
>>> from sage.all import *
>>> S = PowerSeriesRing(ZZ, names=('s', 't',)); (s, t,) = S._first_ngens(2)
>>> f = s + Integer(4)*t + Integer(3)*s*t
>>> f in S
True
>>> f = f.add_bigoh(Integer(4)); f
s + 4*t + 3*s*t + O(s, t)^4
>>> g = Integer(1) + s + t - s*t + S.O(Integer(5)); g
1 + s + t - s*t + O(s, t)^5

>>> T = PowerSeriesRing(GF(Integer(3)),Integer(5),'t'); T
Multivariate Power Series Ring in t0, t1, t2, t3, t4
 over Finite Field of size 3
>>> t = T.gens()
>>> w = t[Integer(0)] - Integer(2)*t[Integer(1)]*t[Integer(3)] + Integer(5)*t[Integer(4)]**Integer(3) - t[Integer(0)]**Integer(3)*t[Integer(2)]**Integer(2); w
t0 + t1*t3 - t4^3 - t0^3*t2^2
>>> w = w.add_bigoh(Integer(5)); w
t0 + t1*t3 - t4^3 + O(t0, t1, t2, t3, t4)^5
>>> w in T
True

>>> w = t[Integer(0)] - Integer(2)*t[Integer(0)]*t[Integer(2)] + Integer(5)*t[Integer(4)]**Integer(3) - t[Integer(0)]**Integer(3)*t[Integer(2)]**Integer(2) + T.O(Integer(6))
>>> w
t0 + t0*t2 - t4^3 - t0^3*t2^2 + O(t0, t1, t2, t3, t4)^6

Get random elements:

sage: S.random_element(4)   # random
-2*t + t^2 - 12*s^3 + O(s, t)^4

sage: T.random_element(10)  # random
-t1^2*t3^2*t4^2 + t1^5*t3^3*t4 + O(t0, t1, t2, t3, t4)^10
>>> from sage.all import *
>>> S.random_element(Integer(4))   # random
-2*t + t^2 - 12*s^3 + O(s, t)^4

>>> T.random_element(Integer(10))  # random
-t1^2*t3^2*t4^2 + t1^5*t3^3*t4 + O(t0, t1, t2, t3, t4)^10

Convert elements from polynomial rings:

sage: # needs sage.rings.finite_rings
sage: R = PolynomialRing(ZZ, 5, T.variable_names())
sage: t = R.gens()
sage: r = -t[2]*t[3] + t[3]^2 + t[4]^2
sage: T(r)
-t2*t3 + t3^2 + t4^2
sage: r.parent()
Multivariate Polynomial Ring in t0, t1, t2, t3, t4 over Integer Ring
sage: r in T
True
>>> from sage.all import *
>>> # needs sage.rings.finite_rings
>>> R = PolynomialRing(ZZ, Integer(5), T.variable_names())
>>> t = R.gens()
>>> r = -t[Integer(2)]*t[Integer(3)] + t[Integer(3)]**Integer(2) + t[Integer(4)]**Integer(2)
>>> T(r)
-t2*t3 + t3^2 + t4^2
>>> r.parent()
Multivariate Polynomial Ring in t0, t1, t2, t3, t4 over Integer Ring
>>> r in T
True
O(prec)[source]#

Return a multivariate power series of precision prec obtained by truncating self at precision prec.

This is the same as add_bigoh().

EXAMPLES:

sage: B.<x,y> = PowerSeriesRing(QQ); B
Multivariate Power Series Ring in x, y over Rational Field
sage: r = 1 - x*y + x^2
sage: r.O(4)
1 + x^2 - x*y + O(x, y)^4
sage: r.O(2)
1 + O(x, y)^2
>>> from sage.all import *
>>> B = PowerSeriesRing(QQ, names=('x', 'y',)); (x, y,) = B._first_ngens(2); B
Multivariate Power Series Ring in x, y over Rational Field
>>> r = Integer(1) - x*y + x**Integer(2)
>>> r.O(Integer(4))
1 + x^2 - x*y + O(x, y)^4
>>> r.O(Integer(2))
1 + O(x, y)^2

Note that this does not change self:

sage: r
1 + x^2 - x*y
>>> from sage.all import *
>>> r
1 + x^2 - x*y
V(n)[source]#

If

\[f = \sum a_{m_0, \ldots, m_k} x_0^{m_0} \cdots x_k^{m_k},\]

then this function returns

\[\sum a_{m_0, \ldots, m_k} x_0^{n m_0} \cdots x_k^{n m_k}.\]

The total-degree precision of the output is n times the precision of self.

EXAMPLES:

sage: H = QQ[['x,y,z']]
sage: (x,y,z) = H.gens()
sage: h = -x*y^4*z^7 - 1/4*y*z^12 + 1/2*x^7*y^5*z^2 \
+ 2/3*y^6*z^8 + H.O(15)
sage: h.V(3)
-x^3*y^12*z^21 - 1/4*y^3*z^36 + 1/2*x^21*y^15*z^6 + 2/3*y^18*z^24 + O(x, y, z)^45
>>> from sage.all import *
>>> H = QQ[['x,y,z']]
>>> (x,y,z) = H.gens()
>>> h = -x*y**Integer(4)*z**Integer(7) - Integer(1)/Integer(4)*y*z**Integer(12) + Integer(1)/Integer(2)*x**Integer(7)*y**Integer(5)*z**Integer(2) \
+ 2/3*y^6*z^8 + H.O(15)
>>> h.V(Integer(3))
-x^3*y^12*z^21 - 1/4*y^3*z^36 + 1/2*x^21*y^15*z^6 + 2/3*y^18*z^24 + O(x, y, z)^45
add_bigoh(prec)[source]#

Return a multivariate power series of precision prec obtained by truncating self at precision prec.

This is the same as O().

EXAMPLES:

sage: B.<x,y> = PowerSeriesRing(QQ); B
Multivariate Power Series Ring in x, y over Rational Field
sage: r = 1 - x*y + x^2
sage: r.add_bigoh(4)
1 + x^2 - x*y + O(x, y)^4
sage: r.add_bigoh(2)
1 + O(x, y)^2
>>> from sage.all import *
>>> B = PowerSeriesRing(QQ, names=('x', 'y',)); (x, y,) = B._first_ngens(2); B
Multivariate Power Series Ring in x, y over Rational Field
>>> r = Integer(1) - x*y + x**Integer(2)
>>> r.add_bigoh(Integer(4))
1 + x^2 - x*y + O(x, y)^4
>>> r.add_bigoh(Integer(2))
1 + O(x, y)^2

Note that this does not change self:

sage: r
1 + x^2 - x*y
>>> from sage.all import *
>>> r
1 + x^2 - x*y
coefficients()[source]#

Return a dict of monomials and coefficients.

EXAMPLES:

sage: R.<s,t> = PowerSeriesRing(ZZ); R
Multivariate Power Series Ring in s, t over Integer Ring
sage: f = 1 + t + s + s*t + R.O(3)
sage: f.coefficients()
{s*t: 1, t: 1, s: 1, 1: 1}
sage: (f^2).coefficients()
{t^2: 1, s*t: 4, s^2: 1, t: 2, s: 2, 1: 1}

sage: g = f^2 + f - 2; g
3*s + 3*t + s^2 + 5*s*t + t^2 + O(s, t)^3
sage: cd = g.coefficients()
sage: g2 = sum(k*v for (k,v) in cd.items()); g2
3*s + 3*t + s^2 + 5*s*t + t^2
sage: g2 == g.truncate()
True
>>> from sage.all import *
>>> R = PowerSeriesRing(ZZ, names=('s', 't',)); (s, t,) = R._first_ngens(2); R
Multivariate Power Series Ring in s, t over Integer Ring
>>> f = Integer(1) + t + s + s*t + R.O(Integer(3))
>>> f.coefficients()
{s*t: 1, t: 1, s: 1, 1: 1}
>>> (f**Integer(2)).coefficients()
{t^2: 1, s*t: 4, s^2: 1, t: 2, s: 2, 1: 1}

>>> g = f**Integer(2) + f - Integer(2); g
3*s + 3*t + s^2 + 5*s*t + t^2 + O(s, t)^3
>>> cd = g.coefficients()
>>> g2 = sum(k*v for (k,v) in cd.items()); g2
3*s + 3*t + s^2 + 5*s*t + t^2
>>> g2 == g.truncate()
True
constant_coefficient()[source]#

Return constant coefficient of self.

EXAMPLES:

sage: R.<a,b,c> = PowerSeriesRing(ZZ); R
Multivariate Power Series Ring in a, b, c over Integer Ring
sage: f = 3 + a + b - a*b - b*c - a*c + R.O(4)
sage: f.constant_coefficient()
3
sage: f.constant_coefficient().parent()
Integer Ring
>>> from sage.all import *
>>> R = PowerSeriesRing(ZZ, names=('a', 'b', 'c',)); (a, b, c,) = R._first_ngens(3); R
Multivariate Power Series Ring in a, b, c over Integer Ring
>>> f = Integer(3) + a + b - a*b - b*c - a*c + R.O(Integer(4))
>>> f.constant_coefficient()
3
>>> f.constant_coefficient().parent()
Integer Ring
degree()[source]#

Return degree of underlying polynomial of self.

EXAMPLES:

sage: B.<x,y> = PowerSeriesRing(QQ)
sage: B
Multivariate Power Series Ring in x, y over Rational Field
sage: r = 1 - x*y + x^2
sage: r = r.add_bigoh(4); r
1 + x^2 - x*y + O(x, y)^4
sage: r.degree()
2
>>> from sage.all import *
>>> B = PowerSeriesRing(QQ, names=('x', 'y',)); (x, y,) = B._first_ngens(2)
>>> B
Multivariate Power Series Ring in x, y over Rational Field
>>> r = Integer(1) - x*y + x**Integer(2)
>>> r = r.add_bigoh(Integer(4)); r
1 + x^2 - x*y + O(x, y)^4
>>> r.degree()
2
derivative(*args)[source]#

The formal derivative of this power series, with respect to variables supplied in args.

EXAMPLES:

sage: T.<a,b> = PowerSeriesRing(ZZ, 2)
sage: f = a + b + a^2*b + T.O(5)
sage: f.derivative(a)
1 + 2*a*b + O(a, b)^4
sage: f.derivative(a,2)
2*b + O(a, b)^3
sage: f.derivative(a,a)
2*b + O(a, b)^3
sage: f.derivative([a,a])
2*b + O(a, b)^3
sage: f.derivative(a,5)
0 + O(a, b)^0
sage: f.derivative(a,6)
0 + O(a, b)^0
>>> from sage.all import *
>>> T = PowerSeriesRing(ZZ, Integer(2), names=('a', 'b',)); (a, b,) = T._first_ngens(2)
>>> f = a + b + a**Integer(2)*b + T.O(Integer(5))
>>> f.derivative(a)
1 + 2*a*b + O(a, b)^4
>>> f.derivative(a,Integer(2))
2*b + O(a, b)^3
>>> f.derivative(a,a)
2*b + O(a, b)^3
>>> f.derivative([a,a])
2*b + O(a, b)^3
>>> f.derivative(a,Integer(5))
0 + O(a, b)^0
>>> f.derivative(a,Integer(6))
0 + O(a, b)^0
dict()[source]#

Return underlying dictionary with keys the exponents and values the coefficients of this power series.

EXAMPLES:

sage: M = PowerSeriesRing(QQ,4,'t',sparse=True); M
Sparse Multivariate Power Series Ring in t0, t1, t2, t3 over
Rational Field

sage: M.inject_variables()
Defining t0, t1, t2, t3

sage: m = 2/3*t0*t1^15*t3^48 - t0^15*t1^21*t2^28*t3^5
sage: m2 = 1/2*t0^12*t1^29*t2^46*t3^6 - 1/4*t0^39*t1^5*t2^23*t3^30 + M.O(100)
sage: s = m + m2
sage: s.dict()
{(1, 15, 0, 48): 2/3,
 (12, 29, 46, 6): 1/2,
 (15, 21, 28, 5): -1,
 (39, 5, 23, 30): -1/4}
>>> from sage.all import *
>>> M = PowerSeriesRing(QQ,Integer(4),'t',sparse=True); M
Sparse Multivariate Power Series Ring in t0, t1, t2, t3 over
Rational Field

>>> M.inject_variables()
Defining t0, t1, t2, t3

>>> m = Integer(2)/Integer(3)*t0*t1**Integer(15)*t3**Integer(48) - t0**Integer(15)*t1**Integer(21)*t2**Integer(28)*t3**Integer(5)
>>> m2 = Integer(1)/Integer(2)*t0**Integer(12)*t1**Integer(29)*t2**Integer(46)*t3**Integer(6) - Integer(1)/Integer(4)*t0**Integer(39)*t1**Integer(5)*t2**Integer(23)*t3**Integer(30) + M.O(Integer(100))
>>> s = m + m2
>>> s.dict()
{(1, 15, 0, 48): 2/3,
 (12, 29, 46, 6): 1/2,
 (15, 21, 28, 5): -1,
 (39, 5, 23, 30): -1/4}
egf()[source]#

Method from univariate power series not yet implemented

exp(prec=+Infinity)[source]#

Exponentiate the formal power series.

INPUT:

  • prec – Integer or infinity. The degree to truncate the result to.

OUTPUT:

The exponentiated multivariate power series as a new multivariate power series.

EXAMPLES:

sage: T.<a,b> = PowerSeriesRing(ZZ, 2)
sage: f = a + b + a*b + T.O(3)
sage: exp(f)
1 + a + b + 1/2*a^2 + 2*a*b + 1/2*b^2 + O(a, b)^3
sage: f.exp()
1 + a + b + 1/2*a^2 + 2*a*b + 1/2*b^2 + O(a, b)^3
sage: f.exp(prec=2)
1 + a + b + O(a, b)^2
sage: log(exp(f)) - f
0 + O(a, b)^3
>>> from sage.all import *
>>> T = PowerSeriesRing(ZZ, Integer(2), names=('a', 'b',)); (a, b,) = T._first_ngens(2)
>>> f = a + b + a*b + T.O(Integer(3))
>>> exp(f)
1 + a + b + 1/2*a^2 + 2*a*b + 1/2*b^2 + O(a, b)^3
>>> f.exp()
1 + a + b + 1/2*a^2 + 2*a*b + 1/2*b^2 + O(a, b)^3
>>> f.exp(prec=Integer(2))
1 + a + b + O(a, b)^2
>>> log(exp(f)) - f
0 + O(a, b)^3

If the power series has a constant coefficient \(c\) and \(\exp(c)\) is transcendental, then \(\exp(f)\) would have to be a power series over the SymbolicRing. These are not yet implemented and therefore such cases raise an error:

sage: g = 2 + f
sage: exp(g)                                                                # needs sage.symbolic
Traceback (most recent call last):
...
TypeError: unsupported operand parent(s) for *: 'Symbolic Ring' and
'Power Series Ring in Tbg over Multivariate Polynomial Ring in a, b
over Rational Field'
>>> from sage.all import *
>>> g = Integer(2) + f
>>> exp(g)                                                                # needs sage.symbolic
Traceback (most recent call last):
...
TypeError: unsupported operand parent(s) for *: 'Symbolic Ring' and
'Power Series Ring in Tbg over Multivariate Polynomial Ring in a, b
over Rational Field'

Another workaround for this limitation is to change base ring to one which is closed under exponentiation, such as \(\RR\) or \(\CC\):

sage: exp(g.change_ring(RDF))
7.38905609... + 7.38905609...*a + 7.38905609...*b + 3.69452804...*a^2 +
14.7781121...*a*b + 3.69452804...*b^2 + O(a, b)^3
>>> from sage.all import *
>>> exp(g.change_ring(RDF))
7.38905609... + 7.38905609...*a + 7.38905609...*b + 3.69452804...*a^2 +
14.7781121...*a*b + 3.69452804...*b^2 + O(a, b)^3

If no precision is specified, the default precision is used:

sage: T.default_prec()
12
sage: exp(a)
1 + a + 1/2*a^2 + 1/6*a^3 + 1/24*a^4 + 1/120*a^5 + 1/720*a^6 + 1/5040*a^7 +
1/40320*a^8 + 1/362880*a^9 + 1/3628800*a^10 + 1/39916800*a^11 + O(a, b)^12
sage: a.exp(prec=5)
1 + a + 1/2*a^2 + 1/6*a^3 + 1/24*a^4 + O(a, b)^5
sage: exp(a + T.O(5))
1 + a + 1/2*a^2 + 1/6*a^3 + 1/24*a^4 + O(a, b)^5
>>> from sage.all import *
>>> T.default_prec()
12
>>> exp(a)
1 + a + 1/2*a^2 + 1/6*a^3 + 1/24*a^4 + 1/120*a^5 + 1/720*a^6 + 1/5040*a^7 +
1/40320*a^8 + 1/362880*a^9 + 1/3628800*a^10 + 1/39916800*a^11 + O(a, b)^12
>>> a.exp(prec=Integer(5))
1 + a + 1/2*a^2 + 1/6*a^3 + 1/24*a^4 + O(a, b)^5
>>> exp(a + T.O(Integer(5)))
1 + a + 1/2*a^2 + 1/6*a^3 + 1/24*a^4 + O(a, b)^5
exponents()[source]#

Return a list of tuples which hold the exponents of each monomial of self.

EXAMPLES:

sage: H = QQ[['x,y']]
sage: (x,y) = H.gens()
sage: h = -y^2 - x*y^3 - 6/5*y^6 - x^7 + 2*x^5*y^2 + H.O(10)
sage: h
-y^2 - x*y^3 - 6/5*y^6 - x^7 + 2*x^5*y^2 + O(x, y)^10
sage: h.exponents()
[(0, 2), (1, 3), (0, 6), (7, 0), (5, 2)]
>>> from sage.all import *
>>> H = QQ[['x,y']]
>>> (x,y) = H.gens()
>>> h = -y**Integer(2) - x*y**Integer(3) - Integer(6)/Integer(5)*y**Integer(6) - x**Integer(7) + Integer(2)*x**Integer(5)*y**Integer(2) + H.O(Integer(10))
>>> h
-y^2 - x*y^3 - 6/5*y^6 - x^7 + 2*x^5*y^2 + O(x, y)^10
>>> h.exponents()
[(0, 2), (1, 3), (0, 6), (7, 0), (5, 2)]
integral(*args)[source]#

The formal integral of this multivariate power series, with respect to variables supplied in args.

The variable sequence args can contain both variables and counts; for the syntax, see derivative_parse().

EXAMPLES:

sage: T.<a,b> = PowerSeriesRing(QQ, 2)
sage: f = a + b + a^2*b + T.O(5)
sage: f.integral(a, 2)
1/6*a^3 + 1/2*a^2*b + 1/12*a^4*b + O(a, b)^7
sage: f.integral(a, b)
1/2*a^2*b + 1/2*a*b^2 + 1/6*a^3*b^2 + O(a, b)^7
sage: f.integral(a, 5)
1/720*a^6 + 1/120*a^5*b + 1/2520*a^7*b + O(a, b)^10
>>> from sage.all import *
>>> T = PowerSeriesRing(QQ, Integer(2), names=('a', 'b',)); (a, b,) = T._first_ngens(2)
>>> f = a + b + a**Integer(2)*b + T.O(Integer(5))
>>> f.integral(a, Integer(2))
1/6*a^3 + 1/2*a^2*b + 1/12*a^4*b + O(a, b)^7
>>> f.integral(a, b)
1/2*a^2*b + 1/2*a*b^2 + 1/6*a^3*b^2 + O(a, b)^7
>>> f.integral(a, Integer(5))
1/720*a^6 + 1/120*a^5*b + 1/2520*a^7*b + O(a, b)^10

Only integration with respect to variables works:

sage: f.integral(a + b)
Traceback (most recent call last):
...
ValueError: a + b is not a variable
>>> from sage.all import *
>>> f.integral(a + b)
Traceback (most recent call last):
...
ValueError: a + b is not a variable

Warning

Coefficient division.

If the base ring is not a field (e.g. \(ZZ\)), or if it has a non-zero characteristic, (e.g. \(ZZ/3ZZ\)), integration is not always possible while staying with the same base ring. In the first case, Sage will report that it has not been able to coerce some coefficient to the base ring:

sage: T.<a,b> = PowerSeriesRing(ZZ, 2)
sage: f = a + T.O(5)
sage: f.integral(a)
Traceback (most recent call last):
...
TypeError: no conversion of this rational to integer
>>> from sage.all import *
>>> T = PowerSeriesRing(ZZ, Integer(2), names=('a', 'b',)); (a, b,) = T._first_ngens(2)
>>> f = a + T.O(Integer(5))
>>> f.integral(a)
Traceback (most recent call last):
...
TypeError: no conversion of this rational to integer

One can get the correct result by changing the base ring first:

sage: f.change_ring(QQ).integral(a)
1/2*a^2 + O(a, b)^6
>>> from sage.all import *
>>> f.change_ring(QQ).integral(a)
1/2*a^2 + O(a, b)^6

However, a correct result is returned even without base change if the denominator cancels:

sage: f = 2*b + T.O(5)
sage: f.integral(b)
b^2 + O(a, b)^6
>>> from sage.all import *
>>> f = Integer(2)*b + T.O(Integer(5))
>>> f.integral(b)
b^2 + O(a, b)^6

In non-zero characteristic, Sage will report that a zero division occurred

sage: T.<a,b> = PowerSeriesRing(Zmod(3), 2)
sage: (a^3).integral(a)
a^4
sage: (a^2).integral(a)
Traceback (most recent call last):
...
ZeroDivisionError: inverse of Mod(0, 3) does not exist
>>> from sage.all import *
>>> T = PowerSeriesRing(Zmod(Integer(3)), Integer(2), names=('a', 'b',)); (a, b,) = T._first_ngens(2)
>>> (a**Integer(3)).integral(a)
a^4
>>> (a**Integer(2)).integral(a)
Traceback (most recent call last):
...
ZeroDivisionError: inverse of Mod(0, 3) does not exist
is_nilpotent()[source]#

Return True if self is nilpotent. This occurs if

  • self has finite precision and positive valuation, or

  • self is constant and nilpotent in base ring.

Otherwise, return False.

Warning

This is so far just a sufficient condition, so don’t trust a False output to be legit!

Todo

What should we do about this method? Is nilpotency of a power series even decidable (assuming a nilpotency oracle in the base ring)? And I am not sure that returning True just because the series has finite precision and zero constant term is a good idea.

EXAMPLES:

sage: R.<a,b,c> = PowerSeriesRing(Zmod(8)); R
Multivariate Power Series Ring in a, b, c over Ring of integers modulo 8
sage: f = a + b + c + a^2*c
sage: f.is_nilpotent()
False
sage: f = f.O(4); f
a + b + c + a^2*c + O(a, b, c)^4
sage: f.is_nilpotent()
True

sage: g = R(2)
sage: g.is_nilpotent()
True
sage: (g.O(4)).is_nilpotent()
True

sage: S = R.change_ring(QQ)
sage: S(g).is_nilpotent()
False
sage: S(g.O(4)).is_nilpotent()
False
>>> from sage.all import *
>>> R = PowerSeriesRing(Zmod(Integer(8)), names=('a', 'b', 'c',)); (a, b, c,) = R._first_ngens(3); R
Multivariate Power Series Ring in a, b, c over Ring of integers modulo 8
>>> f = a + b + c + a**Integer(2)*c
>>> f.is_nilpotent()
False
>>> f = f.O(Integer(4)); f
a + b + c + a^2*c + O(a, b, c)^4
>>> f.is_nilpotent()
True

>>> g = R(Integer(2))
>>> g.is_nilpotent()
True
>>> (g.O(Integer(4))).is_nilpotent()
True

>>> S = R.change_ring(QQ)
>>> S(g).is_nilpotent()
False
>>> S(g.O(Integer(4))).is_nilpotent()
False
is_square()[source]#

Method from univariate power series not yet implemented.

is_unit()[source]#

A multivariate power series is a unit if and only if its constant coefficient is a unit.

EXAMPLES:

sage: R.<a,b> = PowerSeriesRing(ZZ); R
Multivariate Power Series Ring in a, b over Integer Ring
sage: f = 2 + a^2 + a*b + a^3 + R.O(9)
sage: f.is_unit()
False
sage: f.base_extend(QQ).is_unit()
True
sage: (O(a,b)^0).is_unit()
False
>>> from sage.all import *
>>> R = PowerSeriesRing(ZZ, names=('a', 'b',)); (a, b,) = R._first_ngens(2); R
Multivariate Power Series Ring in a, b over Integer Ring
>>> f = Integer(2) + a**Integer(2) + a*b + a**Integer(3) + R.O(Integer(9))
>>> f.is_unit()
False
>>> f.base_extend(QQ).is_unit()
True
>>> (O(a,b)**Integer(0)).is_unit()
False
laurent_series()[source]#

Not implemented for multivariate power series.

list()[source]#

Doesn’t make sense for multivariate power series. Multivariate polynomials don’t have list of coefficients either.

log(prec=+Infinity)[source]#

Return the logarithm of the formal power series.

INPUT:

  • prec – Integer or infinity. The degree to truncate the result to.

OUTPUT:

The logarithm of the multivariate power series as a new multivariate power series.

EXAMPLES:

sage: T.<a,b> = PowerSeriesRing(ZZ, 2)
sage: f = 1 + a + b + a*b + T.O(5)
sage: f.log()
a + b - 1/2*a^2 - 1/2*b^2 + 1/3*a^3 + 1/3*b^3 - 1/4*a^4 - 1/4*b^4 + O(a, b)^5
sage: log(f)
a + b - 1/2*a^2 - 1/2*b^2 + 1/3*a^3 + 1/3*b^3 - 1/4*a^4 - 1/4*b^4 + O(a, b)^5
sage: exp(log(f)) - f
0 + O(a, b)^5
>>> from sage.all import *
>>> T = PowerSeriesRing(ZZ, Integer(2), names=('a', 'b',)); (a, b,) = T._first_ngens(2)
>>> f = Integer(1) + a + b + a*b + T.O(Integer(5))
>>> f.log()
a + b - 1/2*a^2 - 1/2*b^2 + 1/3*a^3 + 1/3*b^3 - 1/4*a^4 - 1/4*b^4 + O(a, b)^5
>>> log(f)
a + b - 1/2*a^2 - 1/2*b^2 + 1/3*a^3 + 1/3*b^3 - 1/4*a^4 - 1/4*b^4 + O(a, b)^5
>>> exp(log(f)) - f
0 + O(a, b)^5

If the power series has a constant coefficient \(c\) and \(\exp(c)\) is transcendental, then \(\exp(f)\) would have to be a power series over the SymbolicRing. These are not yet implemented and therefore such cases raise an error:

sage: g = 2 + f
sage: log(g)                                                                # needs sage.symbolic
Traceback (most recent call last):
...
TypeError: unsupported operand parent(s) for -: 'Symbolic Ring' and 'Power
Series Ring in Tbg over Multivariate Polynomial Ring in a, b over Rational Field'
>>> from sage.all import *
>>> g = Integer(2) + f
>>> log(g)                                                                # needs sage.symbolic
Traceback (most recent call last):
...
TypeError: unsupported operand parent(s) for -: 'Symbolic Ring' and 'Power
Series Ring in Tbg over Multivariate Polynomial Ring in a, b over Rational Field'

Another workaround for this limitation is to change base ring to one which is closed under exponentiation, such as \(\RR\) or \(\CC\):

sage: log(g.change_ring(RDF))
1.09861228... + 0.333333333...*a + 0.333333333...*b - 0.0555555555...*a^2
+ 0.222222222...*a*b - 0.0555555555...*b^2 + 0.0123456790...*a^3
- 0.0740740740...*a^2*b - 0.0740740740...*a*b^2 + 0.0123456790...*b^3
- 0.00308641975...*a^4 + 0.0246913580...*a^3*b + 0.0246913580...*a*b^3
- 0.00308641975...*b^4 + O(a, b)^5
>>> from sage.all import *
>>> log(g.change_ring(RDF))
1.09861228... + 0.333333333...*a + 0.333333333...*b - 0.0555555555...*a^2
+ 0.222222222...*a*b - 0.0555555555...*b^2 + 0.0123456790...*a^3
- 0.0740740740...*a^2*b - 0.0740740740...*a*b^2 + 0.0123456790...*b^3
- 0.00308641975...*a^4 + 0.0246913580...*a^3*b + 0.0246913580...*a*b^3
- 0.00308641975...*b^4 + O(a, b)^5
monomials()[source]#

Return a list of monomials of self.

These are the keys of the dict returned by coefficients().

EXAMPLES:

sage: R.<a,b,c> = PowerSeriesRing(ZZ); R
Multivariate Power Series Ring in a, b, c over Integer Ring
sage: f = 1 + a + b - a*b - b*c - a*c + R.O(4)
sage: sorted(f.monomials())
[b*c, a*c, a*b, b, a, 1]
sage: f = 1 + 2*a + 7*b - 2*a*b - 4*b*c - 13*a*c + R.O(4)
sage: sorted(f.monomials())
[b*c, a*c, a*b, b, a, 1]
sage: f = R.zero()
sage: f.monomials()
[]
>>> from sage.all import *
>>> R = PowerSeriesRing(ZZ, names=('a', 'b', 'c',)); (a, b, c,) = R._first_ngens(3); R
Multivariate Power Series Ring in a, b, c over Integer Ring
>>> f = Integer(1) + a + b - a*b - b*c - a*c + R.O(Integer(4))
>>> sorted(f.monomials())
[b*c, a*c, a*b, b, a, 1]
>>> f = Integer(1) + Integer(2)*a + Integer(7)*b - Integer(2)*a*b - Integer(4)*b*c - Integer(13)*a*c + R.O(Integer(4))
>>> sorted(f.monomials())
[b*c, a*c, a*b, b, a, 1]
>>> f = R.zero()
>>> f.monomials()
[]
ogf()[source]#

Method from univariate power series not yet implemented

padded_list()[source]#

Method from univariate power series not yet implemented.

polynomial()[source]#

Return the underlying polynomial of self as an element of the underlying multivariate polynomial ring (the “foreground polynomial ring”).

EXAMPLES:

sage: M = PowerSeriesRing(QQ,4,'t'); M
Multivariate Power Series Ring in t0, t1, t2, t3 over Rational
Field
sage: t = M.gens()
sage: f = 1/2*t[0]^3*t[1]^3*t[2]^2 + 2/3*t[0]*t[2]^6*t[3]             - t[0]^3*t[1]^3*t[3]^3 - 1/4*t[0]*t[1]*t[2]^7 + M.O(10)
sage: f
1/2*t0^3*t1^3*t2^2 + 2/3*t0*t2^6*t3 - t0^3*t1^3*t3^3
- 1/4*t0*t1*t2^7 + O(t0, t1, t2, t3)^10

sage: f.polynomial()
1/2*t0^3*t1^3*t2^2 + 2/3*t0*t2^6*t3 - t0^3*t1^3*t3^3
- 1/4*t0*t1*t2^7

sage: f.polynomial().parent()
Multivariate Polynomial Ring in t0, t1, t2, t3 over Rational Field
>>> from sage.all import *
>>> M = PowerSeriesRing(QQ,Integer(4),'t'); M
Multivariate Power Series Ring in t0, t1, t2, t3 over Rational
Field
>>> t = M.gens()
>>> f = Integer(1)/Integer(2)*t[Integer(0)]**Integer(3)*t[Integer(1)]**Integer(3)*t[Integer(2)]**Integer(2) + Integer(2)/Integer(3)*t[Integer(0)]*t[Integer(2)]**Integer(6)*t[Integer(3)]             - t[Integer(0)]**Integer(3)*t[Integer(1)]**Integer(3)*t[Integer(3)]**Integer(3) - Integer(1)/Integer(4)*t[Integer(0)]*t[Integer(1)]*t[Integer(2)]**Integer(7) + M.O(Integer(10))
>>> f
1/2*t0^3*t1^3*t2^2 + 2/3*t0*t2^6*t3 - t0^3*t1^3*t3^3
- 1/4*t0*t1*t2^7 + O(t0, t1, t2, t3)^10

>>> f.polynomial()
1/2*t0^3*t1^3*t2^2 + 2/3*t0*t2^6*t3 - t0^3*t1^3*t3^3
- 1/4*t0*t1*t2^7

>>> f.polynomial().parent()
Multivariate Polynomial Ring in t0, t1, t2, t3 over Rational Field

Contrast with truncate():

sage: f.truncate()
1/2*t0^3*t1^3*t2^2 + 2/3*t0*t2^6*t3 - t0^3*t1^3*t3^3 - 1/4*t0*t1*t2^7
sage: f.truncate().parent()
Multivariate Power Series Ring in t0, t1, t2, t3 over Rational Field
>>> from sage.all import *
>>> f.truncate()
1/2*t0^3*t1^3*t2^2 + 2/3*t0*t2^6*t3 - t0^3*t1^3*t3^3 - 1/4*t0*t1*t2^7
>>> f.truncate().parent()
Multivariate Power Series Ring in t0, t1, t2, t3 over Rational Field
prec()[source]#

Return precision of self.

EXAMPLES:

sage: R.<a,b,c> = PowerSeriesRing(ZZ); R
Multivariate Power Series Ring in a, b, c over Integer Ring
sage: f = 3 + a + b - a*b - b*c - a*c + R.O(4)
sage: f.prec()
4
sage: f.truncate().prec()
+Infinity
>>> from sage.all import *
>>> R = PowerSeriesRing(ZZ, names=('a', 'b', 'c',)); (a, b, c,) = R._first_ngens(3); R
Multivariate Power Series Ring in a, b, c over Integer Ring
>>> f = Integer(3) + a + b - a*b - b*c - a*c + R.O(Integer(4))
>>> f.prec()
4
>>> f.truncate().prec()
+Infinity
quo_rem(other, precision=None)[source]#

Return the pair of quotient and remainder for the increasing power division of self by other.

If \(a\) and \(b\) are two elements of a power series ring \(R[[x_1, x_2, \cdots, x_n]]\) such that the trailing term of \(b\) is invertible in \(R\), then the pair of quotient and remainder for the increasing power division of \(a\) by \(b\) is the unique pair \((u, v) \in R[[x_1, x_2, \cdots, x_n]] \times R[x_1, x_2, \cdots, x_n]\) such that \(a = bu + v\) and such that no monomial appearing in \(v\) divides the trailing monomial (trailing_monomial()) of \(b\). Note that this depends on the order of the variables.

This method returns both quotient and remainder as power series, even though in mathematics, the remainder for the increasing power division of two power series is a polynomial. This is because Sage’s power series come with a precision, and that precision is not always sufficient to determine the remainder completely. Disregarding this issue, the polynomial() method can be used to recast the remainder as an actual polynomial.

INPUT:

  • other – an element of the same power series ring as self such that the trailing term of other is invertible in self (this is automatically satisfied if the base ring is a field, unless other is zero)

  • precision – (default: the default precision of the parent of self) nonnegative integer, determining the precision to be cast on the resulting quotient and remainder if both self and other have infinite precision (ignored otherwise); note that the resulting precision might be lower than this integer

EXAMPLES:

sage: # needs sage.libs.singular
sage: R.<a,b,c> = PowerSeriesRing(ZZ)
sage: f = 1 + a + b - a*b + R.O(3)
sage: g = 1 + 2*a - 3*a*b + R.O(3)
sage: q, r = f.quo_rem(g); q, r
(1 - a + b + 2*a^2 + O(a, b, c)^3, 0 + O(a, b, c)^3)
sage: f == q*g + r
True
sage: q, r = (a*f).quo_rem(g); q, r
(a - a^2 + a*b + 2*a^3 + O(a, b, c)^4, 0 + O(a, b, c)^4)
sage: a*f == q*g + r
True
sage: q, r = (a*f).quo_rem(a*g); q, r
(1 - a + b + 2*a^2 + O(a, b, c)^3, 0 + O(a, b, c)^4)
sage: a*f == q*(a*g) + r
True
sage: q, r = (a*f).quo_rem(b*g); q, r
(a - 3*a^2 + O(a, b, c)^3, a + a^2 + O(a, b, c)^4)
sage: a*f == q*(b*g) + r
True
>>> from sage.all import *
>>> # needs sage.libs.singular
>>> R = PowerSeriesRing(ZZ, names=('a', 'b', 'c',)); (a, b, c,) = R._first_ngens(3)
>>> f = Integer(1) + a + b - a*b + R.O(Integer(3))
>>> g = Integer(1) + Integer(2)*a - Integer(3)*a*b + R.O(Integer(3))
>>> q, r = f.quo_rem(g); q, r
(1 - a + b + 2*a^2 + O(a, b, c)^3, 0 + O(a, b, c)^3)
>>> f == q*g + r
True
>>> q, r = (a*f).quo_rem(g); q, r
(a - a^2 + a*b + 2*a^3 + O(a, b, c)^4, 0 + O(a, b, c)^4)
>>> a*f == q*g + r
True
>>> q, r = (a*f).quo_rem(a*g); q, r
(1 - a + b + 2*a^2 + O(a, b, c)^3, 0 + O(a, b, c)^4)
>>> a*f == q*(a*g) + r
True
>>> q, r = (a*f).quo_rem(b*g); q, r
(a - 3*a^2 + O(a, b, c)^3, a + a^2 + O(a, b, c)^4)
>>> a*f == q*(b*g) + r
True

Trying to divide two polynomials, we run into the issue that there is no natural setting for the precision of the quotient and remainder (and if we wouldn’t set a precision, the algorithm would never terminate). Here, default precision comes to our help:

sage: # needs sage.libs.singular
sage: (1 + a^3).quo_rem(a + a^2)
(a^2 - a^3 + a^4 - a^5 + a^6 - a^7 + a^8 - a^9 + a^10 + O(a, b, c)^11,
 1 + O(a, b, c)^12)
sage: (1 + a^3 + a*b).quo_rem(b + c)
(a + O(a, b, c)^11, 1 - a*c + a^3 + O(a, b, c)^12)
sage: (1 + a^3 + a*b).quo_rem(b + c, precision=17)
(a + O(a, b, c)^16, 1 - a*c + a^3 + O(a, b, c)^17)
sage: (a^2 + b^2 + c^2).quo_rem(a + b + c)
(a - b - c + O(a, b, c)^11, 2*b^2 + 2*b*c + 2*c^2 + O(a, b, c)^12)
sage: (a^2 + b^2 + c^2).quo_rem(1/(1+a+b+c))
(a^2 + b^2 + c^2 + a^3 + a^2*b + a^2*c + a*b^2 + a*c^2
   + b^3 + b^2*c + b*c^2 + c^3 + O(a, b, c)^14,
 0)
sage: (a^2 + b^2 + c^2).quo_rem(a/(1+a+b+c))
(a + a^2 + a*b + a*c + O(a, b, c)^13, b^2 + c^2)
sage: (1 + a + a^15).quo_rem(a^2)
(0 + O(a, b, c)^10, 1 + a + O(a, b, c)^12)
sage: (1 + a + a^15).quo_rem(a^2, precision=15)
(0 + O(a, b, c)^13, 1 + a + O(a, b, c)^15)
sage: (1 + a + a^15).quo_rem(a^2, precision=16)
(a^13 + O(a, b, c)^14, 1 + a + O(a, b, c)^16)
>>> from sage.all import *
>>> # needs sage.libs.singular
>>> (Integer(1) + a**Integer(3)).quo_rem(a + a**Integer(2))
(a^2 - a^3 + a^4 - a^5 + a^6 - a^7 + a^8 - a^9 + a^10 + O(a, b, c)^11,
 1 + O(a, b, c)^12)
>>> (Integer(1) + a**Integer(3) + a*b).quo_rem(b + c)
(a + O(a, b, c)^11, 1 - a*c + a^3 + O(a, b, c)^12)
>>> (Integer(1) + a**Integer(3) + a*b).quo_rem(b + c, precision=Integer(17))
(a + O(a, b, c)^16, 1 - a*c + a^3 + O(a, b, c)^17)
>>> (a**Integer(2) + b**Integer(2) + c**Integer(2)).quo_rem(a + b + c)
(a - b - c + O(a, b, c)^11, 2*b^2 + 2*b*c + 2*c^2 + O(a, b, c)^12)
>>> (a**Integer(2) + b**Integer(2) + c**Integer(2)).quo_rem(Integer(1)/(Integer(1)+a+b+c))
(a^2 + b^2 + c^2 + a^3 + a^2*b + a^2*c + a*b^2 + a*c^2
   + b^3 + b^2*c + b*c^2 + c^3 + O(a, b, c)^14,
 0)
>>> (a**Integer(2) + b**Integer(2) + c**Integer(2)).quo_rem(a/(Integer(1)+a+b+c))
(a + a^2 + a*b + a*c + O(a, b, c)^13, b^2 + c^2)
>>> (Integer(1) + a + a**Integer(15)).quo_rem(a**Integer(2))
(0 + O(a, b, c)^10, 1 + a + O(a, b, c)^12)
>>> (Integer(1) + a + a**Integer(15)).quo_rem(a**Integer(2), precision=Integer(15))
(0 + O(a, b, c)^13, 1 + a + O(a, b, c)^15)
>>> (Integer(1) + a + a**Integer(15)).quo_rem(a**Integer(2), precision=Integer(16))
(a^13 + O(a, b, c)^14, 1 + a + O(a, b, c)^16)

Illustrating the dependency on the ordering of variables:

sage: # needs sage.libs.singular
sage: (1 + a + b).quo_rem(b + c)
(1 + O(a, b, c)^11, 1 + a - c + O(a, b, c)^12)
sage: (1 + b + c).quo_rem(c + a)
(0 + O(a, b, c)^11, 1 + b + c + O(a, b, c)^12)
sage: (1 + c + a).quo_rem(a + b)
(1 + O(a, b, c)^11, 1 - b + c + O(a, b, c)^12)
>>> from sage.all import *
>>> # needs sage.libs.singular
>>> (Integer(1) + a + b).quo_rem(b + c)
(1 + O(a, b, c)^11, 1 + a - c + O(a, b, c)^12)
>>> (Integer(1) + b + c).quo_rem(c + a)
(0 + O(a, b, c)^11, 1 + b + c + O(a, b, c)^12)
>>> (Integer(1) + c + a).quo_rem(a + b)
(1 + O(a, b, c)^11, 1 - b + c + O(a, b, c)^12)
shift(n)[source]#

Doesn’t make sense for multivariate power series.

solve_linear_de(prec=+Infinity, b=None, f0=None)[source]#

Not implemented for multivariate power series.

sqrt()[source]#

Method from univariate power series not yet implemented. Depends on square root method for multivariate polynomials.

square_root()[source]#

Method from univariate power series not yet implemented. Depends on square root method for multivariate polynomials.

trailing_monomial()[source]#

Return the trailing monomial of self.

This is defined here as the lowest term of the underlying polynomial.

EXAMPLES:

sage: R.<a,b,c> = PowerSeriesRing(ZZ)
sage: f = 1 + a + b - a*b + R.O(3)
sage: f.trailing_monomial()
1
sage: f = a^2*b^3*f; f
a^2*b^3 + a^3*b^3 + a^2*b^4 - a^3*b^4 + O(a, b, c)^8
sage: f.trailing_monomial()
a^2*b^3
>>> from sage.all import *
>>> R = PowerSeriesRing(ZZ, names=('a', 'b', 'c',)); (a, b, c,) = R._first_ngens(3)
>>> f = Integer(1) + a + b - a*b + R.O(Integer(3))
>>> f.trailing_monomial()
1
>>> f = a**Integer(2)*b**Integer(3)*f; f
a^2*b^3 + a^3*b^3 + a^2*b^4 - a^3*b^4 + O(a, b, c)^8
>>> f.trailing_monomial()
a^2*b^3
truncate(prec=+Infinity)[source]#

Return infinite precision multivariate power series formed by truncating self at precision prec.

EXAMPLES:

sage: M = PowerSeriesRing(QQ,4,'t'); M
Multivariate Power Series Ring in t0, t1, t2, t3 over Rational Field
sage: t = M.gens()
sage: f = 1/2*t[0]^3*t[1]^3*t[2]^2 + 2/3*t[0]*t[2]^6*t[3]             - t[0]^3*t[1]^3*t[3]^3 - 1/4*t[0]*t[1]*t[2]^7 + M.O(10)
sage: f
1/2*t0^3*t1^3*t2^2 + 2/3*t0*t2^6*t3 - t0^3*t1^3*t3^3
- 1/4*t0*t1*t2^7 + O(t0, t1, t2, t3)^10

sage: f.truncate()
1/2*t0^3*t1^3*t2^2 + 2/3*t0*t2^6*t3 - t0^3*t1^3*t3^3
- 1/4*t0*t1*t2^7
sage: f.truncate().parent()
Multivariate Power Series Ring in t0, t1, t2, t3 over Rational Field
>>> from sage.all import *
>>> M = PowerSeriesRing(QQ,Integer(4),'t'); M
Multivariate Power Series Ring in t0, t1, t2, t3 over Rational Field
>>> t = M.gens()
>>> f = Integer(1)/Integer(2)*t[Integer(0)]**Integer(3)*t[Integer(1)]**Integer(3)*t[Integer(2)]**Integer(2) + Integer(2)/Integer(3)*t[Integer(0)]*t[Integer(2)]**Integer(6)*t[Integer(3)]             - t[Integer(0)]**Integer(3)*t[Integer(1)]**Integer(3)*t[Integer(3)]**Integer(3) - Integer(1)/Integer(4)*t[Integer(0)]*t[Integer(1)]*t[Integer(2)]**Integer(7) + M.O(Integer(10))
>>> f
1/2*t0^3*t1^3*t2^2 + 2/3*t0*t2^6*t3 - t0^3*t1^3*t3^3
- 1/4*t0*t1*t2^7 + O(t0, t1, t2, t3)^10

>>> f.truncate()
1/2*t0^3*t1^3*t2^2 + 2/3*t0*t2^6*t3 - t0^3*t1^3*t3^3
- 1/4*t0*t1*t2^7
>>> f.truncate().parent()
Multivariate Power Series Ring in t0, t1, t2, t3 over Rational Field

Contrast with polynomial:

sage: f.polynomial()
1/2*t0^3*t1^3*t2^2 + 2/3*t0*t2^6*t3 - t0^3*t1^3*t3^3 - 1/4*t0*t1*t2^7
sage: f.polynomial().parent()
Multivariate Polynomial Ring in t0, t1, t2, t3 over Rational Field
>>> from sage.all import *
>>> f.polynomial()
1/2*t0^3*t1^3*t2^2 + 2/3*t0*t2^6*t3 - t0^3*t1^3*t3^3 - 1/4*t0*t1*t2^7
>>> f.polynomial().parent()
Multivariate Polynomial Ring in t0, t1, t2, t3 over Rational Field
valuation()[source]#

Return the valuation of self.

The valuation of a power series \(f\) is the highest nonnegative integer \(k\) less or equal to the precision of \(f\) and such that the coefficient of \(f\) before each term of degree \(< k\) is zero. (If such an integer does not exist, then the valuation is the precision of \(f\) itself.)

EXAMPLES:

sage: # needs sage.rings.finite_rings
sage: R.<a,b> = PowerSeriesRing(GF(4949717)); R
Multivariate Power Series Ring in a, b
 over Finite Field of size 4949717
sage: f = a^2 + a*b + a^3 + R.O(9)
sage: f.valuation()
2
sage: g = 1 + a + a^3
sage: g.valuation()
0
sage: R.zero().valuation()
+Infinity
>>> from sage.all import *
>>> # needs sage.rings.finite_rings
>>> R = PowerSeriesRing(GF(Integer(4949717)), names=('a', 'b',)); (a, b,) = R._first_ngens(2); R
Multivariate Power Series Ring in a, b
 over Finite Field of size 4949717
>>> f = a**Integer(2) + a*b + a**Integer(3) + R.O(Integer(9))
>>> f.valuation()
2
>>> g = Integer(1) + a + a**Integer(3)
>>> g.valuation()
0
>>> R.zero().valuation()
+Infinity
valuation_zero_part()[source]#

Doesn’t make sense for multivariate power series; valuation zero with respect to which variable?

variable()[source]#

Doesn’t make sense for multivariate power series.

variables()[source]#

Return tuple of variables occurring in self.

EXAMPLES:

sage: T = PowerSeriesRing(GF(3),5,'t'); T
Multivariate Power Series Ring in t0, t1, t2, t3, t4 over
Finite Field of size 3
sage: t = T.gens()
sage: w = t[0] - 2*t[0]*t[2] + 5*t[4]^3 - t[0]^3*t[2]^2 + T.O(6)
sage: w
t0 + t0*t2 - t4^3 - t0^3*t2^2 + O(t0, t1, t2, t3, t4)^6
sage: w.variables()
(t0, t2, t4)
>>> from sage.all import *
>>> T = PowerSeriesRing(GF(Integer(3)),Integer(5),'t'); T
Multivariate Power Series Ring in t0, t1, t2, t3, t4 over
Finite Field of size 3
>>> t = T.gens()
>>> w = t[Integer(0)] - Integer(2)*t[Integer(0)]*t[Integer(2)] + Integer(5)*t[Integer(4)]**Integer(3) - t[Integer(0)]**Integer(3)*t[Integer(2)]**Integer(2) + T.O(Integer(6))
>>> w
t0 + t0*t2 - t4^3 - t0^3*t2^2 + O(t0, t1, t2, t3, t4)^6
>>> w.variables()
(t0, t2, t4)
sage.rings.multi_power_series_ring_element.is_MPowerSeries(f)[source]#

Return True if f is a multivariate power series.