# Laurent Series#

EXAMPLES:

sage: R.<t> = LaurentSeriesRing(GF(7), 't'); R
Laurent Series Ring in t over Finite Field of size 7
sage: f = 1/(1-t+O(t^10)); f
1 + t + t^2 + t^3 + t^4 + t^5 + t^6 + t^7 + t^8 + t^9 + O(t^10)

>>> from sage.all import *
>>> R = LaurentSeriesRing(GF(Integer(7)), 't', names=('t',)); (t,) = R._first_ngens(1); R
Laurent Series Ring in t over Finite Field of size 7
>>> f = Integer(1)/(Integer(1)-t+O(t**Integer(10))); f
1 + t + t^2 + t^3 + t^4 + t^5 + t^6 + t^7 + t^8 + t^9 + O(t^10)


Laurent series are immutable:

sage: f[2]
1
sage: f[2] = 5
Traceback (most recent call last):
...
IndexError: Laurent series are immutable

>>> from sage.all import *
>>> f[Integer(2)]
1
>>> f[Integer(2)] = Integer(5)
Traceback (most recent call last):
...
IndexError: Laurent series are immutable


We compute with a Laurent series over the complex mpfr numbers.

sage: K.<q> = Frac(CC[['q']]); K                                                    # needs sage.rings.real_mpfr
Laurent Series Ring in q over Complex Field with 53 bits of precision
sage: q                                                                             # needs sage.rings.real_mpfr
1.00000000000000*q

>>> from sage.all import *
>>> K = Frac(CC[['q']], names=('q',)); (q,) = K._first_ngens(1); K                                                    # needs sage.rings.real_mpfr
Laurent Series Ring in q over Complex Field with 53 bits of precision
>>> q                                                                             # needs sage.rings.real_mpfr
1.00000000000000*q


sage: loads(q.dumps()) == q                                                         # needs sage.rings.real_mpfr
True
sage: loads(K.dumps()) == K                                                         # needs sage.rings.real_mpfr
True

>>> from sage.all import *
>>> loads(q.dumps()) == q                                                         # needs sage.rings.real_mpfr
True
>>> loads(K.dumps()) == K                                                         # needs sage.rings.real_mpfr
True


IMPLEMENTATION: Laurent series in Sage are represented internally as a power of the variable times the unit part (which need not be a unit - it’s a polynomial with nonzero constant term). The zero Laurent series has unit part 0.

AUTHORS:

• William Stein: original version

• David Joyner (2006-01-22): added examples

• Robert Bradshaw (2007-04): optimizations, shifting

class sage.rings.laurent_series_ring_element.LaurentSeries[source]#

Bases: AlgebraElement

A Laurent Series.

We consider a Laurent series of the form $$t^n \cdot f$$ where $$f$$ is a power series.

INPUT:

• parent – a Laurent series ring

• f – a power series (or something can be coerced to one); note that f does not have to be a unit

• n – (default: 0) integer

O(prec)[source]#

Return the Laurent series of precision at most prec obtained by adding $$O(q^\text{prec})$$, where $$q$$ is the variable.

The precision of self and the integer prec can be arbitrary. The resulting Laurent series will have precision equal to the minimum of the precision of self and prec. The term $$O(q^\text{prec})$$ is the zero series with precision prec.

See also add_bigoh().

EXAMPLES:

sage: R.<t> = LaurentSeriesRing(QQ)
sage: f = t^-5 + t^-4 + t^3 + O(t^10); f
t^-5 + t^-4 + t^3 + O(t^10)
sage: f.O(-4)
t^-5 + O(t^-4)
sage: f.O(15)
t^-5 + t^-4 + t^3 + O(t^10)

>>> from sage.all import *
>>> R = LaurentSeriesRing(QQ, names=('t',)); (t,) = R._first_ngens(1)
>>> f = t**-Integer(5) + t**-Integer(4) + t**Integer(3) + O(t**Integer(10)); f
t^-5 + t^-4 + t^3 + O(t^10)
>>> f.O(-Integer(4))
t^-5 + O(t^-4)
>>> f.O(Integer(15))
t^-5 + t^-4 + t^3 + O(t^10)

V(n)[source]#

Return the n-th Verschiebung of self.

If $$f = \sum a_m x^m$$ then this function returns $$\sum a_m x^{mn}$$.

EXAMPLES:

sage: R.<x> = LaurentSeriesRing(QQ)
sage: f = -1/x + 1 + 2*x^2 + 5*x^5
sage: f.V(2)
-x^-2 + 1 + 2*x^4 + 5*x^10
sage: f.V(-1)
5*x^-5 + 2*x^-2 + 1 - x
sage: h.V(2)
-x^-2 + 1 + 2*x^4 + 5*x^10 + O(x^14)
sage: h.V(-2)
Traceback (most recent call last):
...
ValueError: For finite precision only positive arguments allowed

>>> from sage.all import *
>>> R = LaurentSeriesRing(QQ, names=('x',)); (x,) = R._first_ngens(1)
>>> f = -Integer(1)/x + Integer(1) + Integer(2)*x**Integer(2) + Integer(5)*x**Integer(5)
>>> f.V(Integer(2))
-x^-2 + 1 + 2*x^4 + 5*x^10
>>> f.V(-Integer(1))
5*x^-5 + 2*x^-2 + 1 - x
>>> h.V(Integer(2))
-x^-2 + 1 + 2*x^4 + 5*x^10 + O(x^14)
>>> h.V(-Integer(2))
Traceback (most recent call last):
...
ValueError: For finite precision only positive arguments allowed


Return the truncated series at chosen precision prec.

See also O().

INPUT:

• prec – the precision of the series as an integer

EXAMPLES:

sage: R.<t> = LaurentSeriesRing(QQ)
sage: f = t^2 + t^3 + O(t^10); f
t^2 + t^3 + O(t^10)
t^2 + t^3 + O(t^5)

>>> from sage.all import *
>>> R = LaurentSeriesRing(QQ, names=('t',)); (t,) = R._first_ngens(1)
>>> f = t**Integer(2) + t**Integer(3) + O(t**Integer(10)); f
t^2 + t^3 + O(t^10)
t^2 + t^3 + O(t^5)

change_ring(R)[source]#

Change the base ring of self.

EXAMPLES:

sage: R.<q> = LaurentSeriesRing(ZZ)
sage: p = R([1,2,3]); p
1 + 2*q + 3*q^2
sage: p.change_ring(GF(2))
1 + q^2

>>> from sage.all import *
>>> R = LaurentSeriesRing(ZZ, names=('q',)); (q,) = R._first_ngens(1)
>>> p = R([Integer(1),Integer(2),Integer(3)]); p
1 + 2*q + 3*q^2
>>> p.change_ring(GF(Integer(2)))
1 + q^2

coefficients()[source]#

Return the nonzero coefficients of self.

EXAMPLES:

sage: R.<t> = LaurentSeriesRing(QQ)
sage: f = -5/t^(2) + t + t^2 - 10/3*t^3
sage: f.coefficients()
[-5, 1, 1, -10/3]

>>> from sage.all import *
>>> R = LaurentSeriesRing(QQ, names=('t',)); (t,) = R._first_ngens(1)
>>> f = -Integer(5)/t**(Integer(2)) + t + t**Integer(2) - Integer(10)/Integer(3)*t**Integer(3)
>>> f.coefficients()
[-5, 1, 1, -10/3]

common_prec(other)[source]#

Return the minimum precision of self and other.

EXAMPLES:

sage: R.<t> = LaurentSeriesRing(QQ)

>>> from sage.all import *
>>> R = LaurentSeriesRing(QQ, names=('t',)); (t,) = R._first_ngens(1)

sage: f = t^(-1) + t + t^2 + O(t^3)
sage: g = t + t^3 + t^4 + O(t^4)
sage: f.common_prec(g)
3
sage: g.common_prec(f)
3

>>> from sage.all import *
>>> f = t**(-Integer(1)) + t + t**Integer(2) + O(t**Integer(3))
>>> g = t + t**Integer(3) + t**Integer(4) + O(t**Integer(4))
>>> f.common_prec(g)
3
>>> g.common_prec(f)
3

sage: f = t + t^2 + O(t^3)
sage: g = t^(-3) + t^2
sage: f.common_prec(g)
3
sage: g.common_prec(f)
3

>>> from sage.all import *
>>> f = t + t**Integer(2) + O(t**Integer(3))
>>> g = t**(-Integer(3)) + t**Integer(2)
>>> f.common_prec(g)
3
>>> g.common_prec(f)
3

sage: f = t + t^2
sage: g = t^2
sage: f.common_prec(g)
+Infinity

>>> from sage.all import *
>>> f = t + t**Integer(2)
>>> g = t**Integer(2)
>>> f.common_prec(g)
+Infinity

sage: f = t^(-3) + O(t^(-2))
sage: g = t^(-5) + O(t^(-1))
sage: f.common_prec(g)
-2

>>> from sage.all import *
>>> f = t**(-Integer(3)) + O(t**(-Integer(2)))
>>> g = t**(-Integer(5)) + O(t**(-Integer(1)))
>>> f.common_prec(g)
-2

sage: f = O(t^2)
sage: g = O(t^5)
sage: f.common_prec(g)
2

>>> from sage.all import *
>>> f = O(t**Integer(2))
>>> g = O(t**Integer(5))
>>> f.common_prec(g)
2

common_valuation(other)[source]#

Return the minimum valuation of self and other.

EXAMPLES:

sage: R.<t> = LaurentSeriesRing(QQ)

>>> from sage.all import *
>>> R = LaurentSeriesRing(QQ, names=('t',)); (t,) = R._first_ngens(1)

sage: f = t^(-1) + t + t^2 + O(t^3)
sage: g = t + t^3 + t^4 + O(t^4)
sage: f.common_valuation(g)
-1
sage: g.common_valuation(f)
-1

>>> from sage.all import *
>>> f = t**(-Integer(1)) + t + t**Integer(2) + O(t**Integer(3))
>>> g = t + t**Integer(3) + t**Integer(4) + O(t**Integer(4))
>>> f.common_valuation(g)
-1
>>> g.common_valuation(f)
-1

sage: f = t + t^2 + O(t^3)
sage: g = t^(-3) + t^2
sage: f.common_valuation(g)
-3
sage: g.common_valuation(f)
-3

>>> from sage.all import *
>>> f = t + t**Integer(2) + O(t**Integer(3))
>>> g = t**(-Integer(3)) + t**Integer(2)
>>> f.common_valuation(g)
-3
>>> g.common_valuation(f)
-3

sage: f = t + t^2
sage: g = t^2
sage: f.common_valuation(g)
1

>>> from sage.all import *
>>> f = t + t**Integer(2)
>>> g = t**Integer(2)
>>> f.common_valuation(g)
1

sage: f = t^(-3) + O(t^(-2))
sage: g = t^(-5) + O(t^(-1))
sage: f.common_valuation(g)
-5

>>> from sage.all import *
>>> f = t**(-Integer(3)) + O(t**(-Integer(2)))
>>> g = t**(-Integer(5)) + O(t**(-Integer(1)))
>>> f.common_valuation(g)
-5

sage: f = O(t^2)
sage: g = O(t^5)
sage: f.common_valuation(g)
+Infinity

>>> from sage.all import *
>>> f = O(t**Integer(2))
>>> g = O(t**Integer(5))
>>> f.common_valuation(g)
+Infinity

degree()[source]#

Return the degree of a polynomial equivalent to this power series modulo big oh of the precision.

EXAMPLES:

sage: x = Frac(QQ[['x']]).0
sage: g = x^2 - x^4 + O(x^8)
sage: g.degree()
4
sage: g = -10/x^5 + x^2 - x^4 + O(x^8)
sage: g.degree()
4
sage: (x^-2 + O(x^0)).degree()
-2

>>> from sage.all import *
>>> x = Frac(QQ[['x']]).gen(0)
>>> g = x**Integer(2) - x**Integer(4) + O(x**Integer(8))
>>> g.degree()
4
>>> g = -Integer(10)/x**Integer(5) + x**Integer(2) - x**Integer(4) + O(x**Integer(8))
>>> g.degree()
4
>>> (x**-Integer(2) + O(x**Integer(0))).degree()
-2

derivative(*args)[source]#

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

Multiple variables and iteration counts may be supplied; see documentation for the global derivative() function for more details.

_derivative()

EXAMPLES:

sage: R.<x> = LaurentSeriesRing(QQ)
sage: g = 1/x^10 - x + x^2 - x^4 + O(x^8)
sage: g.derivative()
-10*x^-11 - 1 + 2*x - 4*x^3 + O(x^7)
sage: g.derivative(x)
-10*x^-11 - 1 + 2*x - 4*x^3 + O(x^7)

>>> from sage.all import *
>>> R = LaurentSeriesRing(QQ, names=('x',)); (x,) = R._first_ngens(1)
>>> g = Integer(1)/x**Integer(10) - x + x**Integer(2) - x**Integer(4) + O(x**Integer(8))
>>> g.derivative()
-10*x^-11 - 1 + 2*x - 4*x^3 + O(x^7)
>>> g.derivative(x)
-10*x^-11 - 1 + 2*x - 4*x^3 + O(x^7)

sage: R.<t> = PolynomialRing(ZZ)
sage: S.<x> = LaurentSeriesRing(R)
sage: f = 2*t/x + (3*t^2 + 6*t)*x + O(x^2)
sage: f.derivative()
-2*t*x^-2 + (3*t^2 + 6*t) + O(x)
sage: f.derivative(x)
-2*t*x^-2 + (3*t^2 + 6*t) + O(x)
sage: f.derivative(t)
2*x^-1 + (6*t + 6)*x + O(x^2)

>>> from sage.all import *
>>> R = PolynomialRing(ZZ, names=('t',)); (t,) = R._first_ngens(1)
>>> S = LaurentSeriesRing(R, names=('x',)); (x,) = S._first_ngens(1)
>>> f = Integer(2)*t/x + (Integer(3)*t**Integer(2) + Integer(6)*t)*x + O(x**Integer(2))
>>> f.derivative()
-2*t*x^-2 + (3*t^2 + 6*t) + O(x)
>>> f.derivative(x)
-2*t*x^-2 + (3*t^2 + 6*t) + O(x)
>>> f.derivative(t)
2*x^-1 + (6*t + 6)*x + O(x^2)

exponents()[source]#

Return the exponents appearing in self with nonzero coefficients.

EXAMPLES:

sage: R.<t> = LaurentSeriesRing(QQ)
sage: f = -5/t^(2) + t + t^2 - 10/3*t^3
sage: f.exponents()
[-2, 1, 2, 3]

>>> from sage.all import *
>>> R = LaurentSeriesRing(QQ, names=('t',)); (t,) = R._first_ngens(1)
>>> f = -Integer(5)/t**(Integer(2)) + t + t**Integer(2) - Integer(10)/Integer(3)*t**Integer(3)
>>> f.exponents()
[-2, 1, 2, 3]

integral()[source]#

The formal integral of this Laurent series with 0 constant term.

EXAMPLES: The integral may or may not be defined if the base ring is not a field.

sage: t = LaurentSeriesRing(ZZ, 't').0
sage: f = 2*t^-3 + 3*t^2 + O(t^4)
sage: f.integral()
-t^-2 + t^3 + O(t^5)

>>> from sage.all import *
>>> t = LaurentSeriesRing(ZZ, 't').gen(0)
>>> f = Integer(2)*t**-Integer(3) + Integer(3)*t**Integer(2) + O(t**Integer(4))
>>> f.integral()
-t^-2 + t^3 + O(t^5)

sage: f = t^3
sage: f.integral()
Traceback (most recent call last):
...
ArithmeticError: Coefficients of integral cannot be coerced into the base ring

>>> from sage.all import *
>>> f = t**Integer(3)
>>> f.integral()
Traceback (most recent call last):
...
ArithmeticError: Coefficients of integral cannot be coerced into the base ring


The integral of 1/t is $$\log(t)$$, which is not given by a Laurent series:

sage: t = Frac(QQ[['t']]).0
sage: f = -1/t^3 - 31/t + O(t^3)
sage: f.integral()
Traceback (most recent call last):
...
ArithmeticError: The integral of is not a Laurent series, since t^-1 has nonzero coefficient.

>>> from sage.all import *
>>> t = Frac(QQ[['t']]).gen(0)
>>> f = -Integer(1)/t**Integer(3) - Integer(31)/t + O(t**Integer(3))
>>> f.integral()
Traceback (most recent call last):
...
ArithmeticError: The integral of is not a Laurent series, since t^-1 has nonzero coefficient.


Another example with just one negative coefficient:

sage: A.<t> = QQ[[]]
sage: f = -2*t^(-4) + O(t^8)
sage: f.integral()
2/3*t^-3 + O(t^9)
sage: f.integral().derivative() == f
True

>>> from sage.all import *
>>> A = QQ[['t']]; (t,) = A._first_ngens(1)
>>> f = -Integer(2)*t**(-Integer(4)) + O(t**Integer(8))
>>> f.integral()
2/3*t^-3 + O(t^9)
>>> f.integral().derivative() == f
True

inverse()[source]#

Return the inverse of self, i.e., self^(-1).

EXAMPLES:

sage: R.<t> = LaurentSeriesRing(ZZ)
sage: t.inverse()
t^-1
sage: (1-t).inverse()
1 + t + t^2 + t^3 + t^4 + t^5 + t^6 + t^7 + t^8 + ...

>>> from sage.all import *
>>> R = LaurentSeriesRing(ZZ, names=('t',)); (t,) = R._first_ngens(1)
>>> t.inverse()
t^-1
>>> (Integer(1)-t).inverse()
1 + t + t^2 + t^3 + t^4 + t^5 + t^6 + t^7 + t^8 + ...

is_monomial()[source]#

Return True if this element is a monomial. That is, if self is $$x^n$$ for some integer $$n$$.

EXAMPLES:

sage: k.<z> = LaurentSeriesRing(QQ, 'z')
sage: (30*z).is_monomial()
False
sage: k(1).is_monomial()
True
sage: (z+1).is_monomial()
False
sage: (z^-2909).is_monomial()
True
sage: (3*z^-2909).is_monomial()
False

>>> from sage.all import *
>>> k = LaurentSeriesRing(QQ, 'z', names=('z',)); (z,) = k._first_ngens(1)
>>> (Integer(30)*z).is_monomial()
False
>>> k(Integer(1)).is_monomial()
True
>>> (z+Integer(1)).is_monomial()
False
>>> (z**-Integer(2909)).is_monomial()
True
>>> (Integer(3)*z**-Integer(2909)).is_monomial()
False

is_unit()[source]#

Return True if this is Laurent series is a unit in this ring.

EXAMPLES:

sage: R.<t> = LaurentSeriesRing(QQ)
sage: (2 + t).is_unit()
True
sage: f = 2 + t^2 + O(t^10); f.is_unit()
True
sage: 1/f
1/2 - 1/4*t^2 + 1/8*t^4 - 1/16*t^6 + 1/32*t^8 + O(t^10)
sage: R(0).is_unit()
False
sage: R.<s> = LaurentSeriesRing(ZZ)
sage: f = 2 + s^2 + O(s^10)
sage: f.is_unit()
False
sage: 1/f
Traceback (most recent call last):
...
ValueError: constant term 2 is not a unit

>>> from sage.all import *
>>> R = LaurentSeriesRing(QQ, names=('t',)); (t,) = R._first_ngens(1)
>>> (Integer(2) + t).is_unit()
True
>>> f = Integer(2) + t**Integer(2) + O(t**Integer(10)); f.is_unit()
True
>>> Integer(1)/f
1/2 - 1/4*t^2 + 1/8*t^4 - 1/16*t^6 + 1/32*t^8 + O(t^10)
>>> R(Integer(0)).is_unit()
False
>>> R = LaurentSeriesRing(ZZ, names=('s',)); (s,) = R._first_ngens(1)
>>> f = Integer(2) + s**Integer(2) + O(s**Integer(10))
>>> f.is_unit()
False
>>> Integer(1)/f
Traceback (most recent call last):
...
ValueError: constant term 2 is not a unit


ALGORITHM: A Laurent series is a unit if and only if its “unit part” is a unit.

is_zero()[source]#

EXAMPLES:

sage: x = Frac(QQ[['x']]).0
sage: f = 1/x + x + x^2 + 3*x^4 + O(x^7)
sage: f.is_zero()
0
sage: z = 0*f
sage: z.is_zero()
1

>>> from sage.all import *
>>> x = Frac(QQ[['x']]).gen(0)
>>> f = Integer(1)/x + x + x**Integer(2) + Integer(3)*x**Integer(4) + O(x**Integer(7))
>>> f.is_zero()
0
>>> z = Integer(0)*f
>>> z.is_zero()
1

laurent_polynomial()[source]#

Return the corresponding Laurent polynomial.

EXAMPLES:

sage: R.<t> = LaurentSeriesRing(QQ)
sage: f = t^-3 + t + 7*t^2 + O(t^5)
sage: g = f.laurent_polynomial(); g
t^-3 + t + 7*t^2
sage: g.parent()
Univariate Laurent Polynomial Ring in t over Rational Field

>>> from sage.all import *
>>> R = LaurentSeriesRing(QQ, names=('t',)); (t,) = R._first_ngens(1)
>>> f = t**-Integer(3) + t + Integer(7)*t**Integer(2) + O(t**Integer(5))
>>> g = f.laurent_polynomial(); g
t^-3 + t + 7*t^2
>>> g.parent()
Univariate Laurent Polynomial Ring in t over Rational Field

lift_to_precision(absprec=None)[source]#

Return a congruent Laurent series with absolute precision at least absprec.

INPUT:

• absprec – an integer or None (default: None), the absolute precision of the result. If None, lifts to an exact element.

EXAMPLES:

sage: # needs sage.rings.finite_rings
sage: A.<t> = LaurentSeriesRing(GF(5))
sage: x = t^(-1) + t^2 + O(t^5)
sage: x.lift_to_precision(10)
t^-1 + t^2 + O(t^10)
sage: x.lift_to_precision()
t^-1 + t^2

>>> from sage.all import *
>>> # needs sage.rings.finite_rings
>>> A = LaurentSeriesRing(GF(Integer(5)), names=('t',)); (t,) = A._first_ngens(1)
>>> x = t**(-Integer(1)) + t**Integer(2) + O(t**Integer(5))
>>> x.lift_to_precision(Integer(10))
t^-1 + t^2 + O(t^10)
>>> x.lift_to_precision()
t^-1 + t^2

list()[source]#

EXAMPLES:

sage: R.<t> = LaurentSeriesRing(QQ)
sage: f = -5/t^(2) + t + t^2 - 10/3*t^3
sage: f.list()
[-5, 0, 0, 1, 1, -10/3]

>>> from sage.all import *
>>> R = LaurentSeriesRing(QQ, names=('t',)); (t,) = R._first_ngens(1)
>>> f = -Integer(5)/t**(Integer(2)) + t + t**Integer(2) - Integer(10)/Integer(3)*t**Integer(3)
>>> f.list()
[-5, 0, 0, 1, 1, -10/3]

nth_root(n, prec=None)[source]#

Return the n-th root of this Laurent power series.

INPUT:

• n – integer

• prec – integer (optional); precision of the result. Though, if this series has finite precision, then the result cannot have larger precision.

EXAMPLES:

sage: R.<x> = LaurentSeriesRing(QQ)
sage: (x^-2 + 1 + x).nth_root(2)
x^-1 + 1/2*x + 1/2*x^2 - ... - 19437/65536*x^18 + O(x^19)
sage: (x^-2 + 1 + x).nth_root(2)**2
x^-2 + 1 + x + O(x^18)

sage: # needs sage.modular
sage: j = j_invariant_qexp()
sage: q = j.parent().gen()
sage: j(q^3).nth_root(3)
q^-1 + 248*q^2 + 4124*q^5 + ... + O(q^29)
sage: (j(q^2) - 1728).nth_root(2)
q^-1 - 492*q - 22590*q^3 - ... + O(q^19)

>>> from sage.all import *
>>> R = LaurentSeriesRing(QQ, names=('x',)); (x,) = R._first_ngens(1)
>>> (x**-Integer(2) + Integer(1) + x).nth_root(Integer(2))
x^-1 + 1/2*x + 1/2*x^2 - ... - 19437/65536*x^18 + O(x^19)
>>> (x**-Integer(2) + Integer(1) + x).nth_root(Integer(2))**Integer(2)
x^-2 + 1 + x + O(x^18)

>>> # needs sage.modular
>>> j = j_invariant_qexp()
>>> q = j.parent().gen()
>>> j(q**Integer(3)).nth_root(Integer(3))
q^-1 + 248*q^2 + 4124*q^5 + ... + O(q^29)
>>> (j(q**Integer(2)) - Integer(1728)).nth_root(Integer(2))
q^-1 - 492*q - 22590*q^3 - ... + O(q^19)

power_series()[source]#

Convert this Laurent series to a power series.

An error is raised if the Laurent series has a term (or an error term $$O(x^k)$$) whose exponent is negative.

EXAMPLES:

sage: R.<t> = LaurentSeriesRing(ZZ)
sage: f = 1/(1-t+O(t^10)); f.parent()
Laurent Series Ring in t over Integer Ring
sage: g = f.power_series(); g
1 + t + t^2 + t^3 + t^4 + t^5 + t^6 + t^7 + t^8 + t^9 + O(t^10)
sage: parent(g)
Power Series Ring in t over Integer Ring
sage: f = 3/t^2 +  t^2 + t^3 + O(t^10)
sage: f.power_series()
Traceback (most recent call last):
...
TypeError: self is not a power series

>>> from sage.all import *
>>> R = LaurentSeriesRing(ZZ, names=('t',)); (t,) = R._first_ngens(1)
>>> f = Integer(1)/(Integer(1)-t+O(t**Integer(10))); f.parent()
Laurent Series Ring in t over Integer Ring
>>> g = f.power_series(); g
1 + t + t^2 + t^3 + t^4 + t^5 + t^6 + t^7 + t^8 + t^9 + O(t^10)
>>> parent(g)
Power Series Ring in t over Integer Ring
>>> f = Integer(3)/t**Integer(2) +  t**Integer(2) + t**Integer(3) + O(t**Integer(10))
>>> f.power_series()
Traceback (most recent call last):
...
TypeError: self is not a power series

prec()[source]#

This function returns the n so that the Laurent series is of the form (stuff) + $$O(t^n)$$. It doesn’t matter how many negative powers appear in the expansion. In particular, prec could be negative.

EXAMPLES:

sage: x = Frac(QQ[['x']]).0
sage: f = x^2 + 3*x^4 + O(x^7)
sage: f.prec()
7
sage: g = 1/x^10 - x + x^2 - x^4 + O(x^8)
sage: g.prec()
8

>>> from sage.all import *
>>> x = Frac(QQ[['x']]).gen(0)
>>> f = x**Integer(2) + Integer(3)*x**Integer(4) + O(x**Integer(7))
>>> f.prec()
7
>>> g = Integer(1)/x**Integer(10) - x + x**Integer(2) - x**Integer(4) + O(x**Integer(8))
>>> g.prec()
8

precision_absolute()[source]#

Return the absolute precision of this series.

By definition, the absolute precision of $$...+O(x^r)$$ is $$r$$.

EXAMPLES:

sage: R.<t> = ZZ[[]]
sage: (t^2 + O(t^3)).precision_absolute()
3
sage: (1 - t^2 + O(t^100)).precision_absolute()
100

>>> from sage.all import *
>>> R = ZZ[['t']]; (t,) = R._first_ngens(1)
>>> (t**Integer(2) + O(t**Integer(3))).precision_absolute()
3
>>> (Integer(1) - t**Integer(2) + O(t**Integer(100))).precision_absolute()
100

precision_relative()[source]#

Return the relative precision of this series, that is the difference between its absolute precision and its valuation.

By convention, the relative precision of $$0$$ (or $$O(x^r)$$ for any $$r$$) is $$0$$.

EXAMPLES:

sage: R.<t> = ZZ[[]]
sage: (t^2 + O(t^3)).precision_relative()
1
sage: (1 - t^2 + O(t^100)).precision_relative()
100
sage: O(t^4).precision_relative()
0

>>> from sage.all import *
>>> R = ZZ[['t']]; (t,) = R._first_ngens(1)
>>> (t**Integer(2) + O(t**Integer(3))).precision_relative()
1
>>> (Integer(1) - t**Integer(2) + O(t**Integer(100))).precision_relative()
100
>>> O(t**Integer(4)).precision_relative()
0

residue()[source]#

Return the residue of self.

Consider the Laurent series

$f = \sum_{n \in \ZZ} a_n t^n = \cdots + \frac{a_{-2}}{t^2} + \frac{a_{-1}}{t} + a_0 + a_1 t + a_2 t^2 + \cdots,$

then the residue of $$f$$ is $$a_{-1}$$. Alternatively this is the coefficient of $$1/t$$.

EXAMPLES:

sage: t = LaurentSeriesRing(ZZ,'t').gen()
sage: f = 1/t**2 + 2/t + 3 + 4*t
sage: f.residue()
2
sage: f = t + t**2
sage: f.residue()
0
sage: f.residue().parent()
Integer Ring

>>> from sage.all import *
>>> t = LaurentSeriesRing(ZZ,'t').gen()
>>> f = Integer(1)/t**Integer(2) + Integer(2)/t + Integer(3) + Integer(4)*t
>>> f.residue()
2
>>> f = t + t**Integer(2)
>>> f.residue()
0
>>> f.residue().parent()
Integer Ring

reverse(precision=None)[source]#

Return the reverse of f, i.e., the series g such that g(f(x)) = x. Given an optional argument precision, return the reverse with given precision (note that the reverse can have precision at most f.prec()). If f has infinite precision, and the argument precision is not given, then the precision of the reverse defaults to the default precision of f.parent().

Note that this is only possible if the valuation of self is exactly 1.

The implementation depends on the underlying power series element implementing a reverse method.

EXAMPLES:

sage: R.<x> = Frac(QQ[['x']])
sage: f = 2*x + 3*x^2 - x^4 + O(x^5)
sage: g = f.reverse()
sage: g
1/2*x - 3/8*x^2 + 9/16*x^3 - 131/128*x^4 + O(x^5)
sage: f(g)
x + O(x^5)
sage: g(f)
x + O(x^5)

sage: A.<t> = LaurentSeriesRing(ZZ)
sage: a = t - t^2 - 2*t^4 + t^5 + O(t^6)
sage: b = a.reverse(); b
t + t^2 + 2*t^3 + 7*t^4 + 25*t^5 + O(t^6)
sage: a(b)
t + O(t^6)
sage: b(a)
t + O(t^6)

sage: B.<b,c> = ZZ[ ]
sage: A.<t> = LaurentSeriesRing(B)
sage: f = t + b*t^2 + c*t^3 + O(t^4)
sage: g = f.reverse(); g
t - b*t^2 + (2*b^2 - c)*t^3 + O(t^4)
sage: f(g)
t + O(t^4)
sage: g(f)
t + O(t^4)

sage: A.<t> = PowerSeriesRing(ZZ)
sage: B.<s> = LaurentSeriesRing(A)
sage: f = (1 - 3*t + 4*t^3 + O(t^4))*s + (2 + t + t^2 + O(t^3))*s^2 + O(s^3)
sage: set_verbose(1)
sage: g = f.reverse(); g
verbose 1 (<module>) passing to pari failed; trying Lagrange inversion
(1 + 3*t + 9*t^2 + 23*t^3 + O(t^4))*s + (-2 - 19*t - 118*t^2 + O(t^3))*s^2 + O(s^3)
sage: set_verbose(0)
sage: f(g) == g(f) == s
True

>>> from sage.all import *
>>> R = Frac(QQ[['x']], names=('x',)); (x,) = R._first_ngens(1)
>>> f = Integer(2)*x + Integer(3)*x**Integer(2) - x**Integer(4) + O(x**Integer(5))
>>> g = f.reverse()
>>> g
1/2*x - 3/8*x^2 + 9/16*x^3 - 131/128*x^4 + O(x^5)
>>> f(g)
x + O(x^5)
>>> g(f)
x + O(x^5)

>>> A = LaurentSeriesRing(ZZ, names=('t',)); (t,) = A._first_ngens(1)
>>> a = t - t**Integer(2) - Integer(2)*t**Integer(4) + t**Integer(5) + O(t**Integer(6))
>>> b = a.reverse(); b
t + t^2 + 2*t^3 + 7*t^4 + 25*t^5 + O(t^6)
>>> a(b)
t + O(t^6)
>>> b(a)
t + O(t^6)

>>> B = ZZ['b, c']; (b, c,) = B._first_ngens(2)
>>> A = LaurentSeriesRing(B, names=('t',)); (t,) = A._first_ngens(1)
>>> f = t + b*t**Integer(2) + c*t**Integer(3) + O(t**Integer(4))
>>> g = f.reverse(); g
t - b*t^2 + (2*b^2 - c)*t^3 + O(t^4)
>>> f(g)
t + O(t^4)
>>> g(f)
t + O(t^4)

>>> A = PowerSeriesRing(ZZ, names=('t',)); (t,) = A._first_ngens(1)
>>> B = LaurentSeriesRing(A, names=('s',)); (s,) = B._first_ngens(1)
>>> f = (Integer(1) - Integer(3)*t + Integer(4)*t**Integer(3) + O(t**Integer(4)))*s + (Integer(2) + t + t**Integer(2) + O(t**Integer(3)))*s**Integer(2) + O(s**Integer(3))
>>> set_verbose(Integer(1))
>>> g = f.reverse(); g
verbose 1 (<module>) passing to pari failed; trying Lagrange inversion
(1 + 3*t + 9*t^2 + 23*t^3 + O(t^4))*s + (-2 - 19*t - 118*t^2 + O(t^3))*s^2 + O(s^3)
>>> set_verbose(Integer(0))
>>> f(g) == g(f) == s
True


If the leading coefficient is not a unit, we pass to its fraction field if possible:

sage: A.<t> = LaurentSeriesRing(ZZ)
sage: a = 2*t - 4*t^2 + t^4 - t^5 + O(t^6)
sage: a.reverse()
1/2*t + 1/2*t^2 + t^3 + 79/32*t^4 + 437/64*t^5 + O(t^6)

sage: B.<b> = PolynomialRing(ZZ)
sage: A.<t> = LaurentSeriesRing(B)
sage: f = 2*b*t + b*t^2 + 3*b^2*t^3 + O(t^4)
sage: g = f.reverse(); g
1/(2*b)*t - 1/(8*b^2)*t^2 + ((-3*b + 1)/(16*b^3))*t^3 + O(t^4)
sage: f(g)
t + O(t^4)
sage: g(f)
t + O(t^4)

>>> from sage.all import *
>>> A = LaurentSeriesRing(ZZ, names=('t',)); (t,) = A._first_ngens(1)
>>> a = Integer(2)*t - Integer(4)*t**Integer(2) + t**Integer(4) - t**Integer(5) + O(t**Integer(6))
>>> a.reverse()
1/2*t + 1/2*t^2 + t^3 + 79/32*t^4 + 437/64*t^5 + O(t^6)

>>> B = PolynomialRing(ZZ, names=('b',)); (b,) = B._first_ngens(1)
>>> A = LaurentSeriesRing(B, names=('t',)); (t,) = A._first_ngens(1)
>>> f = Integer(2)*b*t + b*t**Integer(2) + Integer(3)*b**Integer(2)*t**Integer(3) + O(t**Integer(4))
>>> g = f.reverse(); g
1/(2*b)*t - 1/(8*b^2)*t^2 + ((-3*b + 1)/(16*b^3))*t^3 + O(t^4)
>>> f(g)
t + O(t^4)
>>> g(f)
t + O(t^4)


We can handle some base rings of positive characteristic:

sage: A8.<t> = LaurentSeriesRing(Zmod(8))
sage: a = t - 15*t^2 - 2*t^4 + t^5 + O(t^6)
sage: b = a.reverse(); b
t + 7*t^2 + 2*t^3 + 5*t^4 + t^5 + O(t^6)
sage: a(b)
t + O(t^6)
sage: b(a)
t + O(t^6)

>>> from sage.all import *
>>> A8 = LaurentSeriesRing(Zmod(Integer(8)), names=('t',)); (t,) = A8._first_ngens(1)
>>> a = t - Integer(15)*t**Integer(2) - Integer(2)*t**Integer(4) + t**Integer(5) + O(t**Integer(6))
>>> b = a.reverse(); b
t + 7*t^2 + 2*t^3 + 5*t^4 + t^5 + O(t^6)
>>> a(b)
t + O(t^6)
>>> b(a)
t + O(t^6)


The optional argument precision sets the precision of the output:

sage: R.<x> = LaurentSeriesRing(QQ)
sage: f = 2*x + 3*x^2 - 7*x^3 + x^4 + O(x^5)
sage: g = f.reverse(precision=3); g
1/2*x - 3/8*x^2 + O(x^3)
sage: f(g)
x + O(x^3)
sage: g(f)
x + O(x^3)

>>> from sage.all import *
>>> R = LaurentSeriesRing(QQ, names=('x',)); (x,) = R._first_ngens(1)
>>> f = Integer(2)*x + Integer(3)*x**Integer(2) - Integer(7)*x**Integer(3) + x**Integer(4) + O(x**Integer(5))
>>> g = f.reverse(precision=Integer(3)); g
1/2*x - 3/8*x^2 + O(x^3)
>>> f(g)
x + O(x^3)
>>> g(f)
x + O(x^3)


If the input series has infinite precision, the precision of the output is automatically set to the default precision of the parent ring:

sage: R.<x> = LaurentSeriesRing(QQ, default_prec=20)
sage: (x - x^2).reverse()  # get some Catalan numbers
x + x^2 + 2*x^3 + 5*x^4 + 14*x^5 + 42*x^6 + 132*x^7 + 429*x^8 + 1430*x^9
+ 4862*x^10 + 16796*x^11 + 58786*x^12 + 208012*x^13 + 742900*x^14
+ 2674440*x^15 + 9694845*x^16 + 35357670*x^17 + 129644790*x^18
+ 477638700*x^19 + O(x^20)
sage: (x - x^2).reverse(precision=3)
x + x^2 + O(x^3)

>>> from sage.all import *
>>> R = LaurentSeriesRing(QQ, default_prec=Integer(20), names=('x',)); (x,) = R._first_ngens(1)
>>> (x - x**Integer(2)).reverse()  # get some Catalan numbers
x + x^2 + 2*x^3 + 5*x^4 + 14*x^5 + 42*x^6 + 132*x^7 + 429*x^8 + 1430*x^9
+ 4862*x^10 + 16796*x^11 + 58786*x^12 + 208012*x^13 + 742900*x^14
+ 2674440*x^15 + 9694845*x^16 + 35357670*x^17 + 129644790*x^18
+ 477638700*x^19 + O(x^20)
>>> (x - x**Integer(2)).reverse(precision=Integer(3))
x + x^2 + O(x^3)

shift(k)[source]#

Returns this Laurent series multiplied by the power $$t^n$$. Does not change this series.

Note

Despite the fact that higher order terms are printed to the right in a power series, right shifting decreases the powers of $$t$$, while left shifting increases them. This is to be consistent with polynomials, integers, etc.

EXAMPLES:

sage: R.<t> = LaurentSeriesRing(QQ['y'])
sage: f = (t+t^-1)^4; f
t^-4 + 4*t^-2 + 6 + 4*t^2 + t^4
sage: f.shift(10)
t^6 + 4*t^8 + 6*t^10 + 4*t^12 + t^14
sage: f >> 10
t^-14 + 4*t^-12 + 6*t^-10 + 4*t^-8 + t^-6
sage: t << 4
t^5
sage: t + O(t^3) >> 4
t^-3 + O(t^-1)

>>> from sage.all import *
>>> R = LaurentSeriesRing(QQ['y'], names=('t',)); (t,) = R._first_ngens(1)
>>> f = (t+t**-Integer(1))**Integer(4); f
t^-4 + 4*t^-2 + 6 + 4*t^2 + t^4
>>> f.shift(Integer(10))
t^6 + 4*t^8 + 6*t^10 + 4*t^12 + t^14
>>> f >> Integer(10)
t^-14 + 4*t^-12 + 6*t^-10 + 4*t^-8 + t^-6
>>> t << Integer(4)
t^5
>>> t + O(t**Integer(3)) >> Integer(4)
t^-3 + O(t^-1)


AUTHORS:

truncate(n)[source]#

Return the Laurent series of degree  < n which is equivalent to self modulo $$x^n$$.

EXAMPLES:

sage: A.<x> = LaurentSeriesRing(ZZ)
sage: f = 1/(1-x)
sage: f
1 + x + x^2 + x^3 + x^4 + x^5 + x^6 + x^7 + x^8 + x^9 + x^10 + x^11
+ x^12 + x^13 + x^14 + x^15 + x^16 + x^17 + x^18 + x^19 + O(x^20)
sage: f.truncate(10)
1 + x + x^2 + x^3 + x^4 + x^5 + x^6 + x^7 + x^8 + x^9

>>> from sage.all import *
>>> A = LaurentSeriesRing(ZZ, names=('x',)); (x,) = A._first_ngens(1)
>>> f = Integer(1)/(Integer(1)-x)
>>> f
1 + x + x^2 + x^3 + x^4 + x^5 + x^6 + x^7 + x^8 + x^9 + x^10 + x^11
+ x^12 + x^13 + x^14 + x^15 + x^16 + x^17 + x^18 + x^19 + O(x^20)
>>> f.truncate(Integer(10))
1 + x + x^2 + x^3 + x^4 + x^5 + x^6 + x^7 + x^8 + x^9

truncate_laurentseries(n)[source]#

Replace any terms of degree >= n by big oh.

EXAMPLES:

sage: A.<x> = LaurentSeriesRing(ZZ)
sage: f = 1/(1-x)
sage: f
1 + x + x^2 + x^3 + x^4 + x^5 + x^6 + x^7 + x^8 + x^9 + x^10 + x^11
+ x^12 + x^13 + x^14 + x^15 + x^16 + x^17 + x^18 + x^19 + O(x^20)
sage: f.truncate_laurentseries(10)
1 + x + x^2 + x^3 + x^4 + x^5 + x^6 + x^7 + x^8 + x^9 + O(x^10)

>>> from sage.all import *
>>> A = LaurentSeriesRing(ZZ, names=('x',)); (x,) = A._first_ngens(1)
>>> f = Integer(1)/(Integer(1)-x)
>>> f
1 + x + x^2 + x^3 + x^4 + x^5 + x^6 + x^7 + x^8 + x^9 + x^10 + x^11
+ x^12 + x^13 + x^14 + x^15 + x^16 + x^17 + x^18 + x^19 + O(x^20)
>>> f.truncate_laurentseries(Integer(10))
1 + x + x^2 + x^3 + x^4 + x^5 + x^6 + x^7 + x^8 + x^9 + O(x^10)

truncate_neg(n)[source]#

Return the Laurent series equivalent to self except without any degree n terms.

This is equivalent to:

self - self.truncate(n)


EXAMPLES:

sage: A.<t> = LaurentSeriesRing(ZZ)
sage: f = 1/(1-t)
sage: f.truncate_neg(15)
t^15 + t^16 + t^17 + t^18 + t^19 + O(t^20)

>>> from sage.all import *
>>> A = LaurentSeriesRing(ZZ, names=('t',)); (t,) = A._first_ngens(1)
>>> f = Integer(1)/(Integer(1)-t)
>>> f.truncate_neg(Integer(15))
t^15 + t^16 + t^17 + t^18 + t^19 + O(t^20)

valuation()[source]#

EXAMPLES:

sage: R.<x> = LaurentSeriesRing(QQ)
sage: f = 1/x + x^2 + 3*x^4 + O(x^7)
sage: g = 1 - x + x^2 - x^4 + O(x^8)
sage: f.valuation()
-1
sage: g.valuation()
0

>>> from sage.all import *
>>> R = LaurentSeriesRing(QQ, names=('x',)); (x,) = R._first_ngens(1)
>>> f = Integer(1)/x + x**Integer(2) + Integer(3)*x**Integer(4) + O(x**Integer(7))
>>> g = Integer(1) - x + x**Integer(2) - x**Integer(4) + O(x**Integer(8))
>>> f.valuation()
-1
>>> g.valuation()
0


Note that the valuation of an element undistinguishable from zero is infinite:

sage: h = f - f; h
O(x^7)
sage: h.valuation()
+Infinity

>>> from sage.all import *
>>> h = f - f; h
O(x^7)
>>> h.valuation()
+Infinity

valuation_zero_part()[source]#

EXAMPLES:

sage: x = Frac(QQ[['x']]).0
sage: f = x + x^2 + 3*x^4 + O(x^7)
sage: f/x
1 + x + 3*x^3 + O(x^6)
sage: f.valuation_zero_part()
1 + x + 3*x^3 + O(x^6)
sage: g = 1/x^7 - x + x^2 - x^4 + O(x^8)
sage: g.valuation_zero_part()
1 - x^8 + x^9 - x^11 + O(x^15)

>>> from sage.all import *
>>> x = Frac(QQ[['x']]).gen(0)
>>> f = x + x**Integer(2) + Integer(3)*x**Integer(4) + O(x**Integer(7))
>>> f/x
1 + x + 3*x^3 + O(x^6)
>>> f.valuation_zero_part()
1 + x + 3*x^3 + O(x^6)
>>> g = Integer(1)/x**Integer(7) - x + x**Integer(2) - x**Integer(4) + O(x**Integer(8))
>>> g.valuation_zero_part()
1 - x^8 + x^9 - x^11 + O(x^15)

variable()[source]#

EXAMPLES:

sage: x = Frac(QQ[['x']]).0
sage: f = 1/x + x^2 + 3*x^4 + O(x^7)
sage: f.variable()
'x'

>>> from sage.all import *
>>> x = Frac(QQ[['x']]).gen(0)
>>> f = Integer(1)/x + x**Integer(2) + Integer(3)*x**Integer(4) + O(x**Integer(7))
>>> f.variable()
'x'

verschiebung(n)[source]#

Return the n-th Verschiebung of self.

If $$f = \sum a_m x^m$$ then this function returns $$\sum a_m x^{mn}$$.

EXAMPLES:

sage: R.<x> = LaurentSeriesRing(QQ)
sage: f = -1/x + 1 + 2*x^2 + 5*x^5
sage: f.V(2)
-x^-2 + 1 + 2*x^4 + 5*x^10
sage: f.V(-1)
5*x^-5 + 2*x^-2 + 1 - x
sage: h.V(2)
-x^-2 + 1 + 2*x^4 + 5*x^10 + O(x^14)
sage: h.V(-2)
Traceback (most recent call last):
...
ValueError: For finite precision only positive arguments allowed

>>> from sage.all import *
>>> R = LaurentSeriesRing(QQ, names=('x',)); (x,) = R._first_ngens(1)
>>> f = -Integer(1)/x + Integer(1) + Integer(2)*x**Integer(2) + Integer(5)*x**Integer(5)
>>> f.V(Integer(2))
-x^-2 + 1 + 2*x^4 + 5*x^10
>>> f.V(-Integer(1))
5*x^-5 + 2*x^-2 + 1 - x