+
    i@P                      R t ^ RIHt ^ RIHtHtHtHt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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"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I/H0t0H1t1 ^ RI2H3t3H4t4H5t5H6t6 ^ RI7H&t8H9t:H;t; ^ RI<H=t=H>t>H?t? ^ RI@HAtA ^ RIBHCtCHDtD ^ RIEHFtF ^ RIGHHtH ]C]03R R ll4       tI]C]03R l4       tJ]C]03R l4       tK]CR 4       tLR  tM ! R! R"]A]4      tN ! R# R$](]A]]O4      tPR%# )&zSparse polynomial rings. )annotations)addmulltlegtge)reduce)GeneratorType)cacheit)Expr)igcd)Symbolsymbols)CantSympifysympify)multinomial_coefficients)IPolys)construct_domain)ninfdmp_to_dictdmp_from_dict)Domain)DomainElementPolynomialRingheugcd)MonomialOps)lexMonomialOrder)CoercionFailedGeneratorsErrorExactQuotientFailedMultivariatePolynomialError)r   Orderbuild_options)expr_from_dict_dict_reorder_parallel_dict_from_expr)DefaultPrinting)publicsubsets)is_sequence)pollutec                   V ^8  d   QhRR/# )   orderzMonomialOrder | str )formats   "q/Users/tonyclaw/.openclaw/workspace/skills/math-calculator/venv/lib/python3.14/site-packages/sympy/polys/rings.py__annotate__r5   %   s     ! !!2 !    c                B    \        WV4      pV3VP                  ,           # )aR  Construct a polynomial ring returning ``(ring, x_1, ..., x_n)``.

Parameters
==========

symbols : str
    Symbol/Expr or sequence of str, Symbol/Expr (non-empty)
domain : :class:`~.Domain` or coercible
order : :class:`~.MonomialOrder` or coercible, optional, defaults to ``lex``

Examples
========

>>> from sympy.polys.rings import ring
>>> from sympy.polys.domains import ZZ
>>> from sympy.polys.orderings import lex

>>> R, x, y, z = ring("x,y,z", ZZ, lex)
>>> R
Polynomial ring in x, y, z over ZZ with lex order
>>> x + y + z
x + y + z
>>> type(_)
<class 'sympy.polys.rings.PolyElement'>

PolyRinggensr   domainr1   _rings   &&& r4   ringr>   $   s!    8 We,E8ejj  r6   c                4    \        WV4      pW3P                  3# )aX  Construct a polynomial ring returning ``(ring, (x_1, ..., x_n))``.

Parameters
==========

symbols : str
    Symbol/Expr or sequence of str, Symbol/Expr (non-empty)
domain : :class:`~.Domain` or coercible
order : :class:`~.MonomialOrder` or coercible, optional, defaults to ``lex``

Examples
========

>>> from sympy.polys.rings import xring
>>> from sympy.polys.domains import ZZ
>>> from sympy.polys.orderings import lex

>>> R, (x, y, z) = xring("x,y,z", ZZ, lex)
>>> R
Polynomial ring in x, y, z over ZZ with lex order
>>> x + y + z
x + y + z
>>> type(_)
<class 'sympy.polys.rings.PolyElement'>

r8   r;   s   &&& r4   xringr@   C   s    8 We,E::r6   c                    \        WV4      p\        VP                   Uu. uF  qDP                  NK  	  upVP                  4       V# u upi )a\  Construct a polynomial ring and inject ``x_1, ..., x_n`` into the global namespace.

Parameters
==========

symbols : str
    Symbol/Expr or sequence of str, Symbol/Expr (non-empty)
domain : :class:`~.Domain` or coercible
order : :class:`~.MonomialOrder` or coercible, optional, defaults to ``lex``

Examples
========

>>> from sympy.polys.rings import vring
>>> from sympy.polys.domains import ZZ
>>> from sympy.polys.orderings import lex

>>> vring("x,y,z", ZZ, lex)
Polynomial ring in x, y, z over ZZ with lex order
>>> x + y + z # noqa:
x + y + z
>>> type(_)
<class 'sympy.polys.rings.PolyElement'>

)r9   r.   r   namer:   )r   r<   r1   r=   syms   &&&  r4   vringrD   b   s=    6 We,E%--1-3hh-15::>L 2s   Ac                   Rp\        V 4      '       g   V .Rr0\        \        \        V 4      4      p \	        W4      p\        W4      w  rTVP                  f   \        V Uu. uF  p\        VP                  4       4      NK  	  up. 4      p\        WtR7      w  Vn        p\        \        Wx4      4      p	V UU
Uu. uF-  qfP                  4        U
Uu/ uF  w  rWV,          bK  	  upp
NK/  	  pp
pp\        VP                  VP                  VP                  4      p\        \        VP                   V4      4      pV'       d   W^ ,          3# W3# u upi u upp
i u upp
pi )a   Construct a ring deriving generators and domain from options and input expressions.

Parameters
==========

exprs : :class:`~.Expr` or sequence of :class:`~.Expr` (sympifiable)
symbols : sequence of :class:`~.Symbol`/:class:`~.Expr`
options : keyword arguments understood by :class:`~.Options`

Examples
========

>>> from sympy import sring, symbols

>>> x, y, z = symbols("x,y,z")
>>> R, f = sring(x + 2*y + 3*z)
>>> R
Polynomial ring in x, y, z over ZZ with lex order
>>> f
x + 2*y + 3*z
>>> type(_)
<class 'sympy.polys.rings.PolyElement'>

FT)opt)r-   listmapr   r&   r)   r<   sumvaluesr   dictzipitemsr9   r:   r1   	from_dict)exprsr   optionssinglerF   repsrepcoeffs
coeffs_dom	coeff_mapmcr=   polyss   &*,           r4   sringrZ      s   4 FuvWe$%E

)C )4ID
zzT;TctCJJL)T;R@!1&!B
JV01	EIJTcYY[9[TQaL[9TJSXXszz3995EU__d+,EQx  ~ <
 :Js    "E8EE#EEc                   \        V \        4      '       d   V '       d   \        V R R7      # R# \        V \        4      '       d   V 3# \	        V 4      '       d   \
        ;QJ d    R V  4       F  '       d   K   RM	  R M! R V  4       4      '       d   \        V 4      # \
        ;QJ d    R V  4       F  '       d   K   RM	  R M! R V  4       4      '       d   V # \        R4      h)T)seqc              3  B   "   T F  p\        V\        4      x  K  	  R # 5iN)
isinstancestr.0ss   & r4   	<genexpr>!_parse_symbols.<locals>.<genexpr>   s     37az!S!!7   Fc              3  B   "   T F  p\        V\        4      x  K  	  R # 5ir^   )r_   r   ra   s   & r4   rd   re      s     6gAt$$grf   zbexpected a string, Symbol or expression or a non-empty sequence of strings, Symbols or expressionsr2   )r_   r`   _symbolsr   r-   allr"   r   s   &r4   _parse_symbolsrk      s    '3.5xT*=2=	GT	"	"z	W		337333337333G$$S6g6SSS6g666N
~
r6   c                  r   ] tR t^t$ RtR]R&   R]R&   R]R&   R]R	&   R
]R&   ]3R ltR tR t	R t
R tR tR tR2R lt]R 4       tR t]R 4       t]R 4       tR tR3R ltR tR tR t]tR3R ltR3R ltR  tR! tR" tR# t R$ t!R% t"R& t#R' t$R( t%]R) 4       t&]R* 4       t'R+ t(R, t)R- t*R. t+R/ t,R0 t-R1t.R# )4r9   z*Multivariate distributed polynomial ring. ztuple[PolyElement, ...]r:   ztuple[Expr, ...]r   intngensr   r<   r    r1   c                	  a \        \        V4      4      p\        V4      p\        P                  ! V4      p\
        P                  ! S4      oV P                  WVS3pVP                  '       d7   \        V4      \        VP                  4      ,          '       d   \        R 4      h\        P                  V 4      pWVn        \        V4      Vn        Wn	        WFn        W&n        SVn        \'        VR4      P(                  Vn        RV,          Vn        VP/                  4       Vn        \        VP0                  4      Vn        VP,                  VP4                  3.Vn        V'       d   \9        V4      pVP;                  4       Vn        VP?                  4       Vn         VPC                  4       Vn"        VPG                  4       Vn$        VPK                  4       Vn&        VPO                  4       Vn(        VPS                  4       Vn*        M/R pWn        Wn         R Vn"        Wn$        Wn&        Wn(        Wn*        S\V        J d   \X        Vn-        MV3R lVn-        \]        VP                  VP0                  4       FH  w  r\_        V	\`        4      '       g   K  V	Pb                  p\e        Wk4      '       d   K<  \g        WkV
4       KJ  	  V# )z7polynomial ring and it's ground domain share generatorsc                    R# Nr2   r2   )abs   &&r4   <lambda>"PolyRing.__new__.<locals>.<lambda>   s    2r6   c                    R# rq   r2   )rr   rs   rX   s   &&&r4   rt   ru      s    "r6   c                   < \        V SR 7      # )key)max)fr1   s   &r4   rt   ru      s    QE):r6   r2       )4tuplerk   len	DomainOpt
preprocessOrderOpt__name__is_Compositesetr   r"   object__new___hash_tuplehash_hashrn   r<   r1   PolyElementnewdtype
zero_monom_gensr:   	_gens_setone_oner   r   monomial_mulpowmonomial_powmulpowmonomial_mulpowldivmonomial_ldivdivmonomial_divlcmmonomial_lcmgcdmonomial_gcdr   rz   leading_expvrL   r_   r   rB   hasattrsetattr)clsr   r<   r1   rn   r   objcodegenmonunitsymbol	generatorrB   s   &&&f        r4   r   PolyRing.__new__   s   w/0G%%f-##E*||WVUC3w<#fnn2E#E#E!"[\\nnS!%%		
	R(,,	e99;CHH^^VZZ01!%(G&{{}C&{{}C").."2C 'C&{{}C&{{}C&{{}C%G&&"4C '&&& C<"C:C!$S[[#((!;F&&)){{s))Cy1 "< 
r6   c                    V P                   P                  p. p\        V P                  4       F5  pV P	                  V4      pV P
                  pWV&   VP                  V4       K7  	  \        V4      # )z(Return a list of polynomial generators. )r<   r   rangern   monomial_basiszeroappendr~   )selfr   r   iexpvpolys   &     r4   r   PolyRing._gens  s_    kkootzz"A&&q)D99DJLL	 #
 U|r6   c                	H    V P                   V P                  V P                  3# r^   )r   r<   r1   r   s   &r4   __getnewargs__PolyRing.__getnewargs__  s    dkk4::66r6   c                	    V P                   P                  4       pVR  V F  pVP                  R4      '       g   K  W K   	  V# )r   	monomial_)__dict__copy
startswith)r   statery   s   &  r4   __getstate__PolyRing.__getstate__  sA    ""$.!C~~k**J  r6   c                	    V P                   # r^   )r   r   s   &r4   __hash__PolyRing.__hash__#  s    zzr6   c                	    \        V\        4      ;'       d^    V P                  V P                  V P                  V P
                  3VP                  VP                  VP                  VP
                  38H  # r^   )r_   r9   r   r<   rn   r1   r   others   &&r4   __eq__PolyRing.__eq__&  s\    %* D D\\4;;

DJJ?]]ELL%++u{{CD	Dr6   c                	    W8X  * # r^   r2   r   s   &&r4   __ne__PolyRing.__ne__+  s      r6   Nc                	p    Ve"   \        V\        4      '       d   \        V4      pV P                  WV4      # r^   )r_   rG   r~   _cloner   r   r<   r1   s   &&&&r4   clonePolyRing.clone.  s.    :gt#<#<GnG{{7E22r6   c                	    T P                  T;'       g    V P                  T;'       g    V P                  T;'       g    V P                  4      # r^   )	__class__r   r<   r1   r   s   &&&&r4   r   PolyRing._clone4  s<    ~~g55v7L7LeNaNaW[WaWabbr6   c                H    ^ .V P                   ,          p^W!&   \        V4      # )zReturn the ith-basis element. )rn   r~   )r   r   basiss   && r4   r   PolyRing.monomial_basis8  s"    DJJU|r6   c                	$    V P                  . 4      # r^   )r   r   s   &r4   r   PolyRing.zero>  s    zz"~r6   c                	8    V P                  V P                  4      # r^   )r   r   r   s   &r4   r   PolyRing.oneB  s    zz$))$$r6   c                P    \        V\        4      ;'       d    VP                  V 8H  # )zATrue if ``element`` is an element of this ring. False otherwise. )r_   r   r>   r   elements   &&r4   
is_elementPolyRing.is_elementF  s     ';/HHGLLD4HHr6   c                	8    V P                   P                  W4      # r^   )r<   convertr   r   orig_domains   &&&r4   
domain_newPolyRing.domain_newJ  s    {{""788r6   c                	:    V P                  V P                  V4      # r^   )term_newr   )r   coeffs   &&r4   
ground_newPolyRing.ground_newM  s    }}T__e44r6   c                	X    V P                  V4      pV P                  pV'       d   W#V&   V# r^   )r   r   )r   monomr   r   s   &&& r4   r   PolyRing.term_newP  s(    &yyKr6   c                	   \        V\        4      '       dt   WP                  8X  d   V# \        V P                  \        4      '       d7   V P                  P                  VP                  8X  d   V P                  V4      # \        R 4      h\        V\        4      '       d   \        R4      h\        V\        4      '       d   V P                  V4      # \        V\        4      '       d    V P                  V4      # \        V\        4      '       d   V P                  V4      # V P                  V4      #   \         d    T P                  T4      u # i ; i)
conversionparsing)r_   r   r>   r<   r   r   NotImplementedErrorr`   rK   rN   rG   
from_terms
ValueError	from_listr   	from_exprr   s   &&r4   ring_newPolyRing.ring_newW  s   g{++||#DKK88T[[=M=MQXQ]Q]=]w//),77%%%i00&&>>'**&&/w// &&>>'**??7++  /~~g../s   )D2 2EEc                	    V P                   pV P                  pVP                  4        F  w  rVV! Wb4      pV'       g   K  WdV&   K  	  V# r^   )r   r   rM   )r   r   r   r   r   r   r   s   &&&    r4   rN   PolyRing.from_dicto  sC    __
yy#MMOLEu2Eu#U ,
 r6   c                	8    V P                  \        V4      V4      # r^   )rN   rK   r   s   &&&r4   r   PolyRing.from_termsz  s    ~~d7m[99r6   c                	n    V P                  \        WP                  ^,
          V P                  4      4      #    )rN   r   rn   r<   r   s   &&r4   r   PolyRing.from_list}  s$    ~~k'::a<MNNr6   c                	V   a aaa S P                   oVVVV 3R  loS! \        V4      4      # )c           	       < SP                  V 4      pVe   V# V P                  '       d.   \        \        \	        \        SV P                  4      4      4      # V P                  '       d.   \        \        \	        \        SV P                  4      4      4      # V P                  4       w  r#VP                  '       d    V^8  d   S! V4      \        V4      ,          # SP                  SP                  V 4      4      # r^   )getis_Addr	   r   rG   rH   argsis_Mulr   as_base_exp
is_Integerrm   r   r   )exprr   baseexp_rebuildr<   mappingr   s   &   r4   r
  (PolyRing._rebuild_expr.<locals>._rebuild  s    D)I$  c4Hdii(@#ABBc4Hdii(@#ABB !,,.	>>>cAg#D>3s833??6>>$+?@@r6   )r<   r   )r   r  r  r
  r<   s   f&f@@r4   _rebuild_exprPolyRing._rebuild_expr  s)    	A 	A$ &&r6   c                	    \        \        \        V P                  V P                  4      4      4      p V P                  W4      pV P                  V4      #   \         d    \        R T : RT: 24      hi ; i)z6expected an expression convertible to a polynomial in z, got )	rK   rG   rL   r   r:   r  r   r!   r   )r   r  r  r   s   &&  r4   r   PolyRing.from_expr  sk    tCdii89:	'%%d4D ==&&  	pcgimnoo	ps   A A5c                   Vf   V P                   '       d   ^ pV# Rp V# \        V\        4      '       dT   Tp^ V8:  d   W P                   8  d    V# V P                   ) V8:  d   VR8:  d   V) ^,
          pV# \        RV,          4      hV P	                  V4      '       d    V P
                  P                  V4      pV# \        V\        4      '       d    V P                  P                  V4      pV# \        RV,          4      h  \         d    \        RT,          4      hi ; i  \         d    \        RT,          4      hi ; i)z+Compute index of ``gen`` in ``self.gens``. zinvalid generator index: %szinvalid generator: %szEexpected a polynomial generator, an integer, a string or None, got %s)	rn   r_   rm   r   r   r:   indexr`   r   )r   genr   s   && r4   r  PolyRing.index  sK   ;zzz2 / . - S!!AAv!jj.$ # **!a2gBF   !!>!DEE__S!!@IIOOC(  S!!@LL&&s+  dgjjkk  @ !83!>??@
  @ !83!>??@s   !D D% D"%Ec                    \        \        V P                  V4      4      p\        V P                  4       UUu. uF  w  r4W29  g   K  VNK  	  pppV'       g   V P
                  # V P                  VR7      # u uppi )z,Remove specified generators from this ring. rj   )r   rH   r  	enumerater   r<   r   )r   r:   indicesr   rc   r   s   &*    r4   dropPolyRing.drop  sc    c$**d+,"+DLL"9O"9$!Q=MAA"9O;;::g:.. Ps   
A6A6c                	t    V P                   V,          pV'       g   V P                  # V P                  VR 7      # )rj   )r   r<   r   )r   ry   r   s   && r4   __getitem__PolyRing.__getitem__  s.    ,,s#;;::g:..r6   c                	    V P                   P                  '       g   \        V P                   R 4      '       d'   V P                  V P                   P                   R7      # \	        RV P                   ,          4      h)r<   r<   z%s is not a composite domain)r<   r   r   r   r   r   s   &r4   	to_groundPolyRing.to_ground  sR    ;;###wt{{H'E'E::T[[%7%7:88;dkkIJJr6   c                	    \        V 4      # r^   r   r   s   &r4   	to_domainPolyRing.to_domain  s    d##r6   c                	^    ^ RI Hp V! V P                  V P                  V P                  4      # )r}   )	FracField)sympy.polys.fieldsr&  r   r<   r1   )r   r&  s   & r4   to_fieldPolyRing.to_field  s     0t{{DJJ??r6   c                	2    \        V P                  4      ^8H  # r   r   r:   r   s   &r4   is_univariatePolyRing.is_univariate  s    499~""r6   c                	2    \        V P                  4      ^8  # r   r+  r   s   &r4   is_multivariatePolyRing.is_multivariate  s    499~!!r6   c                    V P                   pV F:  p\        V\        R7      '       d   W P                  ! V!  ,          pK2  W#,          pK<  	  V# )a  
Add a sequence of polynomials or containers of polynomials.

Examples
========

>>> from sympy.polys.rings import ring
>>> from sympy.polys.domains import ZZ

>>> R, x = ring("x", ZZ)
>>> R.add([ x**2 + 2*i + 3 for i in range(4) ])
4*x**2 + 24
>>> _.factor_list()
(4, [(x**2 + 6, 1)])

include)r   r-   r
   r   r   objspr   s   &*  r4   r   PolyRing.add  sB    " IIC366XXs^#	  r6   c                    V P                   pV F:  p\        V\        R7      '       d   W P                  ! V!  ,          pK2  W#,          pK<  	  V# )ap  
Multiply a sequence of polynomials or containers of polynomials.

Examples
========

>>> from sympy.polys.rings import ring
>>> from sympy.polys.domains import ZZ

>>> R, x = ring("x", ZZ)
>>> R.mul([ x**2 + 2*i + 3 for i in range(4) ])
x**8 + 24*x**6 + 206*x**4 + 744*x**2 + 945
>>> _.factor_list()
(1, [(x**2 + 3, 1), (x**2 + 5, 1), (x**2 + 7, 1), (x**2 + 9, 1)])

r2  )r   r-   r
   r   r4  s   &*  r4   r   PolyRing.mul  sB    " HHC366XXs^#	  r6   c                l   \        \        V P                  V4      4      p\        V P                  4       UUu. uF  w  r4W29  g   K  VNK  	  ppp\        V P
                  4       UUu. uF  w  r6W29  g   K  VNK  	  pppV'       g   V # V P                  WPP                  ! V!  R7      # u uppi u uppi )zL
Remove specified generators from the ring and inject them into
its domain.
r   r<   )r   rH   r  r  r   r:   r   r  )r   r:   r  r   rc   r   r  s   &*     r4   drop_to_groundPolyRing.drop_to_ground  s    
 c$**d+,!*4<<!8M!8A<L11!8M"+DII"6K"6!:J"6KK::gii6F:GG NKs   
B*B*(
B07B0c                    W8w  dS   \        V P                  4      P                  \        VP                  4      4      pV P                  \	        V4      R7      # V # )z+Add the generators of ``other`` to ``self``rj   r   r   unionr   rG   )r   r   symss   && r4   composePolyRing.compose,  sC    =t||$**3u}}+=>D::d4j:11Kr6   c                    \        V P                  4      P                  \        V4      4      pV P                  \	        V4      R7      # )z9Add the elements of ``symbols`` as generators to ``self``rj   r?  )r   r   rA  s   && r4   add_gensPolyRing.add_gens4  s4    4<< &&s7|4zz$t*z--r6   c                  a V^ 8  g   WP                   8  d   \        RV: RV P                  : 24      hV'       g   V P                  # V P                  p\        \        V P                   4      \        V4      4       F  o\        ;QJ d*    . V3R l\        V P                   4       4       F  NK  	  5M#! V3R l\        V P                   4       4       4      pW P                  W0P                  P                  4      ,          pK  	  V# )zW
Return the elementary symmetric polynomial of degree *n* over
this ring's generators.
z.Cannot generate symmetric polynomial of order z for c              3  @   <"   T F  p\        VS9   4      x  K  	  R # 5ir^   )rm   )rb   r   rc   s   & r4   rd   *PolyRing.symmetric_poly.<locals>.<genexpr>E  s     E3Dac!q&kk3Ds   )rn   r   r:   r   r   r,   r   rm   r~   r   r<   )r   nr   r   rc   s   &&  @r4   symmetric_polyPolyRing.symmetric_poly9  s    
 q5A

NZ[]a]f]fghh88O99DU4::.A7E53DEE53DEEe[[__== 8 Kr6   r2   )NNNr^   )/r   
__module____qualname____firstlineno____doc____annotations__r   r   r   r   r   r   r   r   r   r   r   r   propertyr   r   r   r   r   r   r   __call__rN   r   r   r  r   r  r  r  r   r#  r(  r,  r/  r   r   r<  rB  rE  rK  __static_attributes__r2   r6   r4   r9   r9      s3   4
!!JN,/ <|	7D
!3 c c   % %I95,, H	:O'.'>//K$@ # # " "66H.
r6   r9   c                    a  ] tR tRtRtV 3R ltR tR tR tR t	Rt
R	 tR
 tR tR tR tR tR tR tR tRR ltR tR tR tR tR tR tR tR tR tR tR tR t R t!]"R  4       t#]"R! 4       t$]"R" 4       t%]"R# 4       t&]"R$ 4       t']"R% 4       t(]"R& 4       t)]"R' 4       t*]"R( 4       t+]"R) 4       t,]"R* 4       t-]"R+ 4       t.]"R, 4       t/]"R- 4       t0]"R. 4       t1]"R/ 4       t2]"R0 4       t3R1 t4R2 t5R3 t6R4 t7R5 t8R6 t9R7 t:R8 t;R9 t<R: t=R; t>R< t?R= t@R> tAR? tBR@ tCRA tDRB tERC tFRD tGRE tHRF tIRG tJRH tKRI tLRJ tMRK tNRRL ltORM tPRRN ltQRO tRRP tSRQ tTRR tURS tV]"RT 4       tW]"RU 4       tXRV tY]"RW 4       tZRX t[RY t\RRZ lt]RR[ lt^RR\ lt_R] t`R^ taR_ tbR` tcRa tdRb teRc tfRd tgRe thRf tiRg tjRh tkRi tlRj tmRk tnRl to]otpRm tqRn trRo tsRp ttRq tuRr tvRs twRt txRu tyRv tzRw t{Rx t|Ry t}Rz t~R{ tR| tR} tR~ tRR ltRR ltR tRR ltR tRR ltRR ltRR ltRR ltRR ltR tR tR tR tR tR tR tR tR tR tR tR tRR ltR tRtV ;t# )r   iJ  z5Element of multivariate distributed polynomial ring. c                	2   < \         SV `  V4       Wn        R # r^   )super__init__r>   )r   r>   initr   s   &&&r4   rX  PolyElement.__init__M  s    	r6   c                	   \        V \        4      '       g   Q h\        V P                  \        4      '       g   Q hV P                  P                  p\        V\
        4      '       g   Q hV P                  4        F  w  r#VP                  V4      '       g   Q h\        V4      V P                  P                  8X  g   Q h\        ;QJ d    R  V 4       F  '       d   K   RM	  RM! R  V 4       4      '       d   K  Q h	  R# )c              3  \   "   T F"  p\        V\        4      ;'       d    V^ 8  x  K$  	  R# 5i)r}   N)r_   rm   )rb   r	  s   & r4   rd   %PolyElement._check.<locals>.<genexpr>[  s&     JESz#s+88q8Es   ,,FTN)r_   r   r>   r9   r<   r   rM   of_typer   rn   ri   )r   domr   r   s   &   r4   _checkPolyElement._checkS  s    $,,,,$))X....ii#v&&&& JJLLE;;u%%%%u:0003JEJ333JEJJJJJ )r6   c                	:    V P                  V P                  V4      # r^   )r   r>   )r   rY  s   &&r4   r   PolyElement.new]  s    ~~dii..r6   c                	6    V P                   P                  4       # r^   )r>   r#  r   s   &r4   parentPolyElement.parent`  s    yy""$$r6   c                	L    V P                   \        V P                  4       4      3# r^   )r>   rG   	itertermsr   s   &r4   r   PolyElement.__getnewargs__c  s    		4 0122r6   Nc                	    V P                   pVf6   \        V P                  \        V P	                  4       4      34      ;V n         pV# r^   )r   r   r>   	frozensetrM   )r   r   s   & r4   r   PolyElement.__hash__h  s<     

=!%tyy)DJJL2I&J!KKDJr6   c                $    V P                  V 4      # )a  Return a copy of polynomial self.

Polynomials are mutable; if one is interested in preserving
a polynomial, and one plans to use inplace operations, one
can copy the polynomial. This method makes a shallow copy.

Examples
========

>>> from sympy.polys.domains import ZZ
>>> from sympy.polys.rings import ring

>>> R, x, y = ring('x, y', ZZ)
>>> p = (x + y)**2
>>> p1 = p.copy()
>>> p2 = p
>>> p[R.zero_monom] = 3
>>> p
x**2 + 2*x*y + y**2 + 3
>>> p1
x**2 + 2*x*y + y**2
>>> p2
x**2 + 2*x*y + y**2 + 3

)r   r   s   &r4   r   PolyElement.copys  s    4 xx~r6   c           	     	z   V P                   V8X  d   V # V P                   P                  VP                  8w  d`   \        \        \	        W P                   P                  VP                  4      !  4      pVP                  W P                   P                  4      # VP                  W P                   P                  4      # r^   )r>   r   rG   rL   r(   r   r<   rN   )r   new_ringtermss   && r4   set_ringPolyElement.set_ring  s    99 KYY("2"22mD))2C2CXEUEUVWXE&&uii.>.>??%%dII,<,<==r6   c                	   V'       g   V P                   P                  pMT\        V4      V P                   P                  8w  d1   \	        R V P                   P                  : R\        V4      : 24      h\        V P                  4       .VO5!  # )z"Wrong number of symbols, expected z got )r>   r   r   rn   r   r'   as_expr_dict)r   r   s   &*r4   as_exprPolyElement.as_expr  sf    ii''G\TYY__,#g,0 
 d//1<G<<r6   c                	    V P                   P                  P                  pV P                  4        UUu/ uF  w  r#W!! V4      bK  	  upp# u uppi r^   )r>   r<   to_sympyrh  )r   ry  r   r   s   &   r4   ru  PolyElement.as_expr_dict  sC    99##,,;?>>;KL;K<5x&;KLLLs   Ac           	     	   V P                   P                  pVP                  '       d   VP                  '       g   VP                  V 3# VP                  4       pVP                  pVP                  pVP                  pV P                  4        F  pV! W5! V4      4      pK  	  T P                  V P                  4        UUu. uF  w  rxWxV,          3NK  	  upp4      p	W93# u uppi r^   )r>   r<   is_Fieldhas_assoc_Ringr   get_ringr   denomrJ   r   rM   )
r   r<   ground_ringcommonr   r  r   kvr   s
   &         r4   clear_denomsPolyElement.clear_denoms  s    !!f&;&;&;::t##oo'oo[[]Eu.F # xxDJJLBLDA1h-LBC| Cs    C 
c                b    \        V P                  4       4       F  w  rV'       d   K  W K  	  R# )z+Eliminate monomials with zero coefficient. NrG   rM   )r   r  r  s   &  r4   
strip_zeroPolyElement.strip_zero  s#    &DA1G 'r6   c                    V'       g   V '       * # V P                   P                  V4      '       d   \        P                  W4      # \	        V 4      ^8  d   R# V P                  V P                   P                  4      V8H  # )zEquality test for polynomials.

Examples
========

>>> from sympy.polys.domains import ZZ
>>> from sympy.polys.rings import ring

>>> _, x, y = ring('x, y', ZZ)
>>> p1 = (x + y)**2 + (x - y)**2
>>> p1 == 4*x*y
False
>>> p1 == 2*(x**2 + y**2)
True

F)r>   r   rK   r   r   r  r   p1p2s   &&r4   r   PolyElement.__eq__  s^    " 6MWW##;;r&&Wq[66"'',,-33r6   c                	    W8X  * # r^   r2   r  s   &&r4   r   PolyElement.__ne__  s
    |r6   c                &   V P                   pVP                  V4      '       d   \        V P                  4       4      \        VP                  4       4      8w  d   R# VP                  P
                  pV P                  4        F"  pV! W,          W,          V4      '       d   K!   R# 	  R# \        V 4      ^8  d   R#  VP                  P                  V4      pVP                  P                  V P                  4       W4      #   \         d     R# i ; i)z+Approximate equality test for polynomials. FT)
r>   r   r   keysr<   almosteqr   r   constr!   )r  r  	tolerancer>   r  r  s   &&&   r4   r  PolyElement.almosteq  s    ww??22779~RWWY/{{++HWWYrui88   Wq[G[[((, {{++BHHJFF " s   <D DDc                	8    \        V 4      V P                  4       3# r^   )r   rq  r   s   &r4   sort_keyPolyElement.sort_key  s    D	4::<((r6   c                	    V P                   P                  V4      '       d&   V! V P                  4       VP                  4       4      # \        # r^   )r>   r   r  NotImplemented)r  r  ops   &&&r4   _cmpPolyElement._cmp  s6    77b!!bkkmR[[]33!!r6   c                	.    V P                  V\        4      # r^   )r  r   r  s   &&r4   __lt__PolyElement.__lt__      wwr2r6   c                	.    V P                  V\        4      # r^   )r  r   r  s   &&r4   __le__PolyElement.__le__  r  r6   c                	.    V P                  V\        4      # r^   )r  r   r  s   &&r4   __gt__PolyElement.__gt__   r  r6   c                	.    V P                  V\        4      # r^   )r  r   r  s   &&r4   __ge__PolyElement.__ge__  r  r6   c                	    V P                   pVP                  V4      pVP                  ^8X  d   W2P                  3# \	        VP
                  4      pWC W2P                  VR7      3# )r   rj   )r>   r  rn   r<   rG   r   r   r   r  r>   r   r   s   &&   r4   _dropPolyElement._drop  sV    yyJJsO::?kk>!4<<(G
jjj111r6   c                	   V P                  V4      w  r#V P                  P                  ^8X  d6   V P                  '       d   V P	                  ^4      # \        RV,          4      hVP                  pV P                  4        F>  w  rVWR,          ^ 8X  d   \        V4      pWr Wd\        V4      &   K.  \        RV,          4      h	  V# )r   zCannot drop %s)
r  r>   rn   	is_groundr   r   r   rM   rG   r~   )r   r  r   r>   r   r  r  Ks   &&      r4   r  PolyElement.drop  s    **S/99??a~~~zz!}$ !1C!78899D

419QA%&qN$%5%;<< % Kr6   c                	    V P                   pVP                  V4      p\        VP                  4      pWC W2P	                  WBV,          R 7      3# )r;  )r>   r  rG   r   r   r  s   &&   r4   _drop_to_groundPolyElement._drop_to_ground%  sC    yyJJsOt||$J**W!W*===r6   c                	   V P                   P                  ^8X  d   \        R4      hV P                  V4      w  r#VP                  pVP
                  P                  ^ ,          pV P                  4        Fr  w  rVVRV WR^,           R ,           pWt9  d#   WV,          ,          P                  V4      WG&   KB  WG;;,          WV,          ,          P                  V4      ,          uu&   Kt  	  V# )r   z$Cannot drop only generator to groundN)	r>   rn   r   r  r   r<   r:   rh  
mul_ground)r   r  r   r>   r   r   r   mons   &&      r4   r<  PolyElement.drop_to_ground-  s    99??aCDD&&s+yykkq! NN,LE)eaCDk)C (]66u=		c8m77>>	 - r6   c                	x    \        W P                  P                  ^,
          V P                  P                  4      # r   )r   r>   rn   r<   r   s   &r4   to_densePolyElement.to_dense>  s&    T99??1#4dii6F6FGGr6   c                	    \        V 4      # r^   )rK   r   s   &r4   to_dictPolyElement.to_dictA  s    Dzr6   c                	   V '       g0   VP                  V P                  P                  P                  4      # VR ,          pVR,          pV P                  pVP                  pVP
                  p	VP                  p
. pV P                  4        EF  w  rVP                  P                  V4      pV'       d   RMRpVP                  V4       W8X  d;   VP                  V4      pV'       d!   VP                  R4      '       d
   VR,          pMEV'       d   V) pWP                  P                  P                  8w  d   VP                  WRR7      pMRp. p\        V	4       F  pVV,          pV'       g   K  VP                  VV,          VRR7      pV^8w  dK   V\        V4      8w  g   V^ 8  d   VP                  VVR	R7      pMTpVP                  VVV3,          4       K  VP                  R
V,          4       K  	  V'       d   V.V,           pVP                  VP                  V4      4       EK  	  V^ ,          R9   d+   VP!                  ^ 4      pVR8X  d   VP#                  ^ R4       RP                  V4      # )MulAtom -  + -r   NNT)strict Fz%s)r  r  )_printr>   r<   r   r   rn   r   rq  is_negativer   r   r   parenthesizer   rm   joinpopinsert)r   printer
precedenceexp_pattern
mul_symbolprec_mul	prec_atomr>   r   rn   zmsexpvsr   r   negativesignscoeffsexpvr   r	  r   sexpheads   &&&&&                  r4   r`   PolyElement.strD  s   >>$))"2"2"7"788e$v&	yy,,

__::<KD{{..u5H$5%DMM$z . 1 1# 6 6#BZF"FEII,,000$11%$1OFFE5\1g --gaj)D-Q!8c#h#'&33C53Q"LL~!=>LL/ " 5(MM*//%01? (@ !9&::a=Du}a%wwvr6   c                	2    W P                   P                  9   # r^   )r>   r   r   s   &r4   is_generatorPolyElement.is_generatort  s    yy****r6   c                	~    V '       * ;'       g0    \        V 4      ^8H  ;'       d    V P                  P                  V 9   # r   )r   r>   r   r   s   &r4   r  PolyElement.is_groundx  s1    xLLCINKKtyy/C/Ct/KLr6   c                	j    V '       * ;'       g&    \        V 4      ^8H  ;'       d    V P                  ^8H  # r   )r   LCr   s   &r4   is_monomialPolyElement.is_monomial|  s*    x<<CIN;;tww!|<r6   c                	    \        V 4      ^8*  # r   )r   r   s   &r4   is_termPolyElement.is_term  s    4yA~r6   c                	`    V P                   P                  P                  V P                  4      # r^   )r>   r<   r  r  r   s   &r4   r  PolyElement.is_negative  !    yy++DGG44r6   c                	`    V P                   P                  P                  V P                  4      # r^   )r>   r<   is_positiver  r   s   &r4   r  PolyElement.is_positive  r  r6   c                	`    V P                   P                  P                  V P                  4      # r^   )r>   r<   is_nonnegativer  r   s   &r4   r  PolyElement.is_nonnegative  !    yy..tww77r6   c                	`    V P                   P                  P                  V P                  4      # r^   )r>   r<   is_nonpositiver  r   s   &r4   r  PolyElement.is_nonpositive  r  r6   c                	    V '       * # r^   r2   r{   s   &r4   is_zeroPolyElement.is_zero  s	    ur6   c                	2    W P                   P                  8H  # r^   )r>   r   r  s   &r4   is_onePolyElement.is_one  s    FFJJr6   c                	`    V P                   P                  P                  V P                  4      # r^   )r>   r<   r  r  r  s   &r4   is_monicPolyElement.is_monic  s    vv}}##ADD))r6   c                	h    V P                   P                  P                  V P                  4       4      # r^   )r>   r<   r  contentr  s   &r4   is_primitivePolyElement.is_primitive  s!    vv}}##AIIK00r6   c                	    \         ;QJ d*    R  V P                  4        4       F  '       d   K   R# 	  R# ! R  V P                  4        4       4      # )c              3  >   "   T F  p\        V4      ^8*  x  K  	  R# 5ir   NrI   rb   r   s   & r4   rd   (PolyElement.is_linear.<locals>.<genexpr>       ?u3u:?   FTri   
itermonomsr  s   &r4   	is_linearPolyElement.is_linear  7    s??ss?s?s????r6   c                	    \         ;QJ d*    R  V P                  4        4       F  '       d   K   R# 	  R# ! R  V P                  4        4       4      # )c              3  >   "   T F  p\        V4      ^8*  x  K  	  R# 5i)r0   Nr	  r
  s   & r4   rd   +PolyElement.is_quadratic.<locals>.<genexpr>  r  r  FTr  r  s   &r4   is_quadraticPolyElement.is_quadratic  r  r6   c                	t    V P                   P                  '       g   R # V P                   P                  V 4      # T)r>   rn   	dmp_sqf_pr  s   &r4   is_squarefreePolyElement.is_squarefree  s'    vv|||vv""r6   c                	t    V P                   P                  '       g   R # V P                   P                  V 4      # r  )r>   rn   dmp_irreducible_pr  s   &r4   is_irreduciblePolyElement.is_irreducible  s'    vv|||vv''**r6   c                	    V P                   P                  '       d   V P                   P                  V 4      # \        R 4      h)zcyclotomic polynomial)r>   r,  dup_cyclotomic_pr$   r  s   &r4   is_cyclotomicPolyElement.is_cyclotomic  s3    6666**1---.EFFr6   c                	x    T P                  V P                  4        UUu. uF	  w  rW) 3NK  	  upp4      # u uppi r^   )r   rh  )r   r   r   s   &  r4   __neg__PolyElement.__neg__  s2    xxdnn>NP>Nle5&/>NPQQPs   6
c                	    V # r^   r2   r   s   &r4   __pos__PolyElement.__pos__  s    r6   c                   V'       g   V P                  4       # V P                  pVP                  V4      '       dm   V P                  4       pVP                  pVP                  P
                  pVP                  4        F$  w  rgV! We4      V,           pV'       d   WsV&   K"  W6 K&  	  V# \        V\        4      '       d   \        VP                  \        4      '       d'   VP                  P                  VP                  8X  d   Mf\        VP                  P                  \        4      '       d7   VP                  P                  P                  V8X  d   VP                  V 4      # \        #  VP                  V4      pV P                  4       pV'       g   V# VP                  p	WP                  4       9  d   WV	&   V# WV	,          ) 8X  d   W9 V# W9;;,          V,          uu&   V#   \         d
    \        u # i ; i)zAdd two polynomials.

Examples
========

>>> from sympy.polys.domains import ZZ
>>> from sympy.polys.rings import ring

>>> _, x, y = ring('x, y', ZZ)
>>> (x + y)**2 + (x - y)**2
2*x**2 + 2*y**2

)r   r>   r   r  r<   r   rM   r_   r   r   __radd__r  r   r   r  r!   )
r  r  r>   r6  r  r   r  r  cp2r  s
   &&        r4   __add__PolyElement.__add__  s    779ww??2	A%%C;;##D
L1$aD # HK(($++~664;;;K;Krww;VBGGNNN;;@S@SW[@[{{2&%%	//"%C 	AB"" H	 B%< H ESLEH  	"!!	"s   +G$ $G87G8c                	<   V P                  4       pV'       g   V# V P                  p VP                  V4      pVP                  pW@P	                  4       9  d   WV&   V# WV,          ) 8X  d   W$ V# W$;;,          V,          uu&   V#   \
         d
    \        u # i ; ir^   )r   r>   r   r   r  r!   r  )r  rJ  r6  r>   r  s   &&   r4   r,  PolyElement.__radd__  s    GGIHww	"A B"" H	 2; H EQJEH  	"!!	"s   B BBc                   V'       g   V P                  4       # V P                  pVP                  V4      '       dm   V P                  4       pVP                  pVP                  P
                  pVP                  4        F$  w  rgV! We4      V,
          pV'       d   WsV&   K"  W6 K&  	  V# \        V\        4      '       d   \        VP                  \        4      '       d'   VP                  P                  VP                  8X  d   Mf\        VP                  P                  \        4      '       d7   VP                  P                  P                  V8X  d   VP                  V 4      # \        #  VP                  V4      pV P                  4       pVP                  pWP                  4       9  d   V) W8&   V# WV,          8X  d   W8 V# W8;;,          V,          uu&   V#   \         d
    \        u # i ; i)zSubtract polynomial p2 from p1.

Examples
========

>>> from sympy.polys.domains import ZZ
>>> from sympy.polys.rings import ring

>>> _, x, y = ring('x, y', ZZ)
>>> p1 = x + y**2
>>> p2 = x*y + y**2
>>> p1 - p2
-x*y + x

)r   r>   r   r  r<   r   rM   r_   r   r   __rsub__r  r   r   r  r!   )	r  r  r>   r6  r  r   r  r  r  s	   &&       r4   __sub__PolyElement.__sub__  s~     779ww??2	A%%C;;##D
L1$aD # HK(($++~664;;;K;Krww;VBGGNNN;;@S@SW[@[{{2&%%	$B 	AB" H	 2; H ERKEH  	"!!	"s   +G G.-G.c                    V P                   p VP                  V4      pVP                  pV  F  pW,          ) W4&   K  	  W1,          pV#   \         d
    \        u # i ; i)zn - p1 with n convertible to the coefficient domain.

Examples
========

>>> from sympy.polys.domains import ZZ
>>> from sympy.polys.rings import ring

>>> _, x, y = ring('x, y', ZZ)
>>> p = x + y
>>> 4 - p
-x - y + 4

)r>   r   r   r!   r  )r  rJ  r>   r6  r   s   &&   r4   r3  PolyElement.__rsub__E  sc     ww
	"A 		A8) FAH  	"!!	"s   A	 	AAc                   V P                   pVP                  pV '       d	   V'       g   V# VP                  V4      '       d   VP                  pVP                  P                  pVP
                  p\        VP                  4       4      pV P                  4        F/  w  rV F$  w  rV! W4      pV! W4      W,          ,           W<&   K&  	  K1  	  VP                  4        V# \        V\        4      '       d   \        VP                  \        4      '       d'   VP                  P                   VP                   8X  d   Mf\        VP                   P                  \        4      '       d7   VP                   P                  P                   V8X  d   VP                  V 4      # \        #  VP                  V4      pV P                  4        F  w  rW,          pV'       g   K  WV&   K  	  V#   \         d
    \        u # i ; i)zMultiply two polynomials.

Examples
========

>>> from sympy.polys.domains import QQ
>>> from sympy.polys.rings import ring

>>> _, x, y = ring('x, y', QQ)
>>> p1 = x + y
>>> p2 = x - y
>>> p1*p2
x**2 - y**2

)r>   r   r   r  r<   r   rG   rM   r  r_   r   r   __rmul__r  r   r!   )r  r  r>   r6  r  r   r   p2itexp1v1exp2v2r	  r  s   &&            r4   __mul__PolyElement.__mul__a  sy     wwIIH__R  %%C;;##D,,L
#DHHJ $HD&t2C ^be3AF !% ' LLNHK(($++~664;;;K;Krww;VBGGNNN;;@S@SW[@[{{2&%%
	$B HHJE1dG '
 H  	"!!	"s   !G# #G76G7c                
   V P                   P                  pV'       g   V#  VP                   P                  V4      pV P                  4        F  w  r4W,          pV'       g   K  WRV&   K  	  V#   \         d
    \
        u # i ; i)zp2 * p1 with p2 in the coefficient domain of p1.

Examples
========

>>> from sympy.polys.domains import ZZ
>>> from sympy.polys.rings import ring

>>> _, x, y = ring('x, y', ZZ)
>>> p = x + y
>>> 4 * p
4*x + 4*y

)r>   r   r   rM   r!   r  )r  r  r6  r;  r<  r  s   &&    r4   r9  PolyElement.__rmul__  sw     GGLLH		""2&B HHJE1dG ' H  	"!!	"s   A. .BBc                .   \        V\        4      '       g   \        RV,          4      hV^ 8  d   \        RV,          4      hV P                  pV'       g    V '       d   VP
                  # \        R4      h\        V 4      ^8X  dy   \        V P                  4       4      ^ ,          w  r4VP                  pWBP                  P
                  8X  d   WEVP                  W14      &   V# WA,          WRP                  W14      &   V# \        V4      pV^ 8  d   \        R4      hV^8X  d   V P                  4       # V^8X  d   V P                  4       # V^8X  d   W P                  4       ,          # \        V 4      ^8:  d   V P                  V4      # V P                  V4      # )zraise polynomial to power `n`

Examples
========

>>> from sympy.polys.domains import ZZ
>>> from sympy.polys.rings import ring

>>> _, x, y = ring('x, y', ZZ)
>>> p = x + y**2
>>> p**3
x**3 + 3*x**2*y**2 + 3*x*y**4 + y**6

z#exponent must be an integer, got %sz/exponent must be a non-negative integer, got %sz0**0zNegative exponent)r_   rm   	TypeErrorr   r>   r   r   rG   rM   r   r<   r   r   square_pow_multinomial_pow_generic)r   rJ  r>   r   r   r6  s   &&    r4   __pow__PolyElement.__pow__  sT    !S!!AAEFFUNQRRSSyyxx ((Y!^

-a0LE		A'16$##E-. H 27##E-.H Fq5011!V99;!V;;= !V%%Y!^((++$$Q''r6   c                	    V P                   P                  pT p V^,          '       d   W#,          pV^,          pV'       g    V# VP                  4       pV^,          pKG  r  )r>   r   rE  )r   rJ  r6  rX   s   &&  r4   rG  PolyElement._pow_generic  sS    IIMM1uuCQ
  
AQAr6   c                	:   \        \        V 4      V4      P                  4       pV P                  P                  pV P                  P
                  pV P                  4       pV P                  P                  P                  pV P                  P                  pV F  w  rTp
T	p\        W4       F*  w  pw  rV'       g   K  V! WV4      p
WV,          ,          pK,  	  \        V
4      pTpVP                  W4      V,           pV'       d   WV&   Ku  W9   g   K}  W} K  	  V# r^   )r   r   rM   r>   r   r   r<   r   rL   r~   r  )r   rJ  multinomialsr   r   rq  r   r   multinomialmultinomial_coeffproduct_monomproduct_coeffr	  r   r   s   &&             r4   rF  PolyElement._pow_multinomial  s    /D	1=CCE))33YY))


yy$$yy~~.:*K&M-M'*;'>#^e3$3M#$NM!CZ/M (?
 -(E!EHHU)E1E#UK# /;& r6   c                f   V P                   pVP                  pVP                  p\        V P	                  4       4      pVP
                  P                  pVP                  p\        \        V4      4       FS  pWG,          pW,          p	\        V4       F1  p
WJ,          pV! W4      pV! W4      WV,          ,          ,           W,&   K3  	  KU  	  VP                  ^4      pVP                  pV P                  4        F%  w  rV! W4      pV! W4      V^,          ,           W+&   K'  	  VP                  4        V# )zsquare of a polynomial

Examples
========

>>> from sympy.polys.rings import ring
>>> from sympy.polys.domains import ZZ

>>> _, x, y = ring('x, y', ZZ)
>>> p = x + y**2
>>> p.square()
x**2 + 2*x*y**2 + y**4

)r>   r   r  rG   r  r<   r   r   r   imul_numrM   r  )r   r>   r6  r  r  r   r   r   k1pkjk2r	  r  r  s   &              r4   rE  PolyElement.square  s     yyIIeeDIIK {{((s4y!ABB1XW"2*S""X+5  " JJqMeeJJLDAa#BMAqD(AE ! 	
r6   c                	   V P                   pV'       g   \        R 4      hVP                  V4      '       d   V P                  V4      # \	        V\
        4      '       d   \	        VP                  \        4      '       d'   VP                  P                   VP                   8X  d   Mf\	        VP                   P                  \        4      '       d7   VP                   P                  P                   V8X  d   VP                  V 4      # \        #  VP                  V4      pV P                  V4      V P                  V4      3#   \         d
    \        u # i ; ipolynomial division)r>   ZeroDivisionErrorr   r   r_   r   r<   r   __rdivmod__r  r   
quo_ground
rem_groundr!   r  r  r>   s   && r4   
__divmod__PolyElement.__divmod__:  s    ww#$9::__R  66":K(($++~664;;;K;Krww;VBGGNNN;;@S@SW[@[~~b))%%	:$B MM"%r}}R'899  	"!!	"s   D> >EEc                	    V P                   p VP                  V4      pVP                  V 4      #   \         d
    \        u # i ; ir^   )r>   r   r   r!   r  ra  s   && r4   r^  PolyElement.__rdivmod__P  E    ww	$B 66":  	"!!	"   0 AAc                	   V P                   pV'       g   \        R 4      hVP                  V4      '       d   V P                  V4      # \	        V\
        4      '       d   \	        VP                  \        4      '       d'   VP                  P                   VP                   8X  d   Mf\	        VP                   P                  \        4      '       d7   VP                   P                  P                   V8X  d   VP                  V 4      # \        #  VP                  V4      pV P                  V4      #   \         d
    \        u # i ; ir[  )r>   r]  r   remr_   r   r<   r   __rmod__r  r   r`  r!   ra  s   && r4   __mod__PolyElement.__mod__Y  s    ww#$9::__R  66":K(($++~664;;;K;Krww;VBGGNNN;;@S@SW[@[{{2&%%	%$B ==$$  	"!!	"   D- -E Ec                	    V P                   p VP                  V4      pVP                  V 4      #   \         d
    \        u # i ; ir^   )r>   r   ri  r!   r  ra  s   && r4   rj  PolyElement.__rmod__o  rf  rg  c                	   V P                   pV'       g   \        R 4      hVP                  V4      '       d   V P                  V4      # \	        V\
        4      '       d   \	        VP                  \        4      '       d'   VP                  P                   VP                   8X  d   Mf\	        VP                   P                  \        4      '       d7   VP                   P                  P                   V8X  d   VP                  V 4      # \        #  VP                  V4      pV P                  V4      #   \         d
    \        u # i ; ir[  )r>   r]  r   quor_   r   r<   r   __rtruediv__r  r   r_  r!   ra  s   && r4   __floordiv__PolyElement.__floordiv__x  s    ww#$9::__R  66":K(($++~664;;;K;Krww;VBGGNNN;;@S@SW[@[r**%%	%$B ==$$  	"!!	"rm  c                	    V P                   p VP                  V4      pVP                  V 4      #   \         d
    \        u # i ; ir^   )r>   r   rq  r!   r  ra  s   && r4   __rfloordiv__PolyElement.__rfloordiv__  rf  rg  c                	   V P                   pV'       g   \        R 4      hVP                  V4      '       d   V P                  V4      # \	        V\
        4      '       d   \	        VP                  \        4      '       d'   VP                  P                   VP                   8X  d   Mf\	        VP                   P                  \        4      '       d7   VP                   P                  P                   V8X  d   VP                  V 4      # \        #  VP                  V4      pV P                  V4      #   \         d
    \        u # i ; ir[  )r>   r]  r   exquor_   r   r<   r   rr  r  r   r_  r!   ra  s   && r4   __truediv__PolyElement.__truediv__  s    ww#$9::__R  88B<K(($++~664;;;K;Krww;VBGGNNN;;@S@SW[@[r**%%	%$B ==$$  	"!!	"rm  c                	    V P                   p VP                  V4      pVP                  V 4      #   \         d
    \        u # i ; ir^   )r>   r   ry  r!   r  ra  s   && r4   rr  PolyElement.__rtruediv__  sE    ww	 $B 88B<  	"!!	"rg  c                	   aaa V P                   P                  oV P                   P                  pVP                  oV P                   P                  oVP
                  '       d   VVV3R  lpV# VVV3R lpV# )c                X   < V w  r#Vw  rEVS	8X  d   TpMS! W$4      pVe   VS! W54      3# R # r^   r2   
	a_lm_a_lc	b_lm_b_lca_lma_lcb_lmb_lcr   
domain_quor   r  s
   &&     r4   term_div'PolyElement._term_div.<locals>.term_div  s@    &
&
2: E(4E$ *T"888r6   c                t   < V w  r#Vw  rEVS	8X  d   TpMS! W$4      pVe   W5,          '       g   VS! W54      3# R # r^   r2   r  s
   &&     r4   r  r    sE    &
&
2: E(4E *T"888r6   )r>   r   r<   rq  r   r|  )r   r<   r  r  r   r  s   &  @@@r4   	_term_divPolyElement._term_div  sZ    YY!!!!ZZ
yy--???
 0 
  r6   c                   V P                   pRp\        V\        4      '       d   RpV.p\        V4      '       g   \	        R4      hV '       g/   V'       d   VP
                  VP
                  3# . VP
                  3# V F  pVP                   V8w  g   K  \        R4      h	  \        V4      p\        V4       Uu. uF  qbP
                  NK  	  ppV P                  4       pVP
                  p	V P                  4       p
V Uu. uF  qP                  4       NK  	  ppV'       d   ^ p^ pWe8  d   V^ 8X  d   VP                  4       pV
! WV,          3W,          W,          W,          ,          34      pVe@   Vw  ppWv,          P                  VV34      Wv&   VP                  W,          VV) 34      p^pK  V^,          pK  V'       d   K  VP                  4       pV	P                  WV,          34      p	W K  XVP                  8X  d	   W,          p	V'       d"   V'       g   VP
                  V	3# V^ ,          V	3# Wy3# u upi u upi )a  Division algorithm, see [CLO] p64.

fv array of polynomials
   return qv, r such that
   self = sum(fv[i]*qv[i]) + r

All polynomials are required not to be Laurent polynomials.

Examples
========

>>> from sympy.polys.rings import ring
>>> from sympy.polys.domains import ZZ

>>> _, x, y = ring('x, y', ZZ)
>>> f = x**3
>>> f0 = x - y**2
>>> f1 = x - y
>>> qv, r = f.div((f0, f1))
>>> qv[0]
x**2 + x*y**2 + y**4
>>> qv[1]
0
>>> r
y**6

FTr\  z"self and f must have the same ring)r>   r_   r   ri   r]  r   r   r   r   r   r  r   _iadd_monom_iadd_poly_monomr   )r   fvr>   
ret_singler{   rc   r   qvr6  rr  fxexpvsdivoccurredr   termexpv1rX   s   &&                r4   r   PolyElement.div  s   8 yy
b+&&JB2ww#$9::yy$))++499}$Avv~ !EFF  G!&q*Aii*IIKII>>#-/0Rr"R0AK%K1,~~'w%(BE%(O1LM##HE1E--uaj9BE**2551"+>A"#KFA;(MM44/2G4??"FAyy!|#!uax5L= + 1s   9H8?H=c                	&   T p\        V\        4      '       d   V.p\        V4      '       g   \        R 4      hVP                  pVP
                  pVP                  pVP                  pVP                  pVP                  4       pVP                  p	VP                  4       pVP                  p
V'       d   V F  pV! WP                  4      pVf   K  Vw  rVP                  4        F7  w  ppV! W4      pV
! VV4      VV,          ,
          pV'       g   VV K2  VVV&   K9  	  VP                  4       pVe   VVV,          3p	 K  	  V	w  ppVV9   d   VV;;,          V,          uu&   MVVV&   VV VP                  4       pVf   K  VVV,          3p	K  V# r[  )r_   r   ri   r]  r>   r<   r   r   r  LTr   r  rh  r   )r   Gr{   r>   r<   r   r   r  r  ltfr  gtqrW   rX   mgcgm1c1ltmltcs   &&                   r4   ri  PolyElement.rem#  sh   a%%A1vv#$9::vv{{((II;;=ddFFHeec44(>DA"#++-B)"0 T]QrT1! !"$&AbE #0 ..*C!1S6k " S!8cFcMF AcFcFnn&?qv+Cr6   c                	2    V P                  V4      ^ ,          # r|   )r   )r{   r  s   &&r4   rq  PolyElement.quoP  s    uuQx{r6   c                	R    V P                  V4      w  r#V'       g   V# \        W4      hr^   )r   r#   )r{   r  qr  s   &&  r4   ry  PolyElement.exquoS  s$    uuQxH%a++r6   c                    W P                   P                  9   d   V P                  4       pMT pVw  r4VP                  V4      pVf   WBV&   V# WT,          pV'       d   WRV&   V# W# V# )a  add to self the monomial coeff*x0**i0*x1**i1*...
unless self is a generator -- then just return the sum of the two.

mc is a tuple, (monom, coeff), where monomial is (i0, i1, ...)

Examples
========

>>> from sympy.polys.rings import ring
>>> from sympy.polys.domains import ZZ

>>> _, x, y = ring('x, y', ZZ)
>>> p = x**4 + 2*y
>>> m = (1, 2)
>>> p1 = p._iadd_monom((m, 5))
>>> p1
x**4 + 5*x*y**2 + 2*y
>>> p1 is p
True
>>> p = x
>>> p1 = p._iadd_monom((m, 5))
>>> p1
5*x*y**2 + x
>>> p1 is p
False

)r>   r   r   r  )r   mccpselfr   r   rX   s   &&    r4   r  PolyElement._iadd_monom[  sr    8 99&&&YY[FFJJt9 4L  JA t  Lr6   c                v   T pW3P                   P                  9   d   VP                  4       pVw  rEVP                  pVP                   P                  P
                  pVP                   P                  pVP                  4        F2  w  rV! W4      pV! W4      W,          ,           pV'       d   WV&   K0  W; K4  	  V# )a  add to self the product of (p)*(coeff*x0**i0*x1**i1*...)
unless self is a generator -- then just return the sum of the two.

mc is a tuple, (monom, coeff), where monomial is (i0, i1, ...)

Examples
========

>>> from sympy.polys.rings import ring
>>> from sympy.polys.domains import ZZ

>>> _, x, y, z = ring('x, y, z', ZZ)
>>> p1 = x**4 + 2*y
>>> p2 = y + z
>>> m = (1, 2, 3)
>>> p1 = p1._iadd_poly_monom(p2, (m, 3))
>>> p1
x**4 + 3*x*y**3*z**3 + 3*x*y**2*z**4 + 2*y

)r>   r   r   r  r<   r   r   rM   )r   r  r  r  rW   rX   r  r   r   r  r  kar   s   &&&          r4   r  PolyElement._iadd_poly_monom  s    * """Bffww~~""ww++HHJDAa#BMAC'E2F  	r6   c                   a V P                   P                  V4      oV '       g   \        # S^ 8  d   ^ # \        V3R lV P	                  4        4       4      # )zx
The leading degree in ``x`` or the main variable.

Note that the degree of 0 is negative infinity (``float('-inf')``)

c              3  4   <"   T F  qS,          x  K  	  R # 5ir^   r2   rb   r   r   s   & r4   rd   %PolyElement.degree.<locals>.<genexpr>       <^EQxx^   )r>   r  r   rz   r  r{   xr   s   &&@r4   degreePolyElement.degree  ?     FFLLOKU<Q\\^<<<r6   c                    V '       g#   \         3V P                  P                  ,          # \        \	        \
        \        \        V P                  4       !  4      4      4      # )z{
A tuple containing leading degrees in all variables.

Note that the degree of 0 is negative infinity (``float('-inf')``)

)	r   r>   rn   r~   rH   rz   rG   rL   r  r  s   &r4   degreesPolyElement.degrees  >     7166<<''S$sALLN';"<=>>r6   c                   a V P                   P                  V4      oV '       g   \        # S^ 8  d   ^ # \        V3R lV P	                  4        4       4      # )zu
The tail degree in ``x`` or the main variable.

Note that the degree of 0 is negative infinity (``float('-inf')``)

c              3  4   <"   T F  qS,          x  K  	  R # 5ir^   r2   r  s   & r4   rd   *PolyElement.tail_degree.<locals>.<genexpr>  r  r  )r>   r  r   minr  r  s   &&@r4   tail_degreePolyElement.tail_degree  r  r6   c                    V '       g#   \         3V P                  P                  ,          # \        \	        \
        \        \        V P                  4       !  4      4      4      # )zx
A tuple containing tail degrees in all variables.

Note that the degree of 0 is negative infinity (``float('-inf')``)

)	r   r>   rn   r~   rH   r  rG   rL   r  r  s   &r4   tail_degreesPolyElement.tail_degrees  r  r6   c                L    V '       d   V P                   P                  V 4      # R# )a  Leading monomial tuple according to the monomial ordering.

Examples
========

>>> from sympy.polys.rings import ring
>>> from sympy.polys.domains import ZZ

>>> _, x, y, z = ring('x, y, z', ZZ)
>>> p = x**4 + x**3*y + x**2*z**2 + z**7
>>> p.leading_expv()
(4, 0, 0)

N)r>   r   r   s   &r4   r   PolyElement.leading_expv  s     99))$//r6   c                	`    V P                  WP                  P                  P                  4      # r^   )r  r>   r<   r   r   r   s   &&r4   
_get_coeffPolyElement._get_coeff  s!    xxii..3344r6   c                   V^8X  d&   V P                  V P                  P                  4      # V P                  P                  V4      '       dj   \	        VP                  4       4      p\        V4      ^8X  dA   V^ ,          w  r4W@P                  P                  P                  8X  d   V P                  V4      # \        RV,          4      h)a|  
Returns the coefficient that stands next to the given monomial.

Parameters
==========

element : PolyElement (with ``is_monomial = True``) or 1

Examples
========

>>> from sympy.polys.rings import ring
>>> from sympy.polys.domains import ZZ

>>> _, x, y, z = ring("x,y,z", ZZ)
>>> f = 3*x**2*y - x*y*z + 7*z**3 + 23

>>> f.coeff(x**2*y)
3
>>> f.coeff(x*y)
0
>>> f.coeff(1)
23

zexpected a monomial, got %s)
r  r>   r   r   rG   rh  r   r<   r   r   )r   r   rq  r   r   s   &&   r4   r   PolyElement.coeff  s    4 a<??499#7#788YY!!'****,-E5zQ$QxII,,000??5116@AAr6   c                L    V P                  V P                  P                  4      # )z"Returns the constant coefficient. )r  r>   r   r   s   &r4   r  PolyElement.const   s    tyy3344r6   c                	@    V P                  V P                  4       4      # r^   )r  r   r   s   &r4   r  PolyElement.LC$  s    t00233r6   c                	Z    V P                  4       pVf   V P                  P                  # V# r^   )r   r>   r   r  s   & r4   LMPolyElement.LM(  s*      "<99'''Kr6   c                    V P                   P                  pV P                  4       pV'       d#   V P                   P                  P                  W&   V# )z
Leading monomial as a polynomial element.

Examples
========

>>> from sympy.polys.rings import ring
>>> from sympy.polys.domains import ZZ

>>> _, x, y = ring('x, y', ZZ)
>>> (3*x*y + y**2).leading_monom()
x*y

)r>   r   r   r<   r   r   r6  r   s   &  r4   leading_monomPolyElement.leading_monom0  s>     IINN  "ii&&**AGr6   c                	    V P                  4       pVf7   V P                  P                  V P                  P                  P                  3# WP                  V4      3# r^   )r   r>   r   r<   r   r  r  s   & r4   r  PolyElement.LTE  sL      "<II(($))*:*:*?*?@@//$/00r6   c                n    V P                   P                  pV P                  4       pVe   W,          W&   V# )zLeading term as a polynomial element.

Examples
========

>>> from sympy.polys.rings import ring
>>> from sympy.polys.domains import ZZ

>>> _, x, y = ring('x, y', ZZ)
>>> (3*x*y + y**2).leading_term()
3*x*y

)r>   r   r   r  s   &  r4   leading_termPolyElement.leading_termM  s3     IINN  "jAGr6   c                	   a Sf   V P                   P                  oM\        P                  ! S4      oS\        J d   \        VR RR7      # \        VV3R lRR7      # )Nc                    V ^ ,          # r|   r2   )r   s   &r4   rt   %PolyElement._sorted.<locals>.<lambda>h  s    qr6   T)ry   reversec                "   < S! V ^ ,          4      # r|   r2   )r   r1   s   &r4   rt   r  j  s    uQxr6   )r>   r1   r   r   r   sorted)r   r\   r1   s   &&fr4   _sortedPolyElement._sorteda  sL    =IIOOE''.EC<##94HH##@$OOr6   c                X    V P                  V4       UUu. uF  w  r#VNK	  	  upp# u uppi )a  Ordered list of polynomial coefficients.

Parameters
==========

order : :class:`~.MonomialOrder` or coercible, optional

Examples
========

>>> from sympy.polys.rings import ring
>>> from sympy.polys.domains import ZZ
>>> from sympy.polys.orderings import lex, grlex

>>> _, x, y = ring("x, y", ZZ, lex)
>>> f = x*y**7 + 2*x**2*y**3

>>> f.coeffs()
[2, 1]
>>> f.coeffs(grlex)
[1, 2]

rq  )r   r1   _r   s   &&  r4   rT   PolyElement.coeffsl  s)    0 (,zz%'8:'881'8:::   &c                X    V P                  V4       UUu. uF  w  r#VNK	  	  upp# u uppi )a  Ordered list of polynomial monomials.

Parameters
==========

order : :class:`~.MonomialOrder` or coercible, optional

Examples
========

>>> from sympy.polys.rings import ring
>>> from sympy.polys.domains import ZZ
>>> from sympy.polys.orderings import lex, grlex

>>> _, x, y = ring("x, y", ZZ, lex)
>>> f = x*y**7 + 2*x**2*y**3

>>> f.monoms()
[(2, 3), (1, 7)]
>>> f.monoms(grlex)
[(1, 7), (2, 3)]

r  )r   r1   r   r  s   &&  r4   monomsPolyElement.monoms  s)    0 (,zz%'8:'885'8:::r  c                T    V P                  \        V P                  4       4      V4      # )a  Ordered list of polynomial terms.

Parameters
==========

order : :class:`~.MonomialOrder` or coercible, optional

Examples
========

>>> from sympy.polys.rings import ring
>>> from sympy.polys.domains import ZZ
>>> from sympy.polys.orderings import lex, grlex

>>> _, x, y = ring("x, y", ZZ, lex)
>>> f = x*y**7 + 2*x**2*y**3

>>> f.terms()
[((2, 3), 2), ((1, 7), 1)]
>>> f.terms(grlex)
[((1, 7), 1), ((2, 3), 2)]

)r  rG   rM   )r   r1   s   &&r4   rq  PolyElement.terms  s     0 ||D.66r6   c                4    \        V P                  4       4      # )z,Iterator over coefficients of a polynomial. )iterrJ   r   s   &r4   
itercoeffsPolyElement.itercoeffs      DKKM""r6   c                4    \        V P                  4       4      # )z)Iterator over monomials of a polynomial. )r  r  r   s   &r4   r  PolyElement.itermonoms      DIIK  r6   c                4    \        V P                  4       4      # )z%Iterator over terms of a polynomial. )r  rM   r   s   &r4   rh  PolyElement.iterterms      DJJL!!r6   c                4    \        V P                  4       4      # )z+Unordered list of polynomial coefficients. )rG   rJ   r   s   &r4   
listcoeffsPolyElement.listcoeffs  r  r6   c                4    \        V P                  4       4      # )z(Unordered list of polynomial monomials. )rG   r  r   s   &r4   
listmonomsPolyElement.listmonoms  r  r6   c                4    \        V P                  4       4      # )z$Unordered list of polynomial terms. r  r   s   &r4   	listtermsPolyElement.listterms  r  r6   c                    W P                   P                  9   d	   W,          # V'       g   V P                  4        R# V  F  pW;;,          V,          uu&   K  	  V # )a  multiply inplace the polynomial p by an element in the
coefficient ring, provided p is not one of the generators;
else multiply not inplace

Examples
========

>>> from sympy.polys.rings import ring
>>> from sympy.polys.domains import ZZ

>>> _, x, y = ring('x, y', ZZ)
>>> p = x + y**2
>>> p1 = p.imul_num(3)
>>> p1
3*x + 3*y**2
>>> p1 is p
True
>>> p = x
>>> p1 = p.imul_num(3)
>>> p1
3*x
>>> p1 is p
False

N)r>   r   clear)r6  rX   r	  s   && r4   rT  PolyElement.imul_num  sD    4    3JGGICFaKF r6   c                    V P                   P                  pVP                  pVP                  pV P	                  4        F  pV! W$4      pK  	  V# )z*Returns GCD of polynomial's coefficients. )r>   r<   r   r   r  )r{   r<   contr   r   s   &    r4   r  PolyElement.content  sB    {{jj\\^Et#D $ r6   c                    V P                  4       pWP                  P                  P                  8X  d   W3# WP	                  V4      3# )z,Returns content and a primitive polynomial. )r  r>   r<   r   r_  )r{   r  s   & r4   	primitivePolyElement.primitive   s;    yy{66==%%%9\\$'''r6   c                L    V '       g   V # V P                  V P                  4      # )z5Divides all coefficients by the leading coefficient. )r_  r  r  s   &r4   monicPolyElement.monic  s    H<<%%r6   c                	    V'       g   V P                   P                  # V P                  4        UUu. uF  w  r#W#V,          3NK  	  pppV P                  V4      # u uppi r^   )r>   r   rh  r   )r{   r  r   r   rq  s   &&   r4   r  PolyElement.mul_ground  sJ    66;;78{{}F}|u5'"}FuuU| Gs   Ac                	    V P                   P                  pV P                  4        UUu. uF  w  r4V! W14      V3NK  	  pppV P                  V4      # u uppi r^   )r>   r   rM   r   )r{   r   r   f_monomf_coeffrq  s   &&    r4   	mul_monomPolyElement.mul_monom  sQ    vv**RSRYRYR[]R[>Ng</9R[]uuU| ^s   Ac                	h   Vw  r#V '       d	   V'       g   V P                   P                  # W P                   P                  8X  d   V P                  V4      # V P                   P                  pV P                  4        UUu. uF  w  rVV! WR4      Wc,          3NK  	  pppV P                  V4      # u uppi r^   )r>   r   r   r  r   rM   r   )r{   r  r   r   r   r  r  rq  s   &&      r4   mul_termPolyElement.mul_term  s    66;;ff'''<<&&vv**XYX_X_XacXaDTG</?XacuuU| ds   ?B.c           	     	   V P                   P                  pV'       g   \        R 4      hV '       d   WP                  8X  d   V # VP                  '       d8   VP
                  pV P                  4        UUu. uF  w  rEWC! WQ4      3NK  	  pppM;V P                  4        UUu. uF  w  rEWQ,          '       d   K  WEV,          3NK!  	  pppV P                  V4      # u uppi u uppi r[  )r>   r<   r]  r   r|  rq  rh  r   )r{   r  r<   rq  r   r   rq  s   &&     r4   r_  PolyElement.quo_ground&  s    #$9::AOH???**CABPuc%m,EPE>?kkm`mleTYT]T])uqj)mE`uuU|	 Q`s   5C C7Cc                	   Vw  r#V'       g   \        R 4      hV '       g   V P                  P                  # W P                  P                  8X  d   V P	                  V4      # V P                  4       pV P                  4        Uu. uF
  qT! WQ4      NK  	  ppT P                  V Uu. uF
  qUf   K  VNK  	  up4      # u upi u upi r[  )r]  r>   r   r   r_  r  rh  r   )r{   r  r   r   r  trq  s   &&     r4   quo_termPolyElement.quo_term6  s    #$9::66;;ff'''<<&&;;=-.[[]<](1#]<uu%:%Qqq%:;; =:s   B;$C .C c                	   V P                   P                  P                  '       dL   . pV P                  4        F4  w  r4WA,          pWA^,          8  d	   WA,
          pVP	                  W434       K6  	  M+V P                  4        UUu. uF  w  r4W4V,          3NK  	  pppV P                  V4      pVP                  4        V# u uppi )r0   )r>   r<   is_ZZrh  r   r   r  )r{   r6  rq  r   r   r   s   &&    r4   trunc_groundPolyElement.trunc_groundE  s    66==E !	6>!IEe^, !. >?[[]L]\Uuai(]ELuuU|	 Ms   C c                	    T pVP                  4       pVP                  4       pVP                  P                  P                  W44      pVP	                  V4      pVP	                  V4      pWRV3# r^   )r  r>   r<   r   r_  )r   r  r{   fcgcr   s   &&    r4   extract_groundPolyElement.extract_groundY  s[    YY[YY[ffmm'LLLLqyr6   c                	    V '       g!   V P                   P                  P                  # V P                   P                  P                  pT! V P	                  4        Uu. uF
  q2! V4      NK  	  up4      # u upi r^   )r>   r<   r   absr  )r{   	norm_func
ground_absr   s   &&  r4   _normPolyElement._norme  sT    66==%%%**JallnNnUz%0nNOONs   A4c                	,    V P                  \        4      # r^   )r2  rz   r  s   &r4   max_normPolyElement.max_norml      wws|r6   c                	,    V P                  \        4      # r^   )r2  rI   r  s   &r4   l1_normPolyElement.l1_normo  r7  r6   c                	   V P                   pV .\        V4      ,           p^ .VP                  ,          pV FB  pVP                  4        F+  p\	        V4       F  w  rx\        WG,          V4      WG&   K  	  K-  	  KD  	  \	        V4       F  w  ryV	'       d   K  ^WG&   K  	  \        V4      p\        ;QJ d    R V 4       F  '       d   K   RM	  RM! R V 4       4      '       d   WC3# . p
V Fj  pVP                  pVP                  4        F6  w  r\        W4       UUu. uF  w  r~W~,          NK  	  pppW\        V4      &   K8  	  V
P                  V4       Kl  	  WJ3# u uppi )r}   c              3  *   "   T F	  q^8H  x  K  	  R# 5ir  r2   )rb   rs   s   & r4   rd   &PolyElement.deflate.<locals>.<genexpr>  s     !q!Avqs   FT)r>   rG   rn   r  r  r   r~   ri   r   rh  rL   r   )r{   r  r>   rY   Jr6  r   r   rW   rs   HhIr   rW  Ns   &*              r4   deflatePolyElement.deflater  s"   vvd1gC

NA%e,DAa=AD - ( 
 aLDA1 ! !H3!q!333!q!!!8OA		AKKM),Q4aff4#%( * HHQK  t 5s   E
c                	    V P                   P                  pV P                  4        F6  w  r4\        W14       UUu. uF  w  rVWV,          NK  	  pppWB\	        V4      &   K8  	  V# u uppi r^   )r>   r   rh  rL   r~   )r{   r>  r   rA  r   r   rW  rB  s   &&      r4   inflatePolyElement.inflate  sV    vv{{HA"%a)-)$!!##)A-"qN &  .s   A#c                	r   T pVP                   P                  pVP                  '       g6   VP                  4       w  rBVP                  4       w  rQVP	                  WE4      pW!,          P                  VP                  V4      4      pVP                  '       g   VP                  X4      # VP                  4       # r^   )	r>   r<   r|  r  r   rq  r   r  r  )r   r  r{   r<   r*  r+  rX   r@  s   &&      r4   r   PolyElement.lcm  s    KKMEBKKMEB

2"ASIIaeeAh<<?"779r6   c                	2    V P                  V4      ^ ,          # r|   )	cofactorsr{   r  s   &&r4   r   PolyElement.gcd  s    {{1~a  r6   c                	.   V '       g#   V'       g   V P                   P                  pW"V3# V '       g   V P                  V4      w  r4pW4V3# V'       g   VP                  V 4      w  r5pW4V3# \        V 4      ^8X  d   V P	                  V4      w  r4pW4V3# \        V4      ^8X  d   VP	                  V 4      w  r5pW4V3# V P                  V4      w  pw  rV P                  V4      w  r4pVP                  V4      VP                  V4      VP                  V4      3# r   )r>   r   	_gcd_zeror   
_gcd_monomrC  _gcdrF  )r{   r  r   r@  cffcfgr>  s   &&     r4   rK  PolyElement.cofactors  s    66;;Dt##++a.KAC3;++a.KAC3;Vq[,,q/KAC3;Vq[,,q/KAC3;IIaL	6AffQi		!ckk!nckk!n==r6   c                	    V P                   P                  V P                   P                  r2VP                  '       d   WV3# V) W2) 3# r^   )r>   r   r   r  )r{   r  r   r   s   &&  r4   rO  PolyElement._gcd_zero  s=    FFJJTC<2tT>!r6   c                	8   V P                   pVP                  P                  pVP                  P                  pVP                  pVP
                  p\        V P                  4       4      ^ ,          w  rxYxrVP                  4        F  w  rV! W4      p	V! W4      p
K  	  V P                  W3.4      pV P                  V! Wy4      V! W4      3.4      pT P                  VP                  4        UUu. uF  w  rV! W4      V! W4      3NK  	  upp4      pWV3# u uppi r|   )	r>   r<   r   rq  r   r   rG   rh  r   )r{   r  r>   
ground_gcd
ground_quor   r   mfcf_mgcd_cgcdr  r  r@  rR  rS  s   &&              r4   rP  PolyElement._gcd_monom  s    vv[[__
[[__
((**akkm$Q'ukkmFB +Eu)E $ EEE>"#eemB.
20EFGHeeUVU`U`UbcUb62mB.
20EFUbcds{ ds   /D
c                	    V P                   pVP                  P                  '       d   V P                  V4      # VP                  P                  '       d   V P                  V4      # VP                  W4      # r^   )r>   r<   is_QQ_gcd_QQr&  _gcd_ZZdmp_inner_gcd)r{   r  r>   s   && r4   rQ  PolyElement._gcd  sX    vv;;99Q<[[99Q<%%a++r6   c                	    \        W4      # r^   r   rL  s   &&r4   rb  PolyElement._gcd_ZZ  s    a|r6   c                	j   T pVP                   pVP                  VP                  P                  4       R 7      pVP	                  4       w  rRVP	                  4       w  raVP                  V4      pVP                  V4      pVP                  V4      w  rxp	VP                  V4      pVP                  VP                  4       rzVP                  V4      P                  VP                  P                  W4      4      pV	P                  V4      P                  VP                  P                  W4      4      p	WxV	3# )r  )r>   r   r<   r~  r  rr  rb  r  r  r  rq  )r   r  r{   r>   rp  r[  r  r@  rR  rS  rX   s   &&         r4   ra  PolyElement._gcd_QQ  s    vv::T[[%9%9%;:<  JJx JJx iilJJtttQWWY1ll4 ++DKKOOA,BCll4 ++DKKOOA,BCs{r6   c                N   T pVP                   pV'       g   W#P                  3# VP                  pVP                  '       d   VP                  '       g   VP                  V4      w  rVpMVP                  VP                  4       R7      pVP                  4       w  rVP                  4       w  rVP                  V4      pVP                  V4      pVP                  V4      w  rVpVP                  P                  W4      w  rZp	VP                  V4      pVP                  V4      pVP                  V
4      pVP                  V	4      pVP                  4       pWP                  8X  d    Wg3# WP                  ) 8X  d	   V) V) rvWg3# VP                  V4      pVP                  V4      pWg3# )z
Cancel common factors in a rational function ``f/g``.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x,y = ring("x,y", ZZ)

>>> (2*x**2 - 2).cancel(x**2 - 2*x + 1)
(2*x + 2, x - 1)

r  )r>   r   r<   r|  r}  rK  r   r~  r  rr  r  canonical_unit)r   r  r{   r>   r<   r  r6  r  rp  cqcpus   &&          r4   cancelPolyElement.cancel  si    vvhh;F$9$9$9kk!nGA!zz):z;HNN$EBNN$EB

8$A

8$Akk!nGA! 11"9IA2

4 A

4 AR AR A
 

? t ::+2rq
 t QAQAtr6   c                	d    V P                   P                  pVP                  V P                  4      # r^   )r>   r<   rj  r  )r{   r<   s   & r4   rj  PolyElement.canonical_unit6	  s$    $$QTT**r6   c                .   V P                   pVP                  V4      pVP                  V4      pVP                  pV P	                  4        FF  w  rgWc,          '       g   K  VP                  Wd4      pVP                  WvV,          ,          4      WX&   KH  	  V# )zComputes partial derivative in ``x``.

Examples
========

>>> from sympy.polys.rings import ring
>>> from sympy.polys.domains import ZZ

>>> _, x, y = ring("x,y", ZZ)
>>> p = x + x**2*y**3
>>> p.diff(x)
2*x*y**3 + 1

)r>   r  r   r   rh  r   r   )	r{   r  r>   r   rW   r  r   r   es	   &&       r4   diffPolyElement.diff:	  sy     vvJJqM"II;;=KDww&&t/u!W}5 ) r6   c                	0   ^ \        V4      u;8  d   V P                  P                  8:  d<   M M8V P                  \	        \        V P                  P                  V4      4      4      # \        RV P                  P                  : R\        V4      : 24      h)r}   z expected at least 1 and at most z values, got )r   r>   rn   evaluaterG   rL   r:   r   )r{   rJ   s   &*r4   rS  PolyElement.__call__S	  sb    s6{*affll*::d3qvv{{F#;<==TUTZTZT`T`beflbmnoor6   c                	b   T p\        V\        4      '       dl   Vfh   V^ ,          VR,          uw  rBpVP                  WB4      pV'       g   V# V UUu. uF  w  rRVP                  V4      V3NK  	  pppVP                  V4      # VP                  pVP                  V4      pVP                  P                  V4      pVP                  ^8X  dI   VP                  P                  pVP                  4        F  w  w  rWW),          ,          ,          pK  	  V# VP                  V4      P                  pVP                  4        Fe  w  rW,          VR V W^,           R  ,           rWV	,          ,          p
W9   d"   WV,          ,           p
V
'       d   WV&   KS  W KW  V
'       g   Ka  WV&   Kg  	  V# u uppi )Nr  )r_   rG   rw  r  r>   r  r<   r   rn   r   rh  )r   r  rr   r{   XYr>   r   resultrJ  r   r   r   s   &&&          r4   rw  PolyElement.evaluateY	  se   a19!aeIFQA

1 A3461!qvvay!n16zz!}$vvJJqMKK"::?[[%%F {{}*$  - M99Q<$$D ! 8U2AYst%<5d
=!K/E&+U Ku&+U !. KA 7s   F+c                	   T p\        V\        4      '       d#   Vf   V F  w  rBVP                  WB4      pK  	  V# VP                  pVP	                  V4      pVP
                  P                  V4      pVP                  ^8X  dX   VP
                  P                  pVP                  4        F  w  w  rWyW(,          ,          ,          pK  	  VP                  V4      # VP                  p
VP                  4        Fl  w  rW,          VR V R,           W^,           R  ,           rWV,          ,          p	W9   d"   WV,          ,           p	V	'       d   WV&   KZ  W K^  V	'       g   Kh  WV&   Kn  	  V
# )Nr|   )r_   rG   subsr>   r  r<   r   rn   r   rh  r   )r   r  rr   r{   rz  r>   r   r|  rJ  r   r   r   s   &&&         r4   r  PolyElement.subs	  s'   a19FF1L HvvJJqMKK"::?[[%%F {{}*$  - ??6**99D ! 8U2AY%5cd%C5d
=!K/E&+U Ku&+U !. Kr6   c                8  aaa V P                  4       pVP                  pVP                  pV'       g   WP                  . 3# \	        V4       Uu. uF  qBP                  V^,           4      NK  	  upo/ oVV3R lp\        \	        V^,
          4      4      p\        \	        V^ R4      4      pVP                  pV'       Ed4   RRRrp	\        VP                  4       4       Ft  w  pw  op\        ;QJ d    V3R lV 4       F  '       d   K   RM	  RM! V3R lV 4       4      '       g   KK  \        R \        VS4       4       4      pW8  g   Ko  TSTrp	Kv  	  V	R8w  d   YuopMM. p\        SSR,          R	,           4       F  w  ppVP                  VV,
          4       K   	  WP                  \        V4      V4      ,          pTp\        V4       F  w  rCVV! WC4      ,          pK  	  VV,          pEK<  \        \        VP                  S4      4      pWV3# u upi )
a  
Rewrite *self* in terms of elementary symmetric polynomials.

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

If this :py:class:`~.PolyElement` belongs to a ring of $n$ variables,
we can try to write it as a function of the elementary symmetric
polynomials on $n$ variables. We compute a symmetric part, and a
remainder for any part we were not able to symmetrize.

Examples
========

>>> from sympy.polys.rings import ring
>>> from sympy.polys.domains import ZZ
>>> R, x, y = ring("x,y", ZZ)

>>> f = x**2 + y**2
>>> f.symmetrize()
(x**2 - 2*y, 0, [(x, x + y), (y, x*y)])

>>> f = x**2 - y**2
>>> f.symmetrize()
(x**2 - 2*y, -2*y**2, [(x, x + y), (y, x*y)])

Returns
=======

Triple ``(p, r, m)``
    ``p`` is a :py:class:`~.PolyElement` that represents our attempt
    to express *self* as a function of elementary symmetric
    polynomials. Each variable in ``p`` stands for one of the
    elementary symmetric polynomials. The correspondence is given
    by ``m``.

    ``r`` is the remainder.

    ``m`` is a list of pairs, giving the mapping from variables in
    ``p`` to elementary symmetric polynomials.

    The triple satisfies the equation ``p.compose(m) + r == self``.
    If the remainder ``r`` is zero, *self* is symmetric. If it is
    nonzero, we were not able to represent *self* as symmetric.

See Also
========

sympy.polys.polyfuncs.symmetrize

References
==========

.. [1] Lauer, E. Algorithms for symmetrical polynomials, Proc. 1976
    ACM Symp. on Symbolic and Algebraic Computing, NY 242-247.
    https://dl.acm.org/doi/pdf/10.1145/800205.806342

c                P   < W3S9  d   SV ,          V,          SW3&   SW3,          # r^   r2   )r   rJ  poly_powersrY   s   &&r4   get_poly_power.PolyElement.symmetrize.<locals>.get_poly_power	  s.    v[(&+AhkQF#v&&r6   Nc              3  X   <"   T F  pSV,          SV^,           ,          8  x  K!  	  R# 5ir  r2   )rb   r   r   s   & r4   rd   )PolyElement.symmetrize.<locals>.<genexpr>	  s"     AAuQx5Q</s   '*FTc              3  6   "   T F  w  rW,          x  K  	  R # 5ir^   r2   )rb   rJ  rW   s   &  r4   rd   r   
  s      E1D1Ds   r  r  r|   )r   r>   rn   r   r   rK  rG   r  rq  ri   rz   rL   r   r   r~   r:   )r   r{   r>   rJ  r   r  r  weights	symmetric_height_monom_coeffr   height	exponentsr  m2productr  r   r  rY   s   &                  @@@r4   
symmetrizePolyElement.symmetrize	  s   v IIKvvJJii##388<8a$$QqS)8<	'
 uQU|$uQ2'II	a&($VG%.qwwy%9!>E53AA333AAAA  EWe1D EEF'28% &: "}%uIeU2Y%56B  b) 7 uY'7??IG!),>!// -LAs499e,-W$$S =s    Hc                	  a V P                   pVP                  p\        \        VP                  \        VP                  4      4      4      oVe   W3.pMc\        V\        4      '       d   \        V4      pMA\        V\        4      '       d!   \        VP                  4       V3R lR7      pM\        R4      h\        V4       F$  w  pw  rSV,          VP                  V4      3WV&   K&  	  V P                  4        Fq  w  r\        V4      pVP                  p
V F+  w  rW,          ^ uqV&   V'       g   K  WV,          ,          p
K-  	  V
P!                  \#        V4      V	34      p
WJ,          pKs  	  V# )Nc                $   < SV ^ ,          ,          # r|   r2   )r  gens_maps   &r4   rt   %PolyElement.compose.<locals>.<lambda>$
  s    x!~r6   rx   z9expected a generator, value pair a sequence of such pairs)r>   r   rK   rL   r:   r   rn   r_   rG   r  rM   r   r  r   rh  r   r  r~   )r{   r  rr   r>   r   replacementsr  r  r   r   subpolyr   rJ  r  s   &&&          @r4   rB  PolyElement.compose
  s+   vvyyDIIuTZZ'89:=F8L!T""#AwAt$$%aggi5MN !\]]"<0IAv'{DMM!,<=LO 1 KKMLEKEhhG$#h81!tOG %
 &&ee'<=GOD * r6   c                   T pVP                   P                  V4      pVP                  4        UUu. uF  w  rVWT,          V8X  g   K  WV3NK  	  pppV'       g   VP                   P                  # \	        V!  w  rV Uu. uF  qURV R,           WT^,           R ,           NK   	  ppVP                   P                  \        \	        W4      4      4      # u uppi u upi )am  
Coefficient of ``self`` with respect to ``x**deg``.

Treating ``self`` as a univariate polynomial in ``x`` this finds the
coefficient of ``x**deg`` as a polynomial in the other generators.

Parameters
==========

x : generator or generator index
    The generator or generator index to compute the expression for.
deg : int
    The degree of the monomial to compute the expression for.

Returns
=======

:py:class:`~.PolyElement`
    The coefficient of ``x**deg`` as a polynomial in the same ring.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x, y, z = ring("x, y, z", ZZ)

>>> p = 2*x**4 + 3*y**4 + 10*z**2 + 10*x*z**2
>>> deg = 2
>>> p.coeff_wrt(2, deg) # Using the generator index
10*x + 10
>>> p.coeff_wrt(z, deg) # Using the generator
10*x + 10
>>> p.coeff(z**2) # shows the difference between coeff and coeff_wrt
10

See Also
========

coeff, coeffs

Nr|   )r>   r  rh  r   rL   rN   rK   )
r   r  degr6  r   rW   rX   rq  r  rT   s
   &&&       r4   	coeff_wrtPolyElement.coeff_wrt9
  s    T FFLLO$%KKMAMDAQTS[!MA66;;e4:;FqBQ%$,q56**F;vvS%8 9:: B <s   CC>$Cc                   T pVP                   P                  V4      pVP                  V4      pVP                  V4      pV^ 8  d   \        R4      hY4rvWE8  d   V# WE,
          ^,           pVP	                  W%4      p	VP                   P
                  V,          p
 VP	                  W'4      pWu,
          V^,
          rWi,          pW,          W,          ,          pW,
          pVP                  V4      pWu8  g   K`   Y,          pYo,          # )ag  
Pseudo-remainder of the polynomial ``self`` with respect to ``g``.

The pseudo-quotient ``q`` and pseudo-remainder ``r`` with respect to
``z`` when dividing ``f`` by ``g`` satisfy ``m*f = g*q + r``,
where ``deg(r,z) < deg(g,z)`` and
``m = LC(g,z)**(deg(f,z) - deg(g,z)+1)``.

See :meth:`pdiv` for explanation of pseudo-division.


Parameters
==========

g : :py:class:`~.PolyElement`
    The polynomial to divide ``self`` by.
x : generator or generator index, optional
    The main variable of the polynomials and default is first generator.

Returns
=======

:py:class:`~.PolyElement`
    The pseudo-remainder polynomial.

Raises
======

ZeroDivisionError : If ``g`` is the zero polynomial.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x, y = ring("x, y", ZZ)

>>> f = x**2 + x*y
>>> g = 2*x + 2
>>> f.prem(g) # first generator is chosen by default if it is not given
-4*y + 4
>>> f.rem(g) # shows the difference between prem and rem
x**2 + x*y
>>> f.prem(g, y) # generator is given
0
>>> f.prem(g, 1) # generator index is given
0

See Also
========

pdiv, pquo, pexquo, sympy.polys.domains.ring.Ring.rem

r\  r>   r  r  r]  r  r:   )r   r  r  r{   dfdgr  drrB  lc_gxplc_rrW  Rr  rX   s   &&&             r4   premPolyElement.premn
  s    l FFLLOXXa[XXa[6#$9::27HGaK{{1!VV[[^;;q%D7AEqA25 AA!BwIur6   c                p   T pVP                   P                  V4      pVP                  V4      pVP                  V4      pV^ 8  d   \        R4      hY#TrpWE8  d   Wg3# WE,
          ^,           p	VP	                  W%4      p
VP                   P
                  V,          p VP	                  W(4      pW,
          V	^,
          rWj,          pWW,          ,          ,           pWz,          pW,          W,          ,          pVV,
          pVP                  V4      pW8  g   K~   Y,          pTT,          pTT,          pYg3# )a	  
Computes the pseudo-division of the polynomial ``self`` with respect to ``g``.

The pseudo-division algorithm is used to find the pseudo-quotient ``q``
and pseudo-remainder ``r`` such that ``m*f = g*q + r``, where ``m``
represents the multiplier and ``f`` is the dividend polynomial.

The pseudo-quotient ``q`` and pseudo-remainder ``r`` are polynomials in
the variable ``x``, with the degree of ``r`` with respect to ``x``
being strictly less than the degree of ``g`` with respect to ``x``.

The multiplier ``m`` is defined as
``LC(g, x) ^ (deg(f, x) - deg(g, x) + 1)``,
where ``LC(g, x)`` represents the leading coefficient of ``g``.

It is important to note that in the context of the ``prem`` method,
multivariate polynomials in a ring, such as ``R[x,y,z]``, are treated
as univariate polynomials with coefficients that are polynomials,
such as ``R[x,y][z]``. When dividing ``f`` by ``g`` with respect to the
variable ``z``, the pseudo-quotient ``q`` and pseudo-remainder ``r``
satisfy ``m*f = g*q + r``, where ``deg(r, z) < deg(g, z)``
and ``m = LC(g, z)^(deg(f, z) - deg(g, z) + 1)``.

In this function, the pseudo-remainder ``r`` can be obtained using the
``prem`` method, the pseudo-quotient ``q`` can
be obtained using the ``pquo`` method, and
the function ``pdiv`` itself returns a tuple ``(q, r)``.


Parameters
==========

g : :py:class:`~.PolyElement`
    The polynomial to divide ``self`` by.
x : generator or generator index, optional
    The main variable of the polynomials and default is first generator.

Returns
=======

:py:class:`~.PolyElement`
    The pseudo-division polynomial (tuple of ``q`` and ``r``).

Raises
======

ZeroDivisionError : If ``g`` is the zero polynomial.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x, y = ring("x, y", ZZ)

>>> f = x**2 + x*y
>>> g = 2*x + 2
>>> f.pdiv(g) # first generator is chosen by default if it is not given
(2*x + 2*y - 2, -4*y + 4)
>>> f.div(g) # shows the difference between pdiv and div
(0, x**2 + x*y)
>>> f.pdiv(g, y) # generator is given
(2*x**3 + 2*x**2*y + 6*x**2 + 2*x*y + 8*x + 4, 0)
>>> f.pdiv(g, 1) # generator index is given
(2*x**3 + 2*x**2*y + 6*x**2 + 2*x*y + 8*x + 4, 0)

See Also
========

prem
    Computes only the pseudo-remainder more efficiently than
    `f.pdiv(g)[1]`.
pquo
    Returns only the pseudo-quotient.
pexquo
    Returns only an exact pseudo-quotient having no remainder.
div
    Returns quotient and remainder of f and g polynomials.

r\  r  )r   r  r  r{   r  r  r  r  r  rB  r  r  r  rW  Qr  r  rX   s   &&&               r4   pdivPolyElement.pdiv
  s   ` FFLLOXXa[XXa[6#$9::b74KGaK{{1!VV[[^;;q%D7AEqA25L AA25 AAA!BwGEEtr6   c                6    T pVP                  W4      ^ ,          # )a  
Polynomial pseudo-quotient in multivariate polynomial ring.

Examples
========
>>> from sympy.polys import ring, ZZ
>>> R, x,y = ring("x,y", ZZ)

>>> f = x**2 + x*y
>>> g = 2*x + 2*y
>>> h = 2*x + 2
>>> f.pquo(g)
2*x
>>> f.quo(g) # shows the difference between pquo and quo
0
>>> f.pquo(h)
2*x + 2*y - 2
>>> f.quo(h) # shows the difference between pquo and quo
0

See Also
========

prem, pdiv, pexquo, sympy.polys.domains.ring.Ring.quo

)r  )r   r  r  r{   s   &&& r4   pquoPolyElement.pquoG  s    6 vva|Ar6   c                j    T pVP                  W4      w  rEVP                  '       d   V# \        W14      h)a<  
Polynomial exact pseudo-quotient in multivariate polynomial ring.

Examples
========
>>> from sympy.polys import ring, ZZ
>>> R, x,y = ring("x,y", ZZ)

>>> f = x**2 + x*y
>>> g = 2*x + 2*y
>>> h = 2*x + 2
>>> f.pexquo(g)
2*x
>>> f.exquo(g) # shows the difference between pexquo and exquo
Traceback (most recent call last):
...
ExactQuotientFailed: 2*x + 2*y does not divide x**2 + x*y
>>> f.pexquo(h)
Traceback (most recent call last):
...
ExactQuotientFailed: 2*x + 2 does not divide x**2 + x*y

See Also
========

prem, pdiv, pquo, sympy.polys.domains.ring.Ring.exquo

)r  r  r#   )r   r  r  r{   r  r  s   &&&   r4   pexquoPolyElement.pexquoe  s1    : vva|999H%a++r6   c                   T pVP                   P                  V4      pVP                  V4      pVP                  V4      pWE8  d   YrYTrTV^ 8X  d   ^ ^ .# V^ 8X  d   V^.# W1.pWE,
          pRV^,           ,          pVP                  W4      p	W,          p	VP	                  W%4      p
W,          p^V.pV) pV	'       d   V	P                  V4      pVP                  V	4       WWV,
          3w  r1rWV
) W,          ,          pVP                  W4      p	V	P                  V4      p	VP	                  W-4      p
V^8  d,   V
) V,          pW^,
          ,          pVP                  V4      pMV
) pVP                  V) 4       K  V# )a  
Computes the subresultant PRS of two polynomials ``self`` and ``g``.

Parameters
==========

g : :py:class:`~.PolyElement`
    The second polynomial.
x : generator or generator index
    The variable with respect to which the subresultant sequence is computed.

Returns
=======

R : list
    Returns a list polynomials representing the subresultant PRS.

Examples
========

>>> from sympy.polys import ring, ZZ
>>> R, x, y = ring("x, y", ZZ)

>>> f = x**2*y + x*y
>>> g = x + y
>>> f.subresultants(g) # first generator is chosen by default if not given
[x**2*y + x*y, x + y, y**3 - y**2]
>>> f.subresultants(g, 0) # generator index is given
[x**2*y + x*y, x + y, y**3 - y**2]
>>> f.subresultants(g, y) # generator is given
[x**2*y + x*y, x + y, x**3 + x**2]

r  )r>   r  r  r  r  r   ry  )r   r  r  r{   rJ  rW   r  drs   r@  lcrX   Sr  r6  r  s   &&&             r4   subresultantsPolyElement.subresultants  s`   D FFLLOHHQKHHQK5qq6q6M6q6MFEQUO FF1LE [[GFBAHHQKqa%JA!afAqA
AQ"B1uSQJa%LGGAJCHHaRLr6   c                	8    V P                   P                  W4      # r^   )r>   dmp_half_gcdexrL  s   &&r4   
half_gcdexPolyElement.half_gcdex  s    vv$$Q**r6   c                	8    V P                   P                  W4      # r^   )r>   	dmp_gcdexrL  s   &&r4   gcdexPolyElement.gcdex      vv%%r6   c                	8    V P                   P                  W4      # r^   )r>   dmp_resultantrL  s   &&r4   	resultantPolyElement.resultant  s    vv##A))r6   c                	8    V P                   P                  V 4      # r^   )r>   dmp_discriminantr  s   &r4   discriminantPolyElement.discriminant  s    vv&&q))r6   c                	    V P                   P                  '       d   V P                   P                  V 4      # \        R 4      h)zpolynomial decomposition)r>   r,  dup_decomposer$   r  s   &r4   	decomposePolyElement.decompose  s3    6666''**-.HIIr6   c                	    V P                   P                  '       d   V P                   P                  W4      # \        R 4      h)zshift: use shift_list instead)r>   r,  	dup_shiftr$   r{   rr   s   &&r4   shiftPolyElement.shift  s3    6666##A))-.MNNr6   c                	8    V P                   P                  W4      # r^   )r>   	dmp_shiftr  s   &&r4   
shift_listPolyElement.shift_list  r  r6   c                	    V P                   P                  '       d   V P                   P                  V 4      # \        R 4      h)zsturm sequence)r>   r,  	dup_sturmr$   r  s   &r4   sturmPolyElement.sturm  s3    6666##A&&-.>??r6   c                	8    V P                   P                  V 4      # r^   )r>   dmp_gff_listr  s   &r4   gff_listPolyElement.gff_list      vv""1%%r6   c                	8    V P                   P                  V 4      # r^   )r>   dmp_normr  s   &r4   normPolyElement.norm  s    vvq!!r6   c                	8    V P                   P                  V 4      # r^   )r>   dmp_sqf_normr  s   &r4   sqf_normPolyElement.sqf_norm  r  r6   c                	8    V P                   P                  V 4      # r^   )r>   dmp_sqf_partr  s   &r4   sqf_partPolyElement.sqf_part  r  r6   c                	:    V P                   P                  WR 7      # ))ri   )r>   dmp_sqf_list)r{   ri   s   &&r4   sqf_listPolyElement.sqf_list  s    vv""1"..r6   c                	8    V P                   P                  V 4      # r^   )r>   dmp_factor_listr  s   &r4   factor_listPolyElement.factor_list  s    vv%%a((r6   )r   r>   r^   )F)r   rM  rN  rO  rP  rX  r`  r   re  r   r   r   r   rr  rv  ru  r  r  r   r   r  r  r  r  r  r  r  r  r  r  r<  r  r  r`   rR  r  r  r  r  r  r  r  r  r  r  r   r  r  r  r  r  r#  r&  r)  r.  r,  r4  r3  r?  r9  rH  rG  rF  rE  rb  r^  rk  rj  rs  rv  rz  rr  r  r   ri  rq  ry  r  r  r  r  r  r  r   r  r   r  r  r  r  r  r  r  rT   r  rq  r  r  rh  r  r  r  rT  r  r  r  r  r  r  r_  r#  r'  r`  r,  r2  r5  r9  rC  rF  r   r   rK  rO  rP  rQ  rb  ra  rn  rj  rt  rS  rw  r  r  rB  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  rT  __classcell__)r   s   @r4   r   r   J  sU   ?K/%3 E	8>	=M"44G0)"	2*>"H.` + + M M = =   5 5 5 5 8 8 8 8     * * 1 1 @ @ @ @ # #
 + +
 G GR4l(4l82h:4(l :#J:,%,%,%, BJX+Z,*X#J= 
?= 
?(5#BJ5 4 4  * 1 1(	P;4;474#!"#!"!F	(&

 <$ J
PB !>," ,*6p+2p*X%Nk%Z@3;jYv||<#,JXz+&**JO&@&"&&/) )r6   r   N)QrP  
__future__r   operatorr   r   r   r   r   r   	functoolsr	   typesr
   sympy.core.cacher   sympy.core.exprr   sympy.core.intfuncr   sympy.core.symbolr   r   rh   sympy.core.sympifyr   r   sympy.ntheory.multinomialr   sympy.polys.compatibilityr   sympy.polys.constructorr   sympy.polys.densebasicr   r   r   sympy.polys.domains.domainr   !sympy.polys.domains.domainelementr   "sympy.polys.domains.polynomialringr   sympy.polys.heuristicgcdr   sympy.polys.monomialsr   sympy.polys.orderingsr   r    sympy.polys.polyerrorsr!   r"   r#   r$   sympy.polys.polyoptionsr   r%   r   r&   sympy.polys.polyutilsr'   r(   r)   sympy.printing.defaultsr*   sympy.utilitiesr+   r,   sympy.utilities.iterablesr-   sympy.utilities.magicr.   r>   r@   rD   rZ   rk   r9   rK   r   r2   r6   r4   <module>r     s     " - -   $   # 9 3 > , 4 C C - ; = + - 46 6G G= = 3 + 1 )58 ! !< !$  < !$  < 2 2h@C CLN')-+t N')r6   