
    \h+                       S SK JrJrJr  S SKJr  S SKJr  S SKJ	r	  S SK
JrJr  S SKJrJr  S SKJrJr  S SKJrJrJrJrJrJr  S S	KJrJrJrJrJrJ r J!r!J"r"J#r#  S S
K$J%r%  S SK&J'r'J(r(J)r)J*r*J+r+  S SK,J-r-J.r.  S SK/J0r0J1r1J2r2  S SK3J4r4J5r5  S SK6J7r7  S SK8J9r9  S SK:J;r;  S SK<J=r=  S SK>J?r?J@r@  S SKAJBrBJCrCJDrD  S SKEJFrF  S SKGJHrHJIrI  S rJ " S S\K5      rL " S S\?5      rMS rNS rOSCS jrPSDS  jrQSDS! jrRS" rSS# rTS$ rU  SES% jrVS& rWS' rXS( rYS) rZS* r[S+ r\SDS, jr]S- r^S. r_S/ r`SFS0 jraS1 rbS2 rcS3 rdS4 reS5 rfS6 rgS7 rhS8 4S9 jriS: rjS; rkS< rlS= rmS> rn  SGS? jroSHS@ jrpSISA jrqSJSB jrrg)K    )AddMulS)Tuple)factor_terms)I)EqEquality)default_sort_keyordered)DummySymbol)
expand_mulexpand
DerivativeAppliedUndefFunctionSubs)	expimcossinre	Piecewisepiecewise_foldsqrtlog	factorial)zerosMatrixNonSquareMatrixError
MatrixBaseeye)Polytogether)collectradsimpsignsimp)	powdenestpowsimp)ratsimp)simplify)	FiniteSet	ode_order)NonlinearErrorsolveset)connected_componentsiterablestrongly_connected_components)
filldedent)Integral	integratec                 ^   ^ U V^s0 s H  mT[        U4S jU  5       5      _M     sn$ s  snf )Nc              3   <   >#    U  H  n[        UT5      v   M     g 7fNr/   ).0eqfuncs     Q/var/www/auris/envauris/lib/python3.13/site-packages/sympy/solvers/ode/systems.py	<genexpr>"_get_func_order.<locals>.<genexpr>   s     8CbiD))C   )max)eqsfuncsr>   s     `r?   _get_func_orderrF      s+    EJKUTD#8C888UKKKs    *c                       \ rS rSrSrSrg)ODEOrderError    z@Raised by linear_ode_to_matrix if the system has the wrong order N__name__
__module____qualname____firstlineno____doc____static_attributes__rJ       r?   rH   rH       s    JrR   rH   c                       \ rS rSrSrSrg)ODENonlinearError%   z9Raised by linear_ode_to_matrix if the system is nonlinearrJ   NrK   rJ   rR   r?   rT   rT   %   s    CrR   rT   c                   ^	 U R                   nU R                  n[        U5      n[        UR	                  [
        5      5      n[        U/UQ7SS06nU Vs/ s H  n[        U5      PM     nnU(       d  UR                  n[        S5      [        S5      /m	/ n[        UR                  5       UR                  5       5       H  u  px[        U5      n[        U[        5      (       a  [        U	4S jUR                    5       6 nO[#        U5      R%                  T	5      n['        S [        X85       5       6 nUR)                  Xx-  5        M     [+        U[-        U6 5      $ s  snf )Nr   FC1C2c              3   `   >#    U  H#  u  p[        U5      R                  T5      U4v   M%     g 7fr;   )r,   r'   )r<   coefcondsymss      r?   r@   _simpsol.<locals>.<genexpr>8   s)     aV`
!6!6t!<d CV`s   +.c              3   .   #    U  H  u  pX-  v   M     g 7fr;   rJ   )r<   gis      r?   r@   r]   ;   s     :)9af)9   )lhsrhsr+   listatomsr   r%   r   gensr   zipcoeffsmonomsr   
isinstancer   argsr,   r'   r   appendr	   r   )
soleqrb   solrf   pr_   termscoeffmonomr\   s
            @r?   _simpsolrs   *   s   
))C
))C
#,C		#DS&4&&A%)*TLOTD*vv4L&,'DEAHHJ
3u%eY''aV[V`V`abEEN**40E:T)9:;U]# 4 c3; +s   Ec                     [        [        U 5      5      R                  U5      u  p#[        U5      nUR	                  [
        S 5      nX#-   $ )Nc                 *    [        [        U 5      5      $ r;   )r   r   )as    r?   <lambda>_solsimp.<locals>.<lambda>D   s    \!_)=rR   )r+   r   as_independentr,   replacer   )etno_thas_ts       r?   _solsimpr   @   s?    *Q-(77:KD4=DMM#=>E<rR   c                 ^  ^	^
^ U	4S jnSU	U
U4S jjm	S mS m
U(       aH  [        5       R                  " S U  5       6 nU Vs0 s H  of[        U5      R                  5       _M     nnO0 nU  Vs/ s H+  n[	        UR
                  U" UR                  XqU5      5      PM-     n nU $ s  snf s  snf )z&Simplify solutions from dsolve_system.c                 v   > U(       a  U R                  U5      n [        U 5      n T" XU5      n [        U 5      n U $ )z#Simplify the rhs of an ODE solution)subsr   r)   )rc   repwrt1wrt2simp_coeff_deps       r?   simprhssimpsol.<locals>.simprhsp   s7    ((3-C3S-sm
rR   c                   >^^^^^ U4S jmU4S jmS mUU4S jn[         R                  " U" U 5      5      n0 nU H}  nUR                  " TSS06u  pxT" UT5      nU[        R                  La3  [        U5      n	U	R                  " T6 (       d  Xy-  n[        R                  nX;  a  XuU'   Mq  XX==   U-  ss'   M     UU4S jUR                  5        5       n
Tb  UU4S jU
 5       n
[        S	 U
 5       6 $ )
zGSplit rhs into terms, split terms into dep and coeff and collect on depc                 H   > U R                   =(       a    U R                  " T6 $ r;   )is_Addhas)r{   r   s    r?   rw   1simpsol.<locals>.simp_coeff_dep.<locals>.<lambda>{   s    !((";quud|";rR   c                 h   > U R                   =(       a    [        [        TU R                  5      5      $ r;   )is_Mulanymaprk   )r{   add_dep_termss    r?   rw   r   |   s!    qxxKCM1660J,KKrR   c                     [        U SS9$ )NF)deep)r   )r{   s    r?   rw   r   }   s    
15 9rR   c                 (   > U R                  TT5      $ r;   )rz   )r{   expand_func
expandables    r?   rw   r   ~   s    199Z#ErR   as_AddFc              3   >   >#    U  H  u  pT" UT5      U4v   M     g 7fr;   rJ   )r<   dc	simpcoeffr   s      r?   r@   2simpsol.<locals>.simp_coeff_dep.<locals>.<genexpr>   s     Di4(!,   c              3   >   >#    U  H  u  pT" UT5      U4v   M     g 7fr;   rJ   )r<   r   r   r   r   s      r?   r@   r      s     L)$!.D115)r   c              3   .   #    U  H  u  pX-  v   M     g 7fr;   rJ   )r<   r   r   s      r?   r@   r      s     1ytqQUyra   )r   	make_argsry   r   Oner   r   items)exprr   r   expand_mul_modrp   dctermrq   depdep2	termpairsr   r   r   r   r   simpdeps    ``        @@@r?   r   simpsol.<locals>.simp_coeff_depy   s    ;K
9EnT23D,,dA5AJE #t$C !%%#C(xxME%%C}35 ! & ED	L)LI1y122rR   c           
         ^ U4S jn[        U 5      n U R                  [        5       Vs0 s H!  o3[        U" UR                  S   5      5      _M#     nnU R	                  U5      n U $ s  snf )z<Normalise factors involving t with powsimp and recombine expc                 t   > [        U 5      n U R                  5       u  p[        U5      n[        UT5      nX-  $ r;   )r   as_numer_denomr   r'   )rv   numdenr   s      r?   canonicalise.simpsol.<locals>.simpdep.<locals>.canonicalise   s;     QA'')HCS/C#t$C9rR   r   )r+   re   r   rk   r   )r   r   r   r{   r   s    `   r?   r   simpsol.<locals>.simpdep   s\    
	 t}8<

3H1#l166!9-..Hyy~ Is   (A'c           	      J   [        U 5      n U R                  5       (       a  [        [        U 5      5      n Ub7  [	        U5      [	        [        U R                  [        U5      -
  5      5      -   nO[	        [        U R                  5      5      n[        X5      n [        U 5      n U $ )z2Bring to a common fraction and cancel with ratsimp)	r&   is_polynomialr,   r(   rd   r   free_symbolssetr'   )rq   r   r\   s      r?   r   simpsol.<locals>.simpcoeff   s      
 GEN+E:WU-?-?#d)-K%L MMD 2 234D$rR   c              3   J   #    U  H  oR                  [        5      v   M     g 7fr;   )re   r7   )r<   ss     r?   r@   simpsol.<locals>.<genexpr>   s     !AS''("3"3Ss   !#r;   )r   unionr   doitr	   rb   rc   )rn   r   r   r   r   	integralsr`   r   r   r   r   r   s            @@@r?   simpsolr   I   s    N3 3@&* EKK!AS!AB	2;<)Q,q/&&(()<?B
Cs!2aeeWQUUCt45sC
CJ = Ds   #B%/2B*Nc           
         0 n[        X5      (       + nUSL =(       d    UR                  (       + nSR                  [        SR                  [        U5      [        U5      5      S5      S-   5      nSnUR	                  XgS.5        U(       aE  [        X5      u  pxU(       d  [        [        S5      5      eXsS'   UR	                  [        XUS	95        U$ )
a	  
Helper function that determines the type of the system of ODEs for solving with :obj:`sympy.solvers.ode.systems.linodesolve()`

Explanation
===========

This function takes in the coefficient matrix and/or the non-homogeneous term
and returns the type of the equation that can be solved by :obj:`sympy.solvers.ode.systems.linodesolve()`.

If the system is constant coefficient homogeneous, then "type1" is returned

If the system is constant coefficient non-homogeneous, then "type2" is returned

If the system is non-constant coefficient homogeneous, then "type3" is returned

If the system is non-constant coefficient non-homogeneous, then "type4" is returned

If the system has a non-constant coefficient matrix which can be factorized into constant
coefficient matrix, then "type5" or "type6" is returned for when the system is homogeneous or
non-homogeneous respectively.

Note that, if the system of ODEs is of "type3" or "type4", then along with the type,
the commutative antiderivative of the coefficient matrix is also returned.

If the system cannot be solved by :obj:`sympy.solvers.ode.systems.linodesolve()`, then
NotImplementedError is raised.

Parameters
==========

A : Matrix
    Coefficient matrix of the system of ODEs
b : Matrix or None
    Non-homogeneous term of the system. The default value is None.
    If this argument is None, then the system is assumed to be homogeneous.

Examples
========

>>> from sympy import symbols, Matrix
>>> from sympy.solvers.ode.systems import linodesolve_type
>>> t = symbols("t")
>>> A = Matrix([[1, 1], [2, 3]])
>>> b = Matrix([t, 1])

>>> linodesolve_type(A, t)
{'antiderivative': None, 'type_of_equation': 'type1'}

>>> linodesolve_type(A, t, b=b)
{'antiderivative': None, 'type_of_equation': 'type2'}

>>> A_t = Matrix([[1, t], [-t, 1]])

>>> linodesolve_type(A_t, t)
{'antiderivative': Matrix([
[      t, t**2/2],
[-t**2/2,      t]]), 'type_of_equation': 'type3'}

>>> linodesolve_type(A_t, t, b=b)
{'antiderivative': Matrix([
[      t, t**2/2],
[-t**2/2,      t]]), 'type_of_equation': 'type4'}

>>> A_non_commutative = Matrix([[1, t], [t, -1]])
>>> linodesolve_type(A_non_commutative, t)
Traceback (most recent call last):
...
NotImplementedError:
The system does not have a commutative antiderivative, it cannot be
solved by linodesolve.

Returns
=======

Dict

Raises
======

NotImplementedError
    When the coefficient matrix does not have a commutative antiderivative

See Also
========

linodesolve: Function for which linodesolve_type gets the information

Ntype{}z{}{}      )type_of_equationantiderivativez
                The system does not have a commutative antiderivative, it cannot be solved
                by linodesolve.
            r   b)	_matrix_is_constantis_zero_matrixformatintupdate_is_commutative_anti_derivativeNotImplementedErrorr6   _first_order_type5_6_subs)	Ar|   r   matchis_non_constantis_non_homogeneoustypeBis_commutings	            r?   linodesolve_typer      s    t E-a33O4i;1+;+;<??3v}}S-A3GYCZ[]^_bccdDA	LLd@A9!?%j 2 '  
 #$.qq9:LrR   c                 
   0 n[        X5      nUS L =(       d    UR                  nUb  [        SR                  U5      5      n[	        US   U5      n[        [        Xg5      U5      n[        U[        5      (       a  UR                  [        5      (       dn  [        U5      S:X  a_  US   n U(       d%  X$S   -  nUR                  U[        U5      S   5      nSR                  SU(       + -   5      n	UR                  XXiUS.5        U$ )N{}_r   r   r      )
func_coefftaut_r   rc   )_factor_matrixr   r   r   r8   r2   r	   rj   r.   r   r   lenr   rd   r   )
r   r|   r   r   r   is_homogeneousr   F_tinverser   s
             r?   r   r   ;  s    E!!'L$Y2!"2"2NELLO$Q+2b;* gy))'++i2H2HG!QA!Q'FF1d7mA./??1N(:#;<DLL "QH I LrR   c                   ^^ SSK Jn  [        UU4S jU  5       5      (       a  Sn[        UR	                  T5      5      e/ n[        TSS5       Hz  nT Vs/ s H  oR                  X'5      PM     n	n U" X	5      u  pU
R                  [        5      n
UR                  UT:X  a  U
OU
* 5        U(       a  U Vs/ s H  o* PM     n nMx  UnM|     UW4$ s  snf ! [         a    [        S5      ef = fs  snf )a
  
Convert a linear system of ODEs to matrix form

Explanation
===========

Express a system of linear ordinary differential equations as a single
matrix differential equation [1]. For example the system $x' = x + y + 1$
and $y' = x - y$ can be represented as

.. math:: A_1 X' = A_0 X + b

where $A_1$ and $A_0$ are $2 \times 2$ matrices and $b$, $X$ and $X'$ are
$2 \times 1$ matrices with $X = [x, y]^T$.

Higher-order systems are represented with additional matrices e.g. a
second-order system would look like

.. math:: A_2 X'' =  A_1 X' + A_0 X  + b

Examples
========

>>> from sympy import Function, Symbol, Matrix, Eq
>>> from sympy.solvers.ode.systems import linear_ode_to_matrix
>>> t = Symbol('t')
>>> x = Function('x')
>>> y = Function('y')

We can create a system of linear ODEs like

>>> eqs = [
...     Eq(x(t).diff(t), x(t) + y(t) + 1),
...     Eq(y(t).diff(t), x(t) - y(t)),
... ]
>>> funcs = [x(t), y(t)]
>>> order = 1 # 1st order system

Now ``linear_ode_to_matrix`` can represent this as a matrix
differential equation.

>>> (A1, A0), b = linear_ode_to_matrix(eqs, funcs, t, order)
>>> A1
Matrix([
[1, 0],
[0, 1]])
>>> A0
Matrix([
[1, 1],
[1,  -1]])
>>> b
Matrix([
[1],
[0]])

The original equations can be recovered from these matrices:

>>> eqs_mat = Matrix([eq.lhs - eq.rhs for eq in eqs])
>>> X = Matrix(funcs)
>>> A1 * X.diff(t) - A0 * X - b == eqs_mat
True

If the system of equations has a maximum order greater than the
order of the system specified, a ODEOrderError exception is raised.

>>> eqs = [Eq(x(t).diff(t, 2), x(t).diff(t) + x(t)), Eq(y(t).diff(t), y(t) + x(t))]
>>> linear_ode_to_matrix(eqs, funcs, t, 1)
Traceback (most recent call last):
...
ODEOrderError: Cannot represent system in 1-order form

If the system of equations is nonlinear, then ODENonlinearError is
raised.

>>> eqs = [Eq(x(t).diff(t), x(t) + y(t)), Eq(y(t).diff(t), y(t)**2 + x(t))]
>>> linear_ode_to_matrix(eqs, funcs, t, 1)
Traceback (most recent call last):
...
ODENonlinearError: The system of ODEs is nonlinear.

Parameters
==========

eqs : list of SymPy expressions or equalities
    The equations as expressions (assumed equal to zero).
funcs : list of applied functions
    The dependent variables of the system of ODEs.
t : symbol
    The independent variable.
order : int
    The order of the system of ODEs.

Returns
=======

The tuple ``(As, b)`` where ``As`` is a tuple of matrices and ``b`` is the
the matrix representing the rhs of the matrix equation.

Raises
======

ODEOrderError
    When the system of ODEs have an order greater than what was specified
ODENonlinearError
    When the system of ODEs is nonlinear

See Also
========

linear_eq_to_matrix: for systems of linear algebraic equations.

References
==========

.. [1] https://en.wikipedia.org/wiki/Matrix_differential_equation

r   )linear_eq_to_matrixc              3   T   >#    U  H  nT  H  n[        X5      T:  v   M     M     g 7fr;   r/   )r<   r=   r>   rE   orders      r?   r@   'linear_ode_to_matrix.<locals>.<genexpr>  s$     
G29R&&s   %(z(Cannot represent system in {}-order formz The system of ODEs is nonlinear.)sympy.solvers.solvesetr   r   rH   r   rangediffr1   rT   	applyfuncr   rl   )rD   rE   r|   r   r   msgAsor>   r\   Air   r=   rc   s    ` `          r?   linear_ode_to_matrixr   V  s    l ;

G
GGG8CJJu-..	B5"b!,12ED		!E2	H'2EB \\*%
		U
",!"#23C#CC% "( s7N% 3  	H#$FGG	H $s   C3
C7C/C,c                 F    [        X5      u  p#X#-  UR                  5       -  $ )a@  
Matrix exponential $\exp(A*t)$ for the matrix ``A`` and scalar ``t``.

Explanation
===========

This functions returns the $\exp(A*t)$ by doing a simple
matrix multiplication:

.. math:: \exp(A*t) = P * expJ * P^{-1}

where $expJ$ is $\exp(J*t)$. $J$ is the Jordan normal
form of $A$ and $P$ is matrix such that:

.. math:: A = P * J * P^{-1}

The matrix exponential $\exp(A*t)$ appears in the solution of linear
differential equations. For example if $x$ is a vector and $A$ is a matrix
then the initial value problem

.. math:: \frac{dx(t)}{dt} = A \times x(t),   x(0) = x0

has the unique solution

.. math:: x(t) = \exp(A t) x0

Examples
========

>>> from sympy import Symbol, Matrix, pprint
>>> from sympy.solvers.ode.systems import matrix_exp
>>> t = Symbol('t')

We will consider a 2x2 matrix for comupting the exponential

>>> A = Matrix([[2, -5], [2, -4]])
>>> pprint(A)
[2  -5]
[     ]
[2  -4]

Now, exp(A*t) is given as follows:

>>> pprint(matrix_exp(A, t))
[   -t           -t                    -t              ]
[3*e  *sin(t) + e  *cos(t)         -5*e  *sin(t)       ]
[                                                      ]
[         -t                     -t           -t       ]
[      2*e  *sin(t)         - 3*e  *sin(t) + e  *cos(t)]

Parameters
==========

A : Matrix
    The matrix $A$ in the expression $\exp(A*t)$
t : Symbol
    The independent variable

See Also
========

matrix_exp_jordan_form: For exponential of Jordan normal form

References
==========

.. [1] https://en.wikipedia.org/wiki/Jordan_normal_form
.. [2] https://en.wikipedia.org/wiki/Matrix_exponential

)matrix_exp_jordan_forminv)r   r|   PexpJs       r?   
matrix_expr     s$    N %Q*GA8aeegrR   c           	        ^^^^ U R                   u  p#X#:w  a  [        SU< SU< S35      eU R                  T5      (       a  [        S5      eS nU" U 5      n[        UR	                  5       [
        S9nU R                  [        5      (       + n/ n/ m[        5       n	U GH  u  pU GH  n[        U5      nU(       Ga5  XR                  5       :w  Ga!  U
R                  5       U;   Ga  X;   a  MG  U	R                  U
R                  5       5        [        [        U
5      T-  5      n[        U
5      T-  n[        [        U5      [!        U5      /[!        U5      * [        U5      //5      m[        XUU4S j5      m[        SU-  SU-  U4S	 j5      nUR#                  UU-  5        [%        U5       H=  nTR#                  [        UU   5      5        TR#                  [        UU   5      5        M?     GML  TR'                  U5        U4S
 jn[        XU5      nUR#                  [        U
T-  5      U-  5        GM     GM     [        R(                  " U6 n[        X"U4S j5      nUU4$ )a  
Matrix exponential $\exp(A*t)$ for the matrix *A* and scalar *t*.

Explanation
===========

Returns the Jordan form of the $\exp(A*t)$ along with the matrix $P$ such that:

.. math::
    \exp(A*t) = P * expJ * P^{-1}

Examples
========

>>> from sympy import Matrix, Symbol
>>> from sympy.solvers.ode.systems import matrix_exp, matrix_exp_jordan_form
>>> t = Symbol('t')

We will consider a 2x2 defective matrix. This shows that our method
works even for defective matrices.

>>> A = Matrix([[1, 1], [0, 1]])

It can be observed that this function gives us the Jordan normal form
and the required invertible matrix P.

>>> P, expJ = matrix_exp_jordan_form(A, t)

Here, it is shown that P and expJ returned by this function is correct
as they satisfy the formula: P * expJ * P_inverse = exp(A*t).

>>> P * expJ * P.inv() == matrix_exp(A, t)
True

Parameters
==========

A : Matrix
    The matrix $A$ in the expression $\exp(A*t)$
t : Symbol
    The independent variable

References
==========

.. [1] https://en.wikipedia.org/wiki/Defective_matrix
.. [2] https://en.wikipedia.org/wiki/Jordan_matrix
.. [3] https://en.wikipedia.org/wiki/Jordan_normal_form

z$Needed square matrix but got shape (z, )zMatrix A should not depend on tc                    U R                  5       u  p[        UR                  S   5       Vs/ s H  o1SS2U4   PM     nnSn0 nU H;  nUS   nUR                  S   n	X;  a  / Xh'   Xh   R                  XEXY-    5        XY-  nM=     U$ s  snf )zChains from Jordan normal form analogous to M.eigenvects().
Returns a dict with eignevalues as keys like:
    {e1: [[v111,v112,...], [v121, v122,...]], e2:...}
where vijk is the kth vector in the jth chain for eigenvalue i.
r   Nr   r   r   )jordan_cellsr   shaperl   )
r   r   blocksr`   basisnchainsr   eigvalsizes
             r?   jordan_chains-matrix_exp_jordan_form.<locals>.jordan_chainsp  s     NN$	!&qwwqz!23!2A1Q3!23AtWF771:D#!#N!!%!&/2IA   4s   Bkeyc                 V   > X:  a  TTX-
  -  -  [        X-
  5      -  $ [        SS5      $ Nr   )r   r    )r`   jimblockr|   s     r?   rw   (matrix_exp_jordan_form.<locals>.<lambda>  s3    ?@v!ac(*Yqs^; )"1a[)rR   r   c                 4   > TU S-  US-  4   U S-  US-  4   $ r
  rJ   )r`   r  
expJblock2s     r?   rw   r    s+    AqDAI9NqQRsSTUVSVw9WrR   c                 <   > X:  a  TX-
  -  [        X-
  5      -  $ S$ Nr   r   )r`   r  r|   s     r?   rw   r    s"    QV!ac(9QS>"9"J"JrR   c                    > TU   U    $ r;   rJ   )r`   r  vectorss     r?   rw   r    s    ArR   )r   
ValueErrorr   sortedr   r   r   r   r   	conjugateaddr   r   r   r!   r   r   rl   r   extenddiag)r   r|   NMr  eigenchainseigenchains_iterisrealr   seen_conjugater{   r  chainr  exprtimrt	expJblockr`   funr   r   r  r  r  s    `                   @@@r?   r   r   6  s   h 77DAv!QOPP	
q:;;&  "K k//17GHq\FFGUN%	EE
A!{{},+1M&""1;;=1BqEAI!uqy 3t9c$i"8$'I:s4y"9"; <#A +) *
 #1Q3!-WX	ei/0qANN2eAh<0NN2eAh<0 " u%J"1-	c!a%j945/  &4 ;;Dq./Ad7NrR   c           	        ^^ [        U [        5      (       d  [        [        S5      5      eU R                  (       d  [        [        S5      5      eUbW  [        U[        5      (       d  [        [        S5      5      eU R                  UR                  :w  a  [        [        S5      5      eUb|  [        U[        5      (       d  [        [        S5      5      eUR                  (       d  [        [        S5      5      eU R                  UR                  :w  a  [        [        S5      5      e[        U4S	 j[        S
S5       5       5      (       d  TS:X  d  [        [        S5      5      eU R                  n[        [        U5       Vs/ s H  n[        5       PM     sn5      n	Uc&  [        U4S jS 5       5      (       a  [        US
5      nUSLn
TnTS:X  a  [        U TUS9nUS   mUS   nTS;   aT  Sn
US:w  aL  UcI  [        U TUS9nU(       d#  [        [        SR                  T5      5      5      eUS   nUS   mUS   n US   nU4S jnTS;   ah  [        U T5      u  p[!        U5      nTS;   a  XU	-  -  nOUR#                  TT* 5      nX-  UUR%                  5       -  U-  R'                  U5      U	-   -  nObUc  [)        U T5      u  p8TS:X  a  UR+                  5       U	-  nO7UR+                  5       U* R+                  5       U-  R'                  U5      U	-   -  nU
(       a  UR#                  TU5      nUR-                  [*        5      nTS:w  a  U Vs/ s H  n[/        U5      PM     nnU Vs/ s H  n[1        U[3        U5      SS9PM     nnU(       a   U Vs/ s H  nUR5                  5       PM     nnU$ s  snf s  snf s  snf s  snf ) a  
System of n equations linear first-order differential equations

Explanation
===========

This solver solves the system of ODEs of the following form:

.. math::
    X'(t) = A(t) X(t) +  b(t)

Here, $A(t)$ is the coefficient matrix, $X(t)$ is the vector of n independent variables,
$b(t)$ is the non-homogeneous term and $X'(t)$ is the derivative of $X(t)$

Depending on the properties of $A(t)$ and $b(t)$, this solver evaluates the solution
differently.

When $A(t)$ is constant coefficient matrix and $b(t)$ is zero vector i.e. system is homogeneous,
the system is "type1". The solution is:

.. math::
    X(t) = \exp(A t) C

Here, $C$ is a vector of constants and $A$ is the constant coefficient matrix.

When $A(t)$ is constant coefficient matrix and $b(t)$ is non-zero i.e. system is non-homogeneous,
the system is "type2". The solution is:

.. math::
    X(t) = e^{A t} ( \int e^{- A t} b \,dt + C)

When $A(t)$ is coefficient matrix such that its commutative with its antiderivative $B(t)$ and
$b(t)$ is a zero vector i.e. system is homogeneous, the system is "type3". The solution is:

.. math::
    X(t) = \exp(B(t)) C

When $A(t)$ is commutative with its antiderivative $B(t)$ and $b(t)$ is non-zero i.e. system is
non-homogeneous, the system is "type4". The solution is:

.. math::
    X(t) =  e^{B(t)} ( \int e^{-B(t)} b(t) \,dt + C)

When $A(t)$ is a coefficient matrix such that it can be factorized into a scalar and a constant
coefficient matrix:

.. math::
    A(t) = f(t) * A

Where $f(t)$ is a scalar expression in the independent variable $t$ and $A$ is a constant matrix,
then we can do the following substitutions:

.. math::
    tau = \int f(t) dt, X(t) = Y(tau), b(t) = b(f^{-1}(tau))

Here, the substitution for the non-homogeneous term is done only when its non-zero.
Using these substitutions, our original system becomes:

.. math::
    Y'(tau) = A * Y(tau) + b(tau)/f(tau)

The above system can be easily solved using the solution for "type1" or "type2" depending
on the homogeneity of the system. After we get the solution for $Y(tau)$, we substitute the
solution for $tau$ as $t$ to get back $X(t)$

.. math::
    X(t) = Y(tau)

Systems of "type5" and "type6" have a commutative antiderivative but we use this solution
because its faster to compute.

The final solution is the general solution for all the four equations since a constant coefficient
matrix is always commutative with its antidervative.

An additional feature of this function is, if someone wants to substitute for value of the independent
variable, they can pass the substitution `tau` and the solution will have the independent variable
substituted with the passed expression(`tau`).

Parameters
==========

A : Matrix
    Coefficient matrix of the system of linear first order ODEs.
t : Symbol
    Independent variable in the system of ODEs.
b : Matrix or None
    Non-homogeneous term in the system of ODEs. If None is passed,
    a homogeneous system of ODEs is assumed.
B : Matrix or None
    Antiderivative of the coefficient matrix. If the antiderivative
    is not passed and the solution requires the term, then the solver
    would compute it internally.
type : String
    Type of the system of ODEs passed. Depending on the type, the
    solution is evaluated. The type values allowed and the corresponding
    system it solves are: "type1" for constant coefficient homogeneous
    "type2" for constant coefficient non-homogeneous, "type3" for non-constant
    coefficient homogeneous, "type4" for non-constant coefficient non-homogeneous,
    "type5" and "type6" for non-constant coefficient homogeneous and non-homogeneous
    systems respectively where the coefficient matrix can be factorized to a constant
    coefficient matrix.
    The default value is "auto" which will let the solver decide the correct type of
    the system passed.
doit : Boolean
    Evaluate the solution if True, default value is False
tau: Expression
    Used to substitute for the value of `t` after we get the solution of the system.

Examples
========

To solve the system of ODEs using this function directly, several things must be
done in the right order. Wrong inputs to the function will lead to incorrect results.

>>> from sympy import symbols, Function, Eq
>>> from sympy.solvers.ode.systems import canonical_odes, linear_ode_to_matrix, linodesolve, linodesolve_type
>>> from sympy.solvers.ode.subscheck import checkodesol
>>> f, g = symbols("f, g", cls=Function)
>>> x, a = symbols("x, a")
>>> funcs = [f(x), g(x)]
>>> eqs = [Eq(f(x).diff(x) - f(x), a*g(x) + 1), Eq(g(x).diff(x) + g(x), a*f(x))]

Here, it is important to note that before we derive the coefficient matrix, it is
important to get the system of ODEs into the desired form. For that we will use
:obj:`sympy.solvers.ode.systems.canonical_odes()`.

>>> eqs = canonical_odes(eqs, funcs, x)
>>> eqs
[[Eq(Derivative(f(x), x), a*g(x) + f(x) + 1), Eq(Derivative(g(x), x), a*f(x) - g(x))]]

Now, we will use :obj:`sympy.solvers.ode.systems.linear_ode_to_matrix()` to get the coefficient matrix and the
non-homogeneous term if it is there.

>>> eqs = eqs[0]
>>> (A1, A0), b = linear_ode_to_matrix(eqs, funcs, x, 1)
>>> A = A0

We have the coefficient matrices and the non-homogeneous term ready. Now, we can use
:obj:`sympy.solvers.ode.systems.linodesolve_type()` to get the information for the system of ODEs
to finally pass it to the solver.

>>> system_info = linodesolve_type(A, x, b=b)
>>> sol_vector = linodesolve(A, x, b=b, B=system_info['antiderivative'], type=system_info['type_of_equation'])

Now, we can prove if the solution is correct or not by using :obj:`sympy.solvers.ode.checkodesol()`

>>> sol = [Eq(f, s) for f, s in zip(funcs, sol_vector)]
>>> checkodesol(eqs, sol)
(True, [0, 0])

We can also use the doit method to evaluate the solutions passed by the function.

>>> sol_vector_evaluated = linodesolve(A, x, b=b, type="type2", doit=True)

Now, we will look at a system of ODEs which is non-constant.

>>> eqs = [Eq(f(x).diff(x), f(x) + x*g(x)), Eq(g(x).diff(x), -x*f(x) + g(x))]

The system defined above is already in the desired form, so we do not have to convert it.

>>> (A1, A0), b = linear_ode_to_matrix(eqs, funcs, x, 1)
>>> A = A0

A user can also pass the commutative antiderivative required for type3 and type4 system of ODEs.
Passing an incorrect one will lead to incorrect results. If the coefficient matrix is not commutative
with its antiderivative, then :obj:`sympy.solvers.ode.systems.linodesolve_type()` raises a NotImplementedError.
If it does have a commutative antiderivative, then the function just returns the information about the system.

>>> system_info = linodesolve_type(A, x, b=b)

Now, we can pass the antiderivative as an argument to get the solution. If the system information is not
passed, then the solver will compute the required arguments internally.

>>> sol_vector = linodesolve(A, x, b=b)

Once again, we can verify the solution obtained.

>>> sol = [Eq(f, s) for f, s in zip(funcs, sol_vector)]
>>> checkodesol(eqs, sol)
(True, [0, 0])

Returns
=======

List

Raises
======

ValueError
    This error is raised when the coefficient matrix, non-homogeneous term
    or the antiderivative, if passed, are not a matrix or
    do not have correct dimensions
NonSquareMatrixError
    When the coefficient matrix or its antiderivative, if passed is not a
    square matrix
NotImplementedError
    If the coefficient matrix does not have a commutative antiderivative

See Also
========

linear_ode_to_matrix: Coefficient matrix computation function
canonical_odes: System of ODEs representation change
linodesolve_type: Getting information about systems of ODEs to pass in this solver

zT            The coefficients of the system of ODEs should be of type Matrix
        z<            The coefficient matrix must be a square
        Nze                The non-homogeneous terms of the system of ODEs should be of type Matrix
            z                The system of ODEs should have the same number of non-homogeneous terms and the number of
                equations
            zn                The antiderivative of coefficients of the system of ODEs should be of type Matrix
            zZ                The antiderivative of the coefficient matrix must be a square
            zv                        The coefficient matrix and its antiderivative should have same dimensions
                    c              3   L   >#    U  H  nTS R                  U5      :H  v   M     g7f)r   N)r   )r<   r`   r   s     r?   r@   linodesolve.<locals>.<genexpr>  s     ?;atxq));s   !$r      autozI                    The input type should be a valid one
                c              3   .   >#    U  H
  nTU:H  v   M     g 7fr;   rJ   )r<   typr   s     r?   r@   r'    s     L0K0K   )type2type4type6r   r   r   )type5r/  TzI
                        The system passed isn't {}.
                    r   r   r   r   c                 .   > U (       a  [        U T5      $ S$ r  )r7   )xr|   s    r?   rw   linodesolve.<locals>.<lambda>  s    A(1a.414rR   )type1r-  r0  r/  )r4  r0  type3r4  )exact)rj   r#   r  r6   	is_squarer"   rowsr   r   r!   r   r    r   r   r   r   r-   r   r   r   r   r   re   r   r'   r   r   )r   r|   r   r   r   r   r   r  _Cvectis_transformedpassed_typesystem_info	intx_wrttr   J
sol_vectorJinvrf   r   s    `  `               r?   linodesolverB    s   d a$$ %   	 ;;": / $  	 	}!Z((Z )    66QVVZ )   
 	}!Z((Z )    {{&z 3 (   66QVVZ )    ?5A;???PV %   	 	
A U1X.XEGX./EySL0KLLL!QK_NKv~&q!q1-.()!!& {71B"$Z 1t&& ' ' "%(%$$4I33%a+QK%%%iJ66!aR=D4!%%'>A#5"@"@"Ke"STJ921a8DA7?5JqbXXZ!^$>$>y$IE$QRJ__Q,
C Dw-78ZjmZ
8AKLA'!WT]$7JL(23
1affh

3y /j 9L 4s   N7N<.OOc                 .   ^ [        U4S jU  5       5      $ )z2Checks if the matrix M is independent of t or not.c              3   N   >#    U  H  oR                  TS S9S   S:H  v   M     g7f)T)r   r   r   N)ry   )r<   rZ   r|   s     r?   r@   &_matrix_is_constant.<locals>.<genexpr>  s)     Iqt""1T"215:qs   "%)all)r  r|   s    `r?   r   r     s    IqIIIrR   c                 T   SSK Jn  [        X5      nU" U /U Vs/ s H  oUR                  X$U   5      PM     snQ7SS06n/ nU HV  nU Vs/ s H5  n[	        UR                  X$U   5      XR                  X$U   5         5      PM7     n	nUR                  U	5        MX     U$ s  snf s  snf )az  
Function that solves for highest order derivatives in a system

Explanation
===========

This function inputs a system of ODEs and based on the system,
the dependent variables and their highest order, returns the system
in the following form:

.. math::
    X'(t) = A(t) X(t) + b(t)

Here, $X(t)$ is the vector of dependent variables of lower order, $A(t)$ is
the coefficient matrix, $b(t)$ is the non-homogeneous term and $X'(t)$ is the
vector of dependent variables in their respective highest order. We use the term
canonical form to imply the system of ODEs which is of the above form.

If the system passed has a non-linear term with multiple solutions, then a list of
systems is returned in its canonical form.

Parameters
==========

eqs : List
    List of the ODEs
funcs : List
    List of dependent variables
t : Symbol
    Independent variable

Examples
========

>>> from sympy import symbols, Function, Eq, Derivative
>>> from sympy.solvers.ode.systems import canonical_odes
>>> f, g = symbols("f g", cls=Function)
>>> x, y = symbols("x y")
>>> funcs = [f(x), g(x)]
>>> eqs = [Eq(f(x).diff(x) - 7*f(x), 12*g(x)), Eq(g(x).diff(x) + g(x), 20*f(x))]

>>> canonical_eqs = canonical_odes(eqs, funcs, x)
>>> canonical_eqs
[[Eq(Derivative(f(x), x), 7*f(x) + 12*g(x)), Eq(Derivative(g(x), x), 20*f(x) - g(x))]]

>>> system = [Eq(Derivative(f(x), x)**2 - 2*Derivative(f(x), x) + 1, 4), Eq(-y*f(x) + Derivative(g(x), x), 0)]

>>> canonical_system = canonical_odes(system, funcs, x)
>>> canonical_system
[[Eq(Derivative(f(x), x), -1), Eq(Derivative(g(x), x), y*f(x))], [Eq(Derivative(f(x), x), 3), Eq(Derivative(g(x), x), y*f(x))]]

Returns
=======

List

r   )solvedictT)sympy.solvers.solversrH  rF   r   r	   rl   )
rD   rE   r|   rH  r   r>   	canon_eqssystemsr=   systems
             r?   canonical_odesrN    s    t ,C'EcU5I54YYq+65IUPTUIG[`a[`SW"TYYq+.99Qd3L0MN[`av  N J bs   B 
<B%c                     [        X5      nX -  X-  -
  R                  [        5      R                  [        5      R                  nUc  SOUnX#4$ )a  
Helper function for determining if the Matrix passed is commutative with its antiderivative

Explanation
===========

This function checks if the Matrix $A$ passed is commutative with its antiderivative with respect
to the independent variable $t$.

.. math::
    B(t) = \int A(t) dt

The function outputs two values, first one being the antiderivative $B(t)$, second one being a
boolean value, if True, then the matrix $A(t)$ passed is commutative with $B(t)$, else the matrix
passed isn't commutative with $B(t)$.

Parameters
==========

A : Matrix
    The matrix which has to be checked
t : Symbol
    Independent variable

Examples
========

>>> from sympy import symbols, Matrix
>>> from sympy.solvers.ode.systems import _is_commutative_anti_derivative
>>> t = symbols("t")
>>> A = Matrix([[1, t], [-t, 1]])

>>> B, is_commuting = _is_commutative_anti_derivative(A, t)
>>> is_commuting
True

Returns
=======

Matrix, Boolean

F)r8   r   r   r   r   )r   r|   r   r   s       r?   r   r   9  sK    V 	!AC!#I((0::<HWWL(05lL?rR   c                     S nU  H1  nUR                  U5      S   nUR                  U5      (       d  M/  Un  O   Ub.  X-  R                  [        5      n[	        XQ5      nU(       a  X%4OS nU$ )Nr   )ry   r   r   r,   r   )r   r|   r   element	temp_term
A_factored
can_factors          r?   r   r   l  sr    D**1-a0	==D	  f''0
(7
%/!TKrR   c                    [        X5      nSnUb  SUS   -  nUR                  5       nU(       a  [        UR                  5       U5      nUR	                  5       nUS   S   S;   a  [        US5      nUu  pxpn[        [        U5      SS9n[        [        U5      SS9n[        [        U	SU-  U-  -
  5      SS9nUSU-  U-  :H  =(       a    U
SU-  U-  :H  nXS-  -  X-  -   U-   nX24$ SnX24$ )	NFr   r   )r      rV  T)forcer   )r   r   r%   r   ri   _get_poly_coeffsr*   r   )r   r|   r   is_type2polyri   csrv   r   r   r   r{   a1c1b1s                  r?   _is_second_order_type2r_  |  s   !DHay%%'DKKM1%!9Q<6!!$*BMA!47$/B47$/B4AbDG,D9BQrT"W81"R<Hd7RT>B&D
 > H>rR   c                     [        US-   5       Vs/ s H  nSPM     nn[        U R                  5       U R                  5       5       H  u  pEXCSUS   -
  '   M     U$ s  snf )Nr   r   r   )r   rg   rh   ri   )rZ  r   r9  r[  r   ms         r?   rX  rX    sV    57^	$^!^B	$DKKM4;;=12ad7 2I 
%s   Ac           	         SS0nU R                   S   n[        X5      (       a  [        X5      (       a  U$ XU-  -   R                  [        5      R                  (       a  UR                  SU S.5        U$ U R                  (       a  Ub  UR                  (       a  [        X5      u  pgU(       a  [        [        Xr5      S5      u  pn	XS-  R                  5       -  R                  [        5      US-  S-  X-  -
  [        XU5      -  -   n
[        SU-  U5      n[        S	R                  U5      5      nUR                  S
U
[        U5      USUS.5        U$ )a  
Works only for second order system in its canonical form.

Type 0: Constant coefficient matrix, can be simply solved by
        introducing dummy variables.
Type 1: When the substitution: $U = t*X' - X$ works for reducing
        the second order system to first order system.
Type 2: When the system is of the form: $poly * X'' = A*X$ where
        $poly$ is square of a quadratic polynomial with respect to
        *t* and $A$ is a constant coefficient matrix.

r   type0r   r4  )r   A1r   rV  r   r   r-  T)r   A0g(t)r   r;  r   )r   r   r   r   r   r   r_  rX  r%   r   r,   r$   r8   r   r   r   )rd  re  r|   r   r   r  rY  r   rv   r   r   r   r   s                r?   _match_second_order_typerg    s+     )E
A2!!&9"&@&@
T	Z(77'<= L 
			Q-=-=/6&tD}a8GA!1W$$&&11':ad1fqslCPQI=UUAAdFA&CQ(BLLgQ"&t*SD "$ % LrR   c           	         [        U Vs/ s H  oCUR                  U5      -  U-
  PM     sn5      n[        XX1-  5      n[        Xe5       VVs/ s H  u  px[	        X5      PM     n	nn[        XU5      S   n	U	$ s  snf s  snnf )a{  
For a linear, second order system of ODEs, a particular substitution.

A system of the below form can be reduced to a linear first order system of
ODEs:
.. math::
    X'' = A(t) * (t*X' - X) + b(t)

By substituting:
.. math::  U = t*X' - X

To get the system:
.. math::  U' = t*(A(t)*U + b(t))

Where $U$ is the vector of dependent variables, $X$ is the vector of dependent
variables in `funcs` and $X'$ is the first order derivative of $X$ with respect to
$t$. It may or may not reduce the system into linear first order system of ODEs.

Then a check is made to determine if the system passed can be reduced or not, if
this substitution works, then the system is reduced and its solved for the new
substitution. After we get the solution for $U$:

.. math::  U = a(t)

We substitute and return the reduced system:

.. math::
    a(t) = t*X' - X

Parameters
==========

A: Matrix
    Coefficient matrix($A(t)*t$) of the second order system of this form.
b: Matrix
    Non-homogeneous term($b(t)$) of the system of ODEs.
funcs: List
    List of dependent variables
t: Symbol
    Independent variable of the system of ODEs.

Returns
=======

List

r   )r!   r   rB  rg   r	   rN  )
r   r   rE   r|   r>   Urn   r   ureduced_eqss
             r?   _second_order_subs_type1rl    sz    b 	%8%$$))A,%%89A
aAC
 C(+C42a8K4 Q7:K 9 5s    A8A=c           
      r   U Vs/ s H  o3R                   R                  PM     nnU Vs/ s H,  n[        [        SR	                  U5      5      5      " U5      PM.     nnU [        U5      -  n[        Xg5       VVs/ s H!  u  p8[        UR                  US5      U5      PM#     n	nnX4$ s  snf s  snf s  snnf )a  
Returns a second order system based on the coefficient matrix passed.

Explanation
===========

This function returns a system of second order ODE of the following form:

.. math::
    X'' = A * X

Here, $X$ is the vector of dependent variables, but a bit modified, $A$ is the
coefficient matrix passed.

Along with returning the second order system, this function also returns the new
dependent variables with the new independent variable `t_` passed.

Parameters
==========

A: Matrix
    Coefficient matrix of the system
funcs: List
    List of old dependent variables
t_: Symbol
    New independent variable

Returns
=======

List, List

r   r   )	r>   rL   r   r   r   r!   rg   r	   r   )
r   rE   r   r>   
func_namesname	new_funcsrhssrc   new_eqss
             r?   _second_order_subs_type2rs    s    D 277))$$J7EOPZT%T 234R8ZIPvi  D:=i:NO:NYTr$))B"C(:NGO 8POs   B)3B.;(B3c                 @   ^ [        U4S j[        U 5       5       5      $ )Nc              3   r   >#    U  H,  u  p[        UTU-  -  R                  [        5      T5      v   M.     g 7fr;   )r   r   r,   )r<   r`   r   r|   s      r?   r@   #_is_euler_system.<locals>.<genexpr>)  s1     ]}tq"AadF#5#5g#>BB}s   47)rF  	enumerate)r   r|   s    `r?   _is_euler_systemrx  (  s    ]yY[}]]]rR   c                   ^^ [        U5      [        U 5      :w  a  [        SU-  5      eU H*  n[        UR                  5      S:w  d  M  [        SU-  5      e   [        X5      m[	        U4S jU 5       5      nUS:  nUS:H  =(       a    [        U4S jU 5       5      n U(       d  [        XT5      OU /n[        U5      S:X  a  [        US   UTU5      u  pOSUS	.nU$ SnU
R                  (       a  SOSn[        U 5      U UTUUSS.nU(       d  XS'   [        U4S jU	 5       5      nU(       dU  U	S   nXS'   [        UT5      nXS'    [        UTU
S9nUR                  U5        UR                  S5      nU(       d  UUS'   U$ SUS'   U(       a+  U	SS
 u  nn[        UUT5      nUR                  U5        SUS'   US   S:X  a  U(       d  [!        U	T5      nU(       a0  [#        SR%                  T5      5      nUR                  SSUS.5        OoS n['        U	S   T5      n[        S U	SS  5       5      (       aC  Ub@  U" US   5      (       d0  US   R)                  5       u  nnUR                  SUUS   USS.5        US   S:w  a  U(       a  UR                  SS
5        XkS'   U$ ! [         a     g
f = f! [         a     g
f = f) a
  
Returns a dictionary with details of the eqs if the system passed is linear
and can be classified by this function else returns None

Explanation
===========

This function takes the eqs, converts it into a form Ax = b where x is a vector of terms
containing dependent variables and their derivatives till their maximum order. If it is
possible to convert eqs into Ax = b, then all the equations in eqs are linear otherwise
they are non-linear.

To check if the equations are constant coefficient, we need to check if all the terms in
A obtained above are constant or not.

To check if the equations are homogeneous or not, we need to check if b is a zero matrix
or not.

Parameters
==========

eqs: List
    List of ODEs
funcs: List
    List of dependent variables
t: Symbol
    Independent variable of the equations in eqs
is_canon: Boolean
    If True, then this function will not try to get the
    system in canonical form. Default value is False

Returns
=======

match = {
    'no_of_equation': len(eqs),
    'eq': eqs,
    'func': funcs,
    'order': order,
    'is_linear': is_linear,
    'is_constant': is_constant,
    'is_homogeneous': is_homogeneous,
}

Dict or list of Dicts or None
    Dict with values for keys:
        1. no_of_equation: Number of equations
        2. eq: The set of equations
        3. func: List of dependent variables
        4. order: A dictionary that gives the order of the
                  dependent variable in eqs
        5. is_linear: Boolean value indicating if the set of
                      equations are linear or not.
        6. is_constant: Boolean value indicating if the set of
                      equations have constant coefficients or not.
        7. is_homogeneous: Boolean value indicating if the set of
                      equations are homogeneous or not.
        8. commutative_antiderivative: Antiderivative of the coefficient
                      matrix if the coefficient matrix is non-constant
                      and commutative with its antiderivative. This key
                      may or may not exist.
        9. is_general: Boolean value indicating if the system of ODEs is
                       solvable using one of the general case solvers or not.
        10. rhs: rhs of the non-homogeneous system of ODEs in Matrix form. This
                 key may or may not exist.
        11. is_higher_order: True if the system passed has an order greater than 1.
                             This key may or may not exist.
        12. is_second_order: True if the system passed is a second order ODE. This
                             key may or may not exist.
    This Dict is the answer returned if the eqs are linear and constant
    coefficient. Otherwise, None is returned.

zDNumber of functions given is not equal to the number of equations %sr   zOdsolve() and classify_sysode() work with functions of one variable only, not %sc              3   .   >#    U  H
  nTU   v   M     g 7fr;   rJ   r<   r>   r   s     r?   r@   *_classify_linear_system.<locals>.<genexpr>  s     5utuT{ur,  r   c              3   4   >#    U  H  nTU   S :H  v   M     g7f)r   NrJ   r{  s     r?   r@   r|    s     /SUTdq0@Us   r   T)is_implicitrK  NF)no_of_equationr=   r>   r   	is_linearr   
is_generalrc   c              3   <   >#    U  H  n[        UT5      v   M     g 7fr;   )r   )r<   A_r|   s     r?   r@   r|    s     >2R)"a002rB   r   is_constantr   r   commutative_antiderivativerc  r   is_second_orderr   r4  )r;  r   r   c                 V    U [         R                  " U R                  S   U S   5      :H  $ )Nr   r   )r!   jordan_blockr   )r  s    r?   rw   )_classify_linear_system.<locals>.<lambda>  s"    a6+>+>qwwqz1T7+S&SrR   r   c              3   8   #    U  H  oR                   v   M     g 7fr;   )r   )r<   r   s     r?   r@   r|    s     :A''s   r-  )r   r?  f(t)r   r;  is_higher_order)r   r  rk   rF   rC   rF  rN  r   rT   r   r   r   r   r   poprg  rx  r   r   r   jordan_form)rD   rE   r|   is_canonr>   system_orderr  r  rK  r   r   r   r  r   r  r   r=  r   rd  re  match_second_orderis_eulerr   	is_jordanrp   r   r?  r   s     `                        @r?   _classify_linear_systemr  ,  s   \ 5zSX_bgghh tyy>Q 57;< = =  C'E5u55L"Q&O"a'SC/SU/S,SO9AN3q1u	y>Q(1uaNEB  $&E
 L I --T5N
 c((E e>2>>K
 qEl *!Q/*m	*1a15K 	[!#342@E./$+ !VFB!9"b!!DLL+,'+E#$
 #$/'A.HELLO,'$&( ) T	&r"vq1:Ab:::u?PYbchijckYlYl 8//1DAqLLgA*/(d"T U '(G3		+T2#2 c  L # 		s*    8J' J' J7 '
J43J47
KKc                     / nU  H5  nUR                  [        U[        5      (       a  UO[        US5      5        M7     U$ r  )rl   rj   r
   r	   )rD   processed_eqsr=   s      r?   _preprocess_eqsr    s;    M:b(#;#;RBK  rR   c                     0 n0 n[        U5      nU  HR  nUR                  R                  [        5      u  nUR                  R                  [        5      U1-
  U-  nXsU'   XRU'   MT     X24$ r;   )r   rb   re   r   rc   )rD   rE   eqsorigeqsmapfuncsetr=   f1f2ss           r?   	_eqs2dictr    si    GF%jGffll<(vv||L)RD0G;r
	 
 ?rR   c                     [        U 5      nU R                  5        VVVs/ s H  u  p#U  H  oBU4PM     M     nnnnX4nU$ s  snnnf r;   )rd   r   )r   nodesr  r  f2edgesGs          r?   _dict2graphr    sB    GE%&WWY=Y'"2"XXYE=	AH >s   Ac                     U u  p# [        X#US5      u  u  pEn[        XQ5      (       a  UR                  (       a  gg! [        [        4 a     gf = f)Nr   FT)r   rT   rH   r   r   )sccr|   rD   rE   rd  re  r   s          r?   	_is_type1r    sV    JC*3q!<! 2!!a&6&6 }- s   ; AAc                   ^^ [        [        U T5      5       VVs/ s H  u  p4[        XB5      (       d  M  UPM     nnn[        5       n[        U5       HP  u  nmXWS-   S   H?  n[	        UU4S jX    5       5      (       d  M"  U T   X   -   X'   UR                  T5        MA     MR     [        U 5       VVs/ s H  u  p4X6;  d  M  UPM     n nnU $ s  snnf s  snnf )Nr   c              3   J   >#    U  H  oR                  TT   5      v   M     g 7fr;   )r   )r<   eq2rE   r`   s     r?   r@   ,_combine_type1_subsystems.<locals>.<genexpr>  s     =7758$$s    #)rw  rg   r  r   r   r  )		subsystemrE   r|   r`   sysindicesremoveipr  s	    ` `     r?   _combine_type1_subsystemsr    s    (Y)>?U?VQ9SCTq?GUUF7#AAA=	===(|il:	

1   $
 $-Y#7K#71?#7IK V Ls   CC5CCc           
      P   [        X5      u  p4/ n[        [        U5      5       Hn  nU Vs0 s H  owX7   _M	     nn[        [        U5      5      n	U	 V
Vs/ s H  o Vs/ s H  otU   PM	     snPM     nn
n[	        XU5      nUR                  U5        Mp     U$ s  snf s  snf s  snn
f r;   )r  r3   r  r5   r  rl   )rD   rE   r|   r  r  
subsystemsccfeqsmap_csccsr  r  s               r?   _component_divisionr  &  s    
  +OFJ";v#67*,-"QvyL"-,[-BC:>?$3#.#Qaj#.$	?-iqA	)$ 8  ..?s   B	B"B+B"B"c           	      &   U S   nU S   nU R                  SS 5      nU R                  SS 5      nSU ;   a  U S   OUnU S   nU R                  SS 5      nU S   n[        XQX6XtS	9n[        X(5       V	V
s/ s H  u  p[        X5      PM     nn	n
U$ s  sn
n	f )
Nr|   r>   rc   r   r   r   r  r   )r   r   r   r   )getrB  rg   r	   )r   r|   rE   rc   r   r   r   r   r@  r  r   rn   s               r?   _linear_ode_solverr  9  s    c
A&ME
))E4
 C
))E4
 Cu}d!AlA 			.5A#$DQS"&1J !$E 6
7 62a8 6C
7J 8s   1Bc                     U $ r;   rJ   )r2  s    r?   rw   rw   O  s    rR   c           
          U  Vs0 s H  o3R                   UR                  _M     nnU Vs/ s H  n[        XTU" U5         5      PM     sn$ s  snf s  snf r;   )rb   rc   r	   )rD   rE   r  r{   eq_dictr  s         r?   _select_equationsr  O  sJ    %()Suuaee|SG),12EqBq#a&/"E22 *2s
    AAc                   ^^ U S   nU S   nU S   mU S   nU R                  SS5      nU R                  SS5      nU R                  S	S5      nU=(       a    US
:H  nU=(       a    US:H  =(       a    SU ;   nU(       aR  [        XTU R                  SS 5      U R                  SS 5      U R                  SS 5      UU R                  SS 5      S9u  pOQ[        XTUX@R                  SS 5      U R                  SS 5      U R                  SS 5      U R                  SS 5      S9	u  pU(       a  U R                  ST5      mU(       d*  [        X Vs/ s H  oR	                  T5      PM     sn5      n	S n U(       d  [        XT5      nUc   [        XT5      nUc  U$ U=(       a    US:H  nU(       a  SOSm[        XUU4S jS9nU R                  S	S5      (       a  U(       aO  U S   nU S   nU Vs/ s H6  n[        UR                  UR                  R                  TU5      U-  5      PM8     nnU$ U(       a7  U S   mU S   nU Vs/ s H  nUR                  U[        T5      5      PM      nnU$ U(       aY  U S   nU[        U Vs/ s H  nUR                  PM     sn5      -  n[        UU5       VVs/ s H  u  nn[        UU5      PM     nnnU$ s  snf ! [         a    S n GN^f = f! [         a    S n GNaf = fs  snf s  snf s  snf s  snnf )Nr=   r>   r|   r   r   rc  r  Fr;  r4  r-  r   rd  re  rc   r   )rd  re  r   r   r   r?  r  )rE   r   r?  f_tr   r   __r9  c                    > [        [        SR                  U R                  R                  T5      5      5      " T5      $ )Nz{}{}0)r   r   r   r>   rL   )r2  r|   underscoress    r?   rw   *_higher_order_ode_solver.<locals>.<lambda>  s)    (5Yd9e3f*ghi*jrR   r  rf  r   )r  _second_order_to_first_order_higher_order_to_first_orderr  r   _strong_component_solverr   _component_solverr	   rb   rc   r   r   r!   rg   )r   rD   rE   sysorderr   r  r;  r  is_higher_order_type2rr  rp  r  rn   is_second_order_type2g_tr   r   r   r@  r|   r  s                      @@r?   _higher_order_ode_solverr  T  s   
+C&MEc
AW~H99'1Dii 159OYY/7N1$'/H*OtwO3%<9#a=BYYtT=RW\W`W`aegkWl<AIIeT<RY]=BYYtT=RT
 :#RW?CyyQTVZG[>CiiPT>U<AIIc4<PTYT]T]^ceiTjl
 IIdA #G-KAffQi-KL
C$*7qAC
 {	#G:C {
+?($cK
C jlC yy!5)) -C,C@CD12aeeQUUZZ3/#56CD J c
A+C0341166#s1v&C4 J #c
AVC$8CqQUUC$899J(+E:(>?(>12a8(>C?JW .L   # 	C	" E 5 %9?sB   K	
,K K! (=K4>%K9=K>
+LKK!K10K1c                    SSK JnJn  [        XUSS9nS nU(       a  X%S'   UR	                  SS5      (       a  [        U5      nO"UR	                  SS5      (       a  [        U5      nUcq  [        U 5      S	:X  ab  U" U S   US   S
9n[        U S   5      R                  n[        [        U S   US   5      5       Vs/ s H  n[        5       PM     n	nU" XgU	S9nU/nU$ s  snf )Nr   )dsolveconstant_renumberT)r  r|   r  Fr  r   )r>   )	variablesnewconstants)sympy.solvers.ode.oder  r  r  r  r  r  r   r   r   r   r0   r   )
rD   rE   r|   r  r  r   rn   r  r9  new_constantss
             r?   r  r    s    ?#CDAE
C
 c
99&..*51CYY{E**$U+C ;3s8q=QeAh/Cc!f22I.3Ic!feAh4O.PQ.PUW.PMQ#C=YC%C J Rs   :Cc                 ^    U  Vs/ s H  oR                   R                  S   PM     sn$ s  snf r  )rb   rk   )rD   r=   s     r?   _get_funcs_from_canonr    s$    %()SrFFKKNS)))s   "*c                    / nU  H  nX#-  nM	     [        U5      n[        X$U5      nU(       a  U$ / nU  H~  nUn[        U5      nU VVs/ s H8  ofR                  U Vs0 s H  owR                  UR                  _M     sn5      PM:     nnn[        XU5      n	U	c  [        [        S5      5      eXY-  nM     U$ s  snf s  snnf )NzZ
                The system of ODEs passed cannot be solved by dsolve_system.
            )r  r  r   rb   rc   r   r6   )
wccr|   rD   r  rE   rn   r=   r   comp_eqsscc_sols
             r?   _weak_component_solverr    s    
 C
 !#&E
"3q
1C


C%c* DGG3RGG373aUUAEE\3783G*8A>?%j 2 '   	! $ J 8Gs   	B= B8=B=8B=c                 P    [        XU5      n/ nU H  nU[        XR5      -  nM     U$ r;   )r  r  )rD   rE   r|   
componentsrn   r  s         r?   r  r    s6    $S3J
C 	%c--  JrR   c                    USL nUSL n	US:X  a  U(       d!  US:X  a  U	(       d  US:X  aE  U(       d  U	(       a7  [        XUS5      u  u  ppVU
R                  (       d  [        [        S5      5      eUS:X  a5  [	        XEU5      nUS   nUR                  SS5      nUR                  S	S5      n[        R                  US5      nUS:X  a9  Uc  [        [        U 5      5      n[        XFX5      n [        R                  US
5      nUS:X  aC  Uc  [        SR                  U5      5      nUn[        XQU5      u  p[        R                  US5      n[        XX!S9$ )a/  
Expects the system to be in second order and in canonical form

Explanation
===========

Reduces a second order system into a first order one depending on the type of second
order system.
1. "type0": If this is passed, then the system will be reduced to first order by
            introducing dummy variables.
2. "type1": If this is passed, then a particular substitution will be used to reduce the
            the system into first order.
3. "type2": If this is passed, then the system will be transformed with new dependent
            variables and independent variables. This transformation is a part of solving
            the corresponding system of ODEs.

`A1` and `A0` are the coefficient matrices from the system and it is assumed that the
second order system has the form given below:

.. math::
    A2 * X'' = A1 * X' + A0 * X + b

Here, $A2$ is the coefficient matrix for the vector $X''$ and $b$ is the non-homogeneous
term.

Default value for `b` is None but if `A1` and `A0` are passed and `b` is not passed, then the
system will be assumed homogeneous.

Nr4  r-  r)  r   zG
                The system must be in its canonical form.
            r   rd  re  r   r   rE   )r   is_Identityr  r6   rg  r  rI  fromkeysr    r   rl  r   r   rs  r  )rD   rE   r|   r   rd  re  r   r   is_a1is_a0A2r   	sys_orders                r?   r  r    s9   > $JE$JEEtw5FN.s1a@~~Z )    v~(3'(YYtT"YYtT"eQ'Iw9c#hA&re7MM%+	w:Q(B-b<
MM%+	'GGrR   c                    U b  Ub  [        X5      (       d  [        [        S5      5      eUc(  Ub%  UR                  (       d  [        [        S5      5      e[	        U Vs/ s H@  n[        [        SR                  UR                  R                  5      5      5      " U5      PMB     sn5      nUR                  X45      X-  U-  -
  n	Ub&  UR                  (       d  XR                  5       U-  -  n	[        XU5      S   n	X4$ s  snf )Nzi
            Correctly input for args 'A' and 'f_t' for Linear, Higher Order,
            Type 2
        zN
            Provide the keyword 'P' for matrix P in A = P * J * P-1.
        z{}__0r   )r   r  r6   r   r!   r   r   r   r>   rL   r   r   rN  )
r?  r  rE   r|   	max_orderr   r   r  rp  rr  s
             r?   "_higher_order_type2_to_sub_systemsr  ;  s     	yCK':1'@'@ %   	
 	yQ]1+;+; %   	 UZ[UZPQw~~affoo'F!GHKUZ[\InnQ*SWy-@@G}Q--557Q;W3A6G \s   ADc                   ^^^ ^! Uc  TR                  5       nUS:X  Ga  [        SR                  U5      5      m!U Vs/ s H@  n[        [	        SR                  UR
                  R                  5      5      5      " T!5      PMB     nn[        U4S jU 5       5      n[        [        X75      5      n	[        T!5      X'   [        [	        5       5      m U4S jm[        SUS-   5       H  n
T " [        T!5      5      R                  T!U
5      T!U
-  -  nT" U5      n[        U
S-   5       Vs/ s H  oU;   a  X   OSPM     nn[        U U!4S j[        U5       5       5      X*-  -  nU	R!                  [        X75       VVs0 s H.  u  nnUR                  X*5      UR#                  T " T!5      U5      _M0     snn5        M     U  Vs/ s H  nUR#                  U	5      PM     nn[        X75       VVs0 s H  u  nnUTU   _M     nnn[%        UUT!5      S   n['        UUT!US9$ US	:X  ak  UR)                  S
S 5      nUR)                  SS 5      nUR)                  SS 5      nUR)                  SS 5      n[        U4S jU 5       5      n[+        UUX2UUUS9$ / nU GH)  nUR
                  R                  n[        [	        SR                  U5      5      5      " U5      nUR-                  U5        UU0n	/ n[        STU   5       H  n[        [	        SR                  UU5      5      5      " U5      nUU	UR                  UU5      '   UR-                  U5        U	UR                  UUS-
  5         n[/        UR                  U5      U5      nUR-                  U5        M     U  Vs/ s H  nUR#                  U	5      PM     snU-   n GM,     X4$ s  snf s  snf s  snnf s  snf s  snnf s  snf )Nr4  r   c              3   .   >#    U  H
  nTU   v   M     g 7fr;   rJ   r<   r>   r  s     r?   r@   /_higher_order_to_first_order.<locals>.<genexpr>\       :ED	$Er,  c                 8  > [        U [        5      (       a.  U R                  S   S   nU R                  S   n[        X!5      S0$ [        U [        5      (       aA  U R                  S   n[        T" U R                  S   5      R                  5       5      S   nXC0$ [        U [        5      (       ak  0 nU R                   HW  n[        U[        5      (       a  UR                  T" U5      5        M1  [        T" U5      R                  5       5      S   nSXT'   MY     U$ g )Nr   r   )	rj   r   rk   r0   r   rd   keysr   r   )r   free_symbolr   rq   r   rh   arg _get_coeffs_from_subs_expressions          r?   r  F_higher_order_to_first_order.<locals>._get_coeffs_from_subs_expressionb  s    $%%"iil1oyy|!$4a88$$$		!=diilKPPRSTUV~%$$$99C!#s++&Fs&KL !%%Ec%J%O%O%Q RST U() %  %rR   r   r   c              3   ^   >#    U  H"  u  pT" T5      R                  TU5      U-  v   M$     g 7fr;   )r   )r<   r`   r   free_functionr   s      r?   r@   r  ~  s3      +) FJQ}R055b!<q@)s   *-r  r-  r?  r  r   r   c              3   .   >#    U  H
  nTU   v   M     g 7fr;   rJ   r  s     r?   r@   r    r  r,  )r   r   z{}_0z{}_{})r  r   r   r   r   r>   rL   rC   rI  rg   r   r   r   r   sumrw  r   r   rN  r  r  r  rl   r	   )"rD   r  r|   rE   r   kwargsr  rp  r  	subs_dictr   r   
coeff_dictr   rh   expr_to_subsnfr=   rr  new_sys_orderr?  r  r   r   	prev_func	func_namer>   r`   new_funcprev_fnew_eqr  r  r   s"    `                             @@@r?   r  r  T  s   }  wELLO$QVWQVAXeELL$ABCBGQV	W:E::	U./	2w	 )	0 q)a-(A R)..r15b!e;D9$?JSXYZ]^Y^S_`S_%J+>j'AES_F` +!&)+ +-.T2L+.u+@B+@%!R  ffQlL,=,=mB>OQS,TT+@B C ) 144"2779%47:57LM7LeaYq\)7LM )R8;+G]BiXX
 wJJsD!jj%JJsD!JJsD!:E::	1!S%IQRVWXX I	NN++	fmmI678;%	q)I./AgnnY&B CDQGH.6IinnQ*+X&y~~a156FA1FNN6" 0 -00Cbrwwy!C07:! $ >i XD aB 5MR 1s$   AO&O:5O?O*OOc                    SSK JnJnJn  [	        U 5      (       d  [        [        S5      5      e[        U 5      n Ub)  [        U[        5      (       d  [        [        S5      5      eUc  U" U 5      n[        S U 5       5      (       a  [        [        S5      5      e[        U 5      [        U5      :w  a  [        [        S5      5      eUb)  [        U[        5      (       d  [        [        S	5      5      eUcC  [        [        U S   R                  [        5      5      S   R                  [        5      5      S   n/ n	[        XU5      n
U
 H0  n [!        XU5      nUc  [%        XU5      nU	R'                  U5        M2     U	(       a  / n[)        U 6 R*                  nU	 H  n[-        X5      nU" XS
9nU(       a?  [)        U6 R*                  U-
  nU" XX5      nU Vs/ s H  nUR/                  U5      PM     nnU(       a   [)        U6 R*                  U-
  n[1        X/XS9nUR'                  U5        M     Un	U	$ ! ["         a    Sn Nf = fs  snf )a?  
Solves any(supported) system of Ordinary Differential Equations

Explanation
===========

This function takes a system of ODEs as an input, determines if the
it is solvable by this function, and returns the solution if found any.

This function can handle:
1. Linear, First Order, Constant coefficient homogeneous system of ODEs
2. Linear, First Order, Constant coefficient non-homogeneous system of ODEs
3. Linear, First Order, non-constant coefficient homogeneous system of ODEs
4. Linear, First Order, non-constant coefficient non-homogeneous system of ODEs
5. Any implicit system which can be divided into system of ODEs which is of the above 4 forms
6. Any higher order linear system of ODEs that can be reduced to one of the 5 forms of systems described above.

The types of systems described above are not limited by the number of equations, i.e. this
function can solve the above types irrespective of the number of equations in the system passed.
But, the bigger the system, the more time it will take to solve the system.

This function returns a list of solutions. Each solution is a list of equations where LHS is
the dependent variable and RHS is an expression in terms of the independent variable.

Among the non constant coefficient types, not all the systems are solvable by this function. Only
those which have either a coefficient matrix with a commutative antiderivative or those systems which
may be divided further so that the divided systems may have coefficient matrix with commutative antiderivative.

Parameters
==========

eqs : List
    system of ODEs to be solved
funcs : List or None
    List of dependent variables that make up the system of ODEs
t : Symbol or None
    Independent variable in the system of ODEs
ics : Dict or None
    Set of initial boundary/conditions for the system of ODEs
doit : Boolean
    Evaluate the solutions if True. Default value is True. Can be
    set to false if the integral evaluation takes too much time and/or
    is not required.
simplify: Boolean
    Simplify the solutions for the systems. Default value is True.
    Can be set to false if simplification takes too much time and/or
    is not required.

Examples
========

>>> from sympy import symbols, Eq, Function
>>> from sympy.solvers.ode.systems import dsolve_system
>>> f, g = symbols("f g", cls=Function)
>>> x = symbols("x")

>>> eqs = [Eq(f(x).diff(x), g(x)), Eq(g(x).diff(x), f(x))]
>>> dsolve_system(eqs)
[[Eq(f(x), -C1*exp(-x) + C2*exp(x)), Eq(g(x), C1*exp(-x) + C2*exp(x))]]

You can also pass the initial conditions for the system of ODEs:

>>> dsolve_system(eqs, ics={f(0): 1, g(0): 0})
[[Eq(f(x), exp(x)/2 + exp(-x)/2), Eq(g(x), exp(x)/2 - exp(-x)/2)]]

Optionally, you can pass the dependent variables and the independent
variable for which the system is to be solved:

>>> funcs = [f(x), g(x)]
>>> dsolve_system(eqs, funcs=funcs, t=x)
[[Eq(f(x), -C1*exp(-x) + C2*exp(x)), Eq(g(x), C1*exp(-x) + C2*exp(x))]]

Lets look at an implicit system of ODEs:

>>> eqs = [Eq(f(x).diff(x)**2, g(x)**2), Eq(g(x).diff(x), g(x))]
>>> dsolve_system(eqs)
[[Eq(f(x), C1 - C2*exp(x)), Eq(g(x), C2*exp(x))], [Eq(f(x), C1 + C2*exp(x)), Eq(g(x), C2*exp(x))]]

Returns
=======

List of List of Equations

Raises
======

NotImplementedError
    When the system of ODEs is not solvable by this function.
ValueError
    When the parameters passed are not in the required form.

r   )	solve_ics_extract_funcsr  zQ
            List of equations should be passed. The input is not valid.
        NzG
            Input to the funcs should be a list of functions.
        c              3   R   #    U  H  n[        UR                  5      S :g  v   M     g7f)r   N)r   rk   )r<   r>   s     r?   r@    dsolve_system.<locals>.<genexpr>   s     
1543tyy>Q5s   %'zn
            dsolve_system can solve a system of ODEs with only one independent
            variable.
        zN
            Number of equations and number of functions do not match
        zE
            The independent variable must be of type Symbol
        )r  )r   )r  r  r  r  r4   r  r6   r  rj   rd   r   r   r   re   r   rN  r  r   r  rl   r   r   r  r   r   )rD   rE   r|   icsr   r-   r  r  r  solsrK  canon_eqrn   
final_solsr  	constantssolved_constantsr   s                     r?   dsolve_systemr    sL   z SRC== %   	 #
CE4!8!8 %   	 }s#

15
111 %   	
 3x3u: %   	 	}Z622 %   	 	yc!fll:./288@A!DDs1-I	*8A>C ;#HQ7CC  
3K,,	C#C/C#C=C!3K44y@	#,S#H 9<=Aqvv./=!3K44y@	c3	=c"   K= # 	C	( >s   H5I5II)Tr;   )NNr)  FN)F)r)  NNNN)NN)Nrc  )NNNFT)s
sympy.corer   r   r   sympy.core.containersr   sympy.core.exprtoolsr   sympy.core.numbersr   sympy.core.relationalr	   r
   sympy.core.sortingr   r   sympy.core.symbolr   r   sympy.core.functionr   r   r   r   r   r   sympy.functionsr   r   r   r   r   r   r   r   r   (sympy.functions.combinatorial.factorialsr   sympy.matricesr    r!   r"   r#   r$   sympy.polysr%   r&   sympy.simplifyr'   r(   r)   sympy.simplify.powsimpr*   r+   sympy.simplify.ratsimpr,   sympy.simplify.simplifyr-   sympy.sets.setsr.   sympy.solvers.deutilsr0   r   r1   r2   sympy.utilities.iterablesr3   r4   r5   sympy.utilities.miscr6   sympy.integrals.integralsr7   r8   rF   r  rH   rT   rs   r   r   r   r   r   r   r   rB  r   rN  r   r   r_  rX  rg  rl  rs  rx  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rJ   rR   r?   <module>r%     sz   " " ' -   . 8 +? ?8 8 8 > O O & 5 5 5 * , % + ;F F + 9L	J 	
	 	
 ,Dm`6RjHVsn 9>|~	J
EP0f :!H7t'T^CJ		&, '2 3
FX@*
"L
 AE59@HF2[|erR   