
    \ha                     N   S r SSKJr  SSKJr  SSKJr  SSKJrJ	r	  SSK
JrJrJrJr  SSKJrJr  SSKJrJrJr  SS	KJr  SS
KJrJr  SSKJrJr  SSKJr  SSK J!r!J"r"J#r#  SSK$J%r%  SSK&J'r'  SSK(r(Sr)S!S jr*S r+S r,S"SS.S jjr-S#S jr.S r/S r0S r1S r2S$S jr3S r4S r5S  r6g)%a  
This module contains pdsolve() and different helper functions that it
uses. It is heavily inspired by the ode module and hence the basic
infrastructure remains the same.

**Functions in this module**

    These are the user functions in this module:

    - pdsolve()     - Solves PDE's
    - classify_pde() - Classifies PDEs into possible hints for dsolve().
    - pde_separate() - Separate variables in partial differential equation either by
                       additive or multiplicative separation approach.

    These are the helper functions in this module:

    - pde_separate_add() - Helper function for searching additive separable solutions.
    - pde_separate_mul() - Helper function for searching multiplicative
                           separable solutions.

**Currently implemented solver methods**

The following methods are implemented for solving partial differential
equations.  See the docstrings of the various pde_hint() functions for
more information on each (run help(pde)):

  - 1st order linear homogeneous partial differential equations
    with constant coefficients.
  - 1st order linear general partial differential equations
    with constant coefficients.
  - 1st order linear partial differential equations with
    variable coefficients.

    )reduce)combinations_with_replacement)simplify)AddS)FunctionexpandAppliedUndefSubs)EqualityEq)SymbolWildsymbols)exp)Integral	integrate)has_dupsis_sequence)
filldedent)_preprocess	ode_order_desolve)solve)collectN)%1st_linear_constant_coeff_homogeneous1st_linear_constant_coeff"1st_linear_constant_coeff_Integral1st_linear_variable_coeffc           	         U(       d  [        S5      n[        U 4XSSS.UD6nUR                  SS5      n UR                  SS5      nU(       ag  0 n0 n	[        U SS9n
UR	                  U
S	   U
S
   S.5        U H&  n [        XXb   S   Xb   S	   Xb   U   U5      nXU'   M(     UR	                  U	5        U$ [        XS   US   US	   XfS      U5      $ ! [         a  nXU'    SnAMn  SnAff = f)aK  
Solves any (supported) kind of partial differential equation.

**Usage**

    pdsolve(eq, f(x,y), hint) -> Solve partial differential equation
    eq for function f(x,y), using method hint.

**Details**

    ``eq`` can be any supported partial differential equation (see
        the pde docstring for supported methods).  This can either
        be an Equality, or an expression, which is assumed to be
        equal to 0.

    ``f(x,y)`` is a function of two variables whose derivatives in that
        variable make up the partial differential equation. In many
        cases it is not necessary to provide this; it will be autodetected
        (and an error raised if it could not be detected).

    ``hint`` is the solving method that you want pdsolve to use.  Use
        classify_pde(eq, f(x,y)) to get all of the possible hints for
        a PDE.  The default hint, 'default', will use whatever hint
        is returned first by classify_pde().  See Hints below for
        more options that you can use for hint.

    ``solvefun`` is the convention used for arbitrary functions returned
        by the PDE solver. If not set by the user, it is set by default
        to be F.

**Hints**

    Aside from the various solving methods, there are also some
    meta-hints that you can pass to pdsolve():

    "default":
            This uses whatever hint is returned first by
            classify_pde(). This is the default argument to
            pdsolve().

    "all":
            To make pdsolve apply all relevant classification hints,
            use pdsolve(PDE, func, hint="all").  This will return a
            dictionary of hint:solution terms.  If a hint causes
            pdsolve 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 PDE.  See also ode_order() in
              deutils.py
            - 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 classify_pde().

    "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
            pdsolve() to hang because of a difficult or impossible
            integral.  This meta-hint will also be much faster than
            "all", because integrate() is an expensive routine.

    See also the classify_pde() docstring for more info on hints,
    and the pde 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, y # x and y are the independent variables
        >>> f = Function("f")(x, y) # f is a function of x and y
        >>> # fx will be the partial derivative of f with respect to x
        >>> fx = Derivative(f, x)
        >>> # fy will be the partial derivative of f with respect to y
        >>> fy = Derivative(f, y)

    - See test_pde.py for many tests, which serves also as a set of
      examples for how to use pdsolve().
    - pdsolve always returns an Equality class (except for the case
      when the hint is "all" or "all_Integral"). Note that it is not possible
      to get an explicit solution for f(x, y) as in the case of ODE's
    - Do help(pde.pde_hintname) to get help more information on a
      specific hint


Examples
========

>>> from sympy.solvers.pde import pdsolve
>>> from sympy import Function, Eq
>>> from sympy.abc import x, y
>>> f = Function('f')
>>> u = f(x, y)
>>> ux = u.diff(x)
>>> uy = u.diff(y)
>>> eq = Eq(1 + (2*(ux/u)) + (3*(uy/u)), 0)
>>> pdsolve(eq)
Eq(f(x, y), F(3*x - 2*y)*exp(-2*x/13 - 3*y/13))

FTpde)funchintr   typeeqFall)dictorderdefault)r)   r*   r#   Nr$   )r   r   popclassify_pdeupdate_helper_simplifyNotImplementedError)r&   r#   r$   r(   solvefunkwargshintsall_pdedictfailed_hintsgethintsrvdetails                I/var/www/auris/envauris/lib/python3.13/site-packages/sympy/solvers/pde.pypdsolver:   ?   s-   L C= R +d+#)+E	4	B99UE"D .'!2#+I#68 	9D#%bF0CK(%+d*;XG
 !#  	|$  &M5= %gFm0DhP 	P ' ,%+T",s   <C
C+C&&C+c           	      j    [        5       SUR                  S5      -      n[        U" XUXE5      X#U5      $ )zHelper function of pdsolve that calls the respective
pde functions to solve for the partial differential
equations. This minimizes the computation in
calling _desolve multiple times.
pde_	_Integral)globalsremovesuffix_handle_Integral)r&   r$   r#   r)   matchr0   	solvefuncs          r9   r.   r.      s@     	&4#4#4[#AABIIbt- -    c                 t    UR                  S5      (       a  U $ US:X  a  [        U R                  5       5      $ U $ )zp
Converts a solution with integrals in it into an actual solution.

Simplifies the integral mainly using doit()
r=   r   )endswithr   doit)exprr#   r)   r$   s       r9   r@   r@      s9     }}[!!	,	,		$$ rC   T)prepc                  ^ U(       a$  [        UR                  5      S:w  a  [        S5      eU(       d  Uc  [        X5      u  p5Uc  Un[	        U [
        5      (       a?  U R                  S:w  a#  [        U R                  U R                  -
  U5      $ U R                  n UR                  nUR                  S   nUR                  S   nU" Xx5      R                  U5      n	U" Xx5      R                  U5      n
[        X" Xx5      5      nSU0mU(       d  U(       a  STS'   T$ g[        U 5      n [        S	U" Xx5      /S
9n[        SU" Xx5      XXx/S
9n[        SU" Xx5      XXx/S
9n[        SU" Xx5      XXx/S
9n[        SU" Xx5      X/S
9n[        SXx/S
9nU nU R                  (       a  Sn[        [!        Xx4U5      5       Hs  nU R#                  U" Xx5      R                  " U6 5      nUS:X  a  M/  UR%                  X" Xx5      U-  -  5      nU(       d  MT  UU   (       d  M`  Ub  UU   U:  d  Mn  UU   nMu     U(       a1  U" Xx5      U-  n['        U R                   Vs/ s H  nUU-  PM
     sn6 nUS:X  Ga  [)        UU" Xx5      5      nUR%                  X-  X-  -   X" Xx5      -  -   U-   5      nU(       aY  UU   (       d  UR+                  XUS.5        UTS'   OUU   S-  UU   S-  -   S:w  a  UR+                  XUUS.5        UTS'   UTS'   O}[        SU" Xx5      X/S
9n[        SU" Xx5      X/S
9n[        SU" Xx5      X/S
9nUR%                  X-  X-  -   X" Xx5      -  -   U-   5      nU(       a  UR+                  XUUS.5        UTS'   [-        U4S j[.         5       5      nU(       a'  STS'   UTS'   [.         H  nUT;   d  M  UTS'     T$    T$ U$ s  snf )a9  
Returns a tuple of possible pdsolve() classifications for a PDE.

The tuple is ordered so that first item is the classification that
pdsolve() uses to solve the PDE by default.  In general,
classifications near the beginning of the list will produce
better solutions faster than those near the end, though there are
always exceptions.  To make pdsolve use a different classification,
use pdsolve(PDE, func, hint=<classification>).  See also the pdsolve()
docstring for different meta-hints you can use.

If ``dict`` is true, classify_pde() will return a dictionary of
hint:match expression terms. This is intended for internal use by
pdsolve().  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 doing help(pde.pde_hintname),
where hintname is the name of the hint without "_Integral".

See sympy.pde.allhints or the sympy.pde docstring for a list of all
supported hints that can be returned from classify_pde.


Examples
========

>>> from sympy.solvers.pde import classify_pde
>>> from sympy import Function, Eq
>>> from sympy.abc import x, y
>>> f = Function('f')
>>> u = f(x, y)
>>> ux = u.diff(x)
>>> uy = u.diff(y)
>>> eq = Eq(1 + (2*(ux/u)) + (3*(uy/u)), 0)
>>> classify_pde(eq)
('1st_linear_constant_coeff_homogeneous',)
   zLRight now only partial differential equations of two variables are supportedNr      r)   r*    a)excludebcden)rO   rP   rQ   r   )rO   rP   rQ   rR   r   r   r   c              3   6   >#    U  H  oT;   d  M
  Uv   M     g 7f)NrL   ).0imatching_hintss     r9   	<genexpr>classify_pde.<locals>.<genexpr>_  s     @1,?QQs   		ordered_hints)lenargsr/   r   
isinstancer   rhsr,   lhsr#   diffr   r	   r   is_Addsetr   coeffrA   r   r   r-   tupleallhints)r&   r#   r(   rH   r1   func_fxyfxfyr)   rM   rO   rP   rQ   rR   rS   
reduced_eqpowerrV   rc   rA   denargrrettuplerW   s                              @r9   r,   r,      s   N DII!#! #D E 	E t|!"+<D"h66Q;66VV		A		!A		!A	
1QB	
1QB b!A&!E u%N(,N9%!!	BSQqVH%ASQqVRQ23ASQqVRQ23ASQqVRQ23ASQqVR,-ASQF#A J	yy2A5%@AAHHQqV[[!_-EzKK!A&!),Euq=E!Hu$4!!HE B A&%-C"'':'3s3w':;JzZ11
QTAD[1QqV83a78Q4 qq12JKFG1q1Q47"a' qqq9:>?:;GHCD S1Q7B"34AS1Q7B"34AS1Q7B"34A  q1x!7!!;<Aqqq9:>?:; @@@H %)y!*2'AN",-y)	  OQ ;s   Oc                    [        U [        5      (       d  [        U S5      n Uc   [        U R                  5      u  pB[        U[        5      (       a+  [        U5      " U Vs/ s H  n[        XUUS9PM     sn5      $ [        U[        5      (       d  [        X!5      nOUR                  U:X  a  UR                   nUR                  U:H  =(       a     UR                  R#                  U5      (       + nU(       ae  U(       d^  [%        X5      nU(       aL  [        U5      S:X  a  [        U [        X(S   5      USS9$ [        X V	s/ s H  n	[        X)5      PM     sn	USS9$ UR                  U:X  a_  U R                  U R                  -
  n ['        U R)                  X!R                  5      R+                  5       5      nU[,        R.                  L U4$ [1        [3        SU< SU < S35      5      e! [
         a    [        U[        5      (       a  UOU/ Vs/ s H  oUR                  [        5      PM     Os  snf nn[        5       R                  U5      n[        U5      S:w  a  [        S5      eUR                  5       n GN=f = fs  snf s  sn	f )	a%  
Checks if the given solution satisfies the partial differential
equation.

pde is the partial differential equation which can be given in the
form of an equation or an expression. sol is the solution for which
the pde is to be checked. This can also be given in an equation or
an expression form. If the function is not provided, the helper
function _preprocess from deutils is used to identify the function.

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

The following methods are currently being implemented to check if the
solution satisfies the PDE:

    1. Directly substitute the solution in the PDE and check. If the
       solution has not been solved for f, then it will solve for f
       provided solve_for_func has not been set to False.

If the solution satisfies the PDE, then a tuple (True, 0) is returned.
Otherwise a tuple (False, expr) where expr is the value obtained
after substituting the solution in the PDE. However if a known solution
returns False, it may be due to the inability of doit() to simplify it to zero.

Examples
========

>>> from sympy import Function, symbols
>>> from sympy.solvers.pde import checkpdesol, pdsolve
>>> x, y = symbols('x y')
>>> f = Function('f')
>>> eq = 2*f(x,y) + 3*f(x,y).diff(x) + 4*f(x,y).diff(y)
>>> sol = pdsolve(eq)
>>> assert checkpdesol(eq, sol)[0]
>>> eq = x*f(x,y) + f(x,y).diff(x)
>>> checkpdesol(eq, sol)
(False, (x*F(4*x - 3*y) - 6*F(4*x - 3*y)/25 + 4*Subs(Derivative(F(_xi_1), _xi_1), _xi_1, 4*x - 3*y))*exp(-6*x/25 - 8*y/25))
r   rK   z0must pass func arg to checkpdesol for this case.)r#   solve_for_funcFz
        Unable to test if z is a solution to .)r]   r   r   r   r_   
ValueErrorr   rb   atomsr
   unionr[   r+   r%   checkpdesolr^   reversedhasr   r   subsrF   r   Zeror/   r   )
r"   solr#   rs   _sfuncsrV   solvedts
             r9   rx   rx   n  s<   T c8$$aj |		!#''*GA 3Cy47947q &)+479 : 	:
 c8$$m	Dll WW_6SWW[[%6!6Ffs!6{a"34(;e5 5 #3f(EfDf(Ee5 5 ww$ggSXXdGG,1134AFF{A~
j8;S*B C D DQ  	"3,,3%7:7 01WW\*7:E :EKK&E5zQ FH H99;D	9& )Fs*   G( !I> J
(&I;H-,AI;:I;c           	         UR                   nUR                  S   nUR                  S   nX3S      nX3S      n	X3S      n
[        U" Xg5      [        [	        U
5      * US-  U	S-  -   -  X-  X-  -   -  5      U" X-  X-  -
  5      -  5      $ )a6  
Solves a first order linear homogeneous
partial differential equation with constant coefficients.

The general form of this partial differential equation is

.. math:: a \frac{\partial f(x,y)}{\partial x}
          + b \frac{\partial f(x,y)}{\partial y} + c f(x,y) = 0

where `a`, `b` and `c` are constants.

The general solution is of the form:

.. math::
    f(x, y) = F(- a y + b x ) e^{- \frac{c (a x + b y)}{a^2 + b^2}}

and can be found in SymPy with ``pdsolve``::

    >>> from sympy.solvers import pdsolve
    >>> from sympy.abc import x, y, a, b, c
    >>> from sympy import Function, pprint
    >>> f = Function('f')
    >>> u = f(x,y)
    >>> ux = u.diff(x)
    >>> uy = u.diff(y)
    >>> genform = a*ux + b*uy + c*u
    >>> pprint(genform)
      d               d
    a*--(f(x, y)) + b*--(f(x, y)) + c*f(x, y)
      dx              dy

    >>> pprint(pdsolve(genform))
                             -c*(a*x + b*y)
                             ---------------
                                  2    2
                                 a  + b
    f(x, y) = F(-a*y + b*x)*e

Examples
========

>>> from sympy import pdsolve
>>> from sympy import Function, pprint
>>> from sympy.abc import x,y
>>> f = Function('f')
>>> pdsolve(f(x,y) + f(x,y).diff(x) + f(x,y).diff(y))
Eq(f(x, y), F(x - y)*exp(-x/2 - y/2))
>>> pprint(pdsolve(f(x,y) + f(x,y).diff(x) + f(x,y).diff(y)))
                      x   y
                    - - - -
                      2   2
f(x, y) = F(x - y)*e

References
==========

- Viktor Grigoryan, "Partial Differential Equations"
  Math 124A - Fall 2010, pp.7

r   rK   rO   rP   rQ   rJ   )r#   r\   r   r   r   )r&   r#   r)   rA   r0   rg   rh   ri   rO   rP   rQ   s              r9   )pde_1st_linear_constant_coeff_homogeneousr     s    B 			A		!A		!ACjACjACjAafc1Q4%A1-qsQSy9:8AC!#I;NNOOrC   c                 0   [        S5      u  pVUR                  nUR                  S   nUR                  S   n	X3S      n
X3S      nX3S      nX3S      * n[        [	        U5      * U
S-  US-  -   -  U-  5      nU" U5      n[        X-  X-  -   U-
  X-  X-  -
  U-
  4X5      nS[	        U
S-  US-  -   5      -  [        SU-  U-  R                  U5      XZU-  X-  -   45      -  n[        U" X5      [        XU-   -  Xe4X-  X-  -
  X-  X-  -   45      5      $ )	a  
Solves a first order linear partial differential equation
with constant coefficients.

The general form of this partial differential equation is

.. math:: a \frac{\partial f(x,y)}{\partial x}
          + b \frac{\partial f(x,y)}{\partial y}
          + c f(x,y) = G(x,y)

where `a`, `b` and `c` are constants and `G(x, y)` can be an arbitrary
function in `x` and `y`.

The general solution of the PDE is:

.. math::
    f(x, y) = \left. \left[F(\eta) + \frac{1}{a^2 + b^2}
    \int\limits^{a x + b y} G\left(\frac{a \xi + b \eta}{a^2 + b^2},
    \frac{- a \eta + b \xi}{a^2 + b^2} \right)
    e^{\frac{c \xi}{a^2 + b^2}}\, d\xi\right]
    e^{- \frac{c \xi}{a^2 + b^2}}
    \right|_{\substack{\eta=- a y + b x\\ \xi=a x + b y }}\, ,

where `F(\eta)` is an arbitrary single-valued function. The solution
can be found in SymPy with ``pdsolve``::

    >>> from sympy.solvers import pdsolve
    >>> from sympy.abc import x, y, a, b, c
    >>> from sympy import Function, pprint
    >>> f = Function('f')
    >>> G = Function('G')
    >>> u = f(x, y)
    >>> ux = u.diff(x)
    >>> uy = u.diff(y)
    >>> genform = a*ux + b*uy + c*u - G(x,y)
    >>> pprint(genform)
      d               d
    a*--(f(x, y)) + b*--(f(x, y)) + c*f(x, y) - G(x, y)
      dx              dy
    >>> pprint(pdsolve(genform, hint='1st_linear_constant_coeff_Integral'))
              //          a*x + b*y                                             \         \|
              ||              /                                                 |         ||
              ||             |                                                  |         ||
              ||             |                                      c*xi        |         ||
              ||             |                                     -------      |         ||
              ||             |                                      2    2      |         ||
              ||             |      /a*xi + b*eta  -a*eta + b*xi\  a  + b       |         ||
              ||             |     G|------------, -------------|*e        d(xi)|         ||
              ||             |      |   2    2         2    2   |               |         ||
              ||             |      \  a  + b         a  + b    /               |  -c*xi  ||
              ||             |                                                  |  -------||
              ||            /                                                   |   2    2||
              ||                                                                |  a  + b ||
    f(x, y) = ||F(eta) + -------------------------------------------------------|*e       ||
              ||                                  2    2                        |         ||
              \\                                 a  + b                         /         /|eta=-a*y + b*x, xi=a*x + b*y

Examples
========

>>> from sympy.solvers.pde import pdsolve
>>> from sympy import Function, pprint, exp
>>> from sympy.abc import x,y
>>> f = Function('f')
>>> eq = -2*f(x,y).diff(x) + 4*f(x,y).diff(y) + 5*f(x,y) - exp(x + 3*y)
>>> pdsolve(eq)
Eq(f(x, y), (F(4*x + 2*y)*exp(x/2) + exp(x + 4*y)/15)*exp(-y))

References
==========

- Viktor Grigoryan, "Partial Differential Equations"
  Math 124A - Fall 2010, pp.7

zxi etar   rK   rO   rP   rQ   rR   rJ   )
r   r#   r\   r   r   r   r   r{   r   r   )r&   r#   r)   rA   r0   xietarg   rh   ri   rO   rP   rQ   rR   exptermfuncterm	solvedictgenterms                     r9   pde_1st_linear_constant_coeffr     sK   ` hGB		A		!A		!ACjACjACjA	Sz	A1Q4%A1%b()G}HqsQSy2~qsQSy37>I 1a4!Q$;	
719%aC!#I"8 8Gafd7w$67		AC!#IqsQSy)+ , ,rC   c                 $   SSK Jn  [        S5      nUR                  nUR                  S   nUR                  S   n	X3S      n
X3S      nX3S      nX3S      * nU(       dp  U
(       a  U(       db  U(       a*   [        X-  U	5      n[        U" X5      U" U5      U-   5      $ U
(       a*   [        X-  U5      n[        U" X5      U" U	5      U-   5      $ U(       d|  U" U5      R                  U5      U
-  X" U5      -  -   U-
  nU" X" U5      5      nUR                  UR                  -
  X1-
  n[        UR                  UXI5      n[        U" X5      U5      $ U
(       d|  U" U	5      R                  U	5      U-  X" U	5      -  -   U-
  nU" X" U	5      5      nUR                  UR                  -
  X1-
  n[        UR                  UXH5      n[        U" X5      U5      $ [        S5      nX-  R                  U	U" U5      5      nU" U" U5      R                  U5      U-
  U" U5      5      n[        U[        5      (       a  US   nUR                  UR                  -
  X1-
  n[!        U5      S:X  a  UR#                  5       n[%        UU5      S   R                  U" U5      U	5      n[%        UU-
  U	5      S   nX" U5      R                  U5      -  X" U5      -  -   U-
  R                  U	U5      nU" UU" U5      S
S9R                  n[        U[        5      (       a  US   nUR                  UR                  -
  X1-
  n[        UUUU5      n[        U" X5      U5      $ [        S5      e! [         a    [        S	5      ef = f! [         a    [        S	5      ef = f)a@  
Solves a first order linear partial differential equation
with variable coefficients. The general form of this partial
differential equation is

.. math:: a(x, y) \frac{\partial f(x, y)}{\partial x}
            + b(x, y) \frac{\partial f(x, y)}{\partial y}
            + c(x, y) f(x, y) = G(x, y)

where `a(x, y)`, `b(x, y)`, `c(x, y)` and `G(x, y)` are arbitrary
functions in `x` and `y`. This PDE is converted into an ODE by
making the following transformation:

1. `\xi` as `x`

2. `\eta` as the constant in the solution to the differential
   equation `\frac{dy}{dx} = -\frac{b}{a}`

Making the previous substitutions reduces it to the linear ODE

.. math:: a(\xi, \eta)\frac{du}{d\xi} + c(\xi, \eta)u - G(\xi, \eta) = 0

which can be solved using ``dsolve``.

>>> from sympy.abc import x, y
>>> from sympy import Function, pprint
>>> a, b, c, G, f= [Function(i) for i in ['a', 'b', 'c', 'G', 'f']]
>>> u = f(x,y)
>>> ux = u.diff(x)
>>> uy = u.diff(y)
>>> genform = a(x, y)*u + b(x, y)*ux + c(x, y)*uy - G(x,y)
>>> pprint(genform)
                                     d                     d
-G(x, y) + a(x, y)*f(x, y) + b(x, y)*--(f(x, y)) + c(x, y)*--(f(x, y))
                                     dx                    dy


Examples
========

>>> from sympy.solvers.pde import pdsolve
>>> from sympy import Function, pprint
>>> from sympy.abc import x,y
>>> f = Function('f')
>>> eq =  x*(u.diff(x)) - y*(u.diff(y)) + y**2*u - y**2
>>> pdsolve(eq)
Eq(f(x, y), F(x*y)*exp(y**2/2) + 1)

References
==========

- Viktor Grigoryan, "Partial Differential Equations"
  Math 124A - Fall 2010, pp.7

r   )dsolver   rK   rO   rP   rQ   rR   z7Unable to find a solution due to inability of integrate
1st_linear)r$   zOCannot solve the partial differential equation due to inability of constantsimp)sympy.solvers.oder   r   r#   r\   r   r   r/   r`   free_symbols_simplify_variable_coeffr^   r   r{   r]   listr[   r+   r   )r&   r#   r)   rA   r0   r   r   rg   rh   ri   rO   rP   rQ   rR   tsolploder}   symsr^   dummyhsolsymetatysubdeqfinalfinsymss                              r9   pde_1st_linear_variable_coeffr   y  s   p )
%.C		A		!A		!ACjACjACjA	Sz	A a:$QS!,D
 afhqkD&899:$QS!,D
 afhqkD&899 !		!Q1Q4'!+UAaD!%"4"44v=&swwhB!A'3 !		!Q1Q4'!+UAaD!%"4"44v=&swwhB!A'3SME	


1eAhA
qq!A%uQx
0C#t!f.!7F
6{ac6"1%++E!Ha8S4Z#A&!A$))A,!AaD&(1,221d;QqT5::eT""!HE$$s'7'771&@&ugxF!A'3 " #, - 	-g + :- /9 : :: + :- /9 : ::s   6M  'M9  M69Nc                     [        S5      n[        U5      S:X  a(  UR                  5       nU R                  XR" U5      5      nO U H  nU R                  XR" U5      5      nM     [	        WR                  XC5      5      $ )zP
Helper function to replace constants by functions in 1st_linear_variable_coeff
r   rK   )r   r[   r+   r{   r   )r}   r   r#   funcargr   symr   s          r9   r   r     sm     -C
4yA~hhjd7m, CHHS$w-0E  EJJs,--rC   c                    SnUS:X  a  SnOUS:X  a  SnO[        SU-  5      e[        U [        5      (       a?  U R                  S:w  a.  [	        [        U R                  U R                  -
  S5      XU5      $ O[	        [        U S5      XU5      $ U R                  S:w  a  [        S5      e[        UR                  5      nU VVs/ s H  ofR                    H  owPM     M     nnnU(       a  [        [        R                  U5      n	O[        [        R                  U5      n	[        U5      [        U5      :w  a  [        S5      e[        U5      (       a  [        S	5      e[        U5      [        U5      :w  a  [        S
5      eU R                  R!                  X5      R#                  5       n
U(       d  Sn U
R                   H
  nXU	-  -  n M     U n
US   nUSS n[%        XU5      $ s  snnf )aI  Separate variables in partial differential equation either by additive
or multiplicative separation approach. It tries to rewrite an equation so
that one of the specified variables occurs on a different side of the
equation than the others.

:param eq: Partial differential equation

:param fun: Original function F(x, y, z)

:param sep: List of separated functions [X(x), u(y, z)]

:param strategy: Separation strategy. You can choose between additive
    separation ('add') and multiplicative separation ('mul') which is
    default.

Examples
========

>>> from sympy import E, Eq, Function, pde_separate, Derivative as D
>>> from sympy.abc import x, t
>>> u, X, T = map(Function, 'uXT')

>>> eq = Eq(D(u(x, t), x), E**(u(x, t))*D(u(x, t), t))
>>> pde_separate(eq, u(x, t), [X(x), T(t)], strategy='add')
[exp(-X(x))*Derivative(X(x), x), exp(T(t))*Derivative(T(t), t)]

>>> eq = Eq(D(u(x, t), x, 2), D(u(x, t), t, 2))
>>> pde_separate(eq, u(x, t), [X(x), T(t)], strategy='mul')
[Derivative(X(x), (x, 2))/X(x), Derivative(T(t), (t, 2))/T(t)]

See Also
========
pde_separate_add, pde_separate_mul
FaddTmulzUnknown strategy: %sr   zValue should be 0zVariable counts do not matchz)Duplicate substitution arguments detectedzArguments do not matchrK   N)ru   r]   r   r^   pde_separater   r_   r   r\   r   operatorr   r   r[   r   rb   r{   rF   	_separate)r&   funsepstrategydo_add	orig_argsr   ro   	subs_args	functionsresultrV   svardvars                 r9   r   r   
  s   H F5	U	/(:;;"h66Q;266BFF?A 6(KK  Br1Is::	vv{,-- SXXI!4cVVcVcI48<<-	8<<-	 9~Y'788	DEE
9~Y'122 VV[[(--/F AI+B Q<DQR=DV4((; 5s   G%c                     [        XUSS9$ )aC  
Helper function for searching additive separable solutions.

Consider an equation of two independent variables x, y and a dependent
variable w, we look for the product of two functions depending on different
arguments:

`w(x, y, z) = X(x) + y(y, z)`

Examples
========

>>> from sympy import E, Eq, Function, pde_separate_add, Derivative as D
>>> from sympy.abc import x, t
>>> u, X, T = map(Function, 'uXT')

>>> eq = Eq(D(u(x, t), x), E**(u(x, t))*D(u(x, t), t))
>>> pde_separate_add(eq, u(x, t), [X(x), T(t)])
[exp(-X(x))*Derivative(X(x), x), exp(T(t))*Derivative(T(t), t)]

r   r   r   r&   r   r   s      r9   pde_separate_addr   a      , u55rC   c                     [        XUSS9$ )a<  
Helper function for searching multiplicative separable solutions.

Consider an equation of two independent variables x, y and a dependent
variable w, we look for the product of two functions depending on different
arguments:

`w(x, y, z) = X(x)*u(y, z)`

Examples
========

>>> from sympy import Function, Eq, pde_separate_mul, Derivative as D
>>> from sympy.abc import x, y
>>> u, X, Y = map(Function, 'uXY')

>>> eq = Eq(D(u(x, y), x, 2), D(u(x, y), y, 2))
>>> pde_separate_mul(eq, u(x, y), [X(x), Y(y)])
[Derivative(X(x), (x, 2))/X(x), Derivative(Y(y), (y, 2))/Y(y)]

r   r   r   r   s      r9   pde_separate_mulr   z  r   rC   c                    [        5       nU R                   H  nUR                  (       aO  UR                   H=  nUR                  (       d  M  UR                  " U6 (       a  M,  UR                  U5        M?     Mc  UR                  (       d  Mv  UR                  " U6 (       a  M  UR                  U5        M     [        5       nU HK  nUR                  5       R                  U5      u  pxUR                  " U6 (       a    gUR                  U5        MM     [        U5      S:  aG  [        U R                   VVs/ s H'  n[        [        U Vs/ s H  oTU-  PM	     sn6 5      PM)     snn6 n [        5       nS=pU R                   Hw  nUR                  " U6 (       d  X-  n	M  UR                  5       R                  U5      u  pUR                  " U6 (       a    gUR                  U5        XR                  5       -  n
My     [        [        R
                  U5      n[        X-  5      R                  5       n	[        X-  5      R                  5       n
U	R                  " U6 (       d  U
R	                  U5      (       a  gX/$ s  snf s  snnf )zFSeparate expression into two parts based on dependencies of variables.Nr   )rb   r\   is_Mulis_Derivativerz   r   r	   as_independentr[   r   r   r   r   )r&   depotherstermstermrV   divextr   r_   r^   tempfulldivs                r9   r   r     s   
 EE;;YY???155&>>IIdO  &(9(9IIdO  %C;;=//477F  3x!|RWWMWT8C#!6#Qq&#!678WMN
%CMCxx KCKKM005	77F{{}  X\\3'G
3;

&
&
(C
3;

&
&
(C
ww3773<<:1 "7Ms   6J 

I;J 
;J 
)Nr*   FN)NF)NT)r   )7__doc__	functoolsr   	itertoolsr   sympy.simplifyr   
sympy.corer   r   sympy.core.functionr   r	   r
   r   sympy.core.relationalr   r   sympy.core.symbolr   r   r   sympy.functionsr   sympy.integrals.integralsr   r   sympy.utilities.iterablesr   r   sympy.utilities.miscr   sympy.solvers.deutilsr   r   r   sympy.solvers.solversr   sympy.simplify.radsimpr   r   re   r:   r.   r@   r,   rx   r   r   r   r   r   r   r   r   rL   rC   r9   <module>r      s   !D  3 #  D D . 3 3  9 ; + B B ' * DPN- JD JZZD|GPT`,F~-B. T)n62623rC   