
    \h(m                        S SK JrJrJr  S SKJr  S SKJr  S SKJ	r	  S SK
JrJr  S SKJrJrJr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  S SKJr  S SKJr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,  S SK-J.r.  S SKJ/r/  S SK0J1r1J2r2  S r3 " S S\\"S9r4\Rh                  r5S'S jr6S'S jr7S(S jr8S)S jr9 " S S \\5      r: " S! S"\:\5      r; " S# S$\:\5      r< " S% S&\5      r=g)*    )Ssympify
NumberKind)sift)Add)Tuple)	LatticeOpShortCircuit)ApplicationLambdaArgumentIndexErrorDefinedFunction)Expr)factor_terms)Mod)Mul)Rational)Pow)Eq
Relational)	Singleton)ordered)Dummy)	Transform)	fuzzy_andfuzzy_or_torf)walk)Integer)AndOrc           	          SSK Jn  / n[        U5       HS  u  pE[        US-   [	        U5      5       Vs/ s H  n[        XQU   U 5      PM     nnUR                  U[        U6 45        MU     U" U6 $ s  snf )Nr   	Piecewise   )$sympy.functions.elementary.piecewiser$   	enumeraterangelenr   appendr    )opargsr$   eciajcs           `/var/www/auris/envauris/lib/python3.13/site-packages/sympy/functions/elementary/miscellaneous.py_minmax_as_Piecewiser3      sp    >	B$16q1uc$i1HI1HAZ7B'1HI
		1c1g,   b> Js   A0c                   H    \ rS rSrSr\" S5      r\S 5       r\S 5       r	Sr
g)IdentityFunction#   zm
The identity function

Examples
========

>>> from sympy import Id, Symbol
>>> x = Symbol('x')
>>> Id(x)
x

xc                 ,    [        U R                  5      $ N)r   _symbolselfs    r2   	signatureIdentityFunction.signature3   s    T\\""    c                     U R                   $ r9   )r:   r;   s    r2   exprIdentityFunction.expr7   s    ||r?    N)__name__
__module____qualname____firstlineno____doc__r   r:   propertyr=   rA   __static_attributes__rC   r?   r2   r5   r5   #   s8     CjG# #  r?   r5   )	metaclassNc                 4    [        U [        R                  US9$ )a  Returns the principal square root.

Parameters
==========

evaluate : bool, optional
    The parameter determines if the expression should be evaluated.
    If ``None``, its value is taken from
    ``global_parameters.evaluate``.

Examples
========

>>> from sympy import sqrt, Symbol, S
>>> x = Symbol('x')

>>> sqrt(x)
sqrt(x)

>>> sqrt(x)**2
x

Note that sqrt(x**2) does not simplify to x.

>>> sqrt(x**2)
sqrt(x**2)

This is because the two are not equal to each other in general.
For example, consider x == -1:

>>> from sympy import Eq
>>> Eq(sqrt(x**2), x).subs(x, -1)
False

This is because sqrt computes the principal square root, so the square may
put the argument in a different branch.  This identity does hold if x is
positive:

>>> y = Symbol('y', positive=True)
>>> sqrt(y**2)
y

You can force this simplification by using the powdenest() function with
the force option set to True:

>>> from sympy import powdenest
>>> sqrt(x**2)
sqrt(x**2)
>>> powdenest(sqrt(x**2), force=True)
x

To get both branches of the square root you can use the rootof function:

>>> from sympy import rootof

>>> [rootof(x**2-3,i) for i in (0,1)]
[-sqrt(3), sqrt(3)]

Although ``sqrt`` is printed, there is no ``sqrt`` function so looking for
``sqrt`` in an expression will fail:

>>> from sympy.utilities.misc import func_name
>>> func_name(sqrt(x))
'Pow'
>>> sqrt(x).has(sqrt)
False

To find ``sqrt`` look for ``Pow`` with an exponent of ``1/2``:

>>> (x + 1/sqrt(x)).find(lambda i: i.is_Pow and abs(i.exp) is S.Half)
{1/sqrt(x)}

See Also
========

sympy.polys.rootoftools.rootof, root, real_root

References
==========

.. [1] https://en.wikipedia.org/wiki/Square_root
.. [2] https://en.wikipedia.org/wiki/Principal_value
evaluate)r   r   HalfargrN   s     r2   sqrtrR   C   s    j sAFFX..r?   c                 ,    [        U [        SS5      US9$ )a  Returns the principal cube root.

Parameters
==========

evaluate : bool, optional
    The parameter determines if the expression should be evaluated.
    If ``None``, its value is taken from
    ``global_parameters.evaluate``.

Examples
========

>>> from sympy import cbrt, Symbol
>>> x = Symbol('x')

>>> cbrt(x)
x**(1/3)

>>> cbrt(x)**3
x

Note that cbrt(x**3) does not simplify to x.

>>> cbrt(x**3)
(x**3)**(1/3)

This is because the two are not equal to each other in general.
For example, consider `x == -1`:

>>> from sympy import Eq
>>> Eq(cbrt(x**3), x).subs(x, -1)
False

This is because cbrt computes the principal cube root, this
identity does hold if `x` is positive:

>>> y = Symbol('y', positive=True)
>>> cbrt(y**3)
y

See Also
========

sympy.polys.rootoftools.rootof, root, real_root

References
==========

.. [1] https://en.wikipedia.org/wiki/Cube_root
.. [2] https://en.wikipedia.org/wiki/Principal_value

r%      rM   )r   r   rP   s     r2   cbrtrU      s    l sHQNX66r?   c                     [        U5      nU(       a<  [        [        U [        R                  U-  US9[        R
                  SU-  U-  -  US9$ [        U SU-  US9$ )a  Returns the *k*-th *n*-th root of ``arg``.

Parameters
==========

k : int, optional
    Should be an integer in $\{0, 1, ..., n-1\}$.
    Defaults to the principal root if $0$.

evaluate : bool, optional
    The parameter determines if the expression should be evaluated.
    If ``None``, its value is taken from
    ``global_parameters.evaluate``.

Examples
========

>>> from sympy import root, Rational
>>> from sympy.abc import x, n

>>> root(x, 2)
sqrt(x)

>>> root(x, 3)
x**(1/3)

>>> root(x, n)
x**(1/n)

>>> root(x, -Rational(2, 3))
x**(-3/2)

To get the k-th n-th root, specify k:

>>> root(-2, 3, 2)
-(-1)**(2/3)*2**(1/3)

To get all n n-th roots you can use the rootof function.
The following examples show the roots of unity for n
equal 2, 3 and 4:

>>> from sympy import rootof

>>> [rootof(x**2 - 1, i) for i in range(2)]
[-1, 1]

>>> [rootof(x**3 - 1,i) for i in range(3)]
[1, -1/2 - sqrt(3)*I/2, -1/2 + sqrt(3)*I/2]

>>> [rootof(x**4 - 1,i) for i in range(4)]
[-1, 1, -I, I]

SymPy, like other symbolic algebra systems, returns the
complex root of negative numbers. This is the principal
root and differs from the text-book result that one might
be expecting. For example, the cube root of -8 does not
come back as -2:

>>> root(-8, 3)
2*(-1)**(1/3)

The real_root function can be used to either make the principal
result real (or simply to return the real root directly):

>>> from sympy import real_root
>>> real_root(_)
-2
>>> real_root(-32, 5)
-2

Alternatively, the n//2-th n-th root of a negative number can be
computed with root:

>>> root(-32, 5, 5//2)
-2

See Also
========

sympy.polys.rootoftools.rootof
sympy.core.intfunc.integer_nthroot
sqrt, real_root

References
==========

.. [1] https://en.wikipedia.org/wiki/Square_root
.. [2] https://en.wikipedia.org/wiki/Real_root
.. [3] https://en.wikipedia.org/wiki/Root_of_unity
.. [4] https://en.wikipedia.org/wiki/Principal_value
.. [5] https://mathworld.wolfram.com/CubeRoot.html

rM      r%   )r   r   r   r   OneNegativeOne)rQ   nkrN   s       r2   rootr\      sV    | 	
A3sAEE!Gh71Q9OZbccsAaC(++r?   c                    SSK JnJnJn  SSKJn  Ub  U" [        XUS9[        [        U[        R                  5      [        U[        R                  5      5      4[        U" U 5      [        U" U 5      XS9US9[        [        U" U 5      [        R                  5      [        [        US5      [        R                  5      5      4[        XUS9S45      $ [!        U 5      n[#        S S 5      nUR%                  U5      $ )	a  Return the real *n*'th-root of *arg* if possible.

Parameters
==========

n : int or None, optional
    If *n* is ``None``, then all instances of
    $(-n)^{1/\text{odd}}$ will be changed to $-n^{1/\text{odd}}$.
    This will only create a real root of a principal root.
    The presence of other factors may cause the result to not be
    real.

evaluate : bool, optional
    The parameter determines if the expression should be evaluated.
    If ``None``, its value is taken from
    ``global_parameters.evaluate``.

Examples
========

>>> from sympy import root, real_root

>>> real_root(-8, 3)
-2
>>> root(-8, 3)
2*(-1)**(1/3)
>>> real_root(_)
-2

If one creates a non-principal root and applies real_root, the
result will not be real (so use with caution):

>>> root(-8, 3, 2)
-2*(-1)**(2/3)
>>> real_root(_)
-2*(-1)**(2/3)

See Also
========

sympy.polys.rootoftools.rootof
sympy.core.intfunc.integer_nthroot
root, sqrt
r   )Absimsignr#   rM   rW   Tc                 8    U R                   * U R                  -  * $ r9   )baseexpr7   s    r2   <lambda>real_root.<locals>.<lambda>n  s    166'AEE!1 1r?   c                    U R                   =(       as    U R                  R                  =(       aV    U R                  R                  =(       a9    U R                  R
                  S:H  =(       a    U R                  R                  S-  $ )Nr%   rW   )is_Powrb   is_negativerc   is_Rationalpqrd   s    r2   re   rf   o  s^    hh 3ff((3ee''3 eeggl3 ()uuww{3r?   )$sympy.functions.elementary.complexesr^   r_   r`   r&   r$   r\   r!   r   r   rX   rY   r   r    Zeror   r   r   xreplace)	rQ   rZ   rN   r^   r_   r`   r$   rvn1pows	            r2   	real_rootrr   8  s    Z CB>}#8,bAquur!Q]]?S.TUcDS1@8T2c7AFF#RAq	155%9:<#8,d3	5 	5
 
B134E ;;ur?   c                      ^  \ rS rSrS r\S 5       r\S 5       r\S 5       r\S 5       r	U 4S jr
S rS&S	 jrS
 rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS r S r!S r"S  r#S! r$S" r%S# r&S$ r'S%r(U =r)$ )'
MinMaxBasei{  c                    SSK Jn  UR                  SUR                  5      nS U 5       nU(       aA   [	        U R                  U5      5      nU R                  " U40 UD6nU R                  " U40 UD6n[	        U5      nU(       d  U R                  $ [        U5      S:X  a  [        U5      R                  5       $ [        R                  " U /[        U5      Q70 UD6nXl        U$ ! [         a    U R                  s $ f = f)Nr   )global_parametersrN   c              3   8   #    U  H  n[        U5      v   M     g 7fr9   )r   ).0rQ   s     r2   	<genexpr>%MinMaxBase.__new__.<locals>.<genexpr>  s     -   r%   )sympy.core.parametersrv   poprN   	frozenset_new_args_filterr
   zero_collapse_arguments_find_localzerosidentityr)   listr   __new__r   _argset)clsr,   assumptionsrv   rN   objs         r2   r   MinMaxBase.__new__|  s    ;??:/@/I/IJ--
   !5!5d!;< **4?;?D''<<D<<t9>:>>## ll3>>+>
#    xx s   C% %C>=C>c                   ^ ^^ U(       d  U$ [        [        U5      5      nT [        :X  a  [        mO[        mUS   R                  (       Ga  / / 4=nu  pEU Ha  n[        U[        [        5       HE  nUR                  S   R                  (       d  M#  U[        U[        5         R                  U5        MG     Mc     [        R                  nU H1  nUR                  S   nUR                  (       d  M%  Xx:  S:X  d  M/  UnM3     [        R                  n	U H1  nUR                  S   nUR                  (       d  M%  Xy:  S:X  d  M/  Un	M3     T [        :X  a)  U H"  n
U
R                  (       d    OCX:  S:X  d  M   U
nM$     O2T [        :X  a(  U H"  n
U
R                  (       d    OX:  S:X  d  M   U
n	M$     SnT [        :X  a  U[        R                  :w  a  [        mUnOU	[        R                  :w  a  [        mU	nUbg  [        [        U5      5       HO  nX   n[        UT5      (       d  M  UR                  S   nT[        :X  a  X:  OX:  S:X  d  MA  T R                  X'   MQ     U U4S jm[        U5       H(  u  plXS-   S  Vs/ s H  nT" X5      PM     snXS-   S& M*     U U4S jn[        U5      S:  a  U" U5      nU$ s  snf )a  Remove redundant args.

Examples
========

>>> from sympy import Min, Max
>>> from sympy.abc import a, b, c, d, e

Any arg in parent that appears in any
parent-like function in any of the flat args
of parent can be removed from that sub-arg:

>>> Min(a, Max(b, Min(a, c, d)))
Min(a, Max(b, Min(c, d)))

If the arg of parent appears in an opposite-than parent
function in any of the flat args of parent that function
can be replaced with the arg:

>>> Min(a, Max(b, Min(c, d, Max(a, e))))
Min(a, Max(b, Min(a, c, d)))
r   TNc           	      |  > [        U [        [        45      (       d  U $ XR                  ;   nU(       d3  U R                  " U R                   Vs/ s H  nT" X15      PM     snSS06$ [        U T5      (       a:  U R                  " U R                   Vs/ s H  o3U:w  d  M
  T" X15      PM     snSS06$ U$ s  snf s  snf )NrN   F)
isinstanceMinMaxr,   func)air/   condr.   r   dos       r2   r   *MinMaxBase._collapse_arguments.<locals>.do  s    b3*--	<Dww277 ;7aA7 ; $"$ $"c""ww277 E7a1fA7 E $"$ $H !< !Fs   B4	B9B9r%   c                   > U4S jn[        XSS9u  p#U(       d  U $ U Vs/ s H  n[        UR                  5      PM     nn[        R                  " U6 nU(       d  U $ [	        U5      nU Vs/ s H  oU-
  PM	     n	n[        U	5      (       a/  U	 V
s/ s H  n
T" U
SS06PM     nn
UR                  T" USS065        T" USS06nX</-   $ s  snf s  snf s  sn
f )Nc                    > [        U T5      $ r9   )r   )rQ   others    r2   re   GMinMaxBase._collapse_arguments.<locals>.factor_minmax.<locals>.<lambda>  s    :c5#9r?   T)binaryrN   F)r   setr,   intersectionr   allr*   )r,   is_other
other_argsremaining_argsrQ   arg_setscommonnew_other_argsarg_setarg_sets_diffsother_args_diffother_args_factoredr   r   s                r2   factor_minmax5MinMaxBase._collapse_arguments.<locals>.factor_minmax  s    9H)-dT)J&J 2<<#CHHH<%%x0F!&\N=EFX'v-XMF =!!FS"Tm5!#<e#<m"T%%c?&KU&KL"'"H%"H!$999 = G
 #Us   C	-CC)r   r   r   r   	is_numberr   r,   is_comparabler   r*   r   r(   r)   r'   )r   r,   r   siftedminsmaxsr.   vsmallbigrQ   Tr/   a0r   r   r   r   s   `               @@r2   r   MinMaxBase._collapse_arguments  s\   0 KGDM"#:EE
 7"$b&(FZTac*Avvay...z!S1299!< +  LLEFF1I;;;AI$#6E  ,,CFF1I;;;AG#4C  czC==, #	  
 C==	d*!	  
 AczCLL(EA$}s4y)AA!!U++VVAY(-RV26tK&)llDG *
	 dODA04UV="BrI=DQL $	:0 t9q= &DI >s   >J<c              #   t  #    U H  n[        U[        5      (       a1  UR                  SL d"  UR                  (       a  UR                  (       d  [        SU-  5      eX R                  :X  a  [        U5      eX R                  :X  a  M  UR                  U :X  a  UR                   Sh  vN   M  Uv   M     g N7f)z
Generator filtering args.

first standard filter, for cls.zero and cls.identity.
Also reshape ``Max(a, Max(b, c))`` to ``Max(a, b, c)``,
and check arguments for comparability
Fz$The argument '%s' is not comparable.N)r   r   is_extended_realr   r   
ValueErrorr   r
   r   r   r,   )r   arg_sequencerQ   s      r2   r   MinMaxBase._new_args_filter!  s       Cc4((C,@,@E,IMM)) !G#!MNNhh"3''$S88##	   $s   B$B8&B6'B8c                 \   [        5       nU H  nSn[        U5      nU Hj  n[        U5      [        U5      :X  a  SnM  U R                  XG5      nU(       d  M9  SnUSL d  X:X  d  MG  UR	                  U5        UR                  U/5        Ml     U(       d  M  UR                  U/5        M     U$ )z
Sequentially allocate values to localzeros.

When a value is identified as being more extreme than another member it
replaces that member; if this is never true, then the value is simply
appended to the localzeros.
TF)r   r   id_is_connectedremoveupdate)	r   valuesoptions
localzerosr   
is_newzerolocalzeros_zcons	            r2   r   MinMaxBase._find_localzeros:  s     U
AJz*K a5BqE>!&J++A1Cs%*
$;#*&--a0&--qc2 ! z!!1#&  r?   c                 T   [        S5       H  nX:X  a    g[        [        pTS HN  n[        S5       H:  n US:X  a  X:  nOX:*  n UR                  (       d  U(       a  UOUs  s  s  $ XTpTX!p!M<     X!p!MP     [        X-
  5      n[        R                  nM     g! [         a           gf = f)z)
Check if x and y are connected somehow.
rW   Tz><>F)r(   r   r   	TypeErroris_Relationalr   r   rn   )	r   r7   yr.   tfr+   r0   r   s	            r2   r   MinMaxBase._is_connectedU  s    
 qAvqqA%9 !A !A ??$%q1,qq " 1   QU#AA+ .  % %$%s   
B B
B'	&B'	c                   > Sn/ nU R                    HQ  nUS-  nUR                  U5      nUR                  (       a  M,   U R                  U5      nUR                  Xe-  5        MS     [        U6 $ ! [         a    [
        TU ]  U5      n N:f = f)Nr   r%   )r,   diffis_zerofdiffr   superr*   r   )r<   r   r.   lr/   dadf	__class__s          r2   _eval_derivativeMinMaxBase._eval_derivatives  s    AFABzz&ZZ] HHRW  Aw & &W]1%&s   A//B
Bc                    SSK Jn  US   U R                  " USS  6 -   S-  n[        US   U R                  " USS  6 -
  5      S-  n[	        U [
        5      (       a  XE-   R                  U5      $ XE-
  R                  U5      $ )Nr   )r^   r%   rW   )rm   r^   r   absr   r   rewrite)r<   r,   kwargsr^   r   ds         r2   _eval_rewrite_as_AbsMinMaxBase._eval_rewrite_as_Abs  s    <!Wtyy$qr(++Q.Q$))T!"X../1#D#..BB3GGAEBB3GGr?   c           
          U R                   " U R                   Vs/ s H  o3R                  " U40 UD6PM     sn6 $ s  snf r9   )r   r,   evalf)r<   rZ   r   r/   s       r2   r   MinMaxBase.evalf  s3    yy$))D)Q77100)DEEDs   ;c                 &    U R                   " U0 UD6$ r9   )r   r<   r,   r   s      r2   rZ   MinMaxBase.n  s    zz4*6**r?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7fr9   )is_algebraicrx   r.   s     r2   ry   &MinMaxBase.<lambda>.<locals>.<genexpr>       (HAr{   r   r,   r   s    r2   re   MinMaxBase.<lambda>      5(H(H#Hr?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7fr9   )is_antihermitianr   s     r2   ry   r          ,PA-?-?r{   r   r   s    r2   re   r         u,P,P'Pr?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7fr9   )is_commutativer   s     r2   ry   r          *LV+;+;Vr{   r   r   s    r2   re   r         U*LQVV*L%Lr?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7fr9   )
is_complexr   s     r2   ry   r          &DV||Vr{   r   r   s    r2   re   r         &DQVV&D!Dr?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7fr9   )is_compositer   s     r2   ry   r     r   r{   r   r   s    r2   re   r     r   r?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7fr9   )is_evenr   s     r2   ry   r          #>v!IIvr{   r   r   s    r2   re   r         e#>qvv#>>r?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7fr9   )	is_finiter   s     r2   ry   r     s     %B6akk6r{   r   r   s    r2   re   r     s    %B166%B Br?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7fr9   )is_hermitianr   s     r2   ry   r     r   r{   r   r   s    r2   re   r     r   r?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7fr9   )is_imaginaryr   s     r2   ry   r     r   r{   r   r   s    r2   re   r     r   r?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7fr9   )is_infiniter   s     r2   ry   r          'Fv!vr{   r   r   s    r2   re   r         %'Fqvv'F"Fr?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7fr9   )
is_integerr   s     r2   ry   r     r   r{   r   r   s    r2   re   r     r   r?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7fr9   )is_irrationalr   s     r2   ry   r          )J6a//6r{   r   r   s    r2   re   r         E)J166)J$Jr?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7fr9   ri   r   s     r2   ry   r     r  r{   r   r   s    r2   re   r     r  r?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7fr9   )is_nonintegerr   s     r2   ry   r     r  r{   r   r   s    r2   re   r     r  r?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7fr9   is_nonnegativer   s     r2   ry   r     r   r{   r   r   s    r2   re   r     r   r?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7fr9   )is_nonpositiver   s     r2   ry   r     r   r{   r   r   s    r2   re   r     r   r?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7fr9   )
is_nonzeror   s     r2   ry   r     r   r{   r   r   s    r2   re   r     r   r?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7fr9   )is_oddr   s     r2   ry   r     s     "<V88Vr{   r   r   s    r2   re   r     s    U"<QVV"<<r?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7fr9   )is_polarr   s     r2   ry   r          $@AZZr{   r   r   s    r2   re   r         u$@$@@r?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7fr9   is_positiver   s     r2   ry   r     r  r{   r   r   s    r2   re   r     r  r?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7fr9   )is_primer   s     r2   ry   r     r4  r{   r   r   s    r2   re   r     r5  r?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7fr9   )is_rationalr   s     r2   ry   r     r  r{   r   r   s    r2   re   r     r  r?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7fr9   )is_realr   s     r2   ry   r     r  r{   r   r   s    r2   re   r     r  r?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7fr9   )r   r   s     r2   ry   r     r   r{   r   r   s    r2   re   r     r   r?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7fr9   )is_transcendentalr   s     r2   ry   r     s     -R6a.A.A6r{   r   r   s    r2   re   r     s    -R166-R(Rr?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7fr9   )r   r   s     r2   ry   r     r  r{   r   r   s    r2   re   r     r  r?   rC   )   )*rD   rE   rF   rG   r   classmethodr   r   r   r   r   r   r   rZ   _eval_is_algebraic_eval_is_antihermitian_eval_is_commutative_eval_is_complex_eval_is_composite_eval_is_even_eval_is_finite_eval_is_hermitian_eval_is_imaginary_eval_is_infinite_eval_is_integer_eval_is_irrational_eval_is_negative_eval_is_noninteger_eval_is_nonnegative_eval_is_nonpositive_eval_is_nonzero_eval_is_odd_eval_is_polar_eval_is_positive_eval_is_prime_eval_is_rational_eval_is_real_eval_is_extended_real_eval_is_transcendental_eval_is_zerorJ   __classcell__)r   s   @r2   rt   rt   {  s	   < D DL  0  4  : HF+ IPLDH>MBOHHFDJFJLLD<L@NF@NF>MPR>Mr?   rt   c                   l    \ rS rSrSr\R                  r\R                  r	S r
S rS rS rS rS rS	rg
)r   i  a  
Return, if possible, the maximum value of the list.

When number of arguments is equal one, then
return this argument.

When number of arguments is equal two, then
return, if possible, the value from (a, b) that is $\ge$ the other.

In common case, when the length of list greater than 2, the task
is more complicated. Return only the arguments, which are greater
than others, if it is possible to determine directional relation.

If is not possible to determine such a relation, return a partially
evaluated result.

Assumptions are used to make the decision too.

Also, only comparable arguments are permitted.

It is named ``Max`` and not ``max`` to avoid conflicts
with the built-in function ``max``.


Examples
========

>>> from sympy import Max, Symbol, oo
>>> from sympy.abc import x, y, z
>>> p = Symbol('p', positive=True)
>>> n = Symbol('n', negative=True)

>>> Max(x, -2)
Max(-2, x)
>>> Max(x, -2).subs(x, 3)
3
>>> Max(p, -2)
p
>>> Max(x, y)
Max(x, y)
>>> Max(x, y) == Max(y, x)
True
>>> Max(x, Max(y, z))
Max(x, y, z)
>>> Max(n, 8, p, 7, -oo)
Max(8, p)
>>> Max (1, x, oo)
oo

* Algorithm

The task can be considered as searching of supremums in the
directed complete partial orders [1]_.

The source values are sequentially allocated by the isolated subsets
in which supremums are searched and result as Max arguments.

If the resulted supremum is single, then it is returned.

The isolated subsets are the sets of values which are only the comparable
with each other in the current set. E.g. natural numbers are comparable with
each other, but not comparable with the `x` symbol. Another example: the
symbol `x` with negative assumption is comparable with a natural number.

Also there are "least" elements, which are comparable with all others,
and have a zero property (maximum or minimum for all elements).
For example, in case of $\infty$, the allocation operation is terminated
and only this value is returned.

Assumption:
   - if $A > B > C$ then $A > C$
   - if $A = B$ then $B$ can be removed

References
==========

.. [1] https://en.wikipedia.org/wiki/Directed_complete_partial_order
.. [2] https://en.wikipedia.org/wiki/Lattice_%28order%29

See Also
========

Min : find minimum values
c                    SSK Jn  [        U R                  5      nSU:  a  X::  a  US-  nUS:X  a(  U" U R                  U   U R                  SU-
     -
  5      $ [	        [        U5       Vs/ s H  oDU:w  d  M
  U R                  U   PM     sn5      nU" U R                  U   [        U6 -
  5      $ [        X5      es  snf Nr   	Heavisider%   rW   )'sympy.functions.special.delta_functionsrk  r)   r,   tupler(   r   r   r<   argindexrk  rZ   r.   newargss         r2   r   	Max.fdiff  s    E		Nx<HMMHAv 8!4tyyX7N!NOO58M8aH}\TYYq\8MNGTYYx03=@AA$T44 N   ,	B<9B<c                     SSK Jn  [        U VVs/ s H.  nU[        U Vs/ s H  oUU:w  d  M
  U" XE-
  5      PM     sn6 -  PM0     snn6 $ s  snf s  snnf Nr   rj  rl  rk  r   r   r<   r,   r   rk  r0   r.   s         r2   _eval_rewrite_as_HeavisideMax._eval_rewrite_as_Heaviside  s\    EA stDt!!t-Yqu-tDEE   	 D    A
	AA
A
A
c                     [        S/UQ76 $ )Nz>=r3   r   s      r2   _eval_rewrite_as_PiecewiseMax._eval_rewrite_as_Piecewise      #D0400r?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7fr9   r8  rx   r/   s     r2   ry   (Max._eval_is_positive.<locals>.<genexpr>       9y!yr{   r   r,   r;   s    r2   r_  Max._eval_is_positive      9tyy999r?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7fr9   r&  r  s     r2   ry   +Max._eval_is_nonnegative.<locals>.<genexpr>  s     <)Q(()r{   r  r;   s    r2   rZ  Max._eval_is_nonnegative  s    <$))<<<r?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7fr9   r   r  s     r2   ry   (Max._eval_is_negative.<locals>.<genexpr>       :	1	r{   r   r,   r;   s    r2   rX  Max._eval_is_negative      :		:::r?   rC   N)rD   rE   rF   rG   rH   r   Infinityr   NegativeInfinityr   r   rw  r|  r_  rZ  rX  rJ   rC   r?   r2   r   r     s=    Sh ::D!!H
5 
1:=;r?   r   c                   l    \ rS rSrSr\R                  r\R                  r	S r
S rS rS rS rS rS	rg
)r   i!  a  
Return, if possible, the minimum value of the list.
It is named ``Min`` and not ``min`` to avoid conflicts
with the built-in function ``min``.

Examples
========

>>> from sympy import Min, Symbol, oo
>>> from sympy.abc import x, y
>>> p = Symbol('p', positive=True)
>>> n = Symbol('n', negative=True)

>>> Min(x, -2)
Min(-2, x)
>>> Min(x, -2).subs(x, 3)
-2
>>> Min(p, -3)
-3
>>> Min(x, y)
Min(x, y)
>>> Min(n, 8, p, -7, p, oo)
Min(-7, n)

See Also
========

Max : find maximum values
c                    SSK Jn  [        U R                  5      nSU:  a  X::  a  US-  nUS:X  a(  U" U R                  SU-
     U R                  U   -
  5      $ [	        [        U5       Vs/ s H  oDU:w  d  M
  U R                  U   PM     sn5      nU" [        U6 U R                  U   -
  5      $ [        X5      es  snf ri  )rl  rk  r)   r,   rm  r(   r   r   rn  s         r2   r   	Min.fdiffB  s    E		Nx<HMMHAv $))AhJ"7$))H:M"MOOE!HNHqXldiilHNOGc7mdii.AACC$T44 Orr  c                     SSK Jn  [        U VVs/ s H.  nU[        U Vs/ s H  oUU:w  d  M
  U" XT-
  5      PM     sn6 -  PM0     snn6 $ s  snf s  snnf rt  ru  rv  s         r2   rw  Min._eval_rewrite_as_HeavisideN  sZ    EA sTBTT^Yqs^TBCC   	 B ry  c                     [        S/UQ76 $ )Nz<=r{  r   s      r2   r|  Min._eval_rewrite_as_PiecewiseS  r~  r?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7fr9   r8  r  s     r2   ry   (Min._eval_is_positive.<locals>.<genexpr>W  r  r{   r  r;   s    r2   r_  Min._eval_is_positiveV  r  r?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7fr9   r&  r  s     r2   ry   +Min._eval_is_nonnegative.<locals>.<genexpr>Z  s     =9a))9r{   r  r;   s    r2   rZ  Min._eval_is_nonnegativeY  s    =499===r?   c                 :    [        S U R                   5       5      $ )Nc              3   8   #    U  H  oR                   v   M     g 7fr9   r   r  s     r2   ry   (Min._eval_is_negative.<locals>.<genexpr>]  r  r{   r  r;   s    r2   rX  Min._eval_is_negative\  r  r?   rC   N)rD   rE   rF   rG   rH   r   r  r   r  r   r   rw  r|  r_  rZ  rX  rJ   rC   r?   r2   r   r   !  s;    : DzzH
5 
1;>:r?   r   c                   ,    \ rS rSrSr\r\S 5       rSr	g)Remi`  a  Returns the remainder when ``p`` is divided by ``q`` where ``p`` is finite
and ``q`` is not equal to zero. The result, ``p - int(p/q)*q``, has the same sign
as the divisor.

Parameters
==========

p : Expr
    Dividend.

q : Expr
    Divisor.

Notes
=====

``Rem`` corresponds to the ``%`` operator in C.

Examples
========

>>> from sympy.abc import x, y
>>> from sympy import Rem
>>> Rem(x**3, y)
Rem(x**3, y)
>>> Rem(x**3, y).subs({x: -5, y: 3})
-2

See Also
========

Mod
c                    UR                   (       a  [        S5      eU[        R                  L d1  U[        R                  L d  UR                  SL d  UR                  SL a  [        R                  $ U[        R
                  L d  XU* 4;   d  UR                  (       a  US:X  a  [        R
                  $ UR                  (       a%  UR                  (       a  U[        X-  5      U-  -
  $ gg)zJReturn the function remainder if both p, q are numbers and q is not
zero.
zDivision by zeroFr%   N)	r   ZeroDivisionErrorr   NaNr
  rn   r  	is_Numberr   )r   rk   rl   s      r2   evalRem.eval  s     99#$677:aeeq{{e';q{{e?S55L;!A2w,1<<AF66M;;{{713<>))  r?   rC   N)
rD   rE   rF   rG   rH   r   kindrK  r  rJ   rC   r?   r2   r  r  `  s!     B D* *r?   r  r9   )r   N)NN)>
sympy.corer   r   r   sympy.utilities.iterablesr   sympy.core.addr   sympy.core.containersr   sympy.core.operationsr	   r
   sympy.core.functionr   r   r   r   sympy.core.exprr   sympy.core.exprtoolsr   sympy.core.modr   sympy.core.mulr   sympy.core.numbersr   sympy.core.powerr   sympy.core.relationalr   r   sympy.core.singletonr   sympy.core.sortingr   sympy.core.symbolr   sympy.core.rulesr   sympy.core.logicr   r   r   sympy.core.traversalr   r   sympy.logic.boolalgr    r!   r3   r5   IdrR   rU   r\   rr   rt   r   r   r  rC   r?   r2   <module>r     s    - - *  ' 9) )   -   '   0 * & # & 7 7 % & 'v 2 U/p67ra,H<Fm?y m?`	s;*k s;l<:*k <:~3*/ 3*r?   