Series expansions
Run Symbolica in your browser
Python examples with a Run button can be edited and run here. The first run loads Python, Symbolica, hover documentation, and code completion.
A series stores the computed terms together with a remainder order. Series support arithmetic while tracking which coefficients are known.
Expanding and reading coefficients
series(x, point, depth) expands around point, including powers through depth. Indexing the result returns the coefficient of (x-point)**exponent:
from symbolica import *
x = S('x')
s = x.exp().series(x, 0, 2)
assert s[2] == N(1)/2
print('Coefficient of x^2:', s[2])
sA missing term below the remainder order has a known zero coefficient. At or above the remainder order, the coefficient is unknown, so indexing raises IndexError:
from symbolica import *
x = S('x')
s = (x**2).series(x, 0, 4)
print('Known zero:', s[3])
try:
s[5]
except IndexError as error:
print(error)
sget_absolute_order() returns the numerator and denominator of the exclusive boundary. Query this boundary after arithmetic; cancellation does not turn an unknown tail into known zeros.
Negative and fractional powers
Series may include poles and fractional powers. Use an exact rational number to index a fractional exponent. The fourth argument is the denominator of the requested expansion depth:
from symbolica import *
x = S('x')
s = (1/x + x.sqrt()).series(x, 0, 3, 2)
assert s[-1] == 1
assert s[N(1)/2] == 1
numerator, denominator = s.get_absolute_order()
print('Coefficients are known below exponent', N(numerator)/denominator)
sExpanding around another point
Coefficients refer to powers of the displacement from the expansion point:
from symbolica import *
x = S('x')
s = (x**2).series(x, 2, 2)
assert [s[i] for i in range(3)] == [4, 4, 1]
sto_expression() discards the remainder and returns the finite expression of the computed terms. A coefficient absent from that expression is zero as an expression, even if it was unknown in the original series. Keep the Series object when the distinction matters.