ó
9­\c        %   @  s  d  Z  d d l 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 d d l m Z m Z m Z m Z m Z d d l m Z d d	 l m Z d d
 l m Z m Z d d l m Z 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* m+ Z+ m, Z, d d l- m. Z. m/ Z/ d d l0 m1 Z1 m2 Z2 m3 Z3 m4 Z4 d d l5 m6 Z6 d d l7 m8 Z8 m9 Z9 m: Z: m; Z; m< Z< m= Z= d d l> m? Z? m@ Z@ mA ZA mB ZB mC ZC mD ZD mE ZE mF ZF mG ZG mH ZH mI ZI d d lJ mK ZK d d lL mM ZM mN ZN d d lO mP ZP mQ ZQ mR ZR mS ZS d d lT mU ZU mV ZV mW ZW mX ZX mY ZY mZ ZZ m[ Z[ d d l\ m] Z] d d l^ m_ Z_ m` Z` ma Za d d lb mc Zc d d ld me Ze d d lf mg Zg mh Zh mi Zi mj Zj mk Zk ml Zl mm Zm mn Zn d d lo mp Zp d d lq mr Zr d d ls mt Zt d d lu mv Zv d d  lw mx Zx my Zy mz Zz d d! l{ m| Z| m} Z} m~ Z~ d" d# d$ d% d& d' d( d) d* d+ d, d- d. d/ d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 d: d; d< d= d> d? d@ dA dB dC dD dE dF f% Z dG dH dI dJ dK dL dM dN dO f	 Z€ dP „  Z dQ dQ dR dS „ Z‚ dQ dR dT „ Zƒ e„ dU e… e„ e„ e„ dV dW dX „ Z† e… e„ dY „ Z‡ dZ „  Zˆ e„ e‰ e„ d[ „ ZŠ e„ d\ „ Z‹ d] „  ZŒ d^ „  Z d_ „  ZŽ d` „  Z da „  Z db „  Z‘ dc „  Z’ dd „  Z“ e„ de „ Z” e' dV ƒ df „  ƒ Z• e„ dg e… dh „ Z– e… di „ Z— dj „  Z˜ dk „  Z™ e' dV ƒ dl „  ƒ Zš e„ e„ dm „ Z› dn „  Zœ do „  Z dp „  Zž dq „  ZŸ dr „  Z  ds „  Z¡ dt „  Z¢ du „  Z£ dv „  Z¤ dw „  Z¥ dx „  Z¦ dy „  Z§ e„ dz „ Z¨ d{ „  Z© d| „  Zª d} „  Z« d~ „  Z¬ d „  Z­ d€ „  Z® d „  Z¯ d‚ dƒ „ Z° d‚ d„ „ Z± d‚ d… „ Z² d† „  Z³ d‡ „  Z´ dˆ „  Zµ d‰ „  Z¶ dŠ „  Z· d‚ d‹ „ Z¸ dŒ „  Z¹ d „  Zº dŽ „  Z» d „  Z¼ d „  Z½ d‘ „  Z¾ e„ e„ d’ „ Z¿ d“ „  ZÀ d” „  ZÁ e„ e„ dU e„ d• „ ZÂ e‰ d– „ ZÃ e‰ d— „ ZÄ e‰ d˜ „ ZÅ e‰ d™ „ ZÆ e‰ dš „ ZÇ e‰ d› „ ZÈ e‰ dœ „ ZÉ e‰ d „ ZÊ e‰ dž „ ZË dŸ „  ZÌ d  „  ZÍ d¡ „  ZÎ d¢ „  ZÏ d£ „  ZÐ d¤ „  ZÑ d¥ „  ZÒ d¦ „  ZÓ d§ „  ZÔ d¨ „  ZÕ d© „  ZÖ dª „  Z× d« „  ZØ d¬ „  ZÙ d­ „  ZÚ d® „  ZÛ d¯ „  ZÜ d° „  ZÝ d± „  ZÞ d² „  Zß d³ „  Zà d´ „  Zá dµ „  Zâ d¶ „  Zã d· „  Zä d¸ „  Zå d¹ „  Zæ dº „  Zç d» „  Zè d¼ „  Zé d½ „  Zê d¾ „  Zë d¿ „  Zì dÀ „  Zí dÁ „  Zî dÂ „  Zï dÃ „  Zð dÄ „  Zñ dÅ „  Zò dÆ S(Ç   s]5  
This module contains :py:meth:`~sympy.solvers.ode.dsolve` and different helper
functions that it uses.

:py:meth:`~sympy.solvers.ode.dsolve` solves ordinary differential equations.
See the docstring on the various functions for their uses.  Note that partial
differential equations support is in ``pde.py``.  Note that hint functions
have docstrings describing their various methods, but they are intended for
internal use.  Use ``dsolve(ode, func, hint=hint)`` to solve an ODE using a
specific hint.  See also the docstring on
:py:meth:`~sympy.solvers.ode.dsolve`.

**Functions in this module**

    These are the user functions in this module:

    - :py:meth:`~sympy.solvers.ode.dsolve` - Solves ODEs.
    - :py:meth:`~sympy.solvers.ode.classify_ode` - Classifies ODEs into
      possible hints for :py:meth:`~sympy.solvers.ode.dsolve`.
    - :py:meth:`~sympy.solvers.ode.checkodesol` - Checks if an equation is the
      solution to an ODE.
    - :py:meth:`~sympy.solvers.ode.homogeneous_order` - Returns the
      homogeneous order of an expression.
    - :py:meth:`~sympy.solvers.ode.infinitesimals` - Returns the infinitesimals
      of the Lie group of point transformations of an ODE, such that it is
      invariant.
    - :py:meth:`~sympy.solvers.ode_checkinfsol` - Checks if the given infinitesimals
      are the actual infinitesimals of a first order ODE.

    These are the non-solver helper functions that are for internal use.  The
    user should use the various options to
    :py:meth:`~sympy.solvers.ode.dsolve` to obtain the functionality provided
    by these functions:

    - :py:meth:`~sympy.solvers.ode.odesimp` - Does all forms of ODE
      simplification.
    - :py:meth:`~sympy.solvers.ode.ode_sol_simplicity` - A key function for
      comparing solutions by simplicity.
    - :py:meth:`~sympy.solvers.ode.constantsimp` - Simplifies arbitrary
      constants.
    - :py:meth:`~sympy.solvers.ode.constant_renumber` - Renumber arbitrary
      constants.
    - :py:meth:`~sympy.solvers.ode._handle_Integral` - Evaluate unevaluated
      Integrals.

    See also the docstrings of these functions.

**Currently implemented solver methods**

The following methods are implemented for solving ordinary differential
equations.  See the docstrings of the various hint functions for more
information on each (run ``help(ode)``):

  - 1st order separable differential equations.
  - 1st order differential equations whose coefficients or `dx` and `dy` are
    functions homogeneous of the same order.
  - 1st order exact differential equations.
  - 1st order linear differential equations.
  - 1st order Bernoulli differential equations.
  - Power series solutions for first order differential equations.
  - Lie Group method of solving first order differential equations.
  - 2nd order Liouville differential equations.
  - Power series solutions for second order differential equations
    at ordinary and regular singular points.
  - `n`\th order differential equation that can be solved with algebraic
    rearrangement and integration.
  - `n`\th order linear homogeneous differential equation with constant
    coefficients.
  - `n`\th order linear inhomogeneous differential equation with constant
    coefficients using the method of undetermined coefficients.
  - `n`\th order linear inhomogeneous differential equation with constant
    coefficients using the method of variation of parameters.

**Philosophy behind this module**

This module is designed to make it easy to add new ODE solving methods without
having to mess with the solving code for other methods.  The idea is that
there is a :py:meth:`~sympy.solvers.ode.classify_ode` function, which takes in
an ODE and tells you what hints, if any, will solve the ODE.  It does this
without attempting to solve the ODE, so it is fast.  Each solving method is a
hint, and it has its own function, named ``ode_<hint>``.  That function takes
in the ODE and any match expression gathered by
:py:meth:`~sympy.solvers.ode.classify_ode` and returns a solved result.  If
this result has any integrals in it, the hint function will return an
unevaluated :py:class:`~sympy.integrals.Integral` class.
:py:meth:`~sympy.solvers.ode.dsolve`, which is the user wrapper function
around all of this, will then call :py:meth:`~sympy.solvers.ode.odesimp` on
the result, which, among other things, will attempt to solve the equation for
the dependent variable (the function we are solving for), simplify the
arbitrary constants in the expression, and evaluate any integrals, if the hint
allows it.

**How to add new solution methods**

If you have an ODE that you want :py:meth:`~sympy.solvers.ode.dsolve` to be
able to solve, try to avoid adding special case code here.  Instead, try
finding a general method that will solve your ODE, as well as others.  This
way, the :py:mod:`~sympy.solvers.ode` module will become more robust, and
unhindered by special case hacks.  WolphramAlpha and Maple's
DETools[odeadvisor] function are two resources you can use to classify a
specific ODE.  It is also better for a method to work with an `n`\th order ODE
instead of only with specific orders, if possible.

To add a new method, there are a few things that you need to do.  First, you
need a hint name for your method.  Try to name your hint so that it is
unambiguous with all other methods, including ones that may not be implemented
yet.  If your method uses integrals, also include a ``hint_Integral`` hint.
If there is more than one way to solve ODEs with your method, include a hint
for each one, as well as a ``<hint>_best`` hint.  Your ``ode_<hint>_best()``
function should choose the best using min with ``ode_sol_simplicity`` as the
key argument.  See
:py:meth:`~sympy.solvers.ode.ode_1st_homogeneous_coeff_best`, for example.
The function that uses your method will be called ``ode_<hint>()``, so the
hint must only use characters that are allowed in a Python function name
(alphanumeric characters and the underscore '``_``' character).  Include a
function for every hint, except for ``_Integral`` hints
(:py:meth:`~sympy.solvers.ode.dsolve` takes care of those automatically).
Hint names should be all lowercase, unless a word is commonly capitalized
(such as Integral or Bernoulli).  If you have a hint that you do not want to
run with ``all_Integral`` that doesn't have an ``_Integral`` counterpart (such
as a best hint that would defeat the purpose of ``all_Integral``), you will
need to remove it manually in the :py:meth:`~sympy.solvers.ode.dsolve` code.
See also the :py:meth:`~sympy.solvers.ode.classify_ode` docstring for
guidelines on writing a hint name.

Determine *in general* how the solutions returned by your method compare with
other methods that can potentially solve the same ODEs.  Then, put your hints
in the :py:data:`~sympy.solvers.ode.allhints` tuple in the order that they
should be called.  The ordering of this tuple determines which hints are
default.  Note that exceptions are ok, because it is easy for the user to
choose individual hints with :py:meth:`~sympy.solvers.ode.dsolve`.  In
general, ``_Integral`` variants should go at the end of the list, and
``_best`` variants should go before the various hints they apply to.  For
example, the ``undetermined_coefficients`` hint comes before the
``variation_of_parameters`` hint because, even though variation of parameters
is more general than undetermined coefficients, undetermined coefficients
generally returns cleaner results for the ODEs that it can solve than
variation of parameters does, and it does not require integration, so it is
much faster.

Next, you need to have a match expression or a function that matches the type
of the ODE, which you should put in :py:meth:`~sympy.solvers.ode.classify_ode`
(if the match function is more than just a few lines, like
:py:meth:`~sympy.solvers.ode._undetermined_coefficients_match`, it should go
outside of :py:meth:`~sympy.solvers.ode.classify_ode`).  It should match the
ODE without solving for it as much as possible, so that
:py:meth:`~sympy.solvers.ode.classify_ode` remains fast and is not hindered by
bugs in solving code.  Be sure to consider corner cases.  For example, if your
solution method involves dividing by something, make sure you exclude the case
where that division will be 0.

In most cases, the matching of the ODE will also give you the various parts
that you need to solve it.  You should put that in a dictionary (``.match()``
will do this for you), and add that as ``matching_hints['hint'] = matchdict``
in the relevant part of :py:meth:`~sympy.solvers.ode.classify_ode`.
:py:meth:`~sympy.solvers.ode.classify_ode` will then send this to
:py:meth:`~sympy.solvers.ode.dsolve`, which will send it to your function as
the ``match`` argument.  Your function should be named ``ode_<hint>(eq, func,
order, match)`.  If you need to send more information, put it in the ``match``
dictionary.  For example, if you had to substitute in a dummy variable in
:py:meth:`~sympy.solvers.ode.classify_ode` to match the ODE, you will need to
pass it to your function using the `match` dict to access it.  You can access
the independent variable using ``func.args[0]``, and the dependent variable
(the function you are trying to solve for) as ``func.func``.  If, while trying
to solve the ODE, you find that you cannot, raise ``NotImplementedError``.
:py:meth:`~sympy.solvers.ode.dsolve` will catch this error with the ``all``
meta-hint, rather than causing the whole routine to fail.

Add a docstring to your function that describes the method employed.  Like
with anything else in SymPy, you will need to add a doctest to the docstring,
in addition to real tests in ``test_ode.py``.  Try to maintain consistency
with the other hint functions' docstrings.  Add your method to the list at the
top of this docstring.  Also, add your method to ``ode.rst`` in the
``docs/src`` directory, so that the Sphinx docs will pull its docstring into
the main SymPy documentation.  Be sure to make the Sphinx documentation by
running ``make html`` from within the doc directory to verify that the
docstring formats correctly.

If your solution method involves integrating, use :py:meth:`Integral()
<sympy.integrals.integrals.Integral>` instead of
:py:meth:`~sympy.core.expr.Expr.integrate`.  This allows the user to bypass
hard/slow integration by using the ``_Integral`` variant of your hint.  In
most cases, calling :py:meth:`sympy.core.basic.Basic.doit` will integrate your
solution.  If this is not the case, you will need to write special code in
:py:meth:`~sympy.solvers.ode._handle_Integral`.  Arbitrary constants should be
symbols named ``C1``, ``C2``, and so on.  All solution methods should return
an equality instance.  If you need an arbitrary number of arbitrary constants,
you can use ``constants = numbered_symbols(prefix='C', cls=Symbol, start=1)``.
If it is possible to solve for the dependent function in a general way, do so.
Otherwise, do as best as you can, but do not call solve in your
``ode_<hint>()`` function.  :py:meth:`~sympy.solvers.ode.odesimp` will attempt
to solve the solution for you, so you do not need to do that.  Lastly, if your
ODE has a common simplification that can be applied to your solutions, you can
add a special case in :py:meth:`~sympy.solvers.ode.odesimp` for it.  For
example, solutions returned from the ``1st_homogeneous_coeff`` hints often
have many :py:meth:`~sympy.functions.log` terms, so
:py:meth:`~sympy.solvers.ode.odesimp` calls
:py:meth:`~sympy.simplify.simplify.logcombine` on them (it also helps to write
the arbitrary constant as ``log(C1)`` instead of ``C1`` in this case).  Also
consider common ways that you can rearrange your solution to have
:py:meth:`~sympy.solvers.ode.constantsimp` take better advantage of it.  It is
better to put simplification in :py:meth:`~sympy.solvers.ode.odesimp` than in
your method, because it can then be turned off with the simplify flag in
:py:meth:`~sympy.solvers.ode.dsolve`.  If you have any extraneous
simplification in your function, be sure to only run it using ``if
match.get('simplify', True):``, especially if it can be slow or if it can
reduce the domain of the solution.

Finally, as with every contribution to SymPy, your method will need to be
tested.  Add a test for each method in ``test_ode.py``.  Follow the
conventions there, i.e., test the solver using ``dsolve(eq, f(x),
hint=your_hint)``, and also test the solution using
:py:meth:`~sympy.solvers.ode.checkodesol` (you can put these in a separate
tests and skip/XFAIL if it runs too slow/doesn't work).  Be sure to call your
hint specifically in :py:meth:`~sympy.solvers.ode.dsolve`, that way the test
won't be broken simply by the introduction of another matching hint.  If your
method works for higher order (>1) ODEs, you will need to run ``sol =
constant_renumber(sol, 'C', 1, order)`` for each solution, where ``order`` is
the order of the ODE.  This is because ``constant_renumber`` renumbers the
arbitrary constants by printing order, which is platform dependent.  Try to
test every corner case of your solver, including a range of orders if it is a
`n`\th order solver, but if your solver is slow, such as if it involves hard
integration, try to keep the test run time down.

Feel free to refactor existing hints to avoid duplicating code or creating
inconsistencies.  If you can show that your method exactly duplicates an
existing method, including in the simplicity and speed of obtaining the
solutions, then you can remove the old, less general method.  The existing
code is tested extensively in ``test_ode.py``, so if anything is broken, one
of those tests will surely fail.

iÿÿÿÿ(   t   print_functiont   division(   t   defaultdict(   t   islice(   t
   cmp_to_key(   t   Addt   St   Mult   Powt   oo(   t   orderedt   iterablet   is_sequencet   ranget   string_types(   t   Tuple(   t   factor_terms(   t
   AtomicExprt   Expr(   t   Functiont
   Derivativet   AppliedUndeft   difft   expandt
   expand_mult   Subst   _mexpand(   t	   vectorize(   t   NaNt   zoot   It   Number(   t   Equalityt   Eq(   t   Symbolt   Wildt   Dummyt   symbols(   t   sympify(   t   BooleanAtomt   Andt   Ort   Nott   BooleanTruet   BooleanFalse(   t   cost   expt   imt   logt   ret   sint   tant   sqrtt   atan2t	   conjugatet	   Piecewise(   t	   factorial(   t   Integralt	   integrate(   t	   wronskiant   Matrixt   eyet   zeros(   t   Polyt   RootOft   rootoft	   terms_gcdt   PolynomialErrort   lcmt   roots(   t   roots_quartic(   t   cancelt   degreet   div(   t   Order(   t   series(   t   collectt
   logcombinet   powsimpt   separatevarst   simplifyt   trigsimpt   posifyt   cse(   t	   powdenest(   t   collect_const(   t   solve(   t   pdsolve(   t   numbered_symbolst   default_sort_keyt   sift(   t   _preprocesst	   ode_ordert   _desolvet   nth_algebraict	   separablet	   1st_exactt
   1st_lineart	   Bernoullit   Riccati_special_minus2t   1st_homogeneous_coeff_bestt(   1st_homogeneous_coeff_subs_indep_div_dept(   1st_homogeneous_coeff_subs_dep_div_indept   almost_lineart   linear_coefficientst   separable_reducedt   1st_power_seriest	   lie_groupt%   nth_linear_constant_coeff_homogeneoust   nth_linear_euler_eq_homogeneoust3   nth_linear_constant_coeff_undetermined_coefficientst<   nth_linear_euler_eq_nonhomogeneous_undetermined_coefficientst1   nth_linear_constant_coeff_variation_of_parameterst:   nth_linear_euler_eq_nonhomogeneous_variation_of_parameterst	   Liouvillet   nth_order_reduciblet   2nd_power_series_ordinaryt   2nd_power_series_regulart   nth_algebraic_Integralt   separable_Integralt   1st_exact_Integralt   1st_linear_Integralt   Bernoulli_Integralt1   1st_homogeneous_coeff_subs_indep_div_dep_Integralt1   1st_homogeneous_coeff_subs_dep_div_indep_Integralt   almost_linear_Integralt   linear_coefficients_Integralt   separable_reduced_Integralt:   nth_linear_constant_coeff_variation_of_parameters_IntegraltC   nth_linear_euler_eq_nonhomogeneous_variation_of_parameters_Integralt   Liouville_Integralt   abaco1_simplet   abaco1_productt   abaco2_similart   abaco2_unique_unknownt   abaco2_unique_generalt   lineart   function_sumt	   bivariatet   chic         C  s‚   i | | 6} xe |  j  t ƒ D]T } | j | k rK | j | j Œ  | | <q | j i | | 6ƒ j d t ƒ | | <q W|  j | ƒ S(   sW  
    When replacing the func with something else, we usually want the
    derivative evaluated, so this function helps in making that happen.

    Examples
    ========

    >>> from sympy import Derivative, symbols, Function
    >>> from sympy.solvers.ode import sub_func_doit
    >>> x, z = symbols('x, z')
    >>> y = Function('y')

    >>> sub_func_doit(3*Derivative(y(x), x) - 1, y(x), x)
    2

    >>> sub_func_doit(x*Derivative(y(x), x) - y(x)**2 + y(x), y(x),
    ... 1/(x*(z + 1/x)))
    x*(-1/(x**2*(z + 1/x)) + 1/(x**3*(z + 1/x)**2)) + 1/(x*(z + 1/x))
    ...- 1/(x**2*(z + 1/x)**2)
    t   deep(   t   atomsR   t   exprR   t   variable_countt   xreplacet   doitt   False(   t   eqt   funct   newt   repst   d(    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt   sub_func_doitV  s    *i   t   Cc         C  sU   t  |  | | ƒ } g  t | ƒ D] } t | ƒ ^ q } | d k rK | d St | ƒ S(   sJ   
    Returns a list of constants that do not occur
    in eq already.
    i   i    (   t   iter_numbered_constantsR   t   nextt   tuple(   R“   t   numt   startt   prefixt   ncst   it   Cs(    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt   get_numbered_constantst  s    %c         C  sÆ   t  |  t ƒ r |  g }  n t |  ƒ s: t d |  ƒ ‚ n  t ƒ  j g  |  D] } | j ^ qJ Œ  } t ƒ  j g  |  D] } | j t ƒ ^ qr Œ  } | r­ | d „  | Dƒ O} n  t	 d | d | d | ƒ S(   sO   
    Returns an iterator of constants that do not occur
    in eq already.
    s$   Expected Expr or iterable but got %sc         S  s%   h  |  ] } t  t | j ƒ ƒ ’ q S(    (   R"   t   strR”   (   t   .0t   f(    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pys	   <setcomp>  s   	 Rž   RŸ   t   exclude(
   t
   isinstanceR   R   t
   ValueErrort   sett   uniont   free_symbolsR   R   RX   (   R“   Rž   RŸ   R¡   t   atom_sett   func_set(    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyRš     s    (.t   defaulti    i   c	           s)  t  |  ƒ rUt |  ˆ  ƒ }
 |
 d }  |
 d } |
 d ‰  t t |  d j t ƒ ƒ d j t ƒ ƒ d } x† t t |  ƒ ƒ D]r } xi ˆ  D]a } t | t ƒ r¡ q‰ |  | j	 t
 ˆ  | | t |  | ˆ  | ƒ ƒ ƒ j r‰ |  | |  | <q‰ q‰ Wq| W|  |
 d <t t | j ƒ  ƒ ƒ d k r)t d ƒ ‚ n  t | j ƒ  ƒ d |
 d <‡ f d †  ‰ ˆ ˆ  ƒ t |  ƒ k ryt d ƒ ‚ n  |
 d	 d! k r’t ‚ q%|
 d
 t k rÚ|
 d d k rÆt ƒ  d |
 } qët ƒ  d |
 } n t ƒ  d |
 } | |
 ƒ } | rNt | Œ  j t |  Œ  j } t | ˆ  | | ƒ } g  | D] } | j | ƒ ^ q5S| SnÐ| } t |  d ˆ  d | d t d | d | d d d | d | d | |	 	} | j d |  ƒ }  | j d t ƒ } | ri  } i  } t |  d t ƒ} | d } xU | D]M } y t |  | | | ˆ ƒ } Wn t k
 r;} | | | <qùX| | | <qùW| | d ‰  t t | j ƒ  ƒ d ‡  ‡ f d †  ƒ| d <| d k rš| d Sx8 | D]0 } | d | j | d! ƒ k r¡| | d <Pq¡q¡W| d  | d  <| d | d <| j | ƒ | S| d } t |  | | ˆ d | ƒSd! S("   s#&  
    Solves any (supported) kind of ordinary differential equation and
    system of ordinary differential equations.

    For single ordinary differential equation
    =========================================

    It is classified under this when number of equation in ``eq`` is one.
    **Usage**

        ``dsolve(eq, f(x), hint)`` -> Solve ordinary differential equation
        ``eq`` for function ``f(x)``, using method ``hint``.

    **Details**

        ``eq`` can be any supported ordinary differential equation (see the
            :py:mod:`~sympy.solvers.ode` docstring for supported methods).
            This can either be an :py:class:`~sympy.core.relational.Equality`,
            or an expression, which is assumed to be equal to ``0``.

        ``f(x)`` is a function of one variable whose derivatives in that
            variable make up the ordinary differential equation ``eq``.  In
            many cases it is not necessary to provide this; it will be
            autodetected (and an error raised if it couldn't be detected).

        ``hint`` is the solving method that you want dsolve to use.  Use
            ``classify_ode(eq, f(x))`` to get all of the possible hints for an
            ODE.  The default hint, ``default``, will use whatever hint is
            returned first by :py:meth:`~sympy.solvers.ode.classify_ode`.  See
            Hints below for more options that you can use for hint.

        ``simplify`` enables simplification by
            :py:meth:`~sympy.solvers.ode.odesimp`.  See its docstring for more
            information.  Turn this off, for example, to disable solving of
            solutions for ``func`` or simplification of arbitrary constants.
            It will still integrate with this hint. Note that the solution may
            contain more arbitrary constants than the order of the ODE with
            this option enabled.

        ``xi`` and ``eta`` are the infinitesimal functions of an ordinary
            differential equation. They are the infinitesimals of the Lie group
            of point transformations for which the differential equation is
            invariant. The user can specify values for the infinitesimals. If
            nothing is specified, ``xi`` and ``eta`` are calculated using
            :py:meth:`~sympy.solvers.ode.infinitesimals` with the help of various
            heuristics.

        ``ics`` is the set of initial/boundary conditions for the differential equation.
          It should be given in the form of ``{f(x0): x1, f(x).diff(x).subs(x, x2):
          x3}`` and so on.  For power series solutions, if no initial
          conditions are specified ``f(0)`` is assumed to be ``C0`` and the power
          series solution is calculated about 0.

        ``x0`` is the point about which the power series solution of a differential
          equation is to be evaluated.

        ``n`` gives the exponent of the dependent variable up to which the power series
          solution of a differential equation is to be evaluated.

    **Hints**

        Aside from the various solving methods, there are also some meta-hints
        that you can pass to :py:meth:`~sympy.solvers.ode.dsolve`:

        ``default``:
                This uses whatever hint is returned first by
                :py:meth:`~sympy.solvers.ode.classify_ode`. This is the
                default argument to :py:meth:`~sympy.solvers.ode.dsolve`.

        ``all``:
                To make :py:meth:`~sympy.solvers.ode.dsolve` apply all
                relevant classification hints, use ``dsolve(ODE, func,
                hint="all")``.  This will return a dictionary of
                ``hint:solution`` terms.  If a hint causes dsolve to raise the
                ``NotImplementedError``, value of that hint's key will be the
                exception object raised.  The dictionary will also include
                some special keys:

                - ``order``: The order of the ODE.  See also
                  :py:meth:`~sympy.solvers.deutils.ode_order` in
                  ``deutils.py``.
                - ``best``: The simplest hint; what would be returned by
                  ``best`` below.
                - ``best_hint``: The hint that would produce the solution
                  given by ``best``.  If more than one hint produces the best
                  solution, the first one in the tuple returned by
                  :py:meth:`~sympy.solvers.ode.classify_ode` is chosen.
                - ``default``: The solution that would be returned by default.
                  This is the one produced by the hint that appears first in
                  the tuple returned by
                  :py:meth:`~sympy.solvers.ode.classify_ode`.

        ``all_Integral``:
                This is the same as ``all``, except if a hint also has a
                corresponding ``_Integral`` hint, it only returns the
                ``_Integral`` hint.  This is useful if ``all`` causes
                :py:meth:`~sympy.solvers.ode.dsolve` to hang because of a
                difficult or impossible integral.  This meta-hint will also be
                much faster than ``all``, because
                :py:meth:`~sympy.core.expr.Expr.integrate` is an expensive
                routine.

        ``best``:
                To have :py:meth:`~sympy.solvers.ode.dsolve` try all methods
                and return the simplest one.  This takes into account whether
                the solution is solvable in the function, whether it contains
                any Integral classes (i.e.  unevaluatable integrals), and
                which one is the shortest in size.

        See also the :py:meth:`~sympy.solvers.ode.classify_ode` docstring for
        more info on hints, and the :py:mod:`~sympy.solvers.ode` docstring for
        a list of all supported hints.

    **Tips**

        - You can declare the derivative of an unknown function this way:

            >>> from sympy import Function, Derivative
            >>> from sympy.abc import x # x is the independent variable
            >>> f = Function("f")(x) # f is a function of x
            >>> # f_ will be the derivative of f with respect to x
            >>> f_ = Derivative(f, x)

        - See ``test_ode.py`` for many tests, which serves also as a set of
          examples for how to use :py:meth:`~sympy.solvers.ode.dsolve`.
        - :py:meth:`~sympy.solvers.ode.dsolve` always returns an
          :py:class:`~sympy.core.relational.Equality` class (except for the
          case when the hint is ``all`` or ``all_Integral``).  If possible, it
          solves the solution explicitly for the function being solved for.
          Otherwise, it returns an implicit solution.
        - Arbitrary constants are symbols named ``C1``, ``C2``, and so on.
        - Because all solutions should be mathematically equivalent, some
          hints may return the exact same result for an ODE. Often, though,
          two different hints will return the same solution formatted
          differently.  The two should be equivalent. Also note that sometimes
          the values of the arbitrary constants in two different solutions may
          not be the same, because one constant may have "absorbed" other
          constants into it.
        - Do ``help(ode.ode_<hintname>)`` to get help more information on a
          specific hint, where ``<hintname>`` is the name of a hint without
          ``_Integral``.

    For system of ordinary differential equations
    =============================================

   **Usage**
        ``dsolve(eq, func)`` -> Solve a system of ordinary differential
        equations ``eq`` for ``func`` being list of functions including
        `x(t)`, `y(t)`, `z(t)` where number of functions in the list depends
        upon the number of equations provided in ``eq``.

    **Details**

        ``eq`` can be any supported system of ordinary differential equations
        This can either be an :py:class:`~sympy.core.relational.Equality`,
        or an expression, which is assumed to be equal to ``0``.

        ``func`` holds ``x(t)`` and ``y(t)`` being functions of one variable which
        together with some of their derivatives make up the system of ordinary
        differential equation ``eq``. It is not necessary to provide this; it
        will be autodetected (and an error raised if it couldn't be detected).

    **Hints**

        The hints are formed by parameters returned by classify_sysode, combining
        them give hints name used later for forming method name.

    Examples
    ========

    >>> from sympy import Function, dsolve, Eq, Derivative, sin, cos, symbols
    >>> from sympy.abc import x
    >>> f = Function('f')
    >>> dsolve(Derivative(f(x), x, x) + 9*f(x), f(x))
    Eq(f(x), C1*sin(3*x) + C2*cos(3*x))

    >>> eq = sin(x)*cos(f(x)) + cos(x)*sin(f(x))*f(x).diff(x)
    >>> dsolve(eq, hint='1st_exact')
    [Eq(f(x), -acos(C1/cos(x)) + 2*pi), Eq(f(x), acos(C1/cos(x)))]
    >>> dsolve(eq, hint='almost_linear')
    [Eq(f(x), -acos(C1/cos(x)) + 2*pi), Eq(f(x), acos(C1/cos(x)))]
    >>> t = symbols('t')
    >>> x, y = symbols('x, y', cls=Function)
    >>> eq = (Eq(Derivative(x(t),t), 12*t*x(t) + 8*y(t)), Eq(Derivative(y(t),t), 21*x(t) + 7*t*y(t)))
    >>> dsolve(eq)
    [Eq(x(t), C1*x0(t) + C2*x0(t)*Integral(8*exp(Integral(7*t, t))*exp(Integral(12*t, t))/x0(t)**2, t)),
    Eq(y(t), C1*y0(t) + C2*(y0(t)*Integral(8*exp(Integral(7*t, t))*exp(Integral(12*t, t))/x0(t)**2, t) +
    exp(Integral(7*t, t))*exp(Integral(12*t, t))/x0(t)))]
    >>> eq = (Eq(Derivative(x(t),t),x(t)*y(t)*sin(t)), Eq(Derivative(y(t),t),y(t)**2*sin(t)))
    >>> dsolve(eq)
    {Eq(x(t), -exp(C1)/(C2*exp(C1) - cos(t))), Eq(y(t), -1/(C1 - cos(t)))}
    R“   t   orderR”   i    i   s@   It solves only those systems of equations whose orders are equalc           s   t  ‡  f d †  |  Dƒ ƒ S(   Nc         3  s0   |  ]& } t  | t ƒ r$ ˆ  | ƒ n d  Vq d S(   i   N(   R¨   t   list(   R¥   t   item(   t	   recur_len(    s0   lib/python2.7/site-packages/sympy/solvers/ode.pys	   <genexpr>g  s    (   t   sum(   t   l(   R³   (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyR³   f  s    s_   dsolve() and classify_sysode() work with number of functions being equal to number of equationst   type_of_equationt	   is_lineart   no_of_equationi   s    sysode_linear_neq_order%(order)ss1   sysode_linear_%(no_of_equation)seq_order%(order)ss4   sysode_nonlinear_%(no_of_equation)seq_order%(order)st   hintRP   t   xit   etat   typet   odet   icst   x0t   nt   allt   dictt   ordered_hintst   keyc           s   t  |  ˆ  d ˆ ƒS(   Nt
   trysolving(   t   ode_sol_simplicity(   t   x(   R”   RP   (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt   <lambda>“  s    t   bestt	   best_hintR¯   N(    R   t   classify_sysodeR±   R   R   R"   R   t   lenR¨   t   coeffR   R\   t   is_negativeRª   t   valuesR©   t   Nonet   NotImplementedErrort   Truet   globalsR   R¬   t	   solve_icst   subsR]   t   popR’   t   classify_odet   _helper_simplifyt   mint   gett   update(   R“   R”   R¹   RP   R¾   Rº   R»   R¿   RÀ   t   kwargst   matchR°   t   tR¡   t   func_t	   solvefunct   solst	   constantst   solved_constantst   solt
   given_hintt   hintst   all_t   retdictt   failed_hintst   gethintst   orderedhintst   rvt   detail(    (   R”   R³   RP   s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt   dsolve‘  s~    Â


07
	 $
.

c           sÿ  | } | j  d ƒ r4 t ƒ  d | t d ƒ  } n t ƒ  d | } | d } | d }	 | | } |  j ‰  ‡  f d †  }
 | rè | |  | |	 | ƒ } t | t ƒ r½ t |  | | | ƒ } qg  | D] } t |  | | | ƒ ^ qÄ } n+ t | d <t | |  | |	 | ƒ | | ƒ } | rûd | k rût | t ƒ rkt	 | g | d g |
 | ƒ | ƒ } | j
 | ƒ } qûg  } xd | D]\ } y) t	 | g | d g |
 | ƒ | ƒ } Wn t k
 r½qxn X| j | j
 | ƒ ƒ qxWt | ƒ d k rò| d	 S| } n  | S(
   s  
    Helper function of dsolve that calls the respective
    :py:mod:`~sympy.solvers.ode` functions to solve for the ordinary
    differential equations. This minimizes the computation in calling
    :py:meth:`~sympy.solvers.deutils._desolve` multiple times.
    t	   _Integralt   ode_R”   R°   c           s   |  j  j ˆ  ƒ S(   N(   R¬   t
   difference(   t   s(   t   free(    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyRÈ   ¶  t    RP   t   power_seriesi   i    (   t   endswithRÓ   RÌ   R¬   R¨   R   t   odesimpR’   t   _handle_IntegralRÔ   RÕ   R©   t   append(   R“   R¹   RÝ   RP   R¾   RÜ   t   rRà   R”   R°   t   consRá   Rì   Rò   Rã   t   rv1(    (   Ró   s0   lib/python2.7/site-packages/sympy/solvers/ode.pyRØ   ¥  s>    


	+
!%)	c         C  s  | d j  d } g  } g  } t ƒ  } xL| j ƒ  D]>\ } }	 t | t ƒ r“ | j  d }
 g  | D] } | j | j k rb | ^ qb d } |  } nBt | t t f ƒ rÉt | t ƒ rÆ | j ƒ  } n  t | t ƒ r | j	 } | j
 d }
 | j	 j } | } nM t | t ƒ rM| } | j d }
 | f t | j ƒ } | j |
 | ƒ } n  | | k r³xW |  D]L } | j | j	 j ƒ r`| j t | j j | Œ  | j j | Œ  ƒ ƒ q`q`Wn  | j | ƒ | } n t d ƒ ‚ x™ | D]‘ } | j | ƒ rÜ| } | j | |
 ƒ } | j | |	 ƒ } t | t ƒ s2| rmg  | D] } t | t ƒ s9| ^ q9} | j | ƒ qmqÜqÜWq3 Wy t | | d t ƒ} Wn t k
 r§g  } n X| s½t d ƒ ‚ n  | t k rØt d ƒ ‚ n  t | ƒ d k rùt d ƒ ‚ n  | d S(   sì  
    Solve for the constants given initial conditions

    ``sols`` is a list of solutions.

    ``funcs`` is a list of functions.

    ``constants`` is a list of constants.

    ``ics`` is the set of initial/boundary conditions for the differential
    equation. It should be given in the form of ``{f(x0): x1,
    f(x).diff(x).subs(x, x2):  x3}`` and so on.

    Returns a dictionary mapping constants to values.
    ``solution.subs(constants)`` will replace the constants in ``solution``.

    Example
    =======
    >>> # From dsolve(f(x).diff(x) - f(x), f(x))
    >>> from sympy import symbols, Eq, exp, Function
    >>> from sympy.solvers.ode import solve_ics
    >>> f = Function('f')
    >>> x, C1 = symbols('x C1')
    >>> sols = [Eq(f(x), C1*exp(x))]
    >>> funcs = [f(x)]
    >>> constants = [C1]
    >>> ics = {f(0): 2}
    >>> solved_constants = solve_ics(sols, funcs, constants, ics)
    >>> solved_constants
    {C1: 2}
    >>> sols[0].subs(solved_constants)
    Eq(f(x), 2*exp(x))

    i    s   Unrecognized initial conditionRÂ   s%   Couldn't solve for initial conditionss\   Initial conditions did not produce any solutions for constants. Perhaps they are degenerate.i   s<   Initial conditions produced too many solutions for constants(   t   argsRª   t   itemsR¨   R   R”   R   R   R‘   RŽ   t   pointt	   variablesRÌ   RÕ   t   hasRù   R!   t   lhsR   t   rhst   addRÑ   R'   RV   RÒ   R©   (   Rá   t   funcsRâ   R¾   RÇ   t	   diff_solst	   subs_solst   diff_variablest   funcargt   valueR¿   R¦   t   matching_funcR   t   derivR   Rä   t   sol2Rò   Rã   (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyRÔ   ×  s`    '	/			8	(
c   ^        s  t  | ƒ } | j d t ƒ } | rL t | j ƒ d k rL t d | ƒ ‚ n  | s^ | df k r‹ t |  | ƒ \ }  } | df k r‹ | } q‹ n  | j d ‰ | j ‰ t	 d ƒ } | j
 d ƒ } | j
 d ƒ }	 | j
 d ƒ }
 t |  t ƒ r?|  j d k r3t |  j |  j | d	 | d
 | d | d |
 d |	 d t ƒS|  j }  n  t |  ˆ ˆ ƒ ƒ } i | d 6} | s‚| r{df | d <| Sdg Sn  ˆ ˆ ƒ j ˆ ƒ } t d d ˆ ˆ ƒ g ƒ} t d d ˆ ˆ ƒ g ƒ} t d d ˆ ˆ ƒ g ƒ} t d d | ˆ ˆ ƒ j ˆ d ƒ g ƒ} t d d | g ƒ} t d d | g ƒ} t d d ˆ ˆ ˆ ƒ | g ƒ} t d d ˆ g ƒ} t d d ˆ ˆ ˆ ƒ | g ƒ} t d d ˆ ˆ ˆ ƒ | g ƒ} t d d ˆ ˆ ˆ ƒ | g ƒ} t d d ˆ ˆ ˆ ƒ | g ƒ} t d d ˆ ˆ ƒ | ˆ ˆ ƒ j ˆ d ƒ g ƒ} t d d ˆ ˆ ƒ | ˆ ˆ ƒ j ˆ d ƒ g ƒ} t d d ˆ ˆ ƒ | ˆ ˆ ƒ j ˆ d ƒ g ƒ} i | d 6|	 d 6} i  } t d ƒ } t |  ƒ }  | df k	 ròx"| D]}  t |  t t f ƒ rIt |  t ƒ r$|  j ‰ |  j d }! |  j d }" n+ t |  t ƒ rO|  ‰ ˆ }! |  j d }" n  t ˆ t ƒ r:t ˆ j d t ƒ r:ˆ j d j ˆ k r:t ˆ j d j ƒ d k r:|! ˆ k r:|" j ˆ ƒ r:t ‡ f d †  ˆ j Dƒ ƒ r:| |  j ˆ ƒ r:t ˆ ˆ ƒ }# d t |# ƒ }$ | j i |" |$ 6| |  |$ d  6ƒ qët d! ƒ ‚ qÔt |  t ƒ rß|  j ˆ k rÐt |  j ƒ d k rÐ|  j d j ˆ ƒ rÐ| |  j ˆ ƒ rÐ| j i |  j d d" 6| |  d# 6ƒ qët d$ ƒ ‚ qÔt d% ƒ ‚ qÔWn  df }% |  j  rž|  j! ˆ ˆ ƒ j ˆ | ƒ ƒ }& |& dh k rž|& j" | ˆ ˆ ƒ | ƒ ‰ ˆ r›ˆ | r›ˆ ˆ ƒ ˆ | }' t# g  |  j D] }( |( |' ^ q|Œ  }% q›qžn  |% s­|  }% n  | d k r„|  j  rÚ|% j$ ˆ ƒ \ }) }* nV t	 d& ƒ }+ |% |+ j$ ˆ ƒ \ }) }* g  |) |* g D] }, |, j% |+ d ƒ ^ q\ }) }* i |* j! | ƒ | 6|* j! ˆ ˆ ƒ ƒ | 6|) | 6‰ ˆ | j ˆ ƒ røˆ | j ˆ ƒ røˆ | | ˆ | ˆ ˆ ƒ ˆ | j ƒ  |% d k rø| ˆ d <| ˆ d <| ˆ d <ˆ | d' <ˆ | d( <n  t& |% ˆ ˆ ƒ d) t ƒj" | | | ˆ ˆ ƒ | ˆ ˆ ƒ | ƒ ‰ ˆ r¥ˆ | d k r¥ˆ | d k r¥| ˆ d <| ˆ d <| ˆ d <| ˆ d <ˆ | d* <ˆ | d+ <n  t& |% ˆ ˆ ƒ d) t ƒj" | | | ˆ ˆ ƒ d | ˆ ˆ ƒ ˆ | ˆ d ƒ ‰ ˆ rh	ˆ | d k rh	ˆ | d k s3	ˆ | d k rh	| ˆ d <| ˆ d <| ˆ d <| ˆ d <ˆ | d, <n  t& |  | d) t ƒj" | | | ƒ ‰ ˆ rÔ| ˆ d <| ˆ d <| ˆ d <ˆ | j% ˆ ˆ ƒ | ƒ ˆ | <ˆ | j% ˆ ˆ ƒ | ƒ ˆ | <| j
 d" d ƒ }- | j
 d# | ƒ }. t' ˆ | ˆ | ƒ }/ |/ j% i |- ˆ 6|. | 6ƒ }0 |0 j t( ƒ r1|0 j t) ƒ r1|0 j t* ƒ r1|0 j t( ƒ r1|0 j ˆ ƒ j% i |- ˆ 6|. | 6ƒ }1 |1 j t( ƒ r1|1 j t) ƒ r1|1 j t* ƒ r1|1 j t( ƒ r1ˆ j+ ƒ  }2 |2 j i |
 d- 6|- d" 6|. d# 6ƒ |2 | d. <q1n  | j ˆ ƒ yˆ | d k r¼t, ˆ | j | ƒ ˆ | j ˆ ƒ ƒ }3 |3 r¥t, |3 ˆ | ƒ ‰ ˆ j- }4 t |4 ƒ d k rˆ |4 j ƒ  k rt. t/ ˆ ƒ j0 ƒ  ƒ ‰ ˆ | c ˆ 9<ˆ | c ˆ 9<ˆ | d/ <ˆ | d0 <q¹t, |3 ˆ | ƒ ‰ ˆ j- }4 t |4 ƒ d k r¹| |4 j ƒ  k r¹t. t/ ˆ ƒ j0 ƒ  ƒ ‰ ˆ | c ˆ 9<ˆ | c ˆ 9<ˆ | d/ <ˆ | d0 <q¹q¼ˆ | d/ <ˆ | d0 <n  WqÔt1 k
 rÐqÔXn  | | d1 <t& |% | d) t ƒj" | | | ƒ ‰ ˆ rˆ | ˆ | }5 }' | ˆ d <| ˆ d <| ˆ d <|5 j% ˆ ˆ ƒ | ƒ ˆ | <|' j% ˆ ˆ ƒ | ƒ ˆ | <t2 ˆ | ƒ ˆ | <t2 ˆ | ƒ ˆ | <t2 ˆ | d	 t d2 ˆ | f ƒ}6 t2 ˆ | d	 t d2 ˆ | f ƒ}7 |6 r|7 ri |6 d3 6|7 d4 6| d 6}8 |8 | d5 <|8 | d6 <n  t3 ˆ | ˆ | ƒ }9 |9 df k	 rht3 ˆ | ˆ | ƒ }: |9 |: k rht	 d7 ƒ }; t	 d8 ƒ }< d9 }= |= d: }> |= d; }? t, ˆ | |; ˆ | j% i d ˆ 6|; | 6ƒ ƒ d k réˆ | |> <ˆ | |> d< <n  t, ˆ | |< ˆ | j% i |< ˆ 6d | 6ƒ ƒ d k r=ˆ | |? <ˆ | |? d< <n  |> | k re|? | k reˆ | d= <qeqhn  |5 |' }@ t4 |@ | ƒ }A |A r7|A \ }B }C t	 d& ƒ }+ t	 d> ƒ }D |% j% | |D f ˆ ˆ ƒ |+ f f ƒ }E ˆ ˆ |B f |+ |+ |C f |D | f |+ ˆ ˆ ƒ f f }F t, |E j% |F ƒ ƒ }E t& t |E ƒ | ˆ ˆ ƒ g ƒ j" | | | ƒ }G |G r7t3 |G | ˆ ˆ ˆ ƒ ƒ }H |H df k	 r4t3 |G | ˆ ˆ ˆ ƒ ƒ }I |H |I k r1|G | j% ˆ ˆ ƒ | ƒ |G | <|G | j% ˆ ˆ ƒ | ƒ |G | <|G j i |B d? 6|C d@ 6| d 6| d 6| d 6ƒ |G | dA <|G | dB <q1q4q7n  t, ˆ ˆ ˆ ƒ |5 |' ƒ ‰ df }+ xN t5 ˆ j6 t7 ƒ ƒ D]7 }J |J j ˆ ƒ rq|J j$ ˆ ˆ ˆ ƒ ƒ \ }K }+ PqqqqW|+ r|+ j ˆ ˆ ƒ ƒ rˆ t8 t9 |+ j% ˆ ˆ ƒ | ƒ dC ˆ ƒƒ ˆ ˆ ƒ }L t dD ƒ }M |+ |L d k s8|+ |L j, ƒ  j" ˆ |M ƒ rt	 d> ƒ }D i |D d> 6}G |+ j$ ˆ ˆ ƒ ƒ \ }N }O ˆ j% |+ |D f d |+ d |D f f ƒ }P |P j- }Q t |Q ƒ d k r|Q j ƒ  |D k r|G j i |N j: ƒ  d dE 6|P d& 6ƒ |G | dF <|G | dG <qqqn  t& |  | ˆ ˆ ƒ g ƒ j" | | | ƒ ‰ ˆ r›ˆ j+ ƒ  }G t; j< |G | <|G | j  r•|G | j$ ˆ ˆ ƒ ƒ \ }R |G | <|G | c |R 7<n  t, |G | j ˆ ˆ ƒ ƒ ˆ | ƒ ‰ ˆ rˆ j ˆ ˆ ƒ ƒ rt= |G | ƒ |G | <|G | j$ ˆ ˆ ƒ dH t ƒd }+ |G j i | d 6| d 6| d 6|+ d& 6ƒ |G | c |+ <|G | c |+ j ˆ ˆ ƒ ƒ <|G | dI <|G | dJ <qq›n| d k r›| ˆ ˆ ƒ j ˆ d ƒ | | d | | }= |% j" |= ƒ ‰ ˆ r˜ˆ | d k r˜t	 d ƒ } t, ˆ | ˆ | ƒ j% ˆ ˆ ƒ | ƒ }S t, ˆ | ˆ | ƒ j% ˆ ˆ ƒ | ƒ }L | |L j- k s•ˆ |S j- k rfq˜i |S dK 6|L dL 6| d 6‰ ˆ | dM <ˆ | dN <n  | ˆ ˆ ƒ j ˆ d ƒ | | | ˆ ˆ ƒ }T t& |% ˆ ˆ ƒ j ˆ d ƒ ˆ ˆ ƒ j ˆ ƒ ˆ ˆ ƒ g ƒ j" |T ƒ ‰ t }U ˆ r›ˆ | d k r›t g  ˆ D] }V ˆ |V j> ƒ  ^ q8ƒ r˜t' ˆ | ˆ | ƒ }M t' ˆ | ˆ | ƒ }W | j
 dO d ƒ }- |M j% ˆ |- ƒ }/ |/ j t( ƒ r…|/ j t* ƒ r…|/ j t) ƒ r…|/ j t( ƒ r…|W j% ˆ |- ƒ }/ |/ j t( ƒ r…|/ j t* ƒ r…|/ j t) ƒ r…|/ j t( ƒ r…t }U ˆ j i | d 6| d 6| d 6|- dO 6|
 d- 6ƒ ˆ | dP <q…n  |U s•t' ˆ |- |M ƒ }M |M j% ˆ |- ƒ }/ |/ j t( ƒ r’|/ j t* ƒ r’|/ j t) ƒ r’|/ j t( ƒ r’t' ˆ |- d |W ƒ }W |W j% ˆ |- ƒ }/ |/ j t( ƒ r|/ j t* ƒ r|/ j t) ƒ r|/ j t( ƒ ri |M dD 6|W dQ 6|- dO 6|
 d- 6}X |X | dR <qq’q•q˜q›n  | d k rµt? |% | ƒ ‰ ˆ rÉˆ | dS <n  t@ |% | ƒ ‰ ˆ dT rùˆ | dU <ˆ | dV <n  tA |% | | ƒ ‰ ˆ r¡tB ‡ ‡ f dW †  ˆ Dƒ ƒ r¡ˆ dX r”tC ˆ dX ˆ ƒ }Y dY }= ˆ | |= <ˆ | |= d< <|Y dZ rž|Y d[ ˆ d[ <ˆ | d\ <qžq¡ˆ | d] <n  ‡ ‡ f d^ †  ‰  df ‰ ˆ df k	 rùˆ | }Z ˆ | |Z ‰ ‡ ‡ f d_ †  ˆ Dƒ ‰ n  ˆ rµtB ‡  ‡ f d` †  ˆ Dƒ ƒ rµˆ dX s6ˆ | da <q²ˆ | db <ˆ | dc <tD ˆ dX j% ˆ t. ˆ ƒ ƒ ƒ \ } }[ tC | j% |[ ƒ ˆ ƒ }Y |Y dZ r²|Y d[ ˆ d[ <ˆ | dd <q²qµn  g  tE D] }\ |\ | k r¼|\ ^ q¼}] | r|] rð|] d n df | d <tF |] ƒ | de <| StF |] ƒ Sdf S(i   sÇ  
    Returns a tuple of possible :py:meth:`~sympy.solvers.ode.dsolve`
    classifications for an ODE.

    The tuple is ordered so that first item is the classification that
    :py:meth:`~sympy.solvers.ode.dsolve` uses to solve the ODE by default.  In
    general, classifications at the near the beginning of the list will
    produce better solutions faster than those near the end, thought there are
    always exceptions.  To make :py:meth:`~sympy.solvers.ode.dsolve` use a
    different classification, use ``dsolve(ODE, func,
    hint=<classification>)``.  See also the
    :py:meth:`~sympy.solvers.ode.dsolve` docstring for different meta-hints
    you can use.

    If ``dict`` is true, :py:meth:`~sympy.solvers.ode.classify_ode` will
    return a dictionary of ``hint:match`` expression terms. This is intended
    for internal use by :py:meth:`~sympy.solvers.ode.dsolve`.  Note that
    because dictionaries are ordered arbitrarily, this will most likely not be
    in the same order as the tuple.

    You can get help on different hints by executing
    ``help(ode.ode_hintname)``, where ``hintname`` is the name of the hint
    without ``_Integral``.

    See :py:data:`~sympy.solvers.ode.allhints` or the
    :py:mod:`~sympy.solvers.ode` docstring for a list of all supported hints
    that can be returned from :py:meth:`~sympy.solvers.ode.classify_ode`.

    Notes
    =====

    These are remarks on hint names.

    ``_Integral``

        If a classification has ``_Integral`` at the end, it will return the
        expression with an unevaluated :py:class:`~sympy.integrals.Integral`
        class in it.  Note that a hint may do this anyway if
        :py:meth:`~sympy.core.expr.Expr.integrate` cannot do the integral,
        though just using an ``_Integral`` will do so much faster.  Indeed, an
        ``_Integral`` hint will always be faster than its corresponding hint
        without ``_Integral`` because
        :py:meth:`~sympy.core.expr.Expr.integrate` is an expensive routine.
        If :py:meth:`~sympy.solvers.ode.dsolve` hangs, it is probably because
        :py:meth:`~sympy.core.expr.Expr.integrate` is hanging on a tough or
        impossible integral.  Try using an ``_Integral`` hint or
        ``all_Integral`` to get it return something.

        Note that some hints do not have ``_Integral`` counterparts.  This is
        because :py:meth:`~sympy.solvers.ode.integrate` is not used in solving
        the ODE for those method. For example, `n`\th order linear homogeneous
        ODEs with constant coefficients do not require integration to solve,
        so there is no ``nth_linear_homogeneous_constant_coeff_Integrate``
        hint. You can easily evaluate any unevaluated
        :py:class:`~sympy.integrals.Integral`\s in an expression by doing
        ``expr.doit()``.

    Ordinals

        Some hints contain an ordinal such as ``1st_linear``.  This is to help
        differentiate them from other hints, as well as from other methods
        that may not be implemented yet. If a hint has ``nth`` in it, such as
        the ``nth_linear`` hints, this means that the method used to applies
        to ODEs of any order.

    ``indep`` and ``dep``

        Some hints contain the words ``indep`` or ``dep``.  These reference
        the independent variable and the dependent function, respectively. For
        example, if an ODE is in terms of `f(x)`, then ``indep`` will refer to
        `x` and ``dep`` will refer to `f`.

    ``subs``

        If a hints has the word ``subs`` in it, it means the the ODE is solved
        by substituting the expression given after the word ``subs`` for a
        single dummy variable.  This is usually in terms of ``indep`` and
        ``dep`` as above.  The substituted expression will be written only in
        characters allowed for names of Python objects, meaning operators will
        be spelled out.  For example, ``indep``/``dep`` will be written as
        ``indep_div_dep``.

    ``coeff``

        The word ``coeff`` in a hint refers to the coefficients of something
        in the ODE, usually of the derivative terms.  See the docstring for
        the individual methods for more info (``help(ode)``).  This is
        contrast to ``coefficients``, as in ``undetermined_coefficients``,
        which refers to the common name of a method.

    ``_best``

        Methods that have more than one fundamental way to solve will have a
        hint for each sub-method and a ``_best`` meta-classification. This
        will evaluate all hints and return the best, using the same
        considerations as the normal ``best`` meta-hint.


    Examples
    ========

    >>> from sympy import Function, classify_ode, Eq
    >>> from sympy.abc import x
    >>> f = Function('f')
    >>> classify_ode(Eq(f(x).diff(x), 0), f(x))
    ('nth_algebraic', 'separable', '1st_linear', '1st_homogeneous_coeff_best',
    '1st_homogeneous_coeff_subs_indep_div_dep',
    '1st_homogeneous_coeff_subs_dep_div_indep',
    '1st_power_series', 'lie_group',
    'nth_linear_constant_coeff_homogeneous',
    'nth_linear_euler_eq_homogeneous', 'nth_algebraic_Integral',
    'separable_Integral', '1st_linear_Integral',
    '1st_homogeneous_coeff_subs_indep_div_dep_Integral',
    '1st_homogeneous_coeff_subs_dep_div_indep_Integral')
    >>> classify_ode(f(x).diff(x, 2) + 3*f(x).diff(x) + 2*f(x) - 4)
    ('nth_linear_constant_coeff_undetermined_coefficients',
    'nth_linear_constant_coeff_variation_of_parameters',
    'nth_linear_constant_coeff_variation_of_parameters_Integral')

    t   prepi   sL   dsolve() and classify_ode() only work with functions of one variable, not %si    t   yRº   R»   RÀ   RÂ   R¾   R°   R¯   t   aR§   t   bt   cR—   i   t   et   kt   c1t   a2t   b2t   c2t   d2t   a3t   b3t   c3t   C1c         3  s"   |  ] } | ˆ  j  d  k Vq d S(   i    N(   R   (   R¥   R¡   (   R  (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pys	   <genexpr>  s    R¦   t   vals/   Enter valid boundary conditions for Derivativest   f0t   f0vals,   Enter valid boundary conditions for Functionsf   Enter boundary conditions of the form ics={f(point}: value, f(x).diff(x, order).subs(x, point): value}t   uRa   Ry   t   exactRb   Rz   Rc   t   termsRj   R`   Rx   Rk   R%   t   m1t   m2R_   Rw   t   u1t   u2t   1st_homogeneous_coeff_subst   _dep_div_indept   _indep_div_depRï   Rd   RÞ   t   xargt   yargRh   R~   t   gent   pt   powerRi   R   t   as_AddRg   R}   t   gt   hRr   R‚   R¿   Rt   t   qRu   Rs   t	   solutionsR^   Rv   c         3  s.   |  ]$ } | d  k r ˆ  | j  ˆ ƒ Vq d S(   i    N(   R  (   R¥   R¡   (   Rú   RÇ   (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pys	   <genexpr>d  s    iÿÿÿÿRp   t   testt   trialsetRn   Rl   c           sº   | d k  r t  d ƒ ‚ n  |  d k r+ t S| d k rN ˆ |  j k rJ t St S|  j r |  j ˆ  ˆ ƒ ƒ rp t Sˆ | |  j k S|  j r  |  j ƒ  ˆ | f k S| d k r¶ ˆ |  k St S(   sN  
            Linear Euler ODEs have the form  K*x**order*diff(y(x),x,order) = F(x),
            where K is independent of x and y(x), order>= 0.
            So we need to check that for each term, coeff == K*x**order from
            some K.  We have a few cases, since coeff may have several
            different types.
            i    s   order should be greater than 0i   (	   R©   RÒ   R¬   R’   t   is_MulR  Rý   t   is_Powt   as_base_exp(   RÍ   R°   (   R¦   RÇ   (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt
   _test_termw  s"    		
c           s!   i  |  ] } ˆ  ˆ | | “ q S(    (    (   R¥   R¡   (   t   factorRú   (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pys
   <dictcomp>—  s   	 c         3  s;   |  ]1 } | d  k r | d k r ˆ  ˆ | | ƒ Vq d S(   R6  i    N(    (   R¥   R¡   (   R:  t
   r_rescaled(    s0   lib/python2.7/site-packages/sympy/solvers/ode.pys	   <genexpr>™  s    Rm   Rq   R   Ro   RÃ   N(    (   i   i    (G   R&   RÖ   RÒ   RÌ   Rý   R©   RÐ   R[   R”   R$   RÚ   R¨   R    R  R×   R  R’   R\   R   R#   R"   R   R   R   RŽ   R   Rÿ   R   R  RÁ   R¤   RÛ   t   is_AddRÍ   RÝ   R   t   as_independentRÕ   RL   RG   R	   R   R   t   copyRP   R¬   R.   R9   R‘   RÑ   RO   t   homogeneous_ordert   _linear_coeff_matchR
   R   R   RH   R?   R9  R   t   ZeroR   t   is_polynomialt   _nth_order_reducible_matcht   _nth_algebraic_matcht   _nth_linear_matcht   anyt    _undetermined_coefficients_matchRR   t   allhintsRœ   (^   R“   R”   RÂ   R¾   RÜ   R  Rß   R  Rº   R»   R#  R°   t   matching_hintst   dfR  R  R  R—   R  R  RÀ   R  R  R  R  R  R  R  R  t   r3t   boundaryR  R	  t   oldR•   t   dordert   tempt
   reduced_eqt
   deriv_coeft   dent   argt   indt   depR!  t   tmpRÿ   R
  t   checkt   check1t   check2t   rseriest	   numeratorR   R   R$  R%  t   r1t   orderat   orderbR&  R'  Rò   t   s1t   s2t   Ft   paramsR+  R,  RÞ   t   dummy_eqR–   t   r2t   orderdt   orderet   mult   _R2  R.  t   xpartt   ypartR5  Ró   t   no_fR1  t   deqt   ordinaryRÄ   R3  t
   coeff_dictt
   undetcoeffRÍ   R1   R¡   t   retlist(    (   R:  R  R¦   R;  Rú   R<  RÇ   s0   lib/python2.7/site-packages/sympy/solvers/ode.pyR×   >  sš   y	(
*!!!!!333	($&$+)	!/		1
(8



E&




R6



&


   !& !"*	$
	$


&


""


9
9

'82  
8-)	$%
,#'#)
0**
2B) ! !0 ! !"

&






(
%c           sž  d „  ‰  ‡  f d †  |  ˆ g Dƒ \ }  ‰ x@ t  |  ƒ D]2 \ } } t | t ƒ r8 | j | j |  | <q8 q8 Wi | d d 6} |  | d <| d k r¤ t d ƒ ‚ n  t t |  d j t ƒ ƒ d j t	 ƒ ƒ d ‰ t
 ƒ  ‰ ˆ d g k rag  ‰ xl |  D]a } | j t ƒ } t ƒ  j g  | D] } | j t ƒ ^ qŒ  }	 x |	 D] }
 ˆ j |
 ƒ qCWqù Wn  t t ˆ ƒ ƒ ‰ t ˆ ƒ t |  ƒ k ržt d ˆ ƒ ‚ n  t
 ƒ  } xÁ ˆ D]¹ }	 ˆ j |	 t ƒ s®d } xD t  |  ƒ D]6 \ } } t | |	 ƒ } | | k  rÙ| } | } qÙqÙW| | k rPg  } | j | | ƒ | j |	 ƒ | | | <n
 |	 | | <| ˆ |	 <q®q®Wg  t t | ƒ ƒ D] } | | ^ q~‰ ˆ | d	 <x‡ ˆ D] }	 t |	 t ƒ röxg |	 D]. } t | j ƒ d k rÁt d
 |	 ƒ ‚ qÁqÁWq¥|	 r¥t |	 j ƒ d k r¥t d
 |	 ƒ ‚ q¥q¥Wˆ | d <‡ ‡ ‡ ‡ f d †  } i  ‰ t } xx t  |  ƒ D]j \ } } x[ ˆ D]S }	 t |	 t ƒ r´x; |	 D] } | | | | | ƒ } q’Wqv| | | |	 | ƒ } qvWqcWˆ | d <| | d <t t ˆ j ƒ  ƒ ƒ d k rŠt | d j ƒ  ƒ d } | d t k r| d d k rˆ| d k r^t |  ˆ ˆ ƒ } q
| d k rt |  ˆ ˆ ƒ } q
d } q‡| d d k rã| d k rÚt |  ˆ ˆ ƒ } | d k ràt |  ˆ ˆ ƒ } qàq
d } q‡| d k rt |  ˆ ˆ ƒ } q‡d } q| d d k rG| d k r>t |  ˆ ˆ ƒ } q‡d } q| d d k r| d k rxt |  ˆ ˆ ƒ } q‡d } qd } n d } | | d <| S(   sy  
    Returns a dictionary of parameter names and values that define the system
    of ordinary differential equations in ``eq``.
    The parameters are further used in
    :py:meth:`~sympy.solvers.ode.dsolve` for solving that system.

    The parameter names and values are:

    'is_linear' (boolean), which tells whether the given system is linear.
    Note that "linear" here refers to the operator: terms such as ``x*diff(x,t)`` are
    nonlinear, whereas terms like ``sin(t)*diff(x,t)`` are still linear operators.

    'func' (list) contains the :py:class:`~sympy.core.function.Function`s that
    appear with a derivative in the ODE, i.e. those that we are trying to solve
    the ODE for.

    'order' (dict) with the maximum derivative for each element of the 'func'
    parameter.

    'func_coeff' (dict) with the coefficient for each triple ``(equation number,
    function, order)```. The coefficients are those subexpressions that do not
    appear in 'func', and hence can be considered constant for purposes of ODE
    solving.

    'eq' (list) with the equations from ``eq``, sympified and transformed into
    expressions (we are solving for these expressions to be zero).

    'no_of_equations' (int) is the number of equations (same as ``len(eq)``).

    'type_of_equation' (string) is an internal classification of the type of
    ODE.

    References
    ==========
    -http://eqworld.ipmnet.ru/en/solutions/sysode/sode-toc1.htm
    -A. D. Polyanin and A. V. Manzhirov, Handbook of Mathematics for Engineers and Scientists

    Examples
    ========

    >>> from sympy import Function, Eq, symbols, diff
    >>> from sympy.solvers.ode import classify_sysode
    >>> from sympy.abc import t
    >>> f, x, y = symbols('f, x, y', cls=Function)
    >>> k, l, m, n = symbols('k, l, m, n', Integer=True)
    >>> x1 = diff(x(t), t) ; y1 = diff(y(t), t)
    >>> x2 = diff(x(t), t, t) ; y2 = diff(y(t), t, t)
    >>> eq = (Eq(5*x1, 12*x(t) - 6*y(t)), Eq(2*y1, 11*x(t) + 3*y(t)))
    >>> classify_sysode(eq)
    {'eq': [-12*x(t) + 6*y(t) + 5*Derivative(x(t), t), -11*x(t) - 3*y(t) + 2*Derivative(y(t), t)],
    'func': [x(t), y(t)], 'func_coeff': {(0, x(t), 0): -12, (0, x(t), 1): 5, (0, y(t), 0): 6,
    (0, y(t), 1): 0, (1, x(t), 0): -11, (1, x(t), 1): 0, (1, y(t), 0): -3, (1, y(t), 1): 2},
    'is_linear': True, 'no_of_equation': 2, 'order': {x(t): 1, y(t): 1}, 'type_of_equation': 'type1'}
    >>> eq = (Eq(diff(x(t),t), 5*t*x(t) + t**2*y(t)), Eq(diff(y(t),t), -t**2*x(t) + 5*t*y(t)))
    >>> classify_sysode(eq)
    {'eq': [-t**2*y(t) - 5*t*x(t) + Derivative(x(t), t), t**2*x(t) - 5*t*y(t) + Derivative(y(t), t)],
    'func': [x(t), y(t)], 'func_coeff': {(0, x(t), 0): -5*t, (0, x(t), 1): 1, (0, y(t), 0): -t**2,
    (0, y(t), 1): 0, (1, x(t), 0): t**2, (1, x(t), 1): 0, (1, y(t), 0): -5*t, (1, y(t), 1): 1},
    'is_linear': True, 'no_of_equation': 2, 'order': {x(t): 1, y(t): 1}, 'type_of_equation': 'type4'}

    c         S  s(   t  t t t |  ƒ r |  n |  g ƒ ƒ S(   N(   R±   t   mapR&   R   (   R“   (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt   _sympifyô  s    c         3  s   |  ] } ˆ  | ƒ Vq d  S(   N(    (   R¥   t   w(   Rs  (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pys	   <genexpr>÷  s    i   R¸   R“   i    sY   classify_sysode() works for systems of ODEs. For scalar ODEs, classify_ode should be usedsD   Number of functions given is not equal to the number of equations %sR”   sO   dsolve() and classify_sysode() work with functions of one variable only, not %sR°   c   
        sù  xòt  ˆ | d ƒ D]Ü} t |  j ƒ  t | ˆ | ƒ g ƒ j t | ˆ | ƒ ƒ ˆ  | | | f <| t k r ˆ  | | | f d k rD| d k r|  j | d t ƒd } xM t  d t |  | ƒ d ƒ D]/ } | |  j t | ˆ | ƒ d t ƒd 8} qÈ W| d k rAt } qAqî|  j t | ˆ | ƒ d t ƒd rît } qîqñxª ˆ D]Ÿ } t	 | t
 ƒ r¯x‡ | D]A } ˆ  | | | f j | d t ƒd }	 |	 d k rgt } qgqgWqKˆ  | | | f j | d t ƒd }	 |	 d k rKt } qKqKWq q W| S(   Ni   i    R0  (   R   RL   R   R   RÍ   RÒ   R>  R\   R’   R¨   R±   (
   t   eqst   jR”   t
   is_linear_R  t   coeft   xrRß   t
   elem_func_RV  (   t	   func_coefR  R°   RÞ   (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt   linearity_check4  s,    F#-%&&t
   func_coeffR·   i   i   R¶   N(   t	   enumerateR¨   R    R  R  R©   R±   R   R   R"   RÂ   RÐ   Rª   R«   R   Rù   RÌ   RÚ   R’   R\   R   Rý   RÒ   RÏ   t   check_linear_2eq_order1t   check_linear_2eq_order2t   check_linear_3eq_order1t   check_linear_neq_order1t   check_nonlinear_2eq_order1t   check_nonlinear_3eq_order1(   R“   R  RÜ   R¡   t   fiRJ  Ru  t   derivsR—   R”   Rß   t	   func_dictt	   max_ordert   eqs_t   order_t   eq_not	   list_funct	   func_elemR|  R·   Rv  t   order_eqR¶   (    (   Rs  R{  R  R°   RÞ   s0   lib/python2.7/site-packages/sympy/solvers/ode.pyRË   ³  s´    A	"
0	.	
)



						
c           s½  | d j  } | d j  } | } t t |  d j t ƒ ƒ d j t ƒ ƒ d ‰ t ƒ  ‰  | d | ˆ ƒ d f ˆ  d <| d | ˆ ƒ d f ˆ  d <| d | ˆ ƒ d f | d | ˆ ƒ d f ˆ  d <| d | ˆ ƒ d f | d | ˆ ƒ d f ˆ  d <| d | ˆ ƒ d f | d | ˆ ƒ d f ˆ  d <| d | ˆ ƒ d f | d | ˆ ƒ d f ˆ  d <t d ƒ t d ƒ g } xc t d	 ƒ D]U } xL t j	 |  | ƒ D]7 } | j
 | ˆ ƒ | ˆ ƒ ƒ s¦| | c | 7<q¦q¦WqŒW| d j
 ˆ ƒ p| d j
 ˆ ƒ s*| d ˆ  d
 <| d ˆ  d <n d  Sd }	 d }
 t ˆ  d t ˆ  d ˆ  d ƒ j ƒ  d ƒ } t ˆ  d t ˆ  d ˆ  d ƒ j ƒ  d ƒ } xô t | | g ƒ D]à \ } } xÑ t j	 t | ƒ ƒ D]º } | j
 ˆ ƒ sí| }
 n  |
 r;| d k r;ˆ  d | ˆ  d ˆ  d ˆ  d | | k r‰d }	 q‰qÏ|
 rÏ| d k rÏˆ  d | ˆ  d ˆ  d ˆ  d | | k r‰d	 }	 q‰qÏqÏWq­Wˆ  d
 d k s±ˆ  d d k rˆ  d
 j
 ˆ ƒ rˆ  d j
 ˆ ƒ rt ‡  ‡ f d †  d j ƒ  Dƒ ƒ r	d Sq¹d  Sn­t ‡  ‡ f d †  d j ƒ  Dƒ ƒ r5d Sˆ  d ˆ  d ˆ  d <ˆ  d ˆ  d ˆ  d <ˆ  d ˆ  d ˆ  d <ˆ  d ˆ  d ˆ  d <ˆ  d ˆ  d k r¹ˆ  d ˆ  d k r¹d Sˆ  d ˆ  d k râˆ  d ˆ  d k sˆ  d ˆ  d k rˆ  d ˆ  d k rd St ˆ  d ˆ  d ƒ j
 ˆ ƒ r[t ˆ  d ˆ  d ˆ  d ƒ j
 ˆ ƒ s§t ˆ  d ˆ  d ƒ j
 ˆ ƒ r«t ˆ  d ˆ  d ˆ  d ƒ j
 ˆ ƒ r«d S|	 rµd Sd Sd  S(   Ni    i   t   a1R  t   b1R  R  R  i   t   d1R  c         3  s#   |  ] } ˆ  | j  ˆ ƒ Vq d  S(   N(   R  (   R¥   R  (   Rú   RÞ   (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pys	   <genexpr>³  s    s   a1 a2 b1 b2 c1 c2t   type2c         3  s#   |  ] } ˆ  | j  ˆ ƒ Vq d  S(   N(   R  (   R¥   R  (   Rú   RÞ   (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pys	   <genexpr>¹  s    t   type1t   type3t   type4t   type5t   type6t   type7(   R”   R±   R   R   R"   RÂ   R   R   R   t	   make_argsR  RÐ   RG   t   as_numer_denomR~  R   RU   RÁ   t   split(   R“   R”   R{  RÇ   R  t   fct   forcingR¡   Rv  R.  R3  t   p1t   p2RÀ   (    (   Rú   RÞ   s0   lib/python2.7/site-packages/sympy/solvers/ode.pyR  ‡  sn    0	 5 55 5&00	00 (%%  (RLLc           sB  | d j  } | d j  } | } t t |  d j t ƒ ƒ d j t ƒ ƒ d ‰ t ƒ  ‰  t d d d ˆ g ƒ} t d d d ˆ d g ƒ} t d d ˆ ˆ d g ƒ} t d d ˆ ˆ d g ƒ}	 t d	 d ˆ ˆ d g ƒ}
 t d
 d ˆ ˆ d g ƒ} | d | ˆ ƒ d f ˆ  d <| d | ˆ ƒ d f ˆ  d <| d | ˆ ƒ d f ˆ  d <| d | ˆ ƒ d f ˆ  d <| d | ˆ ƒ d f ˆ  d <| d | ˆ ƒ d f ˆ  d <| d | ˆ ƒ d f ˆ  d <| d | ˆ ƒ d f ˆ  d <| d | ˆ ƒ d f ˆ  d <| d | ˆ ƒ d f ˆ  d <t d ƒ t d ƒ g } xo t d ƒ D]a } xX t	 j
 |  | ƒ D]C } | j | ˆ ƒ ƒ p| j | ˆ ƒ ƒ s`| | c | 7<q`q`WqFW| d ˆ  d <| d ˆ  d <ˆ  d d k sçˆ  d d k rét ‡  ‡ f d †  d j ƒ  Dƒ ƒ rRˆ  d ˆ  d k oIˆ  d k oIˆ  d k oId k n rRd St ‡  ‡ f d †  d j ƒ  Dƒ ƒ rât d ƒ t d ƒ g } t d ƒ t d ƒ g } xí t ˆ  d ˆ  d g ƒ D]Ñ \ } } | j ˆ ƒ r‰| j ˆ t ƒ d } x t j
 | ƒ D] } | j t ƒ rx| j ƒ  \ } } | j ˆ ƒ } | rk| j ˆ ƒ rk| j t ƒ rkd | | <q‚d | | <qd | | <qWqÂd | | <qÂW| d d k rÛ| d d k rÛ| d d k rÛ| d d k rÛd Sd  Sq>d  SnUˆ  d ˆ  d k o&ˆ  d k o&ˆ  d k o&d k n rTt ‡  ‡ f d †  d j ƒ  Dƒ ƒ rTd Sˆ  d ˆ  d k o‘ˆ  d k o‘ˆ  d k o‘d k n rèt ‡  ‡ f d  †  d! j ƒ  Dƒ ƒ rèˆ  d ˆ  d k rèˆ  d ˆ  d k rèd" St ˆ  d ˆ  d ƒ ˆ k r¤t ˆ  d ˆ  d ƒ ˆ k r¤ˆ  d ˆ  d j ˆ ƒ r¤ˆ  d ˆ  d j ˆ ƒ r¤ˆ  d ˆ  d k o›ˆ  d k o›ˆ  d k o›d k n r¤d# Sˆ  d ˆ  d j ƒ  j | | ˆ d |	 ˆ |
 d j ƒ  ƒ r—t ˆ  d ˆ  d ˆ  d ˆ  d ƒ j ˆ ƒ r—ˆ  d ˆ  d j ˆ ƒ r—ˆ  d ˆ  d j ˆ ƒ r—ˆ  d ˆ  d k oŽˆ  d k oŽˆ  d k oŽd k n r—d$ St ˆ  d ˆ  d ƒ j ˆ ƒ rSt ˆ  d ˆ  d ƒ j ˆ ƒ rSt ˆ  d ˆ  d ˆ  d ˆ  d ƒ j ˆ ƒ rSˆ  d ˆ  d k oJˆ  d k oJˆ  d k oJd k n rSd% St ˆ  d ˆ  d ƒ j ˆ ƒ r	t ˆ  d ˆ  d ƒ j ˆ ƒ r	t ˆ  d ˆ  d ˆ  d ˆ  d ƒ j ˆ ƒ r	ˆ  d ˆ  d k o	ˆ  d k o	ˆ  d k o	d k n r	d& St ˆ  d ˆ  d ƒ ˆ k rØ	t ˆ  d ˆ  d ƒ ˆ k rØ	t ˆ  d ˆ  d ˆ  d ˆ  d ƒ j ˆ ƒ rØ	ˆ  d j ˆ ƒ rØ	ˆ  d ˆ  d k oÏ	ˆ  d k oÏ	ˆ  d k oÏ	d k n rØ	d' Sˆ  d ˆ  d j | ˆ ƒ rÐ
ˆ  d ˆ  d j | ˆ ƒ rÐ
ˆ  d ˆ  d j ˆ ƒ rÐ
ˆ  d ˆ  d j ˆ ƒ rÐ
ˆ  d ˆ  d j | ˆ d ƒ rÐ
ˆ  d ˆ  d j | ˆ d ƒ rÐ
ˆ  d ˆ  d j ˆ ƒ rÐ
ˆ  d ˆ  d j ˆ ƒ rÐ
d( Sˆ  d ˆ  d ˆ  d ˆ  d k o1ˆ  d ˆ  d k o1ˆ  d ˆ  d k o1ˆ k n r:d) Sd  Sd  S(*   Ni    i   R  R§   R  i   R!  t   vRt  R.  R  R  R  R  R  R  R‘  R  t   e1t   e2t   f1t   f2c         3  s#   |  ] } ˆ  | j  ˆ ƒ Vq d  S(   N(   R  (   R¥   R  (   Rú   RÞ   (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pys	   <genexpr>è  s    s   a1 a2 d1 d2 e1 e2 f1 f2R’  c         3  s#   |  ] } ˆ  | j  ˆ ƒ Vq d  S(   N(   R  (   R¥   R  (   Rú   RÞ   (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pys	   <genexpr>ì  s    s   a1 a2 b1 b2 c1 c2 d1 d2 e1 e1R•  c         3  s#   |  ] } ˆ  | j  ˆ ƒ Vq d  S(   N(   R  (   R¥   R  (   Rú   RÞ   (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pys	   <genexpr>  s   s   a1 a2 d1 d2 e1 e2R“  c         3  s#   |  ] } ˆ  | j  ˆ ƒ Vq d  S(   N(   R  (   R¥   R  (   Rú   RÞ   (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pys	   <genexpr>	  s   s   a1 a2 b2 c1 d1 e2R”  R–  t   type10R—  R˜  t   type8t   type9t   type11(   R”   R±   R   R   R"   RÂ   R#   R   R   R   R™  R  RÁ   R›  R~  R>  R   R.   R9  RÍ   R   RÐ   RG   R   RÝ   (   R“   R”   R{  RÇ   R  Rœ  R  R  R!  R   Rt  R.  t   constR¡   Rv  R3  RÀ   R  t   tpartt   co(    (   Rú   RÞ   s0   lib/python2.7/site-packages/sympy/solvers/ode.pyR€  Ï  s¨    0	     * %B% '%@TT(>8BCN^DtDt>EB>8F8fc   
        s”  | d j  } | d j  } | d j  } | } t t |  d j t ƒ ƒ d j t ƒ ƒ d ‰ t ƒ  ‰ | d | ˆ ƒ d f ˆ d <| d | ˆ ƒ d f ˆ d <| d | ˆ ƒ d f ˆ d <| d | ˆ ƒ d f ˆ d <| d | ˆ ƒ d f ˆ d <| d | ˆ ƒ d f ˆ d	 <| d | ˆ ƒ d f ˆ d
 <| d | ˆ ƒ d f ˆ d <| d | ˆ ƒ d f ˆ d <| d | ˆ ƒ d f ˆ d <| d | ˆ ƒ d f ˆ d <| d | ˆ ƒ d f ˆ d <t d ƒ t d ƒ t d ƒ g } xl t d ƒ D]^ } xU t j	 |  | ƒ D]@ }	 |	 j
 | ˆ ƒ | ˆ ƒ | ˆ ƒ ƒ s
| | c |	 7<q
q
WqðW| d j
 ˆ ƒ s‹| d j
 ˆ ƒ s‹| d j
 ˆ ƒ rd  St ‡ ‡ f d †  d j ƒ  Dƒ ƒ rˆ d
 ˆ d k oâˆ d k oâd k n rëd Sˆ d
 ˆ d k raˆ d ˆ d	 k raˆ d ˆ d k raˆ d ˆ d k oXˆ d k oXd k n rad Sˆ d ˆ d k oˆ d k od k n rˆ d
 ˆ d ˆ d ˆ d k rˆ d ˆ d ˆ d ˆ d k rˆ d	 ˆ d ˆ d ˆ d k rd Sd  Sn‚ x d j ƒ  D]q ‰  ˆ ˆ  d k r7qqt ‡  ‡ ‡ f d †  d j ƒ  Dƒ ƒ r‹t ‡  ‡ ‡ f d †  d j ƒ  Dƒ ƒ r‹d SPqWd  S(   Ni    i   i   R  R  R  R  R  R  R  R  R  R‘  R  t   d3i   c         3  s#   |  ] } ˆ  | j  ˆ ƒ Vq d  S(   N(   R  (   R¥   R  (   Rú   RÞ   (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pys	   <genexpr>F  s    s#   a1 a2 a3 b1 b2 b3 c1 c2 c3 d1 d2 d3R“  R’  R”  s   c1 d1 b2 d2 b3 c3c         3  sA   |  ]7 } ˆ | d  k r t  ˆ ˆ  ˆ | ƒ j ˆ ƒ Vq d S(   i    N(   RG   R  (   R¥   R  (   t   k1Rú   RÞ   (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pys	   <genexpr>V  s    s   d1 b2 d2 b3 c3c         3  sM   |  ]C } ˆ d  ˆ | k r t  ˆ ˆ  ˆ d  ˆ | ƒ j ˆ ƒ Vq d S(   R  N(   RG   R  (   R¥   R  (   R­  Rú   RÞ   (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pys	   <genexpr>W  s    s   b1 c2 d3R•  (   R”   R±   R   R   R"   RÂ   R   R   R   R™  R  RÐ   RÁ   R›  (
   R“   R”   R{  RÇ   R  t   zRœ  R  R¡   Rv  (    (   R­  Rú   RÞ   s0   lib/python2.7/site-packages/sympy/solvers/ode.pyR  1  sV    0	        !'9%3?3XJ((c         C  só   | d j  } | d j  } | d j  } | } t t |  d j t ƒ ƒ d j t ƒ ƒ d } t ƒ  } t |  ƒ }	 xd t |	 ƒ D]V }
 xM t |	 ƒ D]? } | |
 | | d f | |
 | |
 d f j | ƒ r’ d  Sq’ Wq Wt |  ƒ d k rï d Sd S(   Ni    i   i   i   R—  R“  (
   R”   R±   R   R   R"   RÂ   RÌ   R   R  RÐ   (   R“   R”   R{  RÇ   R  R®  Rœ  RÞ   Rú   RÀ   R¡   Rv  (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyR‚  ]  s    0	5c           s¢  t  t  ˆ  d j t ƒ ƒ d j t ƒ ƒ d ‰ t d ƒ ‰ t d ƒ ‰ t d d t ƒ\ ‰ ‰ ‡  ‡ ‡ ‡ ‡ ‡ f d †  } xj | D]b } t | t  ƒ r… | d d j } | d d j } | | | ƒ } | sã | | | ƒ } n  | Sq… W| d j } | d j } | } t d d	 | ˆ ƒ | ˆ ƒ g ƒ}	 t d
 d	 ˆ ˆ g ƒ}
 t d d	 ˆ ˆ g ƒ} t d d	 ˆ ˆ g ƒ} t d d	 ˆ ˆ g ƒ} xa t	 d ƒ D]S } d } x: t
 j ˆ  | ƒ D]% } | | | | | | d f 7} q¼W| ˆ  | <qœWˆ  d j t | ˆ ƒ ˆ ƒ | ˆ ƒ |	 ˆ ƒ } | rUt | ˆ ƒ ˆ ƒ ˆ  d | ˆ ‰ n  | rÍˆ j | ˆ ƒ ƒ pÅˆ j | ˆ ƒ ˆ ƒ j ˆ ƒ pÅ| ˆ j | ˆ ƒ ˆ ƒ j | ˆ ƒ ˆ ƒ j ˆ ƒ rÍd Sˆ  d j t | ˆ ƒ ˆ ƒ t |	 | ˆ ƒ ƒ ˆ ƒ } | r5t | ˆ ƒ ˆ ƒ ˆ  d | ˆ ‰ n  | r­ˆ j | ˆ ƒ ƒ p¥ˆ j | ˆ ƒ ˆ ƒ j ˆ ƒ p¥| ˆ j | ˆ ƒ ˆ ƒ j | ˆ ƒ ˆ ƒ j ˆ ƒ r­d St d ƒ ‰ ˆ  d j t | ˆ ƒ ˆ ƒ ˆ ƒ } ˆ  d j t | ˆ ƒ ˆ ƒ ˆ ƒ } | r„| r„| ˆ j | ˆ ƒ ˆ ƒ j | ˆ ƒ ˆ ƒ j ˆ ƒ p|| ˆ j | ˆ ƒ ˆ ƒ j | ˆ ƒ ˆ ƒ j ˆ ƒ r„d Sˆ  d j t | ˆ ƒ ˆ ƒ ˆ ƒ } ˆ  d j t | ˆ ƒ ˆ ƒ ˆ ƒ } | ˆ j | ˆ ƒ ˆ ƒ j | ˆ ƒ ˆ ƒ | ˆ j | ˆ ƒ ˆ ƒ j | ˆ ƒ ˆ ƒ j ƒ  \ } } | j |
 | ƒ } | j | | ƒ } | ˆ j | ˆ ƒ ˆ ƒ j | ˆ ƒ ˆ ƒ | } | rž| ržd Sd  S(   Ni    R¦   R1  s   u, vt   clsc           sŒ  ˆ  d j  ˆ t |  ˆ ƒ ˆ ƒ |  ˆ ƒ ˆ ƒ } ˆ  d j  ˆ t | ˆ ƒ ˆ ƒ | ˆ ƒ ˆ ƒ } | oq | sç ˆ  d j  t |  ˆ ƒ ˆ ƒ |  ˆ ƒ ˆ ˆ ˆ ƒ } ˆ  d j  t | ˆ ƒ ˆ ƒ | ˆ ƒ ˆ ˆ ˆ ƒ } n  | oð | s`ˆ  d j  ˆ t |  ˆ ƒ ˆ ƒ |  ˆ ƒ ˆ ƒ } ˆ  d j  ˆ t | ˆ ƒ ˆ ƒ | ˆ ƒ ˆ ƒ } n  | oi| sáˆ  d j  t |  ˆ ƒ ˆ ƒ |  ˆ ƒ ˆ ˆ ˆ ƒ } ˆ  d j  t | ˆ ƒ ˆ ƒ | ˆ ƒ ˆ ˆ ˆ ƒ } n  | r„| r„| ˆ j t |  ˆ ƒ ˆ ƒ ˆ ƒ j t | ˆ ƒ ˆ ƒ ˆ ƒ j ˆ ƒ p|| ˆ j t |  ˆ ƒ ˆ ƒ ˆ ƒ j t | ˆ ƒ ˆ ƒ ˆ ƒ j ˆ ƒ r„d Sd  Sd  S(   Ni    i   R–  (   RÝ   R   RÕ   R  RÐ   (   RÇ   R  R]  Re  (   R“   R¦   R1  RÞ   R!  R   (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt
   check_typer  s    448;589<UJi   RÀ   R§   R£  R¤  t   g1t   g2i   R“  R’  R”  R•  (   R±   R   R   R"   R#   R%   R$   R¨   R”   R   R   R™  RÝ   R   R  RÕ   R.   Rš  RÐ   (   R“   R”   R{  R°  Rß   RÇ   R  t   eq_typeRœ  RÀ   R£  R¤  R±  R²  R¡   Ru  R#  Rú   R]  Re  R   RS  t   R1t   R2t   phi(    (   R“   R¦   R1  RÞ   R!  R   s0   lib/python2.7/site-packages/sympy/solvers/ode.pyRƒ  m  sh    0$#4(t:(t&&C8&&+;2c         C  s   d  S(   N(   RÐ   (   R“   R”   R{  (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt   check_nonlinear_2eq_order2µ  s    c         C  sg	  | d j  } | d j  } | d j  } | } t t |  d j t ƒ ƒ d j t ƒ ƒ d } t d d t ƒ\ } }	 }
 t d d | | ƒ | | ƒ | | ƒ | g ƒ} t d d | | ƒ | | ƒ | | ƒ | g ƒ} t d	 d | | ƒ | | ƒ | | ƒ | g ƒ} t d
 ƒ } t d ƒ } t d ƒ } t d ƒ } xa t d ƒ D]S } d } x: t	 j
 |  | ƒ D]% } | | | | | | d f 7} qeW| |  | <qEW|  d j t | | ƒ | ƒ | | | ƒ | | ƒ ƒ } |  d j t | | ƒ | ƒ | | | ƒ | | ƒ ƒ } |  d j t | | ƒ | ƒ | | | ƒ | | ƒ ƒ } | ró| ró| ró| | j ƒ  \ } } | | j ƒ  \ } } | | j ƒ  \ } } t | | | |	 |
 | |	 | |
 | | |
 | | |	 g | |	 g ƒ ród Sn  |  d j t | | ƒ | ƒ | | ƒ | | ƒ | ƒ } | r×t | | ƒ j | | ƒ } t | | ƒ | ƒ |  d | | j | | | ƒ | | ƒ ƒ } t | | ƒ | ƒ |  d | | j | | | ƒ | | ƒ ƒ } n  | r€| r€| r€| | j ƒ  \ } } | | j ƒ  \ } } | | j ƒ  \ } } t | | | |	 |
 | |	 | |
 | | |
 | | |	 g | |	 g ƒ r€d Sn  |  d j t | | ƒ | ƒ | | ƒ } | rt | | ƒ j | | ƒ } | j t | | ƒ j | | ƒ ƒ | r¢|  d j | | ƒ re|  d j | | ƒ re| | | | | | <| | <| | | | | | <| | <n  |  d j t | | ƒ | ƒ | | | | | | ƒ } n  | rê|  d t | | ƒ | ƒ | | | | | | | | k } n  | r| r| rd Sn  |  d j t | | ƒ | ƒ | | ƒ | | | ƒ | ƒ } | rÂt | | ƒ j | | ƒ } | j t | | ƒ j | | ƒ ƒ | rM|  d j | | ƒ rü|  d j | | ƒ rü| | | | | | <| | <| | | | | | <| | <n  t | | ƒ | ƒ |  d j | | | ƒ | | | | | | ƒ | ƒ } n  | r©t | | ƒ | ƒ |  d | | | | ƒ | | | | | | ƒ | | k } n  | rÂ| rÂ| rÂd Sn  t | | ƒ | ƒ |  d j | | ƒ | | ƒ } | rc	t | | ƒ j | | ƒ } | j t | | ƒ j | | ƒ ƒ | rø|  d j | | ƒ r±|  d j | | ƒ r±| | | | | | <| | <| | | | | | <| | <n  t | | ƒ | ƒ |  d j | | ƒ | | | | | | ƒ } n  | rJ	t | | ƒ | ƒ |  d | | ƒ | | | | | | | | k } n  | rc	| rc	| rc	d Sn  d  S(   Ni    i   i   s   u, v, wR¯  R  R§   R  R  R¦   t   F1t   F2t   F3i   R“  R’  R”  R•  R–  (   R”   R±   R   R   R"   R%   R$   R#   R   R   R™  RÝ   R   Rš  RV   RU   RÛ   R  RÐ   (   R“   R”   R{  RÇ   R  R®  Rœ  RÞ   R!  R   Rt  R  R  R  R¦   R¸  R¹  Rº  R¡   Ru  R#  R]  Re  RL  t   num1t   den1t   num2t   den2t   num3t   den3Rú   (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyR„  ¸  sœ    0000#:::N:BEN*$/"=B>$/"QV4$/"GLc         C  s   d  S(   N(   RÐ   (   R“   R”   R{  (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt   check_nonlinear_3eq_order2  s    c         C  s.  d „  } | |  ƒ }  xL t  t |  ƒ ƒ D]8 } t |  | t ƒ r( |  | j |  | j |  | <q( q( W| d k r÷ g  } xi |  D]a } | j t ƒ } t	 ƒ  j
 g  | D] } | j t ƒ ^ q¢ Œ  } x | D] }	 | j |	 ƒ qÇ Wq} Wt t	 | ƒ ƒ } n  t d „  | Dƒ ƒ r=t d „  | Dƒ ƒ d k r=t d | ƒ ‚ n  x8 | D]0 }
 t |
 j t ƒ ƒ d k rDt d ƒ ‚ qDqDWt | ƒ t d „  | Dƒ ƒ k r©t d ƒ ‚ n  | d	 j d	 } t ƒ  } xž | D]– }
 t |
 j t ƒ ƒ d	 } |
 j | k r|
 j }
 n  |
 j | k o#|
 j j | ƒ } | sMt |
 | ƒ } | sVt ‚ qVn	 |
 j } | | | <qÊWg  } xu |  D]m } x$ | D] } t | | | | ƒ } q~Wt | ƒ } | d	 k rË| j d
 t ƒ } n d	 } | j | ƒ qqWt t	 | ƒ ƒ d k r t t	 | ƒ ƒ d	 d	 k r t | f St | f Sd S(   sm
  
    Substitutes corresponding ``sols`` for each functions into each ``eqs`` and
    checks that the result of substitutions for each equation is ``0``. The
    equations and solutions passed can be any iterable.

    This only works when each ``sols`` have one function only, like `x(t)` or `y(t)`.
    For each function, ``sols`` can have a single solution or a list of solutions.
    In most cases it will not be necessary to explicitly identify the function,
    but if the function cannot be inferred from the original equation it
    can be supplied through the ``func`` argument.

    When a sequence of equations is passed, the same sequence is used to return
    the result for each equation with each function substituted with corresponding
    solutions.

    It tries the following method to find zero equivalence for each equation:

    Substitute the solutions for functions, like `x(t)` and `y(t)` into the
    original equations containing those functions.
    This function returns a tuple.  The first item in the tuple is ``True`` if
    the substitution results for each equation is ``0``, and ``False`` otherwise.
    The second item in the tuple is what the substitution results in.  Each element
    of the ``list`` should always be ``0`` corresponding to each equation if the
    first item is ``True``. Note that sometimes this function may return ``False``,
    but with an expression that is identically equal to ``0``, instead of returning
    ``True``.  This is because :py:meth:`~sympy.simplify.simplify.simplify` cannot
    reduce the expression to ``0``.  If an expression returned by each function
    vanishes identically, then ``sols`` really is a solution to ``eqs``.

    If this function seems to hang, it is probably because of a difficult simplification.

    Examples
    ========

    >>> from sympy import Eq, diff, symbols, sin, cos, exp, sqrt, S, Function
    >>> from sympy.solvers.ode import checksysodesol
    >>> C1, C2 = symbols('C1:3')
    >>> t = symbols('t')
    >>> x, y = symbols('x, y', cls=Function)
    >>> eq = (Eq(diff(x(t),t), x(t) + y(t) + 17), Eq(diff(y(t),t), -2*x(t) + y(t) + 12))
    >>> sol = [Eq(x(t), (C1*sin(sqrt(2)*t) + C2*cos(sqrt(2)*t))*exp(t) - S(5)/3),
    ... Eq(y(t), (sqrt(2)*C1*cos(sqrt(2)*t) - sqrt(2)*C2*sin(sqrt(2)*t))*exp(t) - S(46)/3)]
    >>> checksysodesol(eq, sol)
    (True, [0, 0])
    >>> eq = (Eq(diff(x(t),t),x(t)*y(t)**4), Eq(diff(y(t),t),y(t)**3))
    >>> sol = [Eq(x(t), C1*exp(-1/(4*(C2 + t)))), Eq(y(t), -sqrt(2)*sqrt(-1/(C2 + t))/2),
    ... Eq(x(t), C1*exp(-1/(4*(C2 + t)))), Eq(y(t), sqrt(2)*sqrt(-1/(C2 + t))/2)]
    >>> checksysodesol(eq, sol)
    (True, [0, 0])

    c         S  s(   t  t t t |  ƒ r |  n |  g ƒ ƒ S(   N(   R±   Rr  R&   R   (   R“   (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyRs  @  s    c         s  s3   |  ]) } t  | t ƒ o* t | j ƒ d  k Vq d S(   i   N(   R¨   R   RÌ   Rý   (   R¥   R”   (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pys	   <genexpr>N  s    c         S  s   h  |  ] } | j  ’ q S(    (   Rý   (   R¥   R”   (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pys	   <setcomp>O  s   	 i   s/   func must be a function of one variable, not %ss'   solutions should have one function onlyc         S  s   h  |  ] } | j  ’ q S(    (   R  (   R¥   Rä   (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pys	   <setcomp>T  s   	 sC   number of solutions provided does not match the number of equationsi    t   forceN(   R   RÌ   R¨   R    R  R  RÐ   R   R   Rª   R«   R   Rù   R±   RÁ   R©   Rý   RÂ   t   reversedR  RV   RÑ   R˜   RP   R   RÒ   R’   (   Ru  Rá   R”   Rs  R¡   R  R“   R†  R—   Rß   Rä   RÞ   t   dictsolt   solvedR  t   checkeqt   ss(    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt   checksysodesol  s\    4	#."	"	4
c         C  s  | j  d } | j } t | d d ƒ} | j |  j } t | | | ƒ } | j d ƒ rh t | ƒ } n  t | t ƒ s† t	 d ƒ ‚ n  t
 | | ƒ } | j | k rÒ | j j | ƒ rÒ t | j | j ƒ g } n  | j | k ro| j j | ƒ ro| g } | j d ƒ r®y t j d t ƒ t j ƒ  Wn t k
 r=n Xt | ƒ d k ri| d j | | ƒ k sot ‚ | d j } t | ƒ } x{ t D]s \ }	 }
 } t | | |	 t |
 | ƒ t t | ƒ | ƒ ƒ } t | | |	 t |
 | ƒ t | | ƒ ƒ } qWx8 t D]0 \ }	 }
 } t | | |	 t |
 | ƒ ƒ } qWb t | ƒ } t | | ƒ | ƒ | d <q®n?yY t d „  | j t ƒ Dƒ ƒ } t  | | d	 t! d
 | r¯t" n d ƒ} | sÇt$ ‚ n  Wn  t$ t% f k
 rê| g } n8 Xd „  } g  | D]! } t | | ƒ | | ƒ ƒ ^ qû} | j d ƒ r®xz t& | ƒ D]i \ } } t' | d	 t! ƒ} t | j t( ƒ r| j d k rt | j j  d | | ƒ } n  | | | <q>Wn  xG t& | ƒ D]9 \ }	 } t
 | | ƒ | |	 <t) | |	 |  j ƒ | |	 <q»Wt | ƒ d k r| d } n  | S(   sØ  
    Simplifies solutions of ODEs, including trying to solve for ``func`` and
    running :py:meth:`~sympy.solvers.ode.constantsimp`.

    It may use knowledge of the type of solution that the hint returns to
    apply additional simplifications.

    It also attempts to integrate any :py:class:`~sympy.integrals.Integral`\s
    in the expression, if the hint is not an ``_Integral`` hint.

    This function should have no effect on expressions returned by
    :py:meth:`~sympy.solvers.ode.dsolve`, as
    :py:meth:`~sympy.solvers.ode.dsolve` already calls
    :py:meth:`~sympy.solvers.ode.odesimp`, but the individual hint functions
    do not call :py:meth:`~sympy.solvers.ode.odesimp` (because the
    :py:meth:`~sympy.solvers.ode.dsolve` wrapper does).  Therefore, this
    function is designed for mainly internal use.

    Examples
    ========

    >>> from sympy import sin, symbols, dsolve, pprint, Function
    >>> from sympy.solvers.ode import odesimp
    >>> x , u2, C1= symbols('x,u2,C1')
    >>> f = Function('f')

    >>> eq = dsolve(x*f(x).diff(x) - f(x) - x*sin(f(x)/x), f(x),
    ... hint='1st_homogeneous_coeff_subs_indep_div_dep_Integral',
    ... simplify=False)
    >>> pprint(eq, wrap_line=False)
                            x
                           ----
                           f(x)
                             /
                            |
                            |   /        1   \
                            |  -|u2 + -------|
                            |   |        /1 \|
                            |   |     sin|--||
                            |   \        \u2//
    log(f(x)) = log(C1) +   |  ---------------- d(u2)
                            |          2
                            |        u2
                            |
                           /

    >>> pprint(odesimp(eq, f(x), 1, {C1},
    ... hint='1st_homogeneous_coeff_subs_indep_div_dep'
    ... )) #doctest: +SKIP
        x
    --------- = C1
       /f(x)\
    tan|----|
       \2*x /

    i    R   i   t"   nth_linear_euler_eq_nonhomogeneouss$   eq should be an instance of Equalityt   nth_linear_constant_coeffRÄ   c         s  s   |  ] } | j  Vq d  S(   N(   t   is_Float(   R¥   R¡   (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pys	   <genexpr>ö  s    RÂ  t   rationalc         S  s?   |  j  ƒ  \ } } | j r |  St |  j ƒ  d d d t ƒSd  S(   Nt   combineR.   RŒ   (   Rš  R=  RN   R   RÒ   (   RŽ   t   numert   denom(    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt   _expandý  s    	t   1st_homogeneous_coeffN(*   Rý   R”   R£   R¬   Rø   t
   startswithRP   R¨   R    t	   TypeErrort   constantsimpR  R  R  R!   t   collecttermst   sortRY   t   reverset	   ExceptionRÌ   t   AssertionErrorR   RL   R.   R2   t   absR-   RN   RG  R   R   RV   RÒ   R’   RÐ   RÑ   RC   R~  RM   R0   t   constant_renumber(   R½   R“   R”   R¹   RÇ   R¦   R  Râ   Rä   R¡   t   reroott   imroott   floatst   eqsolRÐ  RÞ   Rv  t   eqit   newi(    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyR÷   t  sh    :	""	153%'	.! t   autoc      
   C  st  t  |  t ƒ s! t |  d ƒ }  n  | d k rÖ y t |  j ƒ \ } } WqÖ t k
 rÒ g  t | t ƒ rn | n | g D] } | j	 t
 ƒ ^ qu } t ƒ  j | Œ  } t | ƒ d k rÃ t d ƒ ‚ n  | j ƒ  } qÖ Xn  t  | t
 ƒ sû t | j ƒ d k rt d | ƒ ‚ n  t | t ƒ rUt | ƒ g  | D]! } t |  | d | d | ƒ^ q-ƒ St  | t ƒ svt | | ƒ } n | j | k r‘| j } n  | d k r¯t |  | ƒ } n  | j | k oÎ| j j | ƒ }	 | rP|	 rPt | | ƒ }
 |
 rPg  |
 D] } t | | ƒ ^ qú} t |
 ƒ d k r4| d } n  t |  | d | d t ƒSn  t } d } | j d } x³| r| d k rü|  j |  j } | j | k rµt | | | j ƒ } n | d 7} qlt | ƒ } | ré| j d t ƒ } n d } | d 7} ql| d k rct t t | j | | ƒ t | j | | ƒ ƒ t |  j ƒ t |  j ƒ ƒ } | d 7} ql| d	 k r| j | k r¤| j j | ƒ r¤i | j d 6} n; | j | k rÙ| j j | ƒ rÙi | j d 6} n i  } | j | j } x¯ t d | d ƒ D]š } | d k r‚| j | ƒ } y. t | | j | | ƒ ƒ } | sQt ‚ n  Wn t k
 rp| d 7} PqX| d | | <q| | d j | ƒ | | <qW| d	 k r³qlq|  j |  j } }
 xÕ t | d
 d
 ƒ D]Á } | d k rûd | k rûPn  t | | j | | ƒ | | ƒ } t |
 | j | | ƒ | | ƒ }
 t | |
 ƒ } t | ƒ } t  | t t  f ƒ rˆ| ršt! j" } }
 qšqÙ| j } | j }
 qÙWt | |
 j# ƒ  d ƒ } t$ d ƒ } | j% | | ƒ } t& | ƒ \ } } t | ƒ j' | ƒ j' i | | 6ƒ } | d 7} qlPqlW| s/t | f S| t k rft d t( | ƒ d t( |  ƒ d ƒ ‚ n
 t | f Sd S(   sI
  
    Substitutes ``sol`` into ``ode`` and checks that the result is ``0``.

    This only works when ``func`` is one function, like `f(x)`.  ``sol`` can
    be a single solution or a list of solutions.  Each solution may be an
    :py:class:`~sympy.core.relational.Equality` that the solution satisfies,
    e.g. ``Eq(f(x), C1), Eq(f(x) + C1, 0)``; or simply an
    :py:class:`~sympy.core.expr.Expr`, e.g. ``f(x) - C1``. In most cases it
    will not be necessary to explicitly identify the function, but if the
    function cannot be inferred from the original equation it can be supplied
    through the ``func`` argument.

    If a sequence of solutions is passed, the same sort of container will be
    used to return the result for each solution.

    It tries the following methods, in order, until it finds zero equivalence:

    1. Substitute the solution for `f` in the original equation.  This only
       works if ``ode`` is solved for `f`.  It will attempt to solve it first
       unless ``solve_for_func == False``.
    2. Take `n` derivatives of the solution, where `n` is the order of
       ``ode``, and check to see if that is equal to the solution.  This only
       works on exact ODEs.
    3. Take the 1st, 2nd, ..., `n`\th derivatives of the solution, each time
       solving for the derivative of `f` of that order (this will always be
       possible because `f` is a linear operator). Then back substitute each
       derivative into ``ode`` in reverse order.

    This function returns a tuple.  The first item in the tuple is ``True`` if
    the substitution results in ``0``, and ``False`` otherwise. The second
    item in the tuple is what the substitution results in.  It should always
    be ``0`` if the first item is ``True``. Sometimes this function will
    return ``False`` even when an expression is identically equal to ``0``.
    This happens when :py:meth:`~sympy.simplify.simplify.simplify` does not
    reduce the expression to ``0``.  If an expression returned by this
    function vanishes identically, then ``sol`` really is a solution to
    the ``ode``.

    If this function seems to hang, it is probably because of a hard
    simplification.

    To use this function to test, test the first item of the tuple.

    Examples
    ========

    >>> from sympy import Eq, Function, checkodesol, symbols
    >>> x, C1 = symbols('x,C1')
    >>> f = Function('f')
    >>> checkodesol(f(x).diff(x), Eq(f(x), C1))
    (True, 0)
    >>> assert checkodesol(f(x).diff(x), C1)[0]
    >>> assert not checkodesol(f(x).diff(x), x)[0]
    >>> checkodesol(f(x).diff(x, 2), x**2)
    (False, 2)

    i    i   s0   must pass func arg to checkodesol for this case.s/   func must be a function of one variable, not %sR°   t   solve_for_funcRâ  RÂ  i   iÿÿÿÿR”   s   Unable to test if s    is a solution to t   .N()   R¨   R    R!   RÐ   R[   R  R©   R   Rª   R   R   R«   RÌ   RÖ   Rý   R¼   t   checkodesolR  RÃ  R\   R  RV   R’   RÒ   R˜   RP   R   RQ   R   R   RÑ   t   boolR'   R   RB  Rš  R$   RÕ   RR   R   R¤   (   R½   Rä   R”   R°   Rã  Ri  Rò   R  R¡   RÅ  R  RÞ   Ru  t   testnumRÇ   t   ode_diffRÇ  t   diffsolst   dst   sdfR  t   ode_or_boolR   t   _funcR–   (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyRå   	  sÆ    :7%8""
	
K""
""	%
(c         C  sú   t  |  ƒ rL x- |  D]% } t | | d | ƒt k r t Sq Wt t |  ƒ ƒ S|  j t ƒ r_ t S|  j | k r |  j j | ƒ s£ |  j | k r§ |  j j | ƒ r§ d S| rê y" t	 |  | ƒ } | sÎ t
 ‚ n  Wn t
 k
 râ qê Xd Sn  t t |  ƒ ƒ S(   s=  
    Returns an extended integer representing how simple a solution to an ODE
    is.

    The following things are considered, in order from most simple to least:

    - ``sol`` is solved for ``func``.
    - ``sol`` is not solved for ``func``, but can be if passed to solve (e.g.,
      a solution returned by ``dsolve(ode, func, simplify=False``).
    - If ``sol`` is not solved for ``func``, then base the result on the
      length of ``sol``, as computed by ``len(str(sol))``.
    - If ``sol`` has any unevaluated :py:class:`~sympy.integrals.Integral`\s,
      this will automatically be considered less simple than any of the above.

    This function returns an integer such that if solution A is simpler than
    solution B by above metric, then ``ode_sol_simplicity(sola, func) <
    ode_sol_simplicity(solb, func)``.

    Currently, the following are the numbers returned, but if the heuristic is
    ever improved, this may change.  Only the ordering is guaranteed.

    +----------------------------------------------+-------------------+
    | Simplicity                                   | Return            |
    +==============================================+===================+
    | ``sol`` solved for ``func``                  | ``-2``            |
    +----------------------------------------------+-------------------+
    | ``sol`` not solved for ``func`` but can be   | ``-1``            |
    +----------------------------------------------+-------------------+
    | ``sol`` is not solved nor solvable for       | ``len(str(sol))`` |
    | ``func``                                     |                   |
    +----------------------------------------------+-------------------+
    | ``sol`` contains an                          | ``oo``            |
    | :py:class:`~sympy.integrals.Integral`        |                   |
    +----------------------------------------------+-------------------+

    ``oo`` here means the SymPy infinity, which should compare greater than
    any integer.

    If you already know :py:meth:`~sympy.solvers.solvers.solve` cannot solve
    ``sol``, you can use ``trysolving=False`` to skip that step, which is the
    only potentially slow step.  For example,
    :py:meth:`~sympy.solvers.ode.dsolve` with the ``simplify=False`` flag
    should do this.

    If ``sol`` is a list of solutions, if the worst solution in the list
    returns ``oo`` it returns that, otherwise it returns ``len(str(sol))``,
    that is, the length of the string representation of the whole list.

    Examples
    ========

    This function is designed to be passed to ``min`` as the key argument,
    such as ``min(listofsolutions, key=lambda i: ode_sol_simplicity(i,
    f(x)))``.

    >>> from sympy import symbols, Function, Eq, tan, cos, sqrt, Integral
    >>> from sympy.solvers.ode import ode_sol_simplicity
    >>> x, C1, C2 = symbols('x, C1, C2')
    >>> f = Function('f')

    >>> ode_sol_simplicity(Eq(f(x), C1*x**2), f(x))
    -2
    >>> ode_sol_simplicity(Eq(x**2 + f(x), C1), f(x))
    -1
    >>> ode_sol_simplicity(Eq(f(x), C1*Integral(2*x, x)), f(x))
    oo
    >>> eq1 = Eq(f(x)/tan(f(x)/(2*x)), C1)
    >>> eq2 = Eq(f(x)/tan(f(x)/(2*x) + f(x)), C2)
    >>> [ode_sol_simplicity(eq, f(x)) for eq in [eq1, eq2]]
    [28, 35]
    >>> min([eq1, eq2], key=lambda i: ode_sol_simplicity(i, f(x)))
    Eq(f(x)/tan(f(x)/(2*x)), C1)

    RÅ   iþÿÿÿiÿÿÿÿ(   R   RÆ   R	   RÌ   R¤   R  R9   R  R  RV   RÑ   (   Rä   R”   RÅ   R¡   Rá   (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyRÆ   ó	  s&    Q""c           s5   t  ˆ ƒ ‰ g  ‰  ‡  ‡ ‡ f d †  ‰ ˆ |  ƒ ˆ  S(   Nc           s9  |  j  } | r. | j ˆ ƒ r. ˆ  j |  ƒ n|  j t k rR |  j d t ƒ }  n  |  j t t f k rÊ t	 |  j
 ‡ f d †  ƒ } t | t ƒ d k r|  j | t Œ  } | j sÇ ˆ  j | ƒ qÇ qnM t |  t ƒ r|  j  j ˆ ƒ rt d „  |  j Dƒ ƒ rˆ  j |  ƒ qn  x |  j
 D] } ˆ | ƒ q!Wd  S(   NRh  c           s   |  j  j ˆ  ƒ S(   N(   R¬   t   issubset(   R¡   (   R¢   (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyRÈ   z
  Rô   i   c         s  s!   |  ] } t  | ƒ d  k Vq d S(   i   N(   RÌ   (   R¥   RÇ   (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pys	   <genexpr>
  s    (   R¬   Rî  Rù   R”   R.   R   RÒ   R   R   RZ   Rý   RÌ   t	   is_numberR¨   R9   RÁ   t   limits(   RŽ   t	   expr_symsR—   RÇ   R¡   (   t   CesR¢   t   _recursive_walk(    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyRó  r
  s$    		(   Rª   (   RŽ   R¢   (    (   Rò  R¢   Ró  s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt   _get_constant_subexpressionso
  s
    
c   	        sœ  ‡ f d †  ˆ  Dƒ ‰ g  ˆ  D] } ˆ | d k r | ^ q ‰  ‡  ‡ f d †  ‰ ‡ ‡ f d †  ‰ t  ˆ t ƒ rŽg  ˆ j D] } ˆ | ƒ ^ q| \ } } ‡  f d †  } t  | t ƒ rÔ | ˆ  k rÔ | | } } n  | j t t f k rÛ| j t t f k rÛt t  | t ƒ r| g n | j | ƒ } t t  | t ƒ rC| g n | j | ƒ } xG t t	 g D]9 } x0 | | g D]" } | | k rrd g | | <qrqrWq_Wt | t	 Œ  t | t	 Œ  } t | t Œ  t | t Œ  } n¦ | j t
 t f k r| j t
 t f k rt t  | t ƒ r | g n | j | ƒ } t | k rt	 | k rWd g | t	 <n  t
 | t	 Œ  } | t
 | t Œ  } qn  t | | ƒ Sˆ ˆ ƒ Sd  S(   Nc           s"   i  |  ] } ˆ  j  | ƒ | “ q S(    (   t   count(   R¥   R¡   (   RŽ   (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pys
   <dictcomp>Š
  s   	 i    c           s  t  |  t ƒ rg  ˆ  D]= } |  j | ƒ ˆ | k r d |  j | d ƒ k r | ^ q } i  } xG | D]? } |  j | ƒ } | | k r” g  | | <n  | | j | ƒ qf Wxi | D]^ } t | | ƒ d k r° | | j d t ƒ x+ | | d D] } |  j | d ƒ }  qï Wq° q° Wn  |  S(   Ni    i   i   RÄ   (	   R¨   R   Rõ  R   Rù   RÌ   RÖ  R¤   RÕ   (   RŽ   R¡   t   xsR—   RÇ   R  (   R¢   t   cnts(    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt   _linear
  s    &$ c           sS   t  |  j ƒ d k rC |  j g  |  j D] } ˆ | ƒ ^ q% Œ  }  n  ˆ  |  ƒ }  |  S(   Ni    (   RÌ   Rý   R”   (   RŽ   R¡   (   Rø  Ró  (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyRó  ž
  s    .c           s   t  |  t ƒ p |  ˆ  k S(   N(   R¨   R   (   R¡   (   R¢   (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyRÈ   ¦
  Rô   i   (   R¨   R    Rý   R"   R”   R   RZ   R   RÒ   R’   R   R!   (	   RŽ   R¢   R¡   R  R  R¦   t   dlhst   drhst   hs(    (   R¢   Rø  Ró  R÷  RŽ   s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt   __remove_linear_redundancies‰
  s6    )(***!**c           sÝ  | } |  } t  |  | ƒ } x‰ | D] } t | j ƒ } | sC q" n  t g  | D]$ } |  j | ƒ | j | ƒ k ^ qM ƒ r" | j d t ƒ |  j | | d ƒ }  q" q" Wyá t |  ƒ \ } }	 | j	 ƒ  |	 d }	 x® | D]¦ ‰ t ˆ d j
 t ƒ ƒ ‰  t ˆ  ƒ d k rnˆ  d | k rnˆ  d |	 j
 t ƒ k rnt ‡  ‡ f d †  | Dƒ ƒ rn|	 j ˆ d ˆ  d ƒ }	 q× |	 j ˆ Œ  }	 q× W|	 }  Wn t k
 r›n Xt |  | ƒ }  d „  }
 |
 |  ƒ }  | |  k rÙt |  | ƒ S|  S(   sµ
  
    Simplifies an expression with arbitrary constants in it.

    This function is written specifically to work with
    :py:meth:`~sympy.solvers.ode.dsolve`, and is not intended for general use.

    Simplification is done by "absorbing" the arbitrary constants into other
    arbitrary constants, numbers, and symbols that they are not independent
    of.

    The symbols must all have the same name with numbers after it, for
    example, ``C1``, ``C2``, ``C3``.  The ``symbolname`` here would be
    '``C``', the ``startnumber`` would be 1, and the ``endnumber`` would be 3.
    If the arbitrary constants are independent of the variable ``x``, then the
    independent symbol would be ``x``.  There is no need to specify the
    dependent function, such as ``f(x)``, because it already has the
    independent symbol, ``x``, in it.

    Because terms are "absorbed" into arbitrary constants and because
    constants are renumbered after simplifying, the arbitrary constants in
    expr are not necessarily equal to the ones of the same name in the
    returned result.

    If two or more arbitrary constants are added, multiplied, or raised to the
    power of each other, they are first absorbed together into a single
    arbitrary constant.  Then the new constant is combined into other terms if
    necessary.

    Absorption of constants is done with limited assistance:

    1. terms of :py:class:`~sympy.core.add.Add`\s are collected to try join
       constants so `e^x (C_1 \cos(x) + C_2 \cos(x))` will simplify to `e^x
       C_1 \cos(x)`;

    2. powers with exponents that are :py:class:`~sympy.core.add.Add`\s are
       expanded so `e^{C_1 + x}` will be simplified to `C_1 e^x`.

    Use :py:meth:`~sympy.solvers.ode.constant_renumber` to renumber constants
    after simplification or else arbitrary numbers on constants may appear,
    e.g. `C_1 + C_3 x`.

    In rare cases, a single constant can be "simplified" into two constants.
    Every differential equation solution should have as many arbitrary
    constants as the order of the differential equation.  The result here will
    be technically correct, but it may, for example, have `C_1` and `C_2` in
    an expression, when `C_1` is actually equal to `C_2`.  Use your discretion
    in such situations, and also take advantage of the ability to use hints in
    :py:meth:`~sympy.solvers.ode.dsolve`.

    Examples
    ========

    >>> from sympy import symbols
    >>> from sympy.solvers.ode import constantsimp
    >>> C1, C2, C3, x, y = symbols('C1, C2, C3, x, y')
    >>> constantsimp(2*C1*x, {C1, C2, C3})
    C1*x
    >>> constantsimp(C1 + 2 + x, {C1, C2, C3})
    C1 + x
    >>> constantsimp(C1*C2 + 2 + C2 + C3*x, {C1, C2, C3})
    C1 + C3*x

    RÄ   i    i   c         3  s+   |  ]! } | ˆ k r ˆ  d  | k Vq d S(   i    N(    (   R¥   t   ex(   t   csRò   (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pys	   <genexpr>  s    c         S  s¡   t  |  d t d t d t ƒ} | j r t } t } xg | j D]Y } t | t ƒ r[ t } n% | j r€ t d „  | j Dƒ ƒ } n  | r= | r= |  } Pq= q= Wn  | S(   Nt   clearRŒ   R   c         s  s4   |  ]* } t  j | ƒ D] } t | t ƒ Vq q d  S(   N(   R   R™  R¨   R.   (   R¥   RÞ   R…  (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pys	   <genexpr>/  s    (	   RB   R’   RÒ   R7  Rý   R¨   R.   R=  RG  (   RŽ   t   new_exprt   infact   asfact   m(    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt   _conditional_term_factoring$  s    			(   Rô  R±   R¬   RÁ   Rõ  RÖ  R¤   RÕ   RS   R×  R   R"   RÌ   RG  RØ  Rü  RÔ  (   RŽ   Râ   R¢   t	   orig_exprt   constant_subexprst   xet   xesR  t   commonst   rexprR  (    (   Rþ  Rò   s0   lib/python2.7/site-packages/sympy/solvers/ode.pyRÔ  ¾
  s<    G7

" 
	c           s¾  t  |  ƒ t t t f k rP g  |  D] } t | ˆ | ƒ ^ q" } t  |  ƒ | ƒ Sˆ d k	 r~ t ˆ ƒ ‰ t |  j ˆ ƒ ‰ n= t ƒ  ‰ d „  } g  |  j D] } | | j ƒ rš | ^ qš ‰ | d k rå t d d d d d ˆ ƒ } n ‡ f d †  | Dƒ } d a	 t
 ˆ ƒ } d g | d ‰ g  ˆ D] }	 |	 t j f ^ q%‰  ‡  f d	 †  ‰ ‡ ‡ ‡ ‡ f d
 †  ‰ ˆ |  ƒ }  g  ˆ D] }
 |
 ˆ k rz|
 ^ qz‰ |  j t ˆ d | ƒ d t ƒ}  |  S(   sÚ  
    Renumber arbitrary constants in ``expr`` to use the symbol names as given
    in ``newconstants``. In the process, this reorders expression terms in a
    standard way.

    If ``newconstants`` is not provided then the new constant names will be
    ``C1``, ``C2`` etc. Otherwise ``newconstants`` should be an iterable
    giving the new symbols to use for the constants in order.

    The ``variables`` argument is a list of non-constant symbols. All other
    free symbols found in ``expr`` are assumed to be constants and will be
    renumbered. If ``variables`` is not given then any numbered symbol
    beginning with ``C`` (e.g. ``C1``) is assumed to be a constant.

    Symbols are renumbered based on ``.sort_key()``, so they should be
    numbered roughly in the order that they appear in the final, printed
    expression.  Note that this ordering is based in part on hashes, so it can
    produce different results on different machines.

    The structure of this function is very similar to that of
    :py:meth:`~sympy.solvers.ode.constantsimp`.

    Examples
    ========

    >>> from sympy import symbols, Eq, pprint
    >>> from sympy.solvers.ode import constant_renumber
    >>> x, C1, C2, C3 = symbols('x,C1:4')
    >>> expr = C3 + C2*x + C1*x**2
    >>> expr
    C1*x**2  + C2*x + C3
    >>> constant_renumber(expr)
    C1 + C2*x + C3*x**2

    The ``variables`` argument specifies which are constants so that the
    other symbols will not be renumbered:

    >>> constant_renumber(expr, [C1, x])
    C1*x**2  + C2 + C3*x

    The ``newconstants`` argument is used to specify what symbols to use when
    replacing the constants:

    >>> constant_renumber(expr, [x], newconstants=symbols('E1:4'))
    E1 + E2*x + E3*x**2

    c         S  s   |  j  d ƒ o |  d j ƒ  S(   NR™   i   (   RÒ  t   isdigit(   Rò   (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyRÈ   y  Rô   Rž   i   RŸ   R™   R§   c         3  s!   |  ] } | ˆ  k r | Vq d  S(   N(    (   R¥   t   sym(   R   (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pys	   <genexpr>€  s    i   c           s   t  |  j ˆ  ƒ ƒ S(   N(   RY   RÕ   (   RT  (   t   C_1(    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyRÈ   ‹  Rô   c           s:  t  |  t ƒ r. t ˆ  |  j ƒ ˆ  |  j ƒ ƒ St |  ƒ t t t f k rg |  j	 rg |  j
 ˆ Œ  rg |  S|  j rt |  S|  ˆ k r§ |  ˆ k r£ |  ˆ t <t d 7a n  |  S|  j	 sÈ |  j sÈ t  |  t ƒ rñ |  j g  |  j D] } ˆ  | ƒ ^ qØ Œ  St |  j ƒ } | j d ˆ ƒ |  j g  | D] } ˆ  | ƒ ^ qŒ  Sd S(   s‘   
        We need to have an internal recursive function so that
        newstartnumber maintains its values throughout recursive calls.

        i   RÄ   N(   R¨   R    R!   R  R  R¼   R   R   R   t   is_FunctionR  t   is_Piecewiset   newstartnumberR8  R   R”   Rý   R±   RÖ  (   RŽ   RÇ   t
   sortedargs(   t   _constant_renumbert   constants_foundt   constantsymbolst   sort_key(    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyR    s(    	%	
!#t   simultaneousN(   R¼   Rª   R±   Rœ   RÛ  RÐ   R¬   t   nameRX   R  RÌ   R   t   OneRÕ   t   zipRÒ   (   RŽ   R   t   newconstantsR  t
   renumberedt
   isconstantR  t   iter_constantst	   endnumbert   ciR  (    (   R  R  R  R  R  R   s0   lib/python2.7/site-packages/sympy/solvers/ode.pyRÛ  >  s,    0%		+"!%"c         C  s¼   | j  d } | j } | d k rF |  j ƒ  j t | | ƒ ƒ } b nr | d k r t t |  j t | | ƒ ƒ |  j ƒ } b n9 | d k r” |  } n$ | j	 d ƒ s² |  j ƒ  } n |  } | S(   sƒ   
    Converts a solution with Integrals in it into an actual solution.

    For most hints, this simply runs ``expr.doit()``.

    i    R`   Rx   Rl   Rï   (
   Rý   R”   R‘   RÕ   R  R!   R   R  R  Rö   (   RŽ   R”   R¹   RÇ   R¦   Rä   (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyRø   ¸  s    	'	c         C  s“   | j  d } | j } | } | | d } | | d } | d a t |  d d ƒ}	 t | | ƒ t | t | | ƒ j t ƒ t ƒ }
 t |
 |	 ƒ S(   sõ  
    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

    i    R  R—   R  R   i   (   Rý   R”   R  R£   R9   R   R!   (   R“   R”   R°   RÝ   RÇ   R¦   Rú   R  R—   R  Rä   (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt   ode_1st_exactÔ  s    8	
2c           s‘   t  |  ˆ  | | ƒ } t |  ˆ  | | ƒ } | j d t ƒ ‰ ˆ ro t |  | ˆ  d ƒ } t |  | ˆ  d ƒ } n  t | | g d ‡  ‡ f d †  ƒS(   s*  
    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_sol_simplicity`.

    See the
    :py:meth:`~sympy.solvers.ode.ode_1st_homogeneous_coeff_subs_indep_div_dep`
    and
    :py:meth:`~sympy.solvers.ode.ode_1st_homogeneous_coeff_subs_dep_div_indep`
    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

    RP   Re   Rf   RÄ   c           s   t  |  ˆ  d ˆ ƒS(   NRÅ   (   RÆ   (   RÇ   (   R”   RP   (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyRÈ   P  s   (   t,   ode_1st_homogeneous_coeff_subs_indep_div_dept,   ode_1st_homogeneous_coeff_subs_dep_div_indepRÚ   RÒ   R÷   RÙ   (   R“   R”   R°   RÝ   t   sol1R  (    (   R”   RP   s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt   ode_1st_homogeneous_coeff_best  s    ,c         C  sE  | j  d } | j } t d ƒ } t d ƒ } | } t |  d d ƒ}	 | j d d ƒ }
 | j d d ƒ } t | | d | | d	 | | | d j i d | 6| | d
 6ƒ | d | | ƒ | f ƒ } t t	 t
 | ƒ | t
 |	 ƒ ƒ d t ƒ} | j | | ƒ | ƒ j | | | f | | |
 f | | | ƒ f f ƒ } | S(   st  
    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
    :py:meth:`~sympy.solvers.ode.ode_1st_homogeneous_coeff_best` and
    :py:meth:`~sympy.solvers.ode.ode_1st_homogeneous_coeff_subs_indep_div_dep`.

    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

    i    R!  R&  R   i   R+  R,  R  R—   R  RÂ  N(   Rý   R”   R$   R£   RÚ   R9   RÕ   RÐ   RM   R!   R0   RÒ   (   R“   R”   R°   RÝ   RÇ   R¦   R!  R&  Rú   R  R+  R,  t   intRä   (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyR"  T  s    M	C+Jc         C  sQ  | j  d } | j } t d ƒ } t d ƒ } | } t |  d d ƒ}	 | j d d ƒ }
 | j d d ƒ } t t | | d | | d	 | | | d j i | | 6d | d
 6ƒ ƒ | d | | | ƒ f ƒ } t	 t
 t | | ƒ ƒ | t |	 ƒ ƒ d t ƒ} | j | | ƒ | ƒ j | | | f | | |
 f | | | ƒ f f ƒ } | S(   s.  
    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(u2)
                 |  ---------------- d(u2)
                 |  u2*g(u2) + h(u2)
                 |
                /
    <BLANKLINE>
    f(x) = C1*e

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

    See also the docstrings of
    :py:meth:`~sympy.solvers.ode.ode_1st_homogeneous_coeff_best` and
    :py:meth:`~sympy.solvers.ode.ode_1st_homogeneous_coeff_subs_dep_div_indep`.

    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

    i    R!  R'  R   i   R+  R,  R—   R  R  RÂ  N(   Rý   R”   R$   R£   RÚ   R9   RP   RÕ   RÐ   RM   R!   R0   RÒ   (   R“   R”   R°   RÝ   RÇ   R¦   R!  R'  Rú   R  R+  R,  R%  Rä   (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyR!  ±  s    P	F1Jc         G  s  | s t  d ƒ ‚ n  t | ƒ } t |  ƒ }  |  j t t ƒ rC d S|  j s^ |  j s^ |  j	 re t
 j St d d d t ƒ } t ƒ  } xŠ g  | D] } t | d ƒ r | ^ q D]` } t | j ƒ } | j | ƒ rÔ d St | ƒ } |  j | | ƒ }  | j | ƒ | j | ƒ q¬ W| j | ƒ |  j | @s.d St |  t ƒ rjt |  j d t | ƒ Œ d k rcd St
 j St d d t ƒ}	 t |  j g  | D] } | |	 | f ^ qŒƒ |	 g d	 t ƒ|	 }
 |
 t
 j k rÔt
 j S|
 j |	 d
 t ƒ\ } } | j  ƒ  \ } } | |	 k r| Sd S(   s  
    Returns the order `n` if `g` is homogeneous and ``None`` if it is not
    homogeneous.

    Determines if a function is homogeneous and if so of what order.  A
    function `f(x, y, \cdots)` is homogeneous of order `n` if `f(t x, t y,
    \cdots) = t^n f(x, y, \cdots)`.

    If the function is of two variables, `F(x, y)`, then `f` being homogeneous
    of any order is equivalent to being able to rewrite `F(x, y)` as `G(x/y)`
    or `H(y/x)`.  This fact is used to solve 1st order ordinary differential
    equations whose coefficients are homogeneous of the same order (see the
    docstrings of
    :py:meth:`~solvers.ode.ode_1st_homogeneous_coeff_subs_dep_div_indep` and
    :py:meth:`~solvers.ode.ode_1st_homogeneous_coeff_subs_indep_div_dep`).

    Symbols can be functions, but every argument of the function must be a
    symbol, and the arguments of the function that appear in the expression
    must match those given in the list of symbols.  If a declared function
    appears with different arguments than given in the list of symbols,
    ``None`` is returned.

    Examples
    ========

    >>> from sympy import Function, homogeneous_order, sqrt
    >>> from sympy.abc import x, y
    >>> f = Function('f')
    >>> homogeneous_order(f(x), f(x)) is None
    True
    >>> homogeneous_order(f(x,y), f(y, x), x, y) is None
    True
    >>> homogeneous_order(f(x), f(x), x)
    1
    >>> homogeneous_order(x**2*f(x)/sqrt(x**2+f(x)**2), x, f(x))
    2
    >>> homogeneous_order(x**2+f(x), x, f(x)) is None
    True

    s)   homogeneous_order: no symbols were given.RŸ   R—   R¯  R  i    RÞ   t   positiveRÂ   R0  N(!   R©   Rª   R&   R  RJ   R   RÐ   t	   is_Numbert   is_NumberSymbolRï  R   RB  RX   R$   t   getattrRý   Rñ   R›   RÕ   t   removeR  RÛ   R¬   R¨   R   R@  Rœ   RÒ   RO   R  R>  R’   R9  (   R“   R%   t   symsett   dumt   newsymsRv  R¡   t   iargst   dummyvarRÞ   Ru  R—   R  R  (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyR@    sD    *				/*Bc   
      C  s¬   | j  d } | j } | } t |  d d ƒ} t t | | d | | d | ƒ ƒ } t | | | d | | d | ƒ }	 | j d | | ƒ ƒ } t | |	 | | ƒ S(   sp  
    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
    - M. Tenenbaum & H. Pollard, "Ordinary Differential Equations",
      Dover 1963, pp. 92

    # indirect doctest

    i    R   i   R  R  R  R!  (   Rý   R”   R£   R.   R9   RÚ   R!   (
   R“   R”   R°   RÝ   RÇ   R¦   Rú   R  RÞ   t   tt(    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt   ode_1st_linearo  s    3	)(c   
      C  sÍ   | j  d } | j } | } t |  d d ƒ} t d | | d t | | d | | d | ƒ ƒ } | | d d t | | | d | | d | ƒ }	 t | | ƒ |	 | | d d | | d ƒ S(   sr  
    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
    :py:meth:`~sympy.solvers.ode.ode_1st_linear`).  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')) #doctest: +SKIP
                                                                                       1
                                                                                      ----
                                                                                     1 - n
               //                /                            \                     \
               ||               |                             |                     |
               ||               |                  /          |             /       |
               ||               |                 |           |            |        |
               ||               |        (1 - n)* | P(x) dx   |  (-1 + n)* | P(x) dx|
               ||               |                 |           |            |        |
               ||               |                /            |           /         |
        f(x) = ||C1 + (-1 + n)* | -Q(x)*e                   dx|*e                   |
               ||               |                             |                     |
               \\               /                            /                     /


    Note that the equation is separable when `n = 1` (see the docstring of
    :py:meth:`~sympy.solvers.ode.ode_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) = -------------------
             /     log(x)   1\
           x*|C1 + ------ + -|
             \       x      x/

    References
    ==========

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

    # indirect doctest

    i    R   i   RÀ   R  R  R  (   Rý   R”   R£   R.   R9   R!   (
   R“   R”   R°   RÝ   RÇ   R¦   Rú   R  RÞ   R0  (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt   ode_Bernoulli¬  s    L	97c         C  sÈ   | j  d } | j } | } g  d j ƒ  D] } | | | ^ q) \ } }	 }
 } t |  d d ƒ} t d | |	 | |
 d ƒ } t | | ƒ | |
 | t | d | t | ƒ | ƒ d |	 | ƒ S(   s…  
    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, y, a, b, c, d
    >>> from sympy.solvers.ode import dsolve, checkodesol
    >>> from sympy import 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)
    >>> 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
    ==========

    1. http://www.maplesoft.com/support/help/Maple/view.aspx?path=odeadvisor/Riccati
    2. http://eqworld.ipmnet.ru/en/solutions/ode/ode0106.pdf -
       http://eqworld.ipmnet.ru/en/solutions/ode/ode0123.pdf
    i    s   a2 b2 c2 d2R   i   i   i   (   Rý   R”   R›  R£   R4   R!   R3   R0   (   R“   R”   R°   RÝ   RÇ   R¦   Rú   Rò   R  R  R  R  R  t   mu(    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt   ode_Riccati_special_minus2  s    (	3 c         C  s«   | j  d } | j } | } | d } t |  d d ƒ\ } }	 t t t | d | ƒ ƒ | d | | ƒ f ƒ }
 t |
 | t t t | d | ƒ ƒ | ƒ |	 d ƒ } | S(   sÛ  
    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
    - http://www.maplesoft.com/support/help/Maple/view.aspx?path=odeadvisor/Liouville

    # indirect doctest

    i    R  R   i   R1  R2  N(   Rý   R”   R£   R9   R.   RÐ   R!   (   R“   R”   R°   RÝ   RÇ   R¦   Rú   R  R  t   C2R%  Rä   (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt   ode_Liouville2  s    >	
18c   2      C  s„  | j  d } | j } t |  d d ƒ\ } } t d d t ƒ} t d ƒ }	 t d d | g ƒ}
 | j d	 ƒ } | j d
 d ƒ } | | d } | | d } | | d } i  } t d ƒ } | | ƒ | f | | | ƒ | f | | d | | ƒ | f g } xft | ƒ D]X\ } } | d rt	 t
 | d | | | | j | | | ƒ ƒ ƒ } | j ro| j  } n	 | g } xë | D]à } | j |	 | |
 ƒ } | d | |	 } | |
 j så| j | | | |
 j | ƒ d ƒ } n  | |
 j | | ƒ } | rOx[ t t | ƒ ƒ D]4 } | j | | ƒ s9| | | <q| d | | <PqWqt d ƒ | | <qWqqWt d ƒ } | j ƒ  } | j ƒ  } t | Œ  } t | ƒ rt | ƒ }  xZ | D]O } | | }! |! |  k r¹x0 t |! |  ƒ D] } | | j | |! ƒ 7} qåWq¹q¹Wn  i  }" | rœ| j t ƒ }# t |# ƒ d k rOd |" |# j ƒ  <qœt |# d d „  ƒ}$ t | |$ ƒ }% t |% t ƒ r|% d }% n  |% |" |$ <n  | j t ƒ }# t |# d d „  ƒ}$ t |# d d „  ƒ}& |& j  d j rîd }' n |& j  d j | ƒ d }' |$ }( t | |$ ƒ }) t |) t ƒ r:|) d }) n  t g  |" j ƒ  D] }* |* rJ|* ^ qJƒ }+ xb t |+ | d ƒ D]M }, |) j | |' ƒ }- |( j | |' ƒ }. |- j |" ƒ }/ |/ |" |. <|' d 7}' qyW| | | | }0 xi |" D]a } |" | rã| j  d }1 |0 |" | j | d ƒ | f | d ƒ | f g ƒ | | |1 7}0 qãqãWt  t! |0 ƒ | | g ƒ t" | | ƒ }0 t# | | ƒ |0 ƒ S(   s  
    Gives a power series solution to a second order homogeneous differential
    equation with polynomial coefficients at an ordinary point. A homogenous
    differential equation is of the form

    .. math :: P(x)\frac{d^2y}{dx^2} + Q(x)\frac{dy}{dx} + R(x) = 0

    For simplicity it is assumed that `P(x)`, `Q(x)` and `R(x)` are polynomials,
    it is sufficient that `\frac{Q(x)}{P(x)}` and `\frac{R(x)}{P(x)}` exists at
    `x_{0}`. A recurrence relation is obtained by substituting `y` as `\sum_{n=0}^\infty a_{n}x^{n}`,
    in the differential equation, and equating the nth term. Using this relation
    various terms can be generated.


    Examples
    ========

    >>> from sympy import dsolve, Function, pprint
    >>> from sympy.abc import x, y
    >>> f = Function("f")
    >>> eq = f(x).diff(x, 2) + f(x)
    >>> pprint(dsolve(eq, hint='2nd_power_series_ordinary'))
              / 4    2    \        /     2\
              |x    x     |        |    x |    / 6\
    f(x) = C2*|-- - -- + 1| + C1*x*|1 - --| + O\x /
              \24   2     /        \    6 /


    References
    ==========
    - http://tutorial.math.lamar.edu/Classes/DE/SeriesSolutions.aspx
    - George E. Simmons, "Differential Equations with Applications and
      Historical Notes", p.p 176 - 184

    i    R   i   RÀ   t   integerRò   R  R§   R¿   R#  i   R  R  R  Rú   i   RÄ   c         S  s   |  j  d S(   Ni    (   Rý   (   RÇ   (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyRÈ   ã  Rô   c         S  s   |  j  d S(   Ni    (   Rý   (   RÇ   (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyRÈ   ë  Rô   c         S  s   |  j  d S(   Ni    (   Rý   (   RÇ   (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyRÈ   ì  Rô   i   ($   Rý   R”   R£   R$   RÒ   R#   RÚ   R   R~  RN   R   RÕ   R=  RÝ   t	   is_SymbolR>  RÃ  R   R   RÏ   t   keysR   RG  t   maxR   R   RÌ   RÖ   RV   R¨   R±   RÙ   RL   R   RJ   R!   (2   R“   R”   R°   RÝ   RÇ   R¦   t   C0R  RÀ   Rò   R  R¿   R#  R.  R3  Rú   t
   seriesdictt   recurrt	   coefflistt   indexRÍ   R¤  t   addargsRT  t   powmt   termt   startindR¡   t   teqt   suminitt   rkeyst   reqt   maxvalR  t	   finaldictt   fargst   maxfRä   t   minft	   startiterR  R  RÞ   t   tcounterRi  RX  t   nlhst   nrhsRK   t   fact(    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt   ode_2nd_power_series_ordinaryz  sž    $	C
6		*
$	+

1)c         C  s	  | j  d } | j } t |  d d ƒ\ } } t d ƒ } t d ƒ }	 t d ƒ }
 t d d | g ƒ} | j d	 ƒ } | j d
 d ƒ } | d } | d } g  } x¤ | | g D]– } | j | ƒ sÔ | j | ƒ q¯ t | d d d	 | ƒ} t	 | t
 ƒ r| j t d ƒ ƒ q¯ x1 | j  D]& } | j | ƒ s| j | ƒ PqqWq¯ W| \ } } t |	 |	 d |	 | | |	 ƒ } | rt	 | t ƒ rt g  | D] } | j ^ q—ƒ ri  } i  } t | ƒ d k r9| j ƒ  } } | | d d k r
t | | ƒ t
 | ƒ ƒ St | | d | | | | | | | | ƒ	 } nÊ | d } | d } | | k  ri| | } } n  t | | d | | | | | | | | ƒ	 } | | j sÑt | | d | | | | | | | | ƒ	 } n2 t | | d | | | | | | | | d | ƒ	} | r| } x; | D]3 } t | j d ƒ } | | | | | | 7} qW| | | | } t d ƒ } | rÎx; | D]3 } t | j d ƒ } | | | | | | 7} qxW| | 7} | | | | } n  t | | ƒ t | | | | g ƒ t
 | | ƒ ƒ Sn  d S(   sK	  
    Gives a power series solution to a second order homogeneous differential
    equation with polynomial coefficients at a regular point. A second order
    homogenous differential equation is of the form

    .. math :: P(x)\frac{d^2y}{dx^2} + Q(x)\frac{dy}{dx} + R(x) = 0

    A point is said to regular singular at `x0` if `x - x0\frac{Q(x)}{P(x)}`
    and `(x - x0)^{2}\frac{R(x)}{P(x)}` are analytic at `x0`. For simplicity
    `P(x)`, `Q(x)` and `R(x)` are assumed to be polynomials. The algorithm for
    finding the power series solutions is:

    1.  Try expressing `(x - x0)P(x)` and `((x - x0)^{2})Q(x)` as power series
        solutions about x0. Find `p0` and `q0` which are the constants of the
        power series expansions.
    2.  Solve the indicial equation `f(m) = m(m - 1) + m*p0 + q0`, to obtain the
        roots `m1` and `m2` of the indicial equation.
    3.  If `m1 - m2` is a non integer there exists two series solutions. If
        `m1 = m2`, there exists only one solution. If `m1 - m2` is an integer,
        then the existence of one solution is confirmed. The other solution may
        or may not exist.

    The power series solution is of the form `x^{m}\sum_{n=0}^\infty a_{n}x^{n}`. The
    coefficients are determined by the following recurrence relation.
    `a_{n} = -\frac{\sum_{k=0}^{n-1} q_{n-k} + (m + k)p_{n-k}}{f(m + n)}`. For the case
    in which `m1 - m2` is an integer, it can be seen from the recurrence relation
    that for the lower root `m`, when `n` equals the difference of both the
    roots, the denominator becomes zero. So if the numerator is not equal to zero,
    a second series solution exists.


    Examples
    ========

    >>> from sympy import dsolve, Function, pprint
    >>> from sympy.abc import x, y
    >>> f = Function("f")
    >>> eq = x*(f(x).diff(x, 2)) + 2*(f(x).diff(x)) + x*f(x)
    >>> pprint(dsolve(eq))
                                  /    6    4    2    \
                                  |   x    x    x     |
              /  4    2    \   C1*|- --- + -- - -- + 1|
              | x    x     |      \  720   24   2     /    / 6\
    f(x) = C2*|--- - -- + 1| + ------------------------ + O\x /
              \120   6     /              x


    References
    ==========
    - George E. Simmons, "Differential Equations with Applications and
      Historical Notes", p.p 176 - 184

    i    R   i   RÀ   R  Rò   R  R§   R¿   R#  i   R.  R3  i   RX  N(   Rý   R”   R£   R$   R#   RÚ   R  Rù   RK   R¨   RJ   R   RV   R±   RÁ   t   is_realRÌ   RÖ   R!   t
   _frobeniust
   is_integerR%  R  RL   (   R“   R”   R°   RÝ   RÇ   R¦   R;  R  RÀ   R  Rò   R  R¿   R#  R.  R3  t   indicialRB  RT  t   p0t   q0t   sollistRä   t   serdict1t   serdict2R$  R%  t   finalseries1RÄ   R/  t   finalseries2(    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt   ode_2nd_power_series_regular  sp    6	

#/

,/2
c
         C  s®  t  |  ƒ }  |	 }
 t d ƒ } t d d d ƒ} g  t |  d ƒ D] } t | ƒ ^ qA } t d ƒ } g  } x| | g D]ø } | j | ƒ rß t | | ƒ j ƒ  |  k rß | rÇ | j	 | | | ƒ } n  t | | ƒ j
 ƒ  } nD t | d | d |  d ƒ} t t t | j ƒ ƒ d	  | ƒ j
 ƒ  } x= t |  d ƒ D]+ } | f | k r4t d ƒ | | f <q4q4W| j | ƒ qx W| d } | d } | | d | | | } i  } xÿ t d |  d ƒ D]ê } | | | | f | | f } xa t d | ƒ D]P } t d t | ƒ ƒ } | | | | | | | | f | | | f 7} qòW|
 d
 k	 rƒ| |
 | k rƒ| rlt St d ƒ | | | <q¼| | j	 | | | ƒ | | | <q¼W| S(   s\   
    Returns a dict with keys as coefficients and values as their values in terms of C0
    R—   R™   Rž   i    i   R;  RÇ   RÀ   iÿÿÿÿN(   R%  R$   RX   R   R›   R"   RC  R?   RH   RÕ   t   as_dictRK   R±   R
   Rý   R   Rù   R¤   RÐ   R’   (   RÀ   R  RW  RX  R.  R3  R¿   RÇ   R  RX  R%  R—   t   numsymsR¡   R;  t   serlistt   sert   dict_t   tseriest   pseriest   qseriesRV  t   frobdictR   Rv  R  (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyRT  ‰  sB    )*(

 8'c   
      C  s  t  | j ƒ d k s t ‚ | j d } g  |  j t ƒ D]7 } | j | k r8 t  | j ƒ d k r8 | j d ^ q8 } g  | D] \ } } | | k r| | ^ q| } t  | ƒ d k  r¶ d St | ƒ } t ƒ  }	 |  j	 | j
 | | ƒ |	 ƒ j | ƒ rö d Si | d 6S(   sÓ   
    Matches any differential equation that can be rewritten with a smaller
    order. Only derivatives of ``func`` alone, wrt a single variable,
    are considered, and only in them should ``func`` appear.
    i   i    i   NRÀ   (   RÌ   Rý   RÙ  R   R   RŽ   R   RÙ   R$   RÕ   R   R  (
   R“   R”   RÇ   R—   t   vcR   R  t   ordst   smallestt   D(    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyRD  ¾  s    7+	'c         C  sH  | j  d } | j } | d } g  |  j t ƒ D] } | j ^ q0 } x2 t ry t ƒ  j }	 |	 | k rH t |	 ƒ }
 PqH qH W| | ƒ j | | ƒ } |  j	 | |
 | ƒ ƒ } t
 | |
 | ƒ ƒ } t | t ƒ sÚ | g } n  g  } xB | D]: } t
 | j	 |
 | ƒ | ƒ | | ƒ ƒ } | j | ƒ qç Wt | ƒ d k rD| d } n  | S(   s8  
    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))
    >>> 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))

    i    RÀ   i   (   Rý   R”   R   R   R  RÒ   R$   R   R   RÕ   Rî   R¨   R±   Rù   RÌ   (   R“   R”   R°   RÝ   RÇ   R¦   RÀ   R  t   namesR  R1  Rt  t   geqt   gsolt   fsolt   gsolit   fsoli(    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt   ode_nth_order_reducibleÓ  s*    	
%	'c           s÷   t  |  ƒ ‰ ‡ f d †  ‰  d t f ‡  ‡ f d †  ƒ  Y‰ ‡ f d †  } ‡ f d †  } | j d ‰ | |  ˆ ƒ } y t | | ƒ } Wn t k
 r  g  } n Xg  | D] } | | ˆ ƒ ^ q¨ } g  | D] } t | | ƒ ^ qÊ } i ˆ d 6| d 6S(	   s  
    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             s   t  ˆ  d  ƒ S(   N(   R›   RÐ   (    (   Râ   (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyRÈ     Rô   t   diffxc             s   e  Z ‡  ‡ f d  †  Z RS(   c           s   ‡  ‡ f d †  S(   Nc           s   t  |  ˆ ƒ ˆ  ƒ  S(   N(   R9   (   RŽ   (   t   constantt   var(    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyRÈ     Rô   (    (   t   self(   Rt  Ru  (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt   inverse  s    (   t   __name__t
   __module__Rw  (    (   Rt  Ru  (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyRs    s   c           s"   ‡ ‡  f d †  } |  j  t | ƒ S(   Nc            sw   |  d |  d } } | } xU | D]M \ } } x> t  | ƒ D]0 } | ˆ k r\ ˆ  | ƒ } q; t | | ƒ } q; Wq" W| S(   Ni    i   (   R   R   (   Rý   t	   differandt   diffst	   toreplaceR   RÀ   Ri  (   Rs  Ru  (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt   expand_diffx  s    (   t   replaceR   (   R“   Ru  R}  (   Rs  (   Ru  s0   lib/python2.7/site-packages/sympy/solvers/ode.pyR~    s    
c           s   |  j  ˆ ‡  f d †  ƒ S(   Nc           s   t  |  ˆ  ƒ S(   N(   R   (   R  (   Ru  (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyRÈ   ,  Rô   (   R~  (   R“   Ru  (   Rs  (   Ru  s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt	   unreplace+  s    i    Ru  R4  (   Rš   R   Rý   RV   RÑ   R    (   R“   R”   R~  R  t   subs_eqnt   solnst   soln(    (   Rt  Râ   Rs  Ru  s0   lib/python2.7/site-packages/sympy/solvers/ode.pyRE    s    

""c         C  sK   | d } | d } t  |  | | | ƒ } t | ƒ d k rC | d S| Sd S(   s  
    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')
    ... # doctest: +NORMALIZE_WHITESPACE
    [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).

    # indirect doctest

    R4  Ru  i   i    N(   t)   _nth_algebraic_remove_redundant_solutionsRÌ   (   R“   R”   R°   RÝ   R  Ru  (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt   ode_nth_algebraic:  s    

c           s   ‡  ‡ ‡ f d †  } g  } x_ | D]W } xN | D]8 } | | | ƒ rI Pq0 | | | ƒ r0 | j  | ƒ q0 q0 W| j | ƒ q" W| S(   sÜ  
    Remove redundant solutions from the set of solutions returned by
    nth_algebraic.

    This function is needed because otherwise nth_algebraic can return
    redundant solutions where both algebraic solutions and integral
    solutions are found to the ODE. As an example consider:

        eq = Eq(f(x) * f(x).diff(x), 0)

    There are two ways to find solutions to eq. The first is the algebraic
    solution f(x)=0. The second is to solve the equation f(x).diff(x) = 0
    leading to the solution f(x) = C1. In this particular case we then see
    that the first solution is a special case of the second and we don't
    want to return it.

    This does not always happen for algebraic solutions though since if we
    have

        eq = Eq(f(x)*(1 + f(x).diff(x)), 0)

    then we get the algebraic solution f(x) = 0 and the integral solution
    f(x) = -x + C1 and in this case the two solutions are not equivalent wrt
    initial conditions so both should be returned.
    c           s   t  |  | ˆ  ˆ ˆ ƒ S(   N(   t!   _nth_algebraic_is_special_case_of(   t   soln1t   soln2(   R“   R°   Ru  (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt   is_special_case_ofy  s    (   R*  Rù   (   R“   R  R°   Ru  Rˆ  t   unique_solnsR†  R‡  (    (   R“   R°   Ru  s0   lib/python2.7/site-packages/sympy/solvers/ode.pyRƒ  _  s    c           sÈ  |  j  j | j  ƒ } | j  j | j  ƒ } t |  j | j t | ƒ ƒ } t | ƒ d k rg | h } n  x/ t | | ƒ D] \ } }	 |  j | |	 ƒ }  qw W|  j j ƒ  }
 | j j ƒ  } t |
 | ƒ g } xQ t	 d | ƒ D]@ } |
 j
 ˆ  ƒ }
 | j
 ˆ  ƒ } t |
 | ƒ } | j | ƒ qÙ Wt d „  | Dƒ ƒ r7t Sg  | D] } t | t ƒ s>| ^ q>} t | | ƒ } t | t ƒ r‰| g } n  x8 | D], } t ‡  f d †  | j ƒ  Dƒ ƒ st SqWt Sd S(   s‰   
    True if soln1 is found to be a special case of soln2 wrt some value of the
    constants that appear in soln2. False otherwise.
    i   c         s  s   |  ] } t  | t ƒ Vq d  S(   N(   R¨   R,   (   R¥   R“   (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pys	   <genexpr>®  s    c         3  s   |  ] } | j  ˆ  ƒ Vq d  S(   N(   R  (   R¥   R  (   Ru  (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pys	   <genexpr>»  s    N(   R¬   Rñ   R£   R  RÌ   R  RÕ   R‘   R!   R   R   Rù   RG  R’   R¨   R+   RV   RÂ   RÏ   RÒ   (   R†  R‡  R“   R°   Ru  t
   constants1t
   constants2t   constants1_newt   c_oldt   c_newR  R  t   eqnsRÀ   t   constant_solnst   constant_soln(    (   Ru  s0   lib/python2.7/site-packages/sympy/solvers/ode.pyR…  ˆ  s2    ("c   	      C  s  | j  d } | h } d „  t d | d ƒ Dƒ } xË t j |  ƒ D]º } | j | ƒ sk | d c | 7<qC | j | ƒ \ } } t | t ƒ rÍ t | j	 ƒ | k rÍ | j  d | k rÍ | | j
 c | 7<qC | | k rù | t | j  d ƒ c | 7<qC d SqC W| S(   sõ  
    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 import _nth_linear_match
    >>> f = Function('f')
    >>> _nth_linear_match(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), f(x), 3)
    {-1: x - sin(x), 0: -1, 1: cos(x) + 2, 2: x, 3: 1}
    >>> _nth_linear_match(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)), f(x), 3) == None
    True

    i    c         S  s   i  |  ] } t  j | “ q S(    (   R   RB  (   R¥   R¡   (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pys
   <dictcomp>à  s   	 iÿÿÿÿi   N(   Rý   R   R   R™  R  R>  R¨   R   Rª   R   t   derivative_countRÌ   RÐ   (	   R“   R”   R°   RÇ   t   one_xR#  R¡   R  R¦   (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyRF  Á  s    	 Rä   c      
   C  sî  g  a  | j d } | j } | } t j t d ƒ } }	 xd | j ƒ  D]V }
 t |
 t ƒ rE |
 d k rE | | |
 t	 | |	 | |
 ƒ | |	 j
 ƒ  7} qE qE Wt | |	 ƒ } g  t | j ƒ  ƒ D] } t | | ƒ ^ qÁ } t t |  d | j ƒ  d ƒƒ } | j ƒ  t t ƒ } x | D] } | | c d 7<qWt d ƒ } t } x`| j ƒ  D]R\ } } xCt | ƒ D]5}
 t | t ƒ rÎ| | | | j ƒ  7} | d k rµt d ƒ ‚ n  d | d f g t  a  qm| j r| | | ƒ |
 | | | j ƒ  7} |
 | d f g t  a  qmt | ƒ } t | ƒ } | | | ƒ |
 | | | j ƒ  t t | ƒ | | ƒ ƒ | j ƒ  t | | | ƒ ƒ 7} |
 | | f g t  a  qmWqTW| d k rÉt | | ƒ | ƒ S| d k rÞg  } xÌ t  D]Ä \ }
 } } | d k r| j  | | ƒ |
 | | ƒ qâ| | ƒ |
 | | t t | ƒ | | ƒ ƒ } | | k r™| | ƒ |
 | | t | | | ƒ ƒ } | j  | ƒ qâ| j  | ƒ qâW| d	 k rº| Si t | | ƒ | ƒ d 6| d	 6Sn t d
 ƒ ‚ d S(   sß
  
    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:class:`~sympy.polys.rootoftools.CRootOf` instance will be returned
    instead.

    >>> from sympy import Function, dsolve, Eq
    >>> 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

    i    RÇ   R   i   i   s   Value should be 1Rä   t   listbothR±   s    Unknown value for key "returns".N(!   RÕ  Rý   R”   R   RB  R$   R9  R¨   R   R   R   R?   R   RH   RA   R±   R£   R×  R   R%  R0   Rþ   R@   RÖ   R©   RS  R1   R/   R2   RÚ  R-   R!   Rù   (   R“   R”   R°   RÝ   t   returnsRÇ   R¦   Rú   t   chareqt   symbolR¡   R  t   chareqrootsRâ   t	   charrootst   rootRn  t   lnt   multiplicityRÜ  RÝ  t   gensolst   sin_formt   cos_form(    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt#   ode_nth_linear_euler_eq_homogeneousñ  sb    D	8."
	&##"2,$c         C  sí  | j  d } | j } | } t j t j t d ƒ } }  }	 xd | j ƒ  D]V }
 t |
 t ƒ rI |
 d k rI | | |
 t | |	 | |
 ƒ | |	 j	 ƒ  7} qI qI WxW t
 d t t | |	 ƒ ƒ d ƒ D]3 }
 |  | j |	 |
 ƒ t | | ƒ | |
 ƒ 7}  qÆ W| j |	 ƒ d r4|  | j |	 ƒ d | | ƒ 7}  n  t | d j | t | ƒ ƒ ƒ \ } } |  | j | ƒ 7}  t |  | | ƒ t |  | | ƒ ƒ ƒ } | d | d <t |  | | | ƒ j | t | ƒ ƒ j | t | ƒ ƒ | | ƒ ƒ j	 ƒ  S(   s/	  
    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)

    i    RÇ   i   iÿÿÿÿR6  (   Rý   R”   R   RB  R$   R9  R¨   R   R   R   R   RH   R?   RÍ   t   as_coeff_addRR   RÕ   R.   RF  R\   t7   ode_nth_linear_constant_coeff_undetermined_coefficientsR0   (   R“   R”   R°   RÝ   R•  RÇ   R¦   Rú   R–  R—  R¡   R  R1   (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt@   ode_nth_linear_euler_eq_nonhomogeneous_undetermined_coefficients~  s     .	 8)1$('c   
   	   C  sÁ   | j  d } | j } | } t |  | | | d d ƒ} | j | ƒ | d | t |  | | ƒ ƒ | d <t |  | | | ƒ }	 t | | ƒ | d j |	 j | d j | t |  | | ƒ ƒ ƒ S(   sa	  
    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 doesn't 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)

    i    R•  t   bothiÿÿÿÿRä   (   Rý   R”   R   RÛ   R\   t   _solve_variation_of_parametersR!   R  (
   R“   R”   R°   RÝ   R•  RÇ   R¦   Rú   t   gensolRä   (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt>   ode_nth_linear_euler_eq_nonhomogeneous_variation_of_parametersÃ  s    6	%c         C  s   t  |  | | | ƒ S(   s_  
    Solves an almost-linear differential equation.

    The general form of an almost linear differential equation is

    .. math:: f(x) g(y) y + k(x) l(y) + m(x) = 0
                \text{where} l'(y) = g(y)\text{.}

    This can be solved by substituting `l(y) = u(y)`.  Making the given
    substitution reduces it to a linear differential equation of the form `u'
    + P(x) u + Q(x) = 0`.

    The general solution is

        >>> from sympy import Function, dsolve, Eq, pprint
        >>> from sympy.abc import x, y, n
        >>> f, g, k, l = map(Function, ['f', 'g', 'k', 'l'])
        >>> genform = Eq(f(x)*(l(y).diff(y)) + k(x)*l(y) + g(x))
        >>> pprint(genform)
             d
        f(x)*--(l(y)) + g(x) + k(x)*l(y) = 0
             dy
        >>> pprint(dsolve(genform, hint = 'almost_linear'))
               /     //       y*k(x)                \\
               |     ||       ------                ||
               |     ||        f(x)                 ||  -y*k(x)
               |     ||-g(x)*e                      ||  --------
               |     ||--------------  for k(x) != 0||    f(x)
        l(y) = |C1 + |<     k(x)                    ||*e
               |     ||                             ||
               |     ||   -y*g(x)                   ||
               |     ||   --------       otherwise  ||
               |     ||     f(x)                    ||
               \     \\                             //


    See Also
    ========
    :meth:`sympy.solvers.ode.ode_1st_linear`

    Examples
    ========

    >>> from sympy import Function, Derivative, pprint
    >>> from sympy.solvers.ode import dsolve, classify_ode
    >>> 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

    References
    ==========

    - Joel Moses, "Symbolic Integration - The Stormy Decade", Communications
      of the ACM, Volume 14, Number 8, August 1971, pp. 558
    (   R1  (   R“   R”   R°   RÝ   (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt   ode_almost_linear  s    Cc           s  | j  ‰ | j d ‰ ‡ ‡ f d †  ‰  ‡  f d †  ‰ g  |  j t ƒ D]H } | j  ˆ k rG t | j ƒ d k rG | j d j rG | j d ^ qG p› |  h } ˆ | j ƒ  ƒ ‰ ˆ rt ‡ ‡ f d †  | Dƒ ƒ rˆ \ } } } } } }	 }
 | | | |	 |
 | |	 | | |
 f Sd S(   s÷  
    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
    >>> from sympy.abc import x
    >>> from sympy.solvers.ode import _linear_coeff_match
    >>> from sympy.functions.elementary.trigonometric import sin
    >>> f = Function('f')
    >>> _linear_coeff_match((
    ... (-25*f(x) - 8*x + 62)/(4*f(x) + 11*x - 11)), f(x))
    (1/9, 22/9)
    >>> _linear_coeff_match(
    ... sin((-5*f(x) - 8*x + 6)/(4*f(x) + x - 1)), f(x))
    (19/27, 2/27)
    >>> _linear_coeff_match(sin(f(x)/x), f(x))

    i    c           s¬   t  |  ƒ }  |  j ˆ ˆ  ˆ ƒ d t ƒd } | j s; d S|  j ˆ ƒ } | j sW d S|  j ˆ  ˆ ƒ ƒ } | j sy d S|  | ˆ | ˆ  ˆ ƒ | k r¨ | | | f Sd S(   s   
        Internal function of _linear_coeff_match
        that returns Rationals a, b, c
        if eq is a*x + b*f(x) + c, else None.
        R0  i    N(   R   R>  RÒ   t   is_RationalRÍ   (   R“   R  R  R  (   R¦   RÇ   (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt   abcm  s    "			"c   
        s­   |  j  ƒ  j ƒ  \ } } ˆ  | ƒ } | d k	 r© | \ } } } ˆ  | ƒ } | d k	 r© | \ } } }	 | | | | } | s„ |	 r¦ | r¦ | | | | | |	 | f Sq© n  d S(   s  
        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(   t   togetherRš  RÐ   (
   RT  RÀ   R—   R  R  R  R  R  R  R  (   Rª  (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyRÝ   €  s    i   c         3  s!   |  ] } ˆ | ƒ ˆ  k Vq d  S(   N(    (   R¥   t   mi(   R$  RÝ   (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pys	   <genexpr>•  s    N(   R”   Rý   R   R   RÌ   R  RÖ   RÁ   (   RŽ   R”   R…  R  R  R  R  R  R  R  RÏ  (    (   Rª  R¦   R$  RÝ   RÇ   s0   lib/python2.7/site-packages/sympy/solvers/ode.pyRA  I  s    "	%B%c         C  s   t  |  | | | ƒ S(   s²  
    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
    ========
    :meth:`sympy.solvers.ode.ode_1st_homogeneous_coeff_best`
    :meth:`sympy.solvers.ode.ode_1st_homogeneous_coeff_subs_indep_div_dep`
    :meth:`sympy.solvers.ode.ode_1st_homogeneous_coeff_subs_dep_div_indep`

    Examples
    ========

    >>> from sympy import Function, Derivative, pprint
    >>> from sympy.solvers.ode import dsolve, classify_ode
    >>> 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
    (   R$  (   R“   R”   R°   RÝ   (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt   ode_linear_coefficients™  s    4c         C  sÓ   | j  d } | j } t d ƒ } | d j | d | ƒ } d | | d | } i d | 6d | | 6d d 6}	 i | | 6d | 6d d 6}
 i |	 d	 6|
 d
 6| d 6| | d | | ƒ d 6} t |  | | | ƒ S(   sx  
    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, Eq, 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
    ========
    :meth:`sympy.solvers.ode.ode_separable`

    Examples
    ========

    >>> from sympy import Function, Derivative, pprint
    >>> from sympy.solvers.ode import dsolve, classify_ode
    >>> 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
    i    R  R!  RÞ   i   R/  iÿÿÿÿRÍ   R$  R%  R¹   (   Rý   R”   R$   RÕ   t   ode_separable(   R“   R”   R°   RÝ   RÇ   R¦   R  R!  t   ycoeffR$  R%  Rú   (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt   ode_separable_reducedÐ  s    A	4c         C  s  | j  d } | d } | j } | | d | | d } | j d ƒ } | j d ƒ }	 | j d ƒ }
 | } | s‡ t | | ƒ |	 ƒ S|	 } |
 d k r| j i | | 6|	 | 6ƒ } | j t ƒ sã | j t ƒ sã | j t ƒ rö t | | ƒ t ƒ S| r| | | | 7} qn  xÊ t	 d	 |
 ƒ D]¹ } | j
 | ƒ | j
 | ƒ | } | j i | | 6|	 | 6ƒ } | j t ƒ s¤| j t ƒ s¤| j t ƒ s¤| j t ƒ r·t | | ƒ t ƒ S| | | | | t | ƒ 7} | } q$W| t | |
 ƒ 7} t | | ƒ | ƒ S(
   sy  
    The power series solution is a method which gives the Taylor series expansion
    to the solution of a differential equation.

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

    .. math:: y(x) = y(x_{0}) + \sum_{n = 1}^{\infty} \frac{F_{n}(x_{0},b)(x - x_{0})^n}{n!},

    where `y(x_{0}) = b` is the value of y at the initial value of `x_{0}`.
    To compute the values of the `F_{n}(x_{0},b)` the following algorithm is
    followed, until the required number of terms are generated.

    1. `F_1 = h(x_{0}, b)`
    2. `F_{n+1} = \frac{\partial F_{n}}{\partial x} + \frac{\partial F_{n}}{\partial y}F_{1}`

    Examples
    ========

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


    References
    ==========

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

    i    R  R—   R  R  R   R#  i   i   (   Rý   R”   RÚ   R!   RÕ   R  R	   R   R   R   R   R8   RJ   (   R“   R”   R°   RÝ   RÇ   R  R¦   R2  Rÿ   R
  R#  Rb  RK   t   hct	   factcountt   Fnewt   Fnewc(    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt   ode_1st_power_series  s4    (
	- = 
c         C  s  | j  d } | j } | } t j t d ƒ } }	 xK | j ƒ  D]= }
 t |
 ƒ t k s| |
 d k  rf q? | | |
 |	 |
 7} q? Wt | |	 ƒ } t	 | d t
 ƒ} t | ƒ | k rä g  t | j ƒ  ƒ D] } t | | ƒ ^ qÆ } n  t g  | j ƒ  D] }
 |
 j ^ qô ƒ } t t |  d | j ƒ  d ƒƒ } t t ƒ } x | D] } | | c d 7<qBWt d ƒ } g  a g  } g  } xí| D]å} | | k r™qn  | j | ƒ } x»t | ƒ D]­}
 | rü| j | |
 t | | ƒ ƒ |
 | d f g t a qµn  t | ƒ } t | ƒ } | j t ƒ rj| j t ƒ rj| j | |
 t | | ƒ ƒ |
 | d f g t a qµ| | k r’|
 | | f g t a qµn  | d k rÙ| j | |
 t | | ƒ ƒ |
 | d f g t a qµn  | j t | ƒ ƒ | j | |
 t | | ƒ t t  | ƒ | ƒ ƒ | j | |
 t | | ƒ t! | | ƒ ƒ |
 | | f g t a qµWqW| d k rz| S| d k rût" g  t# | | ƒ D] \ }
 } |
 | ^ q™Œ  } | d	 k r×t$ | | ƒ | ƒ Si t$ | | ƒ | ƒ d	 6| d 6Sn t% d
 ƒ ‚ d S(   s]  
    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.CRootOf` instance will be return
    instead.

    >>> from sympy import Function, dsolve, Eq
    >>> 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.

    The following is for internal use:

    - ``returns = 'sol'`` returns the solution to the ODE.
    - ``returns = 'list'`` returns a list of linearly independent solutions,
      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')
    >>> 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

    i    RÇ   t   multipleR   i   i   R±   t   solbothRä   s    Unknown value for key "returns".N(&   Rý   R”   R   RB  R$   R9  R¼   R¤   R?   RE   RÒ   RÌ   R   RH   RA   RÁ   t
   all_coeffsRS  R±   R£   R   R%  RÕ  RÖ   Rù   R.   R1   R/   R  R5   R6   R2   RÚ  R-   R   R  R!   R©   (   R“   R”   R°   RÝ   R•  RÇ   R¦   Rú   R–  R—  R¡   R˜  R  t   chareq_is_complexRâ   R™  Rš  Rn  R  t   conjugate_rootsRœ  RÜ  RÝ  Rv  (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt)   ode_nth_linear_constant_coeff_homogeneousg  sl    N	1)"3-2$c         C  s;   t  |  | | | d d ƒ} | j | ƒ t |  | | | ƒ S(   sž	  
    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'))
           /             4\
           |            x |  -x   4*sin(2*x)   3*cos(2*x)
    f(x) = |C1 + C2*x + --|*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

    R•  R¤  (   R»  RÛ   t    _solve_undetermined_coefficients(   R“   R”   R°   RÝ   R¦  (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyR¢    s    9	c         C  sH  | j  d } | j } | } t d d t ƒ} g  } | d }	 | d }
 | d } t g  ƒ } t g  ƒ } t |	 ƒ | k r« t d t | ƒ d d	 t |  ƒ d
 ƒ ‚ n  t g  ƒ } d } t } x@t	 D]8\ } } } | rò | d } t
 } n  | d k rt } n  | rŠ| | f | k rH| | t | | ƒ t | | ƒ } q¢| | t | | ƒ t t | ƒ | ƒ } | j | | f ƒ n | | t | | ƒ } | | k rÊ x, t rÜ| | | | k rØ| d 7} q±Pq±W| j | | | ƒ | j | ƒ qÊ qÊ W| | } d } x5 | D]- } t | ƒ } | j | ƒ | | | 7} qWt |  | | ƒ | ƒ } t t t | d g t | ƒ d ƒ ƒ ƒ } t | ƒ } xJ t j | ƒ D]9 } t | d t d | g ƒ} | | | c | d 7<q®Wt t | j ƒ  ƒ | ƒ } | st d |  ƒ ‚ n  | j | ƒ } t | | ƒ |
 j | ƒ S(   sí  
    Helper function for the method of undetermined coefficients.

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

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

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

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

    ``trialset``
      The set of trial functions as returned by
      ``_undetermined_coefficients_match()['trialset']``.

    i    R  R¯  R±   Rä   R6  s   Cannot find s9    solutions to the homogeneous equation necessary to applys    undetermined coefficients to s    (number of terms != order)i   RÂ   R%   RÍ   sf   Could not solve `%s` using the method of undetermined coefficients (unable to solve for coefficients).(   Rý   R”   RX   R$   Rª   RÌ   RÑ   R¤   RÒ   RÕ  R’   R.   R-   R2   RÚ  R  R›   Rù   R˜   RÂ   R±   R  R   R   R™  RO   RV   RÏ   RÕ   R!   R  (   R“   R”   R°   RÝ   RÇ   R¦   Rú   t   coeffsR>  R  Rn  R6  t
   notneedsett   newtrialsett   usedsint   multt   getmultR¡   RÜ  RÝ  RX  t	   trialfuncR  Ru  t
   coeffsdictRò   t	   coeffvalst   psol(    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyR¼  D  sn    	



		),	
,c           s¦   t  d d | g ƒ‰ t  d d | g ƒ‰ t |  d d ƒ}  i  } ‡ ‡ ‡ f d †  ‰ t g  ƒ ‡  f d † ‰  ˆ |  | ƒ | d <| d r¢ ˆ  |  | ƒ | d	 <n  | S(
   s­  
    Returns a trial function match if undetermined coefficients can be applied
    to ``expr``, and ``None`` otherwise.

    A trial expression can be found for an expression for use with the method
    of undetermined coefficients if the expression is an
    additive/multiplicative combination of constants, polynomials in `x` (the
    independent variable of expr), `\sin(a x + b)`, `\cos(a x + b)`, and
    `e^{a x}` terms (in other words, it has a finite number of linearly
    independent derivatives).

    Note that you may still need to multiply each term returned here by
    sufficient `x` to make it linearly independent with the solutions to the
    homogeneous equation.

    This is intended for internal use by ``undetermined_coefficients`` hints.

    SymPy currently has no way to convert `\sin^n(x) \cos^m(y)` into a sum of
    only `\sin(a x)` and `\cos(b x)` terms, so these are not implemented.  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.

    Examples
    ========

    >>> from sympy import log, exp
    >>> from sympy.solvers.ode import _undetermined_coefficients_match
    >>> from sympy.abc import x
    >>> _undetermined_coefficients_match(9*x*exp(x) + exp(-x), x)
    {'test': True, 'trialset': {x*exp(x), exp(-x), exp(x)}}
    >>> _undetermined_coefficients_match(log(x), x)
    {'test': False}

    R  R§   R  RÍ  R.   c           s–  |  j  ˆ  ƒ s t S|  j r< t ‡ ‡  f d †  |  j Dƒ ƒ S|  j r¹ |  j  t t ƒ r™ t } x9 |  j D]+ } | j  t t ƒ rg | r‰ t St } qg qg Wn  t ‡ ‡  f d †  |  j Dƒ ƒ S|  j	 r
|  j
 t t t f k r|  j d j ˆ ˆ  ˆ ƒ rü t St Sq’t Snˆ |  j r>|  j j r>|  j j r>|  j d k r>t S|  j rx|  j j rx|  j j ˆ ˆ  ˆ ƒ rqt St Sn |  j sŠ|  j rŽt St Sd S(   sV   
        Test if ``expr`` fits the proper form for undetermined coefficients.
        c         3  s   |  ] } ˆ  | ˆ ƒ Vq d  S(   N(    (   R¥   R¡   (   R:  RÇ   (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pys	   <genexpr>Ý  s    c         3  s   |  ] } ˆ  | ˆ ƒ Vq d  S(   N(    (   R¥   R¡   (   R:  RÇ   (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pys	   <genexpr>é  s    i    N(   R  RÒ   R=  RÁ   Rý   R7  R2   R-   R’   R  R”   R.   RÝ   R8  t   baseR8  t
   is_IntegerRï  (   RŽ   RÇ   t	   foundtrigR¡   (   R:  R  R  (   RÇ   s0   lib/python2.7/site-packages/sympy/solvers/ode.pyR:  Ö  s:    	 	 	!c           s&  d „  } t  |  ƒ }  |  j r~ x|  j D]O } | | | ƒ | k rF q( | j | | | ƒ ƒ | j ˆ  | | | ƒ ƒ } q( Wn¤ | |  | ƒ } | j | h ƒ } t g  ƒ } xn | | k r| j ƒ  } |  j | ƒ }  | |  | ƒ } | j r| j ˆ  | | | ƒ ƒ } q® | j | ƒ q® W| } | S(   sq  
        Returns a set of trial terms for undetermined coefficients.

        The idea behind undetermined coefficients is that the terms expression
        repeat themselves after a finite number of derivatives, except for the
        coefficients (they are linearly dependent).  So if we collect these,
        we should have the terms of our trial function.
        c         S  sa   t  j } |  j rE xH |  j D]" } | j | ƒ r | | 9} q q Wn |  j | ƒ r] |  } n  | S(   s­   
            Returns the expression without a coefficient.

            Similar to expr.as_independent(x)[1], except it only works
            multiplicatively.
            (   R   R  R7  Rý   R  (   RŽ   RÇ   RB  R¡   (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt   _remove_coefficient  s    			(   R   R=  Rý   R  R«   Rª   R?  R   (   RŽ   RÇ   t   exprsRÊ  RB  t   tmpsett   oldset(   t   _get_trial_set(    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyRÎ  ÿ  s(    			"	R5  R6  (   R#   RN   Rª   (   RŽ   RÇ   Rè   (    (   RÎ  R:  R  R  s0   lib/python2.7/site-packages/sympy/solvers/ode.pyRH  ­  s    $)2
c         C  s;   t  |  | | | d d ƒ} | j | ƒ t |  | | | ƒ S(   s  
    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 doesn't 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'))
           /                     3                \
           |                2   x *(6*log(x) - 11)|  x
    f(x) = |C1 + C2*x + C3*x  + ------------------|*e
           \                            36        /

    References
    ==========

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

    # indirect doctest

    R•  R¤  (   R»  RÛ   R¥  (   R“   R”   R°   RÝ   R¦  (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt5   ode_nth_linear_constant_coeff_variation_of_parameters>  s    G	c      	   C  s½  | j  d } | j } | } d } | d } | d }	 t | | ƒ }
 | j d t ƒ r~ t |
 ƒ }
 t |
 d t d t ƒ}
 n  |
 s³ t d t | ƒ d d	 t |  ƒ d
 ƒ ‚ n  t	 | ƒ | k rô t d t | ƒ d d	 t |  ƒ d ƒ ‚ n  d | } xo | D]g } | | t
 t g  | D] } | | k r| ^ q| ƒ | d |
 | ƒ | | | 7} | d 9} qW| j d t ƒ r£t | ƒ } t | d t ƒ} n  t | | ƒ |	 j | ƒ S(   s‰  
    Helper function for the method of variation of parameters and nonhomogeneous euler eq.

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

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

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

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

    i    R±   Rä   RP   RŒ   t	   recursives   Cannot find s:    solutions to the homogeneous equation necessary to apply s   variation of parameters to s    (Wronskian == 0)s    (number of terms != order)iÿÿÿÿ(   Rý   R”   R;   RÚ   RÒ   RP   RQ   RÑ   R¤   RÌ   R9   R!   R  (   R“   R”   R°   RÝ   RÇ   R¦   Rú   RÆ  R  Rn  t   wrt
   negonetermR¡   Rä   (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyR¥  ‹  s0    	

,,
Wc   	      C  s¿   | j  d } | j } t |  d d ƒ} | } | j d | | ƒ ƒ } t t | d d | d | d | d | d | d d	 | f ƒ t | d d | d | | d | | ƒ | ƒ S(
   sa  
    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

    i    R   i   R¹   R%  RÍ   R  R$  N(   Rý   R”   R£   RÚ   R!   R9   RÐ   (	   R“   R”   R°   RÝ   RÇ   R¦   R  Rú   R!  (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyR®  Å  s    7	1.c         C  sí  t  |  t ƒ r" |  j |  j }  n  | s= t |  ƒ \ }  } n  | j } t | ƒ d k rg t d ƒ ‚ n‚| d } | s‰ t |  | ƒ } n  | d k r¤ t	 d ƒ ‚ nE| j
 | ƒ } t d d | g ƒ} t d d | g ƒ} t t |  ƒ | ƒ j | | | ƒ }	 |	 r%t |	 | |	 | ƒ }
 n= y t |  | ƒ } Wn t	 k
 rWt	 d ƒ ‚ n X| d }
 t d	 ƒ } |
 j | | ƒ }
 t d
 ƒ | | ƒ } t d ƒ | | ƒ } t d
 ƒ | | ƒ } t d ƒ | | ƒ } | j
 | ƒ | j
 | ƒ | j
 | ƒ |
 | j
 | ƒ |
 d | |
 j
 | ƒ | |
 j
 | ƒ } g  } x¤ | D]œ } i t | | ƒ j | | ƒ | 6t | | ƒ j | | ƒ | 6} t | j | ƒ j ƒ  ƒ } | rÎ| j t | j | | ƒ f ƒ qE| j t d f ƒ qEW| Sd S(   s=  
    This function is used to check if the given infinitesimals are the
    actual infinitesimals of the given first order differential equation.
    This method is specific to the Lie Group Solver of ODEs.

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


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


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

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

    i   s(   ODE's have only one independent variablei    sR   Lie groups solver has been implemented only for first order differential equationsR  R§   R  s9   Infinitesimals for the first order ODE could not be foundR  Rº   R»   i   N(   R¨   R    R  R  R[   Rý   RÌ   R©   R\   RÑ   R   R#   RL   R   RÝ   RP   RV   R$   RÕ   R   R   R‘   Rù   R’   RÒ   (   R“   t   infinitesimalsR”   R°   R   RÇ   RK  R  R  RÝ   R2  Rä   R  Rº   R»   t   dxit   detat   pdet   soltupt   tsol(    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt   checkinfsol  sN    	
&
d  "c   '      C  sY  t  } i  } | j } | j d } | j | ƒ } t d ƒ }	 t d ƒ }
 t d d | g ƒ} t d d | g ƒ} | j d ƒ } | j d ƒ } | rÅ t | | d | | d ƒ } | d	 } nx y( t |  | ƒ } | g  k rì t	 ‚ n  Wn+ t	 k
 rt	 d
 t
 |  ƒ d ƒ ‚ n# Xt d	 ƒ } | d j | | ƒ } | d k	 rÚ| d k	 rÚi t | ƒ |	 | | | ƒ ƒ 6t | ƒ |
 | | | ƒ ƒ 6g } t |  | d | | ƒ d d ƒd d sÎt d ƒ ‚ qÚd g } n  i | d 6| d	 6} g  } xÎ| D]Æ} y1 | s1t |  d | d | d d d | ƒ} n  Wn t k
 rHqûqûXxu| D]m} | |	 | | ƒ j | | ƒ } | |
 | | ƒ j | | ƒ } t | | ƒ | k r°qPn  | | | ƒ j | ƒ | | | | ƒ j | ƒ | } t | d | | | ƒ ƒj } t | d d | | | ƒ ƒj } g  | | g D] } t | ƒ ^ q3} t d ƒ } t d ƒ } t d ƒ } | d } | d } y* t | | | | g | | d t ƒ} Wn t	 k
 rÃqPqPX| d } | | } | | }  t | j | ƒ | j | ƒ | ƒ }! t | j | ƒ | j | ƒ | ƒ }" |! ri|" rit |! |" j | | f | |  f g ƒ ƒ }# t |# d | | g d t ƒ}$ |$ r½t d |$ | | ƒ | t |$ d |$ | | ƒ }% |% j | | f | | f g ƒ }% y t |% | ƒ }& Wn t	 k
 r| j |% ƒ qfXt |& ƒ d k r=t | | ƒ |& j ƒ  ƒ Sg  |& D] } t | | ƒ | ƒ ^ qDSq½qP|" r“t | | ƒ t | | | ƒ d ƒ S|! rPt | | ƒ t | | | ƒ d ƒ SqPWqûW| r7t | ƒ d k rt | j ƒ  j | | | ƒ ƒ d ƒ Sg  | D]' } t | j | | | ƒ ƒ d ƒ ^ q	Sn  t	 d t
 |  ƒ d d ƒ ‚ d S(   sÝ  
    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 given system into another coordinate system where it becomes
    invariant under the one-parameter Lie group of translations. The converted ODE is
    quadrature and can be solved easily. 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, Eq, 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

    i    Rº   R»   R  R§   R  R—   R  R  s*   Unable to solve the differential equation s    by the lie group methodR”   R°   i   sT   The given infinitesimals xi and eta are not the infinitesimals to the given equationt   user_definedR2  R¹   RÝ   Rú   Rò   R  iÿÿÿÿRÂ   R%   RÍ   s   The given ODE s    cannot be solved bys    the lie group methodN(   t   lie_heuristicsR”   Rý   R   R   R#   RÖ   RP   RV   RÑ   R¤   R$   RÕ   RÐ   R   RÙ  R©   RÓ  RW   R  t   _lie_group_removeR"   RÒ   RO   R:   Rù   RÌ   R!   ('   R“   R”   R°   RÝ   t
   heuristicst   infR¦   RÇ   RK  Rº   R»   R  R  t   xist   etasR2  R  Rä   t   tempsolt	   heuristict   infsimt   xiinft   etainft   rpdeRú   Rò   t   coordt   newcoordR  t   rcoordt   scoordt   xsubt   ysubR   RÏ  t   diffeqt   sepRm  t   sdeq(    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt   ode_lie_groupR  s¤    2	!A)+6"%

*


&&+4!,$,%5c         C  sù   t  |  t ƒ r |  j d S|  j rb |  j t ƒ } | r^ x# | D] } |  j | d ƒ }  q? Wn  |  S|  j r |  j ƒ  \ } } t | ƒ } t | ƒ } | | S|  j	 rõ g  } |  j } x3 | D]+ } t  |  t ƒ s¼ | j
 t | ƒ ƒ q¼ q¼ Wt | Œ  S|  S(   sø  
    This function is strictly meant for internal use by the Lie group ODE solving
    method. It replaces arbitrary functions returned by pdsolve with either 0 or 1 or the
    args of the arbitrary function.

    The algorithm used is:
    1] If coords is an instance of an Undefined Function, then the args are returned
    2] If the arbitrary function is present in an Add object, it is replaced by zero.
    3] If the arbitrary function is present in an Mul object, it is replaced by one.
    4] If coords has no Undefined Function, it is returned as it is.

    Examples
    ========

    >>> from sympy.solvers.ode import _lie_group_remove
    >>> from sympy import Function
    >>> from sympy.abc import x, y
    >>> F = Function("F")
    >>> eq = x**2*y
    >>> _lie_group_remove(eq)
    x**2*y
    >>> eq = F(x**2*y)
    >>> _lie_group_remove(eq)
    x**2*y
    >>> eq = y**2*x + F(x**3)
    >>> _lie_group_remove(eq)
    x*y**2
    >>> eq = (F(x**3) + y)*x**4
    >>> _lie_group_remove(eq)
    x**4*y

    i    (   R¨   R   Rý   R=  R   RÕ   R8  R9  RÜ  R7  Rù   R   (   t   coordst   subfuncR”   RÇ  RŽ   t   mulargst	   coordargsRT  (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyRÜ  ö  s*    !				
c         C  sq  t  |  t ƒ r" |  j |  j }  n  | s= t |  ƒ \ }  } n  | j } t | ƒ d k rg t d ƒ ‚ n| d } | s‰ t |  | ƒ } n  | d k r¤ t	 d ƒ ‚ nÉ| j
 | ƒ } t d d | g ƒ} t d d | g ƒ}	 | rú | d }
 | d	 } n£ t t |  ƒ | ƒ j | | |	 ƒ } | rBt | |	 | | ƒ }
 n= y t |  | ƒ } Wn t	 k
 rtt	 d
 ƒ ‚ n X| d }
 t d	 ƒ } |
 j | | ƒ }
 t d ƒ } |
 j
 | ƒ } |
 j
 | ƒ } d |
 j | | f | | f g ƒ j | | ƒ } i |
 d 6| d 6| d 6| d 6| d	 6| d 6} | d k r¼g  } xf t D]^ } t ƒ  d | } | | d t ƒ} | rA| j g  | D] } | | k r}| ^ q}ƒ qAqAW| r­| St	 d ƒ ‚ n± | d k rx; t D]3 } t ƒ  d | } | | d t ƒ} | rÏ| SqÏWt	 d ƒ ‚ nX | t k r4t d | ƒ ‚ n9 t ƒ  d | } | | d t ƒ} | ra| St d ƒ ‚ d S(   s©  
    The infinitesimal functions of an ordinary differential equation, `\xi(x,y)`
    and `\eta(x,y)`, are the infinitesimals of the Lie group of point transformations
    for which the differential equation is invariant. So, the ODE `y'=f(x,y)`
    would admit a Lie group `x^*=X(x,y;\varepsilon)=x+\varepsilon\xi(x,y)`,
    `y^*=Y(x,y;\varepsilon)=y+\varepsilon\eta(x,y)` such that `(y^*)'=f(x^*, y^*)`.
    A change of coordinates, to `r(x,y)` and `s(x,y)`, can be performed so this Lie group
    becomes the translation group, `r^*=r` and `s^*=s+\varepsilon`.
    They are tangents to the coordinate curves of the new system.

    Consider the transformation `(x, y) \to (X, Y)` such that the
    differential equation remains invariant. `\xi` and `\eta` are the tangents to
    the transformed coordinates `X` and `Y`, at `\varepsilon=0`.

    .. math:: \left(\frac{\partial X(x,y;\varepsilon)}{\partial\varepsilon
                }\right)|_{\varepsilon=0} = \xi,
              \left(\frac{\partial Y(x,y;\varepsilon)}{\partial\varepsilon
                }\right)|_{\varepsilon=0} = \eta,

    The infinitesimals can be found by solving the following PDE:

        >>> from sympy import Function, diff, Eq, pprint
        >>> from sympy.abc import x, y
        >>> xi, eta, h = map(Function, ['xi', 'eta', 'h'])
        >>> h = h(x, y)  # dy/dx = h
        >>> eta = eta(x, y)
        >>> xi = xi(x, y)
        >>> genform = Eq(eta.diff(x) + (eta.diff(y) - xi.diff(x))*h
        ... - (xi.diff(y))*h**2 - xi*(h.diff(x)) - eta*(h.diff(y)), 0)
        >>> pprint(genform)
        /d               d           \                     d              2       d
        |--(eta(x, y)) - --(xi(x, y))|*h(x, y) - eta(x, y)*--(h(x, y)) - h (x, y)*--(x
        \dy              dx          /                     dy                     dy
        <BLANKLINE>
                            d             d
        i(x, y)) - xi(x, y)*--(h(x, y)) + --(eta(x, y)) = 0
                            dx            dx

    Solving the above mentioned PDE is not trivial, and can be solved only by
    making intelligent assumptions for `\xi` and `\eta` (heuristics). Once an
    infinitesimal is found, the attempt to find more heuristics stops. This is done to
    optimise the speed of solving the differential equation. If a list of all the
    infinitesimals is needed, ``hint`` should be flagged as ``all``, which gives
    the complete list of infinitesimals. If the infinitesimals for a particular
    heuristic needs to be found, it can be passed as a flag to ``hint``.

    Examples
    ========

    >>> from sympy import Function, diff
    >>> from sympy.solvers.ode import infinitesimals
    >>> from sympy.abc import x
    >>> f = Function('f')
    >>> eq = f(x).diff(x) - x**2*f(x)
    >>> infinitesimals(eq)
    [{eta(x, f(x)): exp(x**3/3), xi(x, f(x)): 0}]

    References
    ==========

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

    i   s(   ODE's have only one independent variablei    s?   Infinitesimals for only first order ODE's have been implementedR  R§   R  R2  R  s9   Infinitesimals for the first order ODE could not be foundR!  R”   t   hxt   hyt   hinvRÁ   t   lie_heuristic_t   comps3   Infinitesimals could not be found for the given ODER¯   s   Heuristic not recognized: s;   Infinitesimals could not be found using the given heuristicN(   R¨   R    R  R  R[   Rý   RÌ   R©   R\   RÑ   R   R#   RL   R   RÝ   RP   RV   R$   RÕ   RÛ  RÓ   RÒ   t   extendR’   (   R“   R”   R°   R¹   RÝ   R   RÇ   RK  R  R  R2  R  Rä   R!  Rõ  Rö  R÷  t   xietaRâ  t   functiont   inflistRÞ  (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyRÓ  -  sr    B	

&
103c         C  sñ  g  } |  d } |  d } |  d } | j  d } |  d } |  d } t d ƒ | | ƒ }	 t d ƒ | | ƒ }
 | j } | | k rý y t t | | ƒ ƒ } Wn t k
 r° qý Xi t d ƒ |	 6| |
 6} | sØ | g S| rý | | k rý | j | ƒ qý n  | | } | j } | | k r¡y t t | | ƒ ƒ } Wn t k
 rHq¡Xi t d ƒ |	 6| j | | ƒ |
 6} | s|| g S| r¡| | k r¡| j | ƒ q¡n  | | } | j } | | k r:y t t | | ƒ ƒ } Wn t k
 ríq:Xi | |	 6t d ƒ |
 6} | s| g S| r:| | k r:| j | ƒ q:n  | | d	 } | j } | | k rãy t t | | ƒ ƒ } Wn t k
 rŠqãXi | j | | ƒ |	 6t d ƒ |
 6} | s¾| g S| rã| | k rã| j | ƒ qãn  | rí| Sd
 S(   sD  
    The first heuristic uses the following four sets of
    assumptions on `\xi` and `\eta`

    .. math:: \xi = 0, \eta = f(x)

    .. math:: \xi = 0, \eta = f(y)

    .. math:: \xi = f(x), \eta = 0

    .. math:: \xi = f(y), \eta = 0

    The success of this heuristic is determined by algebraic factorisation.
    For the first assumption `\xi = 0` and `\eta` to be a function of `x`, the PDE

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

    reduces to `f'(x) - f\frac{\partial h}{\partial y} = 0`
    If `\frac{\partial h}{\partial y}` is a function of `x`, then this can usually
    be integrated easily. A similar idea is applied to the other 3 assumptions as well.


    References
    ==========

    - E.S Cheb-Terrab, L.G.S Duarte and L.A,C.P da Mota, Computer Algebra
      Solving of First Order ODEs Using Symmetry Methods, pp. 8


    R  R2  R”   i    Rõ  Rö  Rº   R»   i   N(	   Rý   R   R¬   R.   R:   RÑ   R   Rù   RÕ   (   RÝ   Rù  Rû  R  R2  R”   RÇ   Rõ  Rö  Rº   R»   t   hysymt   fxRÞ  R;  t   facsymt   fy(    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt   lie_heuristic_abaco1_simple½  st    #




	
	&		&c         C  s¶  g  } |  d } |  d } |  d } |  d } | j  d } t d ƒ | | ƒ } t d ƒ | | ƒ }	 t t | ƒ j | ƒ j | ƒ | d d	 t d
 | | g ƒ}
 |
 rg|
 d rg|
 | } t | d | | j | ƒ ƒ } | j } | | k rgt t	 | | ƒ ƒ } i t
 d ƒ |	 6| | j | | ƒ | 6}
 | s?|
 g S| rd|
 | k rd| j |
 ƒ qdqgn  t d ƒ } t t | ƒ j | ƒ j | ƒ | d d	 t d
 | | g ƒ}
 |
 r¨|
 d r¨|
 | } t | d | | j | ƒ ƒ } | j } | | k r¨t t	 | | ƒ ƒ } | | } | j | | f | | f g ƒ j | | ƒ } i | j | | ƒ |	 6t
 d ƒ | 6}
 | s€|
 g S| r¥|
 | k r¥| j |
 ƒ q¥q¨n  | r²| Sd S(   sû  
    The second heuristic uses the following two assumptions on `\xi` and `\eta`

    .. math:: \eta = 0, \xi = f(x)*g(y)

    .. math:: \eta = f(x)*g(y), \xi = 0

    The first assumption of this heuristic holds good if
    `\frac{1}{h^{2}}\frac{\partial^2}{\partial x \partial y}\log(h)` is
    separable in `x` and `y`, then the separated factors containing `x`
    is `f(x)`, and `g(y)` is obtained by

    .. math:: e^{\int f\frac{\partial}{\partial x}\left(\frac{1}{f*h}\right)\,dy}

    provided `f\frac{\partial}{\partial x}\left(\frac{1}{f*h}\right)` is a function
    of `y` only.

    The second assumption holds good if `\frac{dy}{dx} = h(x, y)` is rewritten as
    `\frac{dy}{dx} = \frac{1}{h(y, x)}` and the same properties of the first assumption
    satisfies. After obtaining `f(x)` and `g(y)`, the coordinates are again
    interchanged, to get `\eta` as `f(x)*g(y)`


    References
    ==========
    - E.S. Cheb-Terrab, A.D. Roche, Symmetries and First Order
      ODE Patterns, pp. 7 - pp. 8

    R  R2  R÷  R”   i    Rº   R»   i   RÂ   R%   RÍ   i   R&  N(   Rý   R   RO   R0   R   RÒ   RP   R¬   R.   R:   R   RÕ   Rù   R$   (   RÝ   Rù  Rû  R  R2  R÷  R”   RÇ   Rº   R»   RÞ  Rÿ  t   gyt   gysymsR&  t   etaval(    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt   lie_heuristic_abaco1_product$  sJ    



>
!	*>
!	
-&c   "   
   C  sÕ  |  d } |  d } |  d } |  d } | j  d } |  d } t d ƒ | | ƒ } t d ƒ | | ƒ }	 | j ƒ  rÑt d	 ƒ \ }
 } } } } } |
 | | | | | d
 | | | | } t | ƒ j ƒ  \ } } t | | | ƒ j ƒ  } t d ƒ | | ƒ } t d ƒ | | ƒ } | j | ƒ | j | ƒ | j | ƒ | | j | ƒ | d
 | | | | } t	 d ƒ } t	 d ƒ } xIt
 | d ƒ D]4} | rk| t g  t
 | d ƒ D]B } t	 d t | ƒ d t | | ƒ ƒ | | | | | ^ q¹Œ  7} | t g  t
 | d ƒ D]B } t	 d t | ƒ d t | | ƒ ƒ | | | | | ^ qŒ  7} n  | j i | | 6| | 6ƒ j ƒ  j ƒ  \ } } t | ƒ } | j | | ƒ rÜ| j rÜt | | | ƒ j ƒ  } n  | r–| j j | j ƒ | | h } t | j ƒ  | Œ } t | t ƒ r2| d } n  t d „  | j ƒ  Dƒ ƒ rÊ| j | ƒ } | j | ƒ } t d „  | Dƒ ƒ }  i | j |  ƒ j | | ƒ |	 6| j |  ƒ j | | ƒ | 6}! |! g Sq–q–Wn  d S(   sÔ  
    The third heuristic assumes the infinitesimals `\xi` and `\eta`
    to be bi-variate polynomials in `x` and `y`. The assumption made here
    for the logic below is that `h` is a rational function in `x` and `y`
    though that may not be necessary for the infinitesimals to be
    bivariate polynomials. The coefficients of the infinitesimals
    are found out by substituting them in the PDE and grouping similar terms
    that are polynomials and since they form a linear system, solve and check
    for non trivial solutions. The degree of the assumed bivariates
    are increased till a certain maximum value.

    References
    ==========
    - Lie Groups and Differential Equations
      pp. 327 - pp. 329

    R2  Rõ  Rö  R”   i    R  Rº   R»   s   etax etay etad xix xiy xidi   RÕ  RÔ  t   xi0t   eta0i   t   xi_Ri  t   eta_c         s  s   |  ] } | Vq d  S(   N(    (   R¥   RÇ   (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pys	   <genexpr>«  s    c         s  s   |  ] } | d  f Vq d S(   i   N(    (   R¥   R  (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pys	   <genexpr>°  s    N(   Rý   R   t   is_rational_functionR%   RG   Rš  R?   t   total_degreeR   R"   R   R   R¤   RÕ   R‘   R   RC  R=  R_  R¬   R«   RV   RÏ   R¨   R±   RG  RÂ   ("   RÝ   Rù  R2  Rõ  Rö  R”   RÇ   R  Rº   R»   t   etaxt   etayt   etadt   xixt   xiyt   xidt   ipdeR   RÏ  t   degRÕ  RÔ  t   xieqt   etaeqR¡   R/  t   pdent   polyyR+  t   soldictt   xiredt   etaredRc  RÞ  (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt   lie_heuristic_bivariatem  sT    




.RZ]/c       
   C  s  |  d } |  d } |  d } |  d } | j  d } |  d } t d ƒ | | ƒ } t d ƒ | | ƒ }	 | j ƒ  rÿt d	 ƒ \ }
 } } | | | | |
 } t | ƒ j ƒ  \ } } t | | | ƒ j ƒ  } t d
 ƒ | | ƒ } | j | ƒ } | j | ƒ } | | | | | } t	 d
 ƒ } x×t
 d | d ƒ D]¿} | t g  t
 | d ƒ D]B } t	 d t | ƒ d t | | ƒ ƒ | | | | | ^ qVŒ  7} t | j i | | 6ƒ j ƒ  ƒ j ƒ  \ } } t | ƒ } | j | | ƒ r9| j r9t | | | ƒ j ƒ  } | rø| j | | h } t | j ƒ  | Œ } t | t ƒ rY| d } n  t d „  | j ƒ  Dƒ ƒ rõ| j | ƒ } t d „  | Dƒ ƒ } | j | ƒ } t | | ƒ \ } } i | j | | ƒ |	 6| j | | ƒ | 6} | g Sqøq9q9Wn  d S(   s»  
    The aim of the fourth heuristic is to find the function `\chi(x, y)`
    that satisfies the PDE `\frac{d\chi}{dx} + h\frac{d\chi}{dx}
    - \frac{\partial h}{\partial y}\chi = 0`.

    This assumes `\chi` to be a bivariate polynomial in `x` and `y`. By intuition,
    `h` should be a rational function in `x` and `y`. The method used here is
    to substitute a general binomial for `\chi` up to a certain maximum degree
    is reached. The coefficients of the polynomials, are calculated by by collecting
    terms of the same order in `x` and `y`.

    After finding `\chi`, the next step is to use `\eta = \xi*h + \chi`, to
    determine `\xi` and `\eta`. This can be done by dividing `\chi` by `h`
    which would give `-\xi` as the quotient and `\eta` as the remainder.


    References
    ==========
    - E.S Cheb-Terrab, L.G.S Duarte and L.A,C.P da Mota, Computer Algebra
      Solving of First Order ODEs Using Symmetry Methods, pp. 8

    R2  Rõ  Rö  R”   i    R  Rº   R»   s   schi, schix, schiyR‹   i   t   chi_Ri  c         s  s   |  ] } | Vq d  S(   N(    (   R¥   RÇ   (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pys	   <genexpr>î  s    c         s  s   |  ] } | d  f Vq d S(   i   N(    (   R¥   R  (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pys	   <genexpr>ð  s    N(   Rý   R   R  R%   RG   Rš  R?   R  R   R"   R   R   R¤   RÕ   R‘   R   RC  R=  R_  R¬   RV   RÏ   R¨   R±   RG  RÂ   RI   (    RÝ   Rù  R2  Rõ  Rö  R”   RÇ   R  Rº   R»   t   schit   schixt   schiyt   cpdeR   RÏ  R  R‹   t   chixt   chiyt   chieqR¡   R/  t   cnumt   cdent   cpolyt   solsymsR  Rc  t   xict   etacRÞ  (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt   lie_heuristic_chiµ  sL    




Z.-c         C  s  g  } |  d } |  d } |  d } |  d } |  d } | j  d } |  d }	 t d ƒ | | ƒ }
 t d	 ƒ | | ƒ } xŒ| | g D]~} | d
 | j | d ƒ } t d
 | j |	 ƒ d t d | |	 g ƒ} | rú| d rú| | j | ƒ rú| |	 j |	 ƒ rút d ƒ } y | t | |	 |	 ƒ } Wn t k
 rAqúXd
 | | | | d } t	 | | | ƒ } t	 | j | d ƒ | ƒ } | rú| s·| j
 | d
 ƒ } | | } nE t | | ƒ } | r† | d } | j
 | | ƒ } | | | } n q† | | k r/| j
 | |	 ƒ } | j
 |	 | ƒ } n  t | | ƒ } | j rt g  | j  D] } | j | |	 ƒ rU| ^ qUŒ  } n  | | k r´i | j
 |	 | ƒ | 6t d ƒ |
 6} n& i | j
 |	 | ƒ |
 6t d ƒ | 6} | sç| g S| j | ƒ qún  | r† | Sq† Wd S(   s/  
    This heuristic uses the following two assumptions on `\xi` and `\eta`

    .. math:: \eta = 0, \xi = f(x) + g(y)

    .. math:: \eta = f(x) + g(y), \xi = 0

    The first assumption of this heuristic holds good if

    .. math:: \frac{\partial}{\partial y}[(h\frac{\partial^{2}}{
                \partial x^{2}}(h^{-1}))^{-1}]

    is separable in `x` and `y`,

    1. The separated factors containing `y` is `\frac{\partial g}{\partial y}`.
       From this `g(y)` can be determined.
    2. The separated factors containing `x` is `f''(x)`.
    3. `h\frac{\partial^{2}}{\partial x^{2}}(h^{-1})` equals
       `\frac{f''(x)}{f(x) + g(y)}`. From this `f(x)` can be determined.

    The second assumption holds good if `\frac{dy}{dx} = h(x, y)` is rewritten as
    `\frac{dy}{dx} = \frac{1}{h(y, x)}` and the same properties of the first
    assumption satisfies. After obtaining `f(x)` and `g(y)`, the coordinates
    are again interchanged, to get `\eta` as `f(x) + g(y)`.

    For both assumptions, the constant factors are separated among `g(y)`
    and `f''(x)`, such that `f''(x)` obtained from 3] is the same as that
    obtained from 2]. If not possible, then this heuristic fails.


    References
    ==========
    - E.S. Cheb-Terrab, A.D. Roche, Symmetries and First Order
      ODE Patterns, pp. 7 - pp. 8

    R2  Rõ  Rö  R”   R÷  i    R  Rº   R»   i   i   RÂ   R%   RÍ   R  N(   Rý   R   R   RO   RÒ   R  R$   R:   RÑ   RP   RÕ   RV   R   R7  R   R   Rù   (   RÝ   Rù  Rû  R2  Rõ  Rö  R”   R÷  RÇ   R  Rº   R»   t   odefacR;  Rî  R  R  t   fddRÿ  RX  Rä   R  RT  RÞ  (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt   lie_heuristic_function_sumý  s\    &





+6
	7)&c         C  so  g  } |  d } |  d } |  d } |  d } |  d } | j  d } |  d }	 t d ƒ | | ƒ }
 t d	 ƒ | | ƒ } t | j |	 ƒ | j |	 d
 ƒ ƒ } | j | ƒ } | j |	 ƒ } | j | ƒ r§| j |	 ƒ r§t d d |	 g ƒ} t d d |	 g ƒ} t d d | |	 g ƒ} | j | | t |	 | ƒ ƒ }  y. t t |  | |  | ƒ | ƒ |  | } Wn t	 k
 r€qQX|  | | } i | |
 6| | 6g Snª t | | ƒ } | j |	 ƒ sQt | | | j | ƒ | | | ƒ } | j |	 ƒ sQy t t | | ƒ ƒ } Wn t	 k
 r*qNX| | } i | |
 6| | 6g SqQn  t | j |	 ƒ | j |	 d
 ƒ ƒ } | j | ƒ } | j |	 ƒ } | j | ƒ r—| j |	 ƒ r—t d d |	 g ƒ} t d d |	 g ƒ} t d d | |	 g ƒ} | j | | t |	 | ƒ ƒ }  y. t t |  | |  | ƒ | ƒ |  | } Wn t	 k
 rXqkX|  | | } i | j
 | | ƒ | 6| j
 | | ƒ |
 6g SnÔ t | | ƒ } | j |	 ƒ skt | | j |	 ƒ | j | ƒ | j | ƒ | | ƒ } | j |	 ƒ sky t t | | ƒ ƒ } Wn t	 k
 r,qhX| | } i | j
 | | ƒ | 6| j
 | | ƒ |
 6g Sqkn  d S(   sW  
    This heuristic uses the following two assumptions on `\xi` and `\eta`

    .. math:: \eta = g(x), \xi = f(x)

    .. math:: \eta = f(y), \xi = g(y)

    For the first assumption,

    1. First `\frac{\frac{\partial h}{\partial y}}{\frac{\partial^{2} h}{
       \partial yy}}` is calculated. Let us say this value is A

    2. If this is constant, then `h` is matched to the form `A(x) + B(x)e^{
       \frac{y}{C}}` then, `\frac{e^{\int \frac{A(x)}{C} \,dx}}{B(x)}` gives `f(x)`
       and `A(x)*f(x)` gives `g(x)`

    3. Otherwise `\frac{\frac{\partial A}{\partial X}}{\frac{\partial A}{
       \partial Y}} = \gamma` is calculated. If

       a] `\gamma` is a function of `x` alone

       b] `\frac{\gamma\frac{\partial h}{\partial y} - \gamma'(x) - \frac{
       \partial h}{\partial x}}{h + \gamma} = G` is a function of `x` alone.
       then, `e^{\int G \,dx}` gives `f(x)` and `-\gamma*f(x)` gives `g(x)`

    The second assumption holds good if `\frac{dy}{dx} = h(x, y)` is rewritten as
    `\frac{dy}{dx} = \frac{1}{h(y, x)}` and the same properties of the first assumption
    satisfies. After obtaining `f(x)` and `g(x)`, the coordinates are again
    interchanged, to get `\xi` as `f(x^*)` and `\eta` as `g(y^*)`

    References
    ==========
    - E.S. Cheb-Terrab, A.D. Roche, Symmetries and First Order
      ODE Patterns, pp. 10 - pp. 12

    R2  Rõ  Rö  R”   R÷  i    R  Rº   R»   i   t   AR§   t   BR™   N(   Rý   R   RG   R   R  R#   RÝ   R.   R:   RÑ   RÕ   (   RÝ   Rù  Rû  R2  Rõ  Rö  R”   R÷  RÇ   R  Rº   R»   R;  t   factorxt   factoryR/  R0  R™   t   taut   gxt   gammat   tauint(    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt   lie_heuristic_abaco2_similarY  sv    &





% !.)% !.0-c         C  sr  g  } |  d } |  d } |  d } |  d } |  d } | j  d } |  d }	 t d ƒ | | ƒ }
 t d	 ƒ | | ƒ } g  } xc | j t ƒ D]R } | j ƒ  \ } } | j | ƒ r | j |	 ƒ r | j sá | j | ƒ qá q q WxH | j t ƒ D]7 } | j	 } | | k rõ |	 | k rõ | j | ƒ qõ qõ Wx;| D]3} t
 | j |	 ƒ | j | ƒ ƒ } t | d
 t d | |	 g ƒ} | rŒ| d rŒ| | } d | |	 | d } | j |	 ƒ | | j | ƒ | | | | | } t | ƒ si | |
 6| j |	 | ƒ | 6g Sd | } d | } | j | ƒ | j |	 ƒ | d | | | | } t t | ƒ ƒ sji | j |	 | ƒ |
 6| | 6g Sq7d | } | j | ƒ | j |	 ƒ | | | | } t | ƒ sõi t d ƒ |
 6| j |	 | ƒ | 6g S| } | j | ƒ | | j |	 ƒ | d | | | } t t | ƒ ƒ s7i | j |	 | ƒ |
 6t d ƒ | 6g Sq7Wd S(   s¡  
    This heuristic assumes the presence of unknown functions or known functions
    with non-integer powers.

    1. A list of all functions and non-integer powers containing x and y
    2. Loop over each element `f` in the list, find `\frac{\frac{\partial f}{\partial x}}{
       \frac{\partial f}{\partial x}} = R`

       If it is separable in `x` and `y`, let `X` be the factors containing `x`. Then

       a] Check if `\xi = X` and `\eta = -\frac{X}{R}` satisfy the PDE. If yes, then return
          `\xi` and `\eta`
       b] Check if `\xi = \frac{-R}{X}` and `\eta = -\frac{1}{X}` satisfy the PDE.
           If yes, then return `\xi` and `\eta`

       If not, then check if

       a] :math:`\xi = -R,\eta = 1`

       b] :math:`\xi = 1, \eta = -\frac{1}{R}`

       are solutions.

    References
    ==========
    - E.S. Cheb-Terrab, A.D. Roche, Symmetries and First Order
      ODE Patterns, pp. 10 - pp. 12

    R2  Rõ  Rö  R”   R÷  i    R  Rº   R»   RÂ   R%   RÍ   iÿÿÿÿi   i   N(   Rý   R   R   R   R9  R  RÈ  Rù   R   R¬   RG   R   RO   RÒ   RP   RÕ   R   R   (   RÝ   Rù  Rû  R2  Rõ  Rö  R”   R÷  RÇ   R  Rº   R»   t   funclistt   atomRÇ  R.   Rü  t   symsR¦   t   fracRî  t   xitry1t   etatry1t   pde1t   xitry2t   etatry2t   pde2t   etatryRÖ  t   xitry(    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt#   lie_heuristic_abaco2_unique_unknownÆ  sT    





		"
4!

4$
,'5c         C  sµ  g  } |  d } |  d } |  d } |  d } |  d } | j  d } |  d }	 t d ƒ | | ƒ }
 t d	 ƒ | | ƒ } t d ƒ } | j |	 ƒ } | j |	 ƒ | d
 } | j | ƒ | d
 } | oÑ | oÑ | sØ d S| j | ƒ } | j |	 ƒ } | j |	 ƒ } | j | ƒ } | j |	 ƒ } t d
 | | | | | | | d
 | | ƒ | d | | } | st d | d
 | d
 d
 | | d
 | | ƒ } | r±t d
 | d
 | | d
 | | d | d
 ƒ } | st | d | d | | | d | | | | | j | ƒ d | d ƒ } | sÿt d | d | | | | | | | t d
 ƒ | | ƒ } | | k rüy t t | |	 ƒ ƒ } Wn t k
 r²qùXd | d | | } |	 | k rùi | |
 6| j	 |	 | ƒ | 6g Sqüqÿqq±n¬t d
 | d
 | | d
 | | d | d
 ƒ } | r±t d | d | | d
 | d
 | | d
 d
 | | | d | d
 ƒ } | s±t | | | j |	 ƒ | j | ƒ | | | d | | | | d | | | ƒ } | s®t | | | | | | | | t d
 ƒ | | ƒ } | | k r«y t t | |	 ƒ ƒ } Wn t k
 rhq¨X| | | } |	 | k r¨i | |
 6| j	 |	 | ƒ | 6g Sq«q®q±n  d S(   sQ  
    This heuristic finds if infinitesimals of the form `\eta = f(x)`, `\xi = g(y)`
    without making any assumptions on `h`.

    The complete sequence of steps is given in the paper mentioned below.

    References
    ==========
    - E.S. Cheb-Terrab, A.D. Roche, Symmetries and First Order
      ODE Patterns, pp. 10 - pp. 12

    R2  Rõ  Rö  R”   R÷  i    R  Rº   R»   i   Ni   i   i   i   iüÿÿÿ(
   Rý   R   R   R   RP   RG   R.   R:   RÑ   RÕ   (   RÝ   Rù  Rû  R2  Rõ  Rö  R”   R÷  RÇ   R  Rº   R»   R™   R/  R0  t   Axt   Ayt   Axyt   Axxt   AyyRk  t   E1t   E2t   E3R  t   xival(    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt#   lie_heuristic_abaco2_unique_general  sr    





D44NB04M9:c   #      C  s  g  } |  d } |  d } |  d } |  d } |  d } | j  d } |  d }	 t d ƒ | | ƒ }
 t d	 ƒ | | ƒ } i  } t d
 d t ƒ} g  t | d ƒ D] } t | ƒ ^ q¡ } | \ } } } } } } | | | | | | | |	 | | | | | |	 | | | | d } | j ƒ  \ } } t t | ƒ ƒ } | j	 r| j  } x¹ | D]® } | j
 rÕt g  | j  D] } | j | |	 ƒ sx| ^ qxŒ  } | | } | | k rÂ| | | <q
| | c | 7<q\| | k rôt d ƒ | | <q\| | c t d ƒ 7<q\Wn  | j ƒ  } t | | ƒ } | rt | t ƒ rN| d } n  | j ƒ  } t d „  | Dƒ ƒ rt t | d g d ƒ ƒ }  | | | | | }! | | | | | }" |! j | ƒ }! |" j | ƒ }" |! j |  ƒ }! |" j |  ƒ }" i |! |
 6|" | 6g Sn  d S(   s  
    This heuristic assumes

    1. `\xi = ax + by + c` and
    2. `\eta = fx + gy + h`

    After substituting the following assumptions in the determining PDE, it
    reduces to

    .. math:: f + (g - a)h - bh^{2} - (ax + by + c)\frac{\partial h}{\partial x}
                 - (fx + gy + c)\frac{\partial h}{\partial y}

    Solving the reduced PDE obtained, using the method of characteristics, becomes
    impractical. The method followed is grouping similar terms and solving the system
    of linear equations obtained. The difference between the bivariate heuristic is that
    `h` need not be a rational function in this case.

    References
    ==========
    - E.S. Cheb-Terrab, A.D. Roche, Symmetries and First Order
      ODE Patterns, pp. 10 - pp. 12

    R2  Rõ  Rö  R”   R÷  i    R  Rº   R»   R  R¯  i   i   i   c         s  s   |  ] } | Vq d  S(   N(    (   R¥   RÞ   (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pys	   <genexpr>¥  s    N(   Rý   R   RX   R$   R   R›   Rš  RN   R   R=  R7  R   R  R   RÏ   RV   R¨   R±   RG  RÂ   R  RÕ   (#   RÝ   Rù  Rû  R2  Rõ  Rö  R”   R÷  RÇ   R  Rº   R»   t	   coeffdictR%   Ri  t   symlistR;  R  R5  t   C3t   C4t   C5RÖ  RÏ  R#  RB  R  t   remt   xypartRY  R  t   subvalt   onedictRM  R  (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt   lie_heuristic_lineare  sX    





(N			4
c         C  s3  |  d d j  } |  d d j  } |  d } |  d } |  d } t | d d ƒ\ } } } }	 t ƒ  }
 t t | d j t ƒ ƒ d j t ƒ ƒ d } xa t d ƒ D]S } d } x: t j	 | | ƒ D]% } | | | | | | d f 7} qÄ W| | | <q¤ W| d | | ƒ d f | d | | ƒ d f |
 d	 <| d | | ƒ d f | d | | ƒ d f |
 d
 <| d | | ƒ d f | d | | ƒ d f |
 d <| d | | ƒ d f | d | | ƒ d f |
 d <t
 d ƒ t
 d ƒ g } xc t d ƒ D]U } xL t j	 | | ƒ D]7 } | j | | ƒ | | ƒ ƒ s| | c | 7<qqWqôW| d j | ƒ pp| d j | ƒ s’| d |
 d <| d |
 d <n t d d ƒ ‚ |  d d k rÍt | | | |
 | ƒ } n  |  d d k rXt | | | |
 | ƒ } t | | | |
 | ƒ } t | | ƒ | d j | d ƒ t | | ƒ | d j | d ƒ g } n  |  d d k rƒt | | | |
 | ƒ } n  |  d d k r®t | | | |
 | ƒ } n  |  d d k rÙt | | | |
 | ƒ } n  |  d d k rt | | | |
 | ƒ } n  |  d d k r/t | | | |
 | ƒ } n  | S(   NR”   i    i   R}  R“   R   i   i   R  R  R  R—   R­  t   k2s'   Only homogeneous problems are supporteds    (and constant inhomogeneity)R¶   R“  R’  R”  R•  R–  R—  R˜  (   R”   R£   RÂ   R±   R   R   R"   R   R   R™  R   R  RÑ   t   _linear_2eq_order1_type1t   _linear_2eq_order1_type2R!   R  t   _linear_2eq_order1_type3t   _linear_2eq_order1_type4t   _linear_2eq_order1_type5t   _linear_2eq_order1_type6t   _linear_2eq_order1_type7(   t   match_RÇ   R  R”   Rœ  R“   R  R5  RQ  RR  Rú   RÞ   R¡   Ru  R#  R  Rv  Rä   Rn  RÆ  (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt   sysode_linear_2eq_order1°  sX    


	0#5555&
Kc         C  s  t  d ƒ } t | d d ƒ\ } } | d | d | d | d f \ } }	 }
 } t d „  | |	 |
 | f Dƒ ƒ } | | d d	 |	 |
 } | | t | ƒ d } | | t | ƒ d } t | d
 ƒ j ƒ  } g  g  } } | rò | d
 k n	 t | ƒ } t t |	 d
 ƒ t | | ƒ ƒ } t t |	 d
 ƒ t | | ƒ ƒ } t t	 | | | f |	 t
 f ƒ t	 |
 | f | | t
 f ƒ f ƒ } t t	 | | | f |	 t
 f ƒ t	 |
 | f | | t
 f ƒ f ƒ } | t | | ƒ | | t | | ƒ | } | j | d
 | f ƒ | j | d | f ƒ | r6| d
 k  n t } t | ƒ } t | ƒ j rft | ƒ } n t | ƒ } t |	 | | f ƒ } t d
 | f ƒ } t | | ƒ | t | | ƒ | t | | ƒ | | t | | ƒ | t | | ƒ | } | j | d
 | f ƒ | j | d | f ƒ t t | | ƒ t |	 d
 ƒ t |
 d
 ƒ ƒ } t t j t j f ƒ } t t j t j f ƒ } t | | ƒ | | | | } | j | d
 | f ƒ | j | d | f ƒ t t	 | | | f |	 t
 f ƒ t	 |
 | f | | t
 f ƒ f ƒ } t t	 t j | f t j t | | ƒ f |	 | | t
 f ƒ t	 t j | f t j t | | ƒ f t j t
 f ƒ f ƒ } t | | ƒ | | | | | | } | j | d
 | f ƒ | j | d | f ƒ t |  | ƒ t	 | Œ  ƒ t | | ƒ t	 | Œ  ƒ g S(   s
  
    It is classified under system of two linear homogeneous first-order constant-coefficient
    ordinary differential equations.

    The equations which come under this type are

    .. math:: x' = ax + by,

    .. math:: y' = cx + dy

    The characteristics equation is written as

    .. math:: \lambda^{2} + (a+d) \lambda + ad - bc = 0

    and its discriminant is `D = (a-d)^{2} + 4bc`. There are several cases

    1. Case when `ad - bc \neq 0`. The origin of coordinates, `x = y = 0`,
    is the only stationary point; it is
    - a node if `D = 0`
    - a node if `D > 0` and `ad - bc > 0`
    - a saddle if `D > 0` and `ad - bc < 0`
    - a focus if `D < 0` and `a + d \neq 0`
    - a centre if `D < 0` and `a + d \neq 0`.

    1.1. If `D > 0`. The characteristic equation has two distinct real roots
    `\lambda_1` and `\lambda_ 2` . The general solution of the system in question is expressed as

    .. math:: x = C_1 b e^{\lambda_1 t} + C_2 b e^{\lambda_2 t}

    .. math:: y = C_1 (\lambda_1 - a) e^{\lambda_1 t} + C_2 (\lambda_2 - a) e^{\lambda_2 t}

    where `C_1` and `C_2` being arbitrary constants

    1.2. If `D < 0`. The characteristics equation has two conjugate
    roots, `\lambda_1 = \sigma + i \beta` and `\lambda_2 = \sigma - i \beta`.
    The general solution of the system is given by

    .. math:: x = b e^{\sigma t} (C_1 \sin(\beta t) + C_2 \cos(\beta t))

    .. math:: y = e^{\sigma t} ([(\sigma - a) C_1 - \beta C_2] \sin(\beta t) + [\beta C_1 + (\sigma - a) C_2 \cos(\beta t)])

    1.3. If `D = 0` and `a \neq d`. The characteristic equation has
    two equal roots, `\lambda_1 = \lambda_2`. The general solution of the system is written as

    .. math:: x = 2b (C_1 + \frac{C_2}{a-d} + C_2 t) e^{\frac{a+d}{2} t}

    .. math:: y = [(d - a) C_1 + C_2 + (d - a) C_2 t] e^{\frac{a+d}{2} t}

    1.4. If `D = 0` and `a = d \neq 0` and `b = 0`

    .. math:: x = C_1 e^{a t} , y = (c C_1 t + C_2) e^{a t}

    1.5. If `D = 0` and `a = d \neq 0` and `c = 0`

    .. math:: x = (b C_1 t + C_2) e^{a t} , y = C_1 e^{a t}

    2. Case when `ad - bc = 0` and `a^{2} + b^{2} > 0`. The whole straight
    line `ax + by = 0` consists of singular points. The original system of differential
    equations can be rewritten as

    .. math:: x' = ax + by , y' = k (ax + by)

    2.1 If `a + bk \neq 0`, solution will be

    .. math:: x = b C_1 + C_2 e^{(a + bk) t} , y = -a C_1 + k C_2 e^{(a + bk) t}

    2.2 If `a + bk = 0`, solution will be

    .. math:: x = C_1 (bk t - 1) + b C_2 t , y = k^{2} b C_1 t + (b k^{2} t + 1) C_2

    Rµ   R   i   R  R  R  R—   c         s  s   |  ] } | j  Vq d  S(   N(   RS  (   R¥   R   (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pys	   <genexpr>/  s    i   i    i   (   R$   R£   RÁ   R4   R!   R   R*   R(   R<   R7   RÒ   R.   Rù   R’   R1   R/   t   is_positiveR-   R2   R   R  RB  (   RÇ   R  RÞ   Rú   R“   Rµ   R  R5  R  R  R  R—   t
   real_coeffRk  t   l1t   l2t   equal_rootst   gsol1t   gsol2t   exponential_formt   bad_ab_vector1t   bad_ab_vector2t   vector1t   vector2t
   sol_vectort   trigonometric_formt   sigmat   betat   scalar_matrix(    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyRZ  ã  s\    I."!!%%.4,- %'$(c         C  s  | d | d <| d | d <| d | d | d | d d k rÅ t  d d	 t ƒ\ } } t | d | | d | | d | d | | d | | d f | | ƒ } | | | | g } nV| d | d | d | d d k r| d d
 | d d
 d k r| d | d }	 | d | d |	 }
 |
 d k r¸| d |
 d | d |	 | d | |
 d | d | d | d | d } |	 | | d | d |	 | } nT | d | d | d |	 | d
 | d | } |	 | | d | d |	 | } | | g } n  | S(   sõ  
    The equations of this type are

    .. math:: x' = ax + by + k1 , y' = cx + dy + k2

    The general solution of this system is given by sum of its particular solution and the
    general solution of the corresponding homogeneous system is obtained from type1.

    1. When `ad - bc \neq 0`. The particular solution will be
    `x = x_0` and `y = y_0` where `x_0` and `y_0` are determined by solving linear system of equations

    .. math:: a x_0 + b y_0 + k1 = 0 , c x_0 + d y_0 + k2 = 0

    2. When `ad - bc = 0` and `a^{2} + b^{2} > 0`. In this case, the system of equation becomes

    .. math:: x' = ax + by + k_1 , y' = k (ax + by) + k_2

    2.1 If `\sigma = a + bk \neq 0`, particular solution is given by

    .. math:: x = b \sigma^{-1} (c_1 k - c_2) t - \sigma^{-2} (a c_1 + b c_2)

    .. math:: y = kx + (c_2 - c_1 k) t

    2.2 If `\sigma = a + bk = 0`, particular solution is given by

    .. math:: x = \frac{1}{2} b (c_2 - c_1 k) t^{2} + c_1 t

    .. math:: y = kx + (c_2 - c_1 k) t

    R­  RY  R  R—   R  R  i    s   x0, y0R¯  i   iÿÿÿÿiþÿÿÿ(   R%   R$   RV   (   RÇ   R  RÞ   Rú   R“   R¿   t   y0Rä   RÆ  R  Rq  R#  R  (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyR[  m  s      (PHR%2"c         C  s¾   t  | d d ƒ\ } } } } t | d | ƒ }	 t | d | ƒ }
 t |	 ƒ | t |
 ƒ | t |
 ƒ } t |	 ƒ | t |
 ƒ | t |
 ƒ } t |  | ƒ | ƒ t | | ƒ | ƒ g S(   sn  
    The equations of this type of ode are

    .. math:: x' = f(t) x + g(t) y

    .. math:: y' = g(t) x + f(t) y

    The solution of such equations is given by

    .. math:: x = e^{F} (C_1 e^{G} + C_2 e^{-G}) , y = e^{F} (C_1 e^{G} - C_2 e^{-G})

    where `C_1` and `C_2` are arbitrary constants, and

    .. math:: F = \int f(t) \,dt , G = \int g(t) \,dt

    R   i   R  R  (   R£   R9   R.   R!   (   RÇ   R  RÞ   Rú   R“   R  R5  RQ  RR  Rb  t   GR#  R  (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyR\  ž  s    ))c         C  sX  t  | d d ƒ\ } } } } | d | d k r§ t t | d | ƒ ƒ }	 t | d | ƒ }
 |	 | t |
 ƒ | t |
 ƒ } |	 | t |
 ƒ | t |
 ƒ } n‰ | d | d k r0t t | d | ƒ ƒ }	 t | d | ƒ }
 |	 | t |
 ƒ | t |
 ƒ } |	 | t |
 ƒ | t |
 ƒ } n  t |  | ƒ | ƒ t | | ƒ | ƒ g S(   s]  
    The equations of this type of ode are .

    .. math:: x' = f(t) x + g(t) y

    .. math:: y' = -g(t) x + f(t) y

    The solution is given by

    .. math:: x = F (C_1 \cos(G) + C_2 \sin(G)), y = F (-C_1 \sin(G) + C_2 \cos(G))

    where `C_1` and `C_2` are arbitrary constants, and

    .. math:: F = \int f(t) \,dt , G = \int g(t) \,dt

    R   i   R  R  R  R—   (   R£   R.   R9   R-   R2   R!   (   RÇ   R  RÞ   Rú   R“   R  R5  RQ  RR  Rb  Ru  R#  R  (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyR]  ¶  s    "&#%c         C  sÙ  t  | d d ƒ\ } } } } t d d t ƒ\ }	 }
 t d ƒ } t | d | d ƒ j | ƒ s~t | d | d ƒ } t | d | d	 | d ƒ } t t |	 | ƒ | ƒ |
 | ƒ ƒ t t |
 | ƒ | ƒ | |	 | ƒ | |
 | ƒ ƒ f } t | ƒ } t	 t
 | d	 | ƒ ƒ | d
 j j | t
 | d | ƒ ƒ } t	 t
 | d	 | ƒ ƒ | d j j | t
 | d | ƒ ƒ } n  t | d	 | d ƒ j | ƒ s±t | d	 | d ƒ } t | d | d | d ƒ } t t t |	 | ƒ | ƒ |
 | ƒ ƒ t t |
 | ƒ | ƒ | |	 | ƒ | |
 | ƒ ƒ ƒ } t	 t
 | d | ƒ ƒ | d j j | t
 | d | ƒ ƒ } t	 t
 | d | ƒ ƒ | d
 j j | t
 | d | ƒ ƒ } n  t |  | ƒ | ƒ t | | ƒ | ƒ g S(   sr  
    The equations of this type of ode are .

    .. math:: x' = f(t) x + g(t) y

    .. math:: y' = a g(t) x + [f(t) + b g(t)] y

    The transformation of

    .. math:: x = e^{\int f(t) \,dt} u , y = e^{\int f(t) \,dt} v , T = \int g(t) \,dt

    leads to a system of constant coefficient linear differential equations

    .. math:: u'(T) = v , v'(T) = au + bv

    R   i   s   u, vR¯  t   TR  R  R—   R  i    i   (   R£   R%   R   R"   RG   R  R!   R   Rî   R.   R9   R  RÕ   (   RÇ   R  RÞ   Rú   R“   R  R5  RQ  RR  R!  R   Rv  R.  R3  Rä   R#  R  (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyR^  Ô  s"    ! Z=@! ]=@c      
   C  sq  t  | d d ƒ\ } } } } d }	 d }
 t | d t | d | d ƒ j ƒ  d ƒ } t | d t | d | d ƒ j ƒ  d ƒ } xt | | g ƒ D]ú \ } } xë t j t | ƒ ƒ D]Ô } | j | ƒ sÝ | }
 n  |
 d k r8| d k r8| d | | d | d | d | | k r8d }	 | } Pq8n  |
 d k r¿ | d k r¿ | d | | d | d | d | | k r“d	 }	 | } Pq“q¿ q¿ Wq W|	 d k rrt |  | ƒ | ƒ | d |  | ƒ | d | |  | ƒ | t	 | t
 | d | d | | ƒ ƒ } t | ƒ d } t | d
 | d ƒj } | | | t	 | t
 | d | d | | ƒ ƒ } n× |	 d	 k rIt | | ƒ | ƒ | d | | ƒ | d | | | ƒ | t	 | t
 | d | d | | ƒ ƒ } t | ƒ d } t | d
 | d ƒj } | | | t	 | t
 | d | d | | ƒ ƒ } n  t |  | ƒ | ƒ t | | ƒ | ƒ g S(   sg  
    The equations of this type of ode are .

    .. math:: x' = f(t) x + g(t) y

    .. math:: y' = a [f(t) + a h(t)] x + a [g(t) - h(t)] y

    This is solved by first multiplying the first equation by `-a` and adding
    it to the second equation to obtain

    .. math:: y' - a x' = -a h(t) (y - a x)

    Setting `U = y - ax` and integrating the equation we arrive at

    .. math:: y - ax = C_1 e^{-a \int h(t) \,dt}

    and on substituting the value of y in first equation give rise to first order ODEs. After solving for
    `x`, we can obtain `y` by substituting the value of `x` in second equation.

    R   i   i    R  R—   R  R  i   i   R¹   Rï   (   R£   RG   Rš  R~  R   R™  RU   R  R   R.   R9   R×   Rî   R  R!   (   RÇ   R  RÞ   Rú   R“   R  R5  RQ  RR  R.  R3  Rž  RŸ  RÀ   R¡   Rv  Rò   t   equt   hint1R#  R  (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyR_  ÷  s<    00	00i9i9c         C  sÔ  t  | d d ƒ\ } } } } | d | d | d | d d | d | d t | d | ƒ t | d | ƒ | d }	 | d | d | d | d | d d t | d | ƒ | d | d t | d | ƒ }
 | d | d | d | d t | d | ƒ } | d | d | d | d t | d | ƒ } |	 d k rÏt | d t |  | ƒ | | ƒ | t |  | ƒ | ƒ ƒ j } t t | | ƒ | ƒ | d | | d | | ƒ ƒ j } nÝ|
 d k rZt | d t | | ƒ | | ƒ | t | | ƒ | ƒ ƒ j } t t |  | ƒ | ƒ | d |  | ƒ | d | ƒ j } nR|	 | d j | ƒ r| | d j | ƒ rt t |  | ƒ | | ƒ | | d t |  | ƒ | ƒ |	 | d |  | ƒ ƒ j } t t | | ƒ | ƒ | d | | d | | ƒ ƒ j } n|
 | d j | ƒ rä| | d j | ƒ rät t | | ƒ | | ƒ | | d t | | ƒ | ƒ |
 | d | | ƒ ƒ j } t t |  | ƒ | ƒ | d |  | ƒ | d | ƒ j } nÈ t d	 ƒ | ƒ } t d
 ƒ | ƒ } t t | d | ƒ ƒ } t t | d | ƒ ƒ } | | | | t | d | | | d | ƒ } | | | | | | | t | d | | | d | ƒ } t |  | ƒ | ƒ t | | ƒ | ƒ g S(   sÄ  
    The equations of this type of ode are .

    .. math:: x' = f(t) x + g(t) y

    .. math:: y' = h(t) x + p(t) y

    Differentiating the first equation and substituting the value of `y`
    from second equation will give a second-order linear equation

    .. math:: g x'' - (fg + gp + g') x' + (fgp - g^{2} h + f g' - f' g) x = 0

    This above equation can be easily integrated if following conditions are satisfied.

    1. `fgp - g^{2} h + f g' - f' g = 0`

    2. `fgp - g^{2} h + f g' - f' g = ag, fg + gp + g' = bg`

    If first condition is satisfied then it is solved by current dsolve solver and in second case it becomes
    a constant coefficient differential equation which is also solved by current solver.

    Otherwise if the above condition fails then,
    a particular solution is assumed as `x = x_0(t)` and `y = y_0(t)`
    Then the general solution is expressed as

    .. math:: x = C_1 x_0(t) + C_2 x_0(t) \int \frac{g(t) F(t) P(t)}{x_0^{2}(t)} \,dt

    .. math:: y = C_1 y_0(t) + C_2 [\frac{F(t) P(t)}{x_0(t)} + y_0(t) \int \frac{g(t) F(t) P(t)}{x_0^{2}(t)} \,dt]

    where C1 and C2 are arbitrary constants and

    .. math:: F(t) = e^{\int f(t) \,dt} , P(t) = e^{\int p(t) \,dt}

    R   i   R  R  R  i   R—   i    R¿   Rt  (	   R£   R   Rî   R  R  R   R.   R9   R!   (   RÇ   R  RÞ   Rú   R“   R  R5  RQ  RR  R¡  R¢  R$  R%  R#  R  R¿   Rt  Rb  t   P(    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyR`  +  s0    #``33@?@?0V?0V?3?c         C  s‘  |  d d j  } |  d d j  } |  d } |  d } |  d } t | d d ƒ\ } } } }	 t ƒ  }
 t t | d j t ƒ ƒ d j t ƒ ƒ d } xj t d ƒ D]\ } g  } x= t j	 | | ƒ D]( } | j
 | | | | | d f ƒ qÄ Wt | Œ  | | <q¤ W| d | | ƒ d f | d | | ƒ d f |
 d	 <| d | | ƒ d f | d | | ƒ d f |
 d
 <| d | | ƒ d f | d | | ƒ d f |
 d <| d | | ƒ d f | d | | ƒ d f |
 d <| d | | ƒ d f | d | | ƒ d f |
 d <| d | | ƒ d f | d | | ƒ d f |
 d <| d | | ƒ d f | d | | ƒ d f |
 d <| d | | ƒ d f | d | | ƒ d f |
 d <t d ƒ t d ƒ g } xo t d ƒ D]a } xX t j	 | | ƒ D]C } | j | | ƒ ƒ p| j | | ƒ ƒ së| | c | 7<qëqëWqÑW| d |
 d <| d |
 d <|  d d k rt | | | |
 | ƒ } n|  d d k r
t | | | |
 | ƒ } t | | | |
 | ƒ } t | | ƒ | d j | d ƒ t | | ƒ | d j | d ƒ g } nƒ|  d d k r5t | | | |
 | ƒ } nX|  d d k r`t | | | |
 | ƒ } n-|  d d k r‹t | | | |
 | ƒ } n|  d d k r¶t | | | |
 | ƒ } n× |  d d k rát | | | |
 | ƒ } n¬ |  d d k rt | | | |
 | ƒ } n |  d d k r7t | | | |
 | ƒ } nV |  d d k rbt | | | |
 | ƒ } n+ |  d d k rt | | | |
 | ƒ } n  | S(   NR”   i    i   R}  R“   R   i   i   R  R  R  R  R  R  R‘  R  R¡  R¢  R¶   R“  R’  R”  R•  R–  R—  R˜  R¦  R§  R¥  R¨  (   R”   R£   RÂ   R±   R   R   R"   R   R   R™  Rù   R   R  t   _linear_2eq_order2_type1t   _linear_2eq_order2_type2R!   R  t   _linear_2eq_order2_type3t   _linear_2eq_order2_type4t   _linear_2eq_order2_type5t   _linear_2eq_order2_type6t   _linear_2eq_order2_type7t   _linear_2eq_order2_type8t   _linear_2eq_order2_type9t   _linear_2eq_order2_type10t   _linear_2eq_order2_type11(   Ra  RÇ   R  R”   Rœ  R“   R  R5  RQ  RR  Rú   RÞ   R¡   Ru  R#  R©  Rv  Rä   Rn  RÆ  (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt   sysode_linear_2eq_order2i  sj    


	0&5 55 55 55 5*Kc         C  sG  | d | d <| d | d <| d | d <| d | d <t  d	 ƒ } t | d
 d ƒ\ } } } }	 | d | d | d | d | d | d | d | d }
 t |
 d ƒ } t |
 d ƒ } t |
 d ƒ } t |
 d ƒ } | d | d d d | d | d } | d | d | d | d d k r¥| d k r5| | d t | | ƒ | | d t | | ƒ | | d t | | ƒ |	 | d t | | ƒ } | | d | d t | | ƒ | | d | d t | | ƒ | | d | d t | | ƒ |	 | d | d t | | ƒ } q| d | d k rÞt d | d | d ƒ } | d | d | d | | d | d } d | | t | | d ƒ d | | t | | d ƒ d | d | | t | | d ƒ d | d |	 | t | | d ƒ } | | d | d | t | | d ƒ | | d | d | t | | d ƒ | | d | d | d | t | | d ƒ |	 | d | d | d | t | | d ƒ } q| d | d k oýd k n rÀ| d d k rÀt | d ƒ } d | | t | | ƒ d | | t | | ƒ } | d | | t | | ƒ | d | | t | | ƒ | t | | ƒ |	 t | | ƒ } q| d | d k oßd k n r| d d k rt | d ƒ } | d | | t | | ƒ | d | | t | | ƒ | t | | ƒ |	 t | | ƒ } d | | t | | ƒ d | | t | | ƒ } qnz| d | d | d | d d k r| d d | d d d k r| d | d } | d | d | d k rÈt | d | d | ƒ } | t | | ƒ | t | | ƒ | | d | |	 | d } | | t | | ƒ | | t | | ƒ | | d | |	 | d } q| | d | d | | d | d | | |	 } | | d | | d | } n  t |  | ƒ | ƒ t | | ƒ | ƒ g S(   sò  
    System of two constant-coefficient second-order linear homogeneous differential equations

    .. math:: x'' = ax + by

    .. math:: y'' = cx + dy

    The characteristic equation for above equations

    .. math:: \lambda^4 - (a + d) \lambda^2 + ad - bc = 0

    whose discriminant is `D = (a - d)^2 + 4bc \neq 0`

    1. When `ad - bc \neq 0`

    1.1. If `D \neq 0`. The characteristic equation has four distinct roots, `\lambda_1, \lambda_2, \lambda_3, \lambda_4`.
    The general solution of the system is

    .. math:: x = C_1 b e^{\lambda_1 t} + C_2 b e^{\lambda_2 t} + C_3 b e^{\lambda_3 t} + C_4 b e^{\lambda_4 t}

    .. math:: y = C_1 (\lambda_1^{2} - a) e^{\lambda_1 t} + C_2 (\lambda_2^{2} - a) e^{\lambda_2 t} + C_3 (\lambda_3^{2} - a) e^{\lambda_3 t} + C_4 (\lambda_4^{2} - a) e^{\lambda_4 t}

    where `C_1,..., C_4` are arbitrary constants.

    1.2. If `D = 0` and `a \neq d`:

    .. math:: x = 2 C_1 (bt + \frac{2bk}{a - d}) e^{\frac{kt}{2}} + 2 C_2 (bt + \frac{2bk}{a - d}) e^{\frac{-kt}{2}} + 2b C_3 t e^{\frac{kt}{2}} + 2b C_4 t e^{\frac{-kt}{2}}

    .. math:: y = C_1 (d - a) t e^{\frac{kt}{2}} + C_2 (d - a) t e^{\frac{-kt}{2}} + C_3 [(d - a) t + 2k] e^{\frac{kt}{2}} + C_4 [(d - a) t - 2k] e^{\frac{-kt}{2}}

    where `C_1,..., C_4` are arbitrary constants and `k = \sqrt{2 (a + d)}`

    1.3. If `D = 0` and `a = d \neq 0` and `b = 0`:

    .. math:: x = 2 \sqrt{a} C_1 e^{\sqrt{a} t} + 2 \sqrt{a} C_2 e^{-\sqrt{a} t}

    .. math:: y = c C_1 t e^{\sqrt{a} t} - c C_2 t e^{-\sqrt{a} t} + C_3 e^{\sqrt{a} t} + C_4 e^{-\sqrt{a} t}

    1.4. If `D = 0` and `a = d \neq 0` and `c = 0`:

    .. math:: x = b C_1 t e^{\sqrt{a} t} - b C_2 t e^{-\sqrt{a} t} + C_3 e^{\sqrt{a} t} + C_4 e^{-\sqrt{a} t}

    .. math:: y = 2 \sqrt{a} C_1 e^{\sqrt{a} t} + 2 \sqrt{a} C_2 e^{-\sqrt{a} t}

    2. When `ad - bc = 0` and `a^2 + b^2 > 0`. Then the original system becomes

    .. math:: x'' = ax + by

    .. math:: y'' = k (ax + by)

    2.1. If `a + bk \neq 0`:

    .. math:: x = C_1 e^{t \sqrt{a + bk}} + C_2 e^{-t \sqrt{a + bk}} + C_3 bt + C_4 b

    .. math:: y = C_1 k e^{t \sqrt{a + bk}} + C_2 k e^{-t \sqrt{a + bk}} - C_3 at - C_4 a

    2.2. If `a + bk = 0`:

    .. math:: x = C_1 b t^3 + C_2 b t^2 + C_3 t + C_4

    .. math:: y = kx + 6 C_1 t + 2 C_2

    R  R  R‘  R  R  R  R  R—   Rµ   R   i   i   i    i   i   i   (   R"   R£   RA   R.   R4   R!   (   RÇ   R  RÞ   Rú   R“   Rµ   R  R5  RQ  RR  t   chara_eqRe  Rf  t   l3t   l4Rk  Rh  Ri  R  t   midt   sa(    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyRz  ž  sL    @B*(j.Œ¿47g4d=HCN6!c         C  s+  t  d ƒ \ } } | d | d | d | d d k r¡ t | d | | d | | d | d | | d | | d f | | ƒ } | | | | g } n†| d | d | d | d d k r'| d d	 | d d	 d k r'| d | d }	 | d | d |	 }
 |
 d k r°| d |
 d
 | d |	 | d | d	 d	 |
 d | d | d | d | d } |	 | | d | d |	 | d	 d	 } | | g } q'| d | d | d |	 | d d | d | d	 d	 } |	 | | d | d |	 | d	 d	 } | | g } n  | S(   s¬  
    The equations in this type are

    .. math:: x'' = a_1 x + b_1 y + c_1

    .. math:: y'' = a_2 x + b_2 y + c_2

    The general solution of this system is given by the sum of its particular solution
    and the general solution of the homogeneous system. The general solution is given
    by the linear system of 2 equation of order 2 and type 1

    1. If `a_1 b_2 - a_2 b_1 \neq 0`. A particular solution will be `x = x_0` and `y = y_0`
    where the constants `x_0` and `y_0` are determined by solving the linear algebraic system

    .. math:: a_1 x_0 + b_1 y_0 + c_1 = 0, a_2 x_0 + b_2 y_0 + c_2 = 0

    2. If `a_1 b_2 - a_2 b_1 = 0` and `a_1^2 + b_1^2 > 0`. In this case, the system in question becomes

    .. math:: x'' = ax + by + c_1, y'' = k (ax + by) + c_2

    2.1. If `\sigma = a + bk \neq 0`, the particular solution will be

    .. math:: x = \frac{1}{2} b \sigma^{-1} (c_1 k - c_2) t^2 - \sigma^{-2} (a c_1 + b c_2)

    .. math:: y = kx + \frac{1}{2} (c_2 - c_1 k) t^2

    2.2. If `\sigma = a + bk = 0`, the particular solution will be

    .. math:: x = \frac{1}{24} b (c_2 - c_1 k) t^4 + \frac{1}{2} c_1 t^2

    .. math:: y = kx + \frac{1}{2} (c_2 - c_1 k) t^2

    s   x0, y0R  R  R  R‘  i    R¡  R¢  i   iÿÿÿÿiþÿÿÿi   i   (   R%   RV   (   RÇ   R  RÞ   Rú   R“   R¿   Rt  Rä   RÆ  R  t   sigt   psol1t   psol2(    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyR{    s     "(PH/+*>*c         C  s{  t  | d d ƒ\ } } } } | d d d | d d k rS| d | d <| d | d <| d d t | d d d | d ƒ d }	 | d d t | d d d | d ƒ d }
 | t |	 | ƒ | t |	 | ƒ | t |
 | ƒ | t |
 | ƒ } | t |	 | ƒ | t |	 | ƒ | t |
 | ƒ | t |
 | ƒ } n  t |  | ƒ | ƒ t | | ƒ | ƒ g S(	   s  
    These type of equation is used for describing the horizontal motion of a pendulum
    taking into account the Earth rotation.
    The solution is given with `a^2 + 4b > 0`:

    .. math:: x = C_1 \cos(\alpha t) + C_2 \sin(\alpha t) + C_3 \cos(\beta t) + C_4 \sin(\beta t)

    .. math:: y = -C_1 \sin(\alpha t) + C_2 \cos(\alpha t) - C_3 \sin(\beta t) + C_4 \cos(\beta t)

    where `C_1,...,C_4` and

    .. math:: \alpha = \frac{1}{2} a + \frac{1}{2} \sqrt{a^2 + 4b}, \beta = \frac{1}{2} a - \frac{1}{2} \sqrt{a^2 + 4b}

    R   i   R  i   R  i    R  R  (   R£   R4   R-   R2   R!   (   RÇ   R  RÞ   Rú   R“   R  R5  RQ  RR  t   alphaRr  R#  R  (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyR|  ?  s      00JNc   '      C  sö  t  | d d ƒ\ } } } } t d ƒ }	 t d ƒ \ }
 } } } | d } | d } | d } | d } | d	 } | d
 } | d } | d } | d j ƒ  j | ƒ d } | d j ƒ  j | ƒ d } | d j ƒ  j | ƒ d } t | ƒ j ƒ  d } t | | ƒ j | ƒ } t	 | t
 ƒ } | d | |
 | | | | | | | | | } | | |
 | d | | | | | | | } | |
 | | | | d | | | | | | } | | |
 | | | | | | d | | } t | | | | g ƒ }  |	 d | |	 | |	 d | |	 | | |	 | | |	 | }! t t |! ƒ ƒ \ } } }" }# | | | | t | | ƒ | | | | t | | ƒ | | |" | t |" | ƒ | | |# | t |# | ƒ |
 t
 | t t
 | | ƒ }$ | d }% | | d |% | | t | | ƒ | | d |% | | t | | ƒ | |" d |% |" | t |" | ƒ | |# d |% |# | t |# | ƒ | t
 | t t
 | | ƒ }& t |  | ƒ |$ ƒ t | | ƒ |& ƒ g S(   s	  
    These equations are found in the theory of oscillations

    .. math:: x'' + a_1 x' + b_1 y' + c_1 x + d_1 y = k_1 e^{i \omega t}

    .. math:: y'' + a_2 x' + b_2 y' + c_2 x + d_2 y = k_2 e^{i \omega t}

    The general solution of this linear nonhomogeneous system of constant-coefficient
    differential equations is given by the sum of its particular solution and the
    general solution of the corresponding homogeneous system (with `k_1 = k_2 = 0`)

    1. A particular solution is obtained by the method of undetermined coefficients:

    .. math:: x = A_* e^{i \omega t}, y = B_* e^{i \omega t}

    On substituting these expressions into the original system of differential equations,
    one arrive at a linear nonhomogeneous system of algebraic equations for the
    coefficients `A` and `B`.

    2. The general solution of the homogeneous system of differential equations is determined
    by a linear combination of linearly independent particular solutions determined by
    the method of undetermined coefficients in the form of exponentials:

    .. math:: x = A e^{\lambda t}, y = B e^{\lambda t}

    On substituting these expressions into the original system and collecting the
    coefficients of the unknown `A` and `B`, one obtains

    .. math:: (\lambda^{2} + a_1 \lambda + c_1) A + (b_1 \lambda + d_1) B = 0

    .. math:: (a_2 \lambda + c_2) A + (\lambda^{2} + b_2 \lambda + d_2) B = 0

    The determinant of this system must vanish for nontrivial solutions A, B to exist.
    This requirement results in the following characteristic equation for `\lambda`

    .. math:: (\lambda^2 + a_1 \lambda + c_1) (\lambda^2 + b_2 \lambda + d_2) - (b_1 \lambda + d_1) (a_2 \lambda + c_2) = 0

    If all roots `k_1,...,k_4` of this equation are distinct, the general solution of the original
    system of the differential equations has the form

    .. math:: x = C_1 (b_1 \lambda_1 + d_1) e^{\lambda_1 t} - C_2 (b_1 \lambda_2 + d_1) e^{\lambda_2 t} - C_3 (b_1 \lambda_3 + d_1) e^{\lambda_3 t} - C_4 (b_1 \lambda_4 + d_1) e^{\lambda_4 t}

    .. math:: y = C_1 (\lambda_1^{2} + a_1 \lambda_1 + c_1) e^{\lambda_1 t} + C_2 (\lambda_2^{2} + a_1 \lambda_2 + c_1) e^{\lambda_2 t} + C_3 (\lambda_3^{2} + a_1 \lambda_3 + c_1) e^{\lambda_3 t} + C_4 (\lambda_4^{2} + a_1 \lambda_4 + c_1) e^{\lambda_4 t}

    R   i   R  s   Ra, Ca, Rb, CbR  R  R  R  R  R  R‘  R  R¡  i    R¢  i   i   (   R£   R"   R%   R   R>  RT   R9  RL   RÍ   RG   R   RV   RF   R?   R.   R!   ('   RÇ   R  RÞ   Rú   R“   R  R5  RQ  RR  R  t   Rat   Cat   Rbt   CbR  R  R  R  R  R  R‘  R  R­  RY  t   ew1t   ew2t   ew3Rt  t   peq1t   peq2t   peq3t   peq4RÆ  R–  t   k3t   k4R#  t   a1_R  (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyR}  W  s8    .
 

 

 

 
7373B™
¸c         C  sî  t  | d d ƒ\ } } } } | d | d <| d | d <t t | d | d ƒ ƒ }	 | d | d d k rû | | d t |	 | d d ƒ | | d t |	 | d d ƒ }
 | |	 t |	 | d d ƒ | |	 t |	 | d d ƒ } n… | | d t |	 | d d ƒ | | d t |	 | d d ƒ }
 | |	 t |	 | d d ƒ | |	 t |	 | d d ƒ } | | | t |
 | d | ƒ } | | | t | | d | ƒ } t |  | ƒ | ƒ t | | ƒ | ƒ g S(	   sž  
    The equation which come under this category are

    .. math:: x'' = a (t y' - y)

    .. math:: y'' = b (t x' - x)

    The transformation

    .. math:: u = t x' - x, b = t y' - y

    leads to the first-order system

    .. math:: u' = atv, v' = btu

    The general solution of this system is given by

    If `ab > 0`:

    .. math:: u = C_1 a e^{\frac{1}{2} \sqrt{ab} t^2} + C_2 a e^{-\frac{1}{2} \sqrt{ab} t^2}

    .. math:: v = C_1 \sqrt{ab} e^{\frac{1}{2} \sqrt{ab} t^2} - C_2 \sqrt{ab} e^{-\frac{1}{2} \sqrt{ab} t^2}

    If `ab < 0`:

    .. math:: u = C_1 a \cos(\frac{1}{2} \sqrt{\left|ab\right|} t^2) + C_2 a \sin(-\frac{1}{2} \sqrt{\left|ab\right|} t^2)

    .. math:: v = C_1 \sqrt{\left|ab\right|} \sin(\frac{1}{2} \sqrt{\left|ab\right|} t^2) + C_2 \sqrt{\left|ab\right|} \cos(-\frac{1}{2} \sqrt{\left|ab\right|} t^2)

    where `C_1` and `C_2` are arbitrary constants. On substituting the value of `u` and `v`
    in above equations and integrating the resulting expressions, the general solution will become

    .. math:: x = C_3 t + t \int \frac{u}{t^2} \,dt, y = C_4 t + t \int \frac{u}{t^2} \,dt

    where `C_3` and `C_4` are arbitrary constants.

    R   i   R‘  R  R  R  i    i   (   R£   R4   RÚ  R.   R-   R2   R9   R!   (   RÇ   R  RÞ   Rú   R“   R  R5  RQ  RR  Rh  R!  R   R#  R  (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyR~  ¦  s    & GBF?##c         C  s-  t  | d d ƒ\ } } } } t d ƒ }	 t d ƒ }
 t | d |  | ƒ | d | | ƒ | d |  | ƒ | d | | ƒ ƒ j ƒ  \ } } | d | j |  | ƒ ƒ } | j |  | ƒ ƒ } | j | | ƒ ƒ } | j |  | ƒ ƒ } | j | | ƒ ƒ } |	 d	 | | |	 | | | | } g  t t | ƒ j ƒ  ƒ D] }	 t	 | |	 ƒ ^ qB\ } } t
 t |
 | ƒ | | ƒ | | |
 | ƒ ƒ j } t
 t |
 | ƒ | | ƒ | | |
 | ƒ ƒ j } | | | | | | | | | | } | | | | } t |  | ƒ | ƒ t | | ƒ | ƒ g S(
   sš  
    The equations are

    .. math:: x'' = f(t) (a_1 x + b_1 y)

    .. math:: y'' = f(t) (a_2 x + b_2 y)

    If `k_1` and `k_2` are roots of the quadratic equation

    .. math:: k^2 - (a_1 + b_2) k + a_1 b_2 - a_2 b_1 = 0

    Then by multiplying appropriate constants and adding together original equations
    we obtain two independent equations:

    .. math:: z_1'' = k_1 f(t) z_1, z_1 = a_2 x + (k_1 - a_1) y

    .. math:: z_2'' = k_2 f(t) z_2, z_2 = a_2 x + (k_2 - a_1) y

    Solving the equations will give the values of `x` and `y` after obtaining the value
    of `z_1` and `z_2` by solving the differential equation and substituting the result.

    R   i   R  R®  R  R‘  R  R  i   (   R£   R"   R   RG   Rš  RÍ   R   R?   RH   RA   Rî   R   R  R!   (   RÇ   R  RÞ   Rú   R“   R  R5  RQ  RR  R  R®  R   RS  R¦   R  R  R  R  R–  R­  RY  t   z1t   z2R#  R  (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyR  Ù  s$    #6&:33*c         C  s  t  | d d ƒ\ } } } } t d ƒ }	 t | d |  | ƒ | d | | ƒ | d |  | ƒ | d | | ƒ ƒ j ƒ  \ }
 } | d |
 j |  | ƒ ƒ } |
 j |  | ƒ ƒ } |
 j | | ƒ ƒ } | j |  | ƒ ƒ } | j | | ƒ ƒ } |	 d | | |	 | | | | } g  t t | ƒ j ƒ  ƒ D] }	 t | |	 ƒ ^ q6\ } } t	 | | ƒ } | t	 t
 | | ƒ | ƒ | } | t	 t
 | | ƒ | ƒ | } | | | | | | | | | | } | | | | } t |  | ƒ | ƒ t | | ƒ | ƒ g S(	   s{  
    The equations are given as

    .. math:: x'' = f(t) (a_1 x' + b_1 y')

    .. math:: y'' = f(t) (a_2 x' + b_2 y')

    If `k_1` and 'k_2` are roots of the quadratic equation

    .. math:: k^2 - (a_1 + b_2) k + a_1 b_2 - a_2 b_1 = 0

    Then the system can be reduced by adding together the two equations multiplied
    by appropriate constants give following two independent equations:

    .. math:: z_1'' = k_1 f(t) z_1', z_1 = a_2 x + (k_1 - a_1) y

    .. math:: z_2'' = k_2 f(t) z_2', z_2 = a_2 x + (k_2 - a_1) y

    Integrating these and returning to the original variables, one arrives at a linear
    algebraic system for the unknowns `x` and `y`:

    .. math:: a_2 x + (k_1 - a_1) y = C_1 \int e^{k_1 F(t)} \,dt + C_2

    .. math:: a_2 x + (k_2 - a_1) y = C_3 \int e^{k_2 F(t)} \,dt + C_4

    where `C_1,...,C_4` are arbitrary constants and `F(t) = \int f(t) \,dt`

    R   i   R  R  R  R  R  i   (   R£   R"   RG   Rš  RÍ   R   R?   RH   RA   R9   R.   R!   (   RÇ   R  RÞ   Rú   R“   R  R5  RQ  RR  R  R   RS  R¦   R  R  R  R  R–  R­  RY  Rb  R  Rž  R#  R  (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyR€    s$    #6&:!!*c         C  sÂ  t  | d d ƒ\ } } } } t | d | d ƒ j ƒ  \ }	 }
 | d |	 } |	 } |
 } t t | | ƒ ƒ } t | | | ƒ } | | d k r÷ | | t | | ƒ | | t | | ƒ } | | t | | ƒ | | t | | ƒ } n] | | t | | ƒ | | t | | ƒ } | | t | | ƒ | | t | | ƒ } | | | t | | d | ƒ } | | | t | | d | ƒ } t	 |  | ƒ | ƒ t	 | | ƒ | ƒ g S(   s¾  
    The equation of this category are

    .. math:: x'' = a f(t) (t y' - y)

    .. math:: y'' = b f(t) (t x' - x)

    The transformation

    .. math:: u = t x' - x, v = t y' - y

    leads to the system of first-order equations

    .. math:: u' = a t f(t) v, v' = b t f(t) u

    The general solution of this system has the form

    If `ab > 0`:

    .. math:: u = C_1 a e^{\sqrt{ab} \int t f(t) \,dt} + C_2 a e^{-\sqrt{ab} \int t f(t) \,dt}

    .. math:: v = C_1 \sqrt{ab} e^{\sqrt{ab} \int t f(t) \,dt} - C_2 \sqrt{ab} e^{-\sqrt{ab} \int t f(t) \,dt}

    If `ab < 0`:

    .. math:: u = C_1 a \cos(\sqrt{\left|ab\right|} \int t f(t) \,dt) + C_2 a \sin(-\sqrt{\left|ab\right|} \int t f(t) \,dt)

    .. math:: v = C_1 \sqrt{\left|ab\right|} \sin(\sqrt{\left|ab\right|} \int t f(t) \,dt) + C_2 \sqrt{\left|ab\right|} \cos(-\sqrt{\left|ab\right|} \int t f(t) \,dt)

    where `C_1` and `C_2` are arbitrary constants. On substituting the value of `u` and `v`
    in above equations and integrating the resulting expressions, the general solution will become

    .. math:: x = C_3 t + t \int \frac{u}{t^2} \,dt, y = C_4 t + t \int \frac{u}{t^2} \,dt

    where `C_3` and `C_4` are arbitrary constants.

    R   i   R‘  R  i    i   (
   R£   RG   Rš  R4   RÚ  R9   R.   R-   R2   R!   (   RÇ   R  RÞ   Rú   R“   R  R5  RQ  RR  R   RS  R¦   R  R  Rh  t   IgralR!  R   R#  R  (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyR  3  s    &$/2./##c         C  s‘  t  | d d ƒ\ } } } } t d ƒ }	 | d | }
 | d | } | d | } | d | } | d | d	 } | d
 | d	 } | d | d	 } | d | d	 } |	 d	 |
 d |	 | |	 d	 | d |	 | | |	 | | |	 | } t t | ƒ ƒ \ } } } } | | | | t | t | ƒ ƒ | | | | t | t | ƒ ƒ | | | | t | t | ƒ ƒ | | | | t | t | ƒ ƒ } |
 d } | | d	 | | | t | t | ƒ ƒ | | d	 | | | t | t | ƒ ƒ | | d	 | | | t | t | ƒ ƒ | | d	 | | | t | t | ƒ ƒ } t |  | ƒ | ƒ t | | ƒ | ƒ g S(   sÓ  
    .. math:: t^2 x'' + a_1 t x' + b_1 t y' + c_1 x + d_1 y = 0

    .. math:: t^2 y'' + a_2 t x' + b_2 t y' + c_2 x + d_2 y = 0

    These system of equations are euler type.

    The substitution of `t = \sigma e^{\tau} (\sigma \neq 0)` leads to the system of constant
    coefficient linear differential equations

    .. math:: x'' + (a_1 - 1) x' + b_1 y' + c_1 x + d_1 y = 0

    .. math:: y'' + a_2 x' + (b_2 - 1) y' + c_2 x + d_2 y = 0

    The general solution of the homogeneous system of differential equations is determined
    by a linear combination of linearly independent particular solutions determined by
    the method of undetermined coefficients in the form of exponentials

    .. math:: x = A e^{\lambda t}, y = B e^{\lambda t}

    On substituting these expressions into the original system and collecting the
    coefficients of the unknown `A` and `B`, one obtains

    .. math:: (\lambda^{2} + (a_1 - 1) \lambda + c_1) A + (b_1 \lambda + d_1) B = 0

    .. math:: (a_2 \lambda + c_2) A + (\lambda^{2} + (b_2 - 1) \lambda + d_2) B = 0

    The determinant of this system must vanish for nontrivial solutions A, B to exist.
    This requirement results in the following characteristic equation for `\lambda`

    .. math:: (\lambda^2 + (a_1 - 1) \lambda + c_1) (\lambda^2 + (b_2 - 1) \lambda + d_2) - (b_1 \lambda + d_1) (a_2 \lambda + c_2) = 0

    If all roots `k_1,...,k_4` of this equation are distinct, the general solution of the original
    system of the differential equations has the form

    .. math:: x = C_1 (b_1 \lambda_1 + d_1) e^{\lambda_1 t} - C_2 (b_1 \lambda_2 + d_1) e^{\lambda_2 t} - C_3 (b_1 \lambda_3 + d_1) e^{\lambda_3 t} - C_4 (b_1 \lambda_4 + d_1) e^{\lambda_4 t}

    .. math:: y = C_1 (\lambda_1^{2} + (a_1 - 1) \lambda_1 + c_1) e^{\lambda_1 t} + C_2 (\lambda_2^{2} + (a_1 - 1) \lambda_2 + c_1) e^{\lambda_2 t} + C_3 (\lambda_3^{2} + (a_1 - 1) \lambda_3 + c_1) e^{\lambda_3 t} + C_4 (\lambda_4^{2} + (a_1 - 1) \lambda_4 + c_1) e^{\lambda_4 t}

    R   i   R  R  R  R  R  R  i   R  R‘  R  i   (   R£   R"   RF   R?   R.   R0   R!   (   RÇ   R  RÞ   Rú   R“   R  R5  RQ  RR  R  R  R  R  R  R  R  R‘  R  R­  RY  Rš  R›  R#  Rœ  R  (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyR‚  j  s     )    J“
²c      	   C  sË  t  | d d ƒ\ } } } } t d d t ƒ\ }	 }
 t sB t ‚ t d ƒ } t d d | | d g ƒ} t d	 d | | d g ƒ} t d
 d | | d g ƒ} t d d | | d g ƒ} | d j ƒ  \ } } | j | | | d | | | d j	 ƒ  ƒ } | | | d | | | | | } | | | } t
 | d | d ƒ } t
 | d | d ƒ } t
 | d | d ƒ } t t t |	 | ƒ | | ƒ | | | | | | | d d |	 | ƒ | |
 | ƒ ƒ t t |
 | ƒ | | ƒ | |	 | ƒ | | | | | | | d d |
 | ƒ ƒ g ƒ \ } } | j t t | ƒ ƒ j | t d | | ƒ ƒ } | j t t | ƒ ƒ j | t d | | ƒ ƒ } t |  | ƒ | ƒ t | | ƒ | ƒ g S(   s  
    The equation of this category are

    .. math:: (\alpha t^2 + \beta t + \gamma)^{2} x'' = ax + by

    .. math:: (\alpha t^2 + \beta t + \gamma)^{2} y'' = cx + dy

    The transformation

    .. math:: \tau = \int \frac{1}{\alpha t^2 + \beta t + \gamma} \,dt , u = \frac{x}{\sqrt{\left|\alpha t^2 + \beta t + \gamma\right|}} , v = \frac{y}{\sqrt{\left|\alpha t^2 + \beta t + \gamma\right|}}

    leads to a constant coefficient linear system of equations

    .. math:: u'' = (a - \alpha \gamma + \frac{1}{4} \beta^{2}) u + b v

    .. math:: v'' = c u + (d - \alpha \gamma + \frac{1}{4} \beta^{2}) v

    These system of equations obtained can be solved by type1 of System of two
    constant-coefficient second-order linear homogeneous differential equations.

    R   i   s   u, vR¯  Rv  R.  R§   i   R3  Rò   RÀ   R  R‘  R  R  i   (   R£   R%   R   R’   RÙ  R"   R#   Rš  RÝ   R   RG   Rî   R!   R   R  R4   RÚ  RÕ   R9   (   RÇ   R  RÞ   Rú   R“   R  R5  RQ  RR  R!  R   Rv  R.  R3  Rò   RÀ   R   RS  t   dict   eqzR  R  R  R—   t   msol1t   msol2R#  R  (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyRƒ  ¤  s(    1&Hv22c         C  s^  t  | d d ƒ\ } } } } t d d t ƒ\ }	 }
 | d } | d } | d } | d } t t t |	 | ƒ | ƒ | | |	 | ƒ | | |
 | ƒ ƒ t t |
 | ƒ | ƒ | | |	 | ƒ | | |
 | ƒ ƒ g ƒ \ } } | | | t | j | d	 | ƒ } | | | t | j | d	 | ƒ } t |  | ƒ | ƒ t | | ƒ | ƒ g S(
   sY  
    The equations which comes under this type are

    .. math:: x'' = f(t) (t x' - x) + g(t) (t y' - y)

    .. math:: y'' = h(t) (t x' - x) + p(t) (t y' - y)

    The transformation

    .. math:: u = t x' - x, v = t y' - y

    leads to the linear system of first-order equations

    .. math:: u' = t f(t) u + t g(t) v, v' = t h(t) u + t p(t) v

    On substituting the value of `u` and `v` in transformed equation gives value of `x` and `y` as

    .. math:: x = C_3 t + t \int \frac{u}{t^2} \,dt , y = C_4 t + t \int \frac{v}{t^2} \,dt.

    where `C_3` and `C_4` are arbitrary constants.

    R   i   s   u, vR¯  R  R‘  R  R  i   (   R£   R%   R   Rî   R!   R   R9   R  (   RÇ   R  RÞ   Rú   R“   R  R5  RQ  RR  R!  R   R¦   R1  R2  R.  R¢  R£  R#  R  (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyR„  Ï  s      ˆ&&c         C  s&  |  d d j  } |  d d j  } |  d d j  } |  d } |  d } |  d } t | d d ƒ\ } } }	 }
 t ƒ  } t t | d j t ƒ ƒ d j t ƒ ƒ d } xa t d	 ƒ D]S } d } x: t j	 | | ƒ D]% } | | | | | | d f 7} qÕ W| | | <qµ W| d | | ƒ d f | d | | ƒ d f | d
 <| d | | ƒ d f | d | | ƒ d f | d <| d | | ƒ d f | d | | ƒ d f | d <| d | | ƒ d f | d | | ƒ d f | d <| d | | ƒ d f | d | | ƒ d f | d <| d | | ƒ d f | d | | ƒ d f | d <| d | | ƒ d f | d | | ƒ d f | d <| d | | ƒ d f | d | | ƒ d f | d <| d | | ƒ d f | d | | ƒ d f | d <xh t d	 ƒ D]Z } xQ t j	 | | ƒ D]< } | j
 | | ƒ | | ƒ | | ƒ ƒ st d ƒ ‚ qqWqíW|  d d k ryt | | | | | | ƒ } n  |  d d k r§t | | | | | | ƒ } n  |  d d k rÕt | | | | | | ƒ } n  |  d d k rt | | | | | | ƒ } n  |  d d k r"t |  ƒ } n  | S(   NR”   i    i   i   R}  R“   R   i   i   R  R  R  R  R  R  R  R  R  sT   Only homogeneous problems are supported, non-homogenous are not supported currently.R¶   R“  R’  R”  R•  R—  (   R”   R£   RÂ   R±   R   R   R"   R   R   R™  R  RÑ   t   _linear_3eq_order1_type1t   _linear_3eq_order1_type2t   _linear_3eq_order1_type3t   _linear_3eq_order1_type4t   _linear_neq_order1_type1(   Ra  RÇ   R  R®  R”   Rœ  R“   R  R5  RQ  RR  Rú   RÞ   R¡   Ru  R#  Rv  Rä   (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt   sysode_linear_3eq_order1ï  sL    


	0#4 444 444 44'c         C  s@  t  | d d ƒ\ } } } }	 | d }
 | d } | d } | d } | d } | d } | t |
 | ƒ } | | t |
 | ƒ |
 | | t | | ƒ } | | | | |
 | t |
 | ƒ |
 | | | t | | ƒ | | | t | | ƒ } t |  | ƒ | ƒ t | | ƒ | ƒ t | | ƒ | ƒ g S(	   s\  
    .. math:: x' = ax

    .. math:: y' = bx + cy

    .. math:: z' = dx + ky + pz

    Solution of such equations are forward substitution. Solving first equations
    gives the value of `x`, substituting it in second and third equation and
    solving second equation gives `y` and similarly substituting `y` in third
    equation give `z`.

    .. math:: x = C_1 e^{at}

    .. math:: y = \frac{b C_1}{a - c} e^{at} + C_2 e^{ct}

    .. math:: z = \frac{C_1}{a - p} (d + \frac{bk}{a - c}) e^{at} + \frac{k C_2}{c - p} e^{ct} + C_3 e^{pt}

    where `C_1, C_2` and `C_3` are arbitrary constants.

    R   i   R  R  R  R  R  R  (   R£   R.   R!   (   RÇ   R  R®  RÞ   Rú   R“   R  R5  RQ  RR  R  R  R  R—   R  R.  R#  R  t   sol3(    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyR¤    s        2`c         C  sp  t  | d d d d ƒ\ } } } }	 | d }
 | d } | d } t |
 d | d | d ƒ } |
 | | | | }	 |
 | | | t | | ƒ | | | |	 t | | ƒ } | | | | t | | ƒ |
 |	 | | t | | ƒ } | | | |	 t | | ƒ | | |
 | t | | ƒ } t |  | ƒ | ƒ t | | ƒ | ƒ t | | ƒ | ƒ g S(	   sT  
    The equations of this type are

    .. math:: x' = cy - bz

    .. math:: y' = az - cx

    .. math:: z' = bx - ay

    1. First integral:

    .. math:: ax + by + cz = A             \qquad - (1)

    .. math:: x^2 + y^2 + z^2 = B^2        \qquad - (2)

    where `A` and `B` are arbitrary constants. It follows from these integrals
    that the integral lines are circles formed by the intersection of the planes
    `(1)` and sphere `(2)`

    2. Solution:

    .. math:: x = a C_0 + k C_1 \cos(kt) + (c C_2 - b C_3) \sin(kt)

    .. math:: y = b C_0 + k C_2 \cos(kt) + (a C_2 - c C_3) \sin(kt)

    .. math:: z = c C_0 + k C_3 \cos(kt) + (b C_2 - a C_3) \sin(kt)

    where `k = \sqrt{a^2 + b^2 + c^2}` and the four constants of integration,
    `C_1,...,C_4` are constrained by a single relation,

    .. math:: a C_1 + b C_2 + c C_3 = 0

    R   i   Rž   i    R  R  R  i   (   R£   R4   R-   R2   R!   (   RÇ   R  R®  RÞ   Rú   R“   R;  R  R5  RQ  R  R  R  R  R#  R  Rª  (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyR¥  6  s    "$   >>>c         C  s¯  t  | d d d d ƒ\ } } } }	 t | d | d ƒ }
 t | d | d ƒ } t | d | d ƒ } | d | | d | |
 d }	 t | d | d |
 d ƒ } | | | t | | ƒ | d	 | |
 | |	 t | | ƒ } | | | t | | ƒ | | d	 |
 |	 | t | | ƒ } | | |	 t | | ƒ | | |
 d	 | | t | | ƒ } t |  | ƒ | ƒ t | | ƒ | ƒ t | | ƒ | ƒ g S(
   sÎ  
    Equations of this system of ODEs

    .. math:: a x' = bc (y - z)

    .. math:: b y' = ac (z - x)

    .. math:: c z' = ab (x - y)

    1. First integral:

    .. math:: a^2 x + b^2 y + c^2 z = A

    where A is an arbitrary constant. It follows that the integral lines are plane curves.

    2. Solution:

    .. math:: x = C_0 + k C_1 \cos(kt) + a^{-1} bc (C_2 - C_3) \sin(kt)

    .. math:: y = C_0 + k C_2 \cos(kt) + a b^{-1} c (C_3 - C_1) \sin(kt)

    .. math:: z = C_0 + k C_3 \cos(kt) + ab c^{-1} (C_1 - C_2) \sin(kt)

    where `k = \sqrt{a^2 + b^2 + c^2}` and the four constants of integration,
    `C_1,...,C_4` are constrained by a single relation

    .. math:: a^2 C_1 + b^2 C_2 + c^2 C_3 = 0

    R   i   Rž   i    R  R  R  i   iÿÿÿÿ(   R£   R4   R-   R2   R!   (   RÇ   R  R®  RÞ   Rú   R“   R;  R  R5  RQ  R  R  R  R  R#  R  Rª  (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyR¦  a  s    $# BBBc         C  s‰  t  d d t ƒ\ } } } t | d | d ƒ j ƒ  \ }	 }
 t | d |	 ƒ } t | d | ƒ } t | d | ƒ } t | d | ƒ } t | d | ƒ } t | d	 | ƒ \ } } t | d
 | ƒ d } t | d | ƒ d } t | | ƒ | ƒ | | | ƒ |	 | | ƒ |
 | | ƒ t | | ƒ | ƒ | | | ƒ | | | ƒ | | | ƒ t | | ƒ | ƒ | | | ƒ | | | ƒ | | | ƒ f } t | ƒ } t t | | ƒ ƒ | d j	 j
 | t | | ƒ ƒ } t t | | ƒ ƒ | d j	 j
 | t | | ƒ ƒ } t t | | ƒ ƒ | d j	 j
 | t | | ƒ ƒ } t |  | ƒ | ƒ t | | ƒ | ƒ t | | ƒ | ƒ g S(   s!  
    Equations:

    .. math:: x' = (a_1 f(t) + g(t)) x + a_2 f(t) y + a_3 f(t) z

    .. math:: y' = b_1 f(t) x + (b_2 f(t) + g(t)) y + b_3 f(t) z

    .. math:: z' = c_1 f(t) x + c_2 f(t) y + (c_3 f(t) + g(t)) z

    The transformation

    .. math:: x = e^{\int g(t) \,dt} u, y = e^{\int g(t) \,dt} v, z = e^{\int g(t) \,dt} w, \tau = \int f(t) \,dt

    leads to the system of constant coefficient linear differential equations

    .. math:: u' = a_1 u + a_2 v + a_3 w

    .. math:: v' = b_1 u + b_2 v + b_3 w

    .. math:: w' = c_1 u + c_2 v + c_3 w

    These system of equations are solved by homogeneous linear system of constant
    coefficients of `n` equations of first order. Then substituting the value of
    `u, v` and `w` in transformed equation gives value of `x, y` and `z`.

    s   u, v, wR¯  R  R  R  R  R  R  R  R  i    R  i   i   (   R%   R   RG   Rš  RI   R   Rî   R.   R9   R  RÕ   R!   (   RÇ   R  R®  RÞ   Rú   R“   R!  R   Rt  R  R  R¦   R  R  R  R  R  R1  R  R  t   trans_eqRä   R#  R  Rª  (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyR§  Š  s"    $  <~555c         C  s   t  |  ƒ } | S(   N(   R¨  (   Ra  Rä   (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt   sysode_linear_neq_order1µ  s    c      	     s7  |  d } |  d ‰ |  d ‰  t  | ƒ ‰ t t | d j t ƒ ƒ d j t ƒ ƒ d ‰ t d d d t d d	 ƒ } t ˆ ˆ ‡  ‡ f d
 †  ƒ } | j d t ƒ } ‡ ‡ f d †  } ‡ ‡ f d †  } g  } t	 ˆ d	 ƒ } x| D]	}	 |	 d | k rå t  |	 d ƒ |	 d	 k rRt ˆ d	 d „  ƒ ‰ | |	 d t
 |	 d d j ƒ ˆ }
 g  t |	 d	 ƒ D] } d ^ qb} |	 d d | d <xÉ t d	 |	 d	 ƒ D]± } |
 | | d	 } t t | ƒ ˆ d	 ƒ ‰ ˆ d ˆ ˆ d <x4 ˆ j ƒ  D]& \ } } | j ˆ d d	 ƒ ˆ | <qêWt ˆ d	 ‡ ‡ f d †  ƒ | | <|	 d j | | ƒ qšWn  xit |	 d	 ƒ D]W} t | ƒ } xBt | d	 ƒ D]0} |	 d j t ƒ rtt |	 d | ƒ |	 d | <| | | |	 d | |	 d ƒ ˆ | | t t |	 d ƒ ˆ ƒ t | | ƒ 7} t | ƒ } | | | |	 d | |	 d ƒ ˆ | | t t |	 d ƒ ˆ ƒ t | | ƒ 7} q†| | |	 d | ˆ | | t |	 d ˆ ƒ t | | ƒ 7} q†WqcW|	 d j t ƒ rî| j t |	 d ƒ ƒ qîqå qå Wg  } x8 t t  | ƒ ƒ D]$ } | j t ˆ | | | ƒ ƒ qW| S(   s$  
    System of n first-order constant-coefficient linear nonhomogeneous differential equation

    .. math:: y'_k = a_{k1} y_1 + a_{k2} y_2 +...+ a_{kn} y_n; k = 1,2,...,n

    or that can be written as `\vec{y'} = A . \vec{y}`
    where `\vec{y}` is matrix of `y_k` for `k = 1,2,...n` and `A` is a `n \times n` matrix.

    Since these equations are equivalent to a first order homogeneous linear
    differential equation. So the general solution will contain `n` linearly
    independent parts and solution will consist some type of exponential
    functions. Assuming `y = \vec{v} e^{rt}` is a solution of the system where
    `\vec{v}` is a vector of coefficients of `y_1,...,y_n`. Substituting `y` and
    `y' = r v e^{r t}` into the equation `\vec{y'} = A . \vec{y}`, we get

    .. math:: r \vec{v} e^{rt} = A \vec{v} e^{rt}

    .. math:: r \vec{v} = A \vec{v}

    where `r` comes out to be eigenvalue of `A` and vector `\vec{v}` is the eigenvector
    of `A` corresponding to `r`. There are three possibilities of eigenvalues of `A`

    - `n` distinct real eigenvalues
    - complex conjugate eigenvalues
    - eigenvalues with multiplicity `k`

    1. When all eigenvalues `r_1,..,r_n` are distinct with `n` different eigenvectors
    `v_1,...v_n` then the solution is given by

    .. math:: \vec{y} = C_1 e^{r_1 t} \vec{v_1} + C_2 e^{r_2 t} \vec{v_2} +...+ C_n e^{r_n t} \vec{v_n}

    where `C_1,C_2,...,C_n` are arbitrary constants.

    2. When some eigenvalues are complex then in order to make the solution real,
    we take a linear combination: if `r = a + bi` has an eigenvector
    `\vec{v} = \vec{w_1} + i \vec{w_2}` then to obtain real-valued solutions to
    the system, replace the complex-valued solutions `e^{rx} \vec{v}`
    with real-valued solution `e^{ax} (\vec{w_1} \cos(bx) - \vec{w_2} \sin(bx))`
    and for `r = a - bi` replace the solution `e^{-r x} \vec{v}` with
    `e^{ax} (\vec{w_1} \sin(bx) + \vec{w_2} \cos(bx))`

    3. If some eigenvalues are repeated. Then we get fewer than `n` linearly
    independent eigenvectors, we miss some of the solutions and need to
    construct the missing ones. We do this via generalized eigenvectors, vectors
    which are not eigenvectors but are close enough that we can use to write
    down the remaining solutions. For a eigenvalue `r` with eigenvector `\vec{w}`
    we obtain `\vec{w_2},...,\vec{w_k}` using

    .. math:: (A - r I) . \vec{w_2} = \vec{w}

    .. math:: (A - r I) . \vec{w_3} = \vec{w_2}

    .. math:: \vdots

    .. math:: (A - r I) . \vec{w_k} = \vec{w_{k-1}}

    Then the solutions to the system for the eigenspace are `e^{rt} [\vec{w}],
    e^{rt} [t \vec{w} + \vec{w_2}], e^{rt} [\frac{t^2}{2} \vec{w} + t \vec{w_2} + \vec{w_3}],
    ...,e^{rt} [\frac{t^{k-1}}{(k-1)!} \vec{w} + \frac{t^{k-2}}{(k-2)!} \vec{w_2} +...+ t \vec{w_{k-1}}
    + \vec{w_k}]`

    So, If `\vec{y_1},...,\vec{y_n}` are `n` solution of obtained from three
    categories of `A`, then general solution to the system `\vec{y'} = A . \vec{y}`

    .. math:: \vec{y} = C_1 \vec{y_1} + C_2 \vec{y_2} + \cdots + C_n \vec{y_n}

    R“   R”   R}  i    RŸ   R™   R¯  Rž   i   c           s   ˆ  |  ˆ | d f S(   Ni    (    (   R¡   Rv  (   Rœ  R”   (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyRÈ      Rô   RP   c           s   t  ˆ d ‡  ‡ ‡ f d †  ƒ S(   Ni   c           sD   t  ˆ  |  ƒ t t ˆ ƒ ˆ ƒ t ˆ  |  ƒ t t ˆ ƒ ˆ ƒ S(   N(   R1   R-   R/   R2   (   R¡   Rv  (   t   matRš  RÞ   (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyRÈ      Rô   (   R<   (   R­  Rš  (   RÀ   RÞ   (   R­  Rš  s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt
   is_complex   s    c           s   t  ˆ d ‡  ‡ ‡ f d †  ƒ S(   Ni   c           sd   t  ˆ  |  ƒ t t t ˆ ƒ ƒ ˆ ƒ t ˆ  |  ƒ t t ˆ ƒ ˆ ƒ t t ˆ ƒ ƒ t ˆ ƒ S(   N(   R1   R2   RÚ  R/   R-   (   R¡   Rv  (   R­  Rš  RÞ   (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyRÈ      Rô   (   R<   (   R­  Rš  (   RÀ   RÞ   (   R­  Rš  s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt   is_complex_conjugate   s    i   c         S  s   t  d t |  ƒ ƒ S(   NRÇ   (   R"   R¤   (   R¡   Rv  (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyRÈ      Rô   iÿÿÿÿc           s   ˆ  ˆ |  S(   N(    (   R¡   Rv  (   t   sol_dictt   var_mat(    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyRÈ      Rô   (   RÌ   R±   R   R   R"   RX   R<   t
   eigenvectsRÒ   R>   R=   t   rowsR   RV   Rþ   RÕ   Rù   R›   R  R   RP   R.   R1   R8   R6   R!   (   Ra  R“   Râ   t   Mt   evectorR®  R¯  t   conjugate_roott   e_vectort   evectst   MnewR¡   Rt  Rú   t   w_RÄ   R
  R™   Rv  Rä   (    (   Rœ  R”   RÀ   R°  RÞ   R±  s0   lib/python2.7/site-packages/sympy/solvers/ode.pyR¨  ¹  sT    D


0'#"UXJ!"c         C  s–  |  d } |  d } |  d } t  t  | d j t ƒ ƒ d j t ƒ ƒ d } |  d d k rt t | | | ƒ } | S| d j } | d j } xa t d ƒ D]S } d }	 x: t j | | ƒ D]% }
 |	 |
 | | | | d f 7}	 q» W|	 | | <q› W|  d d	 k rt	 | | | | ƒ } nx |  d d
 k rBt
 | | | | ƒ } nP |  d d k rjt | | | | ƒ } n( |  d d k r’t | | | | ƒ } n  | S(   NR”   R“   R}  i    R¶   R–  i   i   R“  R’  R”  R•  (   R±   R   R   R"   t   _nonlinear_2eq_order1_type5R”   R   R   R™  t   _nonlinear_2eq_order1_type1t   _nonlinear_2eq_order1_type2t   _nonlinear_2eq_order1_type3t   _nonlinear_2eq_order1_type4(   Ra  R”   R“   Rœ  RÞ   Rä   RÇ   R  R¡   Ru  R#  (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt   sysode_nonlinear_2eq_order1-   s.    


0#c         C  sù  t  | d d ƒ\ } } t d d |  | ƒ | | ƒ g ƒ} t d ƒ } t d ƒ \ } }	 | d j t |  | ƒ | ƒ |  | ƒ | | ƒ }
 t | | ƒ | ƒ | d |
 | j | | ƒ |	 ƒ } |
 | j |  | ƒ | ƒ j | | ƒ |	 ƒ } |
 | } | d k r7| d | t d | |	 ƒ d d | } n | t t d | |	 ƒ ƒ } | j ƒ  } t	 t d | | j | | ƒ |	 ƒ j ƒ  | | |	 ƒ } g  } xR | D]J } | j
 t |  | ƒ | j |	 | ƒ ƒ ƒ | j
 t | | ƒ | ƒ ƒ q§W| S(	   s¡  
    Equations:

    .. math:: x' = x^n F(x,y)

    .. math:: y' = g(y) F(x,y)

    Solution:

    .. math:: x = \varphi(y), \int \frac{1}{g(y) F(\varphi(y),y)} \,dy = t + C_2

    where

    if `n \neq 1`

    .. math:: \varphi = [C_1 + (1-n) \int \frac{1}{g(y)} \,dy]^{\frac{1}{1-n}}

    if `n = 1`

    .. math:: \varphi = C_1 e^{\int \frac{1}{g(y)} \,dy}

    where `C_1` and `C_2` are arbitrary constants.

    R   i   RÀ   R§   R¦   s   u, vi    i   (   R£   R#   R%   RÝ   R   RÕ   R9   R.   R‘   RV   Rù   R!   (   RÇ   R  RÞ   R“   R  R5  RÀ   R¦   R!  R   Rú   R1  Rb  R¶  R  Rä   Rá   (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyR¼  F   s$    $47.
.:( c         C  sñ  t  | d d ƒ\ } } t d d |  | ƒ | | ƒ g ƒ} t d ƒ } t d ƒ \ } }	 | d j t |  | ƒ | ƒ t | |  | ƒ ƒ | ƒ }
 t | | ƒ | ƒ | d |
 | j | | ƒ |	 ƒ } |
 | j |  | ƒ | ƒ j | | ƒ |	 ƒ } |
 | } | r5d	 | t | | t d | |	 ƒ ƒ } n | t d | |	 ƒ } | j	 ƒ  } t
 t d | | j | | ƒ |	 ƒ j	 ƒ  | | |	 ƒ } g  } xR | D]J } | j t |  | ƒ | j |	 | ƒ ƒ ƒ | j t | | ƒ | ƒ ƒ qŸW| S(
   s½  
    Equations:

    .. math:: x' = e^{\lambda x} F(x,y)

    .. math:: y' = g(y) F(x,y)

    Solution:

    .. math:: x = \varphi(y), \int \frac{1}{g(y) F(\varphi(y),y)} \,dy = t + C_2

    where

    if `\lambda \neq 0`

    .. math:: \varphi = -\frac{1}{\lambda} log(C_1 - \lambda \int \frac{1}{g(y)} \,dy)

    if `\lambda = 0`

    .. math:: \varphi = C_1 + \int \frac{1}{g(y)} \,dy

    where `C_1` and `C_2` are arbitrary constants.

    R   i   RÀ   R§   R¦   s   u, vi    i   iÿÿÿÿ(   R£   R#   R%   RÝ   R   R.   RÕ   R0   R9   R‘   RV   Rù   R!   (   RÇ   R  RÞ   R“   R  R5  RÀ   R¦   R!  R   Rú   R1  Rb  R¶  R  Rä   Rá   (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyR½  s   s$    $:7.
,:( c         C  sÜ  t  | d d ƒ\ } } } } t d ƒ } t d ƒ }	 t d ƒ }
 t d ƒ } | d j t |  | ƒ | ƒ |
 ƒ } | d j t | | ƒ | ƒ | ƒ } | |
 j |  | ƒ |	 ƒ j | | ƒ | |	 ƒ ƒ } | | j |  | ƒ |	 ƒ j | | ƒ | |	 ƒ ƒ } t t t | |	 ƒ |	 ƒ | | ƒ ƒ } xM | D]E } t	 t
 d | j | |	 ƒ | j ƒ |	 ƒ j ƒ  | | |	 ƒ } q1Wg  } xU | D]M } | j t |  | ƒ | ƒ ƒ | j t | | ƒ | j j |	 | ƒ ƒ ƒ q‡W| S(	   sŒ  
    Autonomous system of general form

    .. math:: x' = F(x,y)

    .. math:: y' = G(x,y)

    Assuming `y = y(x, C_1)` where `C_1` is an arbitrary constant is the general
    solution of the first-order equation

    .. math:: F(x,y) y'_x = G(x,y)

    Then the general solution of the original system of equations has the form

    .. math:: \int \frac{1}{F(x,y(x,C_1))} \,dx = t + C_1

    R   i   R   R!  R¦   R1  i    i   (   R£   R   R"   R#   RÝ   R   RÕ   Rî   R!   RV   R9   R  R‘   Rù   (   RÇ   R  RÞ   R“   R  R5  RQ  RR  R   R!  R¦   R1  R]  Re  Rb  Ru  t   sol2rt   sol2sR#  Rä   Rá   (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyR¾      s"    &&44(C/c         C  s´  t  | d d ƒ\ } } t d ƒ \ } } t d d t ƒ\ } }	 t d ƒ }
 t d ƒ } t d d	 | | g ƒ} t d
 d	 | | g ƒ} t d d	 | | g ƒ} t d d	 | | g ƒ} | d j t |  | ƒ | ƒ |
 ƒ } | d j t | | ƒ | ƒ | ƒ } | |
 j |  | ƒ | ƒ j | | ƒ | ƒ | | j |  | ƒ | ƒ j | | ƒ | ƒ j ƒ  \ } } | j | | ƒ } | j | | ƒ } | |
 j |  | ƒ | ƒ j | | ƒ | ƒ | } | | } | | } | | } | | } t t	 | | | ƒ j
 ƒ  t	 | | | ƒ j
 ƒ  | | ƒ } t t	 | | | ƒ j
 ƒ  t	 | | | ƒ j
 ƒ  | | ƒ } g  } xœ | D]” } | j t | | ƒ t t |	 | ƒ | ƒ | j | | ƒ j | |	 | ƒ ƒ | j | |	 | ƒ ƒ | j | | ƒ j | |	 | ƒ ƒ ƒ j ƒ ƒ qsWxœ | D]” } | j t |  | ƒ t t | | ƒ | ƒ | j | | | ƒ ƒ | j | | ƒ j | | | ƒ ƒ | j | | ƒ j | | | ƒ ƒ ƒ j ƒ ƒ qWt | ƒ S(   sé  
    Equation:

    .. math:: x' = f_1(x) g_1(y) \phi(x,y,t)

    .. math:: y' = f_2(x) g_2(y) \phi(x,y,t)

    First integral:

    .. math:: \int \frac{f_2(x)}{f_1(x)} \,dx - \int \frac{g_1(y)}{g_2(y)} \,dy = C

    where `C` is an arbitrary constant.

    On solving the first integral for `x` (resp., `y` ) and on substituting the
    resulting expression into either equation of the original solution, one
    arrives at a first-order equation for determining `y` (resp., `x` ).

    R   i   s   u, vs   U, VR¯  R¦   R1  R£  R§   R¤  R±  R²  i    i   (   R£   R%   R   R#   RÝ   R   RÕ   Rš  RV   R9   R‘   Rù   R!   Rî   R  Rª   (   RÇ   R  RÞ   R“   R  R5  R!  R   t   Ut   VR¦   R1  R£  R¤  R±  R²  R]  Re  R   RS  R´  Rµ  R¶  R¸  R¹  t   G1t   G2t   sol1rRÁ  Rä   Rá   (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyR¿  Ä   s8    &&+;2
 

 
==’’c           sm  t  ˆ  d d ƒ\ } } t d ƒ ‰ t d ƒ ‰ ‡  ‡ ‡ ‡ f d †  } xˆ |  D]€ } t | t ƒ rO |  d d j } |  d d j } | | | ƒ \ }	 }
 |	 o¤ |
 sÏ | | | ƒ \ }	 }
 | | } } qÏ qO qO Wt | ˆ ƒ ˆ ƒ } t | ˆ ƒ ˆ ƒ } t | ˆ ƒ | ˆ |	 ˆ j | | ƒ j | | ƒ ƒ t | ˆ ƒ | ˆ |
 ˆ j | | ƒ j | | ƒ ƒ h S(   s¸  
    Clairaut system of ODEs

    .. math:: x = t x' + F(x',y')

    .. math:: y = t y' + G(x',y')

    The following are solutions of the system

    `(i)` straight lines:

    .. math:: x = C_1 t + F(C_1, C_2), y = C_2 t + G(C_1, C_2)

    where `C_1` and `C_2` are arbitrary constants;

    `(ii)` envelopes of the above lines;

    `(iii)` continuously differentiable lines made up from segments of the lines
    `(i)` and `(ii)`.

    R   i   R¦   R1  c           së  ˆ  d j  ˆ t |  ˆ ƒ ˆ ƒ |  ˆ ƒ ˆ ƒ } ˆ  d j  ˆ t | ˆ ƒ ˆ ƒ | ˆ ƒ ˆ ƒ } | oq | sç ˆ  d j  t |  ˆ ƒ ˆ ƒ |  ˆ ƒ ˆ ˆ ˆ ƒ } ˆ  d j  t | ˆ ƒ ˆ ƒ | ˆ ƒ ˆ ˆ ˆ ƒ } n  | oð | s`ˆ  d j  ˆ t |  ˆ ƒ ˆ ƒ |  ˆ ƒ ˆ ƒ } ˆ  d j  ˆ t | ˆ ƒ ˆ ƒ | ˆ ƒ ˆ ƒ } n  | oi| sáˆ  d j  t |  ˆ ƒ ˆ ƒ |  ˆ ƒ ˆ ˆ ˆ ƒ } ˆ  d j  t | ˆ ƒ ˆ ƒ | ˆ ƒ ˆ ˆ ˆ ƒ } n  | | g S(   Ni    i   (   RÝ   R   (   RÇ   R  R]  Re  (   R“   R¦   R1  RÞ   (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyR°  !  s    448;589<i    i   (   R£   R#   R¨   R±   R”   R   R!   RÕ   (   R”   RÞ   R“   R  R5  R°  Rß   RÇ   R  R]  Re  t   x1t   y1(    (   R“   R¦   R1  RÞ   s0   lib/python2.7/site-packages/sympy/solvers/ode.pyR»  ó   s     c   	      C  s\  |  d d j  } |  d d j  } |  d d j  } |  d } |  d } |  d } t t | d j t ƒ ƒ d j t ƒ ƒ d } |  d d k r¬ t | | | | | ƒ } n  |  d d	 k r× t | | | | | ƒ } n  |  d d
 k rt | | | | | ƒ } n  |  d d k r-t | | | | | ƒ } n  |  d d k rXt	 | | | | | ƒ } n  | S(   NR”   i    i   i   R“   R}  R¶   R“  R’  R”  R•  R–  (
   R”   R±   R   R   R"   t   _nonlinear_3eq_order1_type1t   _nonlinear_3eq_order1_type2t   _nonlinear_3eq_order1_type3t   _nonlinear_3eq_order1_type4t   _nonlinear_3eq_order1_type5(	   Ra  RÇ   R  R®  R“   Rœ  R”   RÞ   Rä   (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt   sysode_nonlinear_3eq_order1$!  s$    


0c   "      C  sv  t  | d d ƒ\ } } t d ƒ \ } } }	 t d d |  | ƒ | | ƒ | | ƒ | g ƒ}
 t d d |  | ƒ | | ƒ | | ƒ | g ƒ} t d d |  | ƒ | | ƒ | | ƒ | g ƒ} t |  | ƒ | ƒ | d j |
 | | ƒ | | ƒ ƒ } | j t | | ƒ | ƒ | d	 j | | | ƒ |  | ƒ ƒ ƒ | j t | | ƒ | ƒ | d j | |  | ƒ | | ƒ ƒ ƒ | |
 j ƒ  \ } } | | j ƒ  \ } } | | j ƒ  \ } } t | | | | | |	 | | | | | |	 | | | | | |	 g | | g ƒ } | | | | g } t | d j ƒ  d	 | d	 j ƒ  d	 ƒ } | d j	 |	 | ƒ } | d	 j	 |	 | ƒ } t
 | | | | | | |  | ƒ d | | | ƒ } t
 | | | | | | |  | ƒ d | | | ƒ } t
 | | | | | | | | ƒ d | | | ƒ } t
 | | | | | | | | ƒ d | | | ƒ } t
 | | | | | | | | ƒ d | | | ƒ } t
 | | | | | | | | ƒ d | | | ƒ } t | t |  | ƒ | ƒ | | | | ƒ } t | t | | ƒ | ƒ | | | | ƒ }  t | t | | ƒ | ƒ | | | | ƒ }! | |  |! g S(
   s±  
    Equations:

    .. math:: a x' = (b - c) y z, \enspace b y' = (c - a) z x, \enspace c z' = (a - b) x y

    First Integrals:

    .. math:: a x^{2} + b y^{2} + c z^{2} = C_1

    .. math:: a^{2} x^{2} + b^{2} y^{2} + c^{2} z^{2} = C_2

    where `C_1` and `C_2` are arbitrary constants. On solving the integrals for `y` and
    `z` and on substituting the resulting expressions into the first equation of the
    system, we arrives at a separable first-order equation on `x`. Similarly doing that
    for other two equations, we will arrive at first order equation on `y` and `z` too.

    References
    ==========
    -http://eqworld.ipmnet.ru/en/solutions/sysode/sode0401.pdf

    R   i   s   u, v, wR.  R§   R3  Rò   i    i   (   R£   R%   R#   R   RÝ   RÛ   Rš  RV   RD   RÕ   R4   Rî   ("   RÇ   R  R®  RÞ   R“   R  R5  R!  R   Rt  R.  R3  Rò   Rú   t   n1R‘  t   n2R  t   n3R¬  R  t   valsR  R  R  t   y_xt   z_xt   z_yt   x_yt   x_zt   y_zR#  R  Rª  (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyRÊ  8!  s4    000:AAZ+::::::///c   $      C  sÈ  t  | d d ƒ\ } } t d ƒ \ } } }	 t d d |  | ƒ | | ƒ | | ƒ | g ƒ}
 t d d |  | ƒ | | ƒ | | ƒ | g ƒ} t d d |  | ƒ | | ƒ | | ƒ | g ƒ} t d ƒ } t |  | ƒ | ƒ | d	 j | | ƒ | | ƒ | ƒ } t | | ƒ j |
 | ƒ } | j t | | ƒ | ƒ | d
 | | j | | | ƒ |  | ƒ ƒ ƒ | j t | | ƒ | ƒ | d | | j | |  | ƒ | | ƒ ƒ ƒ | |
 j ƒ  \ } } | | j ƒ  \ } } | | j ƒ  \ } } t | | | | | |	 | | | | | |	 | | | | | |	 g | | g ƒ } | | | | g } t	 | d	 j ƒ  d
 | d
 j ƒ  d
 ƒ } | d	 j
 |	 | ƒ } | d
 j
 |	 | ƒ } t | | | | | | |  | ƒ d | | | ƒ } t | | | | | | |  | ƒ d | | | ƒ } t | | | | | | | | ƒ d | | | ƒ } t | | | | | | | | ƒ d | | | ƒ } t | | | | | | | | ƒ d | | | ƒ } t | | | | | | | | ƒ d | | | ƒ }  t | t |  | ƒ | ƒ | | | | | | ƒ }! t | t | | ƒ | ƒ | | | | | | ƒ }" t | t | | ƒ | ƒ | | | |  | | ƒ }# |! |" |# g S(   sä  
    Equations:

    .. math:: a x' = (b - c) y z f(x, y, z, t)

    .. math:: b y' = (c - a) z x f(x, y, z, t)

    .. math:: c z' = (a - b) x y f(x, y, z, t)

    First Integrals:

    .. math:: a x^{2} + b y^{2} + c z^{2} = C_1

    .. math:: a^{2} x^{2} + b^{2} y^{2} + c^{2} z^{2} = C_2

    where `C_1` and `C_2` are arbitrary constants. On solving the integrals for `y` and
    `z` and on substituting the resulting expressions into the first equation of the
    system, we arrives at a first-order differential equations on `x`. Similarly doing
    that for other two equations we will arrive at first order equation on `y` and `z`.

    References
    ==========
    -http://eqworld.ipmnet.ru/en/solutions/sysode/sode0402.pdf

    R   i   s   u, v, wR.  R§   R3  Rò   R¦   i    i   (   R£   R%   R#   R   RÝ   RU   RÛ   Rš  RV   RD   RÕ   R4   Rî   ($   RÇ   R  R®  RÞ   R“   R  R5  R!  R   Rt  R.  R3  Rò   R¦   R]  Rú   RÐ  R‘  RÑ  R  RÒ  R¬  R  RÓ  R  R  R  RÔ  RÕ  RÖ  R×  RØ  RÙ  R#  R  Rª  (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyRË  j!  s8    000:II[+::::::777c          C  sU  t  | d d ƒ} t d ƒ \ } } } t d d |  | ƒ | | ƒ | | ƒ | g ƒ}	 t d d |  | ƒ | | ƒ | | ƒ | g ƒ}
 t d d |  | ƒ | | ƒ | | ƒ | g ƒ} t d d	 t ƒ\ } } } t |  | ƒ | ƒ | d
 j | | ƒ } t | | ƒ j | | ƒ } | j t | | ƒ j |
 | ƒ ƒ | d j | | ƒ r«| d j | | ƒ r«| | | | | | <| | <| |
 | | | | <| |
 <n  | j t | | ƒ | ƒ | d j |	 | | | | | ƒ ƒ | |	 } | |
 } | | } | | j |  | ƒ | ƒ j | | ƒ | ƒ j | | ƒ | ƒ } | | j |  | ƒ | ƒ j | | ƒ | ƒ j | | ƒ | ƒ } | | j |  | ƒ | ƒ j | | ƒ | ƒ j | | ƒ | ƒ } | | | | | | } | | | | | | } | | | | | | } t	 t | | ƒ | ƒ | | | | | | | | j | | ƒ j | | | ƒ ƒ ƒ j
 } t	 t | | ƒ | ƒ | | | | | | | | j | | ƒ j | | | ƒ ƒ ƒ j
 } t	 t | | ƒ | ƒ | | | | | | | | j | | ƒ j | | | ƒ ƒ ƒ j
 } t	 t | | ƒ | ƒ | | | | | | | | j | | ƒ j | | | ƒ ƒ ƒ j
 } t	 t | | ƒ | ƒ | | | | | | | | j | | ƒ j | | | ƒ ƒ ƒ j
 } t	 t | | ƒ | ƒ | | | | | | | | j | | ƒ j | | | ƒ ƒ ƒ j
 } t	 t | | ƒ | ƒ | | | | j | | ƒ j | | ƒ j | | | ƒ ƒ ƒ j
 } t	 t | | ƒ | ƒ | | | | j | | ƒ j | | ƒ j | | | ƒ ƒ ƒ j
 } t	 t | | ƒ | ƒ | | | | j | | ƒ j | | ƒ j | | | ƒ ƒ ƒ j
 } | | | g S(   sØ  
    Equations:

    .. math:: x' = c F_2 - b F_3, \enspace y' = a F_3 - c F_1, \enspace z' = b F_1 - a F_2

    where `F_n = F_n(x, y, z, t)`.

    1. First Integral:

    .. math:: a x + b y + c z = C_1,

    where C is an arbitrary constant.

    2. If we assume function `F_n` to be independent of `t`,i.e, `F_n` = `F_n (x, y, z)`
    Then, on eliminating `t` and `z` from the first two equation of the system, one
    arrives at the first-order equation

    .. math:: \frac{dy}{dx} = \frac{a F_3 (x, y, z) - c F_1 (x, y, z)}{c F_2 (x, y, z) -
                b F_3 (x, y, z)}

    where `z = \frac{1}{c} (C_1 - a x - b y)`

    References
    ==========
    -http://eqworld.ipmnet.ru/en/solutions/sysode/sode0404.pdf

    R   i   s   u, v, wR.  R§   R3  Rò   s
   F1, F2, F3R¯  i    (   R£   R%   R#   R   RÝ   RU   RÛ   R  RÕ   Rî   R  (    RÇ   R  R®  RÞ   R“   R  R!  R   Rt  R.  R3  Rò   R¸  R¹  Rº  R]  Rú   R  R  R  t   z_xyt   y_zxt   x_yzRÔ  RÕ  RÖ  R×  RÙ  RØ  R#  R  Rª  (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyRÌ  ¡!  s@    000*$/"A
 
 
@@@\\\\\\XXXc          C  s  t  | d d ƒ} t d ƒ \ } } } t d d |  | ƒ | | ƒ | | ƒ | g ƒ}	 t d d |  | ƒ | | ƒ | | ƒ | g ƒ}
 t d d |  | ƒ | | ƒ | | ƒ | g ƒ} t d d	 t ƒ\ } } } | d
 j t |  | ƒ | ƒ | | ƒ | | | ƒ | ƒ } t | | ƒ j | | ƒ } | j t | | ƒ j |
 | ƒ ƒ | d j | | ƒ r¿| d j | | ƒ r¿| | | | | | <| | <| |
 | | | | <| |
 <n  | j t | | ƒ | ƒ | d j |	 |  | ƒ | | | | | | ƒ | ƒ ƒ | |	 } | |
 } | | } | | j |  | ƒ | ƒ j | | ƒ | ƒ j | | ƒ | ƒ } | | j |  | ƒ | ƒ j | | ƒ | ƒ j | | ƒ | ƒ } | | j |  | ƒ | ƒ j | | ƒ | ƒ j | | ƒ | ƒ } t	 | | | d | | d | ƒ } t	 | | | d | | d | ƒ } t	 | | | d | | d | ƒ } t
 t | | ƒ | ƒ | | | | | | | | | | | | j | | ƒ j | | | ƒ ƒ ƒ j } t
 t | | ƒ | ƒ | | | | | | | | | | | | j | | ƒ j | | | ƒ ƒ ƒ j } t
 t | | ƒ | ƒ | | | | | | | | | | | | j | | ƒ j | | | ƒ ƒ ƒ j } t
 t | | ƒ | ƒ | | | | | | | | | | | | j | | ƒ j | | | ƒ ƒ ƒ j } t
 t | | ƒ | ƒ | | | | | | | | | | | | j | | ƒ j | | | ƒ ƒ ƒ j } t
 t | | ƒ | ƒ | | | | | | | | | | | | j | | ƒ j | | | ƒ ƒ ƒ j } t
 t | | ƒ | ƒ | | | | | | j | | ƒ j | | ƒ j | | | ƒ ƒ ƒ j } t
 t | | ƒ | ƒ | | | | | | j | | ƒ j | | ƒ j | | | ƒ ƒ ƒ j } t
 t | | ƒ | ƒ | | | | | | j | | ƒ j | | ƒ j | | | ƒ ƒ ƒ j } | | | g S(   s  
    Equations:

    .. math:: x' = c z F_2 - b y F_3, \enspace y' = a x F_3 - c z F_1, \enspace z' = b y F_1 - a x F_2

    where `F_n = F_n (x, y, z, t)`

    1. First integral:

    .. math:: a x^{2} + b y^{2} + c z^{2} = C_1

    where `C` is an arbitrary constant.

    2. Assuming the function `F_n` is independent of `t`: `F_n = F_n (x, y, z)`. Then on
    eliminating `t` and `z` from the first two equations of the system, one arrives at
    the first-order equation

    .. math:: \frac{dy}{dx} = \frac{a x F_3 (x, y, z) - c z F_1 (x, y, z)}
                {c z F_2 (x, y, z) - b y F_3 (x, y, z)}

    where `z = \pm \sqrt{\frac{1}{c} (C_1 - a x^{2} - b y^{2})}`

    References
    ==========
    -http://eqworld.ipmnet.ru/en/solutions/sysode/sode0405.pdf

    R   i   s   u, v, wR.  R§   R3  Rò   s
   F1, F2, F3R¯  i    i   (   R£   R%   R#   RÝ   R   RU   RÛ   R  RÕ   R4   Rî   R  (    RÇ   R  R®  RÞ   R“   R  R!  R   Rt  R.  R3  Rò   R¸  R¹  Rº  R]  Rú   R  R  R  RÜ  RÛ  RÚ  RÔ  RÕ  RÖ  R×  RÙ  RØ  R#  R  Rª  (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyRÍ  Ü!  s@    000>$/"U
 
 
@@@(((llllll```c         C  s®  t  | d d ƒ} t d ƒ \ } } } t d d |  | ƒ | | ƒ t | ƒ | g ƒ} t d d |  | ƒ | | ƒ t | ƒ | g ƒ}	 t d d |  | ƒ | | ƒ t | ƒ | g ƒ}
 t d d	 t ƒ\ } } } | d
 j t |  | ƒ | ƒ |  | ƒ | | ƒ } t | | ƒ j |
 | ƒ } | j t | | ƒ j |	 | ƒ ƒ | d j | | ƒ rµ| d j | | ƒ rµ| | | | | | <| | <| |	 | |
 | |
 <| |	 <n  | j t | | ƒ | ƒ | d j | | ƒ | | | | | | ƒ ƒ | | } | |	 } | |
 } | | j	 |  | ƒ | ƒ j	 | | ƒ | ƒ j	 t | ƒ | ƒ } | | j	 |  | ƒ | ƒ j	 | | ƒ | ƒ j	 t | ƒ | ƒ } | | j	 |  | ƒ | ƒ j	 | | ƒ | ƒ j	 t | ƒ | ƒ } | | | | | | } | | | | | | } | | | | | | } t
 t | | ƒ | ƒ | | | | | | | | | | j	 | | ƒ j	 | | | ƒ ƒ ƒ j } t
 t | | ƒ | ƒ | | | | | | | | | | j	 | | ƒ j	 | | | ƒ ƒ ƒ j } t
 t | | ƒ | ƒ | | | | | | | | | | j	 | | ƒ j	 | | | ƒ ƒ ƒ j } t
 t | | ƒ | ƒ | | | | | | | | | | j	 | | ƒ j	 | | | ƒ ƒ ƒ j } t
 t | | ƒ | ƒ | | | | | | | | | | j	 | | ƒ j	 | | | ƒ ƒ ƒ j } t
 t | | ƒ | ƒ | | | | | | | | | | j	 | | ƒ j	 | | | ƒ ƒ ƒ j } t
 t | | ƒ | ƒ | | | | | j	 | | ƒ j	 | | ƒ j	 | | | ƒ ƒ ƒ j } t
 t | | ƒ | ƒ | | | | | j	 | | ƒ j	 | | ƒ j	 | | | ƒ ƒ ƒ j } t
 t | | ƒ | ƒ | | | | | j	 | | ƒ j	 | | ƒ j	 | | | ƒ ƒ ƒ j } | | | g S(   sA  
    .. math:: x' = x (c F_2 - b F_3), \enspace y' = y (a F_3 - c F_1), \enspace z' = z (b F_1 - a F_2)

    where `F_n = F_n (x, y, z, t)` and are arbitrary functions.

    First Integral:

    .. math:: \left|x\right|^{a} \left|y\right|^{b} \left|z\right|^{c} = C_1

    where `C` is an arbitrary constant. If the function `F_n` is independent of `t`,
    then, by eliminating `t` and `z` from the first two equations of the system, one
    arrives at a first-order equation.

    References
    ==========
    -http://eqworld.ipmnet.ru/en/solutions/sysode/sode0406.pdf

    R   i   s   u, v, wR.  R§   R3  Rò   s
   F1, F2, F3R¯  i    (   R£   R%   R#   R®  RÝ   R   RU   RÛ   R  RÕ   Rî   R  (   RÇ   R  RÞ   R“   R  R!  R   Rt  R.  R3  Rò   R¸  R¹  Rº  R]  Rú   R  R  R  RÜ  RÛ  RÚ  RÔ  RÕ  RÖ  R×  RÙ  RØ  R#  R  Rª  (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyRÎ  "  s@    0004$/"K
 
 
@@@dddddd\\\N(ó   t   __doc__t
   __future__R    R   t   collectionsR   t	   itertoolsR   t	   functoolsR   t
   sympy.coreR   R   R   R   R	   t   sympy.core.compatibilityR
   R   R   R   R   t   sympy.core.containersR   t   sympy.core.exprtoolsR   t   sympy.core.exprR   R   t   sympy.core.functionR   R   R   R   R   R   R   R   t   sympy.core.multidimensionalR   t   sympy.core.numbersR   R   R   R   t   sympy.core.relationalR    R!   t   sympy.core.symbolR"   R#   R$   R%   t   sympy.core.sympifyR&   t   sympy.logic.boolalgR'   R(   R)   R*   R+   R,   t   sympy.functionsR-   R.   R/   R0   R1   R2   R3   R4   R5   R6   R7   t(   sympy.functions.combinatorial.factorialsR8   t   sympy.integrals.integralsR9   R:   t   sympy.matricesR;   R<   R=   R>   t   sympy.polysR?   R@   RA   RB   RC   RD   RE   t   sympy.polys.polyrootsRF   t   sympy.polys.polytoolsRG   RH   RI   t   sympy.seriesRJ   t   sympy.series.seriesRK   t   sympy.simplifyRL   RM   RN   RO   RP   RQ   RR   RS   t   sympy.simplify.powsimpRT   t   sympy.simplify.radsimpRU   t   sympy.solversRV   t   sympy.solvers.pdeRW   t   sympy.utilitiesRX   RY   RZ   t   sympy.solvers.deutilsR[   R\   R]   RI  RÛ  R˜   R£   Rš   RÐ   RÒ   Rî   RØ   RÔ   R’   R×   RË   R  R€  R  R‚  Rƒ  R·  R„  RÁ  RÈ  R÷   Rå  RÆ   Rô  Rü  RÔ  RÛ  Rø   R   R$  R"  R!  R@  R1  R2  R4  R6  RR  R^  RT  RD  Rr  RE  R„  Rƒ  R…  RF  R   R£  R§  R¨  RA  R­  R°  Rµ  R»  R¢  R¼  RH  RÏ  R¥  R®  RÙ  Rð  RÜ  RÓ  R  R  R  R+  R.  R7  RD  RN  RX  Rb  RZ  R[  R\  R]  R^  R_  R`  R…  Rz  R{  R|  R}  R~  R  R€  R  R‚  Rƒ  R„  R©  R¤  R¥  R¦  R§  R¬  R¨  RÀ  R¼  R½  R¾  R¿  R»  RÏ  RÊ  RË  RÌ  RÍ  RÎ  (    (    (    s0   lib/python2.7/site-packages/sympy/solvers/ode.pyt   <module>è   s‚  ((:"".L"4:				ÿ 2	gÿ ÿ wÔ	H	b	,		H		P	h¬Ó|		5€z		G	9	]	c	[	=	U	1	H	’	}5		4	3	%	)	9	0EA	E	P	7	L	L	?	i	‘	M	:	AL	¤	7gIHH\mPOK	3	Š	1			#	4	>	5	m	4		O	3	*	0	7	:	+	 	)		+	)	+		t		-	-	$	/	1		2	7	;	;