+
    ig                       R t ^ RIHt ^ RIHt ^ RIHtHt ^ RIH	t	 ^ RI
Ht ^ RIHtHt ^ RIHt ]'       d   ^ RIHtHt ^ R	IHt ^ R
IHt ^ RIHtHt R R lt ! R R4      tR R ltR R ltR R lt ! R R4      tR# )z
Puiseux rings. These are used by the ring_series module to represented
truncated Puiseux series. Elements of a Puiseux ring are like polynomials
except that the exponents can be negative or rational rather than just
non-negative integers.
)annotationsQQ)PolyRingPolyElement)Add)Mul)gcdlcm)TYPE_CHECKING)AnyUnpack)Expr)Domain)IterableIteratorc               $    V ^8  d   QhRRRRRR/# )   symbolsstr | list[Expr]domainr   returnz3tuple[PuiseuxRing, Unpack[tuple[PuiseuxPoly, ...]]] )formats   "Q/var/www/html/photoedit/myenv/lib/python3.14/site-packages/sympy/polys/puiseux.py__annotate__r   '   s$      '-8    c                @    \        W4      pV3VP                  ,           # )a;  Construct a Puiseux ring.

This function constructs a Puiseux ring with the given symbols and domain.

>>> from sympy.polys.domains import QQ
>>> from sympy.polys.puiseux import puiseux_ring
>>> R, x, y = puiseux_ring('x y', QQ)
>>> R
PuiseuxRing((x, y), QQ)
>>> p = 5*x**QQ(1,2) + 7/y
>>> p
7*y**(-1) + 5*x**(1/2)
)PuiseuxRinggens)r   r   rings   && r   puiseux_ringr!   '   s      w'D7TYYr   c                      ] tR t^;tRtR R ltR R ltR R ltR R	 ltR
 R lt	R R lt
R R ltR R ltR R ltR R ltRtR# )r   aT  Ring of Puiseux polynomials.

A Puiseux polynomial is a truncated Puiseux series. The exponents of the
monomials can be negative or rational numbers. This ring is used by the
ring_series module:

>>> from sympy.polys.domains import QQ
>>> from sympy.polys.puiseux import puiseux_ring
>>> from sympy.polys.ring_series import rs_exp, rs_nth_root
>>> ring, x, y = puiseux_ring('x y', QQ)
>>> f = x**2 + y**3
>>> f
y**3 + x**2
>>> f.diff(x)
2*x
>>> rs_exp(x, x, 5)
1 + x + 1/2*x**2 + 1/6*x**3 + 1/24*x**4

Importantly the Puiseux ring can represent truncated series with negative
and fractional exponents:

>>> f = 1/x + 1/y**2
>>> f
x**(-1) + y**(-2)
>>> f.diff(x)
-1*x**(-2)

>>> rs_nth_root(8*x + x**2 + x**3, 3, x, 5)
2*x**(1/3) + 1/12*x**(4/3) + 23/288*x**(7/3) + -139/20736*x**(10/3)

See Also
========

sympy.polys.ring_series.rs_series
PuiseuxPoly
c                    V ^8  d   QhRRRR/# )r   r   r   r   r   r   )r   s   "r   r   PuiseuxRing.__annotate__`   s     3 3 0 3& 3r   c                	   \        W4      pVP                  pVP                  pW0n        W n        VP                  V n        \        VP                   Uu. uF  qPP                  V4      NK  	  up4      V n        W@n        V P                  VP                  4      V n        V P                  VP                  4      V n	        VP                  V n
        VP                  V n        R # u upi N)r   r   ngens	poly_ringr   tupler   	from_polyzeroone
zero_monommonomial_mul)selfr   r   r(   r'   gs   &&&   r   __init__PuiseuxRing.__init__`   s    W-	!!" ((innEn>>!,nEF	
NN9>>2	>>)--0#..%22 Fs   C#c                   V ^8  d   QhRR/# r   r   strr   )r   s   "r   r   r$   t   s     = =# =r   c                	<    R V P                    RV P                   R2# )zPuiseuxRing(z, ))r   r   r/   s   &r   __repr__PuiseuxRing.__repr__t   s    dll^2dkk]!<<r   c                    V ^8  d   QhRRRR/# r   otherr   r   boolr   )r   s   "r   r   r$   w   s     M MC MD Mr   c                	    \        V\        4      '       g   \        # V P                  VP                  8H  ;'       d    V P                  VP                  8H  # r&   )
isinstancer   NotImplementedr   r   r/   r=   s   &&r   __eq__PuiseuxRing.__eq__w   s=    %--!!||u}},LL1LLr   c                    V ^8  d   QhRRRR/# )r   polyr   r   PuiseuxPolyr   )r   s   "r   r   r$   |   s     ' 'k 'k 'r   c                    \        W4      # )a
  Create a Puiseux polynomial from a polynomial.

>>> from sympy.polys.domains import QQ
>>> from sympy.polys.rings import ring
>>> from sympy.polys.puiseux import puiseux_ring
>>> R1, x1 = ring('x', QQ)
>>> R2, x2 = puiseux_ring('x', QQ)
>>> R2.from_poly(x1**2)
x**2
)rG   )r/   rF   s   &&r   r*   PuiseuxRing.from_poly|   s     4&&r   c                    V ^8  d   QhRRRR/# )r   termsdict[tuple[int, ...], Any]r   rG   r   )r   s   "r   r   r$      s     	2 	29 	2k 	2r   c                ,    \         P                  W4      # )zCreate a Puiseux polynomial from a dictionary of terms.

>>> from sympy.polys.domains import QQ
>>> from sympy.polys.puiseux import puiseux_ring
>>> R, x = puiseux_ring('x', QQ)
>>> R.from_dict({(QQ(1,2),): QQ(3)})
3*x**(1/2)
)rG   	from_dict)r/   rK   s   &&r   rN   PuiseuxRing.from_dict   s     $$U11r   c                    V ^8  d   QhRRRR/# r   nintr   rG   r   )r   s   "r   r   r$      s     	1 	1# 	1+ 	1r   c                B    V P                  V P                  V4      4      # )zCreate a Puiseux polynomial from an integer.

>>> from sympy.polys.domains import QQ
>>> from sympy.polys.puiseux import puiseux_ring
>>> R, x = puiseux_ring('x', QQ)
>>> R.from_int(3)
3
)r*   r(   r/   rR   s   &&r   from_intPuiseuxRing.from_int   s     ~~dnnQ/00r   c                    V ^8  d   QhRRRR/# )r   argr   r   r   )r   s   "r   r   r$      s     . .c .c .r   c                8    V P                   P                  V4      # )zCreate a new element of the domain.

>>> from sympy.polys.domains import QQ
>>> from sympy.polys.puiseux import puiseux_ring
>>> R, x = puiseux_ring('x', QQ)
>>> R.domain_new(3)
3
>>> QQ.of_type(_)
True
)r(   
domain_newr/   rY   s   &&r   r[   PuiseuxRing.domain_new   s     ~~((--r   c                    V ^8  d   QhRRRR/# r   rY   r   r   rG   r   )r   s   "r   r   r$      s     > >c >k >r   c                V    V P                  V P                  P                  V4      4      # )zCreate a new element from a ground element.

>>> from sympy.polys.domains import QQ
>>> from sympy.polys.puiseux import puiseux_ring, PuiseuxPoly
>>> R, x = puiseux_ring('x', QQ)
>>> R.ground_new(3)
3
>>> isinstance(_, PuiseuxPoly)
True
)r*   r(   
ground_newr\   s   &&r   ra   PuiseuxRing.ground_new   s"     ~~dnn77<==r   c                    V ^8  d   QhRRRR/# r_   r   )r   s   "r   r   r$      s     7 7C 7K 7r   c                    \        V\        4      '       d   V P                  V4      # V P                  V P	                  V4      4      # )zCoerce an element into the ring.

>>> from sympy.polys.domains import QQ
>>> from sympy.polys.puiseux import puiseux_ring
>>> R, x = puiseux_ring('x', QQ)
>>> R(3)
3
>>> R({(QQ(1,2),): QQ(3)})
3*x**(1/2)
)r@   dictrN   r*   r(   r\   s   &&r   __call__PuiseuxRing.__call__   s8     c4  >>#&&>>$.."566r   c                    V ^8  d   QhRRRR/# )r   xrG   r   rS   r   )r   s   "r   r   r$      s     " "{ "s "r   c                8    V P                   P                  V4      # )zReturn the index of a generator.

>>> from sympy.polys.domains import QQ
>>> from sympy.polys.puiseux import puiseux_ring
>>> R, x, y = puiseux_ring('x y', QQ)
>>> R.index(x)
0
>>> R.index(y)
1
)r   index)r/   ri   s   &&r   rk   PuiseuxRing.index   s     yyq!!r   )	r   r   r.   r'   r,   r(   r   r+   r-   N)__name__
__module____qualname____firstlineno____doc__r1   r9   rC   r*   rN   rV   r[   ra   rf   rk   __static_attributes__r   r   r   r   r   ;   s@    #H3(=M
'	2	1.>7 " "r   r   c               $    V ^8  d   QhRRRRRR/# r   rF   r   monomIterable[int]r   r   )r   s   "r   r   r      &     G G+ Gm G Gr   c           
         V P                   pVP                  pTP                  V P                  4        UUu/ uF  w  rEV! WA4      VbK  	  upp4      # u uppi r&   )r    monomial_divrN   rK   )rF   ru   r    divmcs   &&    r   _div_poly_monomr}      H    99D


C>>

E3q=!+EFFE   A
c               $    V ^8  d   QhRRRRRR/# rt   r   )r   s   "r   r   r      rw   r   c           
         V P                   pVP                  pTP                  V P                  4        UUu/ uF  w  rEV! WA4      VbK  	  upp4      # u uppi r&   )r    r.   rN   rK   )rF   ru   r    mulr{   r|   s   &&    r   _mul_poly_monomr      r~   r   c               $    V ^8  d   QhRRRRRR/# )r   ru   rv   rz   r   tuple[int, ...]r   )r   s   "r   r   r      s!     8 8m 8- 8O 8r   c                ~    \         ;QJ d    . R  \        W4       4       F  NK  	  5# ! R  \        W4       4       4      # )c              3  6   "   T F  w  rW,
          x  K  	  R # 5ir&   r   .0midis   &  r   	<genexpr>_div_monom.<locals>.<genexpr>   s     7VR   r)   zip)ru   rz   s   &&r   
_div_monomr      s,    57s575757s5777r   c                     ] tR t^t$ RtR]R&   R]R&   R]R&   R]R&   R	 R
 lt]R R l4       t]R R l4       t	R R lt
]R R l4       t]R R l4       t]R R l4       tR R ltR R ltR R ltR R ltR R  ltR! R" ltR# R$ lt]R% R& l4       tR' R( lt]R) R* l4       tR+ R, ltR- R. ltR/ R0 ltR1 R2 ltR3 R4 ltR5 R6 ltR7 R8 ltR9 R: lt R; R< lt!R= R> lt"R? R@ lt#RA RB lt$RC RD lt%RE RF lt&RG RH lt'RI RJ lt(RK RL lt)RM RN lt*RO RP lt+RQ RR lt,RS RT lt-RU RV lt.RW RX lt/RY RZ lt0R[ R\ lt1R] R^ lt2R_ R` lt3Rat4Rb# )crG   a  Puiseux polynomial. Represents a truncated Puiseux series.

See the :class:`PuiseuxRing` class for more information.

>>> from sympy import QQ
>>> from sympy.polys.puiseux import puiseux_ring
>>> R, x, y = puiseux_ring('x, y', QQ)
>>> p = 5*x**2 + 7*y**3
>>> p
7*y**3 + 5*x**2

The internal representation of a Puiseux polynomial wraps a normal
polynomial. To support negative powers the polynomial is considered to be
divided by a monomial.

>>> p2 = 1/x + 1/y**2
>>> p2.monom # x*y**2
(1, 2)
>>> p2.poly
x + y**2
>>> (y**2 + x) / (x*y**2) == p2
True

To support fractional powers the polynomial is considered to be a function
of ``x**(1/nx), y**(1/ny), ...``. The representation keeps track of a
monomial and a list of exponent denominators so that the polynomial can be
used to represent both negative and fractional powers.

>>> p3 = x**QQ(1,2) + y**QQ(2,3)
>>> p3.ns
(2, 3)
>>> p3.poly
x + y**2

See Also
========

sympy.polys.puiseux.PuiseuxRing
sympy.polys.rings.PolyElement
r   r    r   rF   tuple[int, ...] | Noneru   nsc               $    V ^8  d   QhRRRRRR/# )r   rF   r   r    r   r   rG   r   )r   s   "r   r   PuiseuxPoly.__annotate__  s!     0 0; 0k 0k 0r   c                	(    V P                  W!R R 4      # r&   )_new)clsrF   r    s   &&&r   __new__PuiseuxPoly.__new__  s    xxD$//r   c          
     ,    V ^8  d   QhRRRRRRRRRR	/# 
r   r    r   rF   r   ru   r   r   r   rG   r   )r   s   "r   r   r     s<     3 33 3 &	3
 #3 
3r   c                	P    V P                  W#V4      w  r#pV P                  WW44      # r&   )
_normalize_new_raw)r   r    rF   ru   r   s   &&&&&r   r   PuiseuxPoly._new  s)     ..b9R||D22r   c          
     ,    V ^8  d   QhRRRRRRRRRR	/# r   r   )r   s   "r   r   r   %  s<        &	
 # 
r   c                	`    \         P                  V 4      pWn        W%n        W5n        WEn        V# r&   )objectr   r    rF   ru   r   )r   r    rF   ru   r   objs   &&&&& r   r   PuiseuxPoly._new_raw$  s+     nnS!	
r   c                    V ^8  d   QhRRRR/# r<   r   )r   s   "r   r   r   3  s     
" 
"C 
"D 
"r   c                	^   \        V\        4      '       d\   V P                  VP                  8H  ;'       d;    V P                  VP                  8H  ;'       d    V P                  VP                  8H  # V P                  f*   V P                  f   V P                  P                  V4      # \        # r&   )r@   rG   rF   ru   r   rC   rA   rB   s   &&r   rC   PuiseuxPoly.__eq__3  s    e[))		UZZ' ( (JJ%++-( (GGuxx'
 ZZDGGO99##E**!!r   c               (    V ^8  d   QhRRRRRRRR/# )r   rF   r   ru   r   r   r   zBtuple[PolyElement, tuple[int, ...] | None, tuple[int, ...] | None]r   )r   s   "r   r   r   @  s3     / // &/ #	/
 
L/r   c                	b   Vf
   Vf   VR R 3# Ve   VP                  4        Uu. uF  p\        V^ 4      NK  	  pp\        ;QJ d%    R \        WR4       4       F  '       d   K   RM	  RM! R \        WR4       4       4      '       d   \	        W4      pR pM'\        V4      '       d   \	        W4      p\        W%4      pVEeh   VP                  4       w  pw  pVP                  4       pVe   TM^ .\        V4      ,          p	. p
. p. p\        WcW4       Fo  w  rppV^ 8X  d   \        VV4      pM\        WV4      pV
P                  VV,          4       VP                  VV,          4       VP                  VV,          4       Kq  	  \
        ;QJ d    R V 4       F  '       g   K   RM	  RM! R V 4       4      '       d   VP                  V4      pTpVe   \        V4      p\        ;QJ d    R V
 4       F  '       d   K   RM	  RM! R V
 4       4      '       d   R pM\        V
4      pWV3# u upi )Nc              3  .   "   T F  w  rW8  x  K  	  R # 5ir&   r   )r   r   r   s   &  r   r   )PuiseuxPoly._normalize.<locals>.<genexpr>K  s     ;*:28*:s   FTc              3  *   "   T F	  q^8  x  K  	  R# 5i   Nr   )r   infls   & r   r   r   b  s     3
!8
   c              3  *   "   T F	  q^8H  x  K  	  R# 5ir   r   r   rR   s   & r   r   r   j  s     *6a66r   )tail_degreesmaxallr   r}   anyr   deflatedegreeslenr	   appendinflater)   )r   rF   ru   r   ddegs	factors_dpoly_dr   monom_dns_new	monom_new
inflationsfinir   r   r0   s   &&&&              r   r   PuiseuxPoly._normalize?  s    =RZt##'+'8'8':;':!C1I':D;s;#d*:;sss;#d*:;;;&t3T&t2"5/>"&,,.IxllnG$0eqcCL6HGFIJ"%iW"FB7BABBAbAg&  q)!!"'* #G s3
3sss3
333
3D i(s*6*sss*6***6]BK <s   H,c               (    V ^8  d   QhRRRRRRRR/# )r   ru   r   dmonomr   r   r   tuple[Any, ...]r   )r   s   "r   r   r   r  s2     1 11 '1 #	1
 
1r   c                	   VeE   VeA   \         ;QJ d    . R \        WV4       4       F  NK  	  5# ! R \        WV4       4       4      # Ve?   \         ;QJ d    . R \        W4       4       F  NK  	  5# ! R \        W4       4       4      # Ve?   \         ;QJ d    . R \        W4       4       F  NK  	  5# ! R \        W4       4       4      # \         ;QJ d    . R V 4       F  NK  	  5# ! R V 4       4      # )Nc              3  L   "   T F  w  rp\        W,
          V4      x  K  	  R # 5ir&   r   r   r   r   r   s   &   r   r   -PuiseuxPoly._monom_fromint.<locals>.<genexpr>y  s      R;QZRRBGR;Q   "$c              3  H   "   T F  w  r\        W,
          4      x  K  	  R # 5ir&   r   r   s   &  r   r   r   {  s     F3EBG3Es    "c              3  <   "   T F  w  r\        W4      x  K  	  R # 5ir&   r   r   r   r   s   &  r   r   r   }  s     A.B.   c              3  8   "   T F  p\        V4      x  K  	  R # 5ir&   r   r   r   s   & r   r   r     s     0%BB%s   r   r   ru   r   r   s   &&&&r   _monom_fromintPuiseuxPoly._monom_fromintq  s     ".5R3ub;QR5R5R3ub;QRRR5F3u3EF5F5F3u3EFFF^5A#e.A5A5A#e.AAA50%05050%000r   c               (    V ^8  d   QhRRRRRRRR/# )r   ru   r   r   r   r   r   r   r   )r   s   "r   r   r     s2     < << '< #	<
 
<r   c                	   VeE   VeA   \         ;QJ d    . R \        WV4       4       F  NK  	  5# ! R \        WV4       4       4      # Ve?   \         ;QJ d    . R \        W4       4       F  NK  	  5# ! R \        W4       4       4      # Ve?   \         ;QJ d    . R \        W4       4       F  NK  	  5# ! R \        W4       4       4      # \         ;QJ d    . R V 4       F  NK  	  5# ! R V 4       4      # )Nc              3  l   "   T F*  w  rp\        W,          P                  V,           4      x  K,  	  R # 5ir&   rS   	numeratorr   s   &   r   r   +PuiseuxPoly._monom_toint.<locals>.<genexpr>  s-      @V*""RW''",--@Vs   24c              3  ^   "   T F#  w  r\        VP                  V,           4      x  K%  	  R # 5ir&   r   r   s   &  r   r   r     s%     Q>PFBR\\B.//>P   +-c              3  \   "   T F"  w  r\        W,          P                  4      x  K$  	  R # 5ir&   r   r   s   &  r   r   r     s"     Ofbbg0011s   *,c              3  L   "   T F  p\        VP                  4      x  K  	  R # 5ir&   r   r   s   & r   r   r     s     ;UrR\\**Ur   r   r   s   &&&&r   _monom_tointPuiseuxPoly._monom_toint  s     ".5 @CESU@V5 5 @CESU@V   5Qc%>PQ5Q5Qc%>PQQQ^5OEO5O5OEOOO5;U;5;5;U;;;r   c                   V ^8  d   QhRR/# )r   r   zIterator[tuple[Any, ...]]r   )r   s   "r   r   r     s     4 45 4r   c              #     "   V P                   V P                  r!V P                  P                  4        F  pV P	                  W1V4      x  K  	  R# 5i)zIterate over the monomials of a Puiseux polynomial.

>>> from sympy import QQ
>>> from sympy.polys.puiseux import puiseux_ring
>>> R, x, y = puiseux_ring('x, y', QQ)
>>> p = 5*x**2 + 7*y**3
>>> list(p.itermonoms())
[(2, 0), (0, 3)]
>>> p[(2, 0)]
5
N)ru   r   rF   
itermonomsr   )r/   ru   r   r{   s   &   r   r   PuiseuxPoly.itermonoms  s@      JJr%%'A%%a33 (s   AAc                   V ^8  d   QhRR/# )r   r   zlist[tuple[Any, ...]]r   )r   s   "r   r   r     s     ' '- 'r   c                4    \        V P                  4       4      # )z7Return a list of the monomials of a Puiseux polynomial.)listr   r8   s   &r   monomsPuiseuxPoly.monoms  s    DOO%&&r   c                   V ^8  d   QhRR/# r   r   z%Iterator[tuple[tuple[Any, ...], Any]]r   )r   s   "r   r   r     s     ! !? !r   c                	"    V P                  4       # r&   )r   r8   s   &r   __iter__PuiseuxPoly.__iter__  s      r   c                    V ^8  d   QhRRRR/# )r   ru   r   r   r   r   )r   s   "r   r   r     s          S  r   c                	t    V P                  WP                  V P                  4      pV P                  V,          # r&   )r   ru   r   rF   )r/   ru   s   &&r   __getitem__PuiseuxPoly.__getitem__  s+    !!%TWW=yyr   c                   V ^8  d   QhRR/# )r   r   rS   r   )r   s   "r   r   r     s       r   c                	,    \        V P                  4      # r&   )r   rF   r8   s   &r   __len__PuiseuxPoly.__len__  s    499~r   c                   V ^8  d   QhRR/# r   r   )r   s   "r   r   r     s      @ r   c              #     "   V P                   V P                  r!V P                  P                  4        F  w  r4V P	                  W1V4      pWT3x  K  	  R# 5i)zIterate over the terms of a Puiseux polynomial.

>>> from sympy import QQ
>>> from sympy.polys.puiseux import puiseux_ring
>>> R, x, y = puiseux_ring('x, y', QQ)
>>> p = 5*x**2 + 7*y**3
>>> list(p.iterterms())
[((2, 0), 5), ((0, 3), 7)]
N)ru   r   rF   	itertermsr   )r/   ru   r   r{   coeffmqs   &     r   r   PuiseuxPoly.iterterms  sH      JJr		++-HA$$Qr2B)O .s   AAc                   V ^8  d   QhRR/# )r   r   z!list[tuple[tuple[Any, ...], Any]]r   )r   s   "r   r   r     s     & &8 &r   c                4    \        V P                  4       4      # )z3Return a list of the terms of a Puiseux polynomial.)r   r   r8   s   &r   rK   PuiseuxPoly.terms      DNN$%%r   c                   V ^8  d   QhRR/# )r   r   r>   r   )r   s   "r   r   r     s     ! ! !r   c                .    V P                   P                  # )z7Return True if the Puiseux polynomial is a single term.)rF   is_termr8   s   &r   r  PuiseuxPoly.is_term  s     yy   r   c                   V ^8  d   QhRR/# )r   r   rL   r   )r   s   "r   r   r     s     & &3 &r   c                4    \        V P                  4       4      # )z;Return a dictionary representation of a Puiseux polynomial.)re   r   r8   s   &r   to_dictPuiseuxPoly.to_dict  r  r   c               $    V ^8  d   QhRRRRRR/# )r   rK   zdict[tuple[Any, ...], Any]r    r   r   rG   r   )r   s   "r   r   r     s$     !5 !5.!56A!5	!5r   c           	     .   ^.VP                   ,          p^ .VP                   ,          pV F[  p\        W54       UUu. uF  w  rg\        WgP                  4      NK  	  ppp\        WT4       UUu. uF  w  rv\	        Wv4      NK  	  pppK]  	  \        V4      '       g   RpM>\        ;QJ d    . R \        WC4       4       F  NK  	  5M! R \        WC4       4       4      p\        ;QJ d    R V 4       F  '       d   K   RM	  RM! R V 4       4      '       d   Rp	M\        V4      p	VP                  4        UU
u/ uF  w  rzV P                  WxV	4      V
bK  	  ppp
VP                  P                  V4      pV P                  W,W4      # u uppi u uppi u up
pi )a  Create a Puiseux polynomial from a dictionary of terms.

>>> from sympy import QQ
>>> from sympy.polys.puiseux import puiseux_ring, PuiseuxPoly
>>> R, x = puiseux_ring('x', QQ)
>>> PuiseuxPoly.from_dict({(QQ(1,2),): QQ(3)}, R)
3*x**(1/2)
>>> R.from_dict({(QQ(1,2),): QQ(3)})
3*x**(1/2)
Nc              3  ^   "   T F#  w  r\        W,          P                  4      ) x  K%  	  R # 5ir&   r   r   r{   rR   s   &  r   r   (PuiseuxPoly.from_dict.<locals>.<genexpr>  s"     Klda30011lr   c              3  *   "   T F	  q^8H  x  K  	  R# 5ir   r   r   s   & r   r   r    s     "r!Avrr   FT)r'   r   r
   denominatorminr   r)   r   itemsr   r(   rN   r   )r   rK   r    r   monmorR   r{   ru   ns_finalr   terms_prF   s   &&&          r   rN   PuiseuxPoly.from_dict  s8    S4::cDJJB47K@KDA#a'KB@),R63q9C6C  3xxEEKc#lKEEKc#lKKE3"r"333"r"""HRyHOT{{}]}813##Ah7>}]~~''0xxE44# A6 ^s    F-F7Fc                   V ^8  d   QhRR/# )r   r   r   r   )r   s   "r   r   r     s       r   c                T   V P                   pVP                  pVP                  p. pV P                  4        Ff  w  rVVP	                  V4      p. p\        V4       F#  w  rVP                  W9,          V
,          4       K%  	  VP                  \        V.VO5!  4       Kh  	  \        V!  # )a  Convert a Puiseux polynomial to :class:`~sympy.core.expr.Expr`.

>>> from sympy import QQ, Expr
>>> from sympy.polys.puiseux import puiseux_ring
>>> R, x = puiseux_ring('x', QQ)
>>> p = 5*x**2 + 7*x**3
>>> p.as_expr()
7*x**3 + 5*x**2
>>> isinstance(_, Expr)
True
)	r    r   r   r   to_sympy	enumerater   r   r   )r/   r    domr   rK   ru   r   
coeff_exprmonoms_exprir{   s   &          r   as_exprPuiseuxPoly.as_expr  s     yykk,, NN,LEe,JK!%(""7:?3 )LLZ6+67 - E{r   c                   V ^8  d   QhRR/# r4   r   )r   s   "r   r   r   	  s     % %# %r   c                	4  a	 R  R lo	V P                   pVP                  pVP                   Uu. uF  p\        V4      NK  	  pp. p\	        V P                  4       4       F  w  rgRP                  V	3R l\        WF4       4       4      pWrP                  8X  d/   V'       d   VP                  V4       KT  VP                  R4       Kg  V'       g   VP                  \        V4      4       K  VP                  V RV 24       K  	  RP                  V4      # u upi )c               $    V ^8  d   QhRRRRRR/# )r   baser5   exprS   r   r   )r   s   "r   r   *PuiseuxPoly.__repr__.<locals>.__annotate__  s!     	* 	*s 	* 	* 	*r   c                `    V^8X  d   V # V^ 8  d   \        V4      V8X  d   V  RV 2# V  RV R2# )r   z**z**(r7   )rS   )r)  r*  s   &&r   format_power*PuiseuxPoly.__repr__.<locals>.format_power  sC    axc#h#or#''s3%q))r   *c              3  L   <"   T F  w  rV'       g   K  S! W4      x  K  	  R # 5ir&   r   )r   ser-  s   &  r   r   'PuiseuxPoly.__repr__.<locals>.<genexpr>  s#      V@PTU!3a!3!3@Ps   $$1z + )
r    r   r   r5   sortedrK   joinr   r,   r   )
r/   r    r   r1  syms	terms_strru   r   	monom_strr-  s
   &        @r   r9   PuiseuxPoly.__repr__	  s    	* yykk $-1A-	"4::<0LE VD@P VVI$$Y/$$S)  U,  E7!I;!78 1 zz)$$ .s   Dc                    V ^8  d   QhRRRR/# )r   r=   rG   r   zOtuple[PolyElement, PolyElement, tuple[int, ...] | None, tuple[int, ...] | None]r   )r   s   "r   r   r   &  s     4' 4' 4'
4'r   c                   V P                   V P                  V P                  rCpVP                   VP                  VP                  rvpW68X  d   WG8X  d   W%W43# WG8X  d   TpEMVEe3   VEe.   \        ;QJ d    . R \	        WG4       4       F  NK  	  5M! R \	        WG4       4       4      p\	        W4       U	U
u. uF  w  rW,          NK  	  pp	p
\	        W4       U	Uu. uF  w  rW,          NK  	  pp	pVP                  V4      pVP                  V4      pVe?   \        ;QJ d    . R \	        W;4       4       F  NK  	  5M! R \	        W;4       4       4      pVe?   \        ;QJ d    . R \	        Wm4       4       F  NK  	  5M! R \	        Wm4       4       4      pMVeW   TpVP                  V4      pVe?   \        ;QJ d    . R \	        W84       4       F  NK  	  5M! R \	        W84       4       4      pM\VeW   TpVP                  V4      pVe?   \        ;QJ d    . R \	        Wh4       4       F  NK  	  5M! R \	        Wh4       4       4      pMQ hW68X  d   TpMVen   Vej   \        ;QJ d    . R \	        W64       4       F  NK  	  5M! R \	        W64       4       4      p\        V\        W4      4      p\        V\        W4      4      pM&Ve   Tp\        W&4      pMVe   Tp\        WS4      pMQ hW%W3# u up
p	i u upp	i )z7Bring two Puiseux polynomials to a common monom and ns.c              3  <   "   T F  w  r\        W4      x  K  	  R # 5ir&   )r
   )r   n1n2s   &  r   r   %PuiseuxPoly._unify.<locals>.<genexpr>5  s     ?vrs2{{r   c              3  6   "   T F  w  rW,          x  K  	  R # 5ir&   r   r   r{   fs   &  r   r   r@  ;       Aquur   c              3  6   "   T F  w  rW,          x  K  	  R # 5ir&   r   rB  s   &  r   r   r@  =  rD  r   c              3  6   "   T F  w  rW,          x  K  	  R # 5ir&   r   r  s   &  r   r   r@  B  rD  r   c              3  6   "   T F  w  rW,          x  K  	  R # 5ir&   r   r  s   &  r   r   r@  G  rD  r   c              3  <   "   T F  w  r\        W4      x  K  	  R # 5ir&   )r   )r   m1m2s   &  r   r   r@  N  s     H4G&"#b++4Gr   )rF   ru   r   r)   r   r   r   r   )r/   r=   poly1monom1ns1poly2monom2ns2r   rR   r>  f1r?  f2ru   s   &&             r   _unifyPuiseuxPoly._unify&  sc    "YY

DGGs"ZZehhs
,,:B_?S??S??B'*2|4|ea!''|B4'*2|4|ea!''|B4MM"%EMM"%E!AVAAVAA!AVAAVAA_BMM"%E!AVAAVAA_BMM"%E!AVAAVAA5EF$6EHC4GHEEHC4GHHE#E:e+DEE#E:e+DEEE#E2EE#E2E5U&&I 54s   7K2K8c                   V ^8  d   QhRR/# r   r   rG   r   )r   s   "r   r   r   \  s       r   c                	    V # r&   r   r8   s   &r   __pos__PuiseuxPoly.__pos__\  s    r   c                   V ^8  d   QhRR/# rV  r   )r   s   "r   r   r   _  s     I I Ir   c                	|    V P                  V P                  V P                  ) V P                  V P                  4      # r&   r   r    rF   ru   r   r8   s   &r   __neg__PuiseuxPoly.__neg___  s)    }}TYY
DJJHHr   c                    V ^8  d   QhRRRR/# r   r=   r   r   rG   r   )r   s   "r   r   r   b  s     " "S "[ "r   c                	   \        V\        4      '       d8   V P                  VP                  8w  d   \        R 4      hV P	                  V4      # V P                  P
                  p\        V\        4      '       d/   V P                  VP                  \        V4      \        4      4      # VP                  V4      '       d   V P                  V4      # \        # )z3Cannot add Puiseux polynomials from different rings)r@   rG   r    
ValueError_addr   rS   _add_groundconvert_fromr   of_typerA   r/   r=   r   s   && r   __add__PuiseuxPoly.__add__b  s    e[))yyEJJ& !VWW99U##!!eS!!##F$7$75	2$FGG^^E""##E**!!r   c                    V ^8  d   QhRRRR/# r`  r   )r   s   "r   r   r   o       " "c "k "r   c                	   V P                   P                  p\        V\        4      '       d/   V P	                  VP                  \        V4      \        4      4      # VP                  V4      '       d   V P	                  V4      # \        # r&   )	r    r   r@   rS   rd  re  r   rf  rA   rg  s   && r   __radd__PuiseuxPoly.__radd__o  f    !!eS!!##F$7$75	2$FGG^^E""##E**!!r   c                    V ^8  d   QhRRRR/# r`  r   )r   s   "r   r   r   x       " "S "[ "r   c                	   \        V\        4      '       d8   V P                  VP                  8w  d   \        R 4      hV P	                  V4      # V P                  P
                  p\        V\        4      '       d/   V P                  VP                  \        V4      \        4      4      # VP                  V4      '       d   V P                  V4      # \        # )z8Cannot subtract Puiseux polynomials from different rings)r@   rG   r    rb  _subr   rS   _sub_groundre  r   rf  rA   rg  s   && r   __sub__PuiseuxPoly.__sub__x      e[))yyEJJ& N  99U##!!eS!!##F$7$75	2$FGG^^E""##E**!!r   c                    V ^8  d   QhRRRR/# r`  r   )r   s   "r   r   r     rk  r   c                	   V P                   P                  p\        V\        4      '       d/   V P	                  VP                  \        V4      \        4      4      # VP                  V4      '       d   V P	                  V4      # \        # r&   )	r    r   r@   rS   _rsub_groundre  r   rf  rA   rg  s   && r   __rsub__PuiseuxPoly.__rsub__  sf    !!eS!!$$V%8%8EB%GHH^^E""$$U++!!r   c                    V ^8  d   QhRRRR/# r`  r   )r   s   "r   r   r     rq  r   c                	   \        V\        4      '       d8   V P                  VP                  8w  d   \        R 4      hV P	                  V4      # V P                  P
                  p\        V\        4      '       d/   V P                  VP                  \        V4      \        4      4      # VP                  V4      '       d   V P                  V4      # \        # )z8Cannot multiply Puiseux polynomials from different rings)r@   rG   r    rb  _mulr   rS   _mul_groundre  r   rf  rA   rg  s   && r   __mul__PuiseuxPoly.__mul__  rw  r   c                    V ^8  d   QhRRRR/# r`  r   )r   s   "r   r   r     rk  r   c                	   V P                   P                  p\        V\        4      '       d/   V P	                  VP                  \        V4      \        4      4      # VP                  V4      '       d   V P	                  V4      # \        # r&   )	r    r   r@   rS   r  re  r   rf  rA   rg  s   && r   __rmul__PuiseuxPoly.__rmul__  ro  r   c                    V ^8  d   QhRRRR/# r`  r   )r   s   "r   r   r     s     	" 	"S 	"[ 	"r   c                	    \        V\        4      '       d+   V^ 8  d   V P                  V4      # V P                  V) 4      # \        P
                  ! V4      '       d   V P                  V4      # \        # )    )r@   rS   	_pow_pint	_pow_nintr   rf  _pow_rationalrA   rB   s   &&r   __pow__PuiseuxPoly.__pow__  s\    eS!!z~~e,,~~uf--ZZ%%e,,!!r   c                    V ^8  d   QhRRRR/# r`  r   )r   s   "r   r   r     s     " " " "r   c                	   \        V\        4      '       dF   V P                  VP                  8w  d   \        R 4      hV P	                  VP                  4       4      # V P                  P                  p\        V\        4      '       d0   V P                  VP                  \        ^V4      \        4      4      # VP                  V4      '       d   V P                  V4      # \        # )z6Cannot divide Puiseux polynomials from different rings)r@   rG   r    rb  r  _invr   rS   r  re  r   rf  _div_groundrA   rg  s   && r   __truediv__PuiseuxPoly.__truediv__  s    e[))yyEJJ& L  99UZZ\**!!eS!!##F$7$71eb$IJJ^^E""##E**!!r   c                    V ^8  d   QhRRRR/# r`  r   )r   s   "r   r   r     s     " "# "+ "r   c                	n   \        V\        4      '       dQ   V P                  4       P                  V P                  P
                  P                  \        V4      \        4      4      # V P                  P
                  P                  V4      '       d    V P                  4       P                  V4      # \        # r&   )
r@   rS   r  r  r    r   re  r   rf  rA   rB   s   &&r   __rtruediv__PuiseuxPoly.__rtruediv__  sz    eS!!99;**499+;+;+H+HETV+WXXYY%%e,,99;**511!!r   c                    V ^8  d   QhRRRR/# r   r=   rG   r   r   )r   s   "r   r   r          > >+ >+ >r   c                	p    V P                  V4      w  r#rEV P                  V P                  W#,           WE4      # r&   rS  r   r    r/   r=   rK  rN  ru   r   s   &&    r   rc  PuiseuxPoly._add  .    "&++e"4eyyEM5==r   c                    V ^8  d   QhRRRR/# r   groundr   r   rG   r   )r   s   "r   r   r          7 7# 7+ 7r   c                	V    V P                  V P                  P                  V4      4      # r&   )rc  r    ra   r/   r  s   &&r   rd  PuiseuxPoly._add_ground       yy--f566r   c                    V ^8  d   QhRRRR/# r  r   )r   s   "r   r   r     r  r   c                	p    V P                  V4      w  r#rEV P                  V P                  W#,
          WE4      # r&   r  r  s   &&    r   rs  PuiseuxPoly._sub  r  r   c                    V ^8  d   QhRRRR/# r  r   )r   s   "r   r   r     r  r   c                	V    V P                  V P                  P                  V4      4      # r&   )rs  r    ra   r  s   &&r   rt  PuiseuxPoly._sub_ground  r  r   c                    V ^8  d   QhRRRR/# r  r   )r   s   "r   r   r     s     7 73 7; 7r   c                	V    V P                   P                  V4      P                  V 4      # r&   )r    ra   rs  r  s   &&r   rz  PuiseuxPoly._rsub_ground  s"    yy##F+0066r   c                    V ^8  d   QhRRRR/# r  r   )r   s   "r   r   r     s     > >+ >+ >r   c                	    V P                  V4      w  r#rEVe-   \        ;QJ d    . R V 4       F  NK  	  5M! R V 4       4      pV P                  V P                  W#,          WE4      # )Nc              3  4   "   T F  p^V,          x  K  	  R# 5i)r   Nr   )r   r2  s   & r   r   #PuiseuxPoly._mul.<locals>.<genexpr>  s     /A!a%%s   )rS  r)   r   r    r  s   &&    r   r  PuiseuxPoly._mul  sR    "&++e"4eE//EE///EyyEM5==r   c                    V ^8  d   QhRRRR/# r  r   )r   s   "r   r   r          Q Q# Q+ Qr   c                	    V P                  V P                  V P                  V,          V P                  V P                  4      # r&   r\  r  s   &&r   r  PuiseuxPoly._mul_ground  ,    }}TYY		F(:DJJPPr   c                    V ^8  d   QhRRRR/# r  r   )r   s   "r   r   r     r  r   c                	    V P                  V P                  V P                  V,          V P                  V P                  4      # r&   r\  r  s   &&r   r  PuiseuxPoly._div_ground  r  r   c                    V ^8  d   QhRRRR/# rQ   r   )r   s   "r   r   r     s     B B3 B; Br   c                	
  a S^ 8  g   Q hV P                   pVe3   \        ;QJ d    . V3R lV 4       F  NK  	  5M! V3R lV 4       4      pV P                  V P                  V P                  S,          W P
                  4      # )r  c              3  4   <"   T F  qS,          x  K  	  R # 5ir&   r   r  s   & r   r   (PuiseuxPoly._pow_pint.<locals>.<genexpr>  s     /Aa%%   )ru   r)   r   r    rF   r   )r/   rR   ru   s   &f r   r  PuiseuxPoly._pow_pint  s^    Avv

E//EE///EyyDIIqL%AAr   c                    V ^8  d   QhRRRR/# rQ   r   )r   s   "r   r   r     s     ( (3 (; (r   c                	@    V P                  4       P                  V4      # r&   )r  r  rU   s   &&r   r  PuiseuxPoly._pow_nint  s    yy{$$Q''r   c                    V ^8  d   QhRRRR/# )r   rR   r   r   rG   r   )r   s   "r   r   r     s     8 8s 8{ 8r   c                	  a V P                   '       g   \        R 4      hV P                  4       w  w  r#V P                  P                  pVP                  V4      '       g   \        R 4      h\        ;QJ d    . V3R lV 4       F  NK  	  5M! V3R lV 4       4      pV P                  P                  W$P                  /4      # )z0Only monomials can be raised to a rational powerc              3  4   <"   T F  qS,          x  K  	  R # 5ir&   r   r  s   & r   r   ,PuiseuxPoly._pow_rational.<locals>.<genexpr>  s     +U!eeUr  )	r  rb  rK   r    r   is_oner)   rN   r,   )r/   rR   ru   r   r   s   &f   r   r  PuiseuxPoly._pow_rational  s    |||OPP::<%!!}}U##OPP+U++U++yy""E::#677r   c                   V ^8  d   QhRR/# rV  r   )r   s   "r   r   r     s     	3 	3k 	3r   c                	   V P                   '       g   \        R 4      hV P                  4       w  w  rV P                  P                  pVP
                  '       g#   VP                  V4      '       g   \        R4      h\        ;QJ d    . R V 4       F  NK  	  5M! R V 4       4      p^V,          pV P                  P                  W/4      # )zOnly terms can be invertedz"Cannot invert non-unit coefficientc              3  &   "   T F  q) x  K	  	  R # 5ir&   r   )r   r{   s   & r   r   #PuiseuxPoly._inv.<locals>.<genexpr>  s     (%Qb%s   )	r  rb  rK   r    r   is_Fieldr  r)   rN   )r/   ru   r   r   s   &   r   r  PuiseuxPoly._inv  s    |||9::::<%!!v}}U';';ABB(%((%((E	yy""E>22r   c                    V ^8  d   QhRRRR/# )r   ri   rG   r   r   )r   s   "r   r   r     s      k k r   c                   V P                   pVP                  V4      p/ pV P                  4        FJ  w  rVWS,          pV'       g   K  \        V4      pW;;,          ^,          uu&   Wg,          V\	        V4      &   KL  	  V! V4      # )zDifferentiate a Puiseux polynomial with respect to a variable.

>>> from sympy import QQ
>>> from sympy.polys.puiseux import puiseux_ring
>>> R, x, y = puiseux_ring('x, y', QQ)
>>> p = 5*x**2 + 7*y**3
>>> p.diff(x)
10*x
>>> p.diff(y)
21*y**2
)r    rk   r   r   r)   )	r/   ri   r    r#  r0   expvr   rR   r2  s	   &&       r   diffPuiseuxPoly.diff  sl     yyJJqM>>+KDAqJ	#i%( , Awr   r   N)5rm   rn   ro   rp   rq   __annotations__r   classmethodr   r   rC   r   r   r   r   r   r   r   r   r   rK   propertyr  r  rN   r$  r9   rS  rX  r]  rh  rm  ru  r{  r  r  r  r  r  rc  rd  rs  rt  rz  r  r  r  r  r  r  r  r  rr   r   r   r   rG   rG      ss   'R 
!!0 3 3  
" / /b 1 1 < <"4 '! & ! !& !5 !5F0%:4'lI""""""	""">7>77>QQB(8	3 r   rG   N)rq   
__future__r   sympy.polys.domainsr   sympy.polys.ringsr   r   sympy.core.addr   sympy.core.mulr   sympy.external.gmpyr	   r
   typingr   r   r   sympy.core.exprr   r   collections.abcr   r   r!   r   r}   r   r   rG   r   r   r   <module>r     sc   & # " 3   ( ! "$*2(Y" Y"xGG8t tr   