
    \hr                   B   S SK Jr  S SKJr  S SKJr  S SKJr  S SKJ	r	  S SK
JrJrJrJrJrJrJrJrJrJrJrJrJrJr  S SKJr  S SKJr  S S	KJrJrJ r J!r!J"r"J#r#  S S
K$J%r%J&r&J'r'J(r(J)r)  S SK*J+r+  S SK,J-r-  S SK.J/r/  S SK0J1r1  S SK2J3r4J5r6  S SK7J8r8J9r9J:r:J;r;J<r<J=r=  S SK>J?r?  S SK@JArAJBrBJCrC  S SKDJErE  S SKFJGrG  S SKHJIrI  S SKJJKrKJLrLJMrM  S SKNJOrO  S SKPJQrQJRrRJSrSJTrTJUrUJVrV  S SKWJXrX  S SKYJZrZ  S SK[J\r\  S SK]J^r^J_r_J`r`JaraJbrb  S SKcJdrdJereJfrf  S SKgJhrhJiri  S SKjJkrk  S S KlJmrm  S S!KnJoroJprp  S S"KqJrrr  S S#KsJtrt  S S$KuJvrvJwrwJxrx  S S%KyJzrz  S S&K{J|r|J}r}  S S'K~Jr  S S(KJrJrJrJr  S S)KJr  S S*Kr/ S+S+4S, jrS- rS. rS/ rS0 rS1 rSPS2 jr\SQS3 j5       r\SRS4 j5       r\SSS5 j5       r\STS6 j5       rS7\S+S+S84S9 jrS: rS; rSUS< jrSVS= jrS> rSVS? jrS@ rSWSA jrSB rSC rSD rSXSE jr  SYSF jrSZSG jr\GR<                  4SH jrS[SI jrSWSJ jr\" SKSLSMSN9" \45      r3\" SOSLSMSN9" \65      r5g*)\    )annotations)overload)defaultdict)Product)Sum)BasicSAddMulPowSymbolsympifyexpand_funcFunctionDummyExprfactor_termsexpand_power_expEq)	factor_nc)global_parameters)
expand_log	count_ops_mexpandnfloat
expand_mulexpand)FloatIpiRationalequal_valued)
Relational)	Transform)ordered)_sympify)	bottom_upwalk)gammaexpsqrtlog	exp_polarre)CombinatorialFunction)
unpolarifyAbssign)ExpBase)HyperbolicFunction)ceiling)	Piecewisepiecewise_foldpiecewise_simplify)TrigonometricFunction)
BesselBasebesseljbesselibesselkbesselyjn)KroneckerDelta)Integral)Boolean)
MatrixExprMatAddMatMulMatPowMatrixSymbol)togethercancelfactor)_is_sum_surds_minimal_polynomial_sq)Set)combsimp)sub_presub_post)hyperexpand)powsimp)radsimpfractioncollect_abs)
sqrtdenest)trigsimpexptrigsimp)
deprecated)has_varietysiftsubsetsiterable)as_intNFc                f    [        U 5      n U(       a  [        [        X5      U5      $ [        X5      $ )a  
Separates variables in an expression, if possible.  By
default, it separates with respect to all symbols in an
expression and collects constant coefficients that are
independent of symbols.

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

If ``dict=True`` then the separated terms will be returned
in a dictionary keyed to their corresponding symbols.
By default, all symbols in the expression will appear as
keys; if symbols are provided, then all those symbols will
be used as keys, and any terms in the expression containing
other symbols or non-symbols will be returned keyed to the
string 'coeff'. (Passing None for symbols will return the
expression in a dictionary keyed to 'coeff'.)

If ``force=True``, then bases of powers will be separated regardless
of assumptions on the symbols involved.

Notes
=====

The order of the factors is determined by Mul, so that the
separated expressions may not necessarily be grouped together.

Although factoring is necessary to separate variables in some
expressions, it is not necessary in all cases, so one should not
count on the returned factors being factored.

Examples
========

>>> from sympy.abc import x, y, z, alpha
>>> from sympy import separatevars, sin
>>> separatevars((x*y)**y)
(x*y)**y
>>> separatevars((x*y)**y, force=True)
x**y*y**y

>>> e = 2*x**2*z*sin(y)+2*z*x**2
>>> separatevars(e)
2*x**2*z*(sin(y) + 1)
>>> separatevars(e, symbols=(x, y), dict=True)
{'coeff': 2*z, x: x**2, y: sin(y) + 1}
>>> separatevars(e, [x, y, alpha], dict=True)
{'coeff': 2*z, alpha: 1, x: x**2, y: sin(y) + 1}

If the expression is not really separable, or is only partially
separable, separatevars will do the best it can to separate it
by using factoring.

>>> separatevars(x + x*y - 3*x**2)
-x*(3*x - y - 1)

If the expression is not separable then expr is returned unchanged
or (if dict=True) then None is returned.

>>> eq = 2*x + y*sin(x)
>>> separatevars(eq) == eq
True
>>> separatevars(2*x + y*sin(x), symbols=(x, y), dict=True) is None
True

)r   _separatevars_dict_separatevars)exprsymbolsdictforces       O/var/www/auris/envauris/lib/python3.13/site-packages/sympy/simplify/simplify.pyseparatevarsrg   7   s.    F 4=D!-"<gFFT))    c                   [        U [        5      (       ak  U R                  S   nUR                  (       aK  UR                  (       d:  [        USUS9nUb*  [        [        U R                  UR                  5       5      6 $ U $ [        U R                  5      S:  a  U $ U R                  (       a`  [        U R                  5      nSn[        U5       H"  u  pg[        Xq5      XF'   U=(       d    XF   U:g  nM$     U(       a  U R                  " U6 n U $ U R                  (       aF  U R                  [         R"                  :w  a(  [%        [        U R                  US9U R&                  5      n U R)                  SSUS9n U(       a  [+        U 5      OU 0 4u  p[-        U5      R/                  U	5      n U R0                  (       d  U $ [        U R                  5      nUS   R3                  SSS9S   n
US	S   H  nXR3                  SSS9S   -  n
M     [        U
6 n
U
R5                  5       S	   n
U
R3                  SSS9S   n[        U5       H.  u  pgUR3                  SSS9u  pX-
  n[        U6 [        U6 -  XF'   M0     [7        U6 n[        UR                  5      S	:  aG  UnU(       a  [+        U5      OU0 4u  p[-        U5      R/                  U	5      nUR0                  (       d  UnX-  $ )
Nr   T)rd   re      Fre   )mulmultinomialre   )csetwarn   )
isinstancer1   argsis_Mul	is_numberrg   r   mapfuncvalueslenfree_symbolslist	enumerateis_Powbaser	   Exp1r   r*   r   posifyrJ   subsis_Addargs_cncas_coeff_Mulr
   )rb   re   argsrr   changedia_exprrepscommonccommonc_setcncnonsepars                  rf   ra   ra      s}   $iil::cmmSt59A}C		188:677
4! {{DIIdODA"1,DG-AG $ 99d#D {{tyyAFF*<		7B ;;5e5;AD"'&,dBZKE%=d#D;; 		?D1gDu5a8G!"X::4e:4Q77 7mG""$Q'G""5"9!<K $

5
1Oq'#r("   DzH
8  !A%',fUm5"+$$T*||Hrh   c                h   U(       a.  [        S U 5       5      (       d  [        S5      e[        U5      nO$Uc  SU 0$ [        U R                  5      nU(       d  g US/-    Vs0 s H  o"/ _M     nn[        R
                  " U 5       H  nUR                  n[        U5      R                  U5      n[        U5      S:  a    g [        U5      S:X  a  US   R                  U5        M_  X5R                  5          R                  U5        M     UR                  5        H  u  pg[	        U6 X6'   M     U$ s  snf )Nc              3  8   #    U  H  oR                   v   M     g 7fN)is_Atom).0ts     rf   	<genexpr>%_separatevars_dict.<locals>.<genexpr>   s     .g99g   zsymbols must be Atoms.coeffrp   r   )all
ValueErrorrz   ry   r   	make_argssetintersectionrx   appendpopitems)rb   rc   r   retexpsymr   kvs           rf   r`   r`      s   .g...566w-	t(()!WI-
.-Qb5-C
.]]4 7|008|q |!L"  "#**1- ! 		a  J# /s   "D/c           	     l   [        U 5      n [        U [        5      (       d  [        U 5      (       a  [	        U 5      n[        U 5      n [        5       nU  H'  nUR                  UR                  [        5      5      nM)     0 nU HC  nUR                  [        U5      S   R                  5        VVs0 s H  u  pgXv_M	     snn5        ME     [        U 5       H  u  pUR                  U5      X'   M     U" U 5      UR                  5        VV	s0 s H  u  pYX_M	     sn	n4$ U R                   Vs0 s H4  oUR                   b  M  U[#        UR$                  4SS0UR&                  D6_M6     nnU R                  U5      n XR                  5        VV	s0 s H  u  pYX_M	     sn	n4$ s  snnf s  sn	nf s  snf s  sn	nf )a  Return ``eq`` (with generic symbols made positive) and a
dictionary containing the mapping between the old and new
symbols.

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

Any symbol that has positive=None will be replaced with a positive dummy
symbol having the same name. This replacement will allow more symbolic
processing of expressions, especially those involving powers and
logarithms.

A dictionary that can be sent to subs to restore ``eq`` to its original
symbols is also returned.

>>> from sympy import posify, Symbol, log, solve
>>> from sympy.abc import x
>>> posify(x + Symbol('p', positive=True) + Symbol('n', negative=True))
(_x + n + p, {_x: x})

>>> eq = 1/x
>>> log(eq).expand()
log(1/x)
>>> log(posify(eq)[0]).expand()
-log(_x)
>>> p, rep = posify(eq)
>>> log(p).expand().subs(rep)
-log(x)

It is possible to apply the same transformations to an iterable
of expressions:

>>> eq = x**2 - 4
>>> solve(eq, x)
[-2, 2]
>>> eq_x, reps = posify([eq, x]); eq_x
[_x**2 - 4, _x]
>>> solve(*eq_x)
[2]
rp   positiveT)r   rq   r   r]   typerz   r   unionatomsr   updater   r   r{   r   ry   is_positiver   nameassumptions0)
eqfsymser   r   r   r   r   rs
             rf   r   r      ss   R 
Bb%  Xb\\H"XuA::aggfo.D AKK&)A,*<*<*>?*>$!*>?@ bMDAFF4LBE "u

5qt555 //D)Q]] >AuQVV=d=ann==) 	 D	B.... @ 6D /s   /F
F%+F+?'F+F0c                h   [        U 5      n U R                  XS-   5      U -  nUR                  [        5      nUR	                  [
        5      (       a  [        U5      nUR                  S   S   n[        U5      n[        USSS9nUR                  U5      (       a  [        U[        R                  S9$ g)	a  Given combinatorial term f(k) simplify its consecutive term ratio
i.e. f(k+1)/f(k).  The input term can be composed of functions and
integer sequences which have equivalent representation in terms
of gamma special function.

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

The algorithm performs three basic steps:

1. Rewrite all functions in terms of gamma, if possible.

2. Rewrite all occurrences of gamma in terms of products
   of gamma and rising factorial with integer,  absolute
   constant exponent.

3. Perform simplification of nested fractions, powers
   and if the resulting expression is a quotient of
   polynomials, reduce their total degree.

If f(k) is hypergeometric then as result we arrive with a
quotient of polynomials of minimal degree. Otherwise None
is returned.

For more information on the implemented algorithm refer to:

1. W. Koepf, Algorithms for m-fold Hypergeometric Summation,
   Journal of Symbolic Computation (1995) 20, 399-417
rp   r   Tr*   )deepcombine)ratioN)r   r   rewriter)   hasr6   r7   rr   r   rR   is_rational_functionsimplifyr	   Infinity)r   r   gs      rf   	hypersimpr     s    < 	
A	qa%1A			%AuuY1FF2JqMAAe,Aa  ,,rh   c                    [        [        [        X45      5      u  pX-  R                  [        5      nUR                  SSS9nUR                  U5      $ )a  
Returns True if ``f`` and ``g`` are hyper-similar.

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

Similarity in hypergeometric sense means that a quotient of
f(k) and g(k) is a rational function in ``k``. This procedure
is useful in solving recurrence relations.

For more information see hypersimp().

TF)rv   basic)rz   ru   r   r   r)   r   r   )r   r   r   hs       rf   hypersimilarr   M  sL     GaV$%DA	
eA	d%(A!!!$$rh   c                   Uc  [         R                  n[        U 5      n [        U [        [
        45      (       a  U R                  (       a  U $ U R                  S S 5      n[        [        U5      5      n[        U[        [
        45      (       a  UR                  (       a  U$ UR                  (       a  UR                  " UR                   Vs/ s H  n[        U5      PM     sn6 nU(       dD  [        U[        5      (       a/  UR                  5       (       a  [!        ["        R$                  U* SS9$ U$ U(       a  UR                  S S 5      nU$ s  snf )aK  Make all Add sub-expressions canonical wrt sign.

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

If an Add subexpression, ``a``, can have a sign extracted,
as determined by could_extract_minus_sign, it is replaced
with Mul(-1, a, evaluate=False). This allows signs to be
extracted from powers and products.

Examples
========

>>> from sympy import signsimp, exp, symbols
>>> from sympy.abc import x, y
>>> i = symbols('i', odd=True)
>>> n = -1 + 1/x
>>> n/x/(-n)**2 - 1/n/x
(-1 + 1/x)/(x*(1 - 1/x)**2) - 1/(x*(-1 + 1/x))
>>> signsimp(_)
0
>>> x*n + x*-n
x*(-1 + 1/x) + x*(1 - 1/x)
>>> signsimp(_)
0

Since powers automatically handle leading signs

>>> (-2)**i
-2**i

signsimp can be used to put the base of a power with an integer
exponent into canonical form:

>>> n**i
(-1 + 1/x)**i

By default, signsimp does not leave behind any hollow simplification:
if making an Add canonical wrt sign didn't change the expression, the
original Add is restored. If this is not desired then the keyword
``evaluate`` can be set to False:

>>> e = exp(y - x)
>>> signsimp(e) == e
True
>>> signsimp(e, evaluate=False)
exp(-(x - y))

c                6    U R                   =(       a    U * * U :g  $ r   rs   xs    rf   <lambda>signsimp.<locals>.<lambda>  s    qxx6qbEQJ6rh   c                
    U * * $ r    r   s    rf   r   r     s    QB%rh   Fevaluatec                6    U R                   =(       a    U * * U :g  $ r   r   r   s    rf   r   r     s     7rUaZ 7rh   c                
    U * * $ r   r   r   s    rf   r   r     s    aR5rh   )r   r   r   rq   r   r#   r   replacerP   rO   r   rv   rr   signsimpr
   could_extract_minus_signr   r	   NegativeOne)rb   r   r   r   rvs        rf   r   r   c  s    d $--4=DdT:.//4<<6HAAa$
+,,		xxVV16626ahqk623Jr3  1133q}}rcE::	II7IH 3s   Ec                    g r   r   rb   kwargss     rf   r   r     s    ,/rh   c                    g r   r   r   s     rf   r   r     s    25rh   c                    g r   r   r   s     rf   r   r     s    *-rh   c                    g r   r   r   s     rf   r   r     s    .1rh   g333333?Tc           	     f  ^^^^^ U4S jmUU4S jn[        XS9n TR                  SU5      TR                  ST5      TR                  SU5      TR                  SU5      TR                  ST5      S	.m[        U [        5      (       a4  U R                  (       a#  U R
                  (       d  [        R                  $ U $ [        U S
S5      nUb  U" S0 TD6$ [        [        U 5      5      =p[        U [        5      (       a  U R                  (       d  U $ U(       a8  U R                  [        5      (       a  [        U 5      n U R                  (       d  U $ [         ["        [$        [&        4mU R)                  U4S jU4S jSS9n [        U T5      (       d  U" U 5      $ U R*                  (       d  [-        U 5      n Sn
USLa&  U R                  [.        5      (       a  Sn
[1        U SS9n [3        U S 5      n [#        [5        U 5      R7                  5       6 n [9        U 5      nT" U[;        U5      R9                  5       5      nT" [=        U SS9[=        USS95      nU[        R>                  L a  Un O	T" XU 5      n [        U [        5      (       d  U $ [A        U SS9n U R                  [B        5      (       a  U RE                  [F        5      n U R                  [H        5      (       a  [K        U 5      n U" U 5      n U R                  [H        5      (       a  [K        U 5      n U R                  [L        5      (       a  [O        U 5      n U R                  [H        5      (       a9  [Q        U SSS9n U R                  [H        5      (       a  T" U [A        U 5      5      n U $ [S        U 5      n U R                  [L        5      (       a  [O        U 5      n U R                  [T        5      (       a  [W        U 5      n U R                  [X        [Z        5      (       a
  []        U SS9n U R                  [^        5      (       a  T" [a        U SS9[c        U 5      5      n U R                  [d        [f        5      (       a  [i        U 5      n U R                  [j        5      (       a  [m        U 40 TD6n U R                  [n        5      (       a>  U Rq                  U Rs                  [n        5       Vs0 s H  o[A        U5      _M     sn5      n U R                  [t        5      (       a  [w        U 40 TD6n SSK<J=n  U R                  U5      (       a  SSK>J?n  U" U 5      n T" [5        U SSS9[5        U 5      U 5      nT" U[9        U5      5      nT" U[A        U5      [        [        U5      5      5      nUR                  [X        [Z        [&        [        5      (       a  [        U5      n[        S S 5      nURq                  U5      n U R                  5       u  nnUR                  (       aC  [        [        SU-  SSS95      u  nnU[        R                  La  UU-  R                  5       U-  n U R                  5       (       a$  [        U 5      u  nnUS:w  a  [        U* U* -  5      n T" U 5      UT" U	5      -  :  a  U	n U
(       a  Uc
  [        U SS9n U" U 5      $ s  snf ) a  Simplifies the given expression.

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

Simplification is not a well defined term and the exact strategies
this function tries can change in the future versions of SymPy. If
your algorithm relies on "simplification" (whatever it is), try to
determine what you need exactly  -  is it powsimp()?, radsimp()?,
together()?, logcombine()?, or something else? And use this particular
function directly, because those are well defined and thus your algorithm
will be robust.

Nonetheless, especially for interactive use, or when you do not know
anything about the structure of the expression, simplify() tries to apply
intelligent heuristics to make the input expression "simpler".  For
example:

>>> from sympy import simplify, cos, sin
>>> from sympy.abc import x, y
>>> a = (x + x**2)/(x*sin(y)**2 + x*cos(y)**2)
>>> a
(x**2 + x)/(x*sin(y)**2 + x*cos(y)**2)
>>> simplify(a)
x + 1

Note that we could have obtained the same result by using specific
simplification functions:

>>> from sympy import trigsimp, cancel
>>> trigsimp(a)
(x**2 + x)/x
>>> cancel(_)
x + 1

In some cases, applying :func:`simplify` may actually result in some more
complicated expression. The default ``ratio=1.7`` prevents more extreme
cases: if (result length)/(input length) > ratio, then input is returned
unmodified.  The ``measure`` parameter lets you specify the function used
to determine how complex an expression is.  The function should take a
single argument as an expression and return a number such that if
expression ``a`` is more complex than expression ``b``, then
``measure(a) > measure(b)``.  The default measure function is
:func:`~.count_ops`, which returns the total number of operations in the
expression.

For example, if ``ratio=1``, ``simplify`` output cannot be longer
than input.

::

    >>> from sympy import sqrt, simplify, count_ops, oo
    >>> root = 1/(sqrt(2)+3)

Since ``simplify(root)`` would result in a slightly longer expression,
root is returned unchanged instead::

   >>> simplify(root, ratio=1) == root
   True

If ``ratio=oo``, simplify will be applied anyway::

    >>> count_ops(simplify(root, ratio=oo)) > count_ops(root)
    True

Note that the shortest expression is not necessary the simplest, so
setting ``ratio`` to 1 may not be a good idea.
Heuristically, the default value ``ratio=1.7`` seems like a reasonable
choice.

You can easily define your own measure function based on what you feel
should represent the "size" or "complexity" of the input expression.  Note
that some choices, such as ``lambda expr: len(str(expr))`` may appear to be
good metrics, but have other problems (in this case, the measure function
may slow down simplify too much for very large expressions).  If you do not
know what a good metric would be, the default, ``count_ops``, is a good
one.

For example:

>>> from sympy import symbols, log
>>> a, b = symbols('a b', positive=True)
>>> g = log(a) + log(b) + log(a)*log(1/b)
>>> h = simplify(g)
>>> h
log(a*b**(1 - log(a)))
>>> count_ops(g)
8
>>> count_ops(h)
5

So you can see that ``h`` is simpler than ``g`` using the count_ops metric.
However, we may not like how ``simplify`` (in this case, using
``logcombine``) has created the ``b**(log(1/a) + 1)`` term.  A simple way
to reduce this would be to give more weight to powers as operations in
``count_ops``.  We can do this by using the ``visual=True`` option:

>>> print(count_ops(g, visual=True))
2*ADD + DIV + 4*LOG + MUL
>>> print(count_ops(h, visual=True))
2*LOG + MUL + POW + SUB

>>> from sympy import Symbol, S
>>> def my_measure(expr):
...     POW = Symbol('POW')
...     # Discourage powers by giving POW a weight of 10
...     count = count_ops(expr, visual=True).subs(POW, 10)
...     # Every other operation gets a weight of 1 (the default)
...     count = count.replace(Symbol, type(S.One))
...     return count
>>> my_measure(g)
8
>>> my_measure(h)
14
>>> 15./8 > 1.7 # 1.7 is the default ratio
True
>>> simplify(g, measure=my_measure)
-log(a)*log(b) + log(a) + log(b)

Note that because ``simplify()`` internally tries many different
simplification strategies and then compares them using the measure
function, we get a completely different result that is still different
from the input expression by doing this.

If ``rational=True``, Floats will be recast as Rationals before simplification.
If ``rational=None``, Floats will be recast as Rationals but the result will
be recast as Floats. If rational=False(default) then nothing will be done
to the Floats.

If ``inverse=True``, it will be assumed that a composition of inverse
functions, such as sin and asin, can be cancelled in any order.
For example, ``asin(sin(x))`` will yield ``x`` without checking whether
x belongs to the set where this relation is true. The default is
False.

Note that ``simplify()`` automatically calls ``doit()`` on the final
expression. You can avoid this behavior by passing ``doit=False`` as
an argument.

Also, it should be noted that simplifying a boolean expression is not
well defined. If the expression prefers automatic evaluation (such as
:obj:`~.Eq()` or :obj:`~.Or()`), simplification will return ``True`` or
``False`` if truth value can be determined. If the expression is not
evaluated by default (such as :obj:`~.Predicate()`), simplification will
not reduce it and you should use :func:`~.refine` or :func:`~.ask`
function. This inconsistency will be resolved in future version.

See Also
========

sympy.assumptions.refine.refine : Simplification using assumptions.
sympy.assumptions.ask.ask : Query for boolean expressions using assumptions.
c                 B   > [        U 5      (       d  U S   $ [        U TS9$ )zg
Return the choice that has the fewest ops. In case of a tie,
the expression listed first is selected.
r   key)rZ   min)choicesmeasures    rf   shortersimplify.<locals>.shorterN  s'    
 7##1:7((rh   c                Z   > T(       a  U R                  5       OU nT" U[        U5      5      $ r   )doitrU   )r   r   r   r   s     rf   donesimplify.<locals>.doneW  s#    QVVX1r;r?++rh   rationalr   r   r   inverser   )r   r   r   r   r   _eval_simplifyNc                z   > [        U [        5      =(       a$    U R                  =(       a    [        U T5      (       + $ r   )rq   r   rr   )r   handleds    rf   r   simplify.<locals>.<lambda>|  s2    *Q% !&& w: 6 rh   c           
     v   > U R                   " U R                   Vs/ s H  n[        U40 TD6PM     sn6 $ s  snf r   )rv   rr   r   )r   r   r   s     rf   r   r   ~  s.    !&&!&&A&Q8A00&ABAs   6FsimultaneousTc                0   ^  [        T SU 4S j5      " 5       $ )Nnormalc                    > T $ r   r   ws   rf   r   ,simplify.<locals>.<lambda>.<locals>.<lambda>  s    1rh   )getattrr   s   `rf   r   r     s    ga9&E&Grh   r   )r2   )r   r   r   )Quantity)quantity_simplifyr*   )r   r   c                &    [        U R                  6 $ r   )r   rr   r   s    rf   r   r     s    #qvv,rh   c                    U R                   =(       ak    [        U R                  5      S:H  =(       aL    U R                  S   R                  =(       a,    U R                  S   R                  =(       a    U R
                  $ )Nrj   r   rp   )rs   rx   rr   	is_Numberr   is_commutativer   s    rf   r   r     sa    	 	AFFq		q		 	
q		 	
		rh   rp   )symbolic	max_terms)exponentr   )Mr   getrq   r   is_zeror   r	   Zeror   rU   r   r   rr   r   r   inversecombiner
   r   r   r3   r   r   nc_simplifyr   	nsimplify
_bottom_uprR   as_content_primitiverI   r   rH   r   r   r2   r   r1   r6   r7   r@   kroneckersimpr8   rQ   r:   
besselsimpr9   r4   rW   r,   r   
logcombiner/   r)   rN   r   sum_simplifyrA   xreplacer   r   product_simplifysympy.physics.unitsr   sympy.physics.units.utilr   r   r   r*   rX   r$   as_numer_denomr   rT   rS   Oner   r   r   )rb   r   r   r   r   r   r   r   r   original_exprfloats_eexpr1expr2r   r   r   short
hollow_mulnumerdenomndr   r   s     `  ``                @@rf   r   r     sy   v), 4+DGU+::i1JJz84::i1

64(*F $$,,!^^qvv55T#3T:N!'''&x~66MdE""$))488H%%d#yyK 3W$G<<	B  	D dG$$Dz4  Fu%-dGHD2245D	BB++-.EHT-xD/IJE

uT*dE""5)D xx~~||C  xx	d#Dz88I "$'Dxx''$T*xx	"" *$TF88I&&"4d);<D  K tDxxT"xx
$xx%'9::4(xx}}z$T2Jt4DExx%u-- ~xx}}D+F+xx}}(,

8(<>(<1|A(<> ? xx//,xx> &GD%d;WT]DQEE6%=)EE<.0@EAR0STEyy&(:GSIIE" 	J >>*%D&&(LE5||%%1EF1AEE>!G##%a'D$$&&~16QBG$Dt}uW]333 ("dU+:_>s   	Z.c                   [        U [        5      (       d[  U R                  U R                  [        5       Vs0 s H+  o"R	                  [
        5      (       d  M  U[        U40 UD6_M-     sn5      n [        U 5      n [        U [        5      (       d  U $ U R                  n/ n/ nU H  n[        [        R                  " U5      S SS9u  pxU(       d  UR                  U5        M?  [        U6 /nUR                  [        X V s/ s H  o R                  " S0 UD6PM     sn -   6 5        M     [        [        U5      /UQ76 n	U	$ s  snf s  sn f )z$Main function for Sum simplificationc                "    [        U [        5      $ r   rq   r   )r   s    rf   r   sum_simplify.<locals>.<lambda>  s    jC(rh   T)binaryr   )rq   r
   r  r   r   r   r  r   rr   r[   r   r   r   r   sum_combine)
r   r   r   termss_to_tterm	sum_termsotherresults
             rf   r  r  	  s"   aJJWWS\1!UU3Z 5<4V44!1 2q	AaFFE
C
Cd 3(7	JJte

3i!Pi"2"2"<V"<i!PPRS  S!(C(FM+1" "Qs   EEEc                   S/[        U 5      -  n[        S5       H}  n[        U 5       Hk  u  p4X   (       a  M  [        U 5       HL  u  pVX   (       a  M  X5:w  d  M  [        XFU5      n[	        U[
        [        45      (       d  M@  XpU'   X   nSX'   MN     Mm     M     [        R                  n[        U 5       H  u  p9X   (       a  M  [        X5      nM     U$ )zHelper function for Sum simplification

Attempts to simplify a list of sums, by combining limits / sum function's
returns the simplified sum
Frj   T)
rx   ranger{   sum_addrq   r   r   r	   r  r
   )
r(  usedmethodr   s_term1js_term2tempr-  s_terms
             rf   r&  r&  $  s     7SXD(#C.JA77"+C.JA77qv&w@%dS#J77%)F&)fG&*DG #1 )  VVFs^	ww(F $ Mrh   c                N    X#XES.nU(       a  [        U /UQ76 OU n[        U40 UD6$ )a  Return Sum with constant factors extracted.

If ``limits`` is specified then ``self`` is the summand; the other
keywords are passed to ``factor_terms``.

Examples
========

>>> from sympy import Sum
>>> from sympy.abc import x, y
>>> from sympy.simplify.simplify import factor_sum
>>> s = Sum(x*y, (x, 1, 3))
>>> factor_sum(s)
y*Sum(x, (x, 1, 3))
>>> factor_sum(s.function, s.limits)
y*Sum(x, (x, 1, 3))
)radicalclearrT   r2   )r   r   )selflimitsr9  r:  rT   r2   r   rb   s           rf   
factor_sumr=  >  s4    ( !,F!'3tfTD'''rh   c                   S n[        U [        5      (       a	  U" U 5      nOU n[        U[        5      (       a	  U" U5      nOUn[        U5      [        U5      L Ga~  US:X  aR  UR                  UR                  :X  a6  [	        [        UR                  UR                  -   /UR                  Q76 5      $ GO&US:X  Ga  [        UR                  UR                  -
  5      S:X  a  [        UR                  5      [        UR                  5      s=:X  a  S:X  a  O  OUR                  S   S   nUR                  S   S   nUR                  S   S   nUR                  S   S   n	UR                  S   S   n
UR                  S   S   nXi:X  aR  XS-   :X  a!  [	        [        UR                  XgU45      5      $ X{S-   :X  a!  [	        [        UR                  XjU45      5      $ [        X5      $ )z&Helper function for Sum simplificationc                    [         R                  " U 5      n[        S U 5       5      n[        U Vs/ s H  o3U:w  d  M
  UPM     sn6 n[        XBR                  -  /UR
                  Q76 $ s  snf )Nc              3  T   #    U  H  n[        U[        5      (       d  M  Uv   M      g 7fr   r#  )r   r   s     rf   r   .sum_add.<locals>.__refactor.<locals>.<genexpr>_  s     :t!z!S'9AAts   (	()r   r   nextr   functionr<  )valrr   sumvr   constants        rf   
__refactorsum_add.<locals>.__refactor]  s]    }}S!:t::D6DqID678mm+:dkk:: 7s
   	A+A+r   rp   rj   )
rq   r   r   r<  r=  r   rC  r   rx   r
   )r;  r,  r2  rG  rselfrotherr   x1y1r4  x2y2s               rf   r0  r0  X  s   
; $4 %E"E{d6l"Q;||v}},!#ennv&F"V"VWW -q[89Q>u||$FMM(:?a?Q*Aa+Ba+Ba(+Aq)!,Bq)!,Bva<#-c%..1"+.N#OO6\#-c%..1"+.N#OOtrh   c           
        [         R                  " U 5      n/ n/ nUR                  SS5      nU H  n[        U[        5      (       a[  U(       aA  UR                  [	        UR                  R                  " S0 UD6/UR                  Q76 5        M`  UR                  U5        Ms  UR                  U5        M     S/[        U5      -  n[        S5       Hs  n[        U5       Ha  u  pXy   (       a  M  [        U5       HB  u  pX{   (       a  M  X:w  d  M  [        XU5      n[        U[        5      (       d  M:  XU	'   SX{'   MD     Mc     Mu     [        U6 n[        U5       H  u  pXy   (       a  M  [        X5      nM     U$ )z(Main function for Product simplificationr   TFrj   r   )r   r   r  rq   r   r   rC  r   r<  rx   r/  r{   product_mul)r   r   r'  p_tr)  r   r*  r1  r2  r   p_term1r4  p_term2tmp_prodr-  p_terms                   rf   r  r    s=   MM!E
C
C::fd#DdG$$

74==#9#9#CF#C 1$(KK1 2 

4 JJt  7SXD(#C.JA77"+C.JA77qv#.w#H%h88%-F&*DG #1 )  #YFs^	ww(F $ Mrh   c                   [        U 5      [        U5      L Gac  US:X  aI  U R                  UR                  :X  a-  [        U R                  UR                  -  /U R                  Q76 $ GOUS:X  Ga  [	        U R                  UR                  -
  5      S:X  a  [        U R                  5      [        UR                  5      s=:X  a  S:X  a  O  OU R                  S   S   nU R                  S   S   nU R                  S   S   nUR                  S   S   nUR                  S   S   nUR                  S   S   nX6:X  a@  XuS-   :X  a  [        U R                  X4U45      $ XHS-   :X  a  [        U R                  X7U45      $ [        X5      $ )z*Helper function for Product simplificationr   rp   rj   )r   r<  r   rC  r   rx   r   )	r;  r,  r2  r   rK  rL  r4  rM  rN  s	            rf   rP  rP    sG   DzT%[ Q;{{ell*t}}u~~=LLL +q[671<t{{#s5<<'8=A=Aq)AQ*BQ*BQ*Aa+Ba+Bva<#*4==1"+#FF6\#*4==1"+#FFtrh   c                ~   SSK Jn  US-  S:X  a$  [        [        U 5      5      n US-  nUS-  S:X  a  M$  US:X  a  U $ U [	        SU5      -  n[        S5      n[        XU5      nUc  gU" Xe5      nU HJ  n[        X-
  5      R                  5       SSU-  -  :  d  M*  [        U5      n[        X-  5      U :X  d  MH  Us  $    g)	z_
helper function for ``nthroot``
It denests ``p**Rational(1, n)`` using its minimal polynomial
r   )solverj   rp   r   Ng      ?
   )
sympy.solversrX  rV   r+   r!   r   rL   absr  r   )	pr  precrX  pnr   r   solssols	            rf   _nthroot_solvera    s    
 $
a%1*tAwF a%1* 	Av	
HQN	BsAqQ'Ay;Dsx=??r"d({*S/C1$
	 rh   c                &   ^ U4S jn[        X5      $ )a-  
Takes logarithms and combines them using the following rules:

- log(x) + log(y) == log(x*y) if both are positive
- a*log(x) == log(x**a) if x is positive and a is real

If ``force`` is ``True`` then the assumptions above will be assumed to hold if
there is no assumption already in place on a quantity. For example, if
``a`` is imaginary or the argument negative, force will not perform a
combination but if ``a`` is a symbol with no assumptions the change will
take place.

Examples
========

>>> from sympy import Symbol, symbols, log, logcombine, I
>>> from sympy.abc import a, x, y, z
>>> logcombine(a*log(x) + log(y) - log(z))
a*log(x) + log(y) - log(z)
>>> logcombine(a*log(x) + log(y) - log(z), force=True)
log(x**a*y/z)
>>> x,y,z = symbols('x,y,z', positive=True)
>>> a = Symbol('a', real=True)
>>> logcombine(a*log(x) + log(y) - log(z))
log(x**a*y/z)

The transformation is limited to factors and/or terms that
contain logs, so the result depends on the initial state of
expansion:

>>> eq = (2 + 3*I)*log(x)
>>> logcombine(eq, force=True) == eq
True
>>> logcombine(eq.expand(), force=True)
log(x**2) + I*log(x**3)

See Also
========

posify: replace all symbols with symbols having positive assumptions
sympy.core.function.expand_log: expand the logarithms of products
    and powers; the opposite of logcombine

c                0	  >^ U R                   (       d  U R                  (       d  U $ U4S jnU4S jn/ n/ n[        [        5      m[        R
                  " U 5       GH  n[        U[        5      (       a%  U" U5      (       a  TS   R                  / U45        M>  UR                  (       d  UR                  U5        Mb  / n/ n/ nUR                   H  n	U	R                  (       a9  U	S:  a3  UR                  [        R                  5        UR                  U	* 5        MM  [        U	[        5      (       a   U" U	5      (       a  UR                  U	5        M  U" U	5      (       a  UR                  U	5        M  UR                  U	5        M     [        U5      S:  a  UR                  XgU45        GMP  U(       a$  T[        U5         R                  XxS   45        GM{  UR                  U5        GM     [        U5      S:X  a<  [        US   [        5      (       a$  TS   R                  / UR                  5       45        U(       d  [!        U4S jT 5       5      (       a  U $ U H  u  pn[        [#        U5      5      n[        UR                  S5      R                  S   [%        U6 -  5      nU(       a5  UR                  S5      n[        UR                  S   U-  5      nU(       a  M5  [%        U
6 Up[        U[        5      (       a  TU4   R                  / U45        M  UR                  X-  5        M     [        TR'                  5       5       H^  n[        [)        [%        TR                  U5       VVs/ s H  u  pUR                  S   [%        U6 -  PM     snn6 TS9SS	9T[%        U6 '   M`     [#        [        TR'                  5       5      5       H  nUT;  a  M  U* T;   a  X* nnUR+                  5       UR+                  5       :  a  UUnnUR                  U[        TR                  U5      R                  S   TR                  U5      R                  S   -  SS	9-  5        M  UR                  UTR                  U5      -  5        M     [	        U6 $ s  snnf )
Nc                   > U [         R                  L=(       a*    U R                  =(       d    T=(       a    U R                  SL$ )NF)r	   r   is_extended_real)r   re   s    rf   gooda$logcombine.<locals>.f.<locals>.gooda  s;     Q]]* R##Pu'P1C1C51PSrh   c                v   > U R                   S   nUR                  =(       d    T=(       a    UR                  SL$ )Nr   F)rr   r   is_nonpositive)lr   re   s     rf   goodlog&logcombine.<locals>.f.<locals>.goodlog  s/    q	A==KE$Ka.>.>e.KKrh   r   r   rp   c              3  j   >#    U  H(  n[        TU   5      S :H  =(       a    TU   S   / :H  v   M*     g7f)rp   r   N)rx   )r   r   log1s     rf   r   (logcombine.<locals>.f.<locals>.<genexpr>;  s3     QDqCQLA-B$q'!*2BBDs   03rk   Fr   )r   rs   r   rz   r
   r   rq   r,   r   rr   is_Rationalr	   r   rx   tupler   r   r%   r   keysr  r   )r   rf  rk  r,  logsr   otcoloaior   rj  lir   r   numdenrn  re   s                     @rf   r   logcombine.<locals>.f	  s   		RYYI	S	L
 4 r"A!S!!gajjRQ(XXQ&&B~~"q&		!--0		2##B,,		"r		"		" ! r7Q;KK-rO**B1;7LLO1 #8 u:?z%(C88HOOR-. QDQQQI GA!WQZ AAEE!HMM!$c1g-.AUU1X
A& ! 7Aq!S!!aT
!!2q'*QS!  diik"A
3/3xx{1</:tqq	37"{1< ,=!',.DaM # diik*+A}rTz bS==?S]]_4"CCDHHSM..q1$((3-2D2DQ2GG%*, ,- Qtxx{]+ , E{)1<s   0$Rr
  )rb   re   r   s    ` rf   r  r    s    \]~ drh   c                    S n[        X5      $ )a  Simplify the composition of a function and its inverse.

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

No attention is paid to whether the inverse is a left inverse or a
right inverse; thus, the result will in general not be equivalent
to the original expression.

Examples
========

>>> from sympy.simplify.simplify import inversecombine
>>> from sympy import asin, sin, log, exp
>>> from sympy.abc import x
>>> inversecombine(asin(sin(x)))
x
>>> inversecombine(2*log(exp(3*x)))
6*x
c                X   [        U [        5      (       a  [        U R                  S   [        5      (       dI  U R                  S   R                  (       aD  U R                  S   R
                  [        R                  :X  a  U R                  S   R                  n OU R                  (       a  [        U S5      (       a  [        U R                  5      S:X  am  [        U R                  S   R                  5      S:X  aG  [        U R                  S   U R                  SS95      (       a  U R                  S   R                  S   n U R                  (       aV  U R
                  [        R                  :X  a8  [        U R                  [        5      (       a  U R                  R                  S   n U $ )Nr   r   rp   )argindex)rq   r,   rr   r*   r|   r}   r	   r~   is_Functionhasattrrx   r   )r   s    rf   r   inversecombine.<locals>.f  s   b#"''!*c**rwwqz/@/@RWWQZ__XYX^X^E^WWQZ^^^^I 6 6BGG!c"''!*//&:a&?"''!*bjj!j&<==WWQZ__Q'99AFF*"&&#&&VV[[^	rh   r}  )rb   r   s     rf   r  r  k  s    , drh   c                   ^ S mU4S jnU R                  [        5      (       d  U $ U R                  [        5      (       a  U R                  [        5      n U nSn X :w  a  Un U R	                  S U5      nX :w  a  M  U $ )a-  
Simplify expressions with KroneckerDelta.

The only simplification currently attempted is to identify multiplicative cancellation:

Examples
========

>>> from sympy import KroneckerDelta, kroneckersimp
>>> from sympy.abc import i
>>> kroneckersimp(1 + KroneckerDelta(0, i) * KroneckerDelta(1, i))
1
c                    [        S5       Hn  n[        S5       H\  nX   nX   nXS-   S-     nXS-   S-     n[        XE5      [        R                  L d  M=  [        Xg5      [        R                  L d  M[      g   Mp     g)Nrj   rp   TF)r/  r   r	   truefalse)args1args2i1i2a1a2a3a4s           rf   args_cancel"kroneckersimp.<locals>.args_cancel  ss    (BAhYYFa<(Fa<(b:'BrJ!'',A   rh   c                  > U R                   nU Vs/ s H  n[        U[        5      (       d  M  UPM     nn[        US5       H?  u  pEUR                   nUR                   nT" Xg5      (       d  M,  [        R
                  U -  s  $    U $ s  snf )Nrj   )rr   rq   r@   r\   r	   r  )	mrr   r   deltasdelta1delta2r  r  r  s	           rf   cancel_kronecker_mul+kroneckersimp.<locals>.cancel_kronecker_mul  st    vv!CTZ>%B!TC%fa0NFKKEKKE5((vvz!	 1
  Ds
   BBNc                "    [        U [        5      $ r   )rq   r   )r   s    rf   r   kroneckersimp.<locals>.<lambda>  s    As);rh   )r   r@   r6   r   r   )rb   r  newexprr  s      @rf   r  r    st    	 88N##xx	||N+GD
/,,;=QR / Krh   c           
       ^	 S nS nS nU n[         [        [         [        -  S-  5      [        [         * [        -  S-  5      /nU R                  [        U" [        U" [        [
        5      U5      5      n U R                  [
        U" [
        U" [
        [        5      U5      5      n S[        [         [        -  5      /nU R                  [        U" [        U" [        5      U5      5      n U R                  [
        U" [
        U" [
        5      U5      5      n [        S5      m	U	4S jnU R                  [        U" [        5      5      n U R                  [        U" [        5      5      n U R                  [
        U" [
        5      5      n U R                  [        U" [        5      5      n S nU" U 5      n X:w  a  U R                  5       n U $ )	a  
Simplify bessel-type functions.

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

This routine tries to simplify bessel-type functions. Currently it only
works on the Bessel J and I functions, however. It works by looking at all
such functions in turn, and eliminating factors of "I" and "-1" (actually
their polar equivalents) in front of the argument. Then, functions of
half-integer order are rewritten using trigonometric functions and
functions of integer order (> 1) are rewritten using functions
of low order.  Finally, if the expression was changed, compute
factorization of the result with factor().

>>> from sympy import besselj, besseli, besselsimp, polar_lift, I, S
>>> from sympy.abc import z, nu
>>> besselsimp(besselj(nu, z*polar_lift(-1)))
exp(I*pi*nu)*besselj(nu, z)
>>> besselsimp(besseli(nu, z*polar_lift(-I)))
exp(-I*pi*nu/2)*besselj(nu, z)
>>> besselsimp(besseli(S(-1)/2, z))
sqrt(2)*cosh(z)/(sqrt(pi)*sqrt(z))
>>> besselsimp(z*besseli(0, z) + z*(besseli(2, z))/2 + besseli(1, z))
3*z*besseli(0, z)/2
c                2   ^ ^^ [        T5      mUU U4S jnU$ )Nc                x   > TR                  [        R                  " U5      5      (       a  T" X5      $ T" X5      $ r   )r   r   r   )nuzfactorsfrotos     rf   repl*besselsimp.<locals>.replacer.<locals>.repl  s1    ##CMM!$455"y r:rh   )r   )r  r  r  r  s   ``` rf   replacerbesselsimp.<locals>.replacer  s    g,	 rh   c                   ^ ^ U U4S jnU$ )Nc                2   > T" X5      R                  T5      $ r   )r   )r  r  r  r  s     rf   tofunc-besselsimp.<locals>.torewrite.<locals>.tofunc  s    r:%%b))rh   r   )r  r  r  s   `` rf   	torewritebesselsimp.<locals>.torewrite  s    	*rh   c                   ^  U 4S jnU$ )Nc                z   > [        [        [        -  U -  5      T" U [        [        * [        -  5      U-  5      -  $ r   )r*   r   r    r-   )r  r  r  s     rf   r  +besselsimp.<locals>.tominus.<locals>.tofunc  s1    qtBw<B	1"R%(8(: ;;;rh   r   )r  r  s   ` rf   tominusbesselsimp.<locals>.tominus  s    	<rh   rj   r   r  c                   >^  U U4S jnU$ )Nc           
     h  > U S-  [         R                  :X  ag  [        [        [	        T" U T5      R                  [        5      R                  [        5      R                  SS95      R                  TU5      5      5      $ U R                  (       a  U S:  a  T" X5      R                  SS9$ T" X5      $ )Nrp   T)rv   )r	   Halfr   rW   r0   r   r;   r?   r   r   
is_Integer)r  r  r  z0s     rf   r  *besselsimp.<locals>.expander.<locals>.repl
  s    Q166!B++G4<<R@GG!% H '*((,R!5 6 6 262z((d(33r:rh   r   )r  r  r  s   ` rf   expanderbesselsimp.<locals>.expander	  s    	 rh   c                    S nU R                  [        5      (       a  U" [        U 5      n U R                  [        5      (       a  U" [        U 5      n U $ )Nc                |  ^   UR                  U 4S j5      n [        US S9 Hz  nUR                  u  pET " US-   U5      nT " US-   U5      nUR                  U5      (       d  MA  UR                  U5      (       d  MY  UR	                  USUS-   -  U-  U-  U-
  5      n  O   U$ M  ! [
        [        4 a    Us $ f = f)Nc                   > [        U T5      $ r   )rq   )r   bessels    rf   r   Tbesselsimp.<locals>._bessel_simp_recursion.<locals>._use_recursion.<locals>.<lambda>  s    jF.Crh   c                2    [        U R                  S   5      $ )Nr   )r.   rr   r   s    rf   r   r    s    BqvvayMrh   r   rp   rj   )findsortedrr   r   r   r   	TypeError)r  rb   besselsbar   r   bap1bap2s   `       rf   _use_recursionBbesselsimp.<locals>._bessel_simp_recursion.<locals>._use_recursion  s    ))$CD $W2IJ!ww%ac1~%ac1~88D>>dhhtnn#'99RAaC4$1F#GD! K  $  #I.  K s$   AB& %B& ="B&  B& &B;:B;)r   r;   r>   )rb   r  s     rf   _bessel_simp_recursion*besselsimp.<locals>._bessel_simp_recursion  sD    	  88G!'40D88G!'40Drh   )
r   r-   r    r   r;   r<   r   r>   r=   rJ   )
rb   r  r  r  	orig_exprifactorsminusfactorsr  r  r  s
            @rf   r  r    su   @

 I9QrT!V$i2a&89H<<''7#X/0D <<''7#X/0D 	!B$(L<<'77#3\BDD<<'77#3\BDD 
sB	 <<'!23D<<'!23D<<'!23D<<'!23D. "$'D{{}Krh   c                   [        U 5      n [        U5      nU [        SU5      -  nUR                  (       d  U$ [        U 5      (       d  U$ / nU R                   Vs/ s H  ofR                  5       PM     nnU H  u  phUR                  (       d  Us  $ U[        R                  L a  M/  UR                  (       a9  UR                  [        R                  :X  a  UR                  R                  (       d  Us  $ UR                  U5        M     UR                  5         USU nU S:  aG  US-  S:X  a>  U * [        SU5      -  n[        XES9n	[!        X-  5      [!        U * 5      :X  a  U	n
U
* $ Un
U
* $ [        XES9n	[!        U	5      [!        U5      La%  [!        X-  5      [!        U 5      :X  a  [!        U	5      $ [#        XU5      n U c  U$ U $ s  snf )a  
Compute a real nth-root of a sum of surds.

Parameters
==========

expr : sum of surds
n : integer
max_len : maximum number of surds passed as constants to ``nsimplify``

Algorithm
=========

First ``nsimplify`` is used to get a candidate root; if it is not a
root the minimal polynomial is computed; the answer is one of its
roots.

Examples
========

>>> from sympy.simplify.simplify import nthroot
>>> from sympy import sqrt
>>> nthroot(90 + 34*sqrt(7), 3)
sqrt(7) + 3

rp   Nr   rj   )	constants)r   r!   
is_integerrK   rr   r   is_rationalr	   r  r|   r*   r  r}   r   sortr	  r   ra  )rb   r  max_lenr]  r\  surdsr   
coeff_mulsyr   ress              rf   nthrootr  7  s   6 4=D
Ahq!nA<<E,0II6Iq.."IJ6}}H:QUUaff_1B1BHQ  
JJL(7OEaxAEQJUXa^#a)AD>Xte_4at ;<t!%A{(1+%(14.HTN*J{$4(D|K- 7s   Gc           
       ^^^^^  [        [        U 5      5      $ ! [        [        4 a     Of = f[        U 5      R	                  [        S5      [        R                  [        S5      [        R                  05      n U [        R                  L d  U [        R                  L a  U $ U(       d  U R                  (       a  [        U TU5      $ Tcn  S[        S/U R                  [
        5       Vs/ s H6  n[        R                  R                  R!                  UR"                  5      PM8     Os  snf sn-   5      * -  mSm[%        TS-  5      m0 mU HX  n[        U5      nUR'                  T5      nUR(                  (       d  [        S5      eUR+                  T5      T[-        U5      '   MZ     U R'                  TSS	9n	U	R/                  5       u  pU
R0                  (       a  UR0                  (       d  U $ UUUUU4S
 jn U
(       a  U" U
5      n
U(       a  U" U5      nO ! [         a    Uc  [        XS9s $ U s $ f = fX[        R2                  -  -   nX:w  d  USL a  U$ [        XS9$ )am  
Find a simple representation for a number or, if there are free symbols or
if ``rational=True``, then replace Floats with their Rational equivalents. If
no change is made and rational is not False then Floats will at least be
converted to Rationals.

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

For numerical expressions, a simple formula that numerically matches the
given numerical expression is sought (and the input should be possible
to evalf to a precision of at least 30 digits).

Optionally, a list of (rationally independent) constants to
include in the formula may be given.

A lower tolerance may be set to find less exact matches. If no tolerance
is given then the least precise value will set the tolerance (e.g. Floats
default to 15 digits of precision, so would be tolerance=10**-15).

With ``full=True``, a more extensive search is performed
(this is useful to find simpler numbers when the tolerance
is set low).

When converting to rational, if rational_conversion='base10' (the default), then
convert floats to rationals using their base-10 (string) representation.
When rational_conversion='exact' it uses the exact, base-2 representation.

Examples
========

>>> from sympy import nsimplify, sqrt, GoldenRatio, exp, I, pi
>>> nsimplify(4/(1+sqrt(5)), [GoldenRatio])
-2 + 2*GoldenRatio
>>> nsimplify((1/(exp(3*pi*I/5)+1)))
1/2 - I*sqrt(sqrt(5)/10 + 1/4)
>>> nsimplify(I**I, [pi])
exp(-pi/2)
>>> nsimplify(pi, tolerance=0.01)
22/7

>>> nsimplify(0.333333333333333, rational=True, rational_conversion='exact')
6004799503160655/18014398509481984
>>> nsimplify(0.333333333333333, rational=True)
1/3

See Also
========

sympy.core.function.nfloat

infz-infrY        gp=
ף
@zconstants must be real-valuedT)chopc                  > [         R                  R                  nU R                  T5      n T
(       dq  T(       dj  S[         R                  l        [         R                  " US/5      nUb:  [        [        US   5      * [        US   5      5      U[         R                  l        $ T	[         R                  l        [         R                  " UTT
TS9nU(       d  [        eT(       a  US   n[        U5      nU (       a  U(       d  [        eUR                  SL a*  U[         R                  [         R                  4;  a  [        eUU[         R                  l        $ ! U[         R                  l        f = f)Nr  rp   r   )r  tolfullF)mpmathmpdps
_to_mpmathpslqr!   intidentifyr   r   	is_finiter  ninf)r   origxvratr  rb   bprecconstants_dictr  r]  	tolerances         rf   nsimplify_real!nsimplify.<locals>.nsimplify_real  s   yy}}\\% 	! "		kk2q'*?#SQ[L#c!f+>" !FIIM! !FIIMoobND*G  !!*7#D  ~~&2fjj&++5N+N   !FIIMDFIIMs   A"E &BE E1)rational_conversionF)r   r^   r  r   r  r   r	   r   NegativeInfinityry   _real_to_rationalr   r   r  libmplibmpfprec_to_dps_precr  evalfis_Floatr  stras_real_imagr   ImaginaryUnit)rb   r  r  r  r   r  r  rF  r   exprvalr.   imr  r   r  r  r]  s     ``          @@@rf   r	  r	  s  s   lvd|$$z" 4=!!eajjfq))#
 D qzzTQ%7%774$$ y2EFF
 bTjj')' ll!!--agg6')) * * *	
 DT	NEN8$NN4 zz<==()U(;s8}%  jjDj)G!!#FB LLR\\! !6#B#B $TSS
 
 	 B 
zX&	TKKs*    ..,=D*<H H83H87H8c           
     8   [        U 5      n [        S5      nU n0 nSnUb  US:  a  [        SU-  5      nUR                  [        5       GH  nUnUb  [	        U5      R                  U5      n	GOUbH  US:  aB  UR                  SL a3  [	        U[        Xq-  5      -  5      R                  [        U5      5      n	GOJUS:X  a  [	        U5      n	XU'   M  US:w  a  [        S5      e[        USS9n	U(       a  U	(       d  [	        U5      n	OU	R                  (       d  XsU* 4;   a  [        R                  n	OUS	:  a^  U* n[        S
[        [        R                   " U5      [        R                   " S
5      -  5      5      n
[	        [#        Xz-  5      5      * U
-  n	OpUS	:  aZ  [        S
[        [        R                   " U5      [        R                   " S
5      -  5      5      n
[	        [#        Xz-  5      5      U
-  n	O[        R$                  n	XU'   GM     UR'                  USS9$ )a  
Replace all reals in expr with rationals.

Examples
========

>>> from sympy.simplify.simplify import _real_to_rational
>>> from sympy.abc import x

>>> _real_to_rational(.76 + .1*x**.5)
sqrt(x)/10 + 19/25

If rational_conversion='base10', this uses the base-10 string. If
rational_conversion='exact', the exact, base-2 representation is used.

>>> _real_to_rational(0.333333333333333, rational_conversion='exact')
6004799503160655/18014398509481984
>>> _real_to_rational(0.333333333333333)
1/3

r  Nrp   Fexactbase10z/rational_conversion must be 'base10' or 'exact'r   r   rY  Tr   )r&   r   r5   r   r!   limit_denominatorr  roundr  r   r	  rp  r	   ComplexInfinityr   r  r,   r  r  r   )rb   r  r  r  r\  r   
reduce_numflr   r   r   s              rf   r  r    s   , D>D
,CADJQQy[)
ggen!..z:A#	Q&5#66 ##C	N3  #g-RLS	$0 !RSS"u-A!RL]]t$))A!VBBFJJrN6::b>$A BCA!#bd),,Q.A!VBFJJrN6::b>$A BCA RT+A-AAS	A B 66$T6**rh   c                   SnU R                   nU R                  (       a  [        R                  X-
  4$ U (       a_  X :w  aZ  U nU(       a  U R	                  5       O[        U 5      R                  SS9u  p@X-  nU R                  SS9u  pPX-  nU (       a  X :w  a  MZ  [        U SS9n U R                  5       (       a  U * n U* nX4$ )a  Return `p, r` where `p` is the expression obtained when Rational
additive and multiplicative coefficients of `expr` have been stripped
away in a naive fashion (i.e. without simplification). The operations
needed to remove the coefficients will be applied to `rhs` and returned
as `r`.

Examples
========

>>> from sympy.simplify.simplify import clear_coefficients
>>> from sympy.abc import x, y
>>> from sympy import Dummy
>>> expr = 4*y*(6*x + 3)
>>> clear_coefficients(expr - 2)
(y*(2*x + 1), 1/6)

When solving 2 or more expressions like `expr = a`,
`expr = b`, etc..., it is advantageous to provide a Dummy symbol
for `rhs` and  simply replace it with `a`, `b`, etc... in `r`.

>>> rhs = Dummy('rhs')
>>> clear_coefficients(expr, rhs)
(y*(2*x + 1), _rhs/12)
>>> _[1].subs(rhs, 2)
1/6
NTr   Fr   )
ry   rp  r	   r  r  r   r   as_coeff_Addr   r   )rb   rhswasfreer  r   s         rf   clear_coefficientsr  ?  s    6 CD
##
3;  %%'++T+: 	 	##T#2 3; DU+D$$&&ud9rh   c           
       ^#^$^%^& [        U [        5      (       a+  U R                  SS9n [        [        [
        [        4u  m#m$m%nO[        [        [        [        4u  m#m$m%nS nU$U%4S jnU#U$U%U&4S jm&U&4S jn[        U T#T$T%45      (       a  U R                  (       a  U $ U R                  SS n[        U T%5      (       a/  U(       a&  T%" [        US   5      US	   5      R                  5       $ U $ [        U T#5      (       a+  T#" U Vs/ s H  n[        XqS
9PM     sn6 R                  5       $ U R                  5       u  p[        U6 n	[        U	S	5      (       d  U	[        X	-  US
9-  $ U" U5      u  pSnU
[!        U5      S-  :  a  SnUSSS2    Vs/ s H  owS-  PM	     nnU(       a  [#        S U 5       5      nU" U5      n0 nS	nS	nSnSn[%        S	[!        U5      5       GHP  nSnSnSnU[!        U5      S	-
  :  a  UU   S   nUnUS	-   nU[!        U5      S	-
  :X  d  WS/:X  a  [        UU   T%5      (       az  [        UU   R                  S   U5      (       dY  UU   R                  S   R                  n[!        U5      nUUU-
  U U:X  a
  US	-  nUU-  nUUS	-   US	-   U-    U:X  a
  US	-  nUU-  nU(       a  UUU   R                  S	   -  nOM  US   nUUS	-
  -  nUUU nSnUU-  nWU;   a  UU   U:  a  GM  U[!        U5      :  a{  UUUS	-
     S   ;   a  US	-  nUU-  nOP[        UU   T%5      (       a;  UU   R                  S   R                  U:X  a  UUU   R                  S	   -  nUS	-  nOOU[!        U5      :  a  M{  SnS	nUU-
  S:  a  UUU-
  S	-   U US	S :X  a  [        US   T%5      (       a%  US   R                  S   nUS   R                  S	   nOUS   nS	n[        UUU-
     T%5      (       a<  UUU-
     R                  S   U:X  a#  UUU-
     R                  S	   U-
  nUU-  nUS	-  nOUUU-
     U:X  a  S	U-
  nUU-  nUS	-  nSnS	nUU-   S	-
  [!        U5      :  a  UUUU-   S	-
   USS :X  a  [        US   T%5      (       a%  US   R                  S   nUS   R                  S	   nOUS   nS	n[        UUU-   S	-
     T%5      (       aB  UUU-   S	-
     R                  S   U:X  a&  UUU-   S	-
     R                  S	   U-
  nUU-  nUS	-  nOUUU-   S	-
     U:X  a  S	U-
  nUU-  nUS	-  nU(       a  WS-  S:X  a  US:  a  US-  nS	nS	n [        UUS	-
     T%5      (       a7  UUS	-
     R                  S   U:X  a  UU-   n UUS	-
     R                  S	   U-
  nOUUS	-
     U:X  a
  UU-   n S	U-
  nUS:X  d  U S:X  a%  U(       d  US	-  nU nUnUnUU-  4USS -   UU-  4-   nUUU-
  -  nU(       a  US	-  nU(       a  US	-  nUUU'   UU:  d  GM:  UnUT$" U6 UUU4nUU-  nUU-  nGMS     U(       ab  T%" [        US	   US
9US   5      n[        T$" USUS    6 U-  US
9nU[        T$" UUS   S 6 US
9-  nUU-  U-  nUS	:w  d  US	:w  a
  [        USS
9nOT$" U6 nU(       a	  T%" US5      n[        U [        5      (       d&  ['        U 5      n!U!U :w  a  [        U!US
9n"U" UU"5      nU$ UR                  SS9nU$ s  snf s  snf )a  
Simplify a non-commutative expression composed of multiplication
and raising to a power by grouping repeated subterms into one power.
Priority is given to simplifications that give the fewest number
of arguments in the end (for example, in a*b*a*b*c*a*b*c simplifying
to (a*b)**2*c*a*b*c gives 5 arguments while a*b*(a*b*c)**2 has 3).
If ``expr`` is a sum of such terms, the sum of the simplified terms
is returned.

Keyword argument ``deep`` controls whether or not subexpressions
nested deeper inside the main expression are simplified. See examples
below. Setting `deep` to `False` can save time on nested expressions
that do not need simplifying on all levels.

Examples
========

>>> from sympy import symbols
>>> from sympy.simplify.simplify import nc_simplify
>>> a, b, c = symbols("a b c", commutative=False)
>>> nc_simplify(a*b*a*b*c*a*b*c)
a*b*(a*b*c)**2
>>> expr = a**2*b*a**4*b*a**4
>>> nc_simplify(expr)
a**2*(b*a**4)**2
>>> nc_simplify(a*b*a*b*c**2*(a*b)**2*c**2)
((a*b)**2*c**2)**2
>>> nc_simplify(a*b*a*b + 2*a*c*a**2*c*a**2*c*a)
(a*b)**2 + 2*(a*c*a)**3
>>> nc_simplify(b**-1*a**-1*(a*b)**2)
a*b
>>> nc_simplify(a**-1*b**-1*c*a)
(b*a)**(-1)*c*a
>>> expr = (a*b*a*b)**2*a*c*a*c
>>> nc_simplify(expr)
(a*b)**4*(a*c)**2
>>> nc_simplify(expr, deep=False)
(a*b*a*b)**2*(a*c)**2

F)
inv_expandc                   U SS   Vs/ s H  oU S   :X  a  SS/OS/PM     sn/n[        S[        U 5      5       H  n/ nSn[        [        U 5      U-
  S-
  5       Hr  n/ nX#S-
     US-       HE  nXS-   S-   U-   [        U 5      :  d  M  X   XU-   S-   U-      :X  d  M1  UR                  US-   5        MG     US/-  nUR                  U5        Mt     UR                  U5        M     U$ s  snf )Nrp   r   )r/  rx   r   )rr   r   r  r   overlapsr4  overlapr   s           rf   	_overlapsnc_simplify.<locals>._overlaps  s     :>abBAd1g1vA3.BCq#d)$AHA3t9q=1,-Q3!Auqy1}s4y0TWqSU1W5Mq1u- % A3( . HHX %  Cs   C(c                
  > Sn/ n/ nU  H  n[        UT5      (       a.  UR                  S   R                  (       a  US-  /U-   nUS-  nMB  [        U5      S:X  a  UR	                  US   S-  5        O;[        U5      S:  a,  UR	                  T" T" U6 S5      5        U[        U5      S-
  -  n/ nUR	                  U5        M     U(       a,  UR	                  T" T" U6 S5      5        U[        U5      S-
  -  nU[        U5      4$ )Nr   rp   r   )rq   rr   is_extended_negativerx   r   rq  )_argsinv_totinversesrr   r   _Mul_Pows        rf   _reduce_inverses%nc_simplify.<locals>._reduce_inverses  s     C#t$$!)I)IG9x/1x=A%KKR0]Q&KKT8_b 9:s8}q00GC   KKT8_b12s8}q((Gd##rh   c                   > [        U T5      (       a  T" U R                  S   5      $ [        U TT45      (       a  [        U4S jU R                   5       5      $ g)Nr   c              3  4   >#    U  H  nT" U5      v   M     g 7fr   r   )r   r   	get_scores     rf   r   1nc_simplify.<locals>.get_score.<locals>.<genexpr>  s     4Vy||Vs   rp   )rq   rr   sum)r   _Addr  r  r!  s    rf   r!  nc_simplify.<locals>.get_score  sN     aQVVAY''D$<((4QVV444rh   c                :   > X:w  a  T" U5      T" U 5      :  a  U$ U $ r   r   )r   alt_sr!  s     rf   comparenc_simplify.<locals>.compare  s$     :)E*Yq\9Lrh   Nr   rp   r   rj   Tr   c              3  8   #    U  H  n[        U5      v   M     g 7fr   )r  )r   r   s     rf   r   nc_simplify.<locals>.<genexpr>  s     2T[^^Tr      )rq   rC   r   rD   rE   rF   rG   r
   r   r   r   r   rr   r  r   r"   rx   rq  r/  r   )'rb   r   _Symbolr  r  r(  rr   r   c_args	com_coeffr  invertr  simpspostpremax_simp_coeffsimpr   
simp_coeffrj  r\  repstartendsubtermpre_exppre_argr*   post_exppost_arg_pre_exp	_post_expf_expralt_simpr$  r  r  r!  s'                                      @@@@rf   r  r  m  s   R $
##yyEy*$*FFL$H!dD'$'c6$9!dD'0$4  dT4.//43F3F99Q<D$DG,d1g6;;==K	D$		>Ak!/>?DDFF }}L	Iq))[dCCC$T*MG FT1#DbDz*z!2z*2T22$A ED
C ND1c$i 
s4y1}A$q'CcD	!sqcz 47D)) *47<<?G D Dq',,q/..L!A;') FAQJE!AaCE?g-FA1HCT!W\\!_$AAQUNE5oGA1HCeg% 7  CIoAc!eHQKQqDIt,,c1B1G1G71RT#Y^^A&&q CIo 19>d5719U3wqr{B'!*d++!!*//!,ajooa(!!*$uQw-..4a=3E3Ea3HG3SuQw-,,Q/#5
QeAg')c'
Q7Q;T"tCAa'8GCRL'H'"+t,,"2;++A.bk&&q)"2;$s1uQw-..4Aa=3E3Ea3HH3TAa=--a036qQc!eAg(*s7qQ a1a%CHI$uQw-..4a=3E3Ea3HH3T$sN	a=--a036eAg(*$sN	s71}	QQJE$""#S=*WSb\9Xs]<LLc%i
!OJ!OJg&'N4>1c15D7"CX%DM !P {476Q@$Xd1g/3$?Kd478n 5DAA7{4!8tqy t%0DT{D"~ dJ''4T>"65H4*D K yyEy*KQ ? +s   [>\c                  ^ S nU4S jmSn[        U [        5      (       Ga  U R                  (       d#  U R                  (       d  U R                  (       Ga  U R                  SSSSSSSSS9nX@:w  a  Un SnU" U 5      u  pVUS:  am  U(       ad  0 nT" X5      nX@L d  U" U5      S   S:  aG  [        U5      nX:w  a7  UR                  UR                  5        V	V
s/ s H  u  pX4PM
     sn
n	5      n SnGO<US	:X  Ga3  U R                  (       Ga!  U R                  S   R                  (       Ga  U R                  S
   R                  (       a  U R                  S   R                  S   R                  (       a  U R                  S
   R                  S   R                  (       a  U R                  S   R                  S   R                  [        R                  L aW  U R                  S
   R                  S   R                  [        R                  L a   [        U 5      nU" U5      S   nX:  a  Un SnOSnU(       a  X4$ U $ s  sn
n	f )ac  Simplification for a sum of products targeted at the kind of blowup that
occurs during summation of products. Intended to reduce expression blowup
during matrix multiplication or other similar operations. Only works with
algebraic expressions and does not recurse into non.

Parameters
==========

withsimp : bool, optional
    Specifies whether a flag should be returned along with the expression
    to indicate roughly whether simplification was successful. It is used
    in ``MatrixArithmetic._eval_pow_by_recursion`` to avoid attempting to
    simplify an expression repetitively which does not simplify.
c                   SnU /nSnU(       Ga{  UR                  5       n[        U[        5      (       d  M/  UR                  (       aI  U[        R
                  La4  U[        UR                  S:  5      [        UR                  S:g  5      -   -  nGOUR                  (       Ga  UR                  5       (       a<  US-  nUR                  S   [        R                  L a  UR                  5       S   nOU* n[        U5      u  pVUR                  (       a'  US[        US:  5      -   -  nUR!                  U5        GOHU[        R
                  La;  UR                  (       d  UR!                  U5        SnUS-  nUR!                  U5        OU[#        UR                  5      S-
  -  nUR%                  UR                  5        OUR&                  (       ab  [#        UR                  5      nSnUR                   H1  n	U	R                  5       (       a  US-  nU	* n	UR!                  U	5        M3     XX:g  -
  -  nOPUR(                  (       a?  US-  nUR!                  UR*                  5        U(       d  UR,                  R.                  SLnU(       a  GM{  X4$ )a  Optimized count algebraic operations with no recursion into
non-algebraic args that ``core.function.count_ops`` does. Also returns
whether rational functions may be present according to negative
exponents of powers or non-number fractions.

Returns
=======

ops, ratfunc : int, bool
    ``ops`` is the number of algebraic operations starting at the top
    level expression (not recursing into non-alg children). ``ratfunc``
    specifies whether the expression MAY contain rational functions
    which ``cancel`` MIGHT optimize.
r   Frp   T)r   rq   r   rp  r	   r  boolr\  qrs   r   rr   r   as_two_termsrT   r  r   rx   extendr   r|   r}   r*   is_negative)
rb   opsrr   ratfuncr   r  r   laargsnegsrw  s
             rf   count_ops_alg"dotprodsimp.<locals>.count_ops_alg  s     &
Aa''}}AEE>4q>D!##(O;;C--//1HCvvayAMM1NN,Q/B{<<1tQU|++CKKNaee^<<A $1HCKKN 3qvv;?*CKK'QVV&&B2244	!#KKO	 ! 00qAFF#ee//u<Gk dn |rh   c                  > U R                   (       d  U $ U R                  (       d"  U R                  (       d  U R                  (       a^  Sn[	        U R                   5       H/  u  p4T" XA5      nXTL a  M  Uc  [        U R                   5      nXRU'   M1     Uc  U $ U R                  " U6 $ UR                  U [        5       5      $ )zSubstitute dummy variables for non-algebraic expressions to avoid
evaluation of non-algebraic terms that ``polys.polytools.cancel`` does.
N)	rr   r   rs   r|   r{   rz   rv   
setdefaultr   )rb   dummiesrr   r   r   r   nonalg_subs_dummiess         rf   rS  (dotprodsimp.<locals>.nonalg_subs_dummies  s    
 yyK;;$++D!$)),'36<		?DQ - |99d##!!$00rh   FTN)r   modulus
power_base	power_exprl   r,   rm   r      r      rp   r   )rq   r   r   rs   r|   r   rI   r   r   rr   r*   r	   r   rH   )rb   withsimprN  
simplifiedr  expropsrK  rR  expr3r   r   expr2opsrS  s               @rf   dotprodsimpr_    s    KZ1: J$DKK4;;$+++t5d%  Q =DJ(.a<-d<=M%$8$;q$@"5ME~%*ZZGMMO0TODA!O0T%U%)
 lt{{{tyy!}/C/C/C		1$$A););R)@)G)G		1""B'..		1""B'++q}}<		1""B'++q}}<E$U+A.H!"!
 J!)D3t3) 1Us   H;
z
    Using bottom_up from the sympy.simplify.simplify submodule is
    deprecated.

    Instead, use bottom_up from the top-level sympy namespace, like

        sympy.bottom_up
    z1.10z$deprecated-traversal-functions-moved)deprecated_since_versionactive_deprecations_targetz
    Using walk from the sympy.simplify.simplify submodule is
    deprecated.

    Instead, use walk from sympy.core.traversal.walk
    r   )rb   r   returnr   )rb   rB   rb  rB   )rb   rM   rb  rM   )rb   r   rb  r   )NFFFT)r   )F)   r  )r   NFNr  )Nr  )T)
__future__r   typingr   collectionsr   sympy.concrete.productsr   sympy.concrete.summationsr   
sympy.corer   r	   r
   r   r   r   r   r   r   r   r   r   r   r   sympy.core.exprtoolsr   sympy.core.parametersr   sympy.core.functionr   r   r   r   r   r   sympy.core.numbersr   r   r    r!   r"   sympy.core.relationalr#   sympy.core.rulesr$   sympy.core.sortingr%   sympy.core.sympifyr&   sympy.core.traversalr'   r
  r(   _walksympy.functionsr)   r*   r+   r,   r-   r.   (sympy.functions.combinatorial.factorialsr/   $sympy.functions.elementary.complexesr0   r1   r2   &sympy.functions.elementary.exponentialr3   %sympy.functions.elementary.hyperbolicr4   #sympy.functions.elementary.integersr5   $sympy.functions.elementary.piecewiser6   r7   r8   (sympy.functions.elementary.trigonometricr9   sympy.functions.special.besselr:   r;   r<   r=   r>   r?   (sympy.functions.special.tensor_functionsr@   sympy.integrals.integralsrA   sympy.logic.boolalgrB   sympy.matrices.expressionsrC   rD   rE   rF   rG   sympy.polysrH   rI   rJ    sympy.polys.numberfields.minpolyrK   rL   sympy.sets.setsrM   sympy.simplify.combsimprN   sympy.simplify.cse_optsrO   rP   sympy.simplify.hyperexpandrQ   sympy.simplify.powsimprR   sympy.simplify.radsimprS   rT   rU   sympy.simplify.sqrtdenestrV   sympy.simplify.trigsimprW   rX   sympy.utilities.decoratorrY   sympy.utilities.iterablesrZ   r[   r\   r]   sympy.utilities.miscr^   r  rg   ra   r`   r   r   r   r   r   r  r&  r=  r0  r  rP  ra  r  r  r  r  r  r	  r  r  r  r  r_  r   rh   rf   <module>r     s   "  # + ). . . . + 3    C C , & & ' G @ @ J F F : D 7F F JB B C . 'B B 0 0 R  , 5 2 * A A 0 9 0 J J '   "U G*T=@@:/z,^%,DN 
 / 
 /	 5 
 5	 - 
 -	 1 
 1i%UY Sl
64(4)X#L20M`#L0fpf9x HL HLV>+B "# ,\EP
c4L  $E 	   $E	 		rh   