Series
Series
Series()A series expansion class.
Supports standard arithmetic operations, such as addition and multiplication.
Examples
x = S('x')
s = E("(1-cos(x))/sin(x)").series(x, 0, 4) * x
print(s)Methods
| Name | Description |
|---|---|
__add__ |
Add another series or expression to this series, returning the result. |
__getitem__ |
Get the coefficient of the term with exponent exp. |
__iter__ |
Iterate over the terms of the series, yielding pairs of exponent and coefficient. |
__mul__ |
Multiply another series or expression to this series, returning the result. |
__neg__ |
Negate the series. |
__pow__ |
Raise the series to the power of exp, returning the result. |
__radd__ |
Add two series together, returning the result. |
__rmul__ |
Multiply two series together, returning the result. |
__rsub__ |
Subtract self from other, returning the result. |
__rtruediv__ |
Divide other by self, returning the result. |
__str__ |
Print the series in a human-readable format. |
__sub__ |
Subtract other from self, returning the result. |
__truediv__ |
Divide self by other, returning the result. |
cos |
Compute the cosine of the series, returning the result. |
exp |
Compute the exponential of the series, returning the result. |
format |
Convert the series into a human-readable string. |
get_absolute_order |
Get the absolute order. |
get_coefficient |
Get the coefficient of the term with exponent exp |
get_ramification |
Get the ramification. |
get_relative_order |
Get the relative order. |
get_trailing_exponent |
Get the trailing exponent; the exponent of the first non-zero term. |
log |
Compute the natural logarithm of the series, returning the result. |
pow |
Raise the series to the power of num/den, returning the result. |
shift |
Shift the series by e units of the ramification. |
sin |
Compute the sine of the series, returning the result. |
spow |
Raise the series to the power of exp, returning the result. |
to_expression |
Convert the series to an expression. |
to_latex |
Convert the series into a LaTeX string. |
__add__
Series.__add__(other: Series | Expression) -> SeriesAdd another series or expression to this series, returning the result.
Parameters
other(Series | Expression) The other operand to combine or compare with.
__getitem__
Series.__getitem__(expr: Expression | int) -> ExpressionGet the coefficient of the term with exponent exp
Parameters
expr(Expression | int) The expression to operate on.
__iter__
Series.__iter__() -> Iterator[tuple[Expression, Expression]]Iterate over the terms of the series, yielding pairs of exponent and coefficient.
__mul__
Series.__mul__(other: Series | Expression) -> SeriesMultiply another series or expression to this series, returning the result.
Parameters
other(Series | Expression) The other operand to combine or compare with.
__neg__
Series.__neg__() -> SeriesNegate the series.
__pow__
Series.__pow__(exp: int) -> SeriesRaise the series to the power of exp, returning the result.
Parameters
exp(int) The exponent.
__radd__
Series.__radd__(other: Expression) -> SeriesAdd two series together, returning the result.
Parameters
other(Expression) The other operand to combine or compare with.
__rmul__
Series.__rmul__(other: Expression) -> SeriesMultiply two series together, returning the result.
Parameters
other(Expression) The other operand to combine or compare with.
__rsub__
Series.__rsub__(other: Expression) -> SeriesSubtract self from other, returning the result.
Parameters
other(Expression) The other operand to combine or compare with.
__rtruediv__
Series.__rtruediv__(other: Expression) -> SeriesDivide other by self, returning the result.
Parameters
other(Expression) The other operand to combine or compare with.
__str__
Series.__str__() -> strPrint the series in a human-readable format.
__sub__
Series.__sub__(other: Series | Expression) -> SeriesSubtract other from self, returning the result.
Parameters
other(Series | Expression) The other operand to combine or compare with.
__truediv__
Series.__truediv__(other: Series | Expression) -> SeriesDivide self by other, returning the result.
Parameters
other(Series | Expression) The other operand to combine or compare with.
cos
Series.cos() -> SeriesCompute the cosine of the series, returning the result.
exp
Series.exp() -> SeriesCompute the exponential of the series, returning the result.
format
Series.format(
mode: PrintMode = PrintMode.Symbolica,
max_line_length: int | None = 80,
indentation: int = 4,
fill_indented_lines: bool = True,
terms_on_new_line: bool = False,
color_top_level_sum: bool = True,
color_builtin_symbols: bool = True,
bracket_level_colors: Sequence[int] | None = [244, 25, 97, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60],
print_ring: bool = True,
symmetric_representation_for_finite_field: bool = False,
explicit_rational_polynomial: bool = False,
number_thousands_separator: str | None = None,
multiplication_operator: str = '*',
double_star_for_exponentiation: bool = False,
square_brackets_for_function: bool = False,
function_brackets: tuple[str, str] = ('(', ')'),
num_exp_as_superscript: bool = True,
precision: int | None = None,
show_namespaces: bool = False,
hide_namespace: str | None = None,
include_attributes: bool = False,
max_terms: int | None = None,
custom_print_mode: int | None = None,
) -> strConvert the series into a human-readable string.
Parameters
mode(PrintMode) The mode that controls how the input is interpreted or formatted.max_line_length(int | None) The preferred maximum line length before wrapping.indentation(int) The number of spaces used for wrapped lines.fill_indented_lines(bool) Whether wrapped lines should be padded to the configured indentation.terms_on_new_line(bool) Whether wrapped output should place terms on separate lines.color_top_level_sum(bool) Whether top-level sums should be colorized.color_builtin_symbols(bool) Whether built-in symbols should be colorized.bracket_level_colors(Sequence[int] | None) The colors assigned to successive nested bracket levels.print_ring(bool) Whether the coefficient ring should be included in the printed output.symmetric_representation_for_finite_field(bool) Whether finite-field elements should be printed using symmetric representatives.explicit_rational_polynomial(bool) Whether rational polynomials should be printed explicitly as numerator and denominator.number_thousands_separator(str | None) The separator inserted between groups of digits in printed integers.multiplication_operator(str) The string used to print multiplication.double_star_for_exponentiation(bool) Whether exponentiation should be printed as**instead of^.square_brackets_for_function(bool) Whether function calls should be printed with square brackets.function_brackets(tuple[str, str]) The opening and closing brackets used when printing function arguments.num_exp_as_superscript(bool) Whether small integer exponents should be printed as superscripts.precision(int | None) The decimal precision used when printing numeric coefficients.show_namespaces(bool) Whether namespaces should be included in the formatted output.hide_namespace(str | None) A namespace prefix to omit from printed symbol names.include_attributes(bool) Whether symbol attributes should be included in the printed output.max_terms(int | None) The maximum number of terms to print before truncating the output.custom_print_mode(int | None) A custom print-mode identifier passed through to custom print callbacks.
get_absolute_order
Series.get_absolute_order() -> tuple[int, int]Get the absolute order.
get_coefficient
Series.get_coefficient(exp: Expression | int) -> ExpressionGet the coefficient of the term with exponent exp. Alternatively, use series[exp].
Parameters
exp(Expression | int) The exponent whose coefficient should be returned.
get_ramification
Series.get_ramification() -> intGet the ramification.
get_relative_order
Series.get_relative_order() -> tuple[int, int]Get the relative order.
get_trailing_exponent
Series.get_trailing_exponent() -> tuple[int, int]Get the trailing exponent; the exponent of the first non-zero term.
log
Series.log() -> SeriesCompute the natural logarithm of the series, returning the result.
pow
Series.pow(num: int, den: int) -> SeriesRaise the series to the power of num/den, returning the result.
Parameters
num(int) The numerator of the rational exponent.den(int) The denominator of the rational exponent.
shift
Series.shift(e: int) -> SeriesShift the series by e units of the ramification.
Parameters
e(int) The shift measured in units of the series ramification.
sin
Series.sin() -> SeriesCompute the sine of the series, returning the result.
spow
Series.spow(exp: Series) -> SeriesRaise the series to the power of exp, returning the result.
Parameters
exp(Series) The series exponent.
to_expression
Series.to_expression() -> ExpressionConvert the series to an expression
to_latex
Series.to_latex() -> strConvert the series into a LaTeX string.