ó
    Š*£h”  ã                   ó$   • S r SSKJr  SrS rS rg)z-Heuristic polynomial GCD algorithm (HEUGCD). é   )ÚHeuristicGCDFailedé   c                 óÔ  • U R                   UR                   :X  a%  U R                   R                  R                  (       d   eU R                   nUR                  S   nUR                  nU R	                  U5      u  pPnU R                  5       nUR                  5       nU" S[        Xg5      -  S-   5      n[        [        USUR                  U5      -  5      S[        U[        U R                  5      -  U[        UR                  5      -  5      -  S-   5      n	[        S[        5       GH²  n
U R                  X95      nUR                  X95      nU(       Ga[  U(       GaS  UR                  S:X  a  UR                  X¼5      u  pÞnO[!        X¼5      u  pÞn[#        XÙU5      nUR%                  5       S   nU R'                  U5      u  nnU(       d3  UR'                  U5      u  nnU(       d  UR)                  U5      nUUU4s  $ [#        XéU5      nU R'                  U5      u  nnU(       d2  UR'                  U5      u  nnU(       d  UR)                  U5      nXÞU4s  $ [#        XùU5      nUR'                  U5      u  nnU(       d3  U R'                  U5      u  nnU(       d  UR)                  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 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.heuristicgcd import heugcd
>>> 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

>>> h, cff, cfg = heugcd(f, g)
>>> h, cff, cfg
(x + y, x + y, x)

>>> cff*h == f
True
>>> cfg*h == g
True

References
==========

.. [1] [Liao95]_

é    é   é   éc   é   r   iB  iƒi  zno luck)ÚringÚdomainÚis_ZZÚgensÚextract_groundÚmax_normÚminÚmaxÚsqrtÚabsÚLCÚrangeÚHEU_GCD_MAXÚevaluateÚngensÚ	cofactorsÚheugcdÚ_gcd_interpolateÚ	primitiveÚdivÚ
mul_groundr   )ÚfÚgr   Úx0r   ÚgcdÚf_normÚg_normÚBÚxÚiÚffÚggÚhÚcffÚcfgÚcff_ÚrÚcfg_s                      ÚU/home/mande/repo/quber/.venv/lib/python3.13/site-packages/sympy/polys/heuristicgcd.pyr   r      sn  € ð` �6‰6�Q—V‘VÓ §¡§¡× 3× 3Ð3Ð3à�6‰6€DØ	�‰�1‰€BØ�[‰[€Fà× Ñ  Ó#�I€CˆAà�Z‰Z‹\€FØ�Z‰Z‹\€Fáˆq”�VÓ$Ñ$ rÑ)Ó*€AäŒC��2�f—k‘k !“nÑ$Ó%ØŒc�&œC §¡›IÑ%ØœC §¡›IÑ%ó'ñ 'Ø)*ñ+ó	,€Aô �1”k×"ˆØ�Z‰Z˜ÓˆØ�Z‰Z˜Óˆç—"Ø�z‰z˜Q‹Ø$×.Ñ.¨rÓ6‘�™ä$ R›n‘�˜ä   tÓ,ˆAØ—‘“˜aÑ ˆAà—e‘e˜A“h‰GˆD�!æØŸ%™% ›(‘��aæØŸ™ SÓ)�AØ˜d D˜=Ò(ä" 3¨4Ó0ˆCà—5‘5˜“:‰DˆAˆqæØŸ%™% ›(‘��aæØŸ™ SÓ)�AØ 4˜<Ò'ä" 3¨4Ó0ˆCà—5‘5˜“:‰DˆAˆqæØŸ%™% ›(‘��aæØŸ™ SÓ)�AØ˜d C˜<Ò'à�!‰G�f—k‘k &§+¡+¨a£.Ó1Ñ1°UÑ:‹ñY #ô\ ˜YÓ
'Ð'ó    c                 óš  • UR                   SpCUR                  S:X  a9  U (       a1  X-  nXQS-  :”  a  XQ-  nX-
  U-  n U(       a  XSU4'   US-  nU (       a  M1  OaU (       aZ  U R                  U5      nX-
  R                  U5      n U(       a!  UR	                  5        H  u  pgXsU4U-   '   M     US-  nU (       a  MZ  UR
                  S:  a  U* $ U$ )z-Interpolate polynomial GCD from integer GCD. r   r   r   )Úzeror   Útrunc_groundÚ
quo_groundÚ	itertermsr   )r+   r'   r   r    r(   r!   ÚmonomÚcoeffs           r1   r   r   x   sÏ   € à�9‰9�a€qð ‡z�z�QƒÞØ‘ˆAØ˜‘6‹z˜1™6˜1Ø‘˜1‘ˆAö Ø�1�$‘Ø�‰FˆA÷ ˆaøö Ø—‘˜qÓ!ˆAØ‘×"Ñ" 1Ó%ˆAö Ø$%§K¡K¦M‘L�EØ&+�q�d˜U‘l“Oñ %2à�‰FˆA÷ ˆað 	‡t�tˆaƒxØˆrˆ	àˆ	r2   N)Ú__doc__Ú
polyerrorsr   r   r   r   © r2   r1   Ú<module>r=      s   ðÙ 3å *à€òo(óbr2   