ó
    Š*£hÅ'  ã                   óL  • S r SSKJr  SSKJrJrJrJrJrJ	r	J
r
Jr  SSKJrJr  SSKJr  SSKJr  S r\SS	 j5       rS
 rSS jrS rS rS rS r\SS j5       r\SS j5       rS rS r\SS j5       r\SS j5       r S r!\SS j5       r"S r#\SS j5       r$S r%S r&SS jr'g)z:Efficient functions for generating orthogonal polynomials.é    )ÚDummy)Údup_mulÚdup_mul_groundÚ
dup_lshiftÚdup_subÚdup_addÚdup_sub_termÚdup_sub_groundÚdup_sqr)ÚZZÚQQ)Ú
named_poly)Úpublicc           	      ó  • U S:  a  UR                   /$ UR                   /X-   U" S5      -  UR                   -   X-
  U" S5      -  /pT[        SU S-   5       GH2  nU" U5      X-   U-   -  X-   U" S5      U-  -   U" S5      -
  -  nX-   U" S5      U-  -   UR                   -
  X-  X"-  -
  -  U" S5      U-  -  nX-   U" S5      U-  -   UR                   -
  X-   U" S5      U-  -   U" S5      -
  -  X-   U" S5      U-  -   -  U" S5      U-  -  n	X-   UR                   -
  X&-   UR                   -
  -  X-   U" S5      U-  -   -  U-  n
[        XXU5      n[        [        USU5      X“5      n[        XJU5      nU[	        [        X¼U5      XÓ5      pTGM5     U$ )z/Low-level implementation of Jacobi polynomials.é   é   )ÚoneÚranger   r   r   r   )ÚnÚaÚbÚKÚm2Úm1ÚiÚdenÚf0Úf1Úf2Úp0Úp1Úp2s                 ÚS/home/mande/repo/quber/.venv/lib/python3.13/site-packages/sympy/polys/orthopolys.pyÚ
dup_jacobir$   	   sš  € àˆ1ƒuØ—‘ˆwˆØ�e‰eˆW˜™™Q˜q›T‘z A§E¡EÑ)¨A©C±°1³©:Ð6ˆÜ�1�a˜‘c�]ˆÙ�‹d�A‘E˜A‘IÑ ¡©¨!«¨Q©¡±°1³Ñ 5Ñ6ˆØ‰e‘a˜“d˜1‘f‰n˜qŸu™uÑ$¨©¨q©s©Ñ3±q¸³t¸C±xÑ@ˆØ‰e‘a˜“d˜1‘f‰n˜qŸu™uÑ$¨©±°1³°a±©¹!¸A»$Ñ)>Ñ?À1Á5É1ÈQË4ÐPQÉ6Á>ÑRÑVWÐXYÓVZÐ[^ÑV^Ñ_ˆØ‰e�a—e‘e‰m˜a™e a§e¡e™mÑ,¨a©e±a¸³d¸1±f©nÑ=ÀÑCˆÜ˜B AÓ&ˆÜœJ r¨1¨aÓ0°"Ó8ˆÜ˜B AÓ&ˆØ”WœW R¨QÓ/°Ó7‹Bñ ð €Ió    Nc           	      ó.   • [        U [        SSX1U4U5      $ )a^  Generates the Jacobi polynomial `P_n^{(a,b)}(x)`.

Parameters
==========

n : int
    Degree of the polynomial.
a
    Lower limit of minimal domain for the list of coefficients.
b
    Upper limit of minimal domain for the list of coefficients.
x : optional
polys : bool, optional
    If True, return a Poly, otherwise (default) return an expression.
NzJacobi polynomial)r   r$   )r   r   r   ÚxÚpolyss        r#   Újacobi_polyr)      s   € ô" �aœ TÐ+>ÀÀqÀ	È5ÓQÐQr%   c                 ó¤  • U S:  a  UR                   /$ UR                   /U" S5      U-  UR                  /pC[        SU S-   5       H†  n[        [	        USU5      U" S5      XR                   -
  -  U" U5      -  U" S5      -   U5      n[        X2" S5      XR                   -
  -  U" U5      -  UR                   -   U5      nU[        XgU5      pCMˆ     U$ )z3Low-level implementation of Gegenbauer polynomials.r   r   ©r   Úzeror   r   r   r   )r   r   r   r   r   r   r!   r"   s           r#   Údup_gegenbauerr-   ,   sÀ   € àˆ1ƒuØ—‘ˆwˆØ�e‰eˆW‘q˜“t˜A‘v˜qŸv™vÐ&ˆÜ�1�a˜‘cŽ]ˆÜœJ r¨1¨aÓ0±!°A³$¸¿%¹%¹±.ÁÀ1ÃÑ2EÉÈ!ËÑ2LÈaÓPˆÜ˜B  !£ a¯©¡g¡©q°«tÑ 3°a·e±eÑ ;¸QÓ?ˆØ”W˜R QÓ'ŠBñ ð €Ir%   c                 ó,   • [        U [        SSX!4U5      $ )a  Generates the Gegenbauer polynomial `C_n^{(a)}(x)`.

Parameters
==========

n : int
    Degree of the polynomial.
x : optional
a
    Decides minimal domain for the list of coefficients.
polys : bool, optional
    If True, return a Poly, otherwise (default) return an expression.
NzGegenbauer polynomial)r   r-   )r   r   r'   r(   s       r#   Úgegenbauer_polyr/   7   s   € ô �aœ¨Ð/FÈÈÐPUÓVÐVr%   c                 ó`   • U S:  a  UR                   /$ U S:  a  [        X5      $ [        X5      $ )zDLow-level implementation of Chebyshev polynomials of the first kind.r   é@   )r   Ú_dup_chebyshevt_recÚ_dup_chebyshevt_prod)r   r   s     r#   Údup_chebyshevtr4   G   s1   € àˆ1ƒuØ—‘ˆwˆàˆ2ƒvÜ" 1Ó(Ð(Ü Ó%Ð%r%   c                 óÊ   • UR                   /UR                   UR                  /p2[        U S-
  5       H,  nU[        [	        [        USU5      U" S5      U5      X!5      p2M.     U$ )a±  Chebyshev polynomials of the first kind using recurrence.

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

Chebyshev polynomials of the first kind are defined by the recurrence
relation:

.. math::
    T_0(x) &= 1\\
    T_1(x) &= x\\
    T_n(x) &= 2xT_{n-1}(x) - T_{n-2}(x)

This function calculates the Chebyshev polynomial of the first kind using
the above recurrence relation.

Parameters
==========

n : int
    n is a nonnegative integer.
K : domain

r   r   ©r   r,   r   r   r   r   )r   r   r   r   Ú_s        r#   r2   r2   P   sX   € ð2 �e‰eˆW�q—u‘u˜aŸf™f�oˆÜ�1�q‘5Ž\ˆØ”Wœ^¬J°r¸1¸aÓ,@Á!ÀAÃ$ÈÓJÈBÓRŠBñ à€Ir%   c           
      óÜ  • UR                   UR                  /U" S5      UR                  UR                   * /p2[        U 5      SS  H¢  n[        [	        [        X2U5      U" S5      U5      UR                   SU5      nUS:X  a4  U[        [	        [        X15      U" S5      U5      UR                   U5      p2Mp  [        [	        [        X!5      U" S5      U5      UR                   U5      Up2M¤     U$ )ar  Chebyshev polynomials of the first kind using recursive products.

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

Computes Chebyshev polynomials of the first kind using

.. math::
    T_{2n}(x) &= 2T_n^2(x) - 1\\
    T_{2n+1}(x) &= 2T_{n+1}(x)T_n(x) - x

This is faster than ``_dup_chebyshevt_rec`` for large ``n``.

Parameters
==========

n : int
    n is a nonnegative integer.
K : domain

r   é   Nr   Ú1)r   r,   Úbinr	   r   r   r
   r   )r   r   r   r   r   Úcs         r#   r3   r3   n   sÇ   € ð, �e‰e�Q—V‘Vˆ_™q ›t Q§V¡V¨a¯e©e¨VÐ4ˆÜ�‹V�A�B‹ZˆÜœ¬°¸Ó(:¹A¸a»DÀ!ÓDÀaÇeÁeÈQÐPQÓRˆØ�#‹IØœ¤~´g¸b³nÁaÈÃdÈAÓ'NÐPQ×PUÑPUÐWXÓY’ä#¤N´7¸2³>Á1ÀQÃ4ÈÓ$KÈQÏUÉUÐTUÓVÐXY’ñ ð €Ir%   c                 óê   • U S:  a  UR                   /$ UR                   /U" S5      UR                  /p2[        SU S-   5       H,  nU[        [	        [        USU5      U" S5      U5      X!5      p2M.     U$ )zELow-level implementation of Chebyshev polynomials of the second kind.r   r   r6   ©r   r   r   r   r   s        r#   Údup_chebyshevur?   �   sj   € àˆ1ƒuØ—‘ˆwˆØ�e‰eˆW‘q˜“t˜QŸV™V�nˆÜ�1�a˜‘cŽ]ˆØ”Wœ^¬J°r¸1¸aÓ,@Á!ÀAÃ$ÈÓJÈBÓRŠBñ à€Ir%   c                 ó4   • [        U [        [        SU4U5      $ )zçGenerates the Chebyshev polynomial of the first kind `T_n(x)`.

Parameters
==========

n : int
    Degree of the polynomial.
x : optional
polys : bool, optional
    If True, return a Poly, otherwise (default) return an expression.
z&Chebyshev polynomial of the first kind)r   r4   r   ©r   r'   r(   s      r#   Úchebyshevt_polyrB   –   s"   € ô �aœ¬Ø4°q°d¸EóCð Cr%   c                 ó4   • [        U [        [        SU4U5      $ )zèGenerates the Chebyshev polynomial of the second kind `U_n(x)`.

Parameters
==========

n : int
    Degree of the polynomial.
x : optional
polys : bool, optional
    If True, return a Poly, otherwise (default) return an expression.
z'Chebyshev polynomial of the second kind)r   r?   r   rA   s      r#   Úchebyshevu_polyrD   ¦   s"   € ô �aœ¬Ø5¸°t¸UóDð Dr%   c           	      ó  • U S:  a  UR                   /$ UR                   /U" S5      UR                  /p2[        SU S-   5       HC  n[        USU5      n[	        X!" US-
  5      U5      nU[	        [        XVU5      U" S5      U5      p2ME     U$ )z0Low-level implementation of Hermite polynomials.r   r   ©r   r,   r   r   r   r   ©r   r   r   r   r   r   r   s          r#   Údup_hermiterH   ¶   s‡   € àˆ1ƒuØ—‘ˆwˆØ�e‰eˆW‘q˜“t˜QŸV™V�nˆÜ�1�a˜‘cŽ]ˆÜ�r˜1˜aÓ ˆÜ˜2˜q  1¡›v qÓ)ˆØ”^¤G¨A°!Ó$4±a¸³d¸AÓ>ŠBñ ð €Ir%   c                 óþ   • U S:  a  UR                   /$ UR                   /UR                   UR                  /p2[        SU S-   5       H2  n[        USU5      n[	        X!" US-
  5      U5      nU[        XVU5      p2M4     U$ )z>Low-level implementation of probabilist's Hermite polynomials.r   r   rF   rG   s          r#   Údup_hermite_probrJ   Á   sz   € àˆ1ƒuØ—‘ˆwˆØ�e‰eˆW�q—u‘u˜aŸf™f�oˆÜ�1�a˜‘cŽ]ˆÜ�r˜1˜aÓ ˆÜ˜2˜q  1¡›v qÓ)ˆØ”W˜Q 1Ó%ŠBñ ð €Ir%   c                 ó4   • [        U [        [        SU4U5      $ )zÓGenerates the Hermite polynomial `H_n(x)`.

Parameters
==========

n : int
    Degree of the polynomial.
x : optional
polys : bool, optional
    If True, return a Poly, otherwise (default) return an expression.
zHermite polynomial)r   rH   r   rA   s      r#   Úhermite_polyrL   Ì   s   € ô �aœ¤bÐ*>ÀÀÀeÓLÐLr%   c                 ó4   • [        U [        [        SU4U5      $ )zâGenerates the probabilist's Hermite polynomial `He_n(x)`.

Parameters
==========

n : int
    Degree of the polynomial.
x : optional
polys : bool, optional
    If True, return a Poly, otherwise (default) return an expression.
z probabilist's Hermite polynomial)r   rJ   r   rA   s      r#   Úhermite_prob_polyrN   Û   s!   € ô �aÔ)¬2Ø.°°°eó=ð =r%   c                 ó0  • U S:  a  UR                   /$ UR                   /UR                   UR                  /p2[        SU S-   5       HK  n[        [	        USU5      U" SU-  S-
  U5      U5      n[        X!" US-
  U5      U5      nU[        XVU5      p2MM     U$ )z1Low-level implementation of Legendre polynomials.r   r   r+   rG   s          r#   Údup_legendrerP   ë   s“   € àˆ1ƒuØ—‘ˆwˆØ�e‰eˆW�q—u‘u˜aŸf™f�oˆÜ�1�a˜‘cŽ]ˆÜœ: b¨!¨QÓ/±°1°Q±3°q±5¸!³¸aÓ@ˆÜ˜2˜q  1¡ a›y¨!Ó,ˆØ”W˜Q 1Ó%ŠBñ ð €Ir%   c                 ó4   • [        U [        [        SU4U5      $ )zÔGenerates the Legendre polynomial `P_n(x)`.

Parameters
==========

n : int
    Degree of the polynomial.
x : optional
polys : bool, optional
    If True, return a Poly, otherwise (default) return an expression.
zLegendre polynomial)r   rP   r   rA   s      r#   Úlegendre_polyrR   ö   s   € ô �aœ¤rÐ+@À1À$ÈÓNÐNr%   c           	      ó\  • UR                   /UR                  /pC[        SU S-   5       H  n[        XBR                  * U" U5      -  XR                  -
  U" U5      -  U" S5      -   /U5      n[	        X1UR                  -
  U" U5      -  UR                  -   U5      nU[        XgU5      pCM�     U$ )z1Low-level implementation of Laguerre polynomials.r   r   )r,   r   r   r   r   r   )r   Úalphar   r   r   r   r   r   s           r#   Údup_laguerrerU     s›   € à�f‰fˆX˜Ÿ™�wˆÜ�1�a˜‘cŽ]ˆÜ�BŸ%™%˜¡ !£™ u¯U©U¡{±A°a³DÑ&8¹1¸Q»4Ñ&?Ð@À!ÓDˆÜ˜2 a§e¡e¡©Q¨q«TÑ1°A·E±EÑ9¸1Ó=ˆØ”W˜Q 1Ó%ŠBñ ð €Ir%   c                 ó,   • [        U [        SSX4U5      $ )a)  Generates the Laguerre polynomial `L_n^{(\alpha)}(x)`.

Parameters
==========

n : int
    Degree of the polynomial.
x : optional
alpha : optional
    Decides minimal domain for the list of coefficients.
polys : bool, optional
    If True, return a Poly, otherwise (default) return an expression.
NzLaguerre polynomial)r   rU   )r   r'   rT   r(   s       r#   Úlaguerre_polyrW     s   € ô �aœ tÐ-BÀQÀJÐPUÓVÐVr%   c                 ó*  • U S:  a  UR                   UR                  /$ UR                   /UR                   UR                  /p2[        SU S-   5       H2  nU[        [	        [        USU5      U" SU-  S-
  5      U5      X!5      p2M4     [        USU5      $ )z%Low-level implementation of fn(n, x).r   r   r6   r>   s        r#   Údup_spherical_bessel_fnrY     s„   € àˆ1ƒuØ—‘�q—v‘vˆÐØ�e‰eˆW�q—u‘u˜aŸf™f�oˆÜ�1�a˜‘cŽ]ˆØ”Wœ^¬J°r¸1¸aÓ,@Á!ÀAÀaÁCÈÁEÃ(ÈAÓNÐPRÓVŠBñ ä�b˜!˜QÓÐr%   c                 óØ   • UR                   UR                  /UR                  /p2[        SU S-   5       H2  nU[        [	        [        USU5      U" SSU-  -
  5      U5      X!5      p2M4     U$ )z&Low-level implementation of fn(-n, x).r   r   r9   r6   r>   s        r#   Údup_spherical_bessel_fn_minusr[   (  sa   € à�e‰e�Q—V‘Vˆ_˜qŸv™v˜hˆÜ�1�a˜‘cŽ]ˆØ”Wœ^¬J°r¸1¸aÓ,@Á!ÀAÀaÈÁcÁEÃ(ÈAÓNÐPRÓVŠBñ à€Ir%   c           	      ó–   • Uc  [        S5      nU S:  a  [        O[        n[        [	        U 5      U[
        S[        S5      U-  4U5      $ )a|  
Coefficients for the spherical Bessel functions.

These are only needed in the jn() function.

The coefficients are calculated from:

fn(0, z) = 1/z
fn(1, z) = 1/z**2
fn(n-1, z) + fn(n+1, z) == (2*n+1)/z * fn(n, z)

Parameters
==========

n : int
    Degree of the polynomial.
x : optional
polys : bool, optional
    If True, return a Poly, otherwise (default) return an expression.

Examples
========

>>> from sympy.polys.orthopolys import spherical_bessel_fn as fn
>>> from sympy import Symbol
>>> z = Symbol("z")
>>> fn(1, z)
z**(-2)
>>> fn(2, z)
-1/z + 3/z**3
>>> fn(3, z)
-6/z**2 + 15/z**4
>>> fn(4, z)
1/z - 45/z**3 + 105/z**5

r'   r   Ú r   )r   r[   rY   r   Úabsr   r   )r   r'   r(   Úfs       r#   Úspherical_bessel_fnr`   /  sE   € ðJ 	�yÜ�#‹JˆØ)*¨Q«Õ%Ô4K€AÜ”c˜!“f˜a¤ R¬"¨Q«%°©'¨°UÓ;Ð;r%   )NF)Nr   F)(Ú__doc__Úsympy.core.symbolr   Úsympy.polys.densearithr   r   r   r   r   r	   r
   r   Úsympy.polys.domainsr   r   Úsympy.polys.polytoolsr   Úsympy.utilitiesr   r$   r)   r-   r/   r4   r2   r3   r?   rB   rD   rH   rJ   rL   rN   rP   rR   rU   rW   rY   r[   r`   © r%   r#   Ú<module>rh      s  ðÙ @Ý #÷I÷ Ió Iç &Ý ,Ý "òð  óRó ðRò$	ôWò &òò<ò>ð óCó ðCð óDó ðDò	ò	ð óMó ðMð ó=ó ð=ò	ð óOó ðOòð óWó ðWò  òõ(<r%   