
    wg                      d dl mZ d dlmZmZ ddlmZmZ d dlm	Z	m
Z
mZmZ d dlmZ d dlmZ d dlmZ d d	lmZmZmZmZmZmZmZ d d
lmZ d dlmZmZ d dl m!Z!m"Z"m#Z# d dl$m%Z% d dl&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/ d dl0m1Z1 d dl2m3Z3 d dl4m5Z5m6Z6m7Z7 d dl8m9Z9m:Z:m;Z;m<Z<m=Z= d dl>m?Z? d dl@mAZA d dlBmCZC d dlDmEZEmFZF d dlGmHZH d dlImJZJ ddlKmLZLmMZMmNZNmOZO ddlPmQZQmRZRmSZSmTZTmUZUmVZVmWZW ddlXmYZY  G d deZ      Z[ G d d      Z\ G d  d!      Z] G d" d#e]      Z^ G d$ d%e]      Z_ G d& d'e^      Z` G d( d)e^      Za G d* d+e^      Zb G d, d-e^      Zc G d. d/e]      Zd G d0 d1e^      Ze G d2 d3e^      Zf G d4 d5e^      Zg G d6 d7e^      Zh G d8 d9e^      Zi G d: d;ei      Zj G d< d=e^      Zk G d> d?e^      Zl G d@ dAelek      Zm G dB dCem      Zn G dD dEe]      Zo G dF dGe]      Zp G dH dIe]      Zq G dJ dKe]      Zr G dL dMe]      Zs G dN dOe]      Zt G dP dQe]      Zu G dR dSe]      Zv G dT dUe]      Zw G dV dWe]      Zx G dX dYe]      Zyi dZedd[eqd\etd]esd^evd_eid`e`daead-ecdbeedcefddemdeeldfekdgebdhendiejereuehexewepeoege_eydj
Zzddkl{m|Z|m}Z}m~Z~mZ yl)m    )annotations)ClassVarIterator   )match_riccatisolve_riccati)AddSPowRational)cached_property)factor_terms)Expr)AppliedUndef
DerivativediffFunctionexpandSubs_mexpand)zoo)EqualityEq)SymbolDummyWild)Mul)	exptanlogsqrtbesseljbesselycbrtairyaiairybi)Integral)Poly)cancelfactordegree)collectsimplifyseparatevars
logcombineposify)fraction)numbered_symbols)solve)	ode_order_preprocess)_lin_eq2dict)PolyNonlinearError)equivalence_hypergeometricmatch_2nd_2F1_hypergeometricget_sol_2F1_hypergeometricmatch_2nd_hypergeometric)!_get_euler_characteristic_eq_sols!_get_const_characteristic_eq_sols _solve_undetermined_coefficients_solve_variation_of_parameters
_test_term _undetermined_coefficients_match_get_simplified_sol)_ode_lie_groupc                      e Zd ZdZy)ODEMatchErrorzFRaised if a SingleODESolver is asked to solve an ODE it does not matchN)__name__
__module____qualname____doc__     ]/home/mcse/projects/flask/flask-venv/lib/python3.12/site-packages/sympy/solvers/ode/single.pyrE   rE   %   s    PrK   rE   c                      e Zd ZdZdZdZdZdZdZdZ	dZ
ddZedd       Zedd       Zedd       Zedd       ZddZddd	Zddd
Zed        Zd Zy)SingleODEProblema  Represents an ordinary differential equation (ODE)

    This class is used internally in the by dsolve and related
    functions/classes so that properties of an ODE can be computed
    efficiently.

    Examples
    ========

    This class is used internally by dsolve. To instantiate an instance
    directly first define an ODE problem:

    >>> from sympy import Function, Symbol
    >>> x = Symbol('x')
    >>> f = Function('f')
    >>> eq = f(x).diff(x, 2)

    Now you can create a SingleODEProblem instance and query its properties:

    >>> from sympy.solvers.ode.single import SingleODEProblem
    >>> problem = SingleODEProblem(f(x).diff(x), f(x), x)
    >>> problem.eq
    Derivative(f(x), x)
    >>> problem.func
    f(x)
    >>> problem.sym
    x
    Nc                    t        |t              sJ t        |t              sJ t        |t              sJ t        |t              sJ || _        || _        || _        || _        || _	        y N)

isinstancer   r   r   booleqfuncsymprepparams)selfrS   rT   rU   rV   kwargss         rL   __init__zSingleODEProblem.__init__Q   se    "d###$---#v&&&$%%%		rK   c                B    t        | j                  | j                        S rP   )r4   rS   rT   rX   s    rL   orderzSingleODEProblem.order\   s    $)),,rK   c                "    | j                         S rP   )_get_eq_preprocessedr\   s    rL   eq_preprocessedz SingleODEProblem.eq_preprocessed`   s    ((**rK   c                6   t        d| j                  g      }t        d| j                  g      }d }| j                  j                  r| j                  j                  | j                  j                  | j                  | j                              }|dvrg|j                  || j                  |z  z        }|rD||   r?| j                  ||   z  }t        | j                  j                  D cg c]  }||z  	 c} }|st        | j                        }|S c c}w )Naexcludec1)r   r   )r   rT   rU   rS   is_Addcoeffr   r]   matchr	   argsr   )rX   rb   re   
reduced_eq
deriv_coefrdenargs           rL   eq_high_order_freez#SingleODEProblem.eq_high_order_freed   s    tyyk*$
+
77>>tyy~~dhh

'KLJ'$$Qtyy"}_52))QrU*C!$$'',,&G3s3w&G!HJJ 'Hs   -Dc                ,    t        | j                        S rP   )r   r`   r\   s    rL   eq_expandedzSingleODEProblem.eq_expandedu   s    d**++rK   c                    | j                   r:t        | j                  | j                        \  }}|| j                  k7  rt        |S | j                  }|S rP   )rV   r5   rS   rT   
ValueError)rX   
process_eqprocess_funcs      rL   r_   z%SingleODEProblem._get_eq_preprocessedy   sM    99'2477DII'F$Jtyy(    JrK   c                v    | j                  ||      }t        |      D cg c]  }t        |       }}|S c c}w )zV
        Returns a list of constants that do not occur
        in eq already.
        )iter_numbered_constantsrangenext)rX   numstartprefixncsiCss          rL   get_numbered_constantsz'SingleODEProblem.get_numbered_constants   s;    
 **5&9!&s,Ad3i,,	 -s   6c           	         | j                   j                  }| j                   j                  t              }|r/||D ch c]   }t	        t        |j                              " c}z  }t        |||      S c c}w )z[
        Returns an iterator of constants that do not occur
        in eq already.
        )r{   r|   rd   )rS   free_symbolsatomsr   r   strrT   r2   )rX   r{   r|   atom_setfunc_setfs         rL   rw   z(SingleODEProblem.iter_numbered_constants   s_    
 77''77==*h?AFF,??HeFHMM @s   %A5c                    t        d      }| j                  }| j                  j                  | j                  |      j
                  }||vS )Nu)r   rU   rS   subsrT   r   )rX   r   xsymss       rL   is_autonomouszSingleODEProblem.is_autonomous   s<    #JHHww||DIIq)66}rK   c           
        j                   }j                  d   }t        |dz         D ch c]  }t         ||      ||       }}	 t	        ||      \  }}	|j                        s"t        fd|	j                         D              ryt        |dz         D ci c]9  }||	j                   ||      j                  ||      t        j                        ; }
}||
d<   |
S c c}w # t
        $ r Y yw xY wc c}w )a  
        Matches a differential equation to the linear form:

        .. math:: a_n(x) y^{(n)} + \cdots + a_1(x)y' + a_0(x) y + B(x) = 0

        Returns a dict of order:coeff terms, where order is the order of the
        derivative on each term, and coeff is the coefficient of that derivative.
        The key ``-1`` holds the function `B(x)`. Returns ``None`` if the ODE is
        not linear.  This function assumes that ``func`` has already been checked
        to be good.

        Examples
        ========

        >>> from sympy import Function, cos, sin
        >>> from sympy.abc import x
        >>> from sympy.solvers.ode.single import SingleODEProblem
        >>> f = Function('f')
        >>> eq = f(x).diff(x, 3) + 2*f(x).diff(x) + \
        ... x*f(x).diff(x, 2) + cos(x)*f(x).diff(x) + x - f(x) - \
        ... sin(x)
        >>> obj = SingleODEProblem(eq, f(x), x)
        >>> obj.get_linear_coefficients(eq, f(x), 3)
        {-1: x - sin(x), 0: -1, 1: cos(x) + 2, 2: x, 3: 1}
        >>> eq = f(x).diff(x, 3) + 2*f(x).diff(x) + \
        ... x*f(x).diff(x, 2) + cos(x)*f(x).diff(x) + x - f(x) - \
        ... sin(f(x))
        >>> obj = SingleODEProblem(eq, f(x), x)
        >>> obj.get_linear_coefficients(eq, f(x), 3) == None
        True

        r   r   Nc              3  @   K   | ]  }|j                          y wrP   )has).0crT   s     rL   	<genexpr>z;SingleODEProblem.get_linear_coefficients.<locals>.<genexpr>   s     HdHs   )rT   ri   rx   r   r6   r7   r   anyvaluesgetr   r
   Zero)rX   rS   rT   r]   r   r   r~   symsetrhs	lhs_termstermss     `        rL   get_linear_coefficientsz(SingleODEProblem.get_linear_coefficients   s    B IIIIaL27a.AQ*QqT1a(AA	)"f5NC 774=CHY5E5E5GHHDI%PQ'NSqIMM!A$))Aq/166::SSb	 B " 		
 Ts   C$
C) >C8)	C54C5)T)returnint)r   r   )r   r   C)r   zlist[Symbol])r   r   )r   zIterator[Symbol])rF   rG   rH   rI   rS   rT   rU   _order_eq_expanded_eq_preprocessed_eq_high_order_freerZ   r   r]   r`   ro   rq   r_   r   rw   r   r   rJ   rK   rL   rN   rN   *   s    < 
BD
CFL	 - - + +    , ,	N  -rK   rN   c                  x    e Zd ZU dZded<   ded<   dZdZded<   dZd	ed
<   d ZddZ	ddddZ
ddZddddZy)SingleODESolvera  
    Base class for Single ODE solvers.

    Subclasses should implement the _matches and _get_general_solution
    methods. This class is not intended to be instantiated directly but its
    subclasses are as part of dsolve.

    Examples
    ========

    You can use a subclass of SingleODEProblem to solve a particular type of
    ODE. We first define a particular ODE problem:

    >>> from sympy import Function, Symbol
    >>> x = Symbol('x')
    >>> f = Function('f')
    >>> eq = f(x).diff(x, 2)

    Now we solve this problem using the NthAlgebraic solver which is a
    subclass of SingleODESolver:

    >>> from sympy.solvers.ode.single import NthAlgebraic, SingleODEProblem
    >>> problem = SingleODEProblem(eq, f(x), x)
    >>> solver = NthAlgebraic(problem)
    >>> solver.get_general_solution()
    [Eq(f(x), _C*x + _C)]

    The normal way to solve an ODE is to use dsolve (which would use
    NthAlgebraic and other solvers internally). When using dsolve a number of
    other things are done such as evaluating integrals, simplifying the
    solution and renumbering the constants:

    >>> from sympy import dsolve
    >>> dsolve(eq, hint='nth_algebraic')
    Eq(f(x), C1 + C2*x)
    zClassVar[str]hintzClassVar[bool]has_integralNzbool | None_matchedzlist | Noner]   c                    || _         y rP   )ode_problem)rX   r   s     rL   rZ   zSingleODESolver.__init__  s
    &rK   c                    | j                   5| j                  j                   | j                   vrd| _        | j                  S | j                  | j                         | _        | j                  S )NF)r]   r   r   _matchesr\   s    rL   matcheszSingleODESolver.matches  sU    ::!d&6&6&<&<DJJ&N!DM== ==  MMODM}}rK   Tr-   c                   | j                         s0d}t        || j                  | j                  j                  fz        | j                  |      S )Nz%s solver cannot solve:
%ssimplify_flag)r   rE   r   r   rS   _get_general_solution)rX   r-   msgs      rL   get_general_solutionz$SingleODESolver.get_general_solution  sI    ||~/Ctyy$2B2B2E2E&F FGG)))AArK   c                    d}t        |      )Nz7Subclasses of SingleODESolver should implement matches.NotImplementedError)rX   r   s     rL   r   zSingleODESolver._matches  s    G!#&&rK   r   c                   d}t        |      )NzDSubclasses of SingleODESolver should implement get_general_solution.r   )rX   r   r   s      rL   r   z%SingleODESolver._get_general_solution!  s    T!#&&rK   r   rR   )r-   rR   r   list[Equality])r   rR   r   r   )rF   rG   rH   rI   __annotations__r   r   r]   rZ   r   r   r   r   rJ   rK   rL   r   r      s\    #N  !  K !Hk  E;' 8< B' >B 'rK   r   c                  6    e Zd ZdZd Zd Zd Zd	dZd Zd Z	y)
SinglePatternODESolverz4Superclass for ODE solvers based on pattern matchingc                    | j                   }|j                  j                  }|j                  }|j                  }| j	                  |||      S rP   )r   rT   rU   r]   _wilds)rX   probr   r   r]   s        rL   wildszSinglePatternODESolver.wilds)  s?    IINNHH

{{1a''rK   c                    | j                   }| j                         D cg c]"  }|j                  |t        j                        $ c}S c c}w rP   )_wilds_matchr   r   r
   r   )rX   rh   ws      rL   wilds_matchz"SinglePatternODESolver.wilds_match0  s6    !!.2jjl;		!QVV$;;;s   'A	c                   | j                   j                  }| j                   j                  j                  }| j                   j                  }| j                   j                  } ||      j                  ||      }|dvry| j                   ||      ||      }|j                  |      j                  t              st        ||j                  |      z        }|j                   ||      j                  |       ||      gt              }|j                  |      x| _        }|| j                   ||            S y)N)r      FrT   )r   rq   rT   rU   r]   r   	_equationrg   r   r   r   r,   r)   rh   r   _verify)rX   rS   r   r   r]   dfpatternrh   s           rL   r   zSinglePatternODESolver._matches4  s   ))!!&&    &&qTYYq% ..1q%0}}R $$T*RXXb\)*BZZ11qt,VZ<$&HHW$55E<<!%%rK   c                     y)NTrJ   rX   fxs     rL   r   zSinglePatternODESolver._verifyI  s    rK   c                    d}t        |      )Nz5Subclasses of SingleODESolver should implement _wildsr   )rX   r   r   r]   r   s        rL   r   zSinglePatternODESolver._wildsL  s    E!#&&rK   c                    d}t        |      )Nz8Subclasses of SingleODESolver should implement _equationr   )rX   r   r   r]   r   s        rL   r   z SinglePatternODESolver._equationP  s    H!#&&rK   Nr   )
rF   rG   rH   rI   r   r   r   r   r   r   rJ   rK   rL   r   r   &  s#    >(<*''rK   r   c                  L    e Zd ZU dZdZdZd ZddddZi Zde	d<   e
d	        Zy
)NthAlgebraica  
    Solves an `n`\th order ordinary differential equation using algebra and
    integrals.

    There is no general form for the kind of equation that this can solve. The
    the equation is solved algebraically treating differentiation as an
    invertible algebraic function.

    Examples
    ========

    >>> from sympy import Function, dsolve, Eq
    >>> from sympy.abc import x
    >>> f = Function('f')
    >>> eq = Eq(f(x) * (f(x).diff(x)**2 - 1), 0)
    >>> dsolve(eq, f(x), hint='nth_algebraic')
    [Eq(f(x), 0), Eq(f(x), C1 - x), Eq(f(x), C1 + x)]

    Note that this solver can return algebraic solutions that do not have any
    integration constants (f(x) = 0 in the above example).
    nth_algebraicTc           	       	 | j                   j                  }| j                   j                  }| j                   j                  }| j	                  |      		fd}	fd} |||      }	 t        ||d      }|D cg c]  }t         |||             }}|D cg c]  }t        ||       }}|| _	        t        |      dk7  S # t        $ r g }Y Zw xY wc c}w c c}w )a%  
        Matches any differential equation that nth_algebraic can solve. Uses
        `sympy.solve` but teaches it how to integrate derivatives.

        This involves calling `sympy.solve` and does most of the work of finding a
        solution (apart from evaluating the integrals).
        c                >    fd}| j                  t        |      S )Nc                     | d   | dd  }}|}|D ]/  \  }}t        |      D ]  }|k(  r	 |      }t        ||      } 1 |S Nr   r   )rx   r   )	ri   	differanddiffs	toreplacevn_diffxvars	          rL   expand_diffxz<NthAlgebraic._matches.<locals>.replace.<locals>.expand_diffx  sj    #'7DH5	%	! ADAq"1X A8(-i(8I(29a(@I	AA ! rK   )replacer   )rS   r   r   r   s    ` rL   r   z&NthAlgebraic._matches.<locals>.replace  s    	! ::j,77rK   c                0    | j                  fd      S )Nc                    t        |       S rP   )r   )er   s    rL   <lambda>z:NthAlgebraic._matches.<locals>.unreplace.<locals>.<lambda>  s    z!S/A rK   )r   )rS   r   r   s    `rL   	unreplacez(NthAlgebraic._matches.<locals>.unreplace  s    ::e%ABBrK   Fr   r   )r   rS   rT   rU   
_get_diffxr3   r   r-   r   	solutionslen)
rX   rS   rT   r   r   r   subs_eqnsolnssolnr   s
            @rL   r   zNthAlgebraic._matcheso  s       $$"" $	8	C 2s#	 (D59E =BBD)D#./BB278$$%885zQ # 	E	 C8s   )C ;CCCCr   c                   | j                   S rP   )r   )rX   r   s     rL   r   z"NthAlgebraic._get_general_solution  s    ~~rK   zdict[Symbol, type[Function]]_diffx_storedc                     t         j                  j                   d       }|1 G  fddt              }t         j                  j	                   |      }|S )Nc                      e Zd Z fdZy)&NthAlgebraic._get_diffx.<locals>.diffxc                    fdS )Nc                4    t        |       t        d      z   S )Nr   )r'   r   )exprr   s    rL   r   z@NthAlgebraic._get_diffx.<locals>.diffx.inverse.<locals>.<lambda>  s    s(;eCj(H rK   rJ   )rX   r   s    rL   inversez.NthAlgebraic._get_diffx.<locals>.diffx.inverse  s     IHrK   N)rF   rG   rH   r   )r   s   rL   r   r     s	    IrK   r   )r   r   r   r   
setdefault)r   diffclsr   s   `  rL   r   zNthAlgebraic._get_diffx  sM    ,,00d;?I I #00;;CGGrK   Nr   rR   )rF   rG   rH   rI   r   r   r   r   r   r   staticmethodr   rJ   rK   rL   r   r   U  sC    , DL.` >B  35M/4 rK   r   c                  @    e Zd ZdZdZdZdgZd Zd ZddZ	dddd	Z
y
)
FirstExacta  
    Solves 1st order exact ordinary differential equations.

    A 1st order differential equation is called exact if it is the total
    differential of a function. That is, the differential equation

    .. math:: P(x, y) \,\partial{}x + Q(x, y) \,\partial{}y = 0

    is exact if there is some function `F(x, y)` such that `P(x, y) =
    \partial{}F/\partial{}x` and `Q(x, y) = \partial{}F/\partial{}y`.  It can
    be shown that a necessary and sufficient condition for a first order ODE
    to be exact is that `\partial{}P/\partial{}y = \partial{}Q/\partial{}x`.
    Then, the solution will be as given below::

        >>> from sympy import Function, Eq, Integral, symbols, pprint
        >>> x, y, t, x0, y0, C1= symbols('x,y,t,x0,y0,C1')
        >>> P, Q, F= map(Function, ['P', 'Q', 'F'])
        >>> pprint(Eq(Eq(F(x, y), Integral(P(t, y), (t, x0, x)) +
        ... Integral(Q(x0, t), (t, y0, y))), C1))
                    x                y
                    /                /
                   |                |
        F(x, y) =  |  P(t, y) dt +  |  Q(x0, t) dt = C1
                   |                |
                  /                /
                  x0               y0

    Where the first partials of `P` and `Q` exist and are continuous in a
    simply connected region.

    A note: SymPy currently has no way to represent inert substitution on an
    expression, so the hint ``1st_exact_Integral`` will return an integral
    with `dy`.  This is supposed to represent the function that you are
    solving for.

    Examples
    ========

    >>> from sympy import Function, dsolve, cos, sin
    >>> from sympy.abc import x
    >>> f = Function('f')
    >>> dsolve(cos(f(x)) - (x*sin(f(x)) - f(x)**2)*f(x).diff(x),
    ... f(x), hint='1st_exact')
    Eq(x*cos(f(x)) + f(x)**3/3, C1)

    References
    ==========

    - https://en.wikipedia.org/wiki/Exact_differential_equation
    - M. Tenenbaum & H. Pollard, "Ordinary Differential Equations",
      Dover 1963, pp. 73

    # indirect doctest

    	1st_exactTr   c                    t        d ||      j                  |      g      }t        d ||      j                  |      g      }||fS NPrc   Qr   r   rX   r   r   r]   r  r  s         rL   r   zFirstExact._wilds  ?    qtyy|n-qtyy|n-!trK   c                V    | j                         \  }}|||j                  |      z  z   S rP   r   r   rX   r   r   r]   r  r  s         rL   r   zFirstExact._equation  (    zz|11RWWQZ<rK   c                   | j                         \  }}| j                  j                  }t        d      }| j	                         \  }}|j                  ||      }|j                  ||      }t        |j                  |      |j                  |      z
        }|j                  ryt        ||z        }	t        | |z        }
||	j                  vr|	}|}n||
j                  vr|
}|}nyt        t        ||            }||z  }||z  }|j                  ||      | j                  |<   |j                  ||      | j                  |<   y)NyTF)r   r   rU   r   r   r   r)   r   is_zeror   r   r'   r   )rX   r   r  r  r   r  mr   	numeratorfactor_nfactor_mr*   integration_variables                rL   r   zFirstExact._verify   s<   zz|1  #J!1FF2qMFF2qM166!9qvvay01	 ik*Hyjl+H--- "'($(/// "'($ &*>?@FKAKA#$66!R=Da #$66!R=Da rK   r   c                  | j                         \  }}| j                  j                  }| j                  j                  }| j                  j	                  d      \  }t        d      }|j                  ||      }|j                  ||      }t        t        t        ||      t        |t        ||      j                  |      z
  |      z   ||      |      }|gS )Nr   rz   r  )r   r   rT   rU   r   r   r   r   r   r'   r   )	rX   r   r  r   r   r   C1r  gen_sols	            rL   r   z FirstExact._get_general_solution-  s    !1""    77A7>#JFF2qMFF2qMT(1a.$Q!Q)<)<Q)?%?CDEFLMOQyrK   Nr   r   rF   rG   rH   rI   r   r   r]   r   r   r   r   rJ   rK   rL   r   r     s6    6n DLCE
 +Z >B rK   r   c                  8    e Zd ZdZdZdZdgZd Zd Zddd
dZ	y	)FirstLineara  
    Solves 1st order linear differential equations.

    These are differential equations of the form

    .. math:: dy/dx + P(x) y = Q(x)\text{.}

    These kinds of differential equations can be solved in a general way.  The
    integrating factor `e^{\int P(x) \,dx}` will turn the equation into a
    separable equation.  The general solution is::

        >>> from sympy import Function, dsolve, Eq, pprint, diff, sin
        >>> from sympy.abc import x
        >>> f, P, Q = map(Function, ['f', 'P', 'Q'])
        >>> genform = Eq(f(x).diff(x) + P(x)*f(x), Q(x))
        >>> pprint(genform)
                    d
        P(x)*f(x) + --(f(x)) = Q(x)
                    dx
        >>> pprint(dsolve(genform, f(x), hint='1st_linear_Integral'))
                /       /                   \
                |      |                    |
                |      |         /          |     /
                |      |        |           |    |
                |      |        | P(x) dx   |  - | P(x) dx
                |      |        |           |    |
                |      |       /            |   /
        f(x) = |C1 +  | Q(x)*e           dx|*e
                |      |                    |
                \     /                     /


    Examples
    ========

    >>> f = Function('f')
    >>> pprint(dsolve(Eq(x*diff(f(x), x) - f(x), x**2*sin(x)),
    ... f(x), '1st_linear'))
    f(x) = x*(C1 - cos(x))

    References
    ==========

    - https://en.wikipedia.org/wiki/Linear_differential_equation#First-order_equation_with_variable_coefficients
    - M. Tenenbaum & H. Pollard, "Ordinary Differential Equations",
      Dover 1963, pp. 92

    # indirect doctest

    
1st_linearTr   c                    t        d ||      g      }t        d ||       ||      j                  |      g      }||fS r   r  r  s         rL   r   zFirstLinear._wildss  s>    qtf%qtQqTYYq\23!trK   c                \    | j                         \  }}|j                  |      ||z  z   |z
  S rP   r  r  s         rL   r   zFirstLinear._equationx  s-    zz|1wwqzAbD 1$$rK   r   c               N   | j                         \  }}| j                  j                  }| j                  j                  }| j                  j	                  d      \  }t        ||t        |t        t        ||            z  |      z   t        t        ||             z        }|gS Nr   r  )r   r   rT   rU   r   r   r'   r   )rX   r   r  r  r   r   r  gensols           rL   r   z!FirstLinear._get_general_solution|  s    !1""  !!88Q8?B"x#hq!n*=(=qAA8Aq>/"# %xrK   Nr   
rF   rG   rH   rI   r   r   r]   r   r   r   rJ   rK   rL   r  r  <  s0    1d DLCE
% >B rK   r  c                  >    e Zd ZdZdZdZdgZd Zd Zd Z	dddd	Z
y
)AlmostLineara  
    Solves an almost-linear differential equation.

    The general form of an almost linear differential equation is

    .. math:: a(x) g'(f(x)) f'(x) + b(x) g(f(x)) + c(x)

    Here `f(x)` is the function to be solved for (the dependent variable).
    The substitution `g(f(x)) = u(x)` leads to a linear differential equation
    for `u(x)` of the form `a(x) u' + b(x) u + c(x) = 0`. This can be solved
    for `u(x)` by the `first_linear` hint and then `f(x)` is found by solving
    `g(f(x)) = u(x)`.

    See Also
    ========
    :obj:`sympy.solvers.ode.single.FirstLinear`

    Examples
    ========

    >>> from sympy import dsolve, Function, pprint, sin, cos
    >>> from sympy.abc import x
    >>> f = Function('f')
    >>> d = f(x).diff(x)
    >>> eq = x*d + x*f(x) + 1
    >>> dsolve(eq, f(x), hint='almost_linear')
    Eq(f(x), (C1 - Ei(x))*exp(-x))
    >>> pprint(dsolve(eq, f(x), hint='almost_linear'))
                        -x
    f(x) = (C1 - Ei(x))*e
    >>> example = cos(f(x))*f(x).diff(x) + sin(f(x)) + 1
    >>> pprint(example)
                        d
    sin(f(x)) + cos(f(x))*--(f(x)) + 1
                        dx
    >>> pprint(dsolve(example, f(x), hint='almost_linear'))
                    /    -x    \             /    -x    \
    [f(x) = pi - asin\C1*e   - 1/, f(x) = asin\C1*e   - 1/]


    References
    ==========

    - Joel Moses, "Symbolic Integration - The Stormy Decade", Communications
      of the ACM, Volume 14, Number 8, August 1971, pp. 558
    almost_linearTr   c                    t        d ||      j                  |      g      }t        d ||      j                  |      g      }||fS r   r  r  s         rL   r   zAlmostLinear._wilds  r  rK   c                V    | j                         \  }}||j                  |      z  |z   S rP   r  r  s         rL   r   zAlmostLinear._equation  s(    zz|1|arK   c                   | j                         \  }}|j                  r|j                  |      nt        j                  |f\  }}|j                  |      dk7  rt        |j                  |      |z        j                  |      smt        |      j                  |d      d   | _	        || j                  j                  |      z  | _
        | | _        t        |      | j                  z  | _        yy)Nr   Fas_Addr   T)r   rf   as_independentr
   r   r   r-   r   r   lyaxcxbx)rX   r   rb   br   s        rL   r   zAlmostLinear._verify  s    !1'(xxq#affa[1 66":?8AFF2JqL#9#=#=b#A"1o44R4FqIDG$'',,r**DGbDG"1o/DGrK   r   c                  | j                   j                  }| j                   j                  d      \  }t        | j                  |t        | j                  | j                  z  t        t        | j                  | j                  z  |            z  |      z   t        t        | j                  | j                  z  |             z        }|gS r  )
r   rU   r   r   r)  r'   r+  r*  r   r,  )rX   r   r   r  r  s        rL   r   z"AlmostLinear._get_general_solution  s      !!88Q8?DGGrHdggdggos8DGGTXT[T[O]^C_?`-`bc$ddx3345 7 xrK   Nr   r  rJ   rK   rL   r!  r!    s5    -\ DLCE
 " >B rK   r!  c                  8    e Zd ZdZd ZdZdgZd Zd Zddd	dZ	y)
	Bernoullia{  
    Solves Bernoulli differential equations.

    These are equations of the form

    .. math:: dy/dx + P(x) y = Q(x) y^n\text{, }n \ne 1`\text{.}

    The substitution `w = 1/y^{1-n}` will transform an equation of this form
    into one that is linear (see the docstring of
    :obj:`~sympy.solvers.ode.single.FirstLinear`).  The general solution is::

        >>> from sympy import Function, dsolve, Eq, pprint
        >>> from sympy.abc import x, n
        >>> f, P, Q = map(Function, ['f', 'P', 'Q'])
        >>> genform = Eq(f(x).diff(x) + P(x)*f(x), Q(x)*f(x)**n)
        >>> pprint(genform)
                    d                n
        P(x)*f(x) + --(f(x)) = Q(x)*f (x)
                    dx
        >>> pprint(dsolve(genform, f(x), hint='Bernoulli_Integral'), num_columns=110)
                                                                                                                -1
                                                                                                               -----
                                                                                                               n - 1
               //         /                                 /                            \                    \
               ||        |                                 |                             |                    |
               ||        |                  /              |                  /          |            /       |
               ||        |                 |               |                 |           |           |        |
               ||        |       -(n - 1)* | P(x) dx       |       -(n - 1)* | P(x) dx   |  (n - 1)* | P(x) dx|
               ||        |                 |               |                 |           |           |        |
               ||        |                /                |                /            |          /         |
        f(x) = ||C1 - n* | Q(x)*e                    dx +  | Q(x)*e                    dx|*e                  |
               ||        |                                 |                             |                    |
               \\       /                                 /                              /                    /


    Note that the equation is separable when `n = 1` (see the docstring of
    :obj:`~sympy.solvers.ode.single.Separable`).

    >>> pprint(dsolve(Eq(f(x).diff(x) + P(x)*f(x), Q(x)*f(x)), f(x),
    ... hint='separable_Integral'))
    f(x)
        /
    |                /
    |  1            |
    |  - dy = C1 +  | (-P(x) + Q(x)) dx
    |  y            |
    |              /
    /


    Examples
    ========

    >>> from sympy import Function, dsolve, Eq, pprint, log
    >>> from sympy.abc import x
    >>> f = Function('f')

    >>> pprint(dsolve(Eq(x*f(x).diff(x) + f(x), log(x)*f(x)**2),
    ... f(x), hint='Bernoulli'))
                    1
    f(x) =  -----------------
            C1*x + log(x) + 1

    References
    ==========

    - https://en.wikipedia.org/wiki/Bernoulli_differential_equation

    - M. Tenenbaum & H. Pollard, "Ordinary Differential Equations",
      Dover 1963, pp. 95

    # indirect doctest

    Tr   c                    t        d ||      g      }t        d ||      g      }t        d| ||       ||      j                  |      g      }|||fS )Nr  rc   r  r   r  )rX   r   r   r]   r  r  r   s          rL   r   zBernoulli._wilds+  sT    qtf%qtf%q!A$!		!56!QwrK   c                j    | j                         \  }}}|j                  |      ||z  z   |||z  z  z
  S rP   r  )rX   r   r   r]   r  r  r   s          rL   r   zBernoulli._equation1  s7    **,1awwqzAbD 1RU7**rK   r   c                  | j                         \  }}}| j                  j                  }| j                  j                  }| j                  j	                  d      \  }|dk(  r)t        t        |      |t        | |z   |      z         }|gS t        |d|z
  z  ||dz
  t        |t        | t        ||      z        z  t        t        ||            z  |      z  z
  t        d|z
   t        ||      z        z        }|gS r  )	r   r   rT   rU   r   r   r    r'   r   )	rX   r   r  r  r   r   r   r  r  s	            rL   r   zBernoulli._get_general_solution5  s   ""$1a""    77A7>a4BA26A&&F x QqS	q1u3r(1a./@+A)A!(1a.1*234!6 6 6!a%!Q/01F
 xrK   Nr   r  rJ   rK   rL   r0  r0    s1    IT DLCE+ >B rK   r0  c                  ,    e Zd ZdZdZdZd Zddd	dZy)

Factorablea  
        Solves equations having a solvable factor.

        This function is used to solve the equation having factors. Factors may be of type algebraic or ode. It
        will try to solve each factor independently. Factors will be solved by calling dsolve. We will return the
        list of solutions.

        Examples
        ========

        >>> from sympy import Function, dsolve, pprint
        >>> from sympy.abc import x
        >>> f = Function('f')
        >>> eq = (f(x)**2-4)*(f(x).diff(x)+f(x))
        >>> pprint(dsolve(eq, f(x)))
                                        -x
        [f(x) = 2, f(x) = -2, f(x) = C1*e  ]


        
factorableFc                $   | j                   j                  }| j                   j                  j                  }| j                   j                  } ||      j	                  |      }g | _        |j                   ||      t              }t        t        |            d   }t        j                  t        |            }|D cg c]+  }t        |j                        dk7  s|j                         - }}t        |      dkD  s|d   d   dkD  rV|D ]8  \  }	}
|	j                   ||            s| j
                  j!                  |	       : t        | j
                        dkD  ryt#        ||      }t        |      dkD  r*|D cg c]  }||z
  	 c}| _        | j
                  |gk7  }|S |D ]5  }|j                   ||            s| j
                  j!                  |       7 t        | j
                        dkD  xr t        |      dkD  S c c}w c c}w )Nr   r   r   T)r   rS   rT   rU   r   eqsr,   r)   r1   r*   r   	make_argsr   ri   as_base_expr   appendr3   )rX   eq_origr   r   r   rS   factorsfacrootsbaseexporootr   r~   s                 rL   r   zFactorable._matches_  s   ""%%!!&&  qTYYq\__QqT&_1fRj!!$--r
+.5JsSXX9I"JJu:a<58A;q=# *
d88AaD>HHOOD)* 488}Qb"u:a<056d6DHhh7)+GN 	#AuuQqT{"	# 488}Q13w<>1! K 7s   HH HTr   c                  | j                   j                  j                  }| j                   j                  }| j                  }g }|D ]H  }	 t	        | ||            }t        |t              r|j                  |       8|j                  |       J |g k(  rt        dt              z   dz   dz         |S # t        $ r Y zw xY w)NThe given ODE  cannot be solved byz the factorable group method)r   rT   rU   r8  dsolverQ   listextendr;  r   r   )rX   r   rT   r   eqnssolsrS   sols           rL   r   z Factorable._get_general_solutionz  s    $$))  xx 		%B%Ra) c4(KK$KK$		% 2:%&6R&@CY&Y0'1 2 2 ' s   B66	CCNr   rF   rG   rH   rI   r   r   r   r   rJ   rK   rL   r5  r5  G  s#    ( DL26 >B rK   r5  c                  8    e Zd ZdZdZdZdgZd Zd Zdddd	Z	y
)RiccatiSpeciala|  
    The general Riccati equation has the form

    .. math:: dy/dx = f(x) y^2 + g(x) y + h(x)\text{.}

    While it does not have a general solution [1], the "special" form, `dy/dx
    = a y^2 - b x^c`, does have solutions in many cases [2].  This routine
    returns a solution for `a(dy/dx) = b y^2 + c y/x + d/x^2` that is obtained
    by using a suitable change of variables to reduce it to the special form
    and is valid when neither `a` nor `b` are zero and either `c` or `d` is
    zero.

    >>> from sympy.abc import x, a, b, c, d
    >>> from sympy import dsolve, checkodesol, pprint, Function
    >>> f = Function('f')
    >>> y = f(x)
    >>> genform = a*y.diff(x) - (b*y**2 + c*y/x + d/x**2)
    >>> sol = dsolve(genform, y, hint="Riccati_special_minus2")
    >>> pprint(sol, wrap_line=False)
            /                                 /        __________________       \\
            |           __________________    |       /                2        ||
            |          /                2     |     \/  4*b*d - (a + c)  *log(x)||
           -|a + c - \/  4*b*d - (a + c)  *tan|C1 + ----------------------------||
            \                                 \                 2*a             //
    f(x) = ------------------------------------------------------------------------
                                            2*b*x

    >>> checkodesol(genform, sol, order=1)[0]
    True

    References
    ==========

    - https://www.maplesoft.com/support/help/Maple/view.aspx?path=odeadvisor/Riccati
    - https://eqworld.ipmnet.ru/en/solutions/ode/ode0106.pdf -
      https://eqworld.ipmnet.ru/en/solutions/ode/ode0123.pdf
    Riccati_special_minus2Fr   c                j   t        d| ||       ||      j                  |      dg      }t        d| ||       ||      j                  |      dg      }t        d| ||       ||      j                  |      g      }t        d| ||       ||      j                  |      g      }||||fS )Nrb   r   rc   r-  r   dr  )rX   r   r   r]   rb   r-  r   rQ  s           rL   r   zRiccatiSpecial._wilds  s    q!A$!		!a89q!A$!		!a89q!A$!		!56q!A$!		!56!QzrK   c                    | j                         \  }}}}||j                  |      z  ||dz  z  z   ||z  |z  z   ||dz  z  z   S Nr   r  )rX   r   r   r]   rb   r-  r   rQ  s           rL   r   zRiccatiSpecial._equation  sN    ZZ\
1a|aAg%"Q.1a477rK   Tr   c               r   | j                         \  }}}}| j                  j                  }| j                  j                  }| j                  j	                  d      \  }t        d|z  |z  ||z
  dz  z
        }	t        |||z
  |	t        |	d|z  z  t        |      z  |z         z  z
  d|z  |z  z        }
|
gS )Nr   r     r   )	r   r   rT   rU   r   r!   r   r   r    )rX   r   rb   r-  r   rQ  r   r   r  mur  s              rL   r   z$RiccatiSpecial._get_general_solution  s    %%'
1a""    77A7>!A#a%1q51*$%BQCAaCQ"(<$=!==!AFGxrK   Nr   r  rJ   rK   rL   rN  rN    s0    $J $DLCE8 >B rK   rN  c                  >    e Zd ZdZdZdZdgZd Zd Zd Z	dd	dd
Z
y)RationalRiccatia  
    Gives general solutions to the first order Riccati differential
    equations that have atleast one rational particular solution.

    .. math :: y' = b_0(x) + b_1(x) y + b_2(x) y^2

    where `b_0`, `b_1` and `b_2` are rational functions of `x`
    with `b_2 \ne 0` (`b_2 = 0` would make it a Bernoulli equation).

    Examples
    ========

    >>> from sympy import Symbol, Function, dsolve, checkodesol
    >>> f = Function('f')
    >>> x = Symbol('x')

    >>> eq = -x**4*f(x)**2 + x**3*f(x).diff(x) + x**2*f(x) + 20
    >>> sol = dsolve(eq, hint="1st_rational_riccati")
    >>> sol
    Eq(f(x), (4*C1 - 5*x**9 - 4)/(x**2*(C1 + x**9 - 1)))
    >>> checkodesol(eq, sol)
    (True, 0)

    References
    ==========

    - Riccati ODE:  https://en.wikipedia.org/wiki/Riccati_equation
    - N. Thieu Vo - Rational and Algebraic Solutions of First-Order Algebraic ODEs:
      Algorithm 11, pp. 78 - https://www3.risc.jku.at/publications/download/risc_5387/PhDThesisThieu.pdf
    F1st_rational_riccatir   c                   t        d ||       ||      j                  |      g      }t        d ||       ||      j                  |      g      }t        d ||       ||      j                  |      g      }|||fS )Nb0rc   b1b2r  )rX   r   r   r]   r[  r\  r]  s          rL   r   zRationalRiccati._wilds  sq    $1qtyy| 45$1qtyy| 45$1qtyy| 45B|rK   c                p    | j                         \  }}}|j                  |      |z
  ||z  z
  ||dz  z  z
  S rS  r  )rX   r   r   r]   r[  r\  r]  s          rL   r   zRationalRiccati._equation  s;    ZZ\
BwwqzBB&BE11rK   c                L   | j                   j                  }| j                   j                  j                  }| j                   j                  }| j                   j                  }|dk7  ryt        |||      \  }}|sy|\  }}}	| j                         \  }
}}|
|||||	ix| _        }y)Nr   FT)r   rq   rT   rU   r]   r   r   r   )rX   rS   r   r   r]   rh   funcs_b0_b1_b2r[  r\  r]  s                rL   r   zRationalRiccati._matches  s    ))!!&&    &&A:$RA.uS#ZZ\
B%'b#r3$??ErK   Tr   c                   | j                         \  }}}| j                  j                  }| j                  j                  }t	        |||||d      S )NT)r  )r   r   rT   rU   r   )rX   r   r[  r\  r]  r   r   s          rL   r   z%RationalRiccati._get_general_solution  sM    %%'
B""  RBBt<<rK   Nr   )rF   rG   rH   rI   r   r   r]   r   r   r   r   rJ   rK   rL   rX  rX    s4    < L!DCE2" >B =rK   rX  c                  >    e Zd ZdZdZdZdgZd Zd Zd Z	dddd	Z
y
)"SecondNonlinearAutonomousConserveda<  
    Gives solution for the autonomous second order nonlinear
    differential equation of the form

    .. math :: f''(x) = g(f(x))

    The solution for this differential equation can be computed
    by multiplying by `f'(x)` and integrating on both sides,
    converting it into a first order differential equation.

    Examples
    ========

    >>> from sympy import Function, symbols, dsolve
    >>> f, g = symbols('f g', cls=Function)
    >>> x = symbols('x')

    >>> eq = f(x).diff(x, 2) - g(f(x))
    >>> dsolve(eq, simplify=False)
    [Eq(Integral(1/sqrt(C1 + 2*Integral(g(_u), _u)), (_u, f(x))), C2 + x),
    Eq(Integral(1/sqrt(C1 + 2*Integral(g(_u), _u)), (_u, f(x))), C2 - x)]

    >>> from sympy import exp, log
    >>> eq = f(x).diff(x, 2) - exp(f(x)) + log(f(x))
    >>> dsolve(eq, simplify=False)
    [Eq(Integral(1/sqrt(-2*_u*log(_u) + 2*_u + C1 + 2*exp(_u)), (_u, f(x))), C2 + x),
    Eq(Integral(1/sqrt(-2*_u*log(_u) + 2*_u + C1 + 2*exp(_u)), (_u, f(x))), C2 - x)]

    References
    ==========

    - https://eqworld.ipmnet.ru/en/solutions/ode/ode0301.pdf
    "2nd_nonlinear_autonomous_conservedTr   c           	     ~    t        dd ||      j                  |       ||      j                  |d      g      }|fS )Nfyr   r   rc   r  )rX   r   r   r]   ri  s        rL   r   z)SecondNonlinearAutonomousConserved._wilds<  s6    $AaDIIaL!A$))Aq/ BCvrK   c                R    | j                         d   }|j                  |d      |z   S )Nr   r   r  )rX   r   r   r]   ri  s        rL   r   z,SecondNonlinearAutonomousConserved._equation@  s&    ZZ\!_wwq!}r!!rK   c                .    | j                   j                  S rP   )r   r   r   s     rL   r   z*SecondNonlinearAutonomousConserved._verifyD  s    ---rK   r   c                  | j                         d   }| j                  j                  }| j                  j                  }t	        d      }|j                  ||      }| j                  j                  d      \  }}dt        ||      z  |z   }t        dt        |      z  ||f      }	t        |	||z         t        |	||z
        gS )Nr   r   r   r  r   )
r   r   rT   rU   r   r   r   r'   r!   r   )
rX   r   gr   r   r   r  C2insidelhss
             rL   r   z8SecondNonlinearAutonomousConserved._get_general_solutionG  s    q!""  #JFF2qM!!88Q8?BHQN"R'qf~2w/3QCa11rK   Nr   r  rJ   rK   rL   rf  rf    s5     B 0DLCE". >B 	2rK   rf  c                  >    e Zd ZdZd ZdZdgZd Zd Zd Z	ddd
dZ
y	)	Liouvillea  
    Solves 2nd order Liouville differential equations.

    The general form of a Liouville ODE is

    .. math:: \frac{d^2 y}{dx^2} + g(y) \left(\!
                \frac{dy}{dx}\!\right)^2 + h(x)
                \frac{dy}{dx}\text{.}

    The general solution is:

        >>> from sympy import Function, dsolve, Eq, pprint, diff
        >>> from sympy.abc import x
        >>> f, g, h = map(Function, ['f', 'g', 'h'])
        >>> genform = Eq(diff(f(x),x,x) + g(f(x))*diff(f(x),x)**2 +
        ... h(x)*diff(f(x),x), 0)
        >>> pprint(genform)
                          2                    2
                /d       \         d          d
        g(f(x))*|--(f(x))|  + h(x)*--(f(x)) + ---(f(x)) = 0
                \dx      /         dx           2
                                              dx
        >>> pprint(dsolve(genform, f(x), hint='Liouville_Integral'))
                                          f(x)
                  /                     /
                 |                     |
                 |     /               |     /
                 |    |                |    |
                 |  - | h(x) dx        |    | g(y) dy
                 |    |                |    |
                 |   /                 |   /
        C1 + C2* | e            dx +   |  e           dy = 0
                 |                     |
                /                     /

    Examples
    ========

    >>> from sympy import Function, dsolve, Eq, pprint
    >>> from sympy.abc import x
    >>> f = Function('f')
    >>> pprint(dsolve(diff(f(x), x, x) + diff(f(x), x)**2/f(x) +
    ... diff(f(x), x)/x, f(x), hint='Liouville'))
               ________________           ________________
    [f(x) = -\/ C1 + C2*log(x) , f(x) = \/ C1 + C2*log(x) ]

    References
    ==========

    - Goldstein and Braun, "Advanced Methods for the Solution of Differential
      Equations", pp. 98
    - https://www.maplesoft.com/support/help/Maple/view.aspx?path=odeadvisor/Liouville

    # indirect doctest

    Tr   c                   t        d ||      j                  |       ||      j                  |d      g      }t        d ||      j                  |      g      }t        d ||      j                  |      g      }|||fS )NrQ  r   rc   r   kr  )rX   r   r   r]   rQ  r   ru  s          rL   r   zLiouville._wilds  sl    qtyy|QqTYYq!_=>qtyy|n-qtyy|n-!QwrK   c                    | j                         \  }}}||j                  |d      z  ||j                  |      dz  z  z   ||j                  |      z  z   S rS  r  )rX   r   r   r]   rQ  r   ru  s          rL   r   zLiouville._equation  sO    
 **,1aA2771:q=01RWWQZ<??rK   c                   | j                         \  }}}t        d      | _        | j                  j                  }t        ||z        j                  || j                        | _        t        ||z        j                  || j                        | _        | j                  | j                  j                  v s|| j                  j                  v ryy)Nr  FT)
r   r   r  r   rU   r-   r   rn  hr   )rX   r   rQ  r   ru  r   s         rL   r   zLiouville._verify  s    ""$1as  !A###B/!A###B/66TVV(((A1D1D,DrK   r   c                  | j                         \  }}}| j                  j                  }| j                  j                  }| j                  j	                  d      \  }}t        t        t        | j                  | j                              | j                  d |f      }	t        |	|t        t        t        | j                  |             |      z  z   |z   d      }
|
gS )Nr   r  r   )r   r   rT   rU   r   r'   r   rn  r  r   rx  )rX   r   rQ  r   ru  r   r   r  ro  r   r  s              rL   r   zLiouville._get_general_solution  s    ""$1a""  !!88Q8?Bs8DFFDFF34tvvtR6HIS2hsHTVVQ,?+?'@!DDDrI1MyrK   Nr   r  rJ   rK   rL   rs  rs  S  s6    7p DLCE@ >B rK   rs  c                  D    e Zd ZdZdZdZdgZd Zd Zd Z	d Z
dd	dd
Zy)	Separableaa  
    Solves separable 1st order differential equations.

    This is any differential equation that can be written as `P(y)
    \tfrac{dy}{dx} = Q(x)`.  The solution can then just be found by
    rearranging terms and integrating: `\int P(y) \,dy = \int Q(x) \,dx`.
    This hint uses :py:meth:`sympy.simplify.simplify.separatevars` as its back
    end, so if a separable equation is not caught by this solver, it is most
    likely the fault of that function.
    :py:meth:`~sympy.simplify.simplify.separatevars` is
    smart enough to do most expansion and factoring necessary to convert a
    separable equation `F(x, y)` into the proper form `P(x)\cdot{}Q(y)`.  The
    general solution is::

        >>> from sympy import Function, dsolve, Eq, pprint
        >>> from sympy.abc import x
        >>> a, b, c, d, f = map(Function, ['a', 'b', 'c', 'd', 'f'])
        >>> genform = Eq(a(x)*b(f(x))*f(x).diff(x), c(x)*d(f(x)))
        >>> pprint(genform)
                     d
        a(x)*b(f(x))*--(f(x)) = c(x)*d(f(x))
                     dx
        >>> pprint(dsolve(genform, f(x), hint='separable_Integral'))
             f(x)
           /                  /
          |                  |
          |  b(y)            | c(x)
          |  ---- dy = C1 +  | ---- dx
          |  d(y)            | a(x)
          |                  |
         /                  /

    Examples
    ========

    >>> from sympy import Function, dsolve, Eq
    >>> from sympy.abc import x
    >>> f = Function('f')
    >>> pprint(dsolve(Eq(f(x)*f(x).diff(x) + x, 3*x*f(x)**2), f(x),
    ... hint='separable', simplify=False))
       /   2       \         2
    log\3*f (x) - 1/        x
    ---------------- = C1 + --
           6                2

    References
    ==========

    - M. Tenenbaum & H. Pollard, "Ordinary Differential Equations",
      Dover 1963, pp. 52

    # indirect doctest

    	separableTr   c                    t        d ||      j                  |       ||      j                  |d      g      }t        d ||      j                  |      g      }||fS NrQ  r   rc   r   r  rX   r   r   r]   rQ  r   s         rL   r   zSeparable._wilds  P    qtyy|QqTYYq!_=>qtyy|n-!trK   c                V    | j                         \  }}|||j                  |      z  z   S rP   r  rX   r   r   r]   rQ  r   s         rL   r   zSeparable._equation  r	  rK   c                   | j                         \  }}t        d      | _        | j                  j                  }t        |j                  || j                              }t        |j                  || j                              }t        |d|| j                  f      | _        t        |d|| j                  f      | _        | j                  r| j                  ryy)Nr  T)dictsymbolsF)	r   r   r  r   rU   r.   r   m1m2)rX   r   rQ  r   r   s        rL   r   zSeparable._verify  s    !1s  DFF+,DFF+,qta[Aqta[A77twwrK   c                    | j                   j                  }| j                   j                  }| j                  | j                  ||fS rP   )r   rT   rU   r  r  )rX   r   r   s      rL   _get_match_objectzSeparable._get_match_object  s;    ""  wwB&&rK   r   c               8   | j                         \  }}}}| j                  j                  d      \  }t        |d   || j                     z  || j                     z  | j                  d |f      }t        |t        |d    ||   z  ||   z  |      |z         }|gS )Nr   r  rg   )r  r   r   r'   r  r   )	rX   r   r  r  r   r   r  r   r  s	            rL   r   zSeparable._get_general_solution	  s    ..0B2  77A7>r'{2dff:-bj8	rS(BwK<1#5
1$ yrK   Nr   rF   rG   rH   rI   r   r   r]   r   r   r   r  r   rJ   rK   rL   r{  r{    s:    5l DLCE
 '
 >B rK   r{  c                  6    e Zd ZdZdZdZdgZd Zd Zd Z	d Z
y	)
SeparableReduceda7  
    Solves a differential equation that can be reduced to the separable form.

    The general form of this equation is

    .. math:: y' + (y/x) H(x^n y) = 0\text{}.

    This can be solved by substituting `u(y) = x^n y`.  The equation then
    reduces to the separable form `\frac{u'}{u (\mathrm{power} - H(u))} -
    \frac{1}{x} = 0`.

    The general solution is:

        >>> from sympy import Function, dsolve, pprint
        >>> from sympy.abc import x, n
        >>> f, g = map(Function, ['f', 'g'])
        >>> genform = f(x).diff(x) + (f(x)/x)*g(x**n*f(x))
        >>> pprint(genform)
                         / n     \
        d          f(x)*g\x *f(x)/
        --(f(x)) + ---------------
        dx                x
        >>> pprint(dsolve(genform, hint='separable_reduced'))
         n
        x *f(x)
          /
         |
         |         1
         |    ------------ dy = C1 + log(x)
         |    y*(n - g(y))
         |
         /

    See Also
    ========
    :obj:`sympy.solvers.ode.single.Separable`

    Examples
    ========

    >>> from sympy import dsolve, Function, pprint
    >>> from sympy.abc import x
    >>> f = Function('f')
    >>> d = f(x).diff(x)
    >>> eq = (x - x**2*f(x))*d - f(x)
    >>> dsolve(eq, hint='separable_reduced')
    [Eq(f(x), (1 - sqrt(C1*x**2 + 1))/x), Eq(f(x), (sqrt(C1*x**2 + 1) + 1)/x)]
    >>> pprint(dsolve(eq, hint='separable_reduced'))
                   ___________            ___________
                  /     2                /     2
            1 - \/  C1*x  + 1          \/  C1*x  + 1  + 1
    [f(x) = ------------------, f(x) = ------------------]
                    x                          x

    References
    ==========

    - Joel Moses, "Symbolic Integration - The Stormy Decade", Communications
      of the ACM, Volume 14, Number 8, August 1971, pp. 558
    separable_reducedTr   c                   |D ]  }|j                  |      st        |t              r+|j                         d   |k(  r|j                         d   c S ||k(  r|j                         d   c S | j	                  |j
                  |      c S  yr   )r   rQ   r   r:  _degreeri   )rX   r   r   vals       rL   r  zSeparableReduced._degreeT  s    
  	5Cwwqzc3'COO,=a,@A,EOO-a01AXOO-a01<<!44	5 rK   c                   t               }| j                  j                  }| j                  j                  }t	        d      | _        t        |t              r|j                  t              }nOt        |t              r|j                  t              }n)t        |t              r|j                  t              }n|h}|D ]  }|j                  |      s|j                  ||      \  }}| j                  |j                  || j
                        f|      | j                  |j                  || j
                        f| j
                        z  }	|j                  |	        |S )Nr  )setr   rT   rU   r   r  rQ   r	   r   r   r   r   r(  r  r   add)
rX   r   powsr   r   exprsrn   r   r   pows
             rL   _powerszSeparableReduced._powersc  s    u""  sdC JJsOEc"JJsOEc"JJsOEFE 	Cwwqz))!R01llAFF2tvv$6#91=dllAFFSUW[W]W]L^Kacgcici>jj		
 rK   c                   | j                         \  }}| j                  j                  }t        ||z  |z  |z        } |j                         \  }}t        |      }t        |      }| j                  |      }|j                  | j                  |             t        |      }t        |      dk(  r|d   t        k7  rt        d      | _        d| j                  i| _        |j                  ||d   z  |z  | j                        }|j                  ||d   z  |z  | j                        }||z  }|j                  }	t        |	      dk(  r?|	j!                         | j                  k(  r"| j                  j                  |d   |d       yyy)Nr   r   t)powerr   TF)r   r   rU   r-   as_numer_denomr   r  updaterG  r   r   r   r  r2r   r   pop)
rX   r   rz   rm   r   r*   demr  testfrees
             rL   r   zSeparableReduced._verifyz  sP   ##%S  !B$s(3,' )6((*SSkSk||C DLL%&Dzt9a<T!Wc\3ZDFDFFmDG((1d1g:b=$&&1C((1d1g:b=$&&1Cs7D$$D4yA~$((*"6$q'>?rK   c                   | j                   j                  }| j                   j                  }| j                  d   j	                  | j                  d   | j
                        }d| j
                  | j                  d   |z
  z  z  }| j
                  d|d|z  ddi}| j
                  ||dddi}||||| j                  d   z  |z  fS )Nr   r  r   r  r   rg   )r   rT   rU   r  r   r  )rX   r   r   r   ycoeffr  r  s          rL   r  z"SeparableReduced._get_match_object  s    ""  GGCLdggclDFF3DFFDGGG,q012ffaBqD'1-fffaGQ/2q!TWWW--b000rK   N)rF   rG   rH   rI   r   r   r]   r  r  r   r  rJ   rK   rL   r  r    s/    ;x DLCE.41rK   r  c                  D    e Zd ZdZdZdZdgZd Zd Zd Z	d Z
dd	dd
Zy)HomogeneousCoeffSubsDepDivIndepac  
    Solves a 1st order differential equation with homogeneous coefficients
    using the substitution `u_1 = \frac{\text{<dependent
    variable>}}{\text{<independent variable>}}`.

    This is a differential equation

    .. math:: P(x, y) + Q(x, y) dy/dx = 0

    such that `P` and `Q` are homogeneous and of the same order.  A function
    `F(x, y)` is homogeneous of order `n` if `F(x t, y t) = t^n F(x, y)`.
    Equivalently, `F(x, y)` can be rewritten as `G(y/x)` or `H(x/y)`.  See
    also the docstring of :py:meth:`~sympy.solvers.ode.homogeneous_order`.

    If the coefficients `P` and `Q` in the differential equation above are
    homogeneous functions of the same order, then it can be shown that the
    substitution `y = u_1 x` (i.e. `u_1 = y/x`) will turn the differential
    equation into an equation separable in the variables `x` and `u`.  If
    `h(u_1)` is the function that results from making the substitution `u_1 =
    f(x)/x` on `P(x, f(x))` and `g(u_2)` is the function that results from the
    substitution on `Q(x, f(x))` in the differential equation `P(x, f(x)) +
    Q(x, f(x)) f'(x) = 0`, then the general solution is::

        >>> from sympy import Function, dsolve, pprint
        >>> from sympy.abc import x
        >>> f, g, h = map(Function, ['f', 'g', 'h'])
        >>> genform = g(f(x)/x) + h(f(x)/x)*f(x).diff(x)
        >>> pprint(genform)
         /f(x)\    /f(x)\ d
        g|----| + h|----|*--(f(x))
         \ x  /    \ x  / dx
        >>> pprint(dsolve(genform, f(x),
        ... hint='1st_homogeneous_coeff_subs_dep_div_indep_Integral'))
                       f(x)
                       ----
                        x
                         /
                        |
                        |       -h(u1)
        log(x) = C1 +   |  ---------------- d(u1)
                        |  u1*h(u1) + g(u1)
                        |
                       /

    Where `u_1 h(u_1) + g(u_1) \ne 0` and `x \ne 0`.

    See also the docstrings of
    :obj:`~sympy.solvers.ode.single.HomogeneousCoeffBest` and
    :obj:`~sympy.solvers.ode.single.HomogeneousCoeffSubsIndepDivDep`.

    Examples
    ========

    >>> from sympy import Function, dsolve
    >>> from sympy.abc import x
    >>> f = Function('f')
    >>> pprint(dsolve(2*x*f(x) + (x**2 + f(x)**2)*f(x).diff(x), f(x),
    ... hint='1st_homogeneous_coeff_subs_dep_div_indep', simplify=False))
                          /          3   \
                          |3*f(x)   f (x)|
                       log|------ + -----|
                          |  x         3 |
                          \           x  /
    log(x) = log(C1) - -------------------
                                3

    References
    ==========

    - https://en.wikipedia.org/wiki/Homogeneous_differential_equation
    - M. Tenenbaum & H. Pollard, "Ordinary Differential Equations",
      Dover 1963, pp. 59

    # indirect doctest

    (1st_homogeneous_coeff_subs_dep_div_indepTr   c                    t        d ||      j                  |       ||      j                  |d      g      }t        d ||      j                  |      g      }||fS r~  r  r  s         rL   r   z&HomogeneousCoeffSubsDepDivIndep._wilds  r  rK   c                V    | j                         \  }}|||j                  |      z  z   S rP   r  r  s         rL   r   z)HomogeneousCoeffSubsDepDivIndep._equation  r	  rK   c                   | j                         \  | _        | _        t        d      | _        | j
                  j                  }t        | j                  j                  || j                              | _        t        | j                  j                  || j                              | _        t        | j                  || j                        }t        | j                  || j                        }||k(  rm|kt        d      | _
        t        | j                  | j                  | j                  z  z   j                  |d| j                  | j                  i            dk7  ryyyNr  r   r   r   TFr   rQ  r   r   r  r   rU   r.   r   homogeneous_orderr   r-   rX   r   r   orderaorderbs        rL   r   z'HomogeneousCoeffSubsDepDivIndep._verify  s    ))+s  dffkk"dff56dffkk"dff56"4661dff5"4661dff5V 23ZDF$&&-/55q!TVVTVV6LMNRSSrK   c           	         | j                   j                  }| j                   j                  }t        d      | _        d}d}| j
                  | j                  ||| j                  | j                  | j                  ||g	S Nu1r   	r   rT   rU   r   r  rQ  r   r   r  rX   r   r   xargyargs        rL   r  z1HomogeneousCoeffSubsDepDivIndep._get_match_object  f    ""  +AtvvtwwdKKrK   r   c          	        | j                         \	  }}}}}}}}	}
| j                  j                  d      \  }t        | |||z  z   z  j	                  |d||i      |d ||z  f      }t        t        t        |      |t        |      z         d      }|j	                  ||      j	                  |||
z
  f|||	z
  f||ff      }|gS Nr   r  T)force)r  r   r   r'   r   r/   r   r    rX   r   rQ  r   r   r   r   r  r  r  r  r  r   rK  r  s                  rL   r   z5HomogeneousCoeffSubsDepDivIndep._get_general_solution  s    ,0,B,B,D)1b!QAtT  77A7>RRT]  !Q2/r!t CFC#b'M2$?((2q/&&AH1t8}q"g'NOyrK   Nr   r  rJ   rK   rL   r  r    s<    KX 6DLCE
 L >B rK   r  c                  D    e Zd ZdZdZdZdgZd Zd Zd Z	d Z
dd	dd
Zy)HomogeneousCoeffSubsIndepDivDepa  
    Solves a 1st order differential equation with homogeneous coefficients
    using the substitution `u_2 = \frac{\text{<independent
    variable>}}{\text{<dependent variable>}}`.

    This is a differential equation

    .. math:: P(x, y) + Q(x, y) dy/dx = 0

    such that `P` and `Q` are homogeneous and of the same order.  A function
    `F(x, y)` is homogeneous of order `n` if `F(x t, y t) = t^n F(x, y)`.
    Equivalently, `F(x, y)` can be rewritten as `G(y/x)` or `H(x/y)`.  See
    also the docstring of :py:meth:`~sympy.solvers.ode.homogeneous_order`.

    If the coefficients `P` and `Q` in the differential equation above are
    homogeneous functions of the same order, then it can be shown that the
    substitution `x = u_2 y` (i.e. `u_2 = x/y`) will turn the differential
    equation into an equation separable in the variables `y` and `u_2`.  If
    `h(u_2)` is the function that results from making the substitution `u_2 =
    x/f(x)` on `P(x, f(x))` and `g(u_2)` is the function that results from the
    substitution on `Q(x, f(x))` in the differential equation `P(x, f(x)) +
    Q(x, f(x)) f'(x) = 0`, then the general solution is:

    >>> from sympy import Function, dsolve, pprint
    >>> from sympy.abc import x
    >>> f, g, h = map(Function, ['f', 'g', 'h'])
    >>> genform = g(x/f(x)) + h(x/f(x))*f(x).diff(x)
    >>> pprint(genform)
     / x  \    / x  \ d
    g|----| + h|----|*--(f(x))
     \f(x)/    \f(x)/ dx
    >>> pprint(dsolve(genform, f(x),
    ... hint='1st_homogeneous_coeff_subs_indep_div_dep_Integral'))
                 x
                ----
                f(x)
                  /
                 |
                 |       -g(u1)
                 |  ---------------- d(u1)
                 |  u1*g(u1) + h(u1)
                 |
                /
    <BLANKLINE>
    f(x) = C1*e

    Where `u_1 g(u_1) + h(u_1) \ne 0` and `f(x) \ne 0`.

    See also the docstrings of
    :obj:`~sympy.solvers.ode.single.HomogeneousCoeffBest` and
    :obj:`~sympy.solvers.ode.single.HomogeneousCoeffSubsDepDivIndep`.

    Examples
    ========

    >>> from sympy import Function, pprint, dsolve
    >>> from sympy.abc import x
    >>> f = Function('f')
    >>> pprint(dsolve(2*x*f(x) + (x**2 + f(x)**2)*f(x).diff(x), f(x),
    ... hint='1st_homogeneous_coeff_subs_indep_div_dep',
    ... simplify=False))
                             /   2     \
                             |3*x      |
                          log|----- + 1|
                             | 2       |
                             \f (x)    /
    log(f(x)) = log(C1) - --------------
                                3

    References
    ==========

    - https://en.wikipedia.org/wiki/Homogeneous_differential_equation
    - M. Tenenbaum & H. Pollard, "Ordinary Differential Equations",
      Dover 1963, pp. 59

    # indirect doctest

    (1st_homogeneous_coeff_subs_indep_div_depTr   c                    t        d ||      j                  |       ||      j                  |d      g      }t        d ||      j                  |      g      }||fS r~  r  r  s         rL   r   z&HomogeneousCoeffSubsIndepDivDep._wildsn  r  rK   c                V    | j                         \  }}|||j                  |      z  z   S rP   r  r  s         rL   r   z)HomogeneousCoeffSubsIndepDivDep._equations  r	  rK   c                   | j                         \  | _        | _        t        d      | _        | j
                  j                  }t        | j                  j                  || j                              | _        t        | j                  j                  || j                              | _        t        | j                  || j                        }t        | j                  || j                        }||k(  rm|kt        d      | _
        t        | j                  | j                  | j                  z  z   j                  || j                  | j                  di            dk7  ryyyr  r  r  s        rL   r   z'HomogeneousCoeffSubsIndepDivDep._verifyw  s    ))+s  dffkk"dff56dffkk"dff56"4661dff5"4661dff5V 23ZDF$&&-/55q$&&$&&!6LMNRSSrK   c           	         | j                   j                  }| j                   j                  }t        d      | _        d}d}| j
                  | j                  ||| j                  | j                  | j                  ||g	S r  r  r  s        rL   r  z1HomogeneousCoeffSubsIndepDivDep._get_match_object  r  rK   r   c          
        | j                         \	  }}}}}}}}	}
| j                  j                  d      \  }t        t	        | |||z  z   z  j                  |||di            |d ||z  f      }t        t        t        |      |t        |      z         d      }|j                  ||      j                  |||
z
  f|||	z
  f||ff      }|gS r  )	r  r   r   r'   r-   r   r/   r   r    r  s                  rL   r   z5HomogeneousCoeffSubsIndepDivDep._get_general_solution  s    ,0,B,B,D)1b!QAtT  77A7>x!QAX 4 4aQ] CDr4QRSUQUFVWCGS3r7]34@((2q/&&AH1t8}q"g'NOyrK   Nr   r  rJ   rK   rL   r  r    s<    N^ 6DLCE
 L >B rK   r  c                  2    e Zd ZdZdZdZdgZd Zddd
dZy	)HomogeneousCoeffBesta  
    Returns the best solution to an ODE from the two hints
    ``1st_homogeneous_coeff_subs_dep_div_indep`` and
    ``1st_homogeneous_coeff_subs_indep_div_dep``.

    This is as determined by :py:meth:`~sympy.solvers.ode.ode.ode_sol_simplicity`.

    See the
    :obj:`~sympy.solvers.ode.single.HomogeneousCoeffSubsIndepDivDep`
    and
    :obj:`~sympy.solvers.ode.single.HomogeneousCoeffSubsDepDivIndep`
    docstrings for more information on these hints.  Note that there is no
    ``ode_1st_homogeneous_coeff_best_Integral`` hint.

    Examples
    ========

    >>> from sympy import Function, dsolve, pprint
    >>> from sympy.abc import x
    >>> f = Function('f')
    >>> pprint(dsolve(2*x*f(x) + (x**2 + f(x)**2)*f(x).diff(x), f(x),
    ... hint='1st_homogeneous_coeff_best', simplify=False))
                             /   2     \
                             |3*x      |
                          log|----- + 1|
                             | 2       |
                             \f (x)    /
    log(f(x)) = log(C1) - --------------
                                3

    References
    ==========

    - https://en.wikipedia.org/wiki/Homogeneous_differential_equation
    - M. Tenenbaum & H. Pollard, "Ordinary Differential Equations",
      Dover 1963, pp. 59

    # indirect doctest

    1st_homogeneous_coeff_bestFr   c                ^    t         j                  | |      rt        j                  | |      ryy)NTF)r  r   r  r   s     rL   r   zHomogeneousCoeffBest._verify  s*    *224<A`AhAhimoqArrK   Tr   c               <   t         j                  |       }t        j                  |       }| j                  j                  |rHt        | j                  j                  g|d }t        | j                  j                  g|d }t        ||gfd      S )Nr  r  c                *    t        | t               S )N)
trysolving)ode_sol_simplicityr-   )r   r   s    rL   r   z<HomogeneousCoeffBest._get_general_solution.<locals>.<lambda>  s    /A!RX`T`/a rK   )key)r  r   r  r   rT   odesimprS   min)rX   r   sol1sol2r   s       @rL   r   z*HomogeneousCoeffBest._get_general_solution  s     /DDTJ.DDTJ""4++..ffrf;efD4++..ffrf;efDD$<%abbrK   Nr   )	rF   rG   rH   rI   r   r   r]   r   r   rJ   rK   rL   r  r    s,    'P (DLCE
 >B 
crK   r  c                  <    e Zd ZdZdZdZdgZd Zd Zd Z	d Z
d	 Zy
)LinearCoefficientsaa  
    Solves a differential equation with linear coefficients.

    The general form of a differential equation with linear coefficients is

    .. math:: y' + F\left(\!\frac{a_1 x + b_1 y + c_1}{a_2 x + b_2 y +
                c_2}\!\right) = 0\text{,}

    where `a_1`, `b_1`, `c_1`, `a_2`, `b_2`, `c_2` are constants and `a_1 b_2
    - a_2 b_1 \ne 0`.

    This can be solved by substituting:

    .. math:: x = x' + \frac{b_2 c_1 - b_1 c_2}{a_2 b_1 - a_1 b_2}

              y = y' + \frac{a_1 c_2 - a_2 c_1}{a_2 b_1 - a_1
                  b_2}\text{.}

    This substitution reduces the equation to a homogeneous differential
    equation.

    See Also
    ========
    :obj:`sympy.solvers.ode.single.HomogeneousCoeffBest`
    :obj:`sympy.solvers.ode.single.HomogeneousCoeffSubsIndepDivDep`
    :obj:`sympy.solvers.ode.single.HomogeneousCoeffSubsDepDivIndep`

    Examples
    ========

    >>> from sympy import dsolve, Function, pprint
    >>> from sympy.abc import x
    >>> f = Function('f')
    >>> df = f(x).diff(x)
    >>> eq = (x + f(x) + 1)*df + (f(x) - 6*x + 1)
    >>> dsolve(eq, hint='linear_coefficients')
    [Eq(f(x), -x - sqrt(C1 + 7*x**2) - 1), Eq(f(x), -x + sqrt(C1 + 7*x**2) - 1)]
    >>> pprint(dsolve(eq, hint='linear_coefficients'))
                      ___________                     ___________
                   /         2                     /         2
    [f(x) = -x - \/  C1 + 7*x   - 1, f(x) = -x + \/  C1 + 7*x   - 1]


    References
    ==========

    - Joel Moses, "Symbolic Integration - The Stormy Decade", Communications
      of the ACM, Volume 14, Number 8, August 1971, pp. 558
    linear_coefficientsTr   c                    t        d ||      j                  |       ||      j                  |d      g      }t        d ||      j                  |      g      }||fS r~  r  r  s         rL   r   zLinearCoefficients._wilds  r  rK   c                V    | j                         \  }}|||j                  |      z  z   S rP   r  r  s         rL   r   zLinearCoefficients._equation  r	  rK   c                J   | j                         \  | _        | _        | j                         \  }}| j                  | j                  z  }| j                  j
                  }| j                  ||      }|r|\  | _        | _        t        d      }t        d      }t        d      | _
        | j                  j                  j                  |j                  |      |f||ff      }	||| j                  z   f||| j                  z   f||j                  |      f||ff}
t        |	j                  |
            }	t        t!        |	      |j                  |      |g      j#                  ||j                  |      z  |z         }|r||   ||   c| _        | _        t%        | j                  ||      }t%        | j                  ||      }||k(  rY|W| j                  j                  || j                        | _        | j                  j                  || j                        | _        yyyy )Nr   r  r  TF)r   rQ  r   r   r   rU   _linear_coeff_matchr  r  r   r  rS   r   r   r-   r,   r   rh   r  )rX   r   rb   r-  Fr   rW   r   r  dummy_eqrepsr  orderdorderes                 rL   r   zLinearCoefficients._verify  s   ))+zz|1FF466M  ))!R0#) DItyc
Ac
A3ZDF''**//"''!*a2q'0JKHDII&A		M(:Q
OaQSWUDd 34H)BGGAJ+;<BB1RWWQZ<RSCSTB!#A1*4661b9*4661b9V#(:!VV[[TVV4DF!VV[[TVV4DF) rK   c                   |j                   |j                  d   fdfd|j                  t              D cg c]R  }|j                   k7  st	        |j                        dk(  r(|j                  d   j
                  s|j                  d   T c}xs |h} |j                               r<t        fd|D              r&\  }}}}}	}
}|	|z  ||
z  z
  |z  ||
z  ||z  z
  |z  fS yyc c}w )a  
        Helper function to match hint ``linear_coefficients``.

        Matches the expression to the form `(a_1 x + b_1 f(x) + c_1)/(a_2 x + b_2
        f(x) + c_2)` where the following conditions hold:

        1. `a_1`, `b_1`, `c_1`, `a_2`, `b_2`, `c_2` are Rationals;
        2. `c_1` or `c_2` are not equal to zero;
        3. `a_2 b_1 - a_1 b_2` is not equal to zero.

        Return ``xarg``, ``yarg`` where

        1. ``xarg`` = `(b_2 c_1 - b_1 c_2)/(a_2 b_1 - a_1 b_2)`
        2. ``yarg`` = `(a_1 c_2 - a_2 c_1)/(a_2 b_1 - a_1 b_2)`


        Examples
        ========

        >>> from sympy import Function, sin
        >>> from sympy.abc import x
        >>> from sympy.solvers.ode.single import LinearCoefficients
        >>> f = Function('f')
        >>> eq = (-25*f(x) - 8*x + 62)/(4*f(x) + 11*x - 11)
        >>> obj = LinearCoefficients(eq)
        >>> obj._linear_coeff_match(eq, f(x))
        (1/9, 22/9)
        >>> eq = sin((-5*f(x) - 8*x + 6)/(4*f(x) + x - 1))
        >>> obj = LinearCoefficients(eq)
        >>> obj._linear_coeff_match(eq, f(x))
        (19/27, 2/27)
        >>> eq = sin(f(x)/x)
        >>> obj = LinearCoefficients(eq)
        >>> obj._linear_coeff_match(eq, f(x))

        r   c                ,   t        |       } | j                         d      d   }|j                  sy| j                        }|j                  sy| j                               }|j                  sy| |z  |       z  z   |z   k(  r|||fS y)z
            Internal function of _linear_coeff_match
            that returns Rationals a, b, c
            if eq is a*x + b*f(x) + c, else None.
            Tr&  r   N)r   r(  is_Rationalrg   )rS   r   rb   r-  r   r   s       rL   abcz3LinearCoefficients._linear_coeff_match.<locals>.abcX  s     "B!!!QqT$!7:A==A==1A==QqS1QqT6\A%%!Qw &rK   c                    | j                         j                         \  }} 
|      }|3|\  }}} 
|      }|"|\  }}}	||z  ||z  z
  }|s|	r|r	||||||	|fS yyyy)a!  
            Internal function of _linear_coeff_match that returns Rationals a1,
            b1, c1, a2, b2, c2 and a2*b1 - a1*b2 of the expression (a1*x + b1*f(x)
            + c1)/(a2*x + b2*f(x) + c2) if one of c1 or c2 and a2*b1 - a1*b2 is
            non-zero, else None.
            N)togetherr  )rn   r   rQ  r  a1r\  re   a2r]  c2r  s             rL   rh   z5LinearCoefficients._linear_coeff_match.<locals>.matchk  s     <<>002DAqAA}
BF=!"JBB22Aba!2r2r2q88 '(b ! rK   r   c              3  4   K   | ]  } |      k(    y wrP   rJ   )r   mir  rh   s     rL   r   z9LinearCoefficients._linear_coeff_match.<locals>.<genexpr>  s     2"eBi2o2s   N)rT   ri   r   r   r   is_Functionr  all)rX   r   rT   fir  r  r\  re   r  r]  r  denomr  r   r  rh   r   s               @@@@@rL   r  z&LinearCoefficients._linear_coeff_match1  s    J IIIIaL	&	9$ #'**X"6 >B"''Q,LAbggaj&<&< WWQZ > HBF 	
1557^#222,.)BBBErEBrEM5(2b52b5=%*??? 32>s   C7AC7c           	        | j                   j                  }| j                   j                  }t        d      | _        t        d      }| j
                  | j                  |||| j                  | j                  | j                  | j                  g	S )Nr  r   )
r   rT   rU   r   r  rQ  r   r  r  r  )rX   r   r   r   s       rL   r  z$LinearCoefficients._get_match_object  si    ""  +#JAq$''466499diiPPrK   N)rF   rG   rH   rI   r   r   r]   r   r   r   r  r  rJ   rK   rL   r  r    s8    0b !DLCE
 8Q@fQrK   r  c                  ,    e Zd ZdZdZdZd Zddd	dZy)
NthOrderReduciblea;  
    Solves ODEs that only involve derivatives of the dependent variable using
    a substitution of the form `f^n(x) = g(x)`.

    For example any second order ODE of the form `f''(x) = h(f'(x), x)` can be
    transformed into a pair of 1st order ODEs `g'(x) = h(g(x), x)` and
    `f'(x) = g(x)`. Usually the 1st order ODE for `g` is easier to solve. If
    that gives an explicit solution for `g` then `f` is found simply by
    integration.


    Examples
    ========

    >>> from sympy import Function, dsolve, Eq
    >>> from sympy.abc import x
    >>> f = Function('f')
    >>> eq = Eq(x*f(x).diff(x)**2 + f(x).diff(x, 2), 0)
    >>> dsolve(eq, f(x), hint='nth_order_reducible')
    ... # doctest: +NORMALIZE_WHITESPACE
    Eq(f(x), C1 - sqrt(-1/C2)*log(-C2*sqrt(-1/C2) + x) + sqrt(-1/C2)*log(C2*sqrt(-1/C2) + x))

    nth_order_reducibleFc                ~   | j                   j                  }| j                   j                  }| j                   j                  }	 t	        |j
                        dk(  sJ |j                  t              D cg c]8  }|j                  |k(  r't	        |j                        dk(  r|j                  d   : }}|D cg c]  \  }}||k(  s| }}}t	        |      dk  ryt        |      | _        t               }	|j                  |j                  || j                        |	      j                  |      ryyc c}w c c}}w )Nr   r   r   FT)r   r`   rT   rU   r   ri   r   r   r   variable_countr  smallestr   r   r   r   )
rX   rS   rT   r   rQ  vcr   r   ordsDs
             rL   r   zNthOrderReducible._matches  s   
 --$$  	 499~"""+-88J+? >avv~#a&6&6"71"< q! > > +daAF++t9q=D	G77499Q.266t<>+s   5=D49D9D9Tr   c                  | j                   j                  }| j                   j                  j                  }| j                   j                  }| j                  }|j                  t              D cg c]  }|j                   }}	 t               j                  }||vrt        |      }	n% ||      j                  ||      }
|j                  |
 |	|            }t        | |	|            }t        |t              s|g}g }|D ];  }t        |j                   |	|      |
       ||            }|j                  |       = |S c c}w rP   )r   rS   rT   rU   r  r   r   namer   r   r   r   rF  rQ   rG  r;  )rX   r   rS   r   r   r   rb   namesr  rn  r   geqgsolfsolgsolifsolis                   rL   r   z'NthOrderReducible._get_general_solution  s"     !!&&  MM!#,!78A887<<D5 TN	 
 aDIIaOgga1c1Q4 $%6D  	E5::adA.!5EKK	 ' 9s   0ENr   rL  rJ   rK   rL   r  r    s#    . !DL6 >B rK   r  c                  ,    e Zd ZdZdZdZd ZddddZy)	SecondHypergeometrica  
    Solves 2nd order linear differential equations.

    It computes special function solutions which can be expressed using the
    2F1, 1F1 or 0F1 hypergeometric functions.

    .. math:: y'' + A(x) y' + B(x) y = 0\text{,}

    where `A` and `B` are rational functions.

    These kinds of differential equations have solution of non-Liouvillian form.

    Given linear ODE can be obtained from 2F1 given by

    .. math:: (x^2 - x) y'' + ((a + b + 1) x - c) y' + b a y = 0\text{,}

    where {a, b, c} are arbitrary constants.

    Notes
    =====

    The algorithm should find any solution of the form

    .. math:: y = P(x) _pF_q(..; ..;\frac{\alpha x^k + \beta}{\gamma x^k + \delta})\text{,}

    where pFq is any of 2F1, 1F1 or 0F1 and `P` is an "arbitrary function".
    Currently only the 2F1 case is implemented in SymPy but the other cases are
    described in the paper and could be implemented in future (contributions
    welcome!).


    Examples
    ========

    >>> from sympy import Function, dsolve, pprint
    >>> from sympy.abc import x
    >>> f = Function('f')
    >>> eq = (x*x - x)*f(x).diff(x,2) + (5*x - 1)*f(x).diff(x) + 4*f(x)
    >>> pprint(dsolve(eq, f(x), '2nd_hypergeometric'))
                                        _
           /        /           4  \\  |_  /-1, -1 |  \
           |C1 + C2*|log(x) + -----||* |   |       | x|
           \        \         x + 1// 2  1 \  1    |  /
    f(x) = --------------------------------------------
                                    3
                             (x - 1)


    References
    ==========

    - "Non-Liouvillian solutions for second order linear ODEs" by L. Chan, E.S. Cheb-Terrab

    2nd_hypergeometricTc                d   | j                   j                  }| j                   j                  }t        ||      }d | _        |rb|\  }}t        |||      }|rN|d   dk(  rFt        |d   |d   |d   |      | _        | j                  | j                  j                  ||d       | j                  d uS )Ntype2F1I0ru  
sing_point)AB)r   r`   rT   r;   match_objectr8   r9   r  )rX   rS   rT   rl   r  r  rQ  s          rL   r   zSecondHypergeometric._matches  s    --$$$R. DAq*1a6AV9%(DQtWaPSfVWXdVegk(lD%((4))00aQ@  ,,rK   r   c                   | j                   j                  }| j                   j                  }| j                  d   dk(  r6t	        ||| j                        }|t        dt        |      z   dz   dz         gS )Nr  r  rD  rE  z the hypergeometric method)r   rS   rT   r	  r:   r   r   )rX   r   rS   rT   rK  s        rL   r   z*SecondHypergeometric._get_general_solution(  s      $$V$-,Rt7H7HIC{)*:SW*DG]*]2+3 4 4 urK   Nr   rL  rJ   rK   rL   r   r     s$    5l  DL-  >B 	rK   r   c                  ,    e Zd ZdZdZdZd Zddd	dZy)
!NthLinearConstantCoeffHomogeneousa
  
    Solves an `n`\th order linear homogeneous differential equation with
    constant coefficients.

    This is an equation of the form

    .. math:: a_n f^{(n)}(x) + a_{n-1} f^{(n-1)}(x) + \cdots + a_1 f'(x)
                + a_0 f(x) = 0\text{.}

    These equations can be solved in a general manner, by taking the roots of
    the characteristic equation `a_n m^n + a_{n-1} m^{n-1} + \cdots + a_1 m +
    a_0 = 0`.  The solution will then be the sum of `C_n x^i e^{r x}` terms,
    for each where `C_n` is an arbitrary constant, `r` is a root of the
    characteristic equation and `i` is one of each from 0 to the multiplicity
    of the root - 1 (for example, a root 3 of multiplicity 2 would create the
    terms `C_1 e^{3 x} + C_2 x e^{3 x}`).  The exponential is usually expanded
    for complex roots using Euler's equation `e^{I x} = \cos(x) + I \sin(x)`.
    Complex roots always come in conjugate pairs in polynomials with real
    coefficients, so the two roots will be represented (after simplifying the
    constants) as `e^{a x} \left(C_1 \cos(b x) + C_2 \sin(b x)\right)`.

    If SymPy cannot find exact roots to the characteristic equation, a
    :py:class:`~sympy.polys.rootoftools.ComplexRootOf` instance will be return
    instead.

    >>> from sympy import Function, dsolve
    >>> from sympy.abc import x
    >>> f = Function('f')
    >>> dsolve(f(x).diff(x, 5) + 10*f(x).diff(x) - 2*f(x), f(x),
    ... hint='nth_linear_constant_coeff_homogeneous')
    ... # doctest: +NORMALIZE_WHITESPACE
    Eq(f(x), C5*exp(x*CRootOf(_x**5 + 10*_x - 2, 0))
    + (C1*sin(x*im(CRootOf(_x**5 + 10*_x - 2, 1)))
    + C2*cos(x*im(CRootOf(_x**5 + 10*_x - 2, 1))))*exp(x*re(CRootOf(_x**5 + 10*_x - 2, 1)))
    + (C3*sin(x*im(CRootOf(_x**5 + 10*_x - 2, 3)))
    + C4*cos(x*im(CRootOf(_x**5 + 10*_x - 2, 3))))*exp(x*re(CRootOf(_x**5 + 10*_x - 2, 3))))

    Note that because this method does not involve integration, there is no
    ``nth_linear_constant_coeff_homogeneous_Integral`` hint.

    Examples
    ========

    >>> from sympy import Function, dsolve, pprint
    >>> from sympy.abc import x
    >>> f = Function('f')
    >>> pprint(dsolve(f(x).diff(x, 4) + 2*f(x).diff(x, 3) -
    ... 2*f(x).diff(x, 2) - 6*f(x).diff(x) + 5*f(x), f(x),
    ... hint='nth_linear_constant_coeff_homogeneous'))
                        x                            -2*x
    f(x) = (C1 + C2*x)*e  + (C3*sin(x) + C4*cos(x))*e

    References
    ==========

    - https://en.wikipedia.org/wiki/Linear_differential_equation section:
      Nonhomogeneous_equation_with_constant_coefficients
    - M. Tenenbaum & H. Pollard, "Ordinary Differential Equations",
      Dover 1963, pp. 211

    # indirect doctest

    %nth_linear_constant_coeff_homogeneousFc                x     j                   j                  } j                   j                  } j                   j                  } j                   j                   j                   j                  |||       _        |r< j                  r0t         fd j                  D              s j                  d   syyy)Nc              3  f   K   | ](  }|d k\  s	j                   |   j                         * ywr   Nrl   r   r   r~   rX   r   s     rL   r   z=NthLinearConstantCoeffHomogeneous._matches.<locals>.<genexpr>}  )     'SQAQRFq	a(8'S   
1#1r   TFr   ro   rT   r]   rU   r   rl   r   rX   rS   rT   r]   r   s   `   @rL   r   z*NthLinearConstantCoeffHomogeneous._matchesw  s    00$$  &&  !!99"dEJTVVC'S$&&'S$S66":rK   Tr   c               r   | j                   j                  }| j                   j                  }t        | j                  ||      \  }}| j                   j                  t        |            }t        t        ||      D cg c]
  \  }}||z   c}} }	t        ||	      }	|rt        |	g||      }	|	gS c c}}w Nr  )r   rT   r]   r=   rl   r   r   r	   zipr   rB   )
rX   r   r   r]   r?  collectterms	constantsr~   jr  s
             rL   r   z7NthLinearConstantCoeffHomogeneous._get_general_solution  s    ""  &&?ER|$$;;E
;K	s9e'<=VaQqS=>"d|&vr<@Dv >s    B3
Nr   rL  rJ   rK   rL   r  r  4  s$    >~ 3DL >B rK   r  c                  ,    e Zd ZdZdZdZd ZddddZy)	+NthLinearConstantCoeffVariationOfParametersa
  
    Solves an `n`\th order linear differential equation with constant
    coefficients using the method of variation of parameters.

    This method works on any differential equations of the form

    .. math:: f^{(n)}(x) + a_{n-1} f^{(n-1)}(x) + \cdots + a_1 f'(x) + a_0
                f(x) = P(x)\text{.}

    This method works by assuming that the particular solution takes the form

    .. math:: \sum_{x=1}^{n} c_i(x) y_i(x)\text{,}

    where `y_i` is the `i`\th solution to the homogeneous equation.  The
    solution is then solved using Wronskian's and Cramer's Rule.  The
    particular solution is given by

    .. math:: \sum_{x=1}^n \left( \int \frac{W_i(x)}{W(x)} \,dx
                \right) y_i(x) \text{,}

    where `W(x)` is the Wronskian of the fundamental system (the system of `n`
    linearly independent solutions to the homogeneous equation), and `W_i(x)`
    is the Wronskian of the fundamental system with the `i`\th column replaced
    with `[0, 0, \cdots, 0, P(x)]`.

    This method is general enough to solve any `n`\th order inhomogeneous
    linear differential equation with constant coefficients, but sometimes
    SymPy cannot simplify the Wronskian well enough to integrate it.  If this
    method hangs, try using the
    ``nth_linear_constant_coeff_variation_of_parameters_Integral`` hint and
    simplifying the integrals manually.  Also, prefer using
    ``nth_linear_constant_coeff_undetermined_coefficients`` when it
    applies, because it does not use integration, making it faster and more
    reliable.

    Warning, using simplify=False with
    'nth_linear_constant_coeff_variation_of_parameters' in
    :py:meth:`~sympy.solvers.ode.dsolve` may cause it to hang, because it will
    not attempt to simplify the Wronskian before integrating.  It is
    recommended that you only use simplify=False with
    'nth_linear_constant_coeff_variation_of_parameters_Integral' for this
    method, especially if the solution to the homogeneous equation has
    trigonometric functions in it.

    Examples
    ========

    >>> from sympy import Function, dsolve, pprint, exp, log
    >>> from sympy.abc import x
    >>> f = Function('f')
    >>> pprint(dsolve(f(x).diff(x, 3) - 3*f(x).diff(x, 2) +
    ... 3*f(x).diff(x) - f(x) - exp(x)*log(x), f(x),
    ... hint='nth_linear_constant_coeff_variation_of_parameters'))
           /       /       /     x*log(x)   11*x\\\  x
    f(x) = |C1 + x*|C2 + x*|C3 + -------- - ----|||*e
           \       \       \        6        36 ///

    References
    ==========

    - https://en.wikipedia.org/wiki/Variation_of_parameters
    - https://planetmath.org/VariationOfParameters
    - M. Tenenbaum & H. Pollard, "Ordinary Differential Equations",
      Dover 1963, pp. 233

    # indirect doctest

    1nth_linear_constant_coeff_variation_of_parametersTc                x     j                   j                  } j                   j                  } j                   j                  } j                   j                   j                   j                  |||       _        |r< j                  r0t         fd j                  D              s j                  d   ryyy)Nc              3  f   K   | ](  }|d k\  s	j                   |   j                         * ywr  r  r  s     rL   r   zGNthLinearConstantCoeffVariationOfParameters._matches.<locals>.<genexpr>  r  r  r   TFr  r  s   `   @rL   r   z4NthLinearConstantCoeffVariationOfParameters._matches  s    00$$  &&  !!99"dEJTVVC'S$&&'S$SvvbzrK   r   c          	     D   | j                   j                  }| j                   j                  j                  }| j                   j                  }| j                   j                  }t        | j                   ||      |      \  }}| j                   j                  t        |            }t        t        ||      D 	
cg c]
  \  }	}
|	|
z   c}
}	 }t         ||      |      }t        | ||      |||| j                  |      }|rt        |g ||      |      }|gS c c}
}	w r  )r   ro   rT   rU   r]   r=   rl   r   r   r	   r  r   r?   rB   )rX   r   rS   r   r   r]   r?  r  r  r~   r  homogen_sols               rL   r   zANthLinearConstantCoeffVariationOfParameters._get_general_solution  s    00!!&&    &&?!eT|$$;;E
;K	c)U.CDFQAaCDE1{+4R1ukSXZ^Z`Z`bop-{mQqT<PK} Es   <D
Nr   rL  rJ   rK   rL   r  r    s%    CH ?DL >B rK   r  c                  ,    e Zd ZdZdZdZd Zddd	dZy)
.NthLinearConstantCoeffUndeterminedCoefficientsa	  
    Solves an `n`\th order linear differential equation with constant
    coefficients using the method of undetermined coefficients.

    This method works on differential equations of the form

    .. math:: a_n f^{(n)}(x) + a_{n-1} f^{(n-1)}(x) + \cdots + a_1 f'(x)
                + a_0 f(x) = P(x)\text{,}

    where `P(x)` is a function that has a finite number of linearly
    independent derivatives.

    Functions that fit this requirement are finite sums functions of the form
    `a x^i e^{b x} \sin(c x + d)` or `a x^i e^{b x} \cos(c x + d)`, where `i`
    is a non-negative integer and `a`, `b`, `c`, and `d` are constants.  For
    example any polynomial in `x`, functions like `x^2 e^{2 x}`, `x \sin(x)`,
    and `e^x \cos(x)` can all be used.  Products of `\sin`'s and `\cos`'s have
    a finite number of derivatives, because they can be expanded into `\sin(a
    x)` and `\cos(b x)` terms.  However, SymPy currently cannot do that
    expansion, so you will need to manually rewrite the expression in terms of
    the above to use this method.  So, for example, you will need to manually
    convert `\sin^2(x)` into `(1 + \cos(2 x))/2` to properly apply the method
    of undetermined coefficients on it.

    This method works by creating a trial function from the expression and all
    of its linear independent derivatives and substituting them into the
    original ODE.  The coefficients for each term will be a system of linear
    equations, which are be solved for and substituted, giving the solution.
    If any of the trial functions are linearly dependent on the solution to
    the homogeneous equation, they are multiplied by sufficient `x` to make
    them linearly independent.

    Examples
    ========

    >>> from sympy import Function, dsolve, pprint, exp, cos
    >>> from sympy.abc import x
    >>> f = Function('f')
    >>> pprint(dsolve(f(x).diff(x, 2) + 2*f(x).diff(x) + f(x) -
    ... 4*exp(-x)*x**2 + cos(2*x), f(x),
    ... hint='nth_linear_constant_coeff_undetermined_coefficients'))
           /       /      3\\
           |       |     x ||  -x   4*sin(2*x)   3*cos(2*x)
    f(x) = |C1 + x*|C2 + --||*e   - ---------- + ----------
           \       \     3 //           25           25

    References
    ==========

    - https://en.wikipedia.org/wiki/Method_of_undetermined_coefficients
    - M. Tenenbaum & H. Pollard, "Ordinary Differential Equations",
      Dover 1963, pp. 221

    # indirect doctest

    3nth_linear_constant_coeff_undetermined_coefficientsFc                     j                   j                  } j                   j                  } j                   j                  } j                   j                   j                   j                  |||       _        d}|r j                  rtt         fd j                  D              sU j                  d   rFt        | j                  d          }t         j                  d   ||      }|d   r|d    _
        d}|S )NFc              3  f   K   | ](  }|d k\  s	j                   |   j                         * ywr  r  r  s     rL   r   zJNthLinearConstantCoeffUndeterminedCoefficients._matches.<locals>.<genexpr>;	  r  r  r   r  trialsetT)r   ro   rT   r]   rU   r   rl   r   r	   rA   r)  )rX   rS   rT   r]   
does_matcheq_homogeneous
undetcoeffr   s   `      @rL   r   z7NthLinearConstantCoeffUndeterminedCoefficients._matches4	  s    00$$  &&  !!99"dEJ
TVVC'S$&&'S$Svvbz!$R$&&*!5=dffRj!TSab
f%$.z$:DM!%JrK   Tr   c                  | j                   j                  }| j                   j                  j                  }| j                   j                  }| j                   j                  }t        | j                   ||      |      \  }}| j                   j                  t        |            }t        t        ||      D 	
cg c]
  \  }	}
|	|
z   c}
}	 }t         ||      |      }| j                  j                  |||d       t        | ||      || j                  | j                        }|rt        |g ||      |      }|gS c c}
}	w )Nr  )rG  rK  simpliy_flag)r   rS   rT   rU   r]   r=   rl   r   r   r	   r  r   r  r>   r)  rB   )rX   r   rS   r   r   r]   r?  r  r  r~   r  r#  r  s                rL   r   zDNthLinearConstantCoeffUndeterminedCoefficients._get_general_solutionD	  s     !!&&    &&?!eT|$$;;E
;K	c)U.CDFQAaCDE1{+u[-XY/AaD%W&vqt\BDv Es   <E
Nr   rL  rJ   rK   rL   r%  r%    s%    7p ADL  >B rK   r%  c                  ,    e Zd ZdZdZdZd Zddd	dZy)
NthLinearEulerEqHomogeneousa
  
    Solves an `n`\th order linear homogeneous variable-coefficient
    Cauchy-Euler equidimensional ordinary differential equation.

    This is an equation with form `0 = a_0 f(x) + a_1 x f'(x) + a_2 x^2 f''(x)
    \cdots`.

    These equations can be solved in a general manner, by substituting
    solutions of the form `f(x) = x^r`, and deriving a characteristic equation
    for `r`.  When there are repeated roots, we include extra terms of the
    form `C_{r k} \ln^k(x) x^r`, where `C_{r k}` is an arbitrary integration
    constant, `r` is a root of the characteristic equation, and `k` ranges
    over the multiplicity of `r`.  In the cases where the roots are complex,
    solutions of the form `C_1 x^a \sin(b \log(x)) + C_2 x^a \cos(b \log(x))`
    are returned, based on expansions with Euler's formula.  The general
    solution is the sum of the terms found.  If SymPy cannot find exact roots
    to the characteristic equation, a
    :py:obj:`~.ComplexRootOf` instance will be returned
    instead.

    >>> from sympy import Function, dsolve
    >>> from sympy.abc import x
    >>> f = Function('f')
    >>> dsolve(4*x**2*f(x).diff(x, 2) + f(x), f(x),
    ... hint='nth_linear_euler_eq_homogeneous')
    ... # doctest: +NORMALIZE_WHITESPACE
    Eq(f(x), sqrt(x)*(C1 + C2*log(x)))

    Note that because this method does not involve integration, there is no
    ``nth_linear_euler_eq_homogeneous_Integral`` hint.

    The following is for internal use:

    - ``returns = 'sol'`` returns the solution to the ODE.
    - ``returns = 'list'`` returns a list of linearly independent solutions,
      corresponding to the fundamental solution set, for use with non
      homogeneous solution methods like variation of parameters and
      undetermined coefficients.  Note that, though the solutions should be
      linearly independent, this function does not explicitly check that.  You
      can do ``assert simplify(wronskian(sollist)) != 0`` to check for linear
      independence.  Also, ``assert len(sollist) == order`` will need to pass.
    - ``returns = 'both'``, return a dictionary ``{'sol': <solution to ODE>,
      'list': <list of linearly independent solutions>}``.

    Examples
    ========

    >>> from sympy import Function, dsolve, pprint
    >>> from sympy.abc import x
    >>> f = Function('f')
    >>> eq = f(x).diff(x, 2)*x**2 - 4*f(x).diff(x)*x + 6*f(x)
    >>> pprint(dsolve(eq, f(x),
    ... hint='nth_linear_euler_eq_homogeneous'))
            2
    f(x) = x *(C1 + C2*x)

    References
    ==========

    - https://en.wikipedia.org/wiki/Cauchy%E2%80%93Euler_equation
    - C. Bender & S. Orszag, "Advanced Mathematical Methods for Scientists and
      Engineers", Springer 1999, pp. 12

    # indirect doctest

    nth_linear_euler_eq_homogeneousFc                   	  j                   j                  } j                   j                  j                   j                   j                  } j                   j                  	 j                   j                  | 	      |      }d  _        d}|r+|r)||   }	|z  |z  }|D ci c]  }||||   z   c} _         j                  r1t         	fd j                  D              r j                  d   sd}|S c c}w )NFc              3  h   K   | ])  }|d k\  r"t        j                  |          |       + ywr  r@   rl   r   r~   r   rX   r   s     rL   r   z7NthLinearEulerEqHomogeneous._matches.<locals>.<genexpr>	  4      ,Q$%F %TVVAY!a8 ,   /2r   Tr   r`   rT   r]   rU   r   rl   r  
rX   rS   r]   rh   r*  rg   r*   r~   r   r   s
   `       @@rL   r   z$NthLinearEulerEqHomogeneous._matches	  s    --!!&&  &&    88QqT5I
U%LEX%F278Qaa(8DF66c ,&&, ,66":!
 9   'C>Tr   c                   | j                   j                  }| j                   j                  }t        ||| j                        d   }|gS )Nr   )r   rT   rS   r<   rl   )rX   r   r   rS   r#  s        rL   r   z1NthLinearEulerEqHomogeneous._get_general_solution	  sC    ""  7BGJ}rK   Nr   rL  rJ   rK   rL   r0  r0  U	  s%    AD -DL& >B rK   r0  c                  ,    e Zd ZdZdZdZd ZddddZy)	3NthLinearEulerEqNonhomogeneousVariationOfParametersae	  
    Solves an `n`\th order linear non homogeneous Cauchy-Euler equidimensional
    ordinary differential equation using variation of parameters.

    This is an equation with form `g(x) = a_0 f(x) + a_1 x f'(x) + a_2 x^2 f''(x)
    \cdots`.

    This method works by assuming that the particular solution takes the form

    .. math:: \sum_{x=1}^{n} c_i(x) y_i(x) {a_n} {x^n} \text{, }

    where `y_i` is the `i`\th solution to the homogeneous equation.  The
    solution is then solved using Wronskian's and Cramer's Rule.  The
    particular solution is given by multiplying eq given below with `a_n x^{n}`

    .. math:: \sum_{x=1}^n \left( \int \frac{W_i(x)}{W(x)} \, dx
                \right) y_i(x) \text{, }

    where `W(x)` is the Wronskian of the fundamental system (the system of `n`
    linearly independent solutions to the homogeneous equation), and `W_i(x)`
    is the Wronskian of the fundamental system with the `i`\th column replaced
    with `[0, 0, \cdots, 0, \frac{x^{- n}}{a_n} g{\left(x \right)}]`.

    This method is general enough to solve any `n`\th order inhomogeneous
    linear differential equation, but sometimes SymPy cannot simplify the
    Wronskian well enough to integrate it.  If this method hangs, try using the
    ``nth_linear_constant_coeff_variation_of_parameters_Integral`` hint and
    simplifying the integrals manually.  Also, prefer using
    ``nth_linear_constant_coeff_undetermined_coefficients`` when it
    applies, because it does not use integration, making it faster and more
    reliable.

    Warning, using simplify=False with
    'nth_linear_constant_coeff_variation_of_parameters' in
    :py:meth:`~sympy.solvers.ode.dsolve` may cause it to hang, because it will
    not attempt to simplify the Wronskian before integrating.  It is
    recommended that you only use simplify=False with
    'nth_linear_constant_coeff_variation_of_parameters_Integral' for this
    method, especially if the solution to the homogeneous equation has
    trigonometric functions in it.

    Examples
    ========

    >>> from sympy import Function, dsolve, Derivative
    >>> from sympy.abc import x
    >>> f = Function('f')
    >>> eq = x**2*Derivative(f(x), x, x) - 2*x*Derivative(f(x), x) + 2*f(x) - x**4
    >>> dsolve(eq, f(x),
    ... hint='nth_linear_euler_eq_nonhomogeneous_variation_of_parameters').expand()
    Eq(f(x), C1*x + C2*x**2 + x**4/6)

    :nth_linear_euler_eq_nonhomogeneous_variation_of_parametersTc                   	  j                   j                  } j                   j                  j                   j                   j                  } j                   j                  	 j                   j                  | 	      |      }d  _        d}|r+|r)||   }	|z  |z  }|D ci c]  }||||   z   c} _         j                  r1t         	fd j                  D              r j                  d   rd}|S c c}w )NFc              3  h   K   | ])  }|d k\  r"t        j                  |          |       + ywr  r4  r5  s     rL   r   zONthLinearEulerEqNonhomogeneousVariationOfParameters._matches.<locals>.<genexpr>	  r6  r7  r   Tr8  r9  s
   `       @@rL   r   z<NthLinearEulerEqNonhomogeneousVariationOfParameters._matches	  s    --!!&&  &&    88QqT5I
U%LEX%F278Qaa(8DF66c ,&&, ,vvbz!
 9r:  r   c          	     .   | j                   j                  }| j                   j                  j                  }| j                   j                  }| j                   j                  }t        | ||      | j                        \  }}| j                  d   | j                  |   z  | j                  d<   t        | ||      |||| j                  |      }t         ||      |j                  |j                  |j                  z
  | j                  |   z  z         gS )Nr   )
r   rS   rT   rU   r]   r<   rl   r?   r   r   )	rX   r   rS   r   r   r]   r#  r?  rK  s	            rL   r   zINthLinearEulerEqNonhomogeneousVariationOfParameters._get_general_solution
  s      !!&&    &&>r1Q4PUVVBZu-r
,R1uk5RVRXRXZgh1Q4CGGkoo,Etvve}+TTUVVrK   Nr   rL  rJ   rK   rL   r=  r=  	  s&    4j HDL( >B 	WrK   r=  c                  ,    e Zd ZdZdZdZd Zddd	dZy)
6NthLinearEulerEqNonhomogeneousUndeterminedCoefficientsa/	  
    Solves an `n`\th order linear non homogeneous Cauchy-Euler equidimensional
    ordinary differential equation using undetermined coefficients.

    This is an equation with form `g(x) = a_0 f(x) + a_1 x f'(x) + a_2 x^2 f''(x)
    \cdots`.

    These equations can be solved in a general manner, by substituting
    solutions of the form `x = exp(t)`, and deriving a characteristic equation
    of form `g(exp(t)) = b_0 f(t) + b_1 f'(t) + b_2 f''(t) \cdots` which can
    be then solved by nth_linear_constant_coeff_undetermined_coefficients if
    g(exp(t)) has finite number of linearly independent derivatives.

    Functions that fit this requirement are finite sums functions of the form
    `a x^i e^{b x} \sin(c x + d)` or `a x^i e^{b x} \cos(c x + d)`, where `i`
    is a non-negative integer and `a`, `b`, `c`, and `d` are constants.  For
    example any polynomial in `x`, functions like `x^2 e^{2 x}`, `x \sin(x)`,
    and `e^x \cos(x)` can all be used.  Products of `\sin`'s and `\cos`'s have
    a finite number of derivatives, because they can be expanded into `\sin(a
    x)` and `\cos(b x)` terms.  However, SymPy currently cannot do that
    expansion, so you will need to manually rewrite the expression in terms of
    the above to use this method.  So, for example, you will need to manually
    convert `\sin^2(x)` into `(1 + \cos(2 x))/2` to properly apply the method
    of undetermined coefficients on it.

    After replacement of x by exp(t), this method works by creating a trial function
    from the expression and all of its linear independent derivatives and
    substituting them into the original ODE.  The coefficients for each term
    will be a system of linear equations, which are be solved for and
    substituted, giving the solution. If any of the trial functions are linearly
    dependent on the solution to the homogeneous equation, they are multiplied
    by sufficient `x` to make them linearly independent.

    Examples
    ========

    >>> from sympy import dsolve, Function, Derivative, log
    >>> from sympy.abc import x
    >>> f = Function('f')
    >>> eq = x**2*Derivative(f(x), x, x) - 2*x*Derivative(f(x), x) + 2*f(x) - log(x)
    >>> dsolve(eq, f(x),
    ... hint='nth_linear_euler_eq_nonhomogeneous_undetermined_coefficients').expand()
    Eq(f(x), C1*x + C2*x**2 + log(x)/2 + 3/4)

    <nth_linear_euler_eq_nonhomogeneous_undetermined_coefficientsFc                     j                   j                  } j                   j                  j                   j                   j                  } j                   j                   j                   j                  |       |      }d  _        d}|r+|r)||   }|z  |z  }|D ci c]  }||||   z   c} _         j                  rt         fd j                  D              re j                  d   rVt         j                  d   j                  t                          \  }}	t        |j                  |	            }
|
d   rd}|S c c}w )NFc              3  h   K   | ])  }|d k\  r"t        j                  |          |       + ywr  r4  r5  s     rL   r   zRNthLinearEulerEqNonhomogeneousUndeterminedCoefficients._matches.<locals>.<genexpr>L
  r6  r7  r   r  T)r   ro   rT   r]   rU   r   rl   r  r0   r   r   rA   )rX   rS   r]   rh   r*  rg   r*   r~   r   rer,  r   r   s   `          @@rL   r   z?NthLinearEulerEqNonhomogeneousUndeterminedCoefficients._matches?
  s-   00!!&&  &&    88QqT5I
U%LEX%F278Qaa(8DF66c ,&&, ,vvbztvvbzq#a&9:2=affRj!L
f%!%J 9s   'ETr   c          	     @   | j                   j                  j                  }| j                   j                  }t        j                  t        j                  t        d      }}}| j                  j                         D ]@  }|dk\  s	|| j                  |   t        ||z  ||      z  || z  z  j                         z  }B t        dt        t        ||            dz         D ]-  }||j                  ||z        t         ||      ||      z  z  }/ |j                  |      d   r ||j                  |      d    ||      z  z  }t        | j                  d   j!                  |t#        |                  \  }}	||j!                  |	      z  }t%        t'        | ||      |            | _        | j(                  j+                  |      d   }
|
j!                  |t-        |            }
|
j!                   |t-        |             ||            j                         }
|
gS )Nr   r   r   r   r   )r   rT   rU   r
   r   r   rl   keysr   r   rx   r+   r(   rg   as_coeff_addr0   r   r   r%  rN   const_undet_instancer   r    )rX   r   r   r   chareqrS   symbolr~   r   rG  rK  s              rL   r   zLNthLinearEulerEqNonhomogeneousUndeterminedCoefficients._get_general_solutionU
  s   !!&&  VVQVVU3ZF 	PAAv466!9T!V)Q%::1vg:EMMOO	P q&ff!56q89 	;A&,,vqy)$qtQ*:::B	; v&q)&%%f-a0155Btvvbzq#a&122
affRj$RScdfhijkhlnoSp$q!''<<<VWXYhhq#a&!hhqQy!A$'..0urK   Nr   rL  rJ   rK   rL   rC  rC  
  s%    ,Z JDL, >B rK   rC  c                  ,    e Zd ZdZdZdZd Zddd	dZy)
SecondLinearBessela  
    Gives solution of the Bessel differential equation

    .. math :: x^2 \frac{d^2y}{dx^2} + x \frac{dy}{dx} y(x) + (x^2-n^2) y(x)

    if `n` is integer then the solution is of the form ``Eq(f(x), C0 besselj(n,x)
    + C1 bessely(n,x))`` as both the solutions are linearly independent else if
    `n` is a fraction then the solution is of the form ``Eq(f(x), C0 besselj(n,x)
    + C1 besselj(-n,x))`` which can also transform into ``Eq(f(x), C0 besselj(n,x)
    + C1 bessely(n,x))``.

    Examples
    ========

    >>> from sympy.abc import x
    >>> from sympy import Symbol
    >>> v = Symbol('v', positive=True)
    >>> from sympy import dsolve, Function
    >>> f = Function('f')
    >>> y = f(x)
    >>> genform = x**2*y.diff(x, 2) + x*y.diff(x) + (x**2 - v**2)*y
    >>> dsolve(genform)
    Eq(f(x), C1*besselj(v, x) + C2*bessely(v, x))

    References
    ==========

    https://math24.net/bessel-differential-equation.html

    2nd_linear_besselFc           	        | j                   j                  }| j                   j                  }| j                   j                  }| j                   j                  }|j                  |      }t        d||g      }t        d|||g      }t        d|||g      }t        d|||g      }	t        d|||g      }
t        d|||g      }t        d|||j                  |d	      g      }t        d
|||j                  |d	      g      }t        d|||j                  |d	      g      }||j                  |d	      z  ||z  z   ||z  z   }t        ||j                  |d	      ||g      j                  |      |d	k(  rbr`t        fdD              sL|j                         \  }}t        |      }t        ||j                  |d	      ||g      j                  |      r|   dk7  rt        |         j                  |||z
  |	z  z        }|r||	   dk(  ry||   }ny|rlt        |   j                  |||z               |<   t        |   j                  |||z               |<   t        |   j                  |||z               |<   t        |   ||   |d||	   z   z  z  z        |<   t        |   ||   |d||	   z   z  z  z        |<   t        |   ||   |d||	   z   z  z  z        |<   t        |         j                  ||z        }|yt        |         j                  ||z
        }|yt        ||         j                  |
d	z  |d	|z  z  z        }|y||   dk(  rd||<   n&t        ||         j                  |d	z        |   ||<   ||   ||
   ||   d| _        ||   | j                   d<   || j                   d<   yy)Nrb   rc   r-  a4b4c4d4a3r   b3c3c              3  D   K   | ]  }|   j                           y wrP   )is_polynomial)r   r  rl   s     rL   r   z.SecondLinearBessel._matches.<locals>.<genexpr>
  s     ;#qv++-;s    r   Frm  )r   rR  rU  T)r   ro   rT   r]   rU   r   r   r,   rh   r  r  r   r*   r-   r   r)   rn)rX   rS   r   r]   r   r   rb   r-  rR  rS  rT  rU  rV  rW  rX  deqr   rQ  rg   pointcoeff1_coeff2coeff2rl   s                          @rL   r   zSecondLinearBessel._matches
  s   00!!  &&  VVAYqf%q!Bi($1R)$1R)$1R)$1R)$Bq! 56$Bq! 56$Bq! 56!&&A,"R%'"Q$.BVVAq\2q!##(5: 	
A:!;;;((*1AYBVVAq\2q)++05:  2!1R5M''AaC"95E9> a 2Aqw!78" 2Aqw!78" 2Aqw!78" 1R5%)Q"U2Y,,?"?@AAbE1R5%)Q"U2Y,,?"?@AAbE1R5%)Q"U2Y,,?"?@AAbEAbE]((Q0F~ QrUm))!a%0GGAJ'--b!eQ!B$K.?@F~qzQr
#GAJ/55b!e<R@r
!":F2JVBZHDG"2JDGGDM!DGGDMrK   Tr   c               f   | j                   j                  j                  }| j                   j                  }| j                  d   }| j                  d   }| j                  d   }| j                  d   }| j                  d   }t	        |dz  t        dd      |dz
  dz  z  z         }| j                   j                  d	      \  }	}
t         ||      |t        d|z
  d      z  |	t        ||z  |||z  z  |z        z  |
t        ||z  |||z  z  |z        z  z   z  j                  |||z
              gS )
Nr   rR  rT  rU  rS  r   r   rU  r  )r   rT   rU   r[  r!   r   r   r   r"   r#   r   )rX   r   r   r   r   rR  rT  rU  rS  r  ro  s              rL   r   z(SecondLinearBessel._get_general_solution
  s.   !!&&  GGCLWWT]WWT]WWT]WWT]AAQ{223##::q:AR1Q41x"Q/02gad2ae8B;6O3O2bBhrk**4+ ,-1T!QrT]< = 	=rK   Nr   rL  rJ   rK   rL   rO  rO  m
  s%    < DLFP >B =rK   rO  c                  ,    e Zd ZdZdZdZd Zddd	dZy)
SecondLinearAirya  
    Gives solution of the Airy differential equation

    .. math :: \frac{d^2y}{dx^2} + (a + b x) y(x) = 0

    in terms of Airy special functions airyai and airybi.

    Examples
    ========

    >>> from sympy import dsolve, Function
    >>> from sympy.abc import x
    >>> f = Function("f")
    >>> eq = f(x).diff(x, 2) - x*f(x)
    >>> dsolve(eq)
    Eq(f(x), C1*airyai(x) + C2*airybi(x))
    2nd_linear_airyFc                v   | j                   j                  }| j                   j                  }| j                   j                  }| j                   j                  }|j                  |      }t        d|||g      }t        d|||g      }| j                   j                  |||      }d}	|dk(  r|r|d   dk7  r|d   j                  rrt        |d   |d   z        j                  |||z  z         | _        | j                  r8| j                  |   dk7  r&| j                  |   | j                  |   d| _        d	}	|	S )
NrR  rc   rS  Fr   r   r   )r-  r  T)r   ro   rT   r]   rU   r   r   r   r  r)   rh   r[  )
rX   rS   r   r]   r   r   rR  rS  rh   r*  s
             rL   r   zSecondLinearAiry._matches
  s   00!!  &&  VVAY$1R)$1R)  88QF
A:%E!HMQx q%(!2399"RT'B77twwr{a/#'772;4772;?DG!%JrK   Tr   c               F   | j                   j                  j                  }| j                   j                  }| j                   j                  d      \  }}| j                  d   }| j                  d   }|j
                  r"| t        |      dz  z  t        |      |z  z
  }nS|j                  r$| t        |       dz  z  t        |       |z  z   }n#| t        |       dz  z  t        |       |z  z   }t         ||      |t        |      z  |t        |      z  z         gS )Nr   r  r-  r  )r   rT   rU   r   r[  is_positiver$   is_negativer   r%   r&   )	rX   r   r   r   r  ro  r-  r  rn   s	            rL   r   z&SecondLinearAiry._get_general_solution  s    !!&&  ##::q:ARGGCLGGCL==#d1gqj.4719,C]]#dA2hk/D!HQJ.C#dA2hk/D!HQJ.C1Q4F3K"VC[.89::rK   Nr   rL  rJ   rK   rL   rc  rc  
  s#    " DL$ >B ;rK   rc  c                  2    e Zd ZdZdZdZd Zd Zddd
dZy	)LieGroupa  
    This hint implements the Lie group method of solving first order differential
    equations. The aim is to convert the given differential equation from the
    given coordinate system into another coordinate system where it becomes
    invariant under the one-parameter Lie group of translations. The converted
    ODE can be easily solved by quadrature. It makes use of the
    :py:meth:`sympy.solvers.ode.infinitesimals` function which returns the
    infinitesimals of the transformation.

    The coordinates `r` and `s` can be found by solving the following Partial
    Differential Equations.

    .. math :: \xi\frac{\partial r}{\partial x} + \eta\frac{\partial r}{\partial y}
                  = 0

    .. math :: \xi\frac{\partial s}{\partial x} + \eta\frac{\partial s}{\partial y}
                  = 1

    The differential equation becomes separable in the new coordinate system

    .. math :: \frac{ds}{dr} = \frac{\frac{\partial s}{\partial x} +
                 h(x, y)\frac{\partial s}{\partial y}}{
                 \frac{\partial r}{\partial x} + h(x, y)\frac{\partial r}{\partial y}}

    After finding the solution by integration, it is then converted back to the original
    coordinate system by substituting `r` and `s` in terms of `x` and `y` again.

    Examples
    ========

    >>> from sympy import Function, dsolve, exp, pprint
    >>> from sympy.abc import x
    >>> f = Function('f')
    >>> pprint(dsolve(f(x).diff(x) + 2*x*f(x) - x*exp(-x**2), f(x),
    ... hint='lie_group'))
           /      2\    2
           |     x |  -x
    f(x) = |C1 + --|*e
           \     2 /


    References
    ==========

    - Solving differential equations by Symmetry Groups,
      John Starrett, pp. 1 - pp. 14

    	lie_groupFc                f    d| j                   j                  v xr d| j                   j                  v S )Nxieta)r   rW   r\   s    rL   _has_additional_paramszLieGroup._has_additional_paramsP  s/    t''...S5D<L<L<S<S3SSrK   c                4   | j                   j                  }| j                   j                  j                  }| j                   j                  }| j                   j                  } ||      j                  |      }t        d      }t        d| ||      j                  |d      g      }t        d|g      }d}	| j                         r|dk(  r| j                   j                  d   }
| j                   j                  d	   }|
|d
| _
        t        ||d      j                  |||z  z         }|rf||d<   ||d<   ||d<   ||   j                   ||      |      ||<   ||   j                   ||      |      ||<   | j                  j                  |       d}	|	S )Nr  rQ  r   rc   r   Fr   rm  rn  )rm  rn  T)exact)r   rS   rT   r]   rU   r   r   r   ro  rW   r3r,   rh   r   r  )rX   rS   r   r]   r   r   r  rQ  r   r*  rm  rn  rl   s                rL   r   zLieGroup._matchesS  st     !!&&  &&  qTYYq\#Jr1Q499Q?34rd#
&&(UaZ!!((.B""))%0C,DGBd+11!a"f*=A###tyy1q)!tyy1q)!q!JrK   Tr   c                  | j                   j                  }| j                   j                  }| j                   j                  }| j                   j                  }|j                  |      }	 t        ||      }g }|D ]/  }	t        |	||| j                        }
|
s|j                  |
       1 |g k(  rt        dt        |      z   dz   dz         |S # t        $ r g }Y gw xY w)N)rh   rD  rE  z the lie group method)r   rS   rU   rT   r]   r   r3   r   rC   rr  rH  r   )rX   r   rS   r   rT   r]   r   eqsoldesolssrK  s              rL   r   zLieGroup._get_general_solutionl  s        $$  &&YYq\	"bME  	#A D%tww?Cc"	#
 R<%&6R&@CY&Y)'* + + # 	E	s   +C CCNr   )	rF   rG   rH   rI   r   r   ro  r   r   rJ   rK   rL   rj  rj    s*    /` DLT2 >B rK   rj  r6  r  r1  r&  rD  r|  r   r  rO  rY  r  r  r  r"  r  r  )
r  r>  rs  rd  rP  r  r  rg  r   rk  )rF  r  r  r  N)
__future__r   typingr   r   riccatir   r   
sympy.corer	   r
   r   r   sympy.core.cacher   sympy.core.exprtoolsr   sympy.core.exprr   sympy.core.functionr   r   r   r   r   r   r   sympy.core.numbersr   sympy.core.relationalr   r   sympy.core.symbolr   r   r   sympy.core.mulr   sympy.functionsr   r   r    r!   r"   r#   r$   r%   r&   sympy.integralsr'   sympy.polysr(   sympy.polys.polytoolsr)   r*   r+   sympy.simplifyr,   r-   r.   r/   r0   sympy.simplify.radsimpr1   sympy.utilitiesr2   sympy.solvers.solversr3   sympy.solvers.deutilsr4   r5   sympy.polys.matrices.linsolver6   sympy.polys.solversr7   hypergeometricr8   r9   r:   r;   nonhomogeneousr<   r=   r>   r?   r@   rA   rB   rk  rC   r   rE   rN   r   r   r   r   r  r!  r0  r5  rN  rX  rf  rs  r{  r  r  r  r  r  r  r   r  r  r%  r0  r=  rC  rO  rc  rj  
solver_mapoderF  r  r  r  rJ   rK   rL   <module>r     sa  
 # % 1 , , , -   ` ` ` " . 1 1  W W W $  8 8 N N + , ' 8 6 29 9   &	' 	
` `RP' P'f,'_ ,'^c? cL~' ~BG( GTS) Slh& hVF FR=+ =@C=, C=L:2)? :2z]& ]@]& ]@H1y H1Vy&< yxz&< zz<c:<[ <c~sQ- sQlO OdS? Sl[ [|c/ cLZ_ Zz]/ ]@VW/ VWr\_ \~u= u=p4; 4;ne eP*+-N &'B :;i	
 CDz   +  n O !"6 /0O /0O \  -!" )#$ :eBu'+.,*L!7
> H GrK   