ó
    Š*£hP£  ã                   ó�  • S r SSKJrJrJrJrJrJrJrJ	r	J
r
JrJrJrJrJrJrJrJrJrJrJrJrJr  SSKJrJrJrJrJrJrJrJ r J!r!J"r"J#r#J$r$J%r%J&r&J'r'J(r(J)r)J*r*J+r+  SSK,J-r-J.r.J/r/J0r0J1r1J2r2J3r3J4r4J5r5J6r6J7r7J8r8J9r9J:r:J;r;  SSK<J=r=J>r>  SSK?J@r@  SSKAJBrBJCrCJDrDJErEJFrF  S rGS	 rHS
 rIS rJS rKS rLS rMS rNS rOS rPS rQS rRS rSS@S jrTS rUS rVS rWS rXS rYS rZS r[S@S jr\S r]S r^S  r_S! r`S" raS# rbS$ rcS% rdS& reS' rfS( rgS)rhS* riS+ rjS, rkS- rlS. rmS/ rnS0 roS1 rpS2 rqS3 rrS4 rsS5 rtS6 ruS7 rvS8 rwS9 rxS: ryS; rzS< r{SAS= jr|SAS> jr}g?)BzEEuclidean algorithms, GCDs, LCMs and polynomial remainder sequences. é    )Údup_sub_mulÚdup_negÚdmp_negÚdmp_addÚdmp_subÚdup_mulÚdmp_mulÚdmp_powÚdup_divÚdmp_divÚdup_remÚdup_quoÚdmp_quoÚdup_premÚdmp_premÚdup_mul_groundÚdmp_mul_groundÚdmp_mul_termÚdup_quo_groundÚdmp_quo_groundÚdup_max_normÚdmp_max_norm)Ú	dup_stripÚ	dmp_raiseÚdmp_zeroÚdmp_oneÚ
dmp_groundÚ	dmp_one_pÚ
dmp_zero_pÚ	dmp_zerosÚ
dup_degreeÚ
dmp_degreeÚdmp_degree_inÚdup_LCÚdmp_LCÚdmp_ground_LCÚdmp_multi_deflateÚdmp_inflateÚdup_convertÚdmp_convertÚdmp_apply_pairs)Údup_clear_denomsÚdmp_clear_denomsÚdup_diffÚdmp_diffÚdup_evalÚdmp_evalÚdmp_eval_inÚ	dup_truncÚdmp_ground_truncÚ	dup_monicÚdmp_ground_monicÚdup_primitiveÚdmp_ground_primitiveÚdup_extractÚdmp_ground_extract©Úgf_intÚgf_crt)Úquery)ÚMultivariatePolynomialErrorÚHeuristicGCDFailedÚHomomorphismFailedÚNotInvertibleÚDomainErrorc                 óþ   • UR                   (       d  [        SU-  5      eUR                  // pCU(       a&  [        XU5      u  pVXpU[	        X5XB5      pCU(       a  M&  [        U[        X5      U5      n[        X5      n X04$ )aF  
Half extended Euclidean algorithm in `F[x]`.

Returns ``(s, h)`` such that ``h = gcd(f, g)`` and ``s*f = h (mod g)``.

Examples
========

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

>>> f = x**4 - 2*x**3 - 6*x**2 + 12*x + 15
>>> g = x**3 + x**2 - 4*x - 4

>>> R.dup_half_gcdex(f, g)
(-1/5*x + 3/5, x + 1)

z(Cannot compute half extended GCD over %s)Úis_FieldrC   Úoner   r   r   r$   r5   )ÚfÚgÚKÚaÚbÚqÚrs          ÚT/home/mande/repo/quber/.venv/lib/python3.13/site-packages/sympy/polys/euclidtools.pyÚdup_half_gcdexrO   2   sx   € ð& �:�:ÜÐDÀqÑHÓIÐIà�E‰Eˆ7�B€qæ
Ü�q˜QÓ‰ˆØˆ1Ø”+˜a AÓ)ˆ1÷ ˆ!ô
 	�qœ& ›,¨Ó*€AÜ�!‹€Aàˆ4€Kó    c                 ó>   • U(       d  [        XU5      $ [        X5      e)z…
Half extended Euclidean algorithm in `F[X]`.

Examples
========

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

)rO   r?   ©rG   rH   ÚurI   s       rN   Údmp_half_gcdexrT   U   s   € ö Ü˜a AÓ&Ð&ä)¨!Ó/Ð/rP   c                 óV   • [        XU5      u  p4[        XCX5      n[        XQU5      nX6U4$ )aS  
Extended Euclidean algorithm in `F[x]`.

Returns ``(s, t, h)`` such that ``h = gcd(f, g)`` and ``s*f + t*g = h``.

Examples
========

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

>>> f = x**4 - 2*x**3 - 6*x**2 + 12*x + 15
>>> g = x**3 + x**2 - 4*x - 4

>>> R.dup_gcdex(f, g)
(-1/5*x + 3/5, 1/5*x**2 - 6/5*x + 2, x + 1)

)rO   r   r   )rG   rH   rI   ÚsÚhÚFÚts          rN   Ú	dup_gcdexrZ   f   s3   € ô& ˜! Ó"�D€Aä�A˜!Ó€AÜ��aÓ€Aà�ˆ7€NrP   c                 ó>   • U(       d  [        XU5      $ [        X5      e)z€
Extended Euclidean algorithm in `F[X]`.

Examples
========

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

)rZ   r?   rR   s       rN   Ú	dmp_gcdexr\   �   s   € ö Ü˜˜qÓ!Ð!ä)¨!Ó/Ð/rP   c                 ól   • [        XU5      u  p4XBR                  /:X  a  [        X1U5      $ [        S5      e)a8  
Compute multiplicative inverse of `f` modulo `g` in `F[x]`.

Examples
========

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

>>> f = x**2 - 1
>>> g = 2*x - 1
>>> h = x - 1

>>> R.dup_invert(f, g)
-4/3

>>> R.dup_invert(f, h)
Traceback (most recent call last):
...
NotInvertible: zero divisor

zzero divisor)rO   rF   r   rB   )rG   rH   rI   rV   rW   s        rN   Ú
dup_invertr^   ’   s5   € ô. ˜! Ó"�D€Aà�U‰UˆGƒ|Ü�q˜QÓÐä˜NÓ+Ð+rP   c                 ó>   • U(       d  [        XU5      $ [        X5      e)z�
Compute multiplicative inverse of `f` modulo `g` in `F[X]`.

Examples
========

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

)r^   r?   rR   s       rN   Ú
dmp_invertr`   ±   s   € ö Ü˜! Ó"Ð"ä)¨!Ó/Ð/rP   c                 ó‚   • X/n[        XU5      nU(       a(  UR                  U5        Xp[        XU5      nU(       a  M(  U$ )a  
Euclidean polynomial remainder sequence (PRS) in `K[x]`.

Examples
========

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

>>> f = x**8 + x**6 - 3*x**4 - 3*x**3 + 8*x**2 + 2*x - 5
>>> g = 3*x**6 + 5*x**4 - 4*x**2 - 9*x + 21

>>> prs = R.dup_euclidean_prs(f, g)

>>> prs[0]
x**8 + x**6 - 3*x**4 - 3*x**3 + 8*x**2 + 2*x - 5
>>> prs[1]
3*x**6 + 5*x**4 - 4*x**2 - 9*x + 21
>>> prs[2]
-5/9*x**4 + 1/9*x**2 - 1/3
>>> prs[3]
-117/25*x**2 - 9*x + 441/25
>>> prs[4]
233150/19773*x - 102500/6591
>>> prs[5]
-1288744821/543589225

)r   Úappend)rG   rH   rI   ÚprsrW   s        rN   Údup_euclidean_prsrd   Â   sD   € ð: ˆ&€CÜ��aÓ€Aæ
Ø�
‰
�1ŒØˆ1Ü�A˜!Óˆ÷ ˆ!ð
 €JrP   c                 ó>   • U(       d  [        XU5      $ [        X5      e)z‘
Euclidean polynomial remainder sequence (PRS) in `K[X]`.

Examples
========

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

)rd   r?   rR   s       rN   Údmp_euclidean_prsrf   ê   ó   € ö Ü   qÓ)Ð)ä)¨!Ó/Ð/rP   c                 ó²   • X/n[        [        XU5      U5      u  pEU(       a4  UR                  U5        Xp[        [        XU5      U5      u  pEU(       a  M4  U$ )aç  
Primitive polynomial remainder sequence (PRS) in `K[x]`.

Examples
========

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

>>> f = x**8 + x**6 - 3*x**4 - 3*x**3 + 8*x**2 + 2*x - 5
>>> g = 3*x**6 + 5*x**4 - 4*x**2 - 9*x + 21

>>> prs = R.dup_primitive_prs(f, g)

>>> prs[0]
x**8 + x**6 - 3*x**4 - 3*x**3 + 8*x**2 + 2*x - 5
>>> prs[1]
3*x**6 + 5*x**4 - 4*x**2 - 9*x + 21
>>> prs[2]
-5*x**4 + x**2 - 3
>>> prs[3]
13*x**2 + 25*x - 49
>>> prs[4]
4663*x - 6150
>>> prs[5]
1

)r7   r   rb   )rG   rH   rI   rc   Ú_rW   s         rN   Údup_primitive_prsrj   û   sV   € ð: ˆ&€CÜœ !¨Ó*¨AÓ.�D€Aæ
Ø�
‰
�1ŒØˆ1ÜœX a¨AÓ.°Ó2‰ˆ÷ ˆ!ð
 €JrP   c                 ó>   • U(       d  [        XU5      $ [        X5      e)z‘
Primitive polynomial remainder sequence (PRS) in `K[X]`.

Examples
========

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

)rj   r?   rR   s       rN   Údmp_primitive_prsrl   #  rg   rP   c                 ób  • [        U 5      n[        U5      nX4:  a  XpXCpCU (       d  / / 4$ U(       d  U /UR                  /4$ X/nX4-
  nUR                  * US-   -  n[        XU5      n[        X‡U5      n[	        X5      n	X–-  n
UR                  U
/nU
* n
U(       a“  [        U5      nUR                  U5        XXÄU-
  4u  ppFU	* X¦-  -  n[        XU5      n[        X‡U5      n[	        X5      n	US:”  a  X¦S-
  -  nUR                  U	* U-  U5      n
OU	* n
UR                  U
* 5        U(       a  M“  X[4$ )aÑ  
Subresultant PRS algorithm in `K[x]`.

Computes the subresultant polynomial remainder sequence (PRS)
and the non-zero scalar subresultants of `f` and `g`.
By [1] Thm. 3, these are the constants '-c' (- to optimize
computation of sign).
The first subdeterminant is set to 1 by convention to match
the polynomial and the scalar subdeterminants.
If 'deg(f) < deg(g)', the subresultants of '(g,f)' are computed.

Examples
========

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

>>> R.dup_inner_subresultants(x**2 + 1, x**2 - 1)
([x**2 + 1, x**2 - 1, -2], [1, 1, 4])

References
==========

.. [1] W.S. Brown, The Subresultant PRS Algorithm.
       ACM Transaction of Mathematical Software 4 (1978) 237-249

é   )r!   rF   r   r   r$   rb   r   Úquo)rG   rH   rI   ÚnÚmÚRÚdrK   rW   ÚlcÚcÚSÚkrL   s                 rN   Údup_inner_subresultantsrx   4  sH  € ô8 	�1‹€AÜ�1‹€AàƒuØˆ1Øˆ1æØ�2ˆvˆæØˆs�Q—U‘U�Gˆ|Ðà	
ˆ€AØ	‰€Aà
�%‰%ˆ�1�q‘5Ñ€Aä��qÓ€AÜ�q˜QÓ€Aä	�‹€BØ
‰€Að 
�‰�ˆ
€AØ	
ˆ€Aæ
Ü�q‹MˆØ	�‰�Œà˜1 !™e�^‰
ˆˆaàˆC�!‘$‰Jˆä�Q˜1ÓˆÜ˜1 Ó#ˆä�A‹\ˆàˆq‹5Ø˜‘E‘
ˆAØ—‘˜�s˜Q‘h Ó"‰Aà�ˆAà	�‰�!�Œ÷' ˆ!ð* ˆ4€KrP   c                 ó    • [        XU5      S   $ )zÒ
Computes subresultant PRS of two polynomials in `K[x]`.

Examples
========

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

>>> R.dup_subresultants(x**2 + 1, x**2 - 1)
[x**2 + 1, x**2 - 1, -2]

r   )rx   ©rG   rH   rI   s      rN   Údup_subresultantsr{   „  s   € ô # 1¨Ó+¨AÑ.Ð.rP   c                 ó¤   • U (       a  U(       d  UR                   / 4$ [        XU5      u  p4[        US   5      S:”  a  UR                   U4$ US   U4$ )zÕ
Resultant algorithm in `K[x]` using subresultant PRS.

Examples
========

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

>>> R.dup_prs_resultant(x**2 + 1, x**2 - 1)
(4, [x**2 + 1, x**2 - 1, -2])

éÿÿÿÿr   )Úzerorx   r!   )rG   rH   rI   rr   rv   s        rN   Údup_prs_resultantr   •  sQ   € ö –AØ—‘˜ˆ|Ðä" 1¨Ó+�D€Aä�!�B‘%Ó˜1ÓØ—‘˜ˆ{ÐàˆR‰5�!ˆ8€OrP   c                 óF   • U(       a  [        XU5      $ [        XU5      S   $ )z°
Computes resultant of two polynomials in `K[x]`.

Examples
========

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

>>> R.dup_resultant(x**2 + 1, x**2 - 1)
4

r   )r   )rG   rH   rI   Ú
includePRSs       rN   Údup_resultantr‚   ®  s&   € ö Ü   qÓ)Ð)Ü˜Q 1Ó% aÑ(Ð(rP   c           	      óö  • U(       d  [        XU5      $ [        X5      n[        X5      nXE:  a  XpXTpT[        X5      (       a  / / 4$ US-
  n[        X5      (       a  U /[        UR                  U5      /4$ X/nXE-
  n[        [        UR                  * U5      US-   Xc5      n	[        XX#5      n
[        X©SX#5      n
[        X5      n[        X¸Xc5      n[        UR                  U5      U/n[        XÆU5      n[        X¢5      (       dí  [        X¢5      nUR                  U
5        XXåU-
  4u  ppX[        [        X¶U5      [        XÈXc5      Xc5      n	[        XX#5      n
U
 Vs/ s H  n[        XùXc5      PM     n
n[        X5      nUS:”  a4  [        [        X¶U5      X†U5      n[        XÈS-
  Xc5      n[        UUXc5      nO[        X¶U5      nUR                  [        XÆU5      5        [        X¢5      (       d  Mí  X}4$ s  snf )aÌ  
Subresultant PRS algorithm in `K[X]`.

Examples
========

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

>>> f = 3*x**2*y - y**3 - 4
>>> g = x**2 + x*y**3 - 9

>>> a = 3*x*y**4 + y**3 - 27*y + 4
>>> b = -3*y**10 - 12*y**7 + y**6 - 54*y**4 + 8*y**3 + 729*y**2 - 216*y + 16

>>> prs = [f, g, a, b]
>>> sres = [[1], [1], [3, 0, 0, 0, 0], [-3, 0, 0, -12, 1, 0, -54, 8, 729, -216, 16]]

>>> R.dmp_inner_subresultants(f, g) == (prs, sres)
True

rn   r   )rx   r"   r   r   rF   r
   r   r   r%   r   rb   r	   r   )rG   rH   rS   rI   rp   rq   Úvrr   rs   rK   rW   rt   ru   rv   rw   ÚchÚprL   s                     rN   Údmp_inner_subresultantsr‡   Á  sí  € ö. Ü& q¨QÓ/Ð/ä�1Ó€AÜ�1Ó€AàƒuØˆ1Øˆ1ä�!×ÑØ�2ˆvˆà	ˆA‰€AÜ�!×ÑØˆs”Z §¡ qÓ)Ð*Ð*Ð*à	
ˆ€AØ	‰€Aä”
˜AŸE™E˜6 1Ó% q¨1¡u¨aÓ3€Aä��qÓ€AÜ�Q˜1˜aÓ#€Aä	�‹€BÜ��qÓ€Aä	�A—E‘E˜1Ó	˜qÐ!€AÜ��aÓ€Aä˜×ÑÜ�qÓˆØ	�‰�Œà˜1 !™e�^‰
ˆˆaä”G˜B 1Ó%Ü˜A !Ó'¨ó/ˆô �Q˜1Ó ˆÙ-.Ó0ªQ rŒg�b˜QÖ"©QˆÐ0ä�A‹\ˆàˆq‹5Üœ  qÓ)¨1°Ó3ˆAÜ˜˜q™5 !Ó'ˆAÜ˜˜1˜aÓ#‰Aä˜˜qÓ!ˆAà	�‰”˜˜qÓ!Ô"ô+ ˜×Óð. ˆ4€Kùò 1s   ÅG6c                 ó    • [        XX#5      S   $ )al  
Computes subresultant PRS of two polynomials in `K[X]`.

Examples
========

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

>>> f = 3*x**2*y - y**3 - 4
>>> g = x**2 + x*y**3 - 9

>>> a = 3*x*y**4 + y**3 - 27*y + 4
>>> b = -3*y**10 - 12*y**7 + y**6 - 54*y**4 + 8*y**3 + 729*y**2 - 216*y + 16

>>> R.dmp_subresultants(f, g) == [f, g, a, b]
True

r   )r‡   rR   s       rN   Údmp_subresultantsr‰     s   € ô( # 1¨Ó.¨qÑ1Ð1rP   c                 óø   • U(       d  [        XU5      $ [        X5      (       d  [        X5      (       a  [        US-
  5      / 4$ [        XX#5      u  pE[	        US   U5      S:”  a  [        US-
  5      U4$ US   U4$ )aÕ  
Resultant algorithm in `K[X]` using subresultant PRS.

Examples
========

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

>>> f = 3*x**2*y - y**3 - 4
>>> g = x**2 + x*y**3 - 9

>>> a = 3*x*y**4 + y**3 - 27*y + 4
>>> b = -3*y**10 - 12*y**7 + y**6 - 54*y**4 + 8*y**3 + 729*y**2 - 216*y + 16

>>> res, prs = R.dmp_prs_resultant(f, g)

>>> res == b             # resultant has n-1 variables
False
>>> res == b.drop(x)
True
>>> prs == [f, g, a, b]
True

rn   r}   r   )r   r   r   r‡   r"   )rG   rH   rS   rI   rr   rv   s         rN   Údmp_prs_resultantr‹   (  s}   € ö4 Ü   qÓ)Ð)ä�!×Ñœ: a×+Ñ+Ü˜˜Q™“ Ð$Ð$ä" 1¨Ó.�D€Aä�!�B‘%˜Ó˜aÓÜ˜˜Q™“ Ð#Ð#àˆR‰5�!ˆ8€OrP   c           	      óÈ  • U(       d  [        [        XU5      S   U-  U5      $ US-
  n[        X5      n[        X5      n[        U SU5      n[        USU5      n	Xi-  Xx-  -   n
UR                  /UR                  * pË[        U5      n[        U5      U
::  GaL   XÄR                  -  nXÂ:X  a  [        S5      e[        U [        XÂ5      SX45      n[        Xå5      U:X  a'  [        U[        XÂ5      SX45      n[        Xõ5      U:X  a  OMm  [        XïX%U5      n[        XÜXT5      nU(       d  [        U/5      n[        U/5      nOU/nU/nUR                  [        X¼U5      U5      n[        UUU5      n[        UUSU5      n[!        U[#        UUXT5      XT5      n[%        UUXT5      n['        XÒXT5      n[)        X´R                  U* /U5      n[+        X²U5      n[        U5      U
::  a  GML  U$ )zë
Compute resultant of `f` and `g` modulo a prime `p`.

Examples
========

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

>>> f = x + y + 2
>>> g = 2*x*y + x + 3

>>> R.dmp_zz_modular_resultant(f, g, 5)
-2*y**2 + 1

r   rn   úno luck)r<   r   r"   r#   rF   r   r!   rA   r2   Údmp_zz_modular_resultantr1   r   Úinvertr0   r   r   r	   r   r   r4   r   r3   )rG   rH   r†   rS   rI   r„   rp   rq   ÚNÚMÚBÚDrJ   rM   rX   ÚGrr   Úers   ru   s                       rN   rŽ   rŽ   P  sÞ  € ö" ÜÔ'¨¨aÓ0°Ñ3°aÑ7¸Ó;Ð;à	ˆA‰€Aä�1Ó€AÜ�1Ó€Aä�a˜˜AÓ€AÜ�a˜˜AÓ€Aà	‰ˆa‰c‰	€Aà�E‰Eˆ7�Q—U‘U�F€qÜ�‹€Aä
�Q‹-˜1Ô
ØØ—‘‰JˆAà‹vÜ(¨Ó3Ð3ä˜Aœv a›|¨Q°Ó5ˆAä˜!Ó 1Ó$Ü ¤6¨!£<°°AÓ9�ä˜aÓ# qÓ(Øñ ô % Q¨1°Ó3ˆÜ�Q˜1Ó ˆæÜ˜1˜#“ˆAÜ˜1˜#“‰Aà�ˆAØ�ˆAà�H‰H”X˜a AÓ&¨Ó*ˆÜ˜1˜a Ó#ˆÜ�a˜˜A˜qÓ!ˆä�A”w˜q ! QÓ*¨AÓ1ˆÜ�A�q˜!Óˆä˜Q 1Ó(ˆä�AŸ™ ˜r�{ AÓ&ˆÜ�a˜AÓˆôG �Q‹-˜1Ö
ðJ €HrP   c                 ó8   • [        [        X/X#/U5      X#-  5      $ )z2Wrapper of CRT for Collins's resultant algorithm. r;   )rM   rr   ÚPr†   rI   s        rN   Ú_collins_crtr˜   ™  s   € ä”&˜!˜ ! ¨Ó+¨Q©SÓ1Ð1rP   c                 óì  • [        X5      n[        X5      nUS:  d  US:  a  [        US-
  5      $ [        XU5      n[        XU5      n[        XU5      n[        XU5      n	US-
  n
U" S5      UR	                  U" XE-   5      5      -  Xe-  -  Xt-  -  n[        U
5      UR
                  UR
                  pÜnSSKJn  X×::  a¤  U" U" U5      5      nXŒ-  (       a	  Xœ-  (       d$  U" U" U5      5      nXŒ-  (       d  M  Xœ-  (       d  M$  [        XX#5      n[        XX#5      n [        UUXÂU5      nUR                  U5      (       a  UnO[        UU[        XÜU4X£5      nXÜ-  nX×::  a  M¤  U$ ! [         a     M¸  f = f)zê
Collins's modular resultant algorithm in `Z[X]`.

Examples
========

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

>>> f = x + y + 2
>>> g = 2*x*y + x + 3

>>> R.dmp_zz_collins_resultant(f, g)
-2*y**2 - 5*y + 1

r   rn   é   )Ú	nextprime)r"   r   r   r&   Ú	factorialrF   Úsympy.ntheoryr›   r4   rŽ   rA   Úis_oner+   r˜   )rG   rH   rS   rI   rp   rq   ÚAr’   rJ   rK   r„   rM   r†   r—   r›   rX   r”   rr   s                     rN   Údmp_zz_collins_resultantr    ž  sj  € ô$ 	�1Ó€AÜ�1Ó€Aàˆ1ƒu��A“Ü˜˜A™‹Ðä�Q˜1Ó€AÜ�Q˜1Ó€Aä�a˜AÓ€AÜ�a˜AÓ€Aà	ˆA‰€Aá	ˆ!‹ˆQ�[‰[™˜1™5›Ó"Ñ" 1¡4Ñ'¨©Ñ,€AÜ�q‹k˜1Ÿ5™5 !§%¡%ˆ!€Aå'à
‹&Ù‰i˜‹l‹Oˆà—5 !§%Ù‘)˜A“,“ˆAð —5‘5 !§%¡%ô ˜Q 1Ó(ˆÜ˜Q 1Ó(ˆð	Ü(¨¨A¨q°QÓ7ˆAð �8‰8�A�;‰;Ø‰Aä  1¤l°Q¸1°I¸qÓDˆAà	‰ˆð' �&ð* €Høô "ó 	Úð	ús   ÄE% Å%
E3Å2E3c                 ór  • [        X5      n[        X5      nUS:  d  US:  a  [        US-
  5      $ UR                  5       n[        XX65      u  pp[        XX65      u  p�[	        XX65      n [	        XX65      n[        XX&5      n	[	        X’S-
  Xc5      n	UR                  Xu-  X„-  -  U5      n
[        XšUS-
  U5      $ )zü
Collins's modular resultant algorithm in `Q[X]`.

Examples
========

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

>>> f = QQ(1,2)*x + y + QQ(2,3)
>>> g = 2*x*y + x + 3

>>> R.dmp_qq_collins_resultant(f, g)
-2*y**2 - 7/3*y + 5/6

r   rn   )r"   r   Úget_ringr-   r*   r    Úconvertr   )rG   rH   rS   ÚK0rp   rq   ÚK1ÚcfÚcgrM   ru   s              rN   Údmp_qq_collins_resultantr¨   Û  s¹   € ô" 	�1Ó€AÜ�1Ó€Aàˆ1ƒu��A“Ü˜˜A™‹Ðà	�‰‹€Bä˜Q 2Ó*�E€BÜ˜Q 2Ó*�E€Bä�A˜"Ó!€AÜ�A˜"Ó!€Aä   qÓ-€AÜ�A˜1‘u˜bÓ%€Aà
�
‰
�2‘5˜2™5‘= "Ó%€Aä˜!  A¡ rÓ*Ð*rP   c                 ó@  • U(       d
  [        XX4S9$ U(       a  [        XX#5      $ UR                  (       a.  UR                  (       a  [	        S5      (       a  [        XX#5      $ O-UR                  (       a  [	        S5      (       a  [        XX#5      $ [        XX#5      S   $ )a   
Computes resultant of two polynomials in `K[X]`.

Examples
========

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

>>> f = 3*x**2*y - y**3 - 4
>>> g = x**2 + x*y**3 - 9

>>> R.dmp_resultant(f, g)
-3*y**10 - 12*y**7 + y**6 - 54*y**4 + 8*y**3 + 729*y**2 - 216*y + 16

)r�   ÚUSE_COLLINS_RESULTANTr   )r‚   r‹   rE   Úis_QQr>   r¨   Úis_ZZr    )rG   rH   rS   rI   r�   s        rN   Údmp_resultantr­     s|   € ö" Ü˜Q 1Ñ<Ð<æÜ   qÓ,Ð,à‡z‡zØ�7�7”uÐ4×5Ñ5Ü+¨A°!Ó7Ð7øà�7�7”uÐ4×5Ñ5Ü+¨A°!Ó7Ð7ä˜Q 1Ó(¨Ñ+Ð+rP   c                 óÐ   • [        U 5      nUS::  a  UR                  $ SX"S-
  -  S-  -  n[        X5      n[        U [	        U SU5      U5      nUR                  XTU" U5      -  5      $ )z°
Computes discriminant of a polynomial in `K[x]`.

Examples
========

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

>>> R.dup_discriminant(x**2 + 2*x + 3)
-8

r   r}   rn   rš   )r!   r~   r$   r‚   r.   ro   )rG   rI   rs   rV   ru   rM   s         rN   Údup_discriminantr¯   #  si   € ô 	�1‹€AàˆAƒvØ�v‰vˆà�A˜1‘u‘I !Ñ#Ñ$ˆÜ�1‹Lˆä˜!œX a¨¨AÓ.°Ó2ˆà�u‰u�Q™!˜A›$™ÓÐrP   c           	      ó  • U(       d  [        X5      $ [        X5      US-
  pCUS::  a  [        U5      $ SX3S-
  -  S-  -  n[        X5      n[	        U [        U SX5      X5      n[        Xb" U5      XB5      n[        XvXB5      $ )zÉ
Computes discriminant of a polynomial in `K[X]`.

Examples
========

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

>>> R.dmp_discriminant(x**2*y + x*z + t)
-4*y*t + z**2

rn   r   r}   rš   )r¯   r"   r   r%   r­   r/   r   r   )rG   rS   rI   rs   r„   rV   ru   rM   s           rN   Údmp_discriminantr±   >  s‡   € ö Ü Ó%Ð%ä�aÓ˜Q ™U€qàˆAƒvÜ˜‹{Ðà�A˜1‘u‘I !Ñ#Ñ$ˆÜ�1‹Lˆä˜!œX a¨¨AÓ1°1Ó8ˆÜ˜1˜a ›d AÓ)ˆä�q˜QÓ"Ð"rP   c                 óh  • U (       d  U(       d  / / / 4$ U (       dI  UR                  [        X5      5      (       a  U/ UR                  /4$ [        X5      / UR                  * /4$ U(       dH  UR                  [        X5      5      (       a  XR                  // 4$ [        X5      UR                  * // 4$ g)ú3Handle trivial cases in GCD algorithm over a ring. N)Úis_nonnegativer$   rF   r   rz   s      rN   Ú_dup_rr_trivial_gcdrµ   ]  sš   € æ–Ø�2�rˆzÐÞØ×ÑœF 1›L×)Ñ)Ø�b˜1Ÿ5™5˜'�>Ð!ä˜1“= "¨¯© v hÐ.Ð.ÞØ×ÑœF 1›L×)Ñ)Ø—u‘u�g˜r�>Ð!ä˜1“= A§E¡E 6 (¨BÐ.Ð.àrP   c                 ó¦   • U (       d  U(       d  / / / 4$ U (       d  [        X5      / [        X5      /4$ U(       d  [        X5      [        X5      // 4$ g)ú4Handle trivial cases in GCD algorithm over a field. N)r5   r$   rz   s      rN   Ú_dup_ff_trivial_gcdr¸   o  sJ   € æ–Ø�2�rˆzÐÞÜ˜‹ ¤V¨A£\ NÐ2Ð2ÞÜ˜‹¤¨£ °Ð2Ð2àrP   c                 óÀ  • [        X5      n[        X5      n[        XU5      =(       d    [        XU5      nU(       a  U(       a  [        [        SX#5      5      $ U(       ad  UR	                  [        XU5      5      (       a  U[        U5      [        X#5      4$ [        XU5      [        U5      [        UR                  * U5      4$ U(       ad  UR	                  [        XU5      5      (       a  U [        X#5      [        U5      4$ [        XU5      [        UR                  * U5      [        U5      4$ U(       a  [        X#5      X4$ [        S5      (       a  [        XX#5      $ g)r³   é   ÚUSE_SIMPLIFY_GCDN)r   r   Útupler    r´   r&   r   r   r   r   rF   r>   Ú_dmp_simplify_gcd)rG   rH   rS   rI   Úzero_fÚzero_gÚif_contain_ones          rN   Ú_dmp_rr_trivial_gcdrÁ   {  s  € ä˜Ó€FÜ˜Ó€FÜ˜q QÓ'×=¬9°Q¸1Ó+=€Næ–&Ü”Y˜q !Ó'Ó(Ð(Þ	Ø×ÑœM¨!°Ó2×3Ñ3Ø”h˜q“k¤7¨1£=Ð0Ð0ä˜1 Ó#¤X¨a£[´*¸a¿e¹e¸VÀQÓ2GÐGÐGÞ	Ø×ÑœM¨!°Ó2×3Ñ3Ø”g˜a“m¤X¨a£[Ð0Ð0ä˜1 Ó#¤Z°·±°¸Ó%:¼HÀQ»KÐGÐGÞ	Ü�q‹}˜aÐ"Ð"Ü	Ð!×	"Ñ	"Ü   qÓ,Ð,àrP   c           	      óz  • [        X5      n[        X5      nU(       a  U(       a  [        [        SX#5      5      $ U(       a,  [        XU5      [	        U5      [        [        XU5      U5      4$ U(       a,  [        XU5      [        [        XU5      U5      [	        U5      4$ [        S5      (       a  [        XX#5      $ g)r·   rº   r»   N)	r   r¼   r    r6   r   r   r&   r>   r½   )rG   rH   rS   rI   r¾   r¿   s         rN   Ú_dmp_ff_trivial_gcdrÃ   •  s«   € ä˜Ó€FÜ˜Ó€Fæ–&Ü”Y˜q !Ó'Ó(Ð(Þ	Ü   qÓ)Ü˜“Üœ=¨¨qÓ1°1Ó5ð7ð 	7ö 
Ü   qÓ)Üœ=¨¨qÓ1°1Ó5Ü˜“ðð 	ô 
Ð!×	"Ñ	"Ü   qÓ,Ð,àrP   c           	      ó®  • [        X5      n[        X5      nUS:”  a  US:”  a  gU(       d  U(       d  [        X5      n[        X5      nO6U(       d  [        X5      n[        XU5      nO[        XU5      n[        X5      nUS-
  n[        XgXƒ5      n	U  V
s/ s H  n
[	        X©Xƒ5      PM     nn
U Vs/ s H  n[	        XÉXƒ5      PM     nnU	/X½4$ s  sn
f s  snf )z7Try to eliminate `x_0` from GCD computation in `K[X]`. r   Nrn   )r"   r%   Údmp_contentÚdmp_gcdr   )rG   rH   rS   rI   ÚdfÚdgrX   r”   r„   rW   r¦   Úcffr§   Úcfgs                 rN   r½   r½   ª  sÉ   € ä	�AÓ	€BÜ	�AÓ	€Bà	ˆAƒv�"�q“&Øæ–"Ü�1‹LˆÜ�1‹L‰æÜ�q“ˆAÜ˜A !Ó$‰Aä˜A !Ó$ˆAÜ�q“ˆAà	ˆA‰€AÜ��aÓ€Aá+,Ó
.ª1 RŒG�B˜1Ö ©1€CÐ
.Ù+,Ó
.ª1 RŒG�B˜1Ö ©1€CÐ
.àˆ3�ˆ=Ðùò /ùÚ
.s   ÂCÂ0Cc                 ó:  • [        XU5      nUb  U$ [        X5      u  pE[        X5      u  pgUR                  XF5      n[        XWU5      S   n	[        X’5      u  p©X‚R	                  [        X’5      5      -  n[        X˜U5      n	[        X	U5      n[        XU5      nX›U4$ )a9  
Computes polynomial GCD using subresultants over a ring.

Returns ``(h, cff, cfg)`` such that ``a = gcd(f, g)``, ``cff = quo(f, h)``,
and ``cfg = quo(g, h)``.

Examples
========

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

>>> R.dup_rr_prs_gcd(x**2 - 1, x**2 - 3*x + 2)
(x - 1, x + 1, x - 2)

r}   )rµ   r7   Úgcdr{   Úcanonical_unitr$   r   r   )rG   rH   rI   ÚresultÚfcrX   Úgcr”   ru   rW   ri   rÉ   rÊ   s                rN   Údup_rr_prs_gcdrÑ   Æ  s¢   € ô" !  qÓ)€FàÑØˆä˜!Ó�E€BÜ˜!Ó�E€Bà	�‰ˆb‹€Aä˜! Ó" 2Ñ&€AÜ˜Ó�D€Aà×	Ñ	œ& ›,Ó	'Ñ'€Aä�q˜QÓ€Aä
�!˜Ó
€CÜ
�!˜Ó
€Cà�3ˆ;ÐrP   c                 ó�   • [        XU5      nUb  U$ [        XU5      S   n[        XB5      n[        XU5      n[        XU5      nXEU4$ )a:  
Computes polynomial GCD using subresultants over a field.

Returns ``(h, cff, cfg)`` such that ``a = gcd(f, g)``, ``cff = quo(f, h)``,
and ``cfg = quo(g, h)``.

Examples
========

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

>>> R.dup_ff_prs_gcd(x**2 - 1, x**2 - 3*x + 2)
(x - 1, x + 1, x - 2)

r}   )r¸   r{   r5   r   )rG   rH   rI   rÎ   rW   rÉ   rÊ   s          rN   Údup_ff_prs_gcdrÓ   î  sW   € ô" !  qÓ)€FàÑØˆä˜! Ó" 2Ñ&€AÜ�!‹€Aä
�!˜Ó
€CÜ
�!˜Ó
€Cà�3ˆ;ÐrP   c                 ó¢  • U(       d  [        XU5      $ [        XX#5      nUb  U$ [        XU5      u  pV[        XU5      u  px[        XhX#5      S   n	[	        XWUS-
  U5      u  n
  n[        X’U5      u  p¹[        XšSX#5      n	UR                  [        X’U5      5      nXÃR                  :w  a  [        XœX#5      n	[        X	X#5      n[        XX#5      nX�U4$ )aV  
Computes polynomial GCD using subresultants over a ring.

Returns ``(h, cff, cfg)`` such that ``a = gcd(f, g)``, ``cff = quo(f, h)``,
and ``cfg = quo(g, h)``.

Examples
========

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

>>> f = x**2 + 2*x*y + y**2
>>> g = x**2 + x*y

>>> R.dmp_rr_prs_gcd(f, g)
(x + y, x + y, x)

r}   rn   r   )rÑ   rÁ   Údmp_primitiver‰   Údmp_rr_prs_gcdr   rÍ   r&   rF   r   r   )rG   rH   rS   rI   rÎ   rÏ   rX   rÐ   r”   rW   ru   ri   ÚunitrÉ   rÊ   s                  rN   rÖ   rÖ     sÚ   € ö( Ü˜a AÓ&Ð&ä   qÓ,€FàÑØˆä˜! Ó"�E€BÜ˜! Ó"�E€Bä˜! Ó% bÑ)€AÜ˜R Q¨¡U¨AÓ.�G€A€qˆ!ä˜˜qÓ!�D€AÜ�Q˜1˜aÓ#€Aà×ÑœM¨!°Ó2Ó3€Dà�u‰uƒ}Ü˜1 AÓ)ˆä
�!˜Ó
€CÜ
�!˜Ó
€Cà�3ˆ;ÐrP   c                 óN  • U(       d  [        XU5      $ [        XX#5      nUb  U$ [        XU5      u  pV[        XU5      u  px[        XhX#5      S   n	[	        XWUS-
  U5      u  n
  n[        X’U5      u  p¹[        XšSX#5      n	[        X’U5      n	[        X	X#5      n[        XX#5      nXœU4$ )am  
Computes polynomial GCD using subresultants over a field.

Returns ``(h, cff, cfg)`` such that ``a = gcd(f, g)``, ``cff = quo(f, h)``,
and ``cfg = quo(g, h)``.

Examples
========

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

>>> f = QQ(1,2)*x**2 + x*y + QQ(1,2)*y**2
>>> g = x**2 + x*y

>>> R.dmp_ff_prs_gcd(f, g)
(x + y, 1/2*x + 1/2*y, x)

r}   rn   r   )rÓ   rÃ   rÕ   r‰   Údmp_ff_prs_gcdr   r6   r   )rG   rH   rS   rI   rÎ   rÏ   rX   rÐ   r”   rW   ru   ri   rÉ   rÊ   s                 rN   rÙ   rÙ   =  sº   € ö( Ü˜a AÓ&Ð&ä   qÓ,€FàÑØˆä˜! Ó"�E€BÜ˜! Ó"�E€Bä˜! Ó% bÑ)€AÜ˜R Q¨¡U¨AÓ.�G€A€qˆ!ä˜˜qÓ!�D€AÜ�Q˜1˜aÓ#€AÜ˜˜qÓ!€Aä
�!˜Ó
€CÜ
�!˜Ó
€Cà�3ˆ;ÐrP   é   c                 ó|   • / nU (       a2  X-  nXAS-  :”  a  XA-  nUR                  SU5        X-
  U-  n U (       a  M2  U$ )ú-Interpolate polynomial GCD from integer GCD. rš   r   )Úinsert)rW   ÚxrI   rG   rH   s        rN   Ú_dup_zz_gcd_interpolaterß   k  sG   € à
€Aæ
Ø‰Eˆà�A‰v‹:Ø‰FˆAà	�‰��AŒØ‰U�q‰Lˆ÷ ˆ!ð €HrP   c                 ó¨  • [        XU5      nUb  U$ [        U 5      n[        U5      n[        XU5      u  p`nUS:X  d  US:X  a  U/X4$ [        X5      n[        X5      nU" S[	        Xx5      -  S-   5      n	[        [	        U	SUR                  U	5      -  5      S[	        U[        [        X5      5      -  U[        [        X5      5      -  5      -  S-   5      n
[        S[        5       GH]  n[        X
U5      n[        XU5      nU(       Ga  U(       Ga  UR                  XÍ5      nXÎ-  nXÞ-  n[        XêU5      n[        Xâ5      S   n[        XU5      u  nnU(       d)  [        XU5      u  nnU(       d  [!        XæU5      nUUU4s  $ [        XúU5      n[        XU5      u  nnU(       d(  [        XU5      u  nnU(       d  [!        XæU5      nXïU4s  $ [        UX¢5      n[        UUU5      u  nnU(       d)  [        XU5      u  nnU(       d  [!        XæU5      nUUU4s  $ SU
-  UR                  UR                  U
5      5      -  S-  n
GM`     [#        S	5      e)
a®  
Heuristic polynomial GCD in `Z[x]`.

Given univariate polynomials `f` and `g` in `Z[x]`, returns
their GCD and cofactors, i.e. polynomials ``h``, ``cff`` and ``cfg``
such that::

      h = gcd(f, g), cff = quo(f, h) and cfg = quo(g, h)

The algorithm is purely heuristic which means it may fail to compute
the GCD. This will be signaled by raising an exception. In this case
you will need to switch to another GCD method.

The algorithm computes the polynomial GCD by evaluating polynomials
f and g at certain points and computing (fast) integer GCD of those
evaluations. The polynomial GCD is recovered from the integer image
by interpolation.  The final step is to verify if the result is the
correct GCD. This gives cofactors as a side effect.

Examples
========

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

>>> R.dup_zz_heu_gcd(x**2 - 1, x**2 - 3*x + 2)
(x - 1, x + 1, x - 2)

References
==========

.. [1] [Liao95]_

r   rš   é   éc   é   rn   éB  éƒi  r�   )rµ   r!   r9   r   ÚminÚmaxÚsqrtÚabsr$   ÚrangeÚHEU_GCD_MAXr0   rÌ   rß   r7   r   r   r@   )rG   rH   rI   rÎ   rÇ   rÈ   rÌ   Úf_normÚg_normr’   rÞ   ÚiÚffÚggrW   rÉ   rÊ   Úcff_rM   Úcfg_s                       rN   Údup_zz_heu_gcdró   {  sF  € ôF !  qÓ)€FàÑØˆä	�A‹€BÜ	�A‹€Bä˜A !Ó$�I€CˆAà	ˆQƒw�"˜“'Øˆu�aˆ{Ðä˜!Ó€FÜ˜!Ó€Fá	ˆ!ŒC�ÓÑ
 "Ñ
$Ó%€AäŒC��2�a—f‘f˜Q“i‘<Ó ØŒc�&œC¤ q£Ó-Ñ-ØœC¤ q£Ó-Ñ-ó/ñ /Ø12ñ3ó	4€Aô �1”k×"ˆÜ�a˜AÓˆÜ�a˜AÓˆç—"Ø—‘�b“ˆAà‘'ˆCØ‘'ˆCä'¨¨aÓ0ˆAÜ˜aÓ# AÑ&ˆAä˜a AÓ&‰GˆD�!æÜ! !¨Ó*‘��aæÜ& q¨qÓ1�AØ˜d D˜=Ò(ä)¨#°!Ó4ˆCä˜1 1Ó%‰DˆAˆqæÜ! !¨Ó*‘��aæÜ& q¨qÓ1�AØ 4˜<Ò'ä)¨#¨qÓ4ˆCä˜1˜c 1Ó%‰DˆAˆqæÜ! !¨Ó*‘��aæÜ& q¨qÓ1�AØ˜d C˜<Ò'à�!‰G�a—f‘f˜QŸV™V A›YÓ'Ñ'¨5Ñ0‹ñY #ô\ ˜YÓ
'Ð'rP   c                 ó  • / n[        X5      (       dH  [        XX#5      nUR                  SU5        [        XX#5      n [	        XX#5      n [        X5      (       d  MH  UR                  [        XBS-   U5      5      (       a  [        XBS-   U5      $ U$ )rÜ   r   rn   )r   r4   rÝ   r   r   Úis_negativer&   r   )rW   rÞ   r„   rI   rG   rH   s         rN   Ú_dmp_zz_gcd_interpolaterö   å  s‚   € à
€Aä˜×ÑÜ˜Q 1Ó(ˆØ	�‰��AŒä�A˜!ÓˆÜ˜1 Ó&ˆô ˜×Óð 	‡}�}”] 1¨!¡e¨QÓ/×0Ñ0Ü�q˜a™% Ó#Ð#àˆrP   c                 ó  • U(       d  [        XU5      $ [        XX#5      nUb  U$ [        XX#5      u  pPn[        XU5      n[        XU5      nU" S[	        Xg5      -  S-   5      n[        [	        USUR                  U5      -  5      S[	        U[        [        XU5      5      -  U[        [        XU5      5      -  5      -  S-   5      n	[        S[        5       GH¨  n
[        X	X#5      n[        XX#5      nUS-
  n[        X½5      (       GdM  [        XÍ5      (       Gd<  [        X¼XÓ5      u  pïn[        XéXÓ5      n[        XâU5      S   n[!        XX#5      u  nn[        UU5      (       a3  [!        XX#5      u  nn[        UU5      (       a  [#        XåX#5      nUUU4s  $ [        XùXÓ5      n[!        XX#5      u  nn[        UU5      (       a2  [!        XX#5      u  nn[        UU5      (       a  [#        XåX#5      nXïU4s  $ [        UX�U5      n[!        UUX#5      u  nn[        UU5      (       a3  [!        XX#5      u  nn[        UU5      (       a  [#        XåX#5      nUUU4s  $ SU	-  UR                  UR                  U	5      5      -  S-  n	GM«     [%        S	5      e)
aG  
Heuristic polynomial GCD in `Z[X]`.

Given univariate polynomials `f` and `g` in `Z[X]`, returns
their GCD and cofactors, i.e. polynomials ``h``, ``cff`` and ``cfg``
such that::

      h = gcd(f, g), cff = quo(f, h) and cfg = quo(g, h)

The algorithm is purely heuristic which means it may fail to compute
the GCD. This will be signaled by raising an exception. In this case
you will need to switch to another GCD method.

The algorithm computes the polynomial GCD by evaluating polynomials
f and g at certain points and computing (fast) integer GCD of those
evaluations. The polynomial GCD is recovered from the integer image
by interpolation. The evaluation process reduces f and g variable by
variable into a large integer.  The final step is to verify if the
interpolated polynomial is the correct GCD. This gives cofactors of
the input polynomials as a side effect.

Examples
========

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

>>> f = x**2 + 2*x*y + y**2
>>> g = x**2 + x*y

>>> R.dmp_zz_heu_gcd(f, g)
(x + y, x + y, x)

References
==========

.. [1] [Liao95]_

rš   rá   râ   rã   r   rn   rä   rå   r�   )ró   rÁ   r:   r   ræ   rç   rè   ré   r&   rê   rë   r1   r   Údmp_zz_heu_gcdrö   r8   r   r   r@   )rG   rH   rS   rI   rÎ   rÌ   rì   rí   r’   rÞ   rî   rï   rð   r„   rW   rÉ   rÊ   rñ   rM   rò   s                       rN   rø   rø   ö  sƒ  € öP Ü˜a AÓ&Ð&ä   qÓ,€FàÑØˆä" 1¨Ó.�I€CˆAä˜! Ó"€FÜ˜! Ó"€Fá	ˆ!ŒC�ÓÑ
 "Ñ
$Ó%€AäŒC��2�a—f‘f˜Q“i‘<Ó ØŒc�&œC¤¨a°AÓ 6Ó7Ñ7ØœC¤¨a°AÓ 6Ó7Ñ7ó9ñ 9Ø;<ñ=ó	>€Aô �1”k×"ˆÜ�a˜AÓ!ˆÜ�a˜AÓ!ˆà�‰Eˆä˜2×!Ò!¤Z°×%6Ò%6Ü(¨°Ó6‰KˆA�Cä'¨¨aÓ3ˆAÜ$ Q¨1Ó-¨aÑ0ˆAä˜a AÓ)‰GˆD�!ä˜!˜Q×ÑÜ! !¨Ó-‘��aä˜a ×#Ñ#Ü& q¨qÓ4�AØ˜d D˜=Ò(ä)¨#°!Ó7ˆCä˜1 1Ó(‰DˆAˆqä˜!˜Q×ÑÜ! !¨Ó-‘��aä˜a ×#Ñ#Ü& q¨qÓ4�AØ 4˜<Ò'ä)¨#¨q°QÓ7ˆCä˜1˜c 1Ó(‰DˆAˆqä˜!˜Q×ÑÜ! !¨Ó-‘��aä˜a ×#Ñ#Ü& q¨qÓ4�AØ˜d C˜<Ò'à�!‰G�a—f‘f˜QŸV™V A›YÓ'Ñ'¨5Ñ0‹ñW #ôZ ˜YÓ
'Ð'rP   c                 ó²  • [        XU5      nUb  U$ UR                  5       n[        XU5      u  pP[        XU5      u  pa[        XU5      n [        XU5      n[	        XU5      u  pxn	[        XtU5      n[        Xr5      n
[        Xr5      n[        X„U5      n[        X”U5      n	[        X‚R                  X¥5      U5      n[        X’R                  X¦5      U5      n	XxU	4$ )a[  
Heuristic polynomial GCD in `Q[x]`.

Returns ``(h, cff, cfg)`` such that ``a = gcd(f, g)``,
``cff = quo(f, h)``, and ``cfg = quo(g, h)``.

Examples
========

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

>>> f = QQ(1,2)*x**2 + QQ(7,4)*x + QQ(3,2)
>>> g = QQ(1,2)*x**2 + x

>>> R.dup_qq_heu_gcd(f, g)
(x + 2, 1/2*x + 3/4, 1/2*x)

)	r¸   r¢   r,   r)   ró   r$   r5   r   ro   )rG   rH   r¤   rÎ   r¥   r¦   r§   rW   rÉ   rÊ   ru   s              rN   Údup_qq_heu_gcdrú   a  sÓ   € ô( !  rÓ*€FàÑØˆà	�‰‹€Bä˜Q BÓ'�E€BÜ˜Q BÓ'�E€Bä�A˜2Ó€AÜ�A˜2Ó€Aä   rÓ*�K€AˆCä�A˜2Ó€Aäˆq‹€AÜ�!Ó€Aä
�c˜rÓ
"€CÜ
�c˜rÓ
"€Cä
˜Ÿf™f Q›m¨RÓ
0€CÜ
˜Ÿf™f Q›m¨RÓ
0€Cà�3ˆ;ÐrP   c                 ó¶  • [        XX#5      nUb  U$ UR                  5       n[        XX55      u  p`[        XX55      u  pq[        XX55      n [        XX55      n[	        XX%5      u  p‰n
[        X‚XS5      n[        X‚U5      n[        X‚U5      n[        X’XS5      n	[        X¢XS5      n
[        X“R                  X¶5      X#5      n	[        X£R                  X·5      X#5      n
X‰U
4$ )a]  
Heuristic polynomial GCD in `Q[X]`.

Returns ``(h, cff, cfg)`` such that ``a = gcd(f, g)``,
``cff = quo(f, h)``, and ``cfg = quo(g, h)``.

Examples
========

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

>>> f = QQ(1,4)*x**2 + x*y + y**2
>>> g = QQ(1,2)*x**2 + x*y

>>> R.dmp_qq_heu_gcd(f, g)
(x + 2*y, 1/4*x + 1/2*y, 1/2*x)

)	rÃ   r¢   r-   r*   rø   r&   r6   r   ro   )rG   rH   rS   r¤   rÎ   r¥   r¦   r§   rW   rÉ   rÊ   ru   s               rN   Údmp_qq_heu_gcdrü   ’  sØ   € ô( !  qÓ-€FàÑØˆà	�‰‹€Bä˜Q 2Ó*�E€BÜ˜Q 2Ó*�E€Bä�A˜"Ó!€AÜ�A˜"Ó!€Aä   qÓ-�K€AˆCä�A˜"Ó!€Aä�a˜BÓ€AÜ˜˜rÓ"€Aä
�c˜bÓ
%€CÜ
�c˜bÓ
%€Cä
˜Ÿf™f Q›m¨QÓ
3€CÜ
˜Ÿf™f Q›m¨QÓ
3€Cà�3ˆ;ÐrP   c                 óŽ  • UR                   (       d  UR                  (       a`   UR                  5       n[        XU5      n [        XU5      n[        XU5      u  pEn[        XCU5      n[        XSU5      n[        XcU5      nXEU4$ UR                  (       a:  UR                  (       a  [        S5      (       a   [        XU5      $ [        XU5      $ UR                  (       a  [        S5      (       a   [        XU5      $ [        XU5      $ ! [         a    UR                  /X4s $ f = f! [         a     Nqf = f! [         a     NGf = f)a?  
Computes polynomial GCD and cofactors of `f` and `g` in `K[x]`.

Returns ``(h, cff, cfg)`` such that ``a = gcd(f, g)``,
``cff = quo(f, h)``, and ``cfg = quo(g, h)``.

Examples
========

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

>>> R.dup_inner_gcd(x**2 - 1, x**2 - 3*x + 2)
(x - 1, x + 1, x - 2)

ÚUSE_HEU_GCD)Úis_RRÚis_CCÚ	get_exactrC   rF   r)   Údup_inner_gcdrE   r«   r>   rú   r@   rÓ   r¬   ró   rÑ   )rG   rH   rI   ÚexactrW   rÉ   rÊ   s          rN   r  r  Ã  s+  € ð: 	‡w‡w�!—'—'ð	!Ø—K‘K“MˆEô ˜˜eÓ$ˆÜ˜˜eÓ$ˆä# A¨%Ó0‰ˆ�ä˜ !Ó$ˆÜ˜# aÓ(ˆÜ˜# aÓ(ˆà�sˆ{ÐØ	
��Ø�7�7”u˜]×+Ñ+ðÜ% a¨AÓ.Ð.ô ˜a AÓ&Ð&à�7�7”u˜]×+Ñ+ðÜ% a¨AÓ.Ð.ô ˜a AÓ&Ð&øô9 ó 	!Ø—E‘E�7˜A�=Ò ð	!ûô" &ó Ùðûô &ó Ùðús5   ¤D Â6D' Ã0D7 ÄD$Ä#D$Ä'
D4Ä3D4Ä7
EÅEc                 óh  • UR                   (       d`   UR                  5       n[	        XX45      n [	        XX45      n[        XX$5      u  pVn[	        XRXC5      n[	        XbXC5      n[	        XrXC5      nXVU4$ UR                  (       a:  UR                  (       a  [        S5      (       a   [        XX#5      $ [        XX#5      $ UR                  (       a  [        S5      (       a   [        XX#5      $ [        XX#5      $ ! [         a    [        X#5      X4s $ f = f! [         a     Nof = f! [         a     NEf = f)z'Helper function for `dmp_inner_gcd()`. rþ   )Úis_Exactr  rC   r   r*   Ú_dmp_inner_gcdrE   r«   r>   rü   r@   rÙ   r¬   rø   rÖ   )rG   rH   rS   rI   r  rW   rÉ   rÊ   s           rN   r  r    s"  € à�:�:ð	'Ø—K‘K“MˆEô ˜˜aÓ'ˆÜ˜˜aÓ'ˆä$ Q¨1Ó4‰ˆ�ä˜˜eÓ'ˆÜ˜# %Ó+ˆÜ˜# %Ó+ˆà�sˆ{ÐØ	
��Ø�7�7”u˜]×+Ñ+ðÜ% a¨AÓ1Ð1ô ˜a AÓ)Ð)à�7�7”u˜]×+Ñ+ðÜ% a¨AÓ1Ð1ô ˜a AÓ)Ð)øô9 ó 	'Ü˜1“= !Ð&Ò&ð	'ûô" &ó Ùðûô &ó Ùðús5   “C7 Â%D ÃD$ Ã7DÄDÄ
D!Ä D!Ä$
D1Ä0D1c                 ó°   • U(       d  [        XU5      $ [        X4X#5      u  nu  p[        XX#5      u  pVn[        XTX#5      [        XdX#5      [        XtX#5      4$ )a\  
Computes polynomial GCD and cofactors of `f` and `g` in `K[X]`.

Returns ``(h, cff, cfg)`` such that ``a = gcd(f, g)``,
``cff = quo(f, h)``, and ``cfg = quo(g, h)``.

Examples
========

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

>>> f = x**2 + 2*x*y + y**2
>>> g = x**2 + x*y

>>> R.dmp_inner_gcd(f, g)
(x + y, x + y, x)

)r  r'   r  r(   )rG   rH   rS   rI   ÚJrW   rÉ   rÊ   s           rN   Údmp_inner_gcdr	  &  s`   € ö( Ü˜Q 1Ó%Ð%ä! 1 &¨!Ó/�I€A�vˆÜ   qÓ,�K€AˆCä˜˜aÓ#Ü˜ Ó%Ü˜ Ó%ð'ð 'rP   c                 ó    • [        XU5      S   $ )zµ
Computes polynomial GCD of `f` and `g` in `K[x]`.

Examples
========

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

>>> R.dup_gcd(x**2 - 1, x**2 - 3*x + 2)
x - 1

r   )r  rz   s      rN   Údup_gcdr  E  s   € ô ˜˜qÓ! !Ñ$Ð$rP   c                 ó    • [        XX#5      S   $ )zÖ
Computes polynomial GCD of `f` and `g` in `K[X]`.

Examples
========

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

>>> f = x**2 + 2*x*y + y**2
>>> g = x**2 + x*y

>>> R.dmp_gcd(f, g)
x + y

r   )r	  rR   s       rN   rÆ   rÆ   V  s   € ô" ˜˜qÓ$ QÑ'Ð'rP   c                 ó  • U (       a  U(       d  [        S5      $ [        X5      u  p0[        X5      u  pAUR                  X45      n[        [	        XU5      [        XU5      U5      nUR                  [        Xb5      5      n[        XeU-  U5      $ )zÅ
Computes polynomial LCM over a ring in `K[x]`.

Examples
========

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

>>> R.dup_rr_lcm(x**2 - 1, x**2 - 3*x + 2)
x**3 - 2*x**2 - x + 2

r   )	r   r7   Úlcmr   r   r  rÍ   r$   r   )rG   rH   rI   rÏ   rÐ   ru   rW   rS   s           rN   Ú
dup_rr_lcmr  j  s~   € ö –AÜ˜‹{Ðä˜!Ó�E€BÜ˜!Ó�E€Bà	�‰ˆb‹€Aä”˜˜aÓ Ü˜˜aÓ  !ó	%€Að 	
×Ñœ ›Ó&€Aä˜!˜q™S !Ó$Ð$rP   c                 óZ   • [        [        XU5      [        XU5      U5      n[        X25      $ )z÷
Computes polynomial LCM over a field in `K[x]`.

Examples
========

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

>>> f = QQ(1,2)*x**2 + QQ(7,4)*x + QQ(3,2)
>>> g = QQ(1,2)*x**2 + x

>>> R.dup_ff_lcm(f, g)
x**3 + 7/2*x**2 + 3*x

)r   r   r  r5   )rG   rH   rI   rW   s       rN   Ú
dup_ff_lcmr  ˆ  s/   € ô" 	”˜˜aÓ Ü˜˜aÓ  !ó	%€Aô �Q‹?ÐrP   c                 óT   • UR                   (       a  [        XU5      $ [        XU5      $ )zÅ
Computes polynomial LCM of `f` and `g` in `K[x]`.

Examples
========

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

>>> R.dup_lcm(x**2 - 1, x**2 - 3*x + 2)
x**3 - 2*x**2 - x + 2

)rE   r  r  rz   s      rN   Údup_lcmr  Ÿ  s%   € ð 	‡z‡zÜ˜! Ó"Ð"ä˜! Ó"Ð"rP   c           	      ó¶   • [        XU5      u  p@[        XU5      u  pQUR                  XE5      n[        [        XX#5      [	        XX#5      X#5      n[        XvX#5      $ )zé
Computes polynomial LCM over a ring in `K[X]`.

Examples
========

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

>>> f = x**2 + 2*x*y + y**2
>>> g = x**2 + x*y

>>> R.dmp_rr_lcm(f, g)
x**3 + 2*x**2*y + x*y**2

)r8   r  r   r	   rÆ   r   )rG   rH   rS   rI   rÏ   rÐ   ru   rW   s           rN   Ú
dmp_rr_lcmr  ³  s[   € ô" !  qÓ)�E€BÜ   qÓ)�E€Bà	�‰ˆb‹€Aä”˜˜aÓ#Ü˜˜aÓ# Qó	+€Aô ˜! Ó%Ð%rP   c           	      ó\   • [        [        XX#5      [        XX#5      X#5      n[        XBU5      $ )zú
Computes polynomial LCM over a field in `K[X]`.

Examples
========

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

>>> f = QQ(1,4)*x**2 + x*y + y**2
>>> g = QQ(1,2)*x**2 + x*y

>>> R.dmp_ff_lcm(f, g)
x**3 + 4*x**2*y + 4*x*y**2

)r   r	   rÆ   r6   )rG   rH   rS   rI   rW   s        rN   Ú
dmp_ff_lcmr  Ï  s2   € ô" 	”˜˜aÓ#Ü˜˜aÓ# Qó	+€Aô ˜A !Ó$Ð$rP   c                 óz   • U(       d  [        XU5      $ UR                  (       a  [        XX#5      $ [        XX#5      $ )zé
Computes polynomial LCM of `f` and `g` in `K[X]`.

Examples
========

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

>>> f = x**2 + 2*x*y + y**2
>>> g = x**2 + x*y

>>> R.dmp_lcm(f, g)
x**3 + 2*x**2*y + x*y**2

)r  rE   r  r  rR   s       rN   Údmp_lcmr  æ  s5   € ö" Ü�q˜QÓÐà‡z‡zÜ˜! Ó%Ð%ä˜! Ó%Ð%rP   c                 óö   • [        X5      US-
  pC[        X5      (       a  U$ U SS  H"  n[        X5XB5      n[        X4U5      (       d  M"    O   UR	                  [        X4U5      5      (       a  [        X4U5      $ U$ )z¶
Returns GCD of multivariate coefficients.

Examples
========

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

>>> R.dmp_content(2*x*y + 6*x + 4*y + 12)
2*y + 6

rn   N)r%   r   rÆ   r   rõ   r&   r   ©rG   rS   rI   Úcontr„   ru   s         rN   rÅ   rÅ      sy   € ô �Q‹l˜A ™Eˆ!ä�!×ÑØˆàˆqˆr‹UˆÜ�t Ó%ˆä�T˜a× Ó Ùñ	 ð 	‡}�}”] 4¨AÓ.×/Ñ/Ü�t Ó"Ð"àˆrP   c           
      ó°   • [        XU5      US-
  pC[        X5      (       d  [        X4U5      (       a  X04$ X0 Vs/ s H  n[        XSXB5      PM     sn4$ s  snf )zÐ
Returns multivariate content and a primitive polynomial.

Examples
========

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

>>> R.dmp_primitive(2*x*y + 6*x + 4*y + 12)
(2*y + 6, x + 2)

rn   )rÅ   r   r   r   r  s         rN   rÕ   rÕ     sX   € ô ˜! Ó" A¨¡Eˆ!ä�!×Ñœ9 T¨a×0Ñ0Øˆwˆà°qÓ:²q°!”w˜q¨Ö-±qÑ:Ð:Ð:ùÒ:s   ¹Ac                 ó   • [        XSX#S9$ )zÇ
Cancel common factors in a rational function `f/g`.

Examples
========

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

>>> R.dup_cancel(2*x**2 - 2, x**2 - 2*x + 1)
(2*x + 2, x - 1)

r   )Úinclude)Ú
dmp_cancel)rG   rH   rI   r  s       rN   Ú
dup_cancelr!  5  s   € ô �a˜A˜qÑ2Ð2rP   c                 ó¨  • SnUR                   (       a<  UR                  (       a+  X3R                  5       p5[        XXSSS9u  p`[        XXSSS9u  pqOUR                  UR                  pg[        XX#5      u  p‰n
Ub.  UR                  Xv5      u  p‡n[        X’X55      n	[        X¢X55      n
UnUR                  [        X’U5      5      nUR                  [        X¢U5      5      nU(       a  U(       a  [        X’U5      [        X¢U5      p©O+U(       a  U* [        X’U5      p—OU(       a  U* [        X¢U5      p§U(       d  XvXš4$ [        X—X#5      n	[        X¦X#5      n
Xš4$ )zË
Cancel common factors in a rational function `f/g`.

Examples
========

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

>>> R.dmp_cancel(2*x**2 - 2, x**2 - 2*x + 1)
(2*x + 2, x - 1)

NT)r£   )rE   Úhas_assoc_Ringr¢   r-   rF   r	  Ú	cofactorsr*   rõ   r&   r   r   )rG   rH   rS   rI   r  r¤   ÚcqÚcpri   r†   rL   Úp_negÚq_negs                rN   r   r   F  s.  € ð 
€Bà‡z‡z�a×&×&Ø—:‘:“<ˆAä   r°dÑ;‰ˆÜ   r°dÑ;‰ˆˆAà—‘˜Ÿ™ˆBä˜A !Ó'�G€Aˆ!à	�~Ø—K‘K Ó'‰	ˆˆrä˜˜aÓ$ˆÜ˜˜aÓ$ˆàˆà�M‰Mœ-¨¨aÓ0Ó1€EØ�M‰Mœ-¨¨aÓ0Ó1€Eæ–Ü�q˜QÓ¤¨¨qÓ!1‰1Þ	Ø�”W˜Q 1Ó%‰AÞ	Ø�”W˜Q 1Ó%ˆAæØ�qˆ|Ðä�q˜aÓ#€AÜ�q˜aÓ#€Aàˆ4€KrP   N)F)T)~Ú__doc__Úsympy.polys.densearithr   r   r   r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   Úsympy.polys.densebasicr   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   Úsympy.polys.densetoolsr,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   Úsympy.polys.galoistoolsr<   r=   Úsympy.polys.polyconfigr>   Úsympy.polys.polyerrorsr?   r@   rA   rB   rC   rO   rT   rZ   r\   r^   r`   rd   rf   rj   rl   rx   r{   r   r‚   r‡   r‰   r‹   rŽ   r˜   r    r¨   r­   r¯   r±   rµ   r¸   rÁ   rÃ   r½   rÑ   rÓ   rÖ   rÙ   rë   rß   ró   rö   rø   rú   rü   r  r  r	  r  rÆ   r  r  r  r  r  r  rÅ   rÕ   r!  r   © rP   rN   Ú<module>r1     sœ  ðÙ K÷ ÷  ÷  ÷  ÷  ÷  ÷	÷ 	÷ 	÷ 	÷ 	ñ 	÷%÷ %÷ %÷ %ñ %÷å (÷õ ò òF0ò"ò60ò",ò>0ò"%òP0ò"%òP0ò"Mò`/ò"ô2)ò&Mò`2ò.%òPFòR2ò
:òz$+ôN,òB ò6#ò>ò$	òò4ò*ò8%òPò>-ò`)ðV €òò g(òTò"h(òV.òb.òb<'ò~!*òH'ò>%ò"(ò(%ò<ò.#ò(&ò8%ò.&ò4ò>;ô,3õ"2rP   