§
    OŠtjÅ'  ã                   óf  — d Z ddlmZ ddlmZmZmZmZmZm	Z	m
Z
mZ ddlmZmZ ddlmZ ddlmZ d„ Zedd
„¦   «         Zd„ Zdd„Zd„ Zd„ Zd„ Zd„ Zedd„¦   «         Zedd„¦   «         Zd„ Zd„ Zedd„¦   «         Zedd„¦   «         Z d„ Z!edd„¦   «         Z"d„ Z#edd„¦   «         Z$d„ Z%d„ Z&dd„Z'dS ) 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           	      ó~  — | dk     r|j         gS |j         g||z    |d¦  «        z  |j         z   ||z
   |d¦  «        z  g}}t          d| dz   ¦  «        D �]g} ||¦  «        ||z   |z   z  ||z    |d¦  «        |z  z    |d¦  «        z
  z  }||z    |d¦  «        |z  z   |j         z
  ||z  ||z  z
  z   |d¦  «        |z  z  }||z    |d¦  «        |z  z   |j         z
  ||z    |d¦  «        |z  z    |d¦  «        z
  z  ||z    |d¦  «        |z  z   z   |d¦  «        |z  z  }	||z   |j         z
  ||z   |j         z
  z  ||z    |d¦  «        |z  z   z  |z  }
t          |||¦  «        }t          t          |d|¦  «        |	|¦  «        }t          ||
|¦  «        }|t	          t          |||¦  «        ||¦  «        }}�Œi|S )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                 úT/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/sympy/polys/orthopolys.pyÚ
dup_jacobir$   	   s  € àˆ1‚u€uØ”ˆwˆØŒeˆW˜˜!™˜Q˜Q˜q™TœT‘z A¤EÑ)¨A¨a©C°°°1±´©:Ð6ˆ€BÝ�1�a˜‘c‰]Œ]ð 8ñ 8ˆØˆa�‰dŒd�A˜‘E˜A‘IÑ  A¡¨¨¨!©¬¨Q©¡°°°1±´Ñ 5Ñ6ˆØ�!‰e�a�a˜‘d”d˜1‘f‰n˜qœuÑ$¨¨1©¨q°©s©Ñ3°q°q¸±t´t¸C±xÑ@ˆØ�!‰e�a�a˜‘d”d˜1‘f‰n˜qœuÑ$¨¨Q©°°°1±´°a±©¸!¸!¸A¹$¼$Ñ)>Ñ?À1ÀqÁ5È1È1ÈQÉ4Ì4ÐPQÉ6Á>ÑRÐVWÐVWÐXYÑVZÔVZÐ[^ÑV^Ñ_ˆØ�!‰e�a”e‰m˜a !™e a¤e™mÑ,¨a°!©e°a°a¸±d´d¸1±f©nÑ=ÀÑCˆÝ˜B  AÑ&Ô&ˆÝ�J r¨1¨aÑ0Ô0°"°aÑ8Ô8ˆÝ˜B  AÑ&Ô&ˆØ•W�W R¨¨QÑ/Ô/°°QÑ7Ô7ˆBˆ‰Ø€Ió    NFc           	      ó:   — t          | t          dd|||f|¦  «        S )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Ð+>ÀÀAÀqÀ	È5ÑQÔQÐQr%   c                 ó¸  — | dk     r|j         gS |j         g |d¦  «        |z  |j        g}}t          d| dz   ¦  «        D ]š}t          t	          |d|¦  «         |d¦  «        ||j         z
  z   ||¦  «        z   |d¦  «        z   |¦  «        }t          | |d¦  «        ||j         z
  z   ||¦  «        z  |j         z   |¦  «        }|t          |||¦  «        }}Œ›|S )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€uØ”ˆwˆØŒeˆW�q�q˜‘t”t˜A‘v˜qœvÐ&ˆ€BÝ�1�a˜‘c‰]Œ]ð (ð (ˆÝ�J r¨1¨aÑ0Ô0°!°!°A±$´$¸¸!¼%¹±.ÀÀÀ1ÁÄÑ2EÈÈÈ!ÉÌÑ2LÈaÑPÔPˆÝ˜B   !¡¤ a¨¬¡g¡¨q¨q°©t¬tÑ 3°a´eÑ ;¸QÑ?Ô?ˆØ•W˜R  QÑ'Ô'ˆBˆˆØ€Ir%   c                 ó8   — t          | t          dd||f|¦  «        S )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ÈÈAÈÐPUÑVÔVÐVr%   c                 ój   — | dk     r|j         gS | dk     rt          | |¦  «        S t          | |¦  «        S )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   s=   € àˆ1‚u€uØ”ˆwˆàˆ2‚v€vÝ" 1 aÑ(Ô(Ð(Ý  1Ñ%Ô%Ð%r%   c                 óÐ   — |j         g|j         |j        g}}t          | dz
  ¦  «        D ]<}|t          t	          t          |d|¦  «         |d¦  «        |¦  «        ||¦  «        }}Œ=|S )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   sq   € ð2 ŒeˆW�q”u˜aœf�oˆ€BÝ�1�q‘5‰\Œ\ð Sð SˆØ•W�^­J°r¸1¸aÑ,@Ô,@À!À!ÀAÁ$Ä$ÈÑJÔJÈBÐPQÑRÔRˆBˆˆØ€Ir%   c           
      ó
  — |j         |j        g |d¦  «        |j        |j          g}}t          | ¦  «        dd…         D ]Ã}t          t	          t          |||¦  «         |d¦  «        |¦  «        |j         d|¦  «        }|dk    r?|t          t	          t          ||¦  «         |d¦  «        |¦  «        |j         |¦  «        }}Œ…t          t	          t          ||¦  «         |d¦  «        |¦  «        |j         |¦  «        |}}ŒÄ|S )a§   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�Q”Vˆ_˜q˜q ™tœt Q¤V¨a¬e¨VÐ4ˆ€BÝ�‰VŒV�A�B�BŒZð Zð ZˆÝ�­°°B¸Ñ(:Ô(:¸A¸A¸a¹D¼DÀ!ÑDÔDÀaÄeÈQÐPQÑRÔRˆØ�#ŠIˆIØ�¥~µg¸bÀ!±n´nÀaÀaÈÁdÄdÈAÑ'NÔ'NÐPQÔPUÐWXÑYÔY�ˆBˆBå#¥Nµ7¸2¸q±>´>À1À1ÀQÁ4Ä4ÈÑ$KÔ$KÈQÌUÐTUÑVÔVÐXY�ˆBˆBØ€Ir%   c                 óö   — | dk     r|j         gS |j         g |d¦  «        |j        g}}t          d| dz   ¦  «        D ]<}|t          t	          t          |d|¦  «         |d¦  «        |¦  «        ||¦  «        }}Œ=|S )zELow-level implementation of Chebyshev polynomials of the second kind.r   r   r6   ©r   r   r   r   r   s        r#   Údup_chebyshevur?   �   s‰   € àˆ1‚u€uØ”ˆwˆØŒeˆW�q�q˜‘t”t˜QœV�nˆ€BÝ�1�a˜‘c‰]Œ]ð Sð SˆØ•W�^­J°r¸1¸aÑ,@Ô,@À!À!ÀAÁ$Ä$ÈÑJÔJÈBÐPQÑRÔRˆBˆˆØ€Ir%   c                 ó@   — t          | t          t          d|f|¦  «        S )a  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ð Cr%   c                 ó@   — t          | t          t          d|f|¦  «        S )a  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ð Dr%   c           	      ó4  — | dk     r|j         gS |j         g |d¦  «        |j        g}}t          d| dz   ¦  «        D ][}t          |d|¦  «        }t	          | ||dz
  ¦  «        |¦  «        }|t	          t          |||¦  «         |d¦  «        |¦  «        }}Œ\|S )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€uØ”ˆwˆØŒeˆW�q�q˜‘t”t˜QœV�nˆ€BÝ�1�a˜‘c‰]Œ]ð ?ð ?ˆÝ�r˜1˜aÑ Ô ˆÝ˜2˜q˜q  1¡™vœv qÑ)Ô)ˆØ•^¥G¨A¨q°!Ñ$4Ô$4°a°a¸±d´d¸AÑ>Ô>ˆBˆˆØ€Ir%   c                 óü   — | dk     r|j         gS |j         g|j         |j        g}}t          d| dz   ¦  «        D ]C}t          |d|¦  «        }t	          | ||dz
  ¦  «        |¦  «        }|t          |||¦  «        }}ŒD|S )z>Low-level implementation of probabilist's Hermite polynomials.r   r   rF   rG   s          r#   Údup_hermite_probrJ   Á   sŽ   € àˆ1‚u€uØ”ˆwˆØŒeˆW�q”u˜aœf�oˆ€BÝ�1�a˜‘c‰]Œ]ð &ð &ˆÝ�r˜1˜aÑ Ô ˆÝ˜2˜q˜q  1¡™vœv qÑ)Ô)ˆØ•W˜Q  1Ñ%Ô%ˆBˆˆØ€Ir%   c                 ó@   — t          | t          t          d|f|¦  «        S )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ÔLÐLr%   c                 ó@   — t          | t          t          d|f|¦  «        S )a  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                 ó<  — | dk     r|j         gS |j         g|j         |j        g}}t          d| dz   ¦  «        D ]c}t          t	          |d|¦  «         |d|z  dz
  |¦  «        |¦  «        }t          | ||dz
  |¦  «        |¦  «        }|t          |||¦  «        }}Œd|S )z1Low-level implementation of Legendre polynomials.r   r   r+   rG   s          r#   Údup_legendrerP   ë   s®   € àˆ1‚u€uØ”ˆwˆØŒeˆW�q”u˜aœf�oˆ€BÝ�1�a˜‘c‰]Œ]ð &ð &ˆÝ�: b¨!¨QÑ/Ô/°°°1°Q±3°q±5¸!±´¸aÑ@Ô@ˆÝ˜2˜q˜q  1¡ a™yœy¨!Ñ,Ô,ˆØ•W˜Q  1Ñ%Ô%ˆBˆˆØ€Ir%   c                 ó@   — t          | t          t          d|f|¦  «        S )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ÔNÐNr%   c           	      ó\  — |j         g|j        g}}t          d| dz   ¦  «        D ]‡}t          ||j          ||¦  «        z  ||j        z
   ||¦  «        z   |d¦  «        z   g|¦  «        }t	          |||j        z
   ||¦  «        z  |j        z   |¦  «        }|t          |||¦  «        }}Œˆ|S )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ˆX˜œ�wˆ€BÝ�1�a˜‘c‰]Œ]ð &ð &ˆÝ�B˜!œ%˜   !¡¤™ u¨Q¬U¡{°A°A°a±D´DÑ&8¸1¸1¸Q¹4¼4Ñ&?Ð@À!ÑDÔDˆÝ˜2  a¤e¡¨Q¨Q¨q©T¬TÑ1°A´EÑ9¸1Ñ=Ô=ˆØ•W˜Q  1Ñ%Ô%ˆBˆˆØ€Ir%   c                 ó8   — t          | t          dd||f|¦  «        S )aQ  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ÔVÐVr%   c                 ó$  — | dk     r|j         |j        gS |j         g|j         |j        g}}t          d| dz   ¦  «        D ]B}|t          t	          t          |d|¦  «         |d|z  dz
  ¦  «        |¦  «        ||¦  «        }}ŒCt          |d|¦  «        S )z%Low-level implementation of fn(n, x).r   r   r6   r>   s        r#   Údup_spherical_bessel_fnrY     sž   € àˆ1‚u€uØ”�q”vˆÐØŒeˆW�q”u˜aœf�oˆ€BÝ�1�a˜‘c‰]Œ]ð Wð WˆØ•W�^­J°r¸1¸aÑ,@Ô,@À!À!ÀAÀaÁCÈÁEÁ(Ä(ÈAÑNÔNÐPRÐTUÑVÔVˆBˆˆÝ�b˜!˜QÑÔÐr%   c                 óÞ   — |j         |j        g|j        g}}t          d| dz   ¦  «        D ]B}|t          t	          t          |d|¦  «         |dd|z  z
  ¦  «        |¦  «        ||¦  «        }}ŒC|S )z&Low-level implementation of fn(-n, x).r   r   r9   r6   r>   s        r#   Údup_spherical_bessel_fn_minusr[   (  sz   € àŒe�Q”Vˆ_˜qœv˜hˆ€BÝ�1�a˜‘c‰]Œ]ð Wð WˆØ•W�^­J°r¸1¸aÑ,@Ô,@À!À!ÀAÀaÈÁcÁEÁ(Ä(ÈAÑNÔNÐPRÐTUÑVÔVˆBˆˆØ€Ir%   c           	      óº   — |€t          d¦  «        }| dk     rt          nt          }t          t	          | ¦  «        |t
          dt          d¦  «        |z  f|¦  «        S )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

    Nr'   r   Ú r   )r   r[   rY   r   Úabsr   r   )r   r'   r(   Úfs       r#   Úspherical_bessel_fnr`   /  sS   € ðJ 	€yÝ�#‰JŒJˆØ)*¨Qª¨Õ%Ð%Õ4K€AÝ•c˜!‘f”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ð Ið Ið Ið Ið Ið Ið Ið Ið Ið Ið Ið Ið Ið Ið Ið Ið Ià &Ð &Ð &Ð &Ð &Ð &Ð &Ð &Ø ,Ð ,Ð ,Ð ,Ð ,Ð ,Ø "Ð "Ð "Ð "Ð "Ð "ðð ð ð  ðRð Rð Rñ „ðRð$	ð 	ð 	ðWð Wð Wð Wð &ð &ð &ðð ð ð<ð ð ð>ð ð ð ðCð Cð Cñ „ðCð ðDð Dð Dñ „ðDð	ð 	ð 	ð	ð 	ð 	ð ðMð Mð Mñ „ðMð ð=ð =ð =ñ „ð=ð	ð 	ð 	ð ðOð Oð Oñ „ðOðð ð ð ðWð Wð Wñ „ðWð  ð  ð  ðð ð ð(<ð (<ð (<ð (<ð (<ð (<r%   