(eq, infinitesimals, func=None, order=None)
r"""
    This function is used to check if the given infinitesimals are the
    actual infinitesimals of the given first order differential equation.
    This method is specific to the Lie Group Solver of ODEs.

    As of now, it simply checks, by substituting the infinitesimals in the
    partial differential equation.


    .. math:: \frac{\partial \eta}{\partial x} + \left(\frac{\partial \eta}{\partial y}
                - \frac{\partial \xi}{\partial x}\right)*h
                - \frac{\partial \xi}{\partial y}*h^{2}
                - \xi\frac{\partial h}{\partial x} - \eta\frac{\partial h}{\partial y} = 0


    where `\eta`, and `\xi` are the infinitesimals and `h(x,y) = \frac{dy}{dx}`

    The infinitesimals should be given in the form of a list of dicts
    ``[{xi(x, y): inf, eta(x, y): inf}]``, corresponding to the
    output of the function infinitesimals. It returns a list
    of values of the form ``[(True/False, sol)]`` where ``sol`` is the value
    obtained after substituting the infinitesimals in the PDE. If it
    is ``True``, then ``sol`` would be 0.
r"""
    This function is used to check if the given infinitesimals are the
    actual infinitesimals of the given first order differential equation.
    This method is specific to the Lie Group Solver of ODEs.
r This function is used to check if the given infinitesimals are the actual infinitesimals of the given first order differential equation . This method is specific to the Lie Group Solver of ODEs .
def checkinfsol(eq, infinitesimals, func=None, order=None):
    r"""
    This function is used to check if the given infinitesimals are the
    actual infinitesimals of the given first order differential equation.
    This method is specific to the Lie Group Solver of ODEs.

    As of now, it simply checks, by substituting the infinitesimals in the
    partial differential equation.


    .. math:: \frac{\partial \eta}{\partial x} + \left(\frac{\partial \eta}{\partial y}
                - \frac{\partial \xi}{\partial x}\right)*h
                - \frac{\partial \xi}{\partial y}*h^{2}
                - \xi\frac{\partial h}{\partial x} - \eta\frac{\partial h}{\partial y} = 0


    where `\eta`, and `\xi` are the infinitesimals and `h(x,y) = \frac{dy}{dx}`

    The infinitesimals should be given in the form of a list of dicts
    ``[{xi(x, y): inf, eta(x, y): inf}]``, corresponding to the
    output of the function infinitesimals. It returns a list
    of values of the form ``[(True/False, sol)]`` where ``sol`` is the value
    obtained after substituting the infinitesimals in the PDE. If it
    is ``True``, then ``sol`` would be 0.

    """
    if isinstance(eq, Equality):
        eq = eq.lhs - eq.rhs
    if not func:
        eq, func = _preprocess(eq)
    variables = func.args
    if len(variables) != 1:
        raise ValueError("ODE's have only one independent variable")
    else:
        x = variables[0]
        if not order:
            order = ode_order(eq, func)
        if order != 1:
            raise NotImplementedError("Lie groups solver has been implemented "
            "only for first order differential equations")
        else:
            df = func.diff(x)
            a = Wild('a', exclude = [df])
            b = Wild('b', exclude = [df])
            match = collect(expand(eq), df).match(a*df + b)

            if match:
                h = -simplify(match[b]/match[a])
            else:
                try:
                    sol = solve(eq, df)
                except NotImplementedError:
                    raise NotImplementedError("Infinitesimals for the "
                        "first order ODE could not be found")
                else:
                    h = sol[0]  # Find infinitesimals for one solution

            y = Dummy('y')
            h = h.subs(func, y)
            xi = Function('xi')(x, y)
            eta = Function('eta')(x, y)
            dxi = Function('xi')(x, func)
            deta = Function('eta')(x, func)
            pde = (eta.diff(x) + (eta.diff(y) - xi.diff(x))*h -
                (xi.diff(y))*h**2 - xi*(h.diff(x)) - eta*(h.diff(y)))
            soltup = []
            for sol in infinitesimals:
                tsol = {xi: S(sol[dxi]).subs(func, y),
                    eta: S(sol[deta]).subs(func, y)}
                sol = simplify(pde.subs(tsol).doit())
                if sol:
                    soltup.append((False, sol.subs(y, func)))
                else:
                    soltup.append((True, 0))
            return soltup
def checkinfsol ( eq , infinitesimals , func = None , order = None ) : if isinstance ( eq , Equality ) : eq = eq . lhs - eq . rhs if not func : eq , func = _preprocess ( eq ) variables = func . args if len ( variables ) != 1 : raise ValueError ( "ODE's have only one independent variable" ) else : x = variables [ 0 ] if not order : order = ode_order ( eq , func ) if order != 1 : raise NotImplementedError ( "Lie groups solver has been implemented " "only for first order differential equations" ) else : df = func . diff ( x ) a = Wild ( 'a' , exclude = [ df ] ) b = Wild ( 'b' , exclude = [ df ] ) match = collect ( expand ( eq ) , df ) . match ( a * df + b ) if match : h = - simplify ( match [ b ] / match [ a ] ) else : try : sol = solve ( eq , df ) except NotImplementedError : raise NotImplementedError ( "Infinitesimals for the " "first order ODE could not be found" ) else : h = sol [ 0 ] # Find infinitesimals for one solution y = Dummy ( 'y' ) h = h . subs ( func , y ) xi = Function ( 'xi' ) ( x , y ) eta = Function ( 'eta' ) ( x , y ) dxi = Function ( 'xi' ) ( x , func ) deta = Function ( 'eta' ) ( x , func ) pde = ( eta . diff ( x ) + ( eta . diff ( y ) - xi . diff ( x ) ) * h - ( xi . diff ( y ) ) * h ** 2 - xi * ( h . diff ( x ) ) - eta * ( h . diff ( y ) ) ) soltup = [ ] for sol in infinitesimals : tsol = { xi : S ( sol [ dxi ] ) . subs ( func , y ) , eta : S ( sol [ deta ] ) . subs ( func , y ) } sol = simplify ( pde . subs ( tsol ) . doit ( ) ) if sol : soltup . append ( ( False , sol . subs ( y , func ) ) ) else : soltup . append ( ( True , 0 ) ) return soltup