(eq, func, order, match)
return Eq(f(x), series)
r"""
    The power series solution is a method which gives the Taylor series expansion
    to the solution of a differential equation.

    For a first order differential equation `\frac{dy}{dx} = h(x, y)`, a power
    series solution exists at a point `x = x0` if `h(x, y)` is analytic at `x0`.
    The solution is given by

    .. math:: f(x0) + \sum_{n = 1}^{\infty} \frac{f^n(x)(x0)(x - x0)^n}{n!}


    The following algorithm is followed, till the required number of terms are
    generated.

    1. F_1 = `h(x, y)`
    2. F_n+1 = \frac{\partial F_n}{\partial x} + \frac{\partial F_n}{\partial y}F_1

    Examples
    ========

    >>> from sympy import Function, Derivative, pprint, exp
    >>> from sympy.solvers.ode import dsolve
    >>> from sympy.abc import x
    >>> f = Function('f')
    >>> eq = exp(x)*(f(x).diff(x)) - f(x)
    >>> pprint(dsolve(eq, hint='1st_power_series'))
                           3       4       5
                       C1*x    C1*x    C1*x     / 6\
    f(x) = C1 + C1*x - ----- + ----- + ----- + O\x /
                         6       24      60


    References
    ==========

    - Travis W. Walker, Analytic power series technique for solving first-order
      differential equations, p.p 17, 18
r"""
    The power series solution is a method which gives the Taylor series expansion
    to the solution of a differential equation.
r The power series solution is a method which gives the Taylor series expansion to the solution of a differential equation .
def ode_1st_power_series(eq, func, order, match):
    r"""
    The power series solution is a method which gives the Taylor series expansion
    to the solution of a differential equation.

    For a first order differential equation `\frac{dy}{dx} = h(x, y)`, a power
    series solution exists at a point `x = x0` if `h(x, y)` is analytic at `x0`.
    The solution is given by

    .. math:: f(x0) + \sum_{n = 1}^{\infty} \frac{f^n(x)(x0)(x - x0)^n}{n!}


    The following algorithm is followed, till the required number of terms are
    generated.

    1. F_1 = `h(x, y)`
    2. F_n+1 = \frac{\partial F_n}{\partial x} + \frac{\partial F_n}{\partial y}F_1

    Examples
    ========

    >>> from sympy import Function, Derivative, pprint, exp
    >>> from sympy.solvers.ode import dsolve
    >>> from sympy.abc import x
    >>> f = Function('f')
    >>> eq = exp(x)*(f(x).diff(x)) - f(x)
    >>> pprint(dsolve(eq, hint='1st_power_series'))
                           3       4       5
                       C1*x    C1*x    C1*x     / 6\
    f(x) = C1 + C1*x - ----- + ----- + ----- + O\x /
                         6       24      60


    References
    ==========

    - Travis W. Walker, Analytic power series technique for solving first-order
      differential equations, p.p 17, 18

    """
    x = func.args[0]
    y = match['y']
    f = func.func
    h = -match[match['d']]/match[match['e']]
    point = match.get('f0')
    value = match.get('f0val')
    terms = match.get('terms')

    # First term
    F = h
    if not h:
        return Eq(f(x), value)

    # Initialisation
    series = value
    if terms > 1:
        hc = h.subs({x: point, y: value})
        if hc.has(oo) or hc.has(NaN) or hc.has(zoo):
            # Derivative does not exist, not analytic
            return Eq(f(x), oo)
        elif hc:
            series += hc*(x - point)

    for factcount in range(2, terms):
        Fnew = F.diff(x) + F.diff(y)*h
        Fnewc = Fnew.subs({x: point, y: value})
        # Same logic as above
        if Fnewc.has(oo) or Fnewc.has(NaN) or Fnewc.has(-oo) or Fnewc.has(zoo):
            return Eq(f(x), oo)
        series += Fnewc*((x - point)**factcount)/factorial(factcount)
        F = Fnew
    series += Order(x**terms)
    return Eq(f(x), series)
def ode_1st_power_series ( eq , func , order , match ) : x = func . args [ 0 ] y = match [ 'y' ] f = func . func h = - match [ match [ 'd' ] ] / match [ match [ 'e' ] ] point = match . get ( 'f0' ) value = match . get ( 'f0val' ) terms = match . get ( 'terms' ) # First term F = h if not h : return Eq ( f ( x ) , value ) # Initialisation series = value if terms > 1 : hc = h . subs ( { x : point , y : value } ) if hc . has ( oo ) or hc . has ( NaN ) or hc . has ( zoo ) : # Derivative does not exist, not analytic return Eq ( f ( x ) , oo ) elif hc : series += hc * ( x - point ) for factcount in range ( 2 , terms ) : Fnew = F . diff ( x ) + F . diff ( y ) * h Fnewc = Fnew . subs ( { x : point , y : value } ) # Same logic as above if Fnewc . has ( oo ) or Fnewc . has ( NaN ) or Fnewc . has ( - oo ) or Fnewc . has ( zoo ) : return Eq ( f ( x ) , oo ) series += Fnewc * ( ( x - point ) ** factcount ) / factorial ( factcount ) F = Fnew series += Order ( x ** terms ) return Eq ( f ( x ) , series )