(eq, func, order, match)
return Eq(f(x), gsol.rhs + psol)
r"""
    Helper function for the method of variation of parameters and nonhomogeneous euler eq.

    See the
    :py:meth:`~sympy.solvers.ode.ode_nth_linear_constant_coeff_variation_of_parameters`
    docstring for more information on this method.

    The parameter ``match`` should be a dictionary that has the following
    keys:

    ``list``
      A list of solutions to the homogeneous equation, such as the list
      returned by
      ``ode_nth_linear_constant_coeff_homogeneous(returns='list')``.

    ``sol``
      The general solution, such as the solution returned by
      ``ode_nth_linear_constant_coeff_homogeneous(returns='sol')``.
r"""
    Helper function for the method of variation of parameters and nonhomogeneous euler eq.
r Helper function for the method of variation of parameters and nonhomogeneous euler eq .
def _solve_variation_of_parameters(eq, func, order, match):
    r"""
    Helper function for the method of variation of parameters and nonhomogeneous euler eq.

    See the
    :py:meth:`~sympy.solvers.ode.ode_nth_linear_constant_coeff_variation_of_parameters`
    docstring for more information on this method.

    The parameter ``match`` should be a dictionary that has the following
    keys:

    ``list``
      A list of solutions to the homogeneous equation, such as the list
      returned by
      ``ode_nth_linear_constant_coeff_homogeneous(returns='list')``.

    ``sol``
      The general solution, such as the solution returned by
      ``ode_nth_linear_constant_coeff_homogeneous(returns='sol')``.

    """

    x = func.args[0]
    f = func.func
    r = match
    psol = 0
    gensols = r['list']
    gsol = r['sol']
    wr = wronskian(gensols, x)

    if r.get('simplify', True):
        wr = simplify(wr)  # We need much better simplification for
                           # some ODEs. See issue 4662, for example.

        # To reduce commonly occuring sin(x)**2 + cos(x)**2 to 1
        wr = trigsimp(wr, deep=True, recursive=True)
    if not wr:
        # The wronskian will be 0 iff the solutions are not linearly
        # independent.
        raise NotImplementedError("Cannot find " + str(order) +
        " solutions to the homogeneous equation nessesary to apply " +
        "variation of parameters to " + str(eq) + " (Wronskian == 0)")
    if len(gensols) != order:
        raise NotImplementedError("Cannot find " + str(order) +
        " solutions to the homogeneous equation nessesary to apply " +
        "variation of parameters to " +
        str(eq) + " (number of terms != order)")
    negoneterm = (-1)**(order)
    for i in gensols:
        psol += negoneterm*C.Integral(wronskian([sol for sol in gensols if sol != i], x)*r[-1]/wr, x)*i/r[order]
        negoneterm *= -1

    if r.get('simplify', True):
        psol = simplify(psol)
        psol = trigsimp(psol, deep=True)
    return Eq(f(x), gsol.rhs + psol)
def _solve_variation_of_parameters ( eq , func , order , match ) : x = func . args [ 0 ] f = func . func r = match psol = 0 gensols = r [ 'list' ] gsol = r [ 'sol' ] wr = wronskian ( gensols , x ) if r . get ( 'simplify' , True ) : wr = simplify ( wr ) # We need much better simplification for # some ODEs. See issue 4662, for example. # To reduce commonly occuring sin(x)**2 + cos(x)**2 to 1 wr = trigsimp ( wr , deep = True , recursive = True ) if not wr : # The wronskian will be 0 iff the solutions are not linearly # independent. raise NotImplementedError ( "Cannot find " + str ( order ) + " solutions to the homogeneous equation nessesary to apply " + "variation of parameters to " + str ( eq ) + " (Wronskian == 0)" ) if len ( gensols ) != order : raise NotImplementedError ( "Cannot find " + str ( order ) + " solutions to the homogeneous equation nessesary to apply " + "variation of parameters to " + str ( eq ) + " (number of terms != order)" ) negoneterm = ( - 1 ) ** ( order ) for i in gensols : psol += negoneterm * C . Integral ( wronskian ( [ sol for sol in gensols if sol != i ] , x ) * r [ - 1 ] / wr , x ) * i / r [ order ] negoneterm *= - 1 if r . get ( 'simplify' , True ) : psol = simplify ( psol ) psol = trigsimp ( psol , deep = True ) return Eq ( f ( x ) , gsol . rhs + psol )