Power Series Ring

This module provides tools for creating and performing arithmetic on univariate power series. It supports rings over the integer ZZ and rational QQ domains.

A power series is represented as a finite sequence of coefficients up to a specified precision. For a ring with precision \(prec\), a series is represented by its terms up to the degree prec - 1. Arithmetic operations that would result in terms of degree \(prec\) or higher are truncated, and this is denoted using the \(O(x**prec)\) notation.

A key feature of this implementation is its handling of precision. If an operation performed using two polynomials results in a polynomial whose degree is strictly less than the ring’s precision, the result is returned as an exact polynomial without any truncation. This ensures that calculations with finite polynomials are mathematically exact, preserving accuracy while leveraging the series framework.

The architecture includes two backends: a pure Python implementation and a high-performance backend using the FLINT library. The system automatically selects the FLINT backend if it is available, falling back to the Python implementation otherwise. The primary factory function, power_series_ring(), handles this selection transparently.

To create a power series ring, use the power_series_ring() function by specifying the domain, generator, and desired precision. This function returns a tuple containing a new instance of the PowerSeriesRingRing or PowerSeriesRingField class over the given domain with the chosen generator.

For example, let’s create a ring with precision 8 over the integers:

>>> from sympy.polys.series import power_series_ring
>>> from sympy import ZZ, QQ
>>> R, x = power_series_ring('x', ZZ, 8)
>>> f = 1 + 2*x + 3*x**2
>>> g = 4 + x

Arithmetic operations are performed using the ring’s methods. The print method provides a readable string representation.

>>> f + g
5 + 3*x + 3*x**2
>>> f * g
4 + 9*x + 14*x**2 + 3*x**3

As shown below, when the result of an operation is a polynomial with a degree less than the ring’s precision, the exact result is returned.

>>> p = 2 - 3*x
>>> q = 7*x + 6*x**2 + x**3
>>> p * q
14*x - 9*x**2 - 16*x**3 - 3*x**4

However, if an operation produces a result that exceeds the precision threshold, it is automatically truncated.

>>> r = 1 + 2*x + 3*x**2 + 4*x**3 + 5*x**4 + 6*x**5 + 7*x**6 + 8*x**7
>>> s = x + x**2
>>> r * s
x + 3*x**2 + 5*x**3 + 7*x**4 + 9*x**5 + 11*x**6 + 13*x**7 + O(x**8)

The power series ring also supports common mathematical functions like logarithm and trigonometric functions:

>>> R, x = power_series_ring("x", QQ, 8)
>>> R.log(1 + x)
x - 1/2*x**2 + 1/3*x**3 - 1/4*x**4 + 1/5*x**5 - 1/6*x**6 + 1/7*x**7 + O(x**8)
>>> R.tan(x)
x + 1/3*x**3 + 2/15*x**5 + 17/315*x**7 + O(x**8)

Domain for Univariate Power Series Rings

class sympy.polys.domains.powerseriesring.SeriesRingProto(
domain: Domain[Er],
symbol: str | Expr = 'x',
prec: int = 6,
)[source]

Generic protocol for power series rings.

class sympy.polys.domains.powerseriesring.PowerSeriesRing(
domain: Domain[Er],
symbol: Expr | str = 'x',
prec: int = 6,
)[source]

A Domain class for representing univariate power series rings.

Notes

This class is at experimental stage. Proper domain methods should be added to integrate with SymPy’s existing domain framework.

Univariate Power Series Ring

sympy.polys.series.ring.power_series_ring(
symbol: str,
K: Field[Ef],
prec: int = 6,
) tuple[PowerSeriesRingField[Ef], PowerSeriesElement[Ef]][source]
sympy.polys.series.ring.power_series_ring(
symbol: str,
K: Domain[Er],
prec: int = 6,
) tuple[PowerSeriesRingRing[Er], PowerSeriesElement[Er]]

Create a power series ring over the given domain.

Parameters:

symbol : str

The symbol to use for the power series variable.

K : Domain

The ground domain for the power series ring. Must be ZZ or QQ.

prec : int, optional

The default precision for power series operations. Default is 6.

Returns:

ring : PowerSeriesRing

The power series ring.

generator : PowerSeriesElement

The generator of the power series ring.

Examples

>>> from sympy import QQ
>>> from sympy.polys.series import power_series_ring
>>> R, x = power_series_ring("x", QQ)
>>> R.sin(x + x**2)
x + x**2 - 1/6*x**3 - 1/2*x**4 - 59/120*x**5 + O(x**6)
>>> R.log(1 + 7*x**2)
7*x**2 - 49/2*x**4 + O(x**6)
class sympy.polys.series.ring.PowerSeriesRingRing(
domain: Domain[Er],
symbol: str | Expr = 'x',
prec: int = 6,
)[source]

A class for representing Univariate Power Series Rings over a Ring.

compose(
s: PowerSeriesElement[Er],
t: PowerSeriesElement[Er],
) PowerSeriesElement[Er][source]

Compute the composition of two power series.

The second series must have zero constant term for valid composition.

Examples

>>> from sympy import ZZ
>>> from sympy.polys.series import PowerSeriesRingRing
>>> R = PowerSeriesRingRing(ZZ, "x", 5)
>>> x = R.gen
>>> R.compose(3 + x + 14*x**2, x**2 + x**3)
3 + x**2 + x**3 + 14*x**4 + O(x**5)
differentiate(
s: PowerSeriesElement[Er],
) PowerSeriesElement[Er][source]

Compute the derivative of a power series.

Examples

>>> from sympy import ZZ
>>> from sympy.polys.series import PowerSeriesRingRing
>>> R = PowerSeriesRingRing(ZZ, "x", 5)
>>> x = R.gen
>>> R.differentiate(10 + x + x**2 + x**3 + x**4 + R.order_term())
1 + 2*x + 3*x**2 + 4*x**3 + O(x**4)
domain_new(
arg: Er | int,
) Er[source]

Convert arg to the element of ground domain of ring.

from_element(
element: TSeriesElement[Er],
) PowerSeriesElement[Er][source]

Convert a lower power series element to a PowerSeriesElement.

from_expr(
expr: Expr,
) PowerSeriesElement[Er][source]

Convert an expression to a power series element.

Examples

>>> from sympy import ZZ
>>> from sympy.polys.series import PowerSeriesRingRing
>>> R = PowerSeriesRingRing(ZZ, "x", 5)
>>> from sympy.abc import x
>>> s = R.from_expr(x + x**2 + x**4 + x**7); s
x + x**2 + x**4 + O(x**5)
>>> type(s)
<class 'sympy.polys.series.ring.PowerSeriesElement'>
from_ground(
arg: Er,
) PowerSeriesElement[Er][source]

Convert a ground element to a power series element.

from_int(
arg: int,
) PowerSeriesElement[Er][source]

Convert an integer to a power series element.

from_list(
lst: list[Er],
prec: int | None = None,
) PowerSeriesElement[Er][source]

Create a power series element from a list of coefficients.

inverse(
s: PowerSeriesElement[Er],
) PowerSeriesElement[Er][source]

Compute the multiplicative inverse of a power series.

The constant term must be a unit in the ground domain for valid multiplicative inverse.

Examples

>>> from sympy import ZZ
>>> from sympy.polys.series import PowerSeriesRingRing
>>> R = PowerSeriesRingRing(ZZ, "x", 5)
>>> x = R.gen
>>> R.inverse(1 + x)
1 - x + x**2 - x**3 + x**4 + O(x**5)
is_element(
element: object,
) TypeIs[PowerSeriesElement[Er]][source]

Check if element belongs to this ring.

order_term()[source]

Return the order term of the power series.

Examples

>>> from sympy import ZZ
>>> from sympy.polys.series import PowerSeriesRingRing
>>> R = PowerSeriesRingRing(ZZ, "x")
>>> R.order_term()
O(x**6)
>>> R10 = PowerSeriesRingRing(ZZ, "x", 10)
>>> R10.order_term()
O(x**10)
reversion(
s: PowerSeriesElement[Er],
) PowerSeriesElement[Er][source]

Compute the compositional inverse of a power series.

The constant term must be zero and the linear term must be a unit in the ground domain for valid compositional inverse.

Examples

>>> from sympy import ZZ
>>> from sympy.polys.series import PowerSeriesRingRing
>>> R = PowerSeriesRingRing(ZZ, "x", 5)
>>> x = R.gen
>>> R.reversion(x + 4*x**2 + 8*x**3)
x - 4*x**2 + 24*x**3 - 160*x**4 + O(x**5)
ring_new(
arg: Expr | Er | int,
) PowerSeriesElement[Er][source]

Create a power series element from various types.

square(
s: PowerSeriesElement[Er],
) PowerSeriesElement[Er][source]

Compute the square of a power series.

Examples

>>> from sympy import ZZ
>>> from sympy.polys.series import PowerSeriesRingRing
>>> R = PowerSeriesRingRing(ZZ, "x", 5)
>>> x = R.gen
>>> R.square(1 + x + x**2)
1 + 2*x + 3*x**2 + 2*x**3 + x**4
to_dense(
element: PowerSeriesElement[Er],
) dup[Er][source]

Returns a dense list coefficients of a power series.

to_expr(
element: PowerSeriesElement[Er],
) Expr[source]

Convert a power series element to an expression.

to_list(
element: PowerSeriesElement[Er],
) list[Er][source]

Returns a list of coefficients of a power series.

truncate(
s: PowerSeriesElement[Er],
prec: int,
) PowerSeriesElement[Er][source]

Truncate the power series to the given precision.

class sympy.polys.series.ring.PowerSeriesRingField(
domain: Domain[Ef],
symbol: str | Expr = 'x',
prec: int = 6,
)[source]

A class for representing Univariate Power Series Rings over a Field.

asin(
s: PowerSeriesElement[Ef],
) PowerSeriesElement[Ef][source]

Compute the arcsine of a power series.

The constant term should be zero for proper expansion in the Rational Field.

Examples

>>> from sympy import QQ
>>> from sympy.polys.series import PowerSeriesRingField
>>> R = PowerSeriesRingField(QQ, "x")
>>> x = R.gen
>>> R.asin(x)
x + 1/6*x**3 + 3/40*x**5 + O(x**6)
asinh(
s: PowerSeriesElement[Ef],
) PowerSeriesElement[Ef][source]

Compute the hyperbolic arcsine of a power series.

The constant term should be zero for proper expansion in the Rational Field.

Examples

>>> from sympy import QQ
>>> from sympy.polys.series import PowerSeriesRingField
>>> R = PowerSeriesRingField(QQ, "x")
>>> x = R.gen
>>> R.asinh(x)
x - 1/6*x**3 + 3/40*x**5 + O(x**6)
atan(
s: PowerSeriesElement[Ef],
) PowerSeriesElement[Ef][source]

Compute the arctangent of a power series.

The constant term should be zero for proper expansion in the Rational Field.

Examples

>>> from sympy import QQ
>>> from sympy.polys.series import PowerSeriesRingField
>>> R = PowerSeriesRingField(QQ, "x")
>>> x = R.gen
>>> R.atan(x)
x - 1/3*x**3 + 1/5*x**5 + O(x**6)
atanh(
s: PowerSeriesElement[Ef],
) PowerSeriesElement[Ef][source]

Compute the hyperbolic arctangent of a power series.

The constant term should be zero for proper expansion in the Rational Field.

Examples

>>> from sympy import QQ
>>> from sympy.polys.series import PowerSeriesRingField
>>> R = PowerSeriesRingField(QQ, "x")
>>> x = R.gen
>>> R.atanh(x)
x + 1/3*x**3 + 1/5*x**5 + O(x**6)
cos(
s: PowerSeriesElement[Ef],
) PowerSeriesElement[Ef][source]

Compute the cosine of a power series.

The constant term should be zero for proper expansion in the Rational Field.

Examples

>>> from sympy import QQ
>>> from sympy.polys.series import PowerSeriesRingField
>>> R = PowerSeriesRingField(QQ, "x")
>>> x = R.gen
>>> R.cos(x)
1 - 1/2*x**2 + 1/24*x**4 + O(x**6)
cosh(
s: PowerSeriesElement[Ef],
) PowerSeriesElement[Ef][source]

Compute the hyperbolic cosine of a power series.

The constant term should be zero for proper expansion in the Rational Field.

Examples

>>> from sympy import QQ
>>> from sympy.polys.series import PowerSeriesRingField
>>> R = PowerSeriesRingField(QQ, "x")
>>> x = R.gen
>>> R.cosh(x)
1 + 1/2*x**2 + 1/24*x**4 + O(x**6)
exp(
s: PowerSeriesElement[Ef],
) PowerSeriesElement[Ef][source]

Compute the exponential of a power series.

The constant term should be zero for proper expansion in the Rational Field.

Examples

>>> from sympy import QQ
>>> from sympy.polys.series import PowerSeriesRingField
>>> R = PowerSeriesRingField(QQ, "x")
>>> x = R.gen
>>> R.exp(x)
1 + x + 1/2*x**2 + 1/6*x**3 + 1/24*x**4 + 1/120*x**5 + O(x**6)
expm1(
s: PowerSeriesElement[Ef],
) PowerSeriesElement[Ef][source]

Compute the exponential of a power series minus one.

The constant term should be zero for proper expansion in the Rational Field.

Examples

>>> from sympy import QQ
>>> from sympy.polys.series import PowerSeriesRingField
>>> R = PowerSeriesRingField(QQ, "x")
>>> x = R.gen
>>> R.expm1(x)
x + 1/2*x**2 + 1/6*x**3 + 1/24*x**4 + 1/120*x**5 + O(x**6)
integrate(
s: PowerSeriesElement[Ef],
) PowerSeriesElement[Ef][source]

Compute the integral of a power series.

Examples

>>> from sympy import QQ
>>> from sympy.polys.series import PowerSeriesRingField
>>> R = PowerSeriesRingField(QQ, "x")
>>> x = R.gen
>>> R.integrate(1 + x + x**2 + x**3 + x**4 + x**5 + R.order_term())
x + 1/2*x**2 + 1/3*x**3 + 1/4*x**4 + 1/5*x**5 + O(x**6)
log(
s: PowerSeriesElement[Ef],
) PowerSeriesElement[Ef][source]

Compute the logarithm of a power series.

The constant term should be one for proper expansion in the Rational Field.

Examples

>>> from sympy import QQ
>>> from sympy.polys.series import PowerSeriesRingField
>>> R = PowerSeriesRingField(QQ, "x")
>>> x = R.gen
>>> R.log(1 + x)
x - 1/2*x**2 + 1/3*x**3 - 1/4*x**4 + 1/5*x**5 + O(x**6)
log1p(
s: PowerSeriesElement[Ef],
) PowerSeriesElement[Ef][source]

Compute the logarithm of a power series plus one.

The constant term should be zero for proper expansion in the Rational Field.

Examples

>>> from sympy import QQ
>>> from sympy.polys.series import PowerSeriesRingField
>>> R = PowerSeriesRingField(QQ, "x")
>>> x = R.gen
>>> R.log1p(x)
x - 1/2*x**2 + 1/3*x**3 - 1/4*x**4 + 1/5*x**5 + O(x**6)
sin(
s: PowerSeriesElement[Ef],
) PowerSeriesElement[Ef][source]

Compute the sine of a power series.

The constant term should be zero for proper expansion in the Rational Field.

Examples

>>> from sympy import QQ
>>> from sympy.polys.series import PowerSeriesRingField
>>> R = PowerSeriesRingField(QQ, "x")
>>> x = R.gen
>>> R.sin(x)
x - 1/6*x**3 + 1/120*x**5 + O(x**6)
sinh(
s: PowerSeriesElement[Ef],
) PowerSeriesElement[Ef][source]

Compute the hyperbolic sine of a power series.

The constant term should be zero for proper expansion in the Rational Field.

Examples

>>> from sympy import QQ
>>> from sympy.polys.series import PowerSeriesRingField
>>> R = PowerSeriesRingField(QQ, "x")
>>> x = R.gen
>>> R.sinh(x)
x + 1/6*x**3 + 1/120*x**5 + O(x**6)
sqrt(
s: PowerSeriesElement[Ef],
) PowerSeriesElement[Ef][source]

Compute the square root of a power series.

Examples

>>> from sympy import QQ
>>> from sympy.polys.series import PowerSeriesRingField
>>> R = PowerSeriesRingField(QQ, "x")
>>> x = R.gen
>>> R.sqrt(1 + 2*x + 4*x**2 + 8*x**3)
1 + x + 3/2*x**2 + 5/2*x**3 - 29/8*x**4 - 1/8*x**5 + O(x**6)
tan(
s: PowerSeriesElement[Ef],
) PowerSeriesElement[Ef][source]

Compute the tangent of a power series.

The constant term should be zero for proper expansion in the Rational Field.

Examples

>>> from sympy import QQ
>>> from sympy.polys.series import PowerSeriesRingField
>>> R = PowerSeriesRingField(QQ, "x")
>>> x = R.gen
>>> R.tan(x)
x + 1/3*x**3 + 2/15*x**5 + O(x**6)
tanh(
s: PowerSeriesElement[Ef],
) PowerSeriesElement[Ef][source]

Compute the hyperbolic tangent of a power series.

The constant term should be zero for proper expansion in the Rational Field.

Examples

>>> from sympy import QQ
>>> from sympy.polys.series import PowerSeriesRingField
>>> R = PowerSeriesRingField(QQ, "x")
>>> x = R.gen
>>> R.tanh(x)
x - 1/3*x**3 + 2/15*x**5 + O(x**6)
class sympy.polys.series.ring.PowerSeriesElement(
ring: PowerSeriesRingRing[Er],
series: TSeriesElement[Er],
)[source]

A class for representing elements of a Power Series.

constant_coefficient() Er[source]

Return the constant coefficient of the series.

property is_ground: bool | None

Check if the series is a ground element.

removeO() PowerSeriesElement[Er][source]

Remove the big O notation from the series.

Protocols for Power Series Rings

class sympy.polys.series.base.PowerSeriesRingProto(prec: int = 6, /)[source]

A protocol for a power series ring.

class sympy.polys.series.base.PowerSeriesRingFieldProto(prec: int = 6, /)[source]

A protocol for a power series ring over a field.

class sympy.polys.series.base.TSeries
class sympy.polys.series.tring.TSeriesElement

Python Implementation

class sympy.polys.series.ringpython.PythonPowerSeriesRingZZ(prec: int = 6)[source]

Python implementation of power series ring over integers ZZ.

This class provides comprehensive power series operations over the integer ring, supporting both series manipulations with precision handling and truncation.

Parameters:

prec : int, optional

The default precision for power series operations. Default is 6.

Examples

>>> from sympy.polys.series.ringpython import PythonPowerSeriesRingZZ
>>> R = PythonPowerSeriesRingZZ()
>>> s = R([1, 2, 3])  # 1 + 2*x + 3*x^2
>>> R.print(s)
1 + 2*x + 3*x**2
>>> s_pow = R.pow_int(s, 2)  # Square the series
>>> R.print(s_pow)
1 + 4*x + 10*x**2 + 12*x**3 + 9*x**4
>>> s_inv = R.inverse(R([1, 1]))  # Inverse of 1 + x
>>> R.print(s_inv)
1 - x + x**2 - x**3 + x**4 - x**5 + O(x**6)

Note

The recommended way to create a power series ring is using the factory function which returns a new instance of the higher level PowerSeriesRing class with the ring generator:

>>> from sympy.polys.series import power_series_ring
>>> from sympy import ZZ
>>> R, x = power_series_ring("x", ZZ, 6)
>>> R
Power Series Ring in x over ZZ of size 6
>>> type(x)
<class 'sympy.polys.series.ring.PowerSeriesElement'>

This function automatically uses the Flint implementation if available for better performance, falling back to the Python implementation otherwise.

add(
s1: USeries[MPZ],
s2: USeries[MPZ],
) USeries[MPZ][source]

Add two power series.

add_ground(
s: USeries[MPZ],
n: MPZ,
) USeries[MPZ][source]

Add a ground element to a power series.

compose(
s1: USeries[MPZ],
s2: USeries[MPZ],
) USeries[MPZ][source]

Compose two power series, \(s1(s2)\).

constant_coefficient(
s: USeries[MPZ],
) MPZ[source]

Return the constant coefficient of a power series.

differentiate(
s: USeries[MPZ],
) USeries[MPZ][source]

Compute the derivative of a power series.

divide(
s1: USeries[MPZ],
s2: USeries[MPZ],
) USeries[MPZ][source]

Divide two power series.

property domain: Domain[int]

Return the ground domain of the power series ring.

equal(
s1: USeries[MPZ],
s2: USeries[MPZ],
) bool | None[source]

Check if two power series are equal up to their minimum precision.

equal_repr(
s1: USeries[MPZ],
s2: USeries[MPZ],
) bool[source]

Check if two power series have the same representation.

from_list(
coeffs: list[MPZ],
prec: int | None = None,
) USeries[MPZ][source]

Create a power series from a list of ground coefficients.

If \(prec\) is not specified, it defaults to the ring’s precision.

inverse(
s: USeries[MPZ],
) USeries[MPZ][source]

Compute the multiplicative inverse of a power series.

is_ground(
arg: USeries[MPZ],
) bool | None[source]

Check if a arg is a ground element of the power series ring.

multiply(
s1: USeries[MPZ],
s2: USeries[MPZ],
) USeries[MPZ][source]

Multiply two power series.

multiply_ground(
s: USeries[MPZ],
n: MPZ,
) USeries[MPZ][source]

Multiply a power series by a ground element.

negative(
s: USeries[MPZ],
) USeries[MPZ][source]

Return the unary negative of a power series.

positive(
s: USeries[MPZ],
) USeries[MPZ][source]

Return the unary positive of a power series, adjusted to the ring’s precision.

pow_int(
s: USeries[MPZ],
n: int,
) USeries[MPZ][source]

Raise a power series to a integer power.

property prec: int

Return the ring’s precision.

pretty(
s: USeries[MPZ],
*,
symbol: str = 'x',
ascending: bool = True,
) str[source]

Return a pretty-printed string representation of a power series.

print(
s: USeries[MPZ],
*,
symbol: str = 'x',
ascending: bool = True,
) None[source]

Print a pretty-printed representation of a power series.

reversion(
s: USeries[MPZ],
) USeries[MPZ][source]

Compute the compositional inverse of a power series.

rsubtract_ground(
s: USeries[MPZ],
n: MPZ,
) USeries[MPZ][source]

Subtract a power series from a ground element.

series_prec(
s: USeries[MPZ],
) int | None[source]

Return the precision of a power series.

square(
s: USeries[MPZ],
) USeries[MPZ][source]

Compute the square of a power series.

subtract(
s1: USeries[MPZ],
s2: USeries[MPZ],
) USeries[MPZ][source]

Subtract two power series.

subtract_ground(
s: USeries[MPZ],
n: MPZ,
) USeries[MPZ][source]

Subtract a ground element from a power series.

to_dense(
s: USeries[MPZ],
) dup[MPZ][source]

Return the coefficients of a power series as a dense list.

to_list(
s: USeries[MPZ],
) list[MPZ][source]

Returns the list of series coefficients.

truncate(
s: USeries[MPZ],
n: int,
) USeries[MPZ][source]

Truncate a power series to \(n\) terms.

class sympy.polys.series.ringpython.PythonPowerSeriesRingQQ(prec: int = 6)[source]

Python implementation of power series ring over rational field QQ.

This class provides comprehensive power series operations over the rational field, supporting series manipulations with precision handling and truncation. It extends the integer ring functionality with support for rational coefficients and integration.

Parameters:

prec : int, optional

The default precision for power series operations. Default is 6.

Examples

>>> from sympy.polys.series.ringpython import PythonPowerSeriesRingQQ
>>> R = PythonPowerSeriesRingQQ()
>>> s = R([1, (1, 2), (1, 3)])  # 1 + x/2 + x^2/3
>>> R.print(s)
1 + 1/2*x + 1/3*x**2
>>> s_int = R.integrate(s)  # Integration
>>> R.print(s_int)
x + 1/4*x**2 + 1/9*x**3
>>> s_inv = R.inverse(R([1, (1, 2)]))  # Inverse of 1 + x/2
>>> R.print(s_inv)
1 - 1/2*x + 1/4*x**2 - 1/8*x**3 + 1/16*x**4 - 1/32*x**5 + O(x**6)

Note

The recommended way to create a power series ring is using the factory function which returns a new instance of the higher level PowerSeriesRing class with the ring generator:

>>> from sympy.polys.series import power_series_ring
>>> from sympy import QQ
>>> R, x = power_series_ring("x", QQ, 6)
>>> R
Power Series Ring in x over QQ of size 6
>>> type(x)
<class 'sympy.polys.series.ring.PowerSeriesElement'>

This function automatically uses the Flint implementation if available for better performance, falling back to the Python implementation otherwise.

add(
s1: USeries[MPQ],
s2: USeries[MPQ],
) USeries[MPQ][source]

Add two power series.

add_ground(
s: USeries[MPQ],
n: MPQ,
) USeries[MPQ][source]

Add a ground element to a power series.

asin(
s: USeries[MPQ],
) USeries[MPQ][source]

Compute the arcsine of a power series.

asinh(
s: USeries[MPQ],
) USeries[MPQ][source]

Compute the hyperbolic arcsine of a power series.

atan(
s: USeries[MPQ],
) USeries[MPQ][source]

Compute the arctangent of a power series.

atanh(
s: USeries[MPQ],
) USeries[MPQ][source]

Compute the hyperbolic arctangent of a power series.

compose(
s1: USeries[MPQ],
s2: USeries[MPQ],
) USeries[MPQ][source]

Compose two power series, \(s1(s2)\).

constant_coefficient(
s: USeries[MPQ],
) MPQ[source]

Return the constant coefficient of a power series.

cos(
s: USeries[MPQ],
) USeries[MPQ][source]

Compute the cosine of a power series.

cosh(
s: USeries[MPQ],
) USeries[MPQ][source]

Compute the hyperbolic cosine of a power series.

differentiate(
s: USeries[MPQ],
) USeries[MPQ][source]

Compute the derivative of a power series.

divide(
s1: USeries[MPQ],
s2: USeries[MPQ],
) USeries[MPQ][source]

Divide two power series.

property domain: Domain[PythonMPQ]

Return the ground domain of the power series ring.

equal(
s1: USeries[MPQ],
s2: USeries[MPQ],
) bool | None[source]

Check if two power series are equal up to their minimum precision.

equal_repr(
s1: USeries[MPQ],
s2: USeries[MPQ],
) bool[source]

Check if two power series have the same representation.

exp(
s: USeries[MPQ],
) USeries[MPQ][source]

Compute the exponential of a power series.

expm1(
s: USeries[MPQ],
) USeries[MPQ][source]

Compute the exponential of a power series minus 1.

from_list(
coeffs: list[MPQ],
prec: int | None = None,
) USeries[MPQ][source]

Create a power series from a list of ground coefficients.

If \(prec\) is not specified, it defaults to the ring’s precision.

hypot(
s1: USeries[MPQ],
s2: USeries[MPQ],
) USeries[MPQ][source]

Compute the hypotenuse of two power series.

integrate(
s: USeries[MPQ],
) USeries[MPQ][source]

Compute the integral of a power series.

inverse(
s: USeries[MPQ],
) USeries[MPQ][source]

Compute the multiplicative inverse of a power series.

is_ground(
arg: USeries[MPQ],
) bool | None[source]

Check if a arg is a ground element of the power series ring.

log(
s: USeries[MPQ],
) USeries[MPQ][source]

Compute the logarithm of a power series.

log1p(
s: USeries[MPQ],
) USeries[MPQ][source]

Compute the logarithm of (1 + x) for a power series.

multiply(
s1: USeries[MPQ],
s2: USeries[MPQ],
) USeries[MPQ][source]

Multiply two power series.

multiply_ground(
s: USeries[MPQ],
n: MPQ,
) USeries[MPQ][source]

Multiply a power series by a ground element.

negative(
s: USeries[MPQ],
) USeries[MPQ][source]

Return the unary negative of a power series.

positive(
s: USeries[MPQ],
) USeries[MPQ][source]

Return the unary positive of a power series, adjusted to the ring’s precision.

pow_int(
s: USeries[MPQ],
n: int,
) USeries[MPQ][source]

Raise a power series to a integer power.

property prec: int

Return the ring’s precision.

pretty(
s: USeries[MPQ],
*,
symbol: str = 'x',
ascending: bool = True,
) str[source]

Return a pretty-printed string representation of a power series.

print(
s: USeries[MPQ],
*,
symbol: str = 'x',
ascending: bool = True,
) None[source]

Print a pretty-printed representation of a power series.

reversion(
s: USeries[MPQ],
) USeries[MPQ][source]

Compute the compositional inverse of a power series.

rsubtract_ground(
s: USeries[MPQ],
n: MPQ,
) USeries[MPQ][source]

Subtract a power series from a ground element.

series_prec(
s: USeries[MPQ],
) int | None[source]

Return the precision of a power series.

sin(
s: USeries[MPQ],
) USeries[MPQ][source]

Compute the sine of a power series.

sinh(
s: USeries[MPQ],
) USeries[MPQ][source]

Compute the hyperbolic sine of a power series.

sqrt(
s: USeries[MPQ],
) USeries[MPQ][source]

Compute the sqrt of a power series.

square(
s: USeries[MPQ],
) USeries[MPQ][source]

Compute the square of a power series.

subtract(
s1: USeries[MPQ],
s2: USeries[MPQ],
) USeries[MPQ][source]

Subtract two power series.

subtract_ground(
s: USeries[MPQ],
n: MPQ,
) USeries[MPQ][source]

Subtract a ground element from a power series.

tan(
s: USeries[MPQ],
) USeries[MPQ][source]

Compute the tangent of a power series.

tanh(
s: USeries[MPQ],
) USeries[MPQ][source]

Compute the hyperbolic tangent of a power series.

to_dense(
s: USeries[MPQ],
) dup[MPQ][source]

Return the coefficients of a power series as a dense list.

to_list(
s: USeries[MPQ],
) list[MPQ][source]

Return the list of series coefficients.

truncate(
s: USeries[MPQ],
n: int,
) USeries[MPQ][source]

Truncate a power series to \(n\) terms.

class sympy.polys.series.ringpython.USeries

Flint Implementation

class sympy.polys.series.ringflint.FlintPowerSeriesRingZZ(prec: int = 6)[source]

Flint implementation of power series ring over integers ZZ.

This class provides high-performance power series operations over the integer ring, leveraging the FLINT library for optimized arithmetic and series manipulations precision handling and truncation.

Parameters:

prec : int, optional

The default precision for power series operations. Default is 6.

Examples

>>> from sympy.polys.series.ringflint import FlintPowerSeriesRingZZ
>>> R = FlintPowerSeriesRingZZ()
>>> s = R([1, 2, 3])  # 1 + 2*x + 3*x^2
>>> R.print(s)
1 + 2*x + 3*x**2
>>> s_pow = R.pow_int(s, 2)  # Square the series
>>> R.print(s_pow)
1 + 4*x + 10*x**2 + 12*x**3 + 9*x**4
>>> s_inv = R.inverse(R([1, 1]))  # Inverse of 1 + x
>>> R.print(s_inv)
1 - x + x**2 - x**3 + x**4 - x**5 + O(x**6)

Note

The recommended way to create a power series ring is using the factory function which returns a new instance of the higher level PowerSeriesRing class with the ring generator:

>>> from sympy.polys.series import power_series_ring
>>> from sympy.polys.domains import ZZ
>>> R, x = power_series_ring("x", ZZ, 6)
>>> R
Power Series Ring in x over ZZ of size 6
>>> type(x)
<class 'sympy.polys.series.ring.PowerSeriesElement'>

This function automatically uses the Flint implementation if available for better performance, falling back to the Python implementation otherwise.

add(
s1: None,
s2: None,
) None[source]

Add two power series.

add_ground(
s: None,
n: int,
) None[source]

Add a ground element to a power series.

compose(
s1: None,
s2: None,
) None[source]

Compose two power series, \(s1(s2)\).

constant_coefficient(
s: None,
) int[source]

Return the constant coefficient of a power series.

differentiate(
s: None,
) None[source]

Compute the derivative of a power series.

divide(
s1: None,
s2: None,
) None[source]

Divide two power series.

property domain: Domain[int]

Return the ground domain of the power series ring.

equal(
s1: None,
s2: None,
) bool | None[source]

Check if two power series are equal up to their minimum precision.

equal_repr(
s1: None,
s2: None,
) bool[source]

Check if two power series have the same representation.

from_list(
coeffs: list[int],
prec: int | None = None,
) None[source]

Create a power series from a list of ground coefficients.

If \(prec\) is not specified, it defaults to the ring’s precision.

inverse(s: None) None[source]

Compute the multiplicative inverse of a power series.

is_ground(
arg: None,
) bool | None[source]

Check if a arg is a ground element of the power series ring.

multiply(
s1: None,
s2: None,
) None[source]

Multiply two power series.

multiply_ground(
s: None,
n: int,
) None[source]

Multiply a power series by a ground element.

negative(s: None) None[source]

Return the unary negative of a power series.

positive(s: None) None[source]

Return the unary positive of a power series, adjusted to the ring’s precision.

pow_int(
s: None,
n: int,
) None[source]

Raise a power series to a integer power.

property prec: int

Return the ring’s precision.

pretty(
s: None,
*,
symbol: str = 'x',
ascending: bool = True,
) str[source]

Return a pretty-printed string representation of a power series.

print(
s: None,
*,
symbol: str = 'x',
ascending: bool = True,
) None[source]

Print a pretty-printed representation of a power series.

reversion(s: None) None[source]

Compute the compositional inverse of a power series.

rsubtract_ground(
s: None,
n: int,
) None[source]

Subtract a power series from a ground element.

series_prec(
s: None,
) int | None[source]

Return the precision of the series.

square(s: None) None[source]

Compute the square of a power series.

subtract(
s1: None,
s2: None,
) None[source]

Subtract two power series.

subtract_ground(
s: None,
n: int,
) None[source]

Subtract a ground element from a power series.

to_dense(
s: ZZSeries,
) dup[MPZ][source]

Return the coefficients of a power series as a dense list.

to_list(
s: None,
) list[int][source]

Returns the list of series coefficients.

truncate(
s: None,
n: int,
) None[source]

Truncate a power series to \(n\) terms.

class sympy.polys.series.ringflint.FlintPowerSeriesRingQQ(prec: int = 6)[source]

Flint implementation of power series ring over rational field QQ.

This class provides high-performance power series operations over the rational field, leveraging the FLINT library for optimized arithmetic and series manipulations with precision handling and truncation. It extends the integer ring functionality with support for rational coefficients and integration.

Parameters:

prec : int, optional

The default precision for power series operations. Default is 6.

Examples

>>> from sympy.polys.series.ringflint import FlintPowerSeriesRingQQ
>>> R = FlintPowerSeriesRingQQ()
>>> s = R([1, (1, 2), (1, 3)])  # 1 + x/2 + x^2/3
>>> R.print(s)
1 + 1/2*x + 1/3*x**2
>>> s_int = R.integrate(s)  # Integration
>>> R.print(s_int)
x + 1/4*x**2 + 1/9*x**3
>>> s_inv = R.inverse(R([1, (1, 2)]))  # Inverse of 1 + x/2
>>> R.print(s_inv)
1 - 1/2*x + 1/4*x**2 - 1/8*x**3 + 1/16*x**4 - 1/32*x**5 + O(x**6)

Note

The recommended way to create a power series ring is using the factory function which returns a new instance of the higher level PowerSeriesRing class with the ring generator:

>>> from sympy.polys.series import power_series_ring
>>> from sympy.polys.domains import QQ
>>> R, x = power_series_ring("x", QQ, 6)
>>> R
Power Series Ring in x over QQ of size 6
>>> type(x)
<class 'sympy.polys.series.ring.PowerSeriesElement'>

This function automatically uses the Flint implementation if available for better performance, falling back to the Python implementation otherwise.

add(
s1: None,
s2: None,
) None[source]

Add two power series.

add_ground(
s: None,
n: PythonMPQ,
) None[source]

Add a ground element to a power series.

asin(s: None) None[source]

Compute the arcsine of a power series.

asinh(s: None) None[source]

Compute the hyperbolic arcsine of a power series.

atan(s: None) None[source]

Compute the arctangent of a power series.

atanh(s: None) None[source]

Compute the hyperbolic arctangent of a power series.

compose(
s1: None,
s2: None,
) None[source]

Compose two power series, \(s1(s2)\).

constant_coefficient(
s: None,
) PythonMPQ[source]

Return the constant coefficient of a power series.

cos(s: None) None[source]

Compute the cosine of a power series.

cosh(s: None) None[source]

Compute the hyperbolic cosine of a power series.

differentiate(
s: None,
) None[source]

Compute the derivative of a power series.

divide(
s1: None,
s2: None,
) None[source]

Divide two power series.

property domain: Domain[PythonMPQ]

Return the ground domain of the power series ring.

equal(
s1: None,
s2: None,
) bool | None[source]

Check if two power series are equal up to their minimum precision.

equal_repr(
s1: None,
s2: None,
) bool[source]

Check if two power series have the same representation.

exp(s: None) None[source]

Compute the exponential of a power series.

expm1(s: None) None[source]

Compute the exponential of a power series minus 1.

from_list(
coeffs: list[PythonMPQ],
prec: int | None = None,
) None[source]

Create a power series from a list of ground coefficients.

If \(prec\) is not specified, it defaults to the ring’s precision.

hypot(
s1: None,
s2: None,
) None[source]

Compute the hypotenuse of two power series.

integrate(s: None) None[source]

Compute the integral of a power series.

inverse(s: None) None[source]

Compute the multiplicative inverse of a power series.

is_ground(
arg: None,
) bool | None[source]

Check if a arg is a ground element of the power series ring.

log(s: None) None[source]

Compute the logarithm of a power series.

log1p(s: None) None[source]

Compute the logarithm of (1 + s) for a power series with zero constant term.

multiply(
s1: None,
s2: None,
) None[source]

Multiply two power series.

multiply_ground(
s: None,
n: PythonMPQ,
) None[source]

Multiply a power series by a ground element.

negative(s: None) None[source]

Return the unary negative of a power series.

positive(s: None) None[source]

Return the unary positive of a power series, adjusted to the ring’s precision.

pow_int(
s: None,
n: int,
) None[source]

Raise a power series to a integer power.

property prec: int

Return the ring’s precision.

pretty(
s: None,
*,
symbol: str = 'x',
ascending: bool = True,
) str[source]

Return a pretty-printed string representation of a power series.

print(
s: None,
*,
symbol: str = 'x',
ascending: bool = True,
) None[source]

Print a pretty-printed representation of a power series.

reversion(s: None) None[source]

Compute the compositional inverse of a power series.

rsubtract_ground(
s: None,
n: PythonMPQ,
) None[source]

Subtract a power series from a ground element.

series_prec(
s: None,
) int | None[source]

Return the precision of the series.

sin(s: None) None[source]

Compute the sine of a power series.

sinh(s: None) None[source]

Compute the hyperbolic sine of a power series.

sqrt(s: None) None[source]

Compute the square root of a power series.

square(s: None) None[source]

Compute the square of a power series.

subtract(
s1: None,
s2: None,
) None[source]

Subtract two power series.

subtract_ground(
s: None,
n: PythonMPQ,
) None[source]

Subtract a ground element from a power series.

tan(s: None) None[source]

Compute the tangent of a power series.

tanh(s: None) None[source]

Compute the hyperbolic tangent of a power series.

to_dense(
s: QQSeries,
) dup[MPQ][source]

Return the coefficients of a power series as a dense list.

to_list(
s: None,
) list[PythonMPQ][source]

Returns the list of series coefficients.

truncate(
s: None,
n: int,
) None[source]

Truncate a power series to \(n\) terms.

class sympy.polys.series.ringflint.ZZSeries
class sympy.polys.series.ringflint.QQSeries
class flint.types.fmpz_poly.fmpz_poly
class flint.types.fmpq_poly.fmpq_poly
class flint.types.fmpz_series.fmpz_series
class flint.types.fmpq_series.fmpq_series