K i@PdZddlmZddlmZmZmZmZmZm Z ddl m Z ddl m Z ddlmZddlmZddlmZdd lmZmZdd lmZmZdd lmZdd lmZdd lm Z ddl!m"Z"m#Z#m$Z$ddl%m&Z&ddl'm(Z(ddl)m*Z*ddl+m,Z,ddl-m.Z.ddl/m0Z0m1Z1ddl2m3Z3m4Z4m5Z5m6Z6ddl7m&Z8m9Z:m;Z;ddlZ>m?Z?ddl@mAZAddlBmCZCmDZDddlEmFZFddlGmHZHeCe0fd&dZIeCe0fdZJeCe0fdZKeCdZLd ZMGd!d"eAeZNGd#d$e(eAeeOZPy%)'zSparse polynomial rings. ) annotations)addmulltlegtge)reduce) GeneratorType)cacheit)Expr)igcd)Symbolsymbols) CantSympifysympify)multinomial_coefficients)IPolys)construct_domain)ninf dmp_to_dict dmp_from_dict)Domain) DomainElementPolynomialRingheugcd) MonomialOps)lex MonomialOrder)CoercionFailedGeneratorsErrorExactQuotientFailedMultivariatePolynomialError)rOrder build_options)expr_from_dict _dict_reorder_parallel_dict_from_expr)DefaultPrinting)publicsubsets) is_sequence)pollutec<t|||}|f|jzS)aConstruct 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(_) PolyRinggensrdomainorder_rings W/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sympy/polys/rings.pyringr9$s#8 Wfe ,E 8ejj  c8t|||}||jfS)aConstruct 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(_) r1r4s r8xringr<Cs!8 Wfe ,E 5:: r:ct|||}t|jDcgc]}|jc}|j|Scc}w)aConstruct 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(_) )r2r/rnamer3)rr5r6r7syms r8vringr@bs=6 Wfe ,E %-- 13chh 15::> L 2sAc d}t|s|gd}}ttt|}t ||}t ||\}}|j t|Dcgc]}t|jc}g}t||\|_}tt||} |D cgc])}|jD cic] \} } | | |  c} } +}} }} t|j|j |j} tt| j |} |r| | dfS| | fScc}wcc} } wcc} } }w)adConstruct 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(_) FT)optr)r.listmaprr'r*r5sumvaluesrdictzipitemsr2r3r6 from_dict)exprsroptionssinglerBrepsrepcoeffs coeffs_dom coeff_mapmcr7polyss r8sringrVs&4F u v We$ %E  )C)4ID# zzT;ctCJJL);R@!1&c!B JVZ01 EIJJcSYY[9TQIaL9JJ SXXszz399 5E U__d+ ,E uQx  u~< :Js D=4E EEEct|tr|r t|dSdSt|tr|fSt |r1t d|Dr t|St d|Dr|St d)NT)seqc3<K|]}t|tywN) isinstancestr.0ss r8 z!_parse_symbols..s3az!S!3c3<K|]}t|tywr[)r\r r^s r8raz!_parse_symbols..s6At$6rbzbexpected a string, Symbol or expression or a non-empty sequence of strings, Symbols or expressions)r\r]_symbolsr r.allr#rs r8_parse_symbolsrgsr'3.5xT*=2= GT "z W  373 3G$ $ 6g6 6N ~ r:c^eZdZUdZded<ded<ded<ded <d ed <efd Zd ZdZdZ dZ dZ dZ d1dZ edZdZedZedZdZd2dZdZdZdZeZd2dZd2dZd Zd!Zd"Zd#Zd$Z d%Z!d&Z"d'Z#d(Z$ed)Z%ed*Z&d+Z'd,Z(d-Z)d.Z*d/Z+d0Z,y)3r2z*Multivariate distributed polynomial ring. ztuple[PolyElement, ...]r3ztuple[Expr, ...]rintngensrr5r!r6cFtt|}t|}tj|}t j|j |||f}|jr,t|t|jzr tdtj|}||_ t||_||_ ||_||_|_t'|dj(|_d|z|_|j/|_t|j0|_|j,|j4fg|_|rt9|}|j;|_|j?|_ |jC|_"|jG|_$|jK|_&|jO|_(|jS|_*n5d}||_||_ d|_"||_$||_&||_(||_*tVur tX|_-n fd|_-t]|j|j0D]<\} } t_| t`s| jb} te|| r0tg|| | >|S)Nz7polynomial ring and it's ground domain share generatorsrYrcyNrYrY)abs r8z"PolyRing.__new__..r:cyrnrY)rorprTs r8rqz"PolyRing.__new__..rrr:ct|S)Nkey)max)fr6s r8rqz"PolyRing.__new__..sQE):r:)4tuplerglen DomainOpt preprocessOrderOpt__name__ is_Compositesetrr#object__new__ _hash_tuplehash_hashrjr5r6 PolyElementnewdtype zero_monom_gensr3 _gens_setone_onerr monomial_mulpow monomial_powmulpowmonomial_mulpowldiv monomial_ldivdiv monomial_divlcm monomial_lcmgcd monomial_gcdr rw leading_expvrHr\rr>hasattrsetattr) clsrr5r6rjrobjcodegenmonunitsymbol generatorr>s ` r8rzPolyRing.__new__s w/0G %%f-##E*||WeVUC   3w<#fnn2E#E!"[\ \nnS!%%     R(,, e99;CHH  ^^VZZ01 !%(G&{{}C &{{}C ").."2C  ' C &{{}C &{{}C &{{}C %G&C &C "4C  'C &C &C &C  C<"C :C !$S[[#((!; 2 FI&&){{sD)Cy1  2 r:c|jj}g}t|jD]5}|j |}|j }|||<|j |7t|S)z(Return a list of polynomial generators. )r5rrangerjmonomial_basiszeroappendry)selfrriexpvpolys r8rzPolyRing._gens sfkkootzz" A&&q)D99DDJ LL    U|r:cH|j|j|jfSr[)rr5r6rs r8__getnewargs__zPolyRing.__getnewargs__s dkk4::66r:cx|jj}|d=|D]}|jds||=|S)Nr monomial_)__dict__copy startswith)rstatervs r8 __getstate__zPolyRing.__getstate__sE ""$ . ! C~~k*#J  r:c|jSr[)rrs r8__hash__zPolyRing.__hash__#s zzr:ct|txr]|j|j|j|j f|j|j|j|j fk(Sr[)r\r2rr5rjr6rothers r8__eq__zPolyRing.__eq__&sV%*D \\4;; DJJ ? ]]ELL%++u{{ C D Dr:c||k( Sr[rYrs r8__ne__zPolyRing.__ne__+s5=  r:Ncb|t|tr t|}|j|||Sr[)r\rCry_clonerrr5r6s r8clonezPolyRing.clone.s-  :gt#<GnG{{7FE22r:c||j|xs |j|xs |j|xs |jSr[) __class__rr5r6rs r8rzPolyRing._clone4s3~~g5v7LeNaW[WaWabbr:cBdg|jz}d||<t|S)zReturn the ith-basis element. r)rjry)rrbasiss r8rzPolyRing.monomial_basis8s$DJJaU|r:c$|jgSr[)rrs r8rz PolyRing.zero>szz"~r:c8|j|jSr[)rrrs r8rz PolyRing.oneBszz$))$$r:cDt|txr|j|k(S)zATrue if ``element`` is an element of this ring. False otherwise. )r\rr9relements r8 is_elementzPolyRing.is_elementFs';/HGLLD4HHr:c:|jj||Sr[)r5convertrr orig_domains r8 domain_newzPolyRing.domain_newJs{{""7K88r:c:|j|j|Sr[)term_newr)rcoeffs r8 ground_newzPolyRing.ground_newMs}}T__e44r:cN|j|}|j}|r|||<|Sr[)rr)rmonomrrs r8rzPolyRing.term_newPs*&yy DK r:cVt|trj||jk(r|St|jtr4|jj|jk(r|j |St dt|tr t dt|tr|j|St|tr |j|St|tr|j|S|j |S#t$r|j|cYSwxYw)N conversionparsing)r\rr9r5rrNotImplementedErrorr]rGrJrC from_terms ValueError from_listr from_exprrs r8ring_newzPolyRing.ring_newWs g{ +w||#DKK8T[[=M=MQXQ]Q]=]w//),77  %%i0 0  &>>'* *  & /w// &>>'* *??7+ +  /~~g.. /sD D('D(c|j}|j}|jD]\}}|||}|s|||<|Sr[)rrrI)rrrrrrrs r8rJzPolyRing.from_dictosL__ yy#MMO $LE5uk2E#U  $  r:c8|jt||Sr[)rJrGrs r8rzPolyRing.from_termszs~~d7m[99r:ch|jt||jdz |jSNr)rJrrjr5rs r8rzPolyRing.from_list}s&~~k'4::a<MNNr:cTjfdt|S)Nc j|}||S|jr-ttt t |j S|jr-ttt t |j S|j\}}|jr|dkDr|t|zSjj|Sr)getis_Addr rrCrDargsis_Mulr as_base_exp is_Integerrirr)exprrbaseexp_rebuildr5mappingrs r8rz(PolyRing._rebuild_expr.._rebuilds D)I$  c4Hdii(@#ABBc4Hdii(@#ABB!,,. c>>cAg#D>3s833??6>>$+?@@r:)r5r)rrrrr5s` `@@r8 _rebuild_exprzPolyRing._rebuild_exprs# A$ &&r:cttt|j|j} |j ||}|j |S#t$rtd|d|wxYw)Nz6expected an expression convertible to a polynomial in z, got ) rGrCrHrr3rrr"r)rrrrs r8rzPolyRing.from_exprsmtC dii89: '%%dG4D==& & pcgimno o ps AA2c||jrd}|Sd}|St|trD|}d|kr||jkr |S|j |kr |dkr| dz }|Std|z|j |r |j j |}|St|tr |jj |}|Std|z#t$rtd|zwxYw#t$rtd|zwxYw)z+Compute index of ``gen`` in ``self.gens``. rrzinvalid generator index: %szinvalid generator: %szEexpected a polynomial generator, an integer, a string or None, got %s) rjr\rirrr3indexr]r)rgenrs r8rzPolyRing.indexsB ;zz2/.-S !AAv!djj.$#**!a2gBF !!>!DEE __S ! @IIOOC(S ! @LL&&s+ dgjjk k @ !83!>?? @  @ !83!>?? @s=C+C1C.1D ctt|j|}t|jDcgc] \}}||vs |}}}|s |j S|j |Scc}}w)z,Remove specified generators from this ring. rf)rrDr enumeraterr5r)rr3indicesrr`rs r8dropz PolyRing.dropsbc$**d+,"+DLL"9O$!QQg=MAOO;; ::g:. . Ps A,A,c`|j|}|s |jS|j|S)Nrf)rr5r)rrvrs r8 __getitem__zPolyRing.__getitem__s.,,s#;; ::g:. .r:c|jjst|jdr&|j|jjSt d|jz)Nr5r5z%s is not a composite domain)r5rrrrrs r8 to_groundzPolyRing.to_groundsL ;; # #wt{{H'E::T[[%7%7:8 8;dkkIJ Jr:ct|Sr[rrs r8 to_domainzPolyRing.to_domains d##r:c^ddlm}||j|j|jS)Nr) FracField)sympy.polys.fieldsrrr5r6)rrs r8to_fieldzPolyRing.to_fields 0t{{DJJ??r:c2t|jdk(Srrzr3rs r8 is_univariatezPolyRing.is_univariates499~""r:c2t|jdkDSrr rs r8is_multivariatezPolyRing.is_multivariates499~!!r:c~|j}|D]+}t|tr||j|z }'||z }-|S)aw 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)rr.r rrobjsprs r8rz PolyRing.addsJ" II C3 6XTXXs^#S   r:c~|j}|D]+}t|tr||j|z}'||z}-|S)a 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)]) r)rr.r rrs r8rz PolyRing.mulsJ" HH C3 6XTXXs^#S   r:cPtt|j|}t|jDcgc] \}}||vs |}}}t|j Dcgc] \}}||vs |}}}|s|S|j ||j|Scc}}wcc}}w)zd Remove specified generators from the ring and inject them into its domain. rr5)rrDrrrr3rr)rr3rrr`rrs r8drop_to_groundzPolyRing.drop_to_grounds c$**d+,!*4<D::d4j:1 1Kr:ct|jjt|}|jt |S)z9Add the elements of ``symbols`` as generators to ``self``rfr)rrrs r8add_genszPolyRing.add_gens4s44<< &&s7|4zz$t*z--r:c|dks||jkDrtd|d|j|s |jS|j}t t |jt|D]Rtfdt |jD}||j||jjz }T|S)zo Return the elementary symmetric polynomial of degree *n* over this ring's generators. rz.Cannot generate symmetric polynomial of order z for c38K|]}t|vywr[)ri)r_rr`s r8raz*PolyRing.symmetric_poly..EsEac!q&kEs) rjrr3rrr-rriryrr5)rnrrr`s @r8symmetric_polyzPolyRing.symmetric_poly9s q5A NZ[]a]f]fgh h88O99DU4::.A7 >E53DEE eT[[__== >Kr:)NNNr[)-r~ __module__ __qualname____doc____annotations__r rrrrrrrrr rrpropertyrrrrrrr__call__rJrrrrrrrrrrr r rrrrrr!rYr:r8r2r2s34 !!  J N ,/<| 7D !3  c c %%I95,,H :O'.'>//K$@##""66 H. r:r2c|eZdZdZfdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZddZdZdZdZdZdZdZdZdZdZdZdZdZdZ e!dZ"e!d Z#e!d!Z$e!d"Z%e!d#Z&e!d$Z'e!d%Z(e!d&Z)e!d'Z*e!d(Z+e!d)Z,e!d*Z-e!d+Z.e!d,Z/e!d-Z0e!d.Z1e!d/Z2d0Z3d1Z4d2Z5d3Z6d4Z7d5Z8d6Z9d7Z:d8Z;d9Zd<Z?d=Z@d>ZAd?ZBd@ZCdAZDdBZEdCZFdDZGdEZHdFZIdGZJdHZKdIZLdJZMddKZNdLZOddMZPdNZQdOZRdPZSdQZTdRZUe!dSZVe!dTZWdUZXe!dVZYdWZZdXZ[ddYZ\ddZZ]dd[Z^d\Z_d]Z`d^Zad_Zbd`ZcdaZddbZedcZfddZgdeZhdfZidgZjdhZkdiZldjZmdkZnenZodlZpdmZqdnZrdoZsdpZtdqZudrZvdsZwdtZxduZydvZzdwZ{dxZ|dyZ}dzZ~d{Zd|Zd}Zdd~ZddZdZddZdZddZddZddZddZddZdZdZdZdZdZdZdZdZdZdZdZdZddZdZxZS)rz5Element of multivariate distributed polynomial ring. c2t||||_yr[)super__init__r9)rr9initrs r8r+zPolyElement.__init__Ms  r:cvt|tsJt|jtsJ|jj}t|t sJ|j D]P\}}|j|sJt||jjk(sJtd|DrPJy)Nc3JK|]}t|txr|dk\yw)rN)r\ri)r_rs r8raz%PolyElement._check..[s#JSz#s+8q8Js!#) r\rr9r2r5rrIof_typerzrjre)rdomrrs r8_checkzPolyElement._checkSs$ ,,,$))X...ii#v&&& JJL KLE5;;u% %%u:0 00JEJJ JJ Kr:c:|j|j|Sr[)rr9)rr,s r8rzPolyElement.new]s~~dii..r:c6|jjSr[)r9rrs r8parentzPolyElement.parent`syy""$$r:cL|jt|jfSr[)r9rC itertermsrs r8rzPolyElement.__getnewargs__cs 4 0122r:Nc|j}|5t|jt|j fx|_}|Sr[)rrr9 frozensetrI)rrs r8rzPolyElement.__hash__hs<   =!%tyy)DJJL2I&J!K KDJ r:c$|j|S)aReturn 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 )rrs r8rzPolyElement.copyss4xx~r:c v|j|k(r|S|jj|jk7r`ttt ||jj|j}|j ||jj S|j||jj Sr[)r9rrCrHr)rr5rJ)rnew_ringtermss r8set_ringzPolyElement.set_rings 99 K YY  ("2"2 2mD$))2C2CXEUEUVWXE&&udii.>.>? ?%%dDII,<,<= =r:c|s|jj}nPt||jjk7r.t d|jjdt|t |j g|S)Nz"Wrong number of symbols, expected z got )r9rrzrjrr( as_expr_dict)rrs r8as_exprzPolyElement.as_exprsfii''G \TYY__ ,#g,0  d//1>;KL<5%x&LLLsA c |jj}|jr |js|j|fS|j }|j}|j }|j}|jD]}||||}|j|jDcgc] \}}|||zfc}}} || fScc}}wr[) r9r5is_Fieldhas_assoc_Ringrget_ringrdenomrFrrI) rr5 ground_ringcommonrrGrkvrs r8 clear_denomszPolyElement.clear_denomss!!f&;&;::t# #oo' oo [[] /Eu.F /xxDJJLBDAq1ah-BCt|Cs3C cRt|jD] \}}|r ||= y)z+Eliminate monomials with zero coefficient. NrCrI)rrJrKs r8 strip_zerozPolyElement.strip_zeros*& DAqG r:c|s| S|jj|rtj||St |dkDry|j |jj |k(S)aPEquality 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 rF)r9rrGrrzrrp1p2s r8rzPolyElement.__eq__s]"6M WW   #;;r2& & Wq[66"'',,-3 3r:c||k( Sr[rYrQs r8rzPolyElement.__ne__s8|r:c|j}|j|rrt|jt|jk7ry|jj }|jD]}||||||ryyt |dkDry |jj|}|jj |j||S#t$rYywxYw)z+Approximate equality test for polynomials. FTr) r9rrkeysr5almosteqrzrconstr")rRrS tolerancer9rWrJs r8rWzPolyElement.almosteqsww ??2 2779~RWWY/{{++HWWY !1r!ui8  ! Wq[ G[[((,{{++BHHJIFF"  s C&& C21C2c8t||jfSr[)rzr<rs r8sort_keyzPolyElement.sort_keysD 4::<((r:c|jj|r%||j|jStSr[)r9rr[NotImplemented)rRrSops r8_cmpzPolyElement._cmps3 77  b !bkkmR[[]3 3! !r:c.|j|tSr[)r_rrQs r8__lt__zPolyElement.__lt__wwr2r:c.|j|tSr[)r_rrQs r8__le__zPolyElement.__le__rbr:c.|j|tSr[)r_rrQs r8__gt__zPolyElement.__gt__rbr:c.|j|tSr[)r_r rQs r8__ge__zPolyElement.__ge__rbr:c|j}|j|}|jdk(r||jfSt |j }||=||j |fS)Nrrf)r9rrjr5rCrrrrr9rrs r8_dropzPolyElement._drops\yy JJsO ::?dkk> !4<<(G djjj11 1r:cb|j|\}}|jjdk(r+|jr|j dSt d|z|j }|jD]7\}}||dk(rt|}||=||t|<+t d|z|S)NrzCannot drop %sr) rkr9rj is_groundrrrrIrCry)rrrr9rrJrKKs r8rzPolyElement.drops**S/4 99??a ~~zz!}$ !1C!78899D  =1Q419QA!%&DqN$%5%;<<  =Kr:c|j}|j|}t|j}||=||j |||fS)Nr)r9rrCrrrjs r8_drop_to_groundzPolyElement._drop_to_ground%sIyy JJsOt||$ AJ$**WT!W*===r:c|jjdk(r td|j|\}}|j}|j j d}|jD]T\}}|d|||dzdz}||vr|||zj|||<3||xx|||zj|z cc<V|S)Nrz$Cannot drop only generator to groundr) r9rjrrprr5r3r6 mul_ground)rrrr9rrrmons r8rzPolyElement.drop_to_ground-s 99??a CD D&&s+4yykkq! NN, ?LE5)eAaCDk)C$ %(]66u=S S c58m77>>  ? r:crt||jjdz |jjSr)rr9rjr5rs r8to_densezPolyElement.to_dense>s(T499??1#4dii6F6FGGr:ct|Sr[)rGrs r8to_dictzPolyElement.to_dictAs Dzr:c6|s/|j|jjjS|d}|d}|j}|j}|j } |j } g} |jD]Y\} } |jj| }|rdnd}| j|| | k(r*|j| }|rV|jdrE|dd}n?|r| } | |jjjk7r|j| |d}nd }g}t| D]{}| |}|s |j|||d}|dk7rA|t|k7s|d kr|j||d }n|}|j|||fzh|jd |z}|r|g|z}| j|j|\| d d vr(| j!d }|dk(r| j#d dd j| S)NMulAtom -  + -rT)strictrFz%s)r|r{)_printr9r5rrrjrr< is_negativerrr parenthesizerrijoinpopinsert)rprinter precedence exp_pattern mul_symbolprec_mul prec_atomr9rrjzmsexpvsrrnegativesignscoeffsexpvrrrsexpheads r8r]zPolyElement.strDs>>$))"2"2"7"78 8e$v& yy,,  __::< 2KD%{{..u5H$5%D MM$ rz . 1 1# 6#ABZF"FEDII,,000$11%$1OFFE5\ 01g --gaj)D-Q!8c#h#'&33C53Q"LL~!=>LL/ 05( MM*//%0 1? 2@ !9 &::a=Du} a%wwvr:c2||jjvSr[)r9rrs r8 is_generatorzPolyElement.is_generatortstyy****r:c\| xs(t|dk(xr|jj|vSr)rzr9rrs r8rmzPolyElement.is_groundxs+xLCINKtyy/C/Ct/KLr:cJ| xst|dk(xr|jdk(Sr)rzLCrs r8 is_monomialzPolyElement.is_monomial|s$x.?u3u:??re itermonomsrs r8 is_linearzPolyElement.is_linear? ???r:cBtd|jDS)Nc38K|]}t|dkyw)Nrrs r8raz+PolyElement.is_quadratic..rrrrs r8 is_quadraticzPolyElement.is_quadraticrr:cf|jjsy|jj|SNT)r9rj dmp_sqf_prs r8 is_squarefreezPolyElement.is_squarefrees%vv||vv""r:cf|jjsy|jj|Sr)r9rjdmp_irreducible_prs r8is_irreduciblezPolyElement.is_irreducibles%vv||vv''**r:cz|jjr|jj|Std)Nzcyclotomic polynomial)r9r dup_cyclotomic_pr%rs r8 is_cyclotomiczPolyElement.is_cyclotomics0 66  66**1- --.EF Fr:cx|j|jDcgc] \}}|| f c}}Scc}}wr[)rr6)rrrs r8__neg__zPolyElement.__neg__s0xxdnn>NPleU55&/PQQPs6 c|Sr[rYrs r8__pos__zPolyElement.__pos__s r:cx|s|jS|j}|j|rc|j}|j}|jj }|j D]\}}||||z}|r|||<||=|St|trt|jtr$|jj|jk(rn^t|jjtr4|jjj|k(r|j|StS |j|}|j}|s|S|j} | |jvr||| <|S|||  k(r|| =|S|| xx|z cc<|S#t$r tcYSwxYw)aAdd 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 )rr9rrr5rrIr\rr__radd__r]rrrVr") rRrSr9rrrrJrKcp2rs r8__add__zPolyElement.__add__s779 ww ??2  A%%C;;##D  14L1$AaD!   H K ($++~64;;;K;Krww;VBGGNNN;@S@SW[@[{{2&%% //"%C AB"" H !B%<"HbESLEH "! ! "sF''F98F9c|j}|s|S|j} |j|}|j}||j vr|||<|S||| k(r||=|S||xx|z cc<|S#t $r t cYSwxYwr[)rr9rrrVr"r])rRr rr9rs r8rzPolyElement.__radd__s GGIHww "AB"" H 2;"HbEQJEH "! ! "sA55BBcp|s|jS|j}|j|rc|j}|j}|jj }|j D]\}}||||z }|r|||<||=|St|trt|jtr$|jj|jk(rn^t|jjtr4|jjj|k(r|j|StS |j|}|j}|j}||jvr| ||<|S|||k(r||=|S||xx|zcc<|S#t$r tcYSwxYw)a.Subtract 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 )rr9rrr5rrIr\rr__rsub__r]rrrVr") rRrSr9rrrrJrKrs r8__sub__zPolyElement.__sub__s 779 ww ??2  A%%C;;##D  14L1$AaD!   H K ($++~64;;;K;Krww;VBGGNNN;@S@SW[@[{{2&%% $B AB"" H 2;"HbERKEH "! ! "sF##F54F5c|j} |j|}|j}|D] }|| ||< ||z }|S#t$r tcYSwxYw)a#n - 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 )r9rrr"r])rRr r9rrs r8rzPolyElement.__rsub__Esnww "A A $d8)$ $ FAH "! ! "sAAAc|j}|j}|r|s|S|j|r|j}|jj}|j }t |j}|jD]*\}} |D] \} } ||| } || || | zz|| <",|j|St|trt|jtr$|jj|jk(rn^t|jjtr4|jjj|k(r|j|StS |j|}|jD]\}} | |z} | s| ||<|S#t$r tcYSwxYw)a!Multiply 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 )r9rrrr5rrCrIrOr\rr__rmul__r]rr")rRrSr9rrrrp2itexp1v1exp2v2rrKs r8__mul__zPolyElement.__mul__as ww IIH __R %%C;;##D,,L #DHHJ 4b $4HD"&tT2C d^be3AcF4 4 LLNH K ($++~64;;;K;Krww;VBGGNNN;@S@SW[@[{{2&%% $BHHJ brEAdG H "! ! "s3F++F=<F=c|jj}|s|S |jj|}|jD]\}}||z}|s|||<|S#t$r t cYSwxYw)ap2 * 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 )r9rrrIr"r])rRrSrrrrKs r8rzPolyElement.__rmul__s GGLLH ""2&BHHJ brEAdG H "! ! "sAA0/A0ct|tstd|z|dkrtd|z|j}|s|r |j Stdt |dk(rut|jd\}}|j}||jj k(r|||j||<|S||z||j||<|St|}|dkr td|dk(r|jS|dk(r|jS|dk(r||jzSt |d kr|j|S|j|S) a(raise 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 %srz/exponent must be a non-negative integer, got %sz0**0rzNegative exponentr)r\ri TypeErrorrr9rrzrCrIrr5rrsquare_pow_multinomial _pow_generic)rr r9rrrs r8__pow__zPolyElement.__pow__sa!S!AAEF F UNQRRS Syyxx (( Y!^ -a0LE5 A '16$##E1-.H27$##E1-.H F q501 1 !V99;  !V;;= !V % % Y!^((+ +$$Q' 'r:c|jj}|} |dzr||z}|dz}|s |S|j}|dz}*)Nrr)r9rr)rr rrTs r8rzPolyElement._pow_genericsX IIMM 1uaCQ  AQAr:ctt||j}|jj}|jj }|j}|jj j}|jj}|D]g\}} |} | } t||D]\} \} }| s || | | } | || zz} t| } | }|j| ||z}|r||| <`| |vse|| =i|Sr[) rrzrIr9rrr5rrHryr)rr  multinomialsrrr<rr multinomialmultinomial_coeff product_monom product_coeffrrrs r8rzPolyElement._pow_multinomials /D 1=CCE ))33YY))  yy$$yy~~.: *K*&M-M'*;'> 0#^eU$3M5#$NM!UCZ/M 0 -(E!EHHUD)E1E#U $K# & r:c0|j}|j}|j}t|j }|j j}|j }tt|D]?}||}||} t|D]%} || } ||| } || || || zz|| <'A|jd}|j}|jD] \} }|| | } || ||dzz|| <"|j|S)asquare 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) r9rrrCrVr5rrrzimul_numrIrO)rr9rrrVrrrk1pkjk2rrJrKs r8rzPolyElement.squaresyy IIeeDIIK {{(( s4y! 6AaBbB1X 6!W"2r*S$"T"X+5# 6 6 JJqMeeJJL )DAqa#BDMAqD(AbE ) r:cb|j}|s td|j|r|j|St |t rt |j tr$|j j|jk(rn^t |jj tr4|jj j|k(r|j|StS |j|}|j||j|fS#t$r tcYSwxYwNpolynomial division)r9ZeroDivisionErrorrrr\rr5r __rdivmod__r]r quo_ground rem_groundr"rRrSr9s r8 __divmod__zPolyElement.__divmod__:sww#$9: : __R 66":  K ($++~64;;;K;Krww;VBGGNNN;@S@SW[@[~~b))%% :$BMM"%r}}R'89 9 "! ! "s)DD.-D.c|j} |j|}|j|S#t$r tcYSwxYwr[)r9rrr"r]rs r8rzPolyElement.__rdivmod__PEww $B66":  "! ! "0AAc@|j}|s td|j|r|j|St |t rt |j tr$|j j|jk(rn^t |jj tr4|jj j|k(r|j|StS |j|}|j|S#t$r tcYSwxYwr) r9rrremr\rr5r__rmod__r]rrr"rs r8__mod__zPolyElement.__mod__Ysww#$9: : __R 66":  K ($++~64;;;K;Krww;VBGGNNN;@S@SW[@[{{2&%% %$B==$ $ "! ! ")D DDc|j} |j|}|j|S#t$r tcYSwxYwr[)r9rrr"r]rs r8rzPolyElement.__rmod__orrc@|j}|s td|j|r|j|St |t rt |j tr$|j j|jk(rn^t |jj tr4|jj j|k(r|j|StS |j|}|j|S#t$r tcYSwxYwr) r9rrquor\rr5r __rtruediv__r]rrr"rs r8 __floordiv__zPolyElement.__floordiv__xsww#$9: : __R 66":  K ($++~64;;;K;Krww;VBGGNNN;@S@SW[@[r**%% %$B==$ $ "! ! "rc|j} |j|}|j|S#t$r tcYSwxYwr[)r9rrr"r]rs r8 __rfloordiv__zPolyElement.__rfloordiv__rrc@|j}|s td|j|r|j|St |t rt |j tr$|j j|jk(rn^t |jj tr4|jj j|k(r|j|StS |j|}|j|S#t$r tcYSwxYwr) r9rrexquor\rr5rrr]rrr"rs r8 __truediv__zPolyElement.__truediv__sww#$9: : __R 88B<  K ($++~64;;;K;Krww;VBGGNNN;@S@SW[@[r**%% %$B==$ $ "! ! "rc|j} |j|}|j|S#t$r tcYSwxYwr[)r9rr r"r]rs r8rzPolyElement.__rtruediv__sEww $B88B<  "! ! "rc|jj|jj}|j|jj|j r fd}|Sfd}|S)NcV|\}}|\}}| k(r|}n ||}| |||fSyr[rY a_lm_a_lc b_lm_b_lca_lma_lcb_lmb_lcr domain_quorrs r8term_divz'PolyElement._term_div..term_divsH& d& d2: E(t4E$ *T4"888r:c`|\}}|\}}| k(r|}n ||}|||zs |||fSyr[rYrs r8rz'PolyElement._term_div..term_divsM& d& d2: E(t4E  *T4"888r:)r9rr5rrrD)rr5rrrrs @@@r8 _term_divzPolyElement._term_divsX YY ! !!!ZZ yy-- ?? 0 r:c|j}d}t|trd}|g}t|s t d|s(|r|j |j fSg|j fS|D]}|j|k7st dt|}t|Dcgc]}|j }}|j}|j } |j} |D cgc]} | j} } |rd}d} ||kr|| dk(rw|j}| |||f| |||| |f}|9|\}}||j||f||<|j|||| f}d} n|dz }||kr| dk(rw| s)|j}| j|||f} ||=|r|jk(r| |z } |r|s|j | fS|d| fS|| fScc}wcc} w)aUDivision 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 FTrz"self and f must have the same ringrr)r9r\rrerrrrzrrrr _iadd_monom_iadd_poly_monomr)rfvr9 ret_singlerxr`rqvrrrfxexpvs divoccurredrtermexpv1rTs r8rzPolyElement.divs8yy b+ &JB2w#$9: :yy$))++499}$ GAvv~ !EFF G G!&q *Adii * * IIK II>>#-/0r"00AKa%K1,~~'qw%(BqE%(O1LM##HE1qE--uaj9BqE**2a551"+>A"#KFAa%K1,(MM44/2dG!" 4?? " FA yy!|#!uaxq5L=+1s G!"G&c|}t|tr|g}t|s td|j}|j }|j }|j}|j }|j}|j} |j}|j} |r|D]r} || | j} | | \} }| jD](\}}||| }| ||||zz }|s||=$|||<*|j}||||f} n9| \}}||vr||xx|z cc<n|||<||=|j}||||f} |r|Sr)r\rrerr9r5rrrLTrrr6r)rGrxr9r5rrr"rltfrgtqrSrTmgcgm1c1ltmltcs r8rzPolyElement.rem#sz  a %A1v#$9: :vv{{(( II;;=dd FFHee &c144(>DAq"#++-'B)"a0 T]QrT1! !"$&AbE '..*C!1S6k &"S!8cFcMF AcFcFnn&?qv+C58r:c*|j|dSNr)r)rxr*s r8rzPolyElement.quoPsuuQx{r:cJ|j|\}}|s|St||r[)rr$)rxr*qr"s r8r zPolyElement.exquoSs(uuQx1H%a+ +r:c||jjvr|j}n|}|\}}|j|}||||<|S||z }|r|||<|S||=|S)aadd 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 )r9rrr)rmccpselfrrrTs r8rzPolyElement._iadd_monom[s~8 499&& &YY[FF e JJt  9 F4L JA t  4L r:c^|}||jjvr|j}|\}}|j}|jjj }|jj }|jD](\} } || |} || || |zz} | r| || <&|| =*|S)aEadd 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 )r9rrrr5rrrI) rrSr9rRrSrTrrrrJrKkars r8rzPolyElement._iadd_poly_monoms* "" "BAffww~~""ww++ HHJ DAqa#BDMAaC'E2rF   r:c|jj||stSdkrytfd|j DS)z The leading degree in ``x`` or the main variable. Note that the degree of 0 is negative infinity (``float('-inf')``) rc3(K|] }| ywr[rYr_rrs r8raz%PolyElement.degree..7166<<' 'S$sALLN';"<=> >r:c|jj||stSdkrytfd|j DS)z The tail degree in ``x`` or the main variable. Note that the degree of 0 is negative infinity (``float('-inf')``) rc3(K|] }| ywr[rYr?s r8raz*PolyElement.tail_degree..r@rA)r9rrminrrBs @r8 tail_degreezPolyElement.tail_degreerEr:c |stf|jjzStt t t t|jS)z A tuple containing tail degrees in all variables. Note that the degree of 0 is negative infinity (``float('-inf')``) ) rr9rjryrDrKrCrHrrs r8 tail_degreeszPolyElement.tail_degreesrHr:c>|r|jj|Sy)aTLeading 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)r9rrs r8rzPolyElement.leading_expvs 99))$/ /r:cb|j||jjjSr[)rr9r5rrrs r8 _get_coeffzPolyElement._get_coeffs#xxdii..3344r:cn|dk(r%|j|jjS|jj|rct |j }t |dk(r<|d\}}||jjjk(r|j|Std|z)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 rrzexpected a monomial, got %s) rRr9rrrCr6rzr5rr)rrr<rrs r8rzPolyElement.coeffs4 a<??499#7#78 8 YY ! !' ***,-E5zQ$Qx uDII,,000??5116@AAr:cL|j|jjS)z"Returns the constant coefficient. )rRr9rrs r8rXzPolyElement.const styy3344r:c@|j|jSr[)rRrrs r8rzPolyElement.LC$st00233r:cV|j}||jjS|Sr[)rr9rrQs r8LMzPolyElement.LM(s*  " <99'' 'Kr:c|jj}|j}|r#|jjj||<|S)a 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 )r9rrr5rrrrs r8 leading_monomzPolyElement.leading_monom0s@ IINN  " ii&&**AdGr:c|j}|6|jj|jjjfS||j |fSr[)rr9rr5rrRrQs r8r)zPolyElement.LTEsN  " <II(($))*:*:*?*?@ @$//$/0 0r:cf|jj}|j}|||||<|S)aLeading 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 )r9rrrYs r8 leading_termzPolyElement.leading_termMs7 IINN  "  4jAdGr:c|jjntjturt |ddSt |fddS)Nc |dSr5rY)rs r8rqz%PolyElement._sorted..hs qr:T)rvreversec|dSr5rY)rr6s r8rqz%PolyElement._sorted..jsuQxr:)r9r6r}r|r sorted)rrXr6s `r8_sortedzPolyElement._sortedasL =IIOOE''.E C<##94H H##@$O Or:cV|j|Dcgc]\}}| c}}Scc}}w)aOrdered 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] r<)rr6_rs r8rPzPolyElement.coeffsls%0(,zz%'8:81e::: %cV|j|Dcgc]\}}| c}}Scc}}w)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)] re)rr6rrfs r8monomszPolyElement.monomss%0(,zz%'8:85!:::rgcT|jt|j|S)aOrdered 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)] )rcrCrI)rr6s r8r<zPolyElement.termss 0||D.66r:c4t|jS)z,Iterator over coefficients of a polynomial. )iterrFrs r8 itercoeffszPolyElement.itercoeffsDKKM""r:c4t|jS)z)Iterator over monomials of a polynomial. )rlrVrs r8rzPolyElement.itermonomsDIIK  r:c4t|jS)z%Iterator over terms of a polynomial. )rlrIrs r8r6zPolyElement.itertermsDJJL!!r:c4t|jS)z+Unordered list of polynomial coefficients. )rCrFrs r8 listcoeffszPolyElement.listcoeffsrnr:c4t|jS)z(Unordered list of polynomial monomials. )rCrVrs r8 listmonomszPolyElement.listmonomsrpr:c4t|jS)z$Unordered list of polynomial terms. rNrs r8 listtermszPolyElement.listtermsrrr:c||jjvr||zS|s|jy|D]}||xx|zcc<|S)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)r9rclear)rrTrs r8rzPolyElement.imul_numsO4   Q3J GGI  C cFaKF r:c|jj}|j}|j}|j D] }|||} |S)z*Returns GCD of polynomial's coefficients. )r9r5rrrm)rxr5contrrs r8rzPolyElement.contentsI{{jj\\^ $EtU#D $ r:c|j}||jjjk(r||fS||j |fS)z,Returns content and a primitive polynomial. )rr9r5rr)rxr|s r8 primitivezPolyElement.primitivesAyy{ 166==%% %!9 Q\\$'''r:c@|s|S|j|jS)z5Divides all coefficients by the leading coefficient. )rrrs r8moniczPolyElement.monicsH<<% %r:c|s|jjS|jDcgc] \}}|||zf}}}|j|Scc}}wr[)r9rr6r)rxrCrrr<s r8rrzPolyElement.mul_groundsM66;; 78{{}F|ue5%'"FFuuU|GsAc|jj}|jDcgc]\}}||||f}}}|j|Scc}}wr[)r9rrIr)rxrrf_monomf_coeffr<s r8 mul_monomzPolyElement.mul_monomsRvv** RSRYRYR[]>Ngw</9]]uuU|^sAcJ|\}}|r|s|jjS||jjk(r|j|S|jj}|j Dcgc]\}}|||||zf}}}|j |Scc}}wr[)r9rrrrrrIr)rxr&rrrrrr<s r8mul_termzPolyElement.mul_terms u66;;  aff'' '<<& &vv** XYX_X_XacDTGW</?ccuuU|ds3Bc |jj}|s td|r||jk(r|S|jr8|j }|j Dcgc]\}}||||f}}}n-|j Dcgc]\}}||zr |||zf}}}|j|Scc}}wcc}}wr)r9r5rrrDrr6r)rxrCr5rrrr<s r8rzPolyElement.quo_ground&s#$9: :AOH ??**CABPuc%m,PEP>?kkm`leUTY\]T]ueqj)`E`uuU| Q`s"B9 B? B?cj|\}}|s td|s|jjS||jjk(r|j |S|j }|j Dcgc] }||| }}|j|Dcgc]}|| c}Scc}wcc}wr)rr9rrrrr6r)rxr&rrrtr<s r8quo_termzPolyElement.quo_term6s u#$9: :66;;  aff'' '<<& &;;=-.[[]<(1d#<<uu%:Q1=q:;;=:s7B+B0 B0cb|jjjr@g}|jD]*\}}||z}||dzkDr||z }|j ||f,n'|jDcgc] \}}|||zf}}}|j |}|j |Scc}}w)Nr)r9r5is_ZZr6rrrO)rxrr<rrrs r8 trunc_groundzPolyElement.trunc_groundEs 66==  E !  - u 16>!AIE eU^,  ->?[[]L\UEueai(LELuuU|  Ms4B+c|}|j}|j}|jjj||}|j |}|j |}|||fSr[)rr9r5rr)rr,rxfcgcrs r8extract_groundzPolyElement.extract_groundYs_  YY[ YY[ffmmB' LL  LL Aqyr:c|s |jjjS|jjj}||j Dcgc] }|| c}Scc}wr[)r9r5rabsrm)rx norm_func ground_absrs r8_normzPolyElement._normesP66==%% %**JallnNUz%0NO ONsA-c,|jtSr[)rrwrs r8max_normzPolyElement.max_normlwws|r:c,|jtSr[)rrErs r8l1_normzPolyElement.l1_normorr:c@|j}|gt|z}dg|jz}|D]<}|jD]'}t |D]\}}t |||||<)>t |D] \}} | r d||<t |}td|Dr||fSg} |D]f}|j} |jD]4\} } t| |Dcgc] \}}||z }}}| | t |<6| j| h|| fScc}}w)Nrrc3&K|] }|dk( ywrrY)r_rps r8raz&PolyElement.deflate..s!!qAv!s) r9rCrjrrrryrerr6rHr)rxr*r9rUJrrrrSrpHhIrrNs r8deflatezPolyElement.deflaters@vvd1g  C N )A )%e,)DAq!a=AaD) ) ) aL DAq!  !H !q! !e8O  A AKKM $5),Q4Aa1f44#%(  $ HHQK !t 5s!D c|jj}|jD]4\}}t||Dcgc] \}}||z }}}||t |<6|Scc}}wr[)r9rr6rHry)rxrrrrrrrs r8inflatezPolyElement.inflatesbvv{{  #HAu"%a)-$!Q!A#-A-"DqN # .sA cZ|}|jj}|js8|j\}}|j\}}|j ||}||zj |j |}|js|jS|jSr[) r9r5rDr~rrrrrr)rr,rxr5rrrTrs r8rzPolyElement.lcms KKMEBKKMEB 2r"A qSIIaeeAh <<? "779 r:c*|j|dSr5) cofactorsrxr,s r8rzPolyElement.gcds{{1~a  r:c |s|s|jj}|||fS|s|j|\}}}|||fS|s|j|\}}}|||fSt|dk(r|j |\}}}|||fSt|dk(r|j |\}}}|||fS|j |\}\}}|j |\}}}|j||j||j|fSr)r9r _gcd_zerorz _gcd_monomr_gcdr)rxr,rrcffcfgrs r8rzPolyElement.cofactorss66;;Dt# #++a.KAsCc3; ++a.KAsCc3;  Vq[,,q/KAsCc3;  Vq[,,q/KAsCc3; IIaL 6AqffQi 3 ! ckk!nckk!n==r:c|jj|jj}}|jr|||fS| || fSr[)r9rrr)rxr,rrs r8rzPolyElement._gcd_zeros@FFJJ T  dC< 2tcT> !r:c B|j}|jj}|jj}|j}|j }t |jd\}}||} } |jD]\} } || | } || | } |j| | fg} |j||| ||| fg}|j|jD cgc]\} } || | || | fc} } }| ||fScc} } wr5) r9r5rrrrrCr6r)rxr,r9 ground_gcd ground_quorrmfcf_mgcd_cgcdr.r/rrrs r8rzPolyElement._gcd_monomsvv[[__ [[__ (( ** akkm$Q'B2ukkm *FB +Eub)E * EEE5>" #eemB. 2u0EFGHeeUVU`U`Ubc62rmB. 2u0EFcd#s{ds2D c|j}|jjr|j|S|jjr|j |S|j ||Sr[)r9r5is_QQ_gcd_QQr_gcd_ZZ dmp_inner_gcd)rxr,r9s r8rzPolyElement._gcdsTvv ;;  99Q<  [[  99Q< %%a+ +r:ct||Sr[rrs r8rzPolyElement._gcd_ZZsa|r:cx|}|j}|j|jj}|j \}}|j \}}|j |}|j |}|j |\}}} |j |}|j|j}} |j |j|jj| |}| j |j|jj| |} ||| fS)Nr) r9rr5rFrLr=rrrrrr) rr,rxr9r;rr/rrrrTs r8rzPolyElement._gcd_QQs vv::T[[%9%9%;:< A A JJx  JJx iil 3 JJt ttQWWY1ll4 ++DKKOOAr,BCll4 ++DKKOOAr,BC#s{r:c<|}|j}|s||jfS|j}|jr |js|j |\}}}n|j |j}|j\} }|j\} }|j|}|j|}|j |\}}}|jj | | \}} } |j|}|j|}|j| }|j| }|j} | |jk(r ||fS| |j k(r | | }}||fS|j| }|j| }||fS)a 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) r9rr5rDrErrrFrLr=rrcanonical_unit) rr,rxr9r5rfrr7r;cqcpus r8cancelzPolyElement.cancels~ vvdhh; F$9$9kk!nGAq!zz):z;HNN$EBNN$EB 8$A 8$Akk!nGAq! 11"b9IAr2 4 A 4 A R A R A      ? !t 6::+ 2rqA !t  QA QA!t r:cd|jj}|j|jSr[)r9r5rr)rxr5s r8rzPolyElement.canonical_unit6 s$$$QTT**r:c|j}|j|}|j|}|j}|j D]7\}}||s |j ||}|j |||z||<9|S)a!Computes 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 )r9rrrr6rr) rxrCr9rrSr,rres r8diffzPolyElement.diff: svv JJqM    " II;;= 6KD%Aw&&tQ/uT!W}5! 6r:c$dt|cxkr|jjkr;nn8|jt t |jj |Std|jjdt|)Nrz expected at least 1 and at most z values, got )rzr9rjevaluaterCrHr3r)rxrFs r8r'zPolyElement.__call__S sb s6{ *affll *::d3qvv{{F#;<= =TUTZTZT`T`beflbmno or:c|}t|tr\|Z|d|ddc\}}}|j||}|s|S|Dcgc]\}}|j||f}}}|j|S|j}|j |}|j j|}|jdk(r=|j j}|jD]\\} } || || zzz }|S|j|j} |jD]@\} } | || d|| |dzdz} } | || zz} | | vr| | | z} | r| | | <5| | =9| s<| | | <B| Scc}}w)Nrr) r\rCrrr9rr5rrjrr6) rrCrorxXYr9rresultr rrrs r8rzPolyElement.evaluateY s  a 19!aeIFQA 1a A346!Qqvvay!n66zz!}$vv JJqM KK   " ::?[[%%F {{} % e%1*$ %M99Q<$$D ! , u 8U2AYqst%<5ad D=!DK/E&+U  K&+U  ,KA7sE#cT|}t|tr ||D]\}}|j||}|S|j}|j |}|j j |}|jdk(rL|j j}|jD]\\}} || ||zzz }|j|S|j} |jD]C\} } | || d|dz| |dzdz} }| ||zz} | | vr| | | z} | r| | | <8| | =<| s?| | | <E| S)Nrrl) r\rCsubsr9rr5rrjrr6r) rrCrorxrr9rrr rrrs r8rzPolyElement.subs sO  a 19 !1FF1aL !Hvv JJqM KK   " ::?[[%%F {{} % e%1*$ %??6* *99D ! , u 8U2AY%5acd %C5ad D=!DK/E&+U  K&+U  ,Kr:c||j}|j}|j}|s||jgfSt |Dcgc]}|j |dzc}ifd}t t |dz }t t |dd}|j}|rd\} } } t|jD]E\}\} tfd|Dstdt|D} | | kDs@| | } } } G| dk7r| | c} nnwg}tddd zD]\}}|j||z ||jt|| z }| }t|D]\}}||||z}||z}|rt t|j}|||fScc}w) aX 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 rc8||fvr ||z||f<||fSr[rY)rr  poly_powersrUs r8get_poly_powerz.PolyElement.symmetrize..get_poly_power s41v[(&+Ahk QF#1v& &r:rr)rNNc3:K|]}||dzk\ywrrY)r_rrs r8raz)PolyElement.symmetrize.. s"AAuQx5Q</Asc3,K|] \}}||zywr[rY)r_r rSs r8raz)PolyElement.symmetrize.. s EA1 EsNrl)rr9rjrrr!rCrr<rerwrHrrryr3)rrxr9r rrrweights symmetric_height_monom_coeffrheight exponentsr0m2productrrrrUs @@@r8 symmetrizezPolyElement.symmetrize sv IIKvv JJdii# #388E5AAA EWe1D EEF'28%  G"}%v uIeU12Y%56 *B  b) * uY'7? ?IG!), 01>!Q// 0 LA14s499e,-!W$$S=s F9c |j}|j}tt|jt |j  |||fg}nVt|tr t|}n:t|trt|j fd}n tdt|D]!\}\}} ||j|f||<#|jD]]\}} t|}|j} |D]\} }|| dc} || <| s| || zz} | j!t#|| f} || z }_|S)Nc|dSr5rY)rJgens_maps r8rqz%PolyElement.compose..$ sx!~r:ruz9expected a generator, value pair a sequence of such pairsr)r9rrGrHr3rrjr\rCrbrIrrrr6rrry)rxrCror9r replacementsrJr,rrsubpolyrr rs @r8rzPolyElement.compose sDvvyyDIIuTZZ'89: =F8L!T"#Aw At$%aggi5MN  !\]]"<0 >IAv1'{DMM!,<=LO >KKM LE5KEhhG$ $1#Ah 58q!tOG $ &&e e'<=G GOD  r:c|}|jj|}|jDcgc]\}}|||k(s||f}}}|s|jjSt |\}} |Dcgc]}|d|dz||dzdz}}|jj t t || Scc}}wcc}w)aU 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 Nrlr)r9rr6rrHrJrG) rrCdegrrrSrTr<rirPs r8 coeff_wrtzPolyElement.coeff_wrt9 sT  FFLLO$%KKMADAqQqTS[!QAA66;; e4:;q!BQ%$,1q56*;;vvS%8 9::B >> 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 rrrr9rrDrrr3)rr,rCrxdfdgr"drrlc_gxplc_rrRr*rTs r8premzPolyElement.premn sl  FFLLO XXa[ XXa[ 6#$9: :22 7H GaK{{1b! VV[[^;;q"%D7AEqADAD2q5 AAA!BBw AI1u r:c|}|jj|}|j|}|j|}|dkr td|||}}}||kr||fS||z dz} |j ||} |jj |} |j ||} ||z | dz } } || z}|| | | zzz}|| z}|| z| | zz}||z }|j|}||krnY| | z}||z}||z}||fS)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. rrrr)rr,rCrxrrr7r"rrrrrrQrr*rTs r8pdivzPolyElement.pdiv s8`  FFLLO XXa[ XXa[ 6#$9: :ab1 7a4K GaK{{1b! VV[[^;;q"%D7AEqADAT2q5L ADAD2q5 AAA!BBw%( !G E E!t r:c0|}|j||dS)aW 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)rr,rCrxs r8pquozPolyElement.pquoG s6 vva|Ar:cd|}|j||\}}|jr|St||)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 )rrr$)rr,rCrxr7r"s r8pexquozPolyElement.pexquoe s5: vva|1 99H%a+ +r:c|}|jj|}|j|}|j|}||kr||}}||}}|dk(rddgS|dk(r|dgS||g}||z }d|dzz}|j||} | |z} |j ||} | |z} d| g} | } | r| j|} |j | || | || z f\}}}}| | |zz}|j||} | j |} |j || } |dkDr | |z}| |dz z}|j |} n| } | j | | r|S)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] rrr)r9rrDrrrr )rr,rCrxr rSrdrprlcrTSrJrr7s r8 subresultantszPolyElement.subresultants sD  FFLLO HHQK HHQK q5aqAaqA 6q6M 6q6M F E QUO FF1aL E[[A  !G F B A HHQKAq!a%JAq!Qa1f Aq! A AQ"B1uSQJ!a%LGGAJC HHaRL'*r:c:|jj||Sr[)r9dmp_half_gcdexrs r8 half_gcdexzPolyElement.half_gcdex svv$$Q**r:c:|jj||Sr[)r9 dmp_gcdexrs r8gcdexzPolyElement.gcdex vv1%%r:c:|jj||Sr[)r9 dmp_resultantrs r8 resultantzPolyElement.resultant svv##Aq))r:c8|jj|Sr[)r9dmp_discriminantrs r8 discriminantzPolyElement.discriminant svv&&q))r:cz|jjr|jj|Std)Nzpolynomial decomposition)r9r  dup_decomposer%rs r8 decomposezPolyElement.decompose s0 66  66''* *-.HI Ir:c||jjr|jj||Std)Nzshift: use shift_list instead)r9r  dup_shiftr%rxros r8shiftzPolyElement.shift s2 66  66##Aq) )-.MN Nr:c:|jj||Sr[)r9 dmp_shiftrs r8 shift_listzPolyElement.shift_list rr:cz|jjr|jj|Std)Nzsturm sequence)r9r  dup_sturmr%rs r8sturmzPolyElement.sturm s0 66  66##A& &-.>? ?r:c8|jj|Sr[)r9 dmp_gff_listrs r8gff_listzPolyElement.gff_list vv""1%%r:c8|jj|Sr[)r9dmp_normrs r8normzPolyElement.norm svvq!!r:c8|jj|Sr[)r9 dmp_sqf_normrs r8sqf_normzPolyElement.sqf_norm rr:c8|jj|Sr[)r9 dmp_sqf_partrs r8sqf_partzPolyElement.sqf_part rr:c<|jj||S)N)re)r9 dmp_sqf_list)rxres r8sqf_listzPolyElement.sqf_list svv""1#"..r:c8|jj|Sr[)r9dmp_factor_listrs r8 factor_listzPolyElement.factor_list svv%%a((r:r[)F)r~r"r#r$r+r1rr4rrrrr=r@r?rLrOrrrWr[r_rardrfrhrkrrprrurwr]r&rrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr r rrrrrr rrrDrGrLrNrrRrrXrrWrZr)r]rcrPrir<rmrr6rtrvrxrrr~rrrrrrrrrrrrrrrrrrrrrrrrrrr'rrrrrrrrrrrrr r rrrrrr r#r&r)r, __classcell__)rs@r8rrJsP? K/%3 E 8> =M" 44G0)"  2*>"H.`++MM==55558888**11@@@@## ++ GG R4l(4l82h:4(l :#J:,%,%,%, BJX+Z,*X#J= ?= ?(5#BJ544*11( P;4;474#!"#!"!F (&  <$J PB !>," ,*6p+2p *X%Nk%Z@3;jYv||<#,JXz+&**J O &@ &"&&/)r:rN)r6zMonomialOrder | str)Qr$ __future__roperatorrrrrrr functoolsr typesr sympy.core.cacher sympy.core.exprr sympy.core.intfuncrsympy.core.symbolrrrdsympy.core.sympifyrrsympy.ntheory.multinomialrsympy.polys.compatibilityrsympy.polys.constructorrsympy.polys.densebasicrrrsympy.polys.domains.domainr!sympy.polys.domains.domainelementr"sympy.polys.domains.polynomialringrsympy.polys.heuristicgcdrsympy.polys.monomialsrsympy.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/r9r<r@rVrgr2rGrrYr:r8rHs"--$ #93>,4CC-;=+-466GG==3+1)58!!<!$<!$<22h @CCL N')-+tN')r: