+
    þäûj{  ã                   óT   € R t ^ RIHtHtHt ^ RIHtHtHt ^ RI	H
t
 RR ltR tR tR# )	z1Gosper's algorithm for hypergeometric summation. )ÚSÚDummyÚsymbols)ÚPolyÚparallel_poly_from_exprÚfactor)Úis_sequencec                óÈ  € \        W3VRRR7      w  w  rEpVP                  4       VP                  4       r‡VP                  4       VP                  4       r©VP                  Wy,          rË\	        R4      p\        W-,           W-VP                  R7      pVP                  V
P                  V4      4      pVP                  4       P                  4        Uu0 uF"  pVP                  '       g   K  V^ 8¼  g   K   VkK$  	  pp\        V4       F‰  pVP                  V
P                  V54      4      pVP                  V4      pV
P                  VP                  V) 4      4      p
\!        ^V^,           4       F  pVVP                  V) 4      ,          pK  	  K‹  	  VP#                  V4      pV'       g1   VP%                  4       pV
P%                  4       p
VP%                  4       pWŠV3# u upi )aü  
Compute the Gosper's normal form of ``f`` and ``g``.

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

Given relatively prime univariate polynomials ``f`` and ``g``,
rewrite their quotient to a normal form defined as follows:

.. math::
    \frac{f(n)}{g(n)} = Z \cdot \frac{A(n) C(n+1)}{B(n) C(n)}

where ``Z`` is an arbitrary constant and ``A``, ``B``, ``C`` are
monic polynomials in ``n`` with the following properties:

1. `\gcd(A(n), B(n+h)) = 1 \forall h \in \mathbb{N}`
2. `\gcd(B(n), C(n+1)) = 1`
3. `\gcd(A(n), C(n)) = 1`

This normal form, or rational factorization in other words, is a
crucial step in Gosper's algorithm and in solving of difference
equations. It can be also used to decide if two hypergeometric
terms are similar or not.

This procedure will return a tuple containing elements of this
factorization in the form ``(Z*A, B, C)``.

Examples
========

>>> from sympy.concrete.gosper import gosper_normal
>>> from sympy.abc import n

>>> gosper_normal(4*n+5, 2*(4*n+1)*(2*n+3), n, polys=False)
(1/4, n + 3/2, n + 1/4)

T)ÚfieldÚ	extensionÚh©Údomain)r   ÚLCÚmonicÚoner   r   r   Ú	resultantÚcomposeÚground_rootsÚkeysÚ
is_IntegerÚsortedÚgcdÚshiftÚquoÚrangeÚ
mul_groundÚas_expr)ÚfÚgÚnÚpolysÚpÚqÚoptÚaÚAÚbÚBÚCÚZr   ÚDÚRÚrÚrootsÚiÚdÚjs   &&&&                 ÚQC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\sympy\concrete\gosper.pyÚgosper_normalr3      ss  € ôL *Ø	
ˆ�˜¨ô/�K�F€QˆCð �4‰4‹6�1—7‘7“9€qØ�4‰4‹6�1—7‘7“9€qà�5‰5�!•#€qÜˆc‹
€AäˆQ�U�A §¡Ô,€Aà	�‰�A—I‘I˜a“LÓ!€AØŸ™Ó(×-Ñ-Ô/ÓKÑ/�1°1·<µ<ŒQÀAÈÁF�QˆQÑ/€EÐKÜ�EŽ]ˆØ�E‰E�!—'‘'˜1˜"“+Óˆà�E‰E�!‹HˆØ�E‰E�!—'‘'˜1˜"“+Óˆä�q˜!˜a�%–ˆAØ�—‘˜!˜“ÕŠAó !ñ ð 	
�‰�Q‹€AçØ�I‰I‹KˆØ�I‰I‹KˆØ�I‰I‹Kˆà�ˆ7€Nùò# Ls   ÃGÃ)GÃ2Gc                ó€  € ^ RI Hp V! W4      pVf   R# VP                  4       w  rE\        WEV4      w  rgpVP	                  R4      p\        VP                  4       4      p	\        VP                  4       4      p
\        VP                  4       4      pWš8w  g$   VP                  4       VP                  4       8w  d   V\        Wš4      ,
          0pM�V	'       g!   W¹,
          ^,           \
        P                  0pMYW¹,
          ^,           VP                  V	^,
          4      VP                  V	^,
          4      ,
          VP                  4       ,          0p\        V4       F/  pVP                  '       d
   V^ 8  g   K  VP                  V4       K1  	  V'       g   R# \        V4      p\        RV^,           ,          \        R7      pVP!                  4       P"                  ! V!  p\%        WáVR7      pVVP	                  ^4      ,          VV,          ,
          V,
          p^ RIHp V! VP+                  4       V4      pVf   R# VP-                  4       P/                  V4      pV F  pVV9  g   K  VP/                  V^ 4      pK   	  VP0                  '       d   R# VP-                  4       V,          VP-                  4       ,          # )aæ  
Compute Gosper's hypergeometric term for ``f``.

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

Suppose ``f`` is a hypergeometric term such that:

.. math::
    s_n = \sum_{k=0}^{n-1} f_k

and `f_k` does not depend on `n`. Returns a hypergeometric
term `g_n` such that `g_{n+1} - g_n = f_n`.

Examples
========

>>> from sympy.concrete.gosper import gosper_term
>>> from sympy import factorial
>>> from sympy.abc import n

>>> gosper_term((4*n + 1)*factorial(n)/factorial(2*n + 1), n)
(-n - 1/2)/(n + 1/4)

)Ú	hypersimpNzc:%s)Úclsr   )Úsolveéÿÿÿÿ)Úsympy.simplifyr5   Úas_numer_denomr3   r   r   Údegreer   ÚmaxÚZeroÚnthÚsetr   Úremover   r   Ú
get_domainÚinjectr   Úsympy.solvers.solversr7   Úcoeffsr   ÚsubsÚis_zero)r   r    r5   r-   r"   r#   r&   r(   r)   ÚNÚMÚKr+   r0   rD   r   ÚxÚHr7   ÚsolutionÚcoeffs   &&                   r2   Úgosper_termrN   N   sö  € õ4 )Ù�!‹€Aà‚yÙà×ÑÓ�D€Aä˜A !Ó$�G€Aˆ!Ø	�‰�‹€Aä	ˆ!�(‰(‹*‹€AÜ	ˆ!�(‰(‹*‹€AÜ	ˆ!�(‰(‹*‹€Aà	Œ�A—D‘D“F˜aŸd™d›fÔ$Ø”�Q“�]ˆO‰ßØ�U�Q�YœŸ™Ð‰à�U�Q�Y˜Ÿ™˜q 1�u›¨¯©¨a°!­e«Õ4°a·d±d³fÕ<Ð=ˆä�ŽVˆØ�|�|ˆ|˜q 1žuØ�H‰H�QŽKñ ÷ ÙäˆA‹€Aä�V˜q 1�uÕ%¬5Ô1€FØ�\‰\‹^×"Ò" FÑ+€FäˆV˜vÔ&€AØ	ˆ!�'‰'�!‹*��q˜•sÕ˜QÕ€Aå+Ù�Q—X‘X“Z Ó(€HàÒÙà	�	‰	‹×Ñ˜Ó"€AãˆØ˜Ö Ø—‘�u˜aÓ ŠAñ ð 	‡y‡y€yÙà�y‰y‹{˜1�}˜QŸY™Y›[Õ(Ð(ó    c                óÎ  € Rp\        V4      '       d   Vw  rpMRp\        W4      pVf   R# V'       d
   W,          pM‹W^,           ,          P                  VX4      W,          P                  VX4      ,
          pV\        P                  J d<    W^,           ,          P                  W4      W,          P                  W4      ,
          p\        V4      #   \         d    Rp Li ; i)aÒ  
Gosper's hypergeometric summation algorithm.

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

Given a hypergeometric term ``f`` such that:

.. math ::
    s_n = \sum_{k=0}^{n-1} f_k

and `f(n)` does not depend on `n`, returns `g_{n} - g(0)` where
`g_{n+1} - g_n = f_n`, or ``None`` if `s_n` cannot be expressed
in closed form as a sum of hypergeometric terms.

Examples
========

>>> from sympy.concrete.gosper import gosper_sum
>>> from sympy import factorial
>>> from sympy.abc import n, k

>>> f = (4*k + 1)*factorial(k)/factorial(2*k + 1)
>>> gosper_sum(f, (k, 0, n))
(-factorial(n) + 2*factorial(2*n + 1))/factorial(2*n + 1)
>>> _.subs(n, 2) == sum(f.subs(k, i) for i in [0, 1, 2])
True
>>> gosper_sum(f, (k, 3, n))
(-60*factorial(n) + factorial(2*n + 1))/(60*factorial(2*n + 1))
>>> _.subs(n, 5) == sum(f.subs(k, i) for i in [3, 4, 5])
True

References
==========

.. [1] Marko Petkovsek, Herbert S. Wilf, Doron Zeilberger, A = B,
       AK Peters, Ltd., Wellesley, MA, USA, 1997, pp. 73--100

FTN)r   rN   rE   r   ÚNaNÚlimitÚNotImplementedErrorr   )r   ÚkÚ
indefiniter%   r'   r   Úresults   &&     r2   Ú
gosper_sumrW   Ÿ   s¿   € ðP €Jä�1‡~‚~Ø‰ˆ‰aàˆ
ä�AÓ€Aà‚yÙçØ•‰à˜•U•)×!Ñ! ! QÓ'¨1­3¯*©*°Q¸Ó*:Õ:ˆà”Q—U‘U‹?ðØ �U�)×*Ñ*¨1Ó0°AµC·;±;¸qÓ3DÕD�ô �&‹>Ðøô 'ô Ø’ðús   Â:C ÃC$Ã#C$N)T)Ú__doc__Ú
sympy.corer   r   r   Úsympy.polysr   r   r   Úsympy.utilities.iterablesr   r3   rN   rW   © rO   r2   Ú<module>r]      s*   ðÙ 7ç (Ñ (ß =Ñ =Ý 1ôCòLN)ôb?rO   