+
    ia5                   x   ^ RI Ht ^ RIHtHt ^ RIHt ^ RIHt ^ RI	H
t
 ^ RIt^RIHt ^RIHtHt ^R	IHt ^R
IHtHt ^RIHt ^RIHtHt ^RIHtHt ^RIHt ^RIH t  ^RI!H"t" ^RI#H$t$ ^ RI%H&t&  ! R R4      t'R t(R t) ! R R]]4      t*]! R4      t+R R lt,R!R lt-R t.^RI/H0t0 ^RI1H2t2 ^RI3H4t4H5t5 R# )"    )annotations)TYPE_CHECKINGClassVar)defaultdict)reduce)productN)sympify)Basic_args_sortkey)S)AssocOpAssocOpDispatcher)cacheit)integer_nthroottrailing)	fuzzy_not_fuzzy_group)Expr)global_parameters)KindDispatcher	bottom_up)siftc                  *    ] tR t^tRtRtRtRtRtRt	R# )	NC_MarkerF N)
__name__
__module____qualname____firstlineno__is_Orderis_Mul	is_Numberis_Polyis_commutative__static_attributes__r       L/var/www/html/photoedit/myenv/lib/python3.14/site-packages/sympy/core/mul.pyr   r      s    HFIGNr'   r   c                2    V P                  \        R 7       R# )keyN)sortr   argss   &r(   _mulsortr/   "   s    II-I r'   c                    . p. p\        V 4      p \        P                  pV  F  pVP                  '       d7   VP	                  4       w  rVV P                  V4       VP                  V4       KK  VP                  '       d   W4,          pKg  VP                  '       d   VP                  V4       K  VP                  V4       K  	  \        V4       V\        P                  Jd   VP                  ^ V4       \        P                  W,           4      # )a  Return a well-formed unevaluated Mul: Numbers are collected and
put in slot 0, any arguments that are Muls will be flattened, and args
are sorted. Use this when args have changed but you still want to return
an unevaluated Mul.

Examples
========

>>> from sympy.core.mul import _unevaluated_Mul as uMul
>>> from sympy import S, sqrt, Mul
>>> from sympy.abc import x
>>> a = uMul(*[S(3.0), x, S(2)])
>>> a.args[0]
6.00000000000000
>>> a.args[1]
x

Two unevaluated Muls with the same arguments will
always compare as equal during testing:

>>> m = uMul(sqrt(2), sqrt(3))
>>> m == uMul(sqrt(3), sqrt(2))
True
>>> u = Mul(sqrt(3), sqrt(2), evaluate=False)
>>> m == uMul(u)
True
>>> m == Mul(*m.args)
False

)listr   Oner"   args_cncextendr#   r%   appendr/   insertMul
_from_args)r.   cargsncargscoaa_ca_ncs   *      r(   _unevaluated_Mulr?   '   s    > EF:D	
B888

ICKKMM$[[[GBLLOMM!  UO	Q>>%,''r'   c                    a  ] tR t^[t$ RtRMtRt]t]	! RRR7      t
R]R&   ]R 4       t]'       d   RR/R	 R
 llt]R R l4       tR tR t]R 4       tR t]R 4       tR t]R 4       t]R 4       t]RR/R l4       tRNR ltROR lt]R 4       tR t ]R 4       t!]V 3R l4       t"R t#R t$RPR lt%]R  4       t&]RQR! l4       t']R" 4       t(]R# 4       t)]R$ 4       t*]R% 4       t+]R& 4       t,R' t-R( t.R) t/R* t0R+ t1R, t2R- t3R. t4R/ t5R0 t6R1 t7R2 t8R3 t9R4 t:R5 t;R6 t<R7 t=R8 t>R9 t?R: t@R; tAR< tBR= tCR> tDR? tER@ tFRA tGRB tHRC tIRD tJRRRE ltKRF tLRG tMRH tNRI tORSRJ ltPRQRK ltQ]RL 4       tRRMtSV ;tT# )Tr7   a~  
Expression representing multiplication operation for algebraic field.

.. deprecated:: 1.7

   Using arguments that aren't subclasses of :class:`~.Expr` in core
   operators (:class:`~.Mul`, :class:`~.Add`, and :class:`~.Pow`) is
   deprecated. See :ref:`non-expr-args-deprecated` for details.

Every argument of ``Mul()`` must be ``Expr``. Infix operator ``*``
on most scalar objects in SymPy calls this class.

Another use of ``Mul()`` is to represent the structure of abstract
multiplication so that its arguments can be substituted to return
different class. Refer to examples section for this.

``Mul()`` evaluates the argument unless ``evaluate=False`` is passed.
The evaluation logic includes:

1. Flattening
    ``Mul(x, Mul(y, z))`` -> ``Mul(x, y, z)``

2. Identity removing
    ``Mul(x, 1, y)`` -> ``Mul(x, y)``

3. Exponent collecting by ``.as_base_exp()``
    ``Mul(x, x**2)`` -> ``Pow(x, 3)``

4. Term sorting
    ``Mul(y, x, 2)`` -> ``Mul(2, x, y)``

Since multiplication can be vector space operation, arguments may
have the different :obj:`sympy.core.kind.Kind()`. Kind of the
resulting object is automatically inferred.

Examples
========

>>> from sympy import Mul
>>> from sympy.abc import x, y
>>> Mul(x, 1)
x
>>> Mul(x, x)
x**2

If ``evaluate=False`` is passed, result is not evaluated.

>>> Mul(1, 2, evaluate=False)
1*2
>>> Mul(x, x, evaluate=False)
x*x

``Mul()`` also represents the general structure of multiplication
operation.

>>> from sympy import MatrixSymbol
>>> A = MatrixSymbol('A', 2,2)
>>> expr = Mul(x,y).subs({y:A})
>>> expr
x*A
>>> type(expr)
<class 'sympy.matrices.expressions.matmul.MatMul'>

See Also
========

MatMul

TMul_kind_dispatcher)commutativezClassVar[Expr]identityc                	H    R  V P                    4       pV P                  ! V!  # )c              3  8   "   T F  qP                   x  K  	  R # 5iN)kind.0r<   s   & r(   	<genexpr>Mul.kind.<locals>.<genexpr>   s     /YVVY   )r.   _kind_dispatcher)self	arg_kindss   & r(   rG   Mul.kind   s!    /TYY/	$$i00r'   evaluatec               $    V ^8  d   QhRRRRRR/# )   r.   zExpr | complexrQ   boolreturnr   r   )formats   "r(   __annotate__Mul.__annotate__   s!     	 	 	$ 	 	r'   c               	    R # rF   r   )clsrQ   r.   s   &$*r(   __new__Mul.__new__   s    r'   c                   V ^8  d   QhRR/# )rS   rU   ztuple[Expr, ...]r   )rV   s   "r(   rW   rX      s     	 	* 	r'   c                	    R # rF   r   rN   s   &r(   r.   Mul.args   s    r'   c                	z    W ) 8X  d   R # V P                   ^ ,          pVP                  ;'       d    VP                  # F)r.   r#   is_extended_negative)rN   cs   & r(   could_extract_minus_signMul.could_extract_minus_sign   s1    E?IIaL{{55q555r'   c                	   V P                  4       w  rV^ ,          \        P                  Jd   V) pV\        P                  Jdg   V^ ,          P                  '       dD   \        V4      pV\        P                  J d   V^ ,          ) V^ &   M V^ ;;,          V,          uu&   M
V3V,           pV P                  W P                  4      # r   )	as_coeff_mulr   ComplexInfinityr2   r#   r1   NegativeOner8   r%   )rN   rd   r.   s   &  r(   __neg__Mul.__neg__   s    ##%7!+++AAEE>Aw   Dz%#AwhDGGqLGtd{t%8%899r'   c           
     !  a"a6 ^ RI Hp ^ RIHo6 Rp\	        V4      ^8X  Ed/   Vw  po"S"P
                  '       d
   S"Tupo"VS".pV\        P                  Jg   Q hVP
                  '       d   VP                  '       g   S"P                  4       w  po"S"P                  '       d   V\        P                  Jd8   WE,          pV\        P                  J d   S"pMV ! WE,          S"RR7      pV.. R3pMZ\        P                  '       dE   S"P                  '       d3   \        S"P                   Uu. uF  p\!        WH4      NK  	  up!  p	V	.. R3pV'       d   V# . p
. p. p\        P                  p. p. p\        P"                  p/ pRpV EF  pVP$                  '       d   VP'                  V4      w  ppVP(                  '       d   VP                  '       d   VP+                  VP                  4       M^VP                   F9  pVP                  '       d   VP-                  V4       K(  VP-                  V4       K;  	  VP-                  \.        4       K  VP0                  '       d   V\        P2                  J g'   V\        P4                  J d)   VP                  '       d   \        P2                  .. R3u # VP0                  '       g   \7        W4      '       d4   VV,          pV\        P2                  J d   \        P2                  .. R3u # EK  \7        VV4      '       d   VP9                  V4      pEK  V\        P4                  J d2   V'       g   \        P2                  .. R3u # \        P4                  pEK  V'       g{   \7        V\        4      '       de   \:        ;QJ d&    R VP                   4       F  '       g   K   RM	  RM! R VP                   4       4      '       d   \        P2                  .. R3u # V\        P<                  J d   V\        P>                  ,          pEK  VP                  '       EdI   VPA                  4       w  o"pVPB                  '       Ed   S"P0                  '       d   VP
                  '       d   VPD                  '       d   V\G        S"V4      ,          pEK%  VPH                  '       d   VP-                  \G        S"V4      4       EKU  S"PH                  '       d   VV,          pS") o"S"\        P                  Jd"   VPK                  S". 4      P-                  V4       EK  S"PL                  '       g   VPN                  '       d   VP-                  S"V34       EK  VP-                  S"V34       EK  V\.        Jd   VP-                  V4       V'       g   EK!  VPQ                  ^ 4      pV'       g   VP-                  V4       K7  VPQ                  4       pVPA                  4       w  ppVPA                  4       w  ppVV,           pVV8X  dU   VP                  '       gC   VV,          pVP                  '       d   VP-                  V4       K  VPS                  ^ V4       K  VP+                  VV.4       K  	  R pV! V4      pV! V4      p\U        ^4       EF  p. pRp V EF  w  o"pVP                  '       d   S"P                  '       g   S"P(                  '       d   \:        ;QJ dL    V"3R	 l\        P4                  \        PV                  \        PX                  3 4       F  '       g   K   RMA	  RM=! V"3R	 l\        P4                  \        PV                  \        PX                  3 4       4      '       d   \        P2                  .. R3u u # K  V\        P                  J d!   S"P0                  '       d   VS",          pEK#  S"p!V\        P                  JdO   \G        S"V4      p!V!PB                  '       d1   S"PB                  '       g   S"pV!PA                  4       w  o"pS"V8w  d   Rp V
P-                  X!4       VP-                  S"V34       EK  	  V '       d<   \	        V U"Uu0 uF  w  p"pV"kK
  	  upp"4      \	        V4      8w  d   . p
V! V4      pEK   M	  / p#V F'  w  o"pV#PK                  V. 4      P-                  S"4       K)  	  V#P[                  4        F  w  po"V ! S"!  V#V&   K  	  T
P+                  V#P[                  4        UU"u. uF  w  pp"V'       g   K  \G        V"V4      NK  	  up"p4       / p$VP[                  4        F.  w  o"pV$PK                  \        V!  . 4      P-                  S"4       K0  	  ?. p%V$P[                  4        F  w  po"V ! S"!  o"VP\                  ^8X  d   V\G        S"V4      ,          pK2  VP^                  VP\                  8  dM   \a        VP^                  VP\                  4      w  p&p'V\G        S"V&4      ,          p\c        V'VP\                  4      pV%P-                  S"V34       K  	  ?$\e        \f        4      p(^ pV\	        V%4      8  Ed   V%V,          w  pp)V^8X  d   V^,          pK/  . p*\U        V^,           \	        V%4      4       EF  p+V%V+,          w  p,p-VPi                  V,4      p.V.\        P                  Jg   K7  V)V-,           pVP\                  ^8X  d   V\G        V.V4      ,          pMzVP^                  VP\                  8  dM   \a        VP^                  VP\                  4      w  p&p'V\G        V.V&4      ,          p\c        V'VP\                  4      pV*P-                  V.V34       V,V.,          V-3V%V+&   VV.,          pV\        P                  J g   EK   M	  V\        P                  Jd   \G        VV)4      p/V/P0                  '       d   VV/,          pMt\j        Pm                  V/4       F[  p/V/P0                  '       d   VV/,          pK   V/PB                  '       g   Q hV/P                  w  pp)V(V),          P-                  V4       K]  	  V%P+                  V*4       V^,          pEK+  V(P[                  4        F  w  po"V ! S"!  V(V&   K  	  V'       d   VPo                  4       w  p!p\a        V!V4      w  p0p!V0^,          '       d   V) pV^8X  d!   V
P-                  \        P<                  4       M|V!'       du   \c        V!V4      pV(P[                  4        F)  w  po"VV8X  g   K  S"PL                  '       g   K#  S") V(V&    M-	  V
P-                  \G        \        Pp                  VRR7      4       T
P+                  V(P[                  4        UU"u. uF  w  pp"\G        V"V4      NK  	  up"p4       V\        PV                  \        PX                  39   d%   R
 p1V1! V
^4      w  p
p2V1! VV24      w  pp2VV2,          pV\        P4                  J dz   V
 U3u. uF0  p3\s        V3P                  4      '       d   V3Pt                  e   K.  V3NK2  	  p
p3V U3u. uF0  p3\s        V3P                  4      '       d   V3Pt                  e   K.  V3NK2  	  pp3MVP                  '       d   \:        ;QJ d    V63R lV 4       F  '       g   K   RM	  RM! V63R lV 4       4      '       d   V.VV3# \:        ;QJ d    R V
 4       F  '       g   K   RM	  RM! R V
 4       4      '       d   \        P2                  .. V3# V.. V3# . p4V
 F1  pVP0                  '       d   VV,          pK   V4P-                  V4       K3  	  T4p
\w        V
4       V\        P                  Jd   V
PS                  ^ V4       \        P                  '       d   V'       g   \	        V
4      ^8X  d   V
^ ,          P0                  '       dn   V
^ ,          Px                  '       dU   V
^,          P                  '       d<   V
^ ,          p\        V
^,          P                   U5u. uF  p5VV5,          NK  	  up5!  .p
WV3# u upi u upp"i u up"pi u up"pi u up3i u up3i u up5i )a6  Return commutative, noncommutative and order arguments by
combining related terms.

Notes
=====
    * In an expression like ``a*b*c``, Python process this through SymPy
      as ``Mul(Mul(a, b), c)``. This can have undesirable consequences.

      -  Sometimes terms are not combined as one would like:
         {c.f. https://github.com/sympy/sympy/issues/4596}

        >>> from sympy import Mul, sqrt
        >>> from sympy.abc import x, y, z
        >>> 2*(x + 1) # this is the 2-arg Mul behavior
        2*x + 2
        >>> y*(x + 1)*2
        2*y*(x + 1)
        >>> 2*(x + 1)*y # 2-arg result will be obtained first
        y*(2*x + 2)
        >>> Mul(2, x + 1, y) # all 3 args simultaneously processed
        2*y*(x + 1)
        >>> 2*((x + 1)*y) # parentheses can control this behavior
        2*y*(x + 1)

        Powers with compound bases may not find a single base to
        combine with unless all arguments are processed at once.
        Post-processing may be necessary in such cases.
        {c.f. https://github.com/sympy/sympy/issues/5728}

        >>> a = sqrt(x*sqrt(y))
        >>> a**3
        (x*sqrt(y))**(3/2)
        >>> Mul(a,a,a)
        (x*sqrt(y))**(3/2)
        >>> a*a*a
        x*sqrt(y)*sqrt(x*sqrt(y))
        >>> _.subs(a.base, z).subs(z, a.base)
        (x*sqrt(y))**(3/2)

      -  If more than two terms are being multiplied then all the
         previous terms will be re-processed for each new argument.
         So if each of ``a``, ``b`` and ``c`` were :class:`Mul`
         expression, then ``a*b*c`` (or building up the product
         with ``*=``) will process all the arguments of ``a`` and
         ``b`` twice: once when ``a*b`` is computed and again when
         ``c`` is multiplied.

         Using ``Mul(a, b, c)`` will process all arguments once.

    * The results of Mul are cached according to arguments, so flatten
      will only be called once for ``Mul(a, b, c)``. If you can
      structure a calculation so the arguments are most likely to be
      repeats then this can save time in computing the answer. For
      example, say you had a Mul, M, that you wished to divide by ``d[i]``
      and multiply by ``n[i]`` and you suspect there are many repeats
      in ``n``. It would be better to compute ``M*n[i]/d[i]`` rather
      than ``M/d[i]*n[i]`` since every time n[i] is a repeat, the
      product, ``M*n[i]`` will be returned without flattening -- the
      cached value will be returned. If you divide by the ``d[i]``
      first (and those are more unique than the ``n[i]``) then that will
      create a new Mul, ``M/d[i]`` the args of which will be traversed
      again when it is multiplied by ``n[i]``.

      {c.f. https://github.com/sympy/sympy/issues/5706}

      This consideration is moot if the cache is turned off.

    NB
    --
      The validity of the above notes depends on the implementation
      details of Mul and flatten which may change at any time. Therefore,
      you should only consider them when your code is highly performance
      sensitive.

      Removal of 1 from the sequence is already handled by AssocOp.__new__.
)AccumBounds)
MatrixExprNFrQ   c              3     "   T FS  p\         P                  V4       F7  pV\        P                  \        P                  \        P
                  39   x  K9  	  KU  	  R # 5irF   )r7   	make_argsr   NegativeInfinityrj   Infinity)rI   ___s   &  r(   rJ   Mul.flatten.<locals>.<genexpr>  sJ      :A$cmmB.? !,,a.?.?LL.? M$s   AATc           
        / pV  FT  w  r#VP                  4       pVP                  V/ 4      P                  V^,          . 4      P                  V^ ,          4       KV  	  VP                  4        F)  w  r%VP                  4        F  w  rg\	        V!  WV&   K  	  K+  	  . pVP                  4        F@  w  r#TP                  VP                  4        U	U
u. uF  w  rW*V	,          3NK  	  up
p	4       KB  	  V# u up
p	i    )as_coeff_Mul
setdefaultr5   itemsAddr4   )c_powerscommon_bber;   ddilinew_c_powerstrd   s   &          r(   _gatherMul.flatten.<locals>._gather  s    H ^^%##Ar*55qE2%vbe} ! !(ggiFBHAE ( ) L (##!'')$D)$!a1X)$DE ) %Es   C2c              3  B   <"   T F  pVSP                   9   x  K  	  R # 5irF   r-   )rI   inftyr   s   & r(   rJ   rx     s$      6;&:E 7<qvvo&:s   c                    . pV  FE  pVP                   '       d   K  VP                  '       d   VR,          pK4  VP                  V4       KG  	  W!3# r{   )is_extended_positiverc   r5   )c_part
coeff_sign
new_c_partr   s   &&  r(   _handle_for_oo#Mul.flatten.<locals>._handle_for_oo  sR    
A--- ---"b(
 %%a(   "--r'   c              3  <   <"   T F  p\        VS4      x  K  	  R # 5irF   )
isinstance)rI   rd   rp   s   & r(   rJ   rx     s     >g:a,,gs   c              3  >   "   T F  qP                   R 8H  x  K  	  R# 5iFN	is_finite)rI   rd   s   & r(   rJ   rx     s     8A;;%'   )=!sympy.calculus.accumulationboundsro   sympy.matrices.expressionsrp   lenis_Rationalr   r2   is_zeror|   is_Addr   
distributer%   r   r.   _keep_coeffZeror!   as_expr_variablesr"   r4   r5   r   r#   NaNrj   r   __mul__anyImaginaryUnitHalfas_base_expis_Pow
is_IntegerPowis_negativer}   is_positive
is_integerpopr6   rangeru   rt   r~   qpdivmodRationalr   r1   gcdr7   rs   as_numer_denomrk   r   is_extended_realr/   r   )7rZ   seqro   rvr<   rararbbinewbr   nc_partnc_seqcoeffr   num_expneg1epnum_ratorder_symbolsor   r   o1b1e1b2e2new_expo12r   ir   changedr   r   inv_exp_dictcomb_enum_rate_ieppneweigrowjbjejgobjnr   r   rd   _newfrp   s7   &&                                `                   @r(   flattenMul.flatten   s   ^ 	B9s8q=DAq}}}!1!fAEE>!>}}}QYYY~~'1888~S;"#C"%ac1u"=C!UB_*555!:J:J:J"!&&$I&B[%7&$IJ"VR-	      Azzz#$#6#6}#E = xxx###JJqvv& VV+++JJqM"MM!,	 $ JJy) :!*;*;!;			EE7B,,___
5(F(FQJE~ !wD00A{++		%(a'''EE7B,,))z!S11cc :Aff:Accc :Aff:A 7A 7A wD((aoo%!!! }}1 888{{{
 === ||| %Q 2 (!" #

3q!9 5 (!" %
%&B ~ ( 3 3Ar : A A! D$]]]alll#NNAq62$A'
 I%MM!$ f

1A"q)  !B^^-FB]]_FB 2gG
 Rx Gm ---JJsO$"MM!S1  Aw/{ X	  8$ '"0 qALG 1999AHHH## 6;&'&7&7&'&8&8&:6;### 6;&'&7&7&'&8&8&:6; 3; 3; !"wD00:{{{
 AAEE>Aq	A xxx }}17&*Ga ##QF+1 !6 3". 0".$!QA, 0 1474EF "<0I P DAq##Ar*11!4  &&(DAq!1gLO )\-?-?-AG-ATQQys1ay-AGH NN$DAqc1gr*11!4 % LLNDAqQAssaxQ"ssQSSy acc*RQ$R%NNAq6" #  4 #g,QZFBQwQD1q5#g,/ BFF2JAEE> RAssaxQ*339&,QSS!##&6GC!SC[0E (QSS 1AQF+"$Q$GAJABQUU{) 0* "bk===SLE  #}}S1===!SLE#&:::-:%(XXFB HOOB/  2 NN4 FA JJLDAq1gDG ! ((*DAq!Q<DAq1uuAvaoo. !A JJLDAqEzammm#$"Q ) MM#ammUU"KL 	TZZ\:\TQs1ay\:; QZZ!3!344	. "0!:FJ"0*"EGZZE A%%% "( QA	!))0D0D010B0B aF Q") S'Q)AII2F2F232D2D q'G SG ]]] s>g>sss>g>>>w66s88sss8888wM117B-- A{{{
A	 
  	 MM!U# (((S[A=Mq	###q	(;(;(;q	@P@P@P1IEVAY^^<^E!GG^<=>F--] %Jt 0  HJ ;2QSD =sG   'AA!(AA&AA,
AA,
AA2
+AA8AA8+AA=AA=AABc                	   V P                  R R7      w  r#VP                  '       dK   \        V Uu. uF  p\        WAR R7      NK  	  up!  \        \        P	                  V4      VR R7      ,          # VP
                  '       Ed   VP                  ^8X  d   V P                  '       d   V P                  4       ^,          pVP
                  '       d   \        V^,          4      P                  4       w  rg\        V^4      w  rhV'       d~   \        V^4      w  rxV'       dh   ^ RIHp	 \        V4      V,          p
\        WP                   ,          ^V	! V4      \"        P$                  ,          ,           VP                   ,          4      # \        WR R7      pVP
                  '       g   VP&                  '       d   VP)                  4       # V# u upi )F)split_1rq   sign)r3   r   r7   r   r8   r   r   is_imaginaryas_real_imagabsr   r   $sympy.functions.elementary.complexesr   r	   r?   r   r   r   is_Float_eval_expand_power_base)rN   exptr9   ncr   r<   r   r   r   r   r   r   s   &&          r(   _eval_powerMul._eval_power  sO    MM%M0	???uEu!Qu5uEFCNN2&u=> >!   %%'*===qs8224DA*1a0DA.q!4Q '
1A#3AvvIDGAOOD[@[^b^d^d?d#eeU+t}}},,..) Fs   Gc                	     ^^ V P                   3# )   )r   rZ   s   &r(   	class_keyMul.class_key  s    !S\\!!r'   c                	L   V P                  4       w  r#V\        P                  J dF   VP                  '       d   \        P
                  ! W14      ) pM1VP                  V4      pVe   TpV) pM\        P
                  ! W4      pVP                  '       d   VP                  4       # V# rF   )r|   r   rk   r"   r   _eval_evalf	is_numberexpand)rN   precrd   mr   mnews   &&    r(   r   Mul._eval_evalf  s      "xxx))!22}}T*#AR$$T0B<<<99;	r'   c                    ^RI Hp V P                  4       w  r#V\        P                  Jd   \        R4      hV! ^ 4      P                  V! V4      P                  3# )z+
Convert self to an mpmath mpc if possible
)Floatz7Cannot convert Mul to mpc. Must be of the form Number*I)numbersr  r|   r   r   AttributeError_mpf_)rN   r  im_part	imag_units   &   r(   _mpc_	Mul._mpc_  sO    
 	#!..0AOO+ !!Z[[ag 4 455r'   c                    V P                   p\        V4      ^8X  d   \        P                  V 3# \        V4      ^8X  d   V# V^ ,          V P                  ! VR,          !  3# )a  Return head and tail of self.

This is the most efficient way to get the head and tail of an
expression.

- if you want only the head, use self.args[0];
- if you want to process the arguments of the tail then use
  self.as_coef_mul() which gives the head and a tuple containing
  the arguments of the tail when treated as a Mul.
- if you want the coefficient when self is treated as an Add
  then use self.as_coeff_add()[0]

Examples
========

>>> from sympy.abc import x, y
>>> (3*x*y).as_two_terms()
(3, x*y)
r{   NN)r.   r   r   r2   _new_rawargs)rN   r.   s   & r(   as_two_termsMul.as_two_terms   sV    * yyt9>55$;Y!^K 7D--tBx888r'   rationalc               	  a S'       d:   \        V P                  V3R  lRR7      w  rEV P                  ! V!  \        V4      3# V P                  pV^ ,          P                  '       dv   V'       d   V^ ,          P
                  '       d   V^ ,          VR,          3# V^ ,          P                  '       d*   \        P                  V^ ,          ) 3VR,          ,           3# \        P                  V3# )c                $   < V P                   ! S!  # rF   )has)xdepss   &r(   <lambda>"Mul.as_coeff_mul.<locals>.<lambda>B  s    quud|r'   T)binaryr  )
r   r.   r  tupler#   r   rc   r   rk   r2   )rN   r  r  kwargsl1l2r.   s   &$j,   r(   ri   Mul.as_coeff_mul?  s    $))%;DIFB$$b)5944yy7tAw222AwR((a---}}QxkDH&<<<uud{r'   c                   V P                   ^ ,          V P                   R,          r2VP                  '       d   V'       d   VP                  '       d,   \        V4      ^8X  d   W#^ ,          3# W P                  ! V!  3# VP
                  '       d*   \        P                  V P                  ! V) 3V,           !  3# \        P                  V 3# )z3
Efficiently extract the coefficient of a product.
r  )	r.   r#   r   r   r  rc   r   rk   r2   )rN   r  r   r.   s   &&  r(   r|   Mul.as_coeff_MulL  s     iilDIIbMt???u000t9> q'>) "3"3T":::+++}}d&7&7E6)d:J&LLLuud{r'   c                	   ^ RI HpHpHp . p. p. p\        P
                  p	V P                   EF  p
V
P                  4       w  rVP                  '       d   VP                  V4       K;  VP                  '       d)   VP                  V\        P                  ,          4       Ku  V
P                  '       d   V'       d   V
P                  4       MRp\        V4       F.  w  rW8X  g   K  VP                  V! V4      ^,          4       Wl  K  	  V
P                  '       d   W,          p	K  VP                  V
4       EK  VP                  V
4       EK"  	  V P                  ! V!  pVP!                  R4      V8X  d   R# \#        V4      ^,          '       d   V! VP%                  ^ 4      4      pM\        P&                  pV P                  ! Wx,           !  pVV! V4      ,          VV! V4      ,          rV	^8X  do   V^8X  d>   VP                  '       d   V\        P&                  3# \        P&                  VV,          3# V\        P&                  J d   W3# V) V,          VV,          3# ^RIHp V! V	RR7      P                  4       w  ppV\        P&                  J d/   VV,          VV,          ,
          VV,          VV,          ,           3# V) V,          VV,          rVV,          VV,          ,
          VV,          VV,          ,           3# )r   )AbsimreNignore)
expand_mulF)deep)r   r   r!  r"  r   r2   r.   r   r   r5   r   r%   	conjugate	enumerater   funcgetr   r   r   functionr$  )rN   r%  hintsr   r!  r"  othercoeffrcoeffiaddtermsr<   r   r   aconjr  r   imcorecor$  addreaddims   &&,                  r(   r   Mul.as_real_imag\  s:   DD55A>>#DAyyya a/0!!!).D%e,DAzc!fai0!H	 - xxx QQ) * IIu99X!#v;??fjjm$D 66Dyy6?,RU
DAJ1q=Av<<< !&&>)FFDI..qvv~vE!GT!V$$(!(7DDFu166>eGag%qw5'89957DFqeGag%qw5'899r'   c           	     \   \        V 4      pV^8X  d   V ^ ,          P                  # . p\        P                  V RV^,           4      p\        P                  W^,          R 4      pV UUu. uF  qT F  p\        WV4      NK  	  K  	  ppp\	        V!  p\        P
                  ! V4      # u uppi )zS
Helper function for _eval_expand_mul.

sums must be a list of instances of Basic.
N)r   r.   r7   _expandsumsr   rs   )sumsLtermsleftrightr<   r   addeds   &       r(   r7  Mul._expandsums  s     I67<<tEQT{+TU,$(8Dq%QQ%D8U}}U## 9s   *B(c                	   ^ RI Hp T pV! W1P                  RR4      4      w  rEVP                  '       d:   WE3 Uu. uF)  pVP                  '       d   VP                  ! R/ VB MTNK+  	  upw  rEWE,          pVP                  '       g   V# . . RrpVP
                   Fi  p
V
P                  '       d   VP                  V
4       Rp	K*  V
P                  '       d   VP                  V
4       KO  VP                  \        V
4      4       Kk  	  V	'       g   V# V P                  ! V!  pV'       d   VP                  RR4      pV P                  P                  V4      p. pV F  pV P                  W~4      pVP                  '       dg   \        ;QJ d&    R VP
                   4       F  '       g   K   RM	  RM! R VP
                   4       4      '       d   V'       d   VP	                  4       pVP                  V4       K  	  \        V!  # V# u upi )r   fractionexactFTr%  c              3  8   "   T F  qP                   x  K  	  R # 5irF   )r   rH   s   & r(   rJ   'Mul._eval_expand_mul.<locals>.<genexpr>  s     'A&Q&rL   r   )sympy.simplify.radsimprA  r)  r"   _eval_expand_mulr.   r   r5   r%   r
   r(  r7  r   r   )rN   r+  rA  exprr   r   r   plainr8  rewritefactorr%  r:  r.   termr   s   &,              r(   rF  Mul._eval_expand_mul  s   3 ii78888!A 45888A&&//B!DAs{{{K!2uWiiF}}}F#(((LL(KKf.   KIIu%Eyy/		--d3!D		%.AxxxCC'A!&&'ACCC'A!&&'A$A$Ad..0KKN	 "
 Dz!A!s   HHc           
     	`   \        V P                  4      p. p\        \        V4      4       Fj  pW$,          P	                  V4      pV'       g   K$  VP                  \        R  VRV V.,           W$^,           R ,           \        P                  4      4       Kl  	  \        P                  ! V4      # )c                    W,          # rF   r   )r  ys   &&r(   r  &Mul._eval_derivative.<locals>.<lambda>  s    r'   N)r1   r.   r   r   diffr5   r   r   r2   r   fromiter)rN   sr.   r:  r   r   s   &&    r(   _eval_derivativeMul._eval_derivative  s    DIIs4y!AQAq V$4tBQx1#~QRUV7TWXW\W\]^ " ||E""r'   c                	  < ^RI Hp ^RIHpHpHp \        WV34      '       g   \        SV `!  W4      # ^RI	H
p V P                  p\        V4      p	\        V\        V34      '       dq   . p
^ RIHp V! W4       FS  w  r\!        \#        W4       UUu. uF  w  rVP%                  W34      NK  	  upp!  pV
P'                  VV,          4       KU  	  \)        V
!  # ^ RIHp ^ RIHp ^ RIHp V! RV	,          VR	7      pV\7        V4      ,
          pV! V4      pV\9        \;        VV4      4      ,          V! V4      ,          \!        \=        V	^,
          4       Uu. uF#  pVV,          P%                  WV,          34      NK%  	  up!  ,          VR
,          P%                  VV! ^ V4      34      ,          V Uu. uF  q^ V3NK	  	  upppV! V.VO5!  # u uppi u upi u upi )r{   )AppliedUndef)SymbolsymbolsDummy)Integer)!multinomial_coefficients_iterator)Sum)	factorial)Maxzk1:%ir   r   )r*  rW  symbolrX  rY  rZ  r   super_eval_derivative_n_timesr  r[  r.   r   intsympy.ntheory.multinomialr\  r7   ziprQ  r5   r   sympy.concrete.summationsr]  (sympy.functions.combinatorial.factorialsr^  (sympy.functions.elementary.miscellaneousr_  sumprodmapr   )rN   rS  r   rW  rX  rY  rZ  r[  r.   r   r:  r\  kvalsrd   kargr   r]  r^  r_  klastnfactr   r   l	__class__s   &&&                      r(   rb  Mul._eval_derivative_n_times  s   *22!F344 73A99$yyIa#w((ES=aCU9IJ9Ivq#((A6*9IJKQU# D ;1F@!/CJ!$s9e,--i.>>uQqSzBz!$q',,8}-zBCDHMM1c!Um,-. !&&1AY&	 
 1zqz K C&s   G)G
4Gc                	    ^ RI Hp V P                  ^ ,          p\        V P                  R,          !  pVP	                  WV,           4      V! WQV4      ,          V! WAV4      V,          ,           # )r   )difference_deltar  )sympy.series.limitseqru  r.   r7   subs)rN   r   stepddarg0rests   &&&   r(   _eval_difference_deltaMul._eval_difference_delta  s[    @yy|DIIbM"		!X&DT)::R=N>  	r'   c                	    V P                  4       w  r4\        P                  V4      p\        V4      ^8X  d4   V P                  P                  W4      pV^ ,          P                  WR4      # R# r{   N)r|   r7   rs   r   rr  _combine_inversematches)rN   rG  	repl_dictr   r:  newexprs   &&&   r(   _matches_simpleMul._matches_simple  sW    ((*e$u:?nn55dBG8##G77r'   c                	L   \        V4      pV P                  '       d%   VP                  '       d   V P                  WV4      # V P                  VP                  Jd   R # V P                  4       w  rEVP                  4       w  rgWF3 Uu. uF  q;'       g    ^.NK  	  upw  rF\	        V!  p	\	        V!  p
V	P                  WV4      pV'       g	   WF8w  d   R # \        P                  V4      p\        P                  V4      p\        P                  WWV4      pT;'       g    R # u upi rF   )r	   r%   _matches_commutativer3   r7   r  _matches_expand_pows_matches_noncomm)rN   rG  r  oldc1nc1c2nc2rd   comm_mul_selfcomm_mul_exprs   &&&&       r(   r  Mul.matches  s   t}4#6#6#6,,TcBB  (;(;; --/--/%'H-Hq((s(H- RR!))-CH	 RX &&s+&&s+((9=	  D ) .s   D!D!c                	    . pV  Ff  pVP                   '       dA   VP                  ^ 8  d0   VP                  VP                  .VP                  ,          4       KU  VP	                  V4       Kh  	  V# rh   )r   expr4   baser5   )arg_listnew_argsrn  s   &  r(   r  Mul._matches_expand_pows-  sR    Czzzcggk
SWW 45$	 
 r'   c                   Vf   / pMVP                  4       p. pRpVw  rV/ pV\        V4      8  d   V\        V 4      8  d   W,          pVP                  '       d   \        P	                  Wt4       \        P                  WtW4      p	V	'       d1   V	w  rVP                  V
4       V'       d   V F  pW,          W,&   K  	  V'       g   R# VP                  4       pVw  rVK  V# )zNon-commutative multiplication matcher.

`nodes` is a list of symbols within the matcher multiplication
expression, while `targets` is a list of arguments in the
multiplication expression being matched against.
N)r   r   )copyr   is_Wildr7   _matches_add_wildcard_matches_new_statesr4   r   )nodestargetsr  agendastatenode_ind
target_indwildcard_dictnodestates_matches
new_statesnew_matchesmatchs   &&&          r(   r  Mul._matches_noncomm7  s     I!(I $3w<'Hs5z,A?D|||))-? 44]5:EN*8'
j)!,+6+=	( "-

',$*r'   c                	F    Vw  r#W 9   d   W,          w  rEWC3W&   R # W33W&   R # rF   r   )
dictionaryr  r  r  beginends   &&    r(   r  Mul._matches_add_wildcardb  s0    $!#-JE$)#6J $.#;J r'   c                	F   Vw  rEW$,          pW5,          pV\        V4      ^,
          8  d   V\        V4      ^,
          8  d   R# VP                  '       d   \        P                  WW#4      pV'       d   \        P	                  V W$4      p	V	 FN  p
W
,          w  rW,          w  rW;V^,            pW=V^,            p\        VV4       F  w  ppVV8w  g   K    R# 	  KP  	  WE^,           3.pV\        V4      ^,
          8  d"   VP                  V^,           V^,           34       VV3# R# V\        V4      ^,
          8  d   V\        V4      ^,
          8  d   R# VP                  V4      pV'       d   V^,           V^,           3.V3# Wg8X  d   V^,           V^,           3.R3# R# r  )r   r  r7   _matches_match_wilds_matches_get_other_nodesre  r5   r  )r  r  r  r  r  r  r  targetmatch_attemptother_node_indsindother_begin	other_end
curr_begincurr_endother_targetscurrent_targetscurrr,  	new_states   &&&&                r(   r  Mul._matches_new_statesk  s   $$ W))hUa.G<<<44Z5:EM #&">">z?D#P*C-7_*K+5+?(J$+	A$FM&-A&FO'*?M'Je5=#' (K + 'Q78	c%j1n,$$hlJN%CD -/// 8 3u:>)j3w<!;K.K LL0M!AzA~67FF!AzA~67==r'   c                    W!,          pW,          w  rVW5V^,            p\        V4      ^8  d
   \        V!  MV^ ,          pVP                  V4      # )z@Determine matches of a wildcard with sub-expression in `target`.)r   r7   r  )	r  wildcard_indr  r  wildcardr  r  r:  mults	   &&&&     r(   r  Mul._matches_match_wilds  sN     &-
cAg&!%j1nsE{%(%%r'   c                ^    W,          pV  Uu. uF  qAV,          V8X  g   K  VNK  	  up# u upi )z8Find other wildcards that may have already been matched.r   )r  r  r  ind_noder  s   &&&  r(   r  Mul._matches_get_other_nodes  s.     ?)Dz3Z8-CzDDDs   **c                d   ^ RI Hp ^RIHp W8X  d   \        P
                  # R pV! W4      '       g   V! W4      '       d   \        P
                  # \        ;QJ d    R W3 4       F  '       g   K   RM	  RM! R W3 4       4      '       Edr   V! R4      p\        P                  V/pV\        P                  /pV P                  V4      P                  4       pVP                  V4      P                  4       p	\        V	4      p
\        V	P                  4       4       FO  pW9   g   K  W;;,          V	P                  V4      ,          uu&   W,          '       d   K>  VP                  V4       KQ  	  \        V	4      V
8w  d   \        VP                  4        UUu. uF  w  rW,          NK  	  upp!  P                  V4      p \        V	P                  4        UUu. uF  w  rW,          NK  	  upp!  P                  V4      pW,          pV! V4      pVP                   '       d   V# T# u uppi u uppi )z
Returns lhs/rhs, but treats arguments like symbols, so things
like oo/oo return 1 (instead of a nan) and ``I`` behaves like
a symbol instead of sqrt(-1).
)signsimp)rZ  c                    V P                   '       dD   VP                  '       d2   V P                  ^ 4      VP                  4       P                  ^ 4      8H  # R# )r   F)r   is_comparable__add__evalf)rq  r   s   &&r(   check#Mul._combine_inverse.<locals>.check  s<    zzzaooo yy|qwwy'8'8';;;r'   c              3  `   "   T F$  qP                   ;'       g    VP                  x  K&  	  R # 5irF   )r   r"   rI   r   s   & r(   rJ   'Mul._combine_inverse.<locals>.<genexpr>  s!     8Zxx##188#Z   ..TFI)sympy.simplify.simplifyr  r`  rZ  r   r2   r   r   xreplaceas_powers_dictr   r  keysr   r7   r~   r#   )lhsrhsr  rZ  r  r   _ii_r<   r   blenr   rm  vr   srvs   &&              r(   r  Mul._combine_inverse  s    	5!:55L	 ??eCoo55L38cZ83338cZ888 c
A//1%BQ__%BR //1AR //1Aq6DAFFHo7EQUU2Y&E55b		 &
 1v~QWWY7YTQADDY78AA"EQWWY7YTQADDY78AA"EWrlmmms++	 87s   H&
H,
c                	    \        \        4      pV P                   F>  pVP                  4       P	                  4        F  w  r4W;;,          V,          uu&   K  	  K@  	  V# rF   )r   rc  r.   r  r~   )rN   r   rK  r   r   s   &    r(   r  Mul.as_powers_dict  sJ    IID++-335	 6  r'   c           	     	    \        \        V P                   Uu. uF  qP                  4       NK  	  up!  4      w  r#V P                  ! V!  V P                  ! V!  3# u upi rF   )r1   re  r.   r   r(  )rN   r   numersdenomss   &   r(   r   Mul.as_numer_denom  sR     c		#J	1$4$4$6	#JKLyy&!499f#555 $Ks   Ac                	H   R p. p^ pV P                    F{  pVP                  4       w  rVVP                  '       g
   V^,          pVf   TpM3Wa8w  g   V^8  g   VP                  '       g   V \        P
                  3u # VP                  V4       K}  	  V P                  ! V!  V3# rF   )r.   r   r%   r   r   r2   r5   r(  )rN   r   basesr   r   r   r   s   &      r(   r   Mul.as_base_exp  s    A==?DA###azBF!,,,QUU{"LLO  yy% "$$r'   c                	   a \         ;QJ d)    V3R  lV P                   4       F  '       d   K   R# 	  R# ! V3R  lV P                   4       4      # )c              3  D   <"   T F  qP                  S4      x  K  	  R # 5irF   )_eval_is_polynomialrI   rK  symss   & r(   rJ   *Mul._eval_is_polynomial.<locals>.<genexpr>  s     Hid++D11i    FTallr.   rN   r  s   &fr(   r  Mul._eval_is_polynomial  s4    sHdiiHssHsHsHdiiHHHr'   c                	   a \         ;QJ d)    V3R  lV P                   4       F  '       d   K   R# 	  R# ! V3R  lV P                   4       4      # )c              3  D   <"   T F  qP                  S4      x  K  	  R # 5irF   )_eval_is_rational_functionr  s   & r(   rJ   1Mul._eval_is_rational_function.<locals>.<genexpr>  s     OYT22488Yr  FTr  r  s   &fr(   r  Mul._eval_is_rational_function  s4    sOTYYOssOsOsOTYYOOOr'   c                	J   aa \        VV3R  lV P                   4       RR7      # )c              3  F   <"   T F  qP                  SS4      x  K  	  R # 5irF   )is_meromorphic)rI   rn  r<   r  s   & r(   rJ   +Mul._eval_is_meromorphic.<locals>.<genexpr>  s     K#//155s   !T
quick_exitr   r.   )rN   r  r<   s   &ffr(   _eval_is_meromorphicMul._eval_is_meromorphic  s    KK'+- 	-r'   c                	   a \         ;QJ d)    V3R  lV P                   4       F  '       d   K   R# 	  R# ! V3R  lV P                   4       4      # )c              3  D   <"   T F  qP                  S4      x  K  	  R # 5irF   )_eval_is_algebraic_exprr  s   & r(   rJ   .Mul._eval_is_algebraic_expr.<locals>.<genexpr>  s     L)$//55)r  FTr  r  s   &fr(   r  Mul._eval_is_algebraic_expr  s4    sL$))LssLsLsL$))LLLr'   c                	:    \        R  V P                   4       4      # )c              3  8   "   T F  qP                   x  K  	  R # 5irF   )r%   rH   s   & r(   rJ   Mul.<lambda>.<locals>.<genexpr>  s      5-"+Q)rL   r  r_   s   &r(   r  Mul.<lambda>  s     5-"&))5- )-r'   c                	   \        R  V P                   4       4      pVRJ d   \        ;QJ d&    R V P                   4       F  '       g   K   RM	  RM! R V P                   4       4      '       dS   \        ;QJ d&    R V P                   4       F  '       g   K   RM	  RM! R V P                   4       4      '       d   R# R# V# )c              3  8   "   T F  qP                   x  K  	  R # 5irF   )
is_complexrH   s   & r(   rJ   'Mul._eval_is_complex.<locals>.<genexpr>  s     <)QLL)rL   Fc              3  8   "   T F  qP                   x  K  	  R # 5irF   )is_infiniterH   s   & r(   rJ   r  
  s     4)Q==)rL   Tc              3  <   "   T F  qP                   R Jx  K  	  R# 5ir   r   rH   s   & r(   rJ   r    s     Ay!yy-y   N)r   r.   r   )rN   comps   & r(   _eval_is_complexMul._eval_is_complex  sz    <$))<<5=s4$))4sss4$))4443AtyyA333AtyyAAAr'   c                	<   R ;rV P                    F  pVP                  '       d   VR Jd   Ru # RpK#  VP                  '       d   VR Jd   Ru # RpKC  VR J d   VP                  f   VR Jd   Ru # RpVR J g   Kk  VP                  e   K{  VR Jd   Ru # RpK  	  W3# )FNT)NN)r.   r   r  )rN   	seen_zeroseen_infiniter<   s   &   r(   _eval_is_zero_infinite_helper!Mul._eval_is_zero_infinite_helper  s    X %*)	Ayyy -%% 	E)%% $%!))*;$E1)) $I E)amm.C -))$(M# & ''r'   c                	V    V P                  4       w  rVR J d   R # VRJ d	   VR J d   R# R# )FTNr  rN   r  r  s   &  r(   _eval_is_zeroMul._eval_is_zeroS  s5     $(#E#E#G 	$=E#9r'   c                	V    V P                  4       w  rVR J d	   VRJ d   R # VRJ d   R# R# )TFNr  r  s   &  r(   _eval_is_infiniteMul._eval_is_infinite_  s5     $(#E#E#G 	D Y%%7e#r'   c                	   \        R  V P                   4       RR7      pV'       d   V# VRJ dS   \        ;QJ d&    R V P                   4       F  '       d   K   RM	  RM! R V P                   4       4      '       d   R# R# R# )c              3  8   "   T F  qP                   x  K  	  R # 5irF   )is_rationalrH   s   & r(   rJ   (Mul._eval_is_rational.<locals>.<genexpr>o  s     ;A--rL   Tr  Fc              3  <   "   T F  qP                   R J x  K  	  R# 5ir   r  rH   s   & r(   rJ   r'  t       9y!99%yr  Nr   r.   r  rN   r   s   & r(   _eval_is_rationalMul._eval_is_rationaln  s]    ;;MH%Zs9tyy9sss9tyy999 : r'   c                	   \        R  V P                   4       RR7      pV'       d   V# VRJ dS   \        ;QJ d&    R V P                   4       F  '       d   K   RM	  RM! R V P                   4       4      '       d   R# R# R# )c              3  8   "   T F  qP                   x  K  	  R # 5irF   )is_algebraicrH   s   & r(   rJ   )Mul._eval_is_algebraic.<locals>.<genexpr>x  s     <)Q..)rL   Tr  Fc              3  <   "   T F  qP                   R J x  K  	  R# 5ir   r  rH   s   & r(   rJ   r1  }  r)  r  Nr*  r+  s   & r(   _eval_is_algebraicMul._eval_is_algebraicw  s]    <$))<NH%Zs9tyy9sss9tyy999 : r'   c                	L  a V P                  4       pVR J d   R # . p. pR pV P                   EF  pR pVP                  '       d3   \        V4      \        P
                  Jd   VP                  V4       KH  KJ  VP                  '       dj   VP                  4       w  rx\        V4      \        P
                  Jd   VP                  V4       V\        P
                  Jd   VP                  V4       K  K  VP                  '       d   VP                  4       w  rV	P                  '       d   V
P                  '       g   R;rdV
P                  '       dC   TP                  V\        P                  J d   ^M\        V\        P                  4      4       EKd  V'       g,   V
P                  '       d   Q hV
P                   '       d   Q h R#  R#  R# 	  V'       g   V'       g   R# R pR pR p^RIHo V'       gK   V'       dC   \&        ;QJ d    V3R lV 4       F  '       d   K   R M	  RM! V3R lV 4       4      '       d   R # V'       d   R# V! V4      '       d   V! V4      '       d   R # V! V4      '       d   V^.8X  d   R# V! V4      '       d3   V! V4      '       d%   \)        VRR / ^,
          P                  '       d   R # \+        V4      ^8X  d   V^ ,          pVP,                  '       d   VP.                  '       do   \1        V Uu. uF.  pVP.                  '       g   K  VP                  4       ^,          NK0  	  up!  \3        VP4                  4      ,
          P6                  '       d   R# \+        V4      ^8X  d   V^ ,          pVP,                  '       d   VP.                  '       dq   \1        V Uu. uF.  pVP.                  '       g   K  VP                  4       ^,          NK0  	  up!  \3        VP4                  4      ,
          P                  '       d   R # R# R# R# R# u upi u upi )	FTNc                j    \         ;QJ d    R  V  4       F  '       d   K   R# 	  R# ! R  V  4       4      # )c              3  8   "   T F  qP                   x  K  	  R # 5irF   )is_oddr  s   & r(   rJ   9Mul._eval_is_integer.<locals>.<lambda>.<locals>.<genexpr>  s     3AxxrL   FTr  r  s   &r(   r  &Mul._eval_is_integer.<locals>.<lambda>  s'    3333333333333r'   c                j    \         ;QJ d    R  V  4       F  '       d   K   R# 	  R# ! R  V  4       4      # )c              3  8   "   T F  qP                   x  K  	  R # 5irF   is_evenr  s   & r(   rJ   r9         51a		1rL   FTr:  r;  s   &r(   r  r<    '    CC515CC5C5C5155r'   c                j    \         ;QJ d    R  V  4       F  '       g   K   R# 	  R# ! R  V  4       4      # )c              3  8   "   T F  qP                   x  K  	  R # 5irF   r?  r  s   & r(   rJ   r9    rA  rL   TF)r   r;  s   &r(   r  r<    rB  r'   )is_gtc              3  R   <"   T F  pS! V\         P                  4      x  K  	  R # 5irF   )r   r2   )rI   rw   rE  s   & r(   rJ   'Mul._eval_is_integer.<locals>.<genexpr>  s       37)5Aas   $'rQ   )r,  r.   r   r   r   r2   r5   r   r   r   r   r   r   r   rk   r   r   
relationalrE  r  r7   r   r   r@  r   r   r   is_nonnegative)rN   r&  
numeratorsdenominatorsunknownr<   hitr   r   r   r   alloddallevenanyevenr   rE  s   &              @r(   _eval_is_integerMul._eval_is_integer  s/   ,,.%
AC|||q6&%%a( ''')q6&%%a(AEE> ''* "}}|||1<<<$((C=== ''Q!&&[Aq}}-/ }}},, yyy(= 9 < G355%lss 37)537sss 37)537 07 07JGL$9$9Z  \aS%8Z  VL & &L959A=+|!QA|||			 "1" 23&'ii -!--/!,,"1 24<QSSMB(.)  z?a1A|||			 $3$ 23()		 -!--/!,,$3 46>qssmD%+& !& !*|  	13s   PP/P!P!c                	6   \         ;QJ d&    R  V P                   4       F  '       g   K   RM	  RM! R  V P                   4       4      pT;'       dI    \        ;QJ d&    R V P                   4       F  '       d   K   R# 	  R# ! R V P                   4       4      # )c              3  8   "   T F  qP                   x  K  	  R # 5irF   )is_polarrI   rn  s   & r(   rJ   %Mul._eval_is_polar.<locals>.<genexpr>  s     :		rL   TFc              3  `   "   T F$  qP                   ;'       g    VP                  x  K&  	  R # 5irF   )rU  r   rV  s   & r(   rJ   rW    s!     E9C///9r  )r   r.   r  )rN   	has_polars   & r(   _eval_is_polarMul._eval_is_polar  su    C:		:CCC:		::	 F FCE499ECC	F	FE499EE	Fr'   c                	$    V P                  R 4      # T)_eval_real_imagr_   s   &r(   _eval_is_extended_realMul._eval_is_extended_real  s    ##D))r'   c                	0   R pRpV P                    EF.  pVP                  ;'       g    VP                  R J d   VP                  R J d    R # VP                  '       d
   V'       * pKV  VP                  '       d   V'       g}   VP
                  pV'       g   VR J d   TpK  V'       dU   \        ;QJ d&    R V P                    4       F  '       d   K   R M	  RM! R V P                    4       4      '       d    R#  R# K  K  VP                  R J d   V'       d    R# TpEK  VP                  R J d   V'       d    R# TpEK.   R# 	  V'       d9   VP                  R J d   V'       d   V# VP                  R J d   V'       g   V# R# R# VR J d   V# V'       d   V# R# )FNc              3  8   "   T F  qP                   x  K  	  R # 5irF   r   rH   s   & r(   rJ   &Mul._eval_real_imag.<locals>.<genexpr>  s     >Iq{{IrL   T)r.   r  r  r   r   r   r  )rN   realzerot_not_re_imr   zs   &&    r(   r^  Mul._eval_real_imag  s@   A--%7A<N<NRW<Wx###		A 3>DII>333>DII>>>#' 	  ##u,5(1 4 ++u4K''50K  1 U]KK r'   c                	    \         ;QJ d&    R  V P                   4       F  '       d   K   RM	  RM! R  V P                   4       4      '       d   V P                  R4      # R# )c              3  d   "   T F&  qP                   R J ;'       d    VP                  x  K(  	  R# 5ir   )r   r   rH   s   & r(   rJ   )Mul._eval_is_imaginary.<locals>.<genexpr>  s&     E9ayyE!11akk19s   00FTN)r  r.   r^  r_   s   &r(   _eval_is_imaginaryMul._eval_is_imaginary  sB    3E499E333E499EEE''.. Fr'   c                	$    V P                  R 4      # r]  _eval_herm_antihermr_   s   &r(   _eval_is_hermitianMul._eval_is_hermitian  s    ''--r'   c                	$    V P                  R 4      # rb   ro  r_   s   &r(   _eval_is_antihermitianMul._eval_is_antihermitian
  s    ''..r'   c                	   V P                    FR  pVP                  e   VP                  f    R # VP                  '       d   K6  VP                  '       d
   V'       * pKQ   R # 	  VRJd   V# V P                  4       pV'       d   R# VRJ d   V# R # )NFT)r.   is_hermitianis_antihermitianr  )rN   hermr   r   s   &&  r(   rp  Mul._eval_herm_antiherm  s    A~~%););)C~~~###x  uK$$&K r'   c                	   V P                    F  pVP                  pV'       dg   \        V P                   4      pVP                  V4       \        ;QJ d    R  V 4       F  '       d   K   RM	  RM! R  V 4       4      '       d    R#  R# Ve   K   R# 	  \        ;QJ d&    R V P                    4       F  '       d   K   RM	  RM! R V P                    4       4      '       d   R# R# )c              3  v   "   T F/  qP                   ;'       d    \        VP                  4      R J x  K1  	  R# 5i)TN)r&  r   r   rI   r  s   & r(   rJ   *Mul._eval_is_irrational.<locals>.<genexpr>'  s*     XQWA>>)AII*>4GQWs   9 9FTNc              3  8   "   T F  qP                   x  K  	  R # 5irF   )is_realr}  s   & r(   rJ   r~  ,  s     ,)Qyy)rL   )r.   is_irrationalr1   remover  )rN   r   r<   otherss   &   r(   _eval_is_irrationalMul._eval_is_irrational!  s    AAdiia 3XQWX333XQWXXXy  3,$)),333,$)),,, -r'   c                $    V P                  ^4      # )a3  Return True if self is positive, False if not, and None if it
cannot be determined.

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

This algorithm is non-recursive and works by keeping track of the
sign which changes when a negative or nonpositive is encountered.
Whether a nonpositive or nonnegative is seen is also tracked since
the presence of these makes it impossible to return True, but
possible to return False if the end result is nonpositive. e.g.

    pos * neg * nonpositive -> pos or zero -> None is returned
    pos * neg * nonnegative -> neg or zero -> False is returned
_eval_pos_negr_   s   &r(   _eval_is_extended_positiveMul._eval_is_extended_positive/  s      !!!$$r'   c                	v   R ;r#V P                    EF  pVP                  '       d   K  VP                  '       d   V) pK/  VP                  '       dU   \        ;QJ d&    R V P                    4       F  '       d   K   R M	  RM! R V P                    4       4      '       d    R #  R# VP
                  '       d   V) pRpK  VP                  '       d   RpK  VP                  R J d   V) pV'       d    R# RpK  VP                  R J d   V'       d    R# RpEK   R# 	  V^8X  d   VR J d	   VR J d   R# V^ 8  d   R # R# )Fc              3  8   "   T F  qP                   x  K  	  R # 5irF   r   rH   s   & r(   rJ   $Mul._eval_pos_neg.<locals>.<genexpr>I  s     6Iq{{IrL   TN)	r.   r   rc   r   r  is_extended_nonpositiveis_extended_nonnegativer   r   )rN   r   saw_NONsaw_NOTr   s   &&   r(   r  Mul._eval_pos_negA  s    !!A%%%'''u36DII63336DII666 ***u*** %'u%'7 8 19E)g.>!8 r'   c                	$    V P                  R4      # r   r  r_   s   &r(   _eval_is_extended_negativeMul._eval_is_extended_negatived  s    !!"%%r'   c                	   V P                  4       pVR Jd   V# ^ RIHp V! V 4      w  r4VP                  '       d   VP                  '       d   \        \        P                  V4       Uu. uF.  pVP                  '       g   K  VP                  4       ^,          NK0  	  up!  \        VP                  4      ,
          P                  '       d   R# R# R ^rvV P                   Fr  p\        V4      \        P                  J d   K"  VP                  '       d    R# VRJ d   M2V^8w  d   Wx,           P                   '       d   RpMVP                  f   RpTpKt  	  V# u upi )Tr@  FN)rQ  rE  rA  r   r@  r   r7   rs   r   r   r   r   r.   r   r   r2   r8  )	rN   r   rA  r   r   r   r   accr   s	   &        r(   _eval_is_oddMul._eval_is_oddg  s   **,
T!3~<<<AIII MM!$3$ ./()		 )ammoa(($3 46>qssmD!k" q3A1vyyyEzsw..."C  %3s   )EEc                	   ^ RI Hp V! V 4      w  r#VP                  '       d   VP                  '       d   \	        \
        P                  V4       Uu. uF.  pVP                  '       g   K  VP                  4       ^,          NK0  	  up!  \        VP                  4      ,
          P                  '       d   R# R# R# R# u upi )r   r@  FN)rE  rA  r   r@  r   r7   rs   r   r   r   rI  )rN   rA  r   r   r   s   &    r(   _eval_is_evenMul._eval_is_even  s    3~<<<AIII MM!$3$ ./()		 )ammoa(($3 46>qssmD$n% %	 &<3s   B<*B<c                    ^ pV P                    FN  pVP                  '       d   VP                  '       g    R# V^,
          P                  '       g   KE  V^,          pKP  	  V^8  d   R# R# )z
Here we count the number of arguments that have a minimum value
greater than two.
If there are more than one of such a symbol then the result is composite.
Else, the result cannot be determined.
NT)r.   r   r   )rN   number_of_argsrn  s   &  r(   _eval_is_compositeMul._eval_is_composite  sW     99CNNNsA"""!#	  A r'   c           	     	  a(a)a*a+a, ^ RI Ho, ^ RIHp ^ RIHo+ ^ RIHp VP                  '       g   R# VP                  ^ ,          P                  '       dj   VP                  ^ ,          ^ 8  dR   V P                  ^ ,          P                  '       d/   V P                  ^ ,          ^ 8  d   V P                  V) V) 4      # R# R o(V(V+3R lpV(3R lpR	 pRpV! V 4      w  rT pV
\        P                  JdS   V	P                  W4      V
P                  W4      ,          pVP                  '       g   VP                  W4      # W8w  d   TpVP                  ^ ,          pVP                  ^ ,          pRpVP                  '       d+   VP                  '       d   W8w  d   VP                  V4      pMVP                  '       d   V# V! V4      w  o)pV! V4      w  o*pV'       d   VP                  '       do   \!        V4      ^8w  d_   \        V! \!        V4      V4      4      pS)P#                  V4       VS)9   d   S)V;;,          V,          uu&   MVS)V&   WV,          ,          pM^pR
p\%        V4      \%        V4      8  d   RpM\%        S*4      \%        S)4      8  d   RpMV Uu0 uF  pV^ ,          kK  	  upP'                  V Uu0 uF  pV^ ,          kK  	  up4      '       d   RpMr\)        S*4      P'                  \)        S)4      4      '       d   RpMF\*        ;QJ d!    V)V*V,3R lS* 4       F  '       g   K   R
M	  RM! V)V*V,3R lS* 4       4      '       d   RpV'       g   V# S*'       g   RpM[. pS*P-                  4        F:  w  ppS)V,          pVP/                  V! VV4      4       VR,          '       d   K8  Vu # 	  \1        V4      pV'       g0   Rp\3        \%        V4      4       F  pV! VV,          !  VV&   K  	  EM}^ p\%        V4      pT;'       g    \        P4                  p. p^ pV'       Ed   VV,           \%        V4      8:  Ed   Rp. p\3        V4       EF  pVVV,           ,          ^ ,          VV,          ^ ,          8w  d    EMvV^ 8X  d=   VP/                  V! VVV,           ,          ^,          VV,          ^,          4      4       MVV^,
          8X  d=   VP/                  V! VVV,           ,          ^,          VV,          ^,          4      4       M>VVV,           ,          ^,          VV,          ^,          8w  d    EMVP/                  ^4       V^,          pEK  	  \1        V4      p V '       Ed   V^8X  dl   V'       d   \1        VV 4      p \7        VV 4      V! VV,          ^ ,          VV,          ^,          V V^ ,          ^,          ,          ,
          4      ,          VV&   EM^p V! VV,          ^ ,          VV,          ^,          V V^ ,          ^,          ,          ,
          4      p!Tp"VV,           ^,
          p#VV#,          ^ ,          VV#,          ^,          V VR,          ^,          ,          ,
          3p$V$^,          '       dP   VV,           \%        V4      8  d   V!V",          V$.VVVV,           % M6V! V$!  p$V!V",          V$,          .VVVV,           % MV!V",          .VVVV,           % VV ,          pVV ,          pR
pV'       g   VP/                  V4       V^,          pEK  V'       g   V# VP9                  \3        V\%        V4      4      4       V F"  pV! VV,          !  P;                  W4      VV&   K$  	  Vf   Tp%MVf   Tp%M\1        VV4      p%. p&S) Fp  pVS*9   d9   S)V,          S*V,          V%,          ,
          p'V&P/                  V! VV'4      4       KB  V&P/                  V! VP;                  W4      S)V,          4      4       Kr  	  V'       d   V'       g   \7        VV4      .V&,           p&VVP<                  ! V&!  ,          VP<                  ! V!  ,          # u upi u upi )r   r   )multiplicity)	powdenestr@  Nc                    ^ RI Hp V P                  '       g   \        W4      '       d   V P	                  4       # V \
        P                  3# )r   )r  )&sympy.functions.elementary.exponentialr  r   r   r   r   r2   )r<   r  s   & r(   base_exp Mul._eval_subs.<locals>.base_exp  s4     Cxxx:a--}}&aee8Or'   c                n  < \        \        4      . r!\        P                  V 4       F  pS	! V4      pS! V4      w  rEV\        P
                  Jd'   VP                  4       w  rg\        WEV,          4      pTpVP                  '       d   W;;,          V,          uu&   Kw  VP                  WE.4       K  	  W3# )zbreak up powers of eq when treated as a Mul:
   b**(Rational*e) -> b**e, Rational
commutatives come back as a dictionary {b**e: Rational}
noncommutatives come back as a list [(b**e, Rational)]
)
r   rc  r7   rs   r   r2   ri   r   r%   r5   )
eqrd   r   r<   r   r   r;   rw   r  r  s
   &       r(   breakupMul._eval_subs.<locals>.breakup  s     #3']]2&aL!!AEE>nn.GRAtAA###DAIDIIqf% ' 7Nr'   c                <   < S! V 4      w  r\        WV,          4      # )z
Put rational back with exponent; in general this is not ok, but
since we took it from the exponent for analysis, it's ok to put
it back.
r   )r   r;   r   r  s   && r(   rejoinMul._eval_subs.<locals>.rejoin  s     a[FQqB$<r'   c                    VP                   V P                   ,          '       d$   V P                   VP                   ,          '       g   \        W,          4      # ^ # )zif b divides a in an extractive way (like 1/4 divides 1/2
but not vice versa, and 2/5 does not divide 1/3) then return
the integer number of times it divides, else return 0.
)r   rc  )r<   r   s   &&r(   ndivMul._eval_subs.<locals>.ndiv  s3    
 3399ACC!##II13xr'   TFc              3  b   <"   T F$  pS! SV,          4      S! SV,          4      8g  x  K&  	  R # 5irF   r   )rI   r   rd   old_cr   s   & r(   rJ   !Mul._eval_subs.<locals>.<genexpr>$  s&     =u!adtE!H~-us   ,/r   )r   r   sympy.ntheory.factor_r  sympy.simplify.powsimpr  rE  rA  r"   r.   r#   _subsr   r2   r   extract_multiplicativelyr   r   r   
differencesetr   r~   r5   minr   ru   r   r4   rw  r(  )-rN   r  newr  rA  r  r  r  r   r   r   self2co_selfco_oldco_xmulr   old_ncr  co_residualokr   cdidratr   old_ec_encdidtakelimitfailedrM  r   ndorq  midirr   domargsr   r  rd   r  r  r   s-   &&&                                     @@@@@r(   
_eval_subsMul._eval_subs  s   =643zzz 88A;   SXXa[1_yy|%%%99Q<!#::sdSD11		*	 	 ~AEE>GGC%aggc&77E<<<{{3,,} **Q-!'"5"5"5  !::6BI %.B!#, w***s6{a/?\#f+w78DEE'N{&	T!	 &	!$,.KK v;R BZ#a& B"#FqaddF#..b/Ab!b/ABBBZ""3q6**BS=u=SSS=u===BIDC#kkm
Ed

4U+,2wwI	 ,
 s8DE3r7^11 $ Ev;D&&AJJEFA%AHB/ tA!a%y|vay|3a

41q5	!fQil#CDdQh

41q5	!fQil#CDAE115

1FA % c(Cs19#&)$n$'SM&Aq$&qE!Hs6!9Q</?$?3A %ABqE #$C !'r!uQxAqC$*1IaL=1 21 !2A
 #&C "#TAB!#BBrF1I!'A9/ -/ !0A tt#$t8c"g#567eQZBqTN(.
A67eAgYBqTN
 34C%1QX" MM!$Q I eAs2w/0A"BqEN//9BqE  
 <B]BUD!BAEz aD58B;&VAq\*VAFF3$4ad;<   d^$u,E5::u--ejj"o==U $/As   a=ac                	<  a  ^RI Hp ^ RIHp ^ RIHp R p. p	 V P                   FE  p
V
P                  V4      w  rVP                  V4      '       g   V	P                  W34       KA  \        h	  \        R V	 4       4      p. pV	 F~  w  rT! W-,
          VP                  '       d   TM^ ,           4      pV
P                  VVW4R7      pVP                  4       pVe   VV8  d   VVV,
          ,          pVP                  V4       K  	  \&        P(                  pT Uu. uF  p\2        P4                  ! T4      NK  	  pp\7        T!   Fk  pT Uu. uF  pT! TT4      NK  	  pp\9        T!  w  pp\        T4      pTT,
          P:                  '       g   KM  T\=        T!  TT,          ,          ,          pKm  	  T 3R lo T P?                  T4      '       dG   ^ RI H!p ^ RI"H#p  S ! Y4      T8  g   T! Y4      T! TT4      8w  d   TT! Y,          T4      ,          pT# TT 8w  dt   T T,
          PI                  T^ 4      \&        P(                  8X  d2   T^ 8  d+   T PK                  YTR7      pT\&        P(                  8X  d   T# TT! Y,          T4      ,          pT#   \        \        \         T3 d    \#        \        R T	 4       4      4      pTP$                  '       d   \&        P(                  pT P                   U
u. uF!  qP                  Y! Y-,
          4      Y4R7      NK#  	  Mu up
i pp
^ RIHp T! T P.                  ! T!  P1                  4       R	R
R7      pTP                  T4      '       d   TT! Y,          T4      ,          pTu # i ; iu upi u upi   T d     ELi ; i)r{   )	PoleError)ceiling)Orderc                    V P                  V4      pV^ ,          P                  V4      '       d    V P                  V4      pV# V#   \         d    T \        P
                  3u # i ; irh   )as_coeff_exponentr  leadterm
ValueErrorr   r   )rK  r  lts   && r(   	coeff_exp$Mul._eval_nseries.<locals>.coeff_exp  s`    ''*B!uyy||(q)B I2I " (<'(s   A A&%A&c              3  h   "   T F(  q^,          P                   '       g   K  V^,          x  K*  	  R# 5ir  r   rI   r   s   & r(   rJ   $Mul._eval_nseries.<locals>.<genexpr>  s      :4aQ4>>TQqTT4   22)r   logxcdirc              3  h   "   T F(  q^,          P                   '       g   K  V^,          x  K*  	  R# 5ir  r  r  s   & r(   rJ   r    s      B4aQ4>>TQqTT4r  )powsimpr  T)combiner%  c           	       <a V SJ d   \         P                  # V P                  '       d   \         P                  # V P                  '       d!   \        VV3R  lV P                   4       4      # V P                  '       d+   \        V P                   Uu. uF  pS! VS4      NK  	  up!  # V P                  '       d%   S! V P                  S4      V P                  ,          # \         P                  # u upi )c              3  6   <"   T F  pS! VS4      x  K  	  R # 5irF   r   )rI   r<   
max_degreer  s   & r(   rJ   8Mul._eval_nseries.<locals>.max_degree.<locals>.<genexpr>  s     <V:a++Vs   )r   r2   is_Atomr   r   maxr.   r"   r   r   r  r  )r   r  r<   r  s   &f r(   r  %Mul._eval_nseries.<locals>.max_degree  s    Avuuyyyvvxxx<QVV<<<xxxqvv>v!Z1-v>??xxx!!&&!,QUU2266M ?s   C/)PolynomialError)degreer  r  )&r*  r  #sympy.functions.elementary.integersr  sympy.series.orderr  r.   r  r  r5   r  ri  r   nseriesgetnNotImplementedError	TypeErrorr	   rI  r   r   r  r  r(  r   r   rs   r   re  r   r7   is_polynomialsympy.polys.polyerrorsr  sympy.polys.polytoolsr  rw  _eval_as_leading_term)!rN   r  r   r  r  r  r  r  r  ordsr   r   r  n0facsr   n1rS  nsr  resrJ  ords2facrK  ords3coeffspowerspowerr  r  r  r  s!   &&&&&                           @r(   _eval_nseriesMul._eval_nseries  s   '?,	 	YYZZ]
yy||KK)$$  :4::BDQVAKKKqQ?@IIa2DI<VVX>BwR"WA . ff59:T6v&T:E?C478CDYtQ'CE8 %[NFFKE	&&&sF|QX.. #	 a  >4d&!+vd&a./P5q>)C 
$;s
  A&!&&0QU//4/H<J5q>!C
m /IF 	 B4BBCB   VVQUQZQZ[QZAIIa714=tIGQZ[D[6$))T*113UNCwwu~~uQT1~%J	 ; 92 # s>   C-J NN7N A"N5'LA$NNNNc                	    V P                   ! V P                   Uu. uF  qDP                  WVR 7      NK  	  up!  # u upi )r  )r(  r.   as_leading_term)rN   r  r  r  r   s   &&&& r(   r  Mul._eval_as_leading_term  s5    yytyyYy!,,Q,EyYZZYs   ;c                	z    V P                   ! V P                   Uu. uF  qP                  4       NK  	  up!  # u upi rF   )r(  r.   r&  rN   r   s   & r(   _eval_conjugateMul._eval_conjugate  s+    yy$))<)Q;;=)<==<s   8c                	    V P                   ! V P                  R R R1,           Uu. uF  qP                  4       NK  	  up!  # u upi Nr   )r(  r.   	transposer  s   & r(   _eval_transposeMul._eval_transpose  s3    yy$))DbD/B/Q;;=/BCCB   Ac                	    V P                   ! V P                  R R R1,           Uu. uF  qP                  4       NK  	  up!  # u upi r  )r(  r.   adjointr  s   & r(   _eval_adjointMul._eval_adjoint  s3    yy		$B$@199;@AA@r  c                    \         P                  p. pV P                   FF  pVP                  WR7      w  rgW6,          pV\         P                  Jg   K5  VP	                  V4       KH  	  W0P
                  ! V!  3# )a  Return the tuple (R, self/R) where R is the positive Rational
extracted from self.

Examples
========

>>> from sympy import sqrt
>>> (-3*sqrt(2)*(2 - 2*sqrt(2))).as_content_primitive()
(6, -sqrt(2)*(1 - sqrt(2)))

See docstring of Expr.as_content_primitive for more examples.
)radicalclear)r   r2   r.   as_content_primitiver5   r(  )rN   r  r  coefr.   r<   rd   r   s   &&&     r(   r  Mul.as_content_primitive  sf     uuA))')GDAID~A	  YY%%%r'   c                d   a V P                  4       w  r#VP                  V3R lR7       W#,           # )zTransform an expression into an ordered list of factors.

Examples
========

>>> from sympy import sin, cos
>>> from sympy.abc import x, y

>>> (2*x*y*sin(x)*cos(x)).as_ordered_factors()
[2, x, y, sin(x), cos(x)]

c                (   < V P                  SR 7      # ))order)sort_key)rG  r$  s   &r(   r  (Mul.as_ordered_factors.<locals>.<lambda>9  s    DMMM$>r'   r*   )r3   r,   )rN   r$  cpartncparts   &f  r(   as_ordered_factorsMul.as_ordered_factors+  s)     

>
?~r'   c                	4    \        V P                  4       4      # rF   )r  r)  r_   s   &r(   _sorted_argsMul._sorted_args<  s    T,,.//r'   r   rb   r]  )NFrF   rh   )FT)Ur   r   r   r    __doc__	__slots__r"   r   
_args_typer   rM   __annotations__propertyrG   r   r[   r.   re   rl   classmethodr   r   r   r   r  r   r  ri   r|   r   staticmethodr7  rF  rT  rb  r|  r  r  r  r  r  r  r  r  r  r  r   r   r  r  r   r  _eval_is_commutativer  r  r  r"  r,  r3  rQ  rZ  r_  r^  rl  rq  rt  rp  r  r  r  r  r  r  r  r  r	  r  r  r  r  r  r)  r,  r&   __classcell__)rr  s   @r(   r7   r7   [   s   DJ IFJ%&;N1 1 	t 	 
	 
	6: Q. Q.f8 " "  6 6 9 9< 
4 
 
 5:n $ $$)V 	# 	#  >!@   ( (T < < 2 2h & & E E
 ', ',R6%IP-M-A(F

L!\F
*(T/./(%$!F&<
"F>PYv[>DB&4" 0 0r'   r7   mulc                6    \        \        P                  W4      # )aK  Return product of elements of a. Start with int 1 so if only
   ints are included then an int result is returned.

Examples
========

>>> from sympy import prod, S
>>> prod(range(3))
0
>>> type(_) is int
True
>>> prod([S(2), 3])
6
>>> _.is_Integer
True

You can start the product at something other than 1:

>>> prod([1, 2], 3)
6

)r   operatorr7  )r<   starts   &&r(   rj  rj  C  s    . (,,))r'   c           	        V P                   '       g   VP                   '       d   YrMW,          # V\        P                  J d   V # V \        P                  J d   V# V \        P                  J d   V'       g   V) # VP                  '       Ed   V'       g   V P
                  '       d   V P                  ^8w  d   VP                   Uu. uF  qDP                  4       NK  	  ppV UUu. uF  w  rg\        W`4      V3NK  	  ppp\        ;QJ d    R V 4       F  '       g   K   RM	  RM! R V 4       4      '       dQ   \        P                  ! V Uu. uF/  p\        P                  V^ ,          ^8X  d
   VR,          MT4      NK1  	  up4      # \        WRR7      # VP                  '       d   \        VP                  4      pV^ ,          P                   '       d6   V^ ;;,          V ,          uu&   V^ ,          ^8X  d   VP!                  ^ 4       MVP#                  ^ V 4       \        P                  V4      # W,          pVP                   '       d)   VP                   '       g   \        P                  W34      pV# u upi u uppi u upi )a  Return ``coeff*factors`` unevaluated if necessary.

If ``clear`` is False, do not keep the coefficient as a factor
if it can be distributed on a single factor such that one or
more terms will still have integer coefficients.

If ``sign`` is True, allow a coefficient of -1 to remain factored out.

Examples
========

>>> from sympy.core.mul import _keep_coeff
>>> from sympy.abc import x, y
>>> from sympy import S

>>> _keep_coeff(S.Half, x + 2)
(x + 2)/2
>>> _keep_coeff(S.Half, x + 2, clear=False)
x/2 + 1
>>> _keep_coeff(S.Half, (x + 2)*y, clear=False)
y*(x + 2)/2
>>> _keep_coeff(S(-1), x + y)
-x - y
>>> _keep_coeff(S(-1), x + y, sign=True)
-(x + y)
c              3  >   "   T F  w  rVP                   x  K  	  R # 5irF   )r   )rI   rd   rw   s   &  r(   rJ   _keep_coeff.<locals>.<genexpr>  s     1DDA1<<Dr   TFr  rq   )r#   r   r2   rk   r   r   r   r.   r|   r   r   r   r8   r7   r"   r1   r   r6   )	r   factorsr  r   r   r.   rd   r   r  s	   &&&&     r(   r   r   ]  s   6 ???"U= !%%~	!--	x	***uww!|.5ll;lNN$lD;;?@441[*A.4D@s1D1sss1D111~~8<'>8<1 (+~~qTQYAbEA(/8<'> ? ?5E22	W\\"8!HHQx1}		!LLE"~~e$$M;;;w000/0A' <@'>s   I8&I=5Jc                    R  p\        W4      # )c                    V P                   '       d`   V P                  4       w  rVP                  '       d<   VP                  '       d*   \	        VP
                   Uu. uF  q1V,          NK  	  up!  # V # u upi rF   )r"   r|   r#   r   _unevaluated_Addr.   )r   rd   r   ris   &   r(   r  expand_2arg.<locals>.do  sW    888>>#DA{{{qxxx')@2B$$)@AA *As   A4r   )r   r  s   & r(   expand_2argrD    s     Qr'   )r   r  )r   rA  rz   )TF)6
__future__r   typingr   r   collectionsr   	functoolsr   	itertoolsr   r9  r	   basicr
   r   	singletonr   
operationsr   r   cacher   intfuncr   r   logicr   r   rG  r   
parametersr   rG   r   	traversalr   sympy.utilities.iterablesr   r   r/   r?   r7   r7  rj  r   rD  r  r   r  r   addr   rA  r   r'   r(   <module>rT     s    " * #     '  2  . *  )     *
 !
1(hc0$ c0J? *4;z   & &r'   