Methods for computing and manipulating Formal Power Series.
Represents Formal Power Series of a function.
No computation is performed. This class should only to be used to represent a series. No checks are performed.
For computing a series use fps().
See also
Integrate Formal Power Series.
Examples
>>> from sympy import fps, sin
>>> from sympy.abc import x
>>> f = fps(sin(x))
>>> f.integrate(x).truncate()
1 + x**2/2  x**4/24 + O(x**6)
>>> f.integrate((x, 0, 1))
cos(1) + 1
Generates Formal Power Series of f.
Returns the formal series expansion of f around x = x0 with respect to x in the form of a FormalPowerSeries object.
Formal Power Series is represented using an explicit formula computed using different algorithms.
See compute_fps() for the more details regarding the computation of formula.
Parameters :  x : Symbol, optional
x0 : number, optional
dir : {1, 1, ‘+’, ‘‘}, optional
hyper : {True, False}, optional
order : int, optional
rational : {True, False}, optional
full : {True, False}, optional


Examples
>>> from sympy import fps, O, ln, atan
>>> from sympy.abc import x
Rational Functions
>>> fps(ln(1 + x)).truncate()
x  x**2/2 + x**3/3  x**4/4 + x**5/5 + O(x**6)
>>> fps(atan(x), full=True).truncate()
x  x**3/3 + x**5/5 + O(x**6)
Computes the formula for Formal Power Series of a function.
Tries to compute the formula by applying the following techniques (in order):
Parameters :  x : Symbol x0 : number, optional
dir : {1, 1, ‘+’, ‘‘}, optional
hyper : {True, False}, optional
order : int, optional
rational : {True, False}, optional
full : {True, False}, optional


Returns :  ak : sequence
xk : sequence
ind : Expr
mul : Pow

Returns a list of all the rationally independent terms.
Examples
>>> from sympy import sin, cos
>>> from sympy.series.formal import rational_independent
>>> from sympy.abc import x
>>> rational_independent([cos(x), sin(x)], x)
[cos(x), sin(x)]
>>> rational_independent([x**2, sin(x), x*sin(x), x**3], x)
[x**3 + x**2, x*sin(x) + sin(x)]
Rational algorithm for computing formula of coefficients of Formal Power Series of a function.
Applicable when f(x) or some derivative of f(x) is a rational function in x.
rational_algorithm() uses apart() function for partial fraction decomposition. apart() by default uses ‘undetermined coefficients method’. By setting full=True, ‘Bronstein’s algorithm’ can be used instead.
Looks for derivative of a function up to 4’th order (by default). This can be overriden using order option.
Returns :  formula : Expr ind : Expr
order : int 

See also
Notes
By setting full=True, range of admissible functions to be solved using rational_algorithm can be increased. This option should be used carefully as it can signifcantly slow down the computation as doit is performed on the RootSum object returned by the apart function. Use full=False whenever possible.
References
[R427]  Formal Power Series  Dominik Gruntz, Wolfram Koepf 
[R428]  Power Series in Computer Algebra  Wolfram Koepf 
Examples
>>> from sympy import log, atan, I
>>> from sympy.series.formal import rational_algorithm as ra
>>> from sympy.abc import x, k
>>> ra(1 / (1  x), x, k)
(1, 0, 0)
>>> ra(log(1 + x), x, k)
((1)**(k)/k, 0, 1)
>>> ra(atan(x), x, k, full=True)
((I*(I)**(k)/2 + I*I**(k)/2)/k, 0, 1)
Generates simple DE.
DE is of the form
where \(A_j\) should be rational function in x.
Generates DE’s upto order 4 (default). DE’s can also have free parameters.
By increasing order, higher order DE’s can be found.
Yields a tuple of (DE, order).
Converts a DE with constant coefficients (explike) into a RE.
Performs the substitution:
Normalises the terms so that lowest order of a term is always r(k).
See also
Examples
>>> from sympy import Function, Derivative
>>> from sympy.series.formal import exp_re
>>> from sympy.abc import x, k
>>> f, r = Function('f'), Function('r')
>>> exp_re(f(x) + Derivative(f(x)), r, k)
r(k) + r(k + 1)
>>> exp_re(Derivative(f(x), x) + Derivative(f(x), x, x), r, k)
r(k) + r(k + 1)
Converts a DE into a RE.
Performs the substitution:
Normalises the terms so that lowest order of a term is always r(k).
See also
Examples
>>> from sympy import Function, Derivative
>>> from sympy.series.formal import hyper_re
>>> from sympy.abc import x, k
>>> f, r = Function('f'), Function('r')
>>> hyper_re(f(x) + Derivative(f(x)), r, k)
(k + 1)*r(k + 1)  r(k)
>>> hyper_re(x*f(x) + Derivative(f(x), x, x), r, k)
(k + 2)*(k + 3)*r(k + 3)  r(k)
Solves RE of hypergeometric type.
Attempts to solve RE of the form
Q(k)*a(k + m)  P(k)*a(k)
Transformations that preserve Hypergeometric type:
 x**n*f(x): b(k + m) = R(k  n)*b(k)
 f(A*x): b(k + m) = A**m*R(k)*b(k)
 f(x**n): b(k + n*m) = R(k/n)*b(k)
 f(x**(1/m)): b(k + 1) = R(k*m)*b(k)
 f’(x): b(k + m) = ((k + m + 1)/(k + 1))*R(k + 1)*b(k)
Some of these transformations have been used to solve the RE.
Returns :  formula : Expr ind : Expr
order : int 

References
[R429]  Formal Power Series  Dominik Gruntz, Wolfram Koepf 
[R430]  Power Series in Computer Algebra  Wolfram Koepf 
Examples
>>> from sympy import exp, ln, S
>>> from sympy.series.formal import rsolve_hypergeometric as rh
>>> from sympy.abc import x, k
>>> rh(exp(x), x, S.One, (k + 1), k, 1)
(Piecewise((1/factorial(k), Eq(Mod(k, 1), 0)), (0, True)), 1, 1)
>>> rh(ln(1 + x), x, k**2, k*(k + 1), k, 1)
(Piecewise(((1)**(k  1)*factorial(k  1)/RisingFactorial(2, k  1),
Eq(Mod(k, 1), 0)), (0, True)), x, 2)
Solves the DE.
Tries to solve DE by either converting into a RE containing two terms or converting into a DE having constant coefficients.
Returns :  formula : Expr ind : Expr
order : int 

Examples
>>> from sympy import Derivative as D
>>> from sympy import exp, ln
>>> from sympy.series.formal import solve_de
>>> from sympy.abc import x, k, f
>>> solve_de(exp(x), x, D(f(x), x)  f(x), 1, f, k)
(Piecewise((1/factorial(k), Eq(Mod(k, 1), 0)), (0, True)), 1, 1)
>>> solve_de(ln(1 + x), x, (x + 1)*D(f(x), x, 2) + D(f(x)), 2, f, k)
(Piecewise(((1)**(k  1)*factorial(k  1)/RisingFactorial(2, k  1),
Eq(Mod(k, 1), 0)), (0, True)), x, 2)
Hypergeometric algorithm for computing Formal Power Series.
Examples
>>> from sympy import exp, ln
>>> from sympy.series.formal import hyper_algorithm
>>> from sympy.abc import x, k
>>> hyper_algorithm(exp(x), x, k)
(Piecewise((1/factorial(k), Eq(Mod(k, 1), 0)), (0, True)), 1, 1)
>>> hyper_algorithm(ln(1 + x), x, k)
(Piecewise(((1)**(k  1)*factorial(k  1)/RisingFactorial(2, k  1),
Eq(Mod(k, 1), 0)), (0, True)), x, 2)