
    g~                     Z   d Z ddlmZ ddlmZmZ ddlmZ ddlm	Z	 ddl
mZmZmZ ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZmZ ddlm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%  e	d          Z& G d de          Z' G d de'          Z(d Z) G d de'          Z* G d de'          Z+ G d de'          Z, G d de          Z- G d de          Z. G d d e'          Z/ G d! d"e          Z0 G d# d$e'          Z1 G d% d&e'          Z2 G d' d(e'          Z3 G d) d*e'          Z4d+S ),z
This module mainly implements special orthogonal polynomials.

See also functions.combinatorial.numbers which contains some
combinatorial polynomials.

    )Rational)FunctionArgumentIndexError)S)Dummy)binomial	factorialRisingFactorial)re)exp)floor)sqrt)cossec)gamma)hyper)chebyshevt_polychebyshevu_polygegenbauer_polyhermite_polyhermite_prob_polyjacobi_polylaguerre_polylegendre_polyxc                   .    e Zd ZdZed             Zd ZdS )OrthogonalPolynomialz+Base class for orthogonal polynomials.
    c                     |j         rG|dk    rC|                     t          |          t                                        t          |          S d S d S )Nr   )
is_integer_ortho_polyint_xsubsclsnr   s      _/var/www/html/ai-engine/env/lib/python3.11/site-packages/sympy/functions/special/polynomials.py_eval_at_orderz#OrthogonalPolynomial._eval_at_order    sL    < 	;AFF??3q662..33B:::	; 	;FF    c                 ~    |                      | j        d         | j        d                                                   S )Nr      )funcargs	conjugate)selfs    r'   _eval_conjugatez$OrthogonalPolynomial._eval_conjugate%   s.    yy1ty|'='='?'?@@@r)   N)__name__
__module____qualname____doc__classmethodr(   r0    r)   r'   r   r      sM          ; ; [;A A A A Ar)   r   c                   B    e Zd ZdZed             Zd	dZd Zd Zd Z	dS )
jacobia  
    Jacobi polynomial $P_n^{\left(\alpha, \beta\right)}(x)$.

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

    ``jacobi(n, alpha, beta, x)`` gives the $n$th Jacobi polynomial
    in $x$, $P_n^{\left(\alpha, \beta\right)}(x)$.

    The Jacobi polynomials are orthogonal on $[-1, 1]$ with respect
    to the weight $\left(1-x\right)^\alpha \left(1+x\right)^\beta$.

    Examples
    ========

    >>> from sympy import jacobi, S, conjugate, diff
    >>> from sympy.abc import a, b, n, x

    >>> jacobi(0, a, b, x)
    1
    >>> jacobi(1, a, b, x)
    a/2 - b/2 + x*(a/2 + b/2 + 1)
    >>> jacobi(2, a, b, x)
    a**2/8 - a*b/4 - a/8 + b**2/8 - b/8 + x**2*(a**2/8 + a*b/4 + 7*a/8 + b**2/8 + 7*b/8 + 3/2) + x*(a**2/4 + 3*a/4 - b**2/4 - 3*b/4) - 1/2

    >>> jacobi(n, a, b, x)
    jacobi(n, a, b, x)

    >>> jacobi(n, a, a, x)
    RisingFactorial(a + 1, n)*gegenbauer(n,
        a + 1/2, x)/RisingFactorial(2*a + 1, n)

    >>> jacobi(n, 0, 0, x)
    legendre(n, x)

    >>> jacobi(n, S(1)/2, S(1)/2, x)
    RisingFactorial(3/2, n)*chebyshevu(n, x)/factorial(n + 1)

    >>> jacobi(n, -S(1)/2, -S(1)/2, x)
    RisingFactorial(1/2, n)*chebyshevt(n, x)/factorial(n)

    >>> jacobi(n, a, b, -x)
    (-1)**n*jacobi(n, b, a, x)

    >>> jacobi(n, a, b, 0)
    gamma(a + n + 1)*hyper((-n, -b - n), (a + 1,), -1)/(2**n*factorial(n)*gamma(a + 1))
    >>> jacobi(n, a, b, 1)
    RisingFactorial(a + 1, n)/factorial(n)

    >>> conjugate(jacobi(n, a, b, x))
    jacobi(n, conjugate(a), conjugate(b), conjugate(x))

    >>> diff(jacobi(n,a,b,x), x)
    (a/2 + b/2 + n/2 + 1/2)*jacobi(n - 1, a + 1, b + 1, x)

    See Also
    ========

    gegenbauer,
    chebyshevt_root, chebyshevu, chebyshevu_root,
    legendre, assoc_legendre,
    hermite, hermite_prob,
    laguerre, assoc_laguerre,
    sympy.polys.orthopolys.jacobi_poly,
    sympy.polys.orthopolys.gegenbauer_poly
    sympy.polys.orthopolys.chebyshevt_poly
    sympy.polys.orthopolys.chebyshevu_poly
    sympy.polys.orthopolys.hermite_poly
    sympy.polys.orthopolys.legendre_poly
    sympy.polys.orthopolys.laguerre_poly

    References
    ==========

    .. [1] https://en.wikipedia.org/wiki/Jacobi_polynomials
    .. [2] https://mathworld.wolfram.com/JacobiPolynomial.html
    .. [3] https://functions.wolfram.com/Polynomials/JacobiP/

    c                 N   ||k    r |t          dd          k    r;t          t          j        |          t	          |          z  t          ||          z  S |j        rt          ||          S |t          j        k    rAt          dt          j        z  |          t	          |dz             z  t          ||          z  S t          |dz   |          t          d|z  dz   |          z  t          ||t          j        z   |          z  S || k    rSt          ||z   dz             t          |dz             z  d|z   |dz  z  z  d|z
  |dz  z  z  t          || |          z  S |j        s+|                                r#t          j        |z  t          ||||           z  S |j        r\d| z  t          ||z   dz             z  t          |dz             t	          |          z  z  t!          | |z
  | g|dz   gd          z  S |t          j        k    r#t          |dz   |          t	          |          z  S |t          j        u rL|j        rG||z   d|z  z   j        rt+          d          t          ||z   |z   dz   |          t          j        z  S d S d S t-          ||||          S )N      r+   z,Error. a + b + 2*n should not be an integer.)r   r
   r   Halfr	   
chebyshevtis_zerolegendre
chebyshevu
gegenbauerr   assoc_legendre	is_Numbercould_extract_minus_signNegativeOner8   r   OneInfinityis_positiver   
ValueErrorr   )r%   r&   abr   s        r'   evalzjacobi.eval~   s    66HROO##&qvq11IaLL@:aQRCSCSSS n1~~%af&qx33iA6F6FFTUWXIYIYYY&q1ua00?1Q37A3N3NNQ[\]_`cdci_iklQmQmmm1"WWQ##eAEll2a!eqs^Cq1uPQRSPSnTWefgjkikmnWoWooo{ 	+ ))++ >}a'&Aq1"*=*===y :QB%A	"2"22eAEllYq\\6QRrAvrlQUGR889 :AEzz&q1ua009Q<<??aj= JA!/ Y()WXXX*1q519q=!<<qzII !J J q!Q***r)      c                    ddl m} |dk    rt          | |          |dk    r| j        \  }}}}t	          d          }d||z   |z   |z   dz   z  }||z   d|z  z   dz   t          ||z   dz   ||z
            z  ||z
  t          ||z   |z   dz   ||z
            z  z  }	 ||t          ||||          |	t          ||||          z  z   z  |d|dz
  f          S |dk    r| j        \  }}}}t	          d          }d||z   |z   |z   dz   z  }d||z
  z  ||z   d|z  z   dz   t          ||z   dz   ||z
            z  ||z
  t          ||z   |z   dz   ||z
            z  z  z  }	 ||t          ||||          |	t          ||||          z  z   z  |d|dz
  f          S |dk    r@| j        \  }}}}t          j        ||z   |z   dz   z  t          |dz
  |dz   |dz   |          z  S t          | |          )	Nr   Sumr+   r;   kr<   r:   rN   )	sympy.concrete.summationsrQ   r   r-   r   r
   r8   r   r=   )
r/   argindexrQ   r&   rK   rL   r   rR   f1f2s
             r'   fdiffzjacobi.fdiff   sh   111111q==$T8444]]JAq!Qc

Aa!eai!ma'(Bq51Q3;?oa!eaiQ&G&GGE_QUQY]AEBBBDB3rVAq!Q//"VAq!Q5G5G2GGH1aQRUVQV-XXX]]JAq!Qc

Aa!eai!ma'(BA1q51Q3;?oa!eaiQRUVQV6W6W"WE_QUQY]AEBBB#D EB3rVAq!Q//"VAq!Q5G5G2GGH1aQRUVQV-XXX]]JAq!Q6QUQY]+fQUAE1q5!.L.LLL$T8444r)   c                 p   ddl m} |j        s	|j        du rt	          d          t          d          }t          | |          t          ||z   |z   dz   |          z  t          ||z   dz   ||z
            z  t          |          z  d|z
  dz  |z  z  }dt          |          z   |||d|f          z  S )Nr   rP   F*Error: n should be a non-negative integer.rR   r+   r;   )rS   rQ   is_negativer   rJ   r   r
   r	   )	r/   r&   rK   rL   r   kwargsrQ   rR   kerns	            r'   _eval_rewrite_as_Sumzjacobi._eval_rewrite_as_Sum   s    111111= 	KALE11IJJJ#JJA&&QQ)J)JJ_]^ab]bef]fhilmhmMnMnn!!"Q	A~.9Q<<##dQ1I"6"666r)   c                 $     | j         ||||fi |S Nr]   )r/   r&   rK   rL   r   r[   s         r'   _eval_rewrite_as_polynomialz"jacobi._eval_rewrite_as_polynomial   s%     )t(Aq!>>v>>>r)   c                     | j         \  }}}}|                     ||                                |                                |                                          S r_   r-   r,   r.   )r/   r&   rK   rL   r   s        r'   r0   zjacobi._eval_conjugate   sA    Y
1ayyAKKMM1;;==!++--HHHr)   N)rN   
r1   r2   r3   r4   r5   rM   rW   r]   ra   r0   r6   r)   r'   r8   r8   -   s        N N` #+ #+ [#+J5 5 5 587 7 7? ? ?
I I I I Ir)   r8   c                 >   t          d          ||z   dz   z  t          | |z   dz             t          | |z   dz             z  z  d| z  |z   |z   dz   z  t          |           t          | |z   |z   dz             z  z  }t          | |||          t	          |          z  S )a  
    Jacobi polynomial $P_n^{\left(\alpha, \beta\right)}(x)$.

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

    ``jacobi_normalized(n, alpha, beta, x)`` gives the $n$th
    Jacobi polynomial in $x$, $P_n^{\left(\alpha, \beta\right)}(x)$.

    The Jacobi polynomials are orthogonal on $[-1, 1]$ with respect
    to the weight $\left(1-x\right)^\alpha \left(1+x\right)^\beta$.

    This functions returns the polynomials normilzed:

    .. math::

        \int_{-1}^{1}
          P_m^{\left(\alpha, \beta\right)}(x)
          P_n^{\left(\alpha, \beta\right)}(x)
          (1-x)^{\alpha} (1+x)^{\beta} \mathrm{d}x
        = \delta_{m,n}

    Examples
    ========

    >>> from sympy import jacobi_normalized
    >>> from sympy.abc import n,a,b,x

    >>> jacobi_normalized(n, a, b, x)
    jacobi(n, a, b, x)/sqrt(2**(a + b + 1)*gamma(a + n + 1)*gamma(b + n + 1)/((a + b + 2*n + 1)*factorial(n)*gamma(a + b + n + 1)))

    Parameters
    ==========

    n : integer degree of polynomial

    a : alpha value

    b : beta value

    x : symbol

    See Also
    ========

    gegenbauer,
    chebyshevt_root, chebyshevu, chebyshevu_root,
    legendre, assoc_legendre,
    hermite, hermite_prob,
    laguerre, assoc_laguerre,
    sympy.polys.orthopolys.jacobi_poly,
    sympy.polys.orthopolys.gegenbauer_poly
    sympy.polys.orthopolys.chebyshevt_poly
    sympy.polys.orthopolys.chebyshevu_poly
    sympy.polys.orthopolys.hermite_poly
    sympy.polys.orthopolys.legendre_poly
    sympy.polys.orthopolys.laguerre_poly

    References
    ==========

    .. [1] https://en.wikipedia.org/wiki/Jacobi_polynomials
    .. [2] https://mathworld.wolfram.com/JacobiPolynomial.html
    .. [3] https://functions.wolfram.com/Polynomials/JacobiP/

    r;   r+   )r   r   r	   r8   r   )r&   rK   rL   r   nfactors        r'   jacobi_normalizedrg      s    F tta!eai E!a%!)$4$4uQUQY7G7G$GHA#'A+/#&/llU1q519q=5I5I&IKG !Q1W--r)   c                   B    e Zd ZdZed             Zd	dZd Zd Zd Z	dS )
rB   aN  
    Gegenbauer polynomial $C_n^{\left(\alpha\right)}(x)$.

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

    ``gegenbauer(n, alpha, x)`` gives the $n$th Gegenbauer polynomial
    in $x$, $C_n^{\left(\alpha\right)}(x)$.

    The Gegenbauer polynomials are orthogonal on $[-1, 1]$ with
    respect to the weight $\left(1-x^2\right)^{\alpha-\frac{1}{2}}$.

    Examples
    ========

    >>> from sympy import gegenbauer, conjugate, diff
    >>> from sympy.abc import n,a,x
    >>> gegenbauer(0, a, x)
    1
    >>> gegenbauer(1, a, x)
    2*a*x
    >>> gegenbauer(2, a, x)
    -a + x**2*(2*a**2 + 2*a)
    >>> gegenbauer(3, a, x)
    x**3*(4*a**3/3 + 4*a**2 + 8*a/3) + x*(-2*a**2 - 2*a)

    >>> gegenbauer(n, a, x)
    gegenbauer(n, a, x)
    >>> gegenbauer(n, a, -x)
    (-1)**n*gegenbauer(n, a, x)

    >>> gegenbauer(n, a, 0)
    2**n*sqrt(pi)*gamma(a + n/2)/(gamma(a)*gamma(1/2 - n/2)*gamma(n + 1))
    >>> gegenbauer(n, a, 1)
    gamma(2*a + n)/(gamma(2*a)*gamma(n + 1))

    >>> conjugate(gegenbauer(n, a, x))
    gegenbauer(n, conjugate(a), conjugate(x))

    >>> diff(gegenbauer(n, a, x), x)
    2*a*gegenbauer(n - 1, a + 1, x)

    See Also
    ========

    jacobi,
    chebyshevt_root, chebyshevu, chebyshevu_root,
    legendre, assoc_legendre,
    hermite, hermite_prob,
    laguerre, assoc_laguerre,
    sympy.polys.orthopolys.jacobi_poly
    sympy.polys.orthopolys.gegenbauer_poly
    sympy.polys.orthopolys.chebyshevt_poly
    sympy.polys.orthopolys.chebyshevu_poly
    sympy.polys.orthopolys.hermite_poly
    sympy.polys.orthopolys.hermite_prob_poly
    sympy.polys.orthopolys.legendre_poly
    sympy.polys.orthopolys.laguerre_poly

    References
    ==========

    .. [1] https://en.wikipedia.org/wiki/Gegenbauer_polynomials
    .. [2] https://mathworld.wolfram.com/GegenbauerPolynomial.html
    .. [3] https://functions.wolfram.com/Polynomials/GegenbauerC3/

    c                    |j         rt          j        S |t          j        k    rt	          ||          S |t          j        k    rt          ||          S |t          j        k    rt          j        S |j        s|t          j        k    rt          |          t          j        k    dk    rt          j
        S t          t          j        ||z   z            t          t          j        |z            z  t          d|z  |z             z  t          d|z            t          |dz             z  z  S |                                r"t          j        |z  t!          |||           z  S |j        rxd|z  t%          t          j                  z  t          |t          j        |z  z             z  t          d|z
  dz            t          |dz             z  t          |          z  z  S |t          j        k    r;t          d|z  |z             t          d|z            t          |dz             z  z  S |t          j        u r$|j        rt+          ||          t          j        z  S d S d S t-          |||          S )NTr;   r+   )rZ   r   Zeror=   r@   rG   rA   rF   rD   r   ComplexInfinityr   Pir   r   rE   rB   r?   r   rH   rI   r
   r   )r%   r&   rK   r   s       r'   rM   zgegenbauer.evalg  s&    = 	6M ;;Aq>>!!%ZZa###!-6M{ 	,AM!!qEEAFNt++,,ac
OOc!$q&kk9E!A#a%LLH!&qseAaCjj!8: ;
 ))++ ?}a'*QA2*>*>>>y G1tADzz)E!afQh,,?,??Aqy))E!a%LL8588CE GAEzzQqS1W~~qseAEll)BCCaj= >*1a001:== !> > #1a+++r)   r<   c                    ddl m} |dk    rt          | |          |dk    r| j        \  }}}t	          d          }ddd||z
  z  z   z  ||z   z  ||z   d|z  z   ||z
  z  z  }d|dz   z  |d|z  z   d|z  d|z  z   dz   z  z  d||z   d|z  z   z  z   }|t          |||          z  |t          |||          z  z   }	 ||	|d|dz
  f          S |dk    r(| j        \  }}}d|z  t          |dz
  |dz   |          z  S t          | |          )Nr   rP   r+   r;   rR   r:   r<   )rS   rQ   r   r-   r   rB   )
r/   rT   rQ   r&   rK   r   rR   factor1factor2r\   s
             r'   rW   zgegenbauer.fdiff  sn   111111q==$T8444]]iGAq!c

A1a!e},-Q7A= s=#'(1u<. /GQiA!G!ac	A#>?QUQqS[!"G:aA...Aq!9L9L1LLD3taAE]+++]]iGAq!Q3z!a%Q2222$T8444r)   c           	         ddl m} t          d          }d|z  t          |||z
            z  d|z  |d|z  z
  z  z  t	          |          t	          |d|z  z
            z  z  } |||dt          |dz            f          S )Nr   rP   rR   r:   r;   )rS   rQ   r   r
   r	   r   )r/   r&   rK   r   r[   rQ   rR   r\   s           r'   r]   zgegenbauer._eval_rewrite_as_Sum  s    111111#JJa/!QU333qsa!A#g6FF1	!ac' 2 224s4!Qac

+,,,r)   c                 "     | j         |||fi |S r_   r`   )r/   r&   rK   r   r[   s        r'   ra   z&gegenbauer._eval_rewrite_as_polynomial  #     )t(Aq;;F;;;r)   c                     | j         \  }}}|                     ||                                |                                          S r_   rc   )r/   r&   rK   r   s       r'   r0   zgegenbauer._eval_conjugate  5    )1ayyAKKMM1;;==999r)   Nr<   rd   r6   r)   r'   rB   rB   "  s~        B BH &, &, [&,P5 5 5 5,- - -< < <
: : : : :r)   rB   c                   R    e Zd ZdZ ee          Zed             ZddZ	d Z
d ZdS )	r>   a  
    Chebyshev polynomial of the first kind, $T_n(x)$.

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

    ``chebyshevt(n, x)`` gives the $n$th Chebyshev polynomial (of the first
    kind) in $x$, $T_n(x)$.

    The Chebyshev polynomials of the first kind are orthogonal on
    $[-1, 1]$ with respect to the weight $\frac{1}{\sqrt{1-x^2}}$.

    Examples
    ========

    >>> from sympy import chebyshevt, diff
    >>> from sympy.abc import n,x
    >>> chebyshevt(0, x)
    1
    >>> chebyshevt(1, x)
    x
    >>> chebyshevt(2, x)
    2*x**2 - 1

    >>> chebyshevt(n, x)
    chebyshevt(n, x)
    >>> chebyshevt(n, -x)
    (-1)**n*chebyshevt(n, x)
    >>> chebyshevt(-n, x)
    chebyshevt(n, x)

    >>> chebyshevt(n, 0)
    cos(pi*n/2)
    >>> chebyshevt(n, -1)
    (-1)**n

    >>> diff(chebyshevt(n, x), x)
    n*chebyshevu(n - 1, x)

    See Also
    ========

    jacobi, gegenbauer,
    chebyshevt_root, chebyshevu, chebyshevu_root,
    legendre, assoc_legendre,
    hermite, hermite_prob,
    laguerre, assoc_laguerre,
    sympy.polys.orthopolys.jacobi_poly
    sympy.polys.orthopolys.gegenbauer_poly
    sympy.polys.orthopolys.chebyshevt_poly
    sympy.polys.orthopolys.chebyshevu_poly
    sympy.polys.orthopolys.hermite_poly
    sympy.polys.orthopolys.hermite_prob_poly
    sympy.polys.orthopolys.legendre_poly
    sympy.polys.orthopolys.laguerre_poly

    References
    ==========

    .. [1] https://en.wikipedia.org/wiki/Chebyshev_polynomial
    .. [2] https://mathworld.wolfram.com/ChebyshevPolynomialoftheFirstKind.html
    .. [3] https://mathworld.wolfram.com/ChebyshevPolynomialoftheSecondKind.html
    .. [4] https://functions.wolfram.com/Polynomials/ChebyshevT/
    .. [5] https://functions.wolfram.com/Polynomials/ChebyshevU/

    c                    |j         s|                                r!t          j        |z  t	          ||           z  S |                                rt	          | |          S |j        r)t          t          j        t          j        z  |z            S |t          j	        k    rt          j	        S |t          j
        u rt          j
        S d S |j        r|                     | |          S |                     ||          S r_   )rD   rE   r   rF   r>   r?   r   r=   rl   rG   rH   rZ   r(   r$   s      r'   rM   zchebyshevt.eval  s    { 	0 ))++ <}a'*Q*;*;;;))++ )!1"a(((y .16AD=1,---AEzzuajz! ! } 0))1"a000))!Q///r)   r;   c                     |dk    rt          | |          |dk    r | j        \  }}|t          |dz
  |          z  S t          | |          Nr+   r;   )r   r-   rA   r/   rT   r&   r   s       r'   rW   zchebyshevt.fdiff  sX    q==$T8444]]9DAqz!a%++++$T8444r)   c           	          ddl m} t          d          }t          |d|z            |dz  dz
  |z  z  ||d|z  z
  z  z  } |||dt	          |dz            f          S Nr   rP   rR   r;   r+   )rS   rQ   r   r   r   r/   r&   r   r[   rQ   rR   r\   s          r'   r]   zchebyshevt._eval_rewrite_as_Sum%  sw    111111#JJ1Q31a4!8a-/!a!A#g,>s4!Qac

+,,,r)   c                       | j         ||fi |S r_   r`   r/   r&   r   r[   s       r'   ra   z&chebyshevt._eval_rewrite_as_polynomial+  !     )t(A88888r)   Nr;   )r1   r2   r3   r4   staticmethodr   r    r5   rM   rW   r]   ra   r6   r)   r'   r>   r>     s}        A AF ,//K0 0 [00	5 	5 	5 	5- - -9 9 9 9 9r)   r>   c                   R    e Zd ZdZ ee          Zed             ZddZ	d Z
d ZdS )	rA   a  
    Chebyshev polynomial of the second kind, $U_n(x)$.

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

    ``chebyshevu(n, x)`` gives the $n$th Chebyshev polynomial of the second
    kind in x, $U_n(x)$.

    The Chebyshev polynomials of the second kind are orthogonal on
    $[-1, 1]$ with respect to the weight $\sqrt{1-x^2}$.

    Examples
    ========

    >>> from sympy import chebyshevu, diff
    >>> from sympy.abc import n,x
    >>> chebyshevu(0, x)
    1
    >>> chebyshevu(1, x)
    2*x
    >>> chebyshevu(2, x)
    4*x**2 - 1

    >>> chebyshevu(n, x)
    chebyshevu(n, x)
    >>> chebyshevu(n, -x)
    (-1)**n*chebyshevu(n, x)
    >>> chebyshevu(-n, x)
    -chebyshevu(n - 2, x)

    >>> chebyshevu(n, 0)
    cos(pi*n/2)
    >>> chebyshevu(n, 1)
    n + 1

    >>> diff(chebyshevu(n, x), x)
    (-x*chebyshevu(n, x) + (n + 1)*chebyshevt(n + 1, x))/(x**2 - 1)

    See Also
    ========

    jacobi, gegenbauer,
    chebyshevt, chebyshevt_root, chebyshevu_root,
    legendre, assoc_legendre,
    hermite, hermite_prob,
    laguerre, assoc_laguerre,
    sympy.polys.orthopolys.jacobi_poly
    sympy.polys.orthopolys.gegenbauer_poly
    sympy.polys.orthopolys.chebyshevt_poly
    sympy.polys.orthopolys.chebyshevu_poly
    sympy.polys.orthopolys.hermite_poly
    sympy.polys.orthopolys.hermite_prob_poly
    sympy.polys.orthopolys.legendre_poly
    sympy.polys.orthopolys.laguerre_poly

    References
    ==========

    .. [1] https://en.wikipedia.org/wiki/Chebyshev_polynomial
    .. [2] https://mathworld.wolfram.com/ChebyshevPolynomialoftheFirstKind.html
    .. [3] https://mathworld.wolfram.com/ChebyshevPolynomialoftheSecondKind.html
    .. [4] https://functions.wolfram.com/Polynomials/ChebyshevT/
    .. [5] https://functions.wolfram.com/Polynomials/ChebyshevU/

    c                    |j         s|                                r!t          j        |z  t	          ||           z  S |                                rI|t          j        k    rt          j        S | dz
                                  st	          | dz
  |           S |j        r)t          t          j        t          j	        z  |z            S |t          j
        k    rt          j
        |z   S |t          j        u rt          j        S d S |j        r7|t          j        k    rt          j        S |                     | dz
  |           S |                     ||          S Nr;   )rD   rE   r   rF   rA   rj   r?   r   r=   rl   rG   rH   rZ   r(   r$   s      r'   rM   zchebyshevu.evalw  sF   { 	0 ))++ <}a'*Q*;*;;;))++ 2%%6M"q&::<< 2&rAvq1111y .16AD=1,---AEzzuqy ajz! ! } 0%%6M..rAvq9999))!Q///r)   r;   c                     |dk    rt          | |          |dk    r@| j        \  }}|dz   t          |dz   |          z  |t          ||          z  z
  |dz  dz
  z  S t          | |          ry   )r   r-   r>   rA   rz   s       r'   rW   zchebyshevu.fdiff  s    q==$T8444]]9DAqUjQ222QAq9I9I5IIaQRdUVhWW$T8444r)   c           	         ddl m} t          d          }t          j        |z  t          ||z
            z  d|z  |d|z  z
  z  z  t          |          t          |d|z  z
            z  z  } |||dt          |dz            f          S Nr   rP   rR   r;   rS   rQ   r   r   rF   r	   r   r}   s          r'   r]   zchebyshevu._eval_rewrite_as_Sum  s    111111#JJ}a)E# # cQ1W%&)21	!ac'8J8J)JLs4!Qac

+,,,r)   c                       | j         ||fi |S r_   r`   r   s       r'   ra   z&chebyshevu._eval_rewrite_as_polynomial  r   r)   Nr   )r1   r2   r3   r4   r   r   r    r5   rM   rW   r]   ra   r6   r)   r'   rA   rA   1  s}        A AF ,//K0 0 [0>	5 	5 	5 	5- - -9 9 9 9 9r)   rA   c                   (    e Zd ZdZed             ZdS )chebyshevt_roota  
    ``chebyshev_root(n, k)`` returns the $k$th root (indexed from zero) of
    the $n$th Chebyshev polynomial of the first kind; that is, if
    $0 \le k < n$, ``chebyshevt(n, chebyshevt_root(n, k)) == 0``.

    Examples
    ========

    >>> from sympy import chebyshevt, chebyshevt_root
    >>> chebyshevt_root(3, 2)
    -sqrt(3)/2
    >>> chebyshevt(3, chebyshevt_root(3, 2))
    0

    See Also
    ========

    jacobi, gegenbauer,
    chebyshevt, chebyshevu, chebyshevu_root,
    legendre, assoc_legendre,
    hermite, hermite_prob,
    laguerre, assoc_laguerre,
    sympy.polys.orthopolys.jacobi_poly
    sympy.polys.orthopolys.gegenbauer_poly
    sympy.polys.orthopolys.chebyshevt_poly
    sympy.polys.orthopolys.chebyshevu_poly
    sympy.polys.orthopolys.hermite_poly
    sympy.polys.orthopolys.hermite_prob_poly
    sympy.polys.orthopolys.legendre_poly
    sympy.polys.orthopolys.laguerre_poly
    c                     d|k    r||k     st          d|d|          t          t          j        d|z  dz   z  d|z  z            S )Nr   must have 0 <= k < n, got k = 	 and n = r;   r+   rJ   r   r   rl   r%   r&   rR   s      r'   rM   zchebyshevt_root.eval  s\    aa!ee*+,11aa1 2 2 2141q>1Q3'(((r)   Nr1   r2   r3   r4   r5   rM   r6   r)   r'   r   r     s:         @ ) ) [) ) )r)   r   c                   (    e Zd ZdZed             ZdS )chebyshevu_rootaw  
    ``chebyshevu_root(n, k)`` returns the $k$th root (indexed from zero) of the
    $n$th Chebyshev polynomial of the second kind; that is, if $0 \le k < n$,
    ``chebyshevu(n, chebyshevu_root(n, k)) == 0``.

    Examples
    ========

    >>> from sympy import chebyshevu, chebyshevu_root
    >>> chebyshevu_root(3, 2)
    -sqrt(2)/2
    >>> chebyshevu(3, chebyshevu_root(3, 2))
    0

    See Also
    ========

    chebyshevt, chebyshevt_root, chebyshevu,
    legendre, assoc_legendre,
    hermite, hermite_prob,
    laguerre, assoc_laguerre,
    sympy.polys.orthopolys.jacobi_poly
    sympy.polys.orthopolys.gegenbauer_poly
    sympy.polys.orthopolys.chebyshevt_poly
    sympy.polys.orthopolys.chebyshevu_poly
    sympy.polys.orthopolys.hermite_poly
    sympy.polys.orthopolys.hermite_prob_poly
    sympy.polys.orthopolys.legendre_poly
    sympy.polys.orthopolys.laguerre_poly
    c                     d|k    r||k     st          d|d|          t          t          j        |dz   z  |dz   z            S )Nr   r   r   r+   r   r   s      r'   rM   zchebyshevu_root.eval  sX    aa!ee*+,11aa1 2 2 214Q<Q'(((r)   Nr   r6   r)   r'   r   r     s:         @ ) ) [) ) )r)   r   c                   R    e Zd ZdZ ee          Zed             ZddZ	d Z
d ZdS )	r@   a  
    ``legendre(n, x)`` gives the $n$th Legendre polynomial of $x$, $P_n(x)$

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

    The Legendre polynomials are orthogonal on $[-1, 1]$ with respect to
    the constant weight 1. They satisfy $P_n(1) = 1$ for all $n$; further,
    $P_n$ is odd for odd $n$ and even for even $n$.

    Examples
    ========

    >>> from sympy import legendre, diff
    >>> from sympy.abc import x, n
    >>> legendre(0, x)
    1
    >>> legendre(1, x)
    x
    >>> legendre(2, x)
    3*x**2/2 - 1/2
    >>> legendre(n, x)
    legendre(n, x)
    >>> diff(legendre(n,x), x)
    n*(x*legendre(n, x) - legendre(n - 1, x))/(x**2 - 1)

    See Also
    ========

    jacobi, gegenbauer,
    chebyshevt, chebyshevt_root, chebyshevu, chebyshevu_root,
    assoc_legendre,
    hermite, hermite_prob,
    laguerre, assoc_laguerre,
    sympy.polys.orthopolys.jacobi_poly
    sympy.polys.orthopolys.gegenbauer_poly
    sympy.polys.orthopolys.chebyshevt_poly
    sympy.polys.orthopolys.chebyshevu_poly
    sympy.polys.orthopolys.hermite_poly
    sympy.polys.orthopolys.hermite_prob_poly
    sympy.polys.orthopolys.legendre_poly
    sympy.polys.orthopolys.laguerre_poly

    References
    ==========

    .. [1] https://en.wikipedia.org/wiki/Legendre_polynomial
    .. [2] https://mathworld.wolfram.com/LegendrePolynomial.html
    .. [3] https://functions.wolfram.com/Polynomials/LegendreP/
    .. [4] https://functions.wolfram.com/Polynomials/LegendreP2/

    c                    |j         s|                                r!t          j        |z  t	          ||           z  S |                                r6| dz
                                  st	          | t          j        z
  |          S |j        rYt          t          j                  t          t          j
        |dz  z
            t          t          j        |dz  z             z  z  S |t          j        k    rt          j        S |t          j        u rt          j        S d S |j        r| t          j        z
  }|                     ||          S ry   )rD   rE   r   rF   r@   rG   r?   r   rl   r   r=   rH   rZ   r(   r$   s      r'   rM   zlegendre.eval=  s$   { 	, ))++ :}a'(1qb//99))++ /QBF3T3T3V3V /QU
A...y "ADzz5!A##6#6uQUQqS[7I7I#IJJaeuajz! !
 } BJ%%a+++r)   r;   c                     |dk    rt          | |          |dk    r=| j        \  }}||dz  dz
  z  |t          ||          z  t          |dz
  |          z
  z  S t          | |          ry   )r   r-   r@   rz   s       r'   rW   zlegendre.fdiffU  sx    q==$T8444]] 9DAqadQh<8Aq>>!1HQUA4F4F!FGG$T8444r)   c                     ddl m} t          d          }t          j        |z  t          ||          dz  z  d|z   dz  ||z
  z  z  d|z
  dz  |z  z  } |||d|f          S r|   )rS   rQ   r   r   rF   r   r}   s          r'   r]   zlegendre._eval_rewrite_as_Summ  s~    111111#JJ}aA 11AE19A2FFQPQ	TU~Us4!Q###r)   c                       | j         ||fi |S r_   r`   r   s       r'   ra   z$legendre._eval_rewrite_as_polynomials  r   r)   Nr   )r1   r2   r3   r4   r   r   r    r5   rM   rW   r]   ra   r6   r)   r'   r@   r@     s{        3 3j ,}--K, , [,.5 5 5 50$ $ $9 9 9 9 9r)   r@   c                   X    e Zd ZdZed             Zed             Zd
dZd Zd Z	d Z
d	S )rC   a  
    ``assoc_legendre(n, m, x)`` gives $P_n^m(x)$, where $n$ and $m$ are
    the degree and order or an expression which is related to the nth
    order Legendre polynomial, $P_n(x)$ in the following manner:

    .. math::
        P_n^m(x) = (-1)^m (1 - x^2)^{\frac{m}{2}}
                   \frac{\mathrm{d}^m P_n(x)}{\mathrm{d} x^m}

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

    Associated Legendre polynomials are orthogonal on $[-1, 1]$ with:

    - weight $= 1$            for the same $m$ and different $n$.
    - weight $= \frac{1}{1-x^2}$   for the same $n$ and different $m$.

    Examples
    ========

    >>> from sympy import assoc_legendre
    >>> from sympy.abc import x, m, n
    >>> assoc_legendre(0,0, x)
    1
    >>> assoc_legendre(1,0, x)
    x
    >>> assoc_legendre(1,1, x)
    -sqrt(1 - x**2)
    >>> assoc_legendre(n,m,x)
    assoc_legendre(n, m, x)

    See Also
    ========

    jacobi, gegenbauer,
    chebyshevt, chebyshevt_root, chebyshevu, chebyshevu_root,
    legendre,
    hermite, hermite_prob,
    laguerre, assoc_laguerre,
    sympy.polys.orthopolys.jacobi_poly
    sympy.polys.orthopolys.gegenbauer_poly
    sympy.polys.orthopolys.chebyshevt_poly
    sympy.polys.orthopolys.chebyshevu_poly
    sympy.polys.orthopolys.hermite_poly
    sympy.polys.orthopolys.hermite_prob_poly
    sympy.polys.orthopolys.legendre_poly
    sympy.polys.orthopolys.laguerre_poly

    References
    ==========

    .. [1] https://en.wikipedia.org/wiki/Associated_Legendre_polynomials
    .. [2] https://mathworld.wolfram.com/LegendrePolynomial.html
    .. [3] https://functions.wolfram.com/Polynomials/LegendreP/
    .. [4] https://functions.wolfram.com/Polynomials/LegendreP2/

    c                     t          |t          d                              t          |f          }t          j        |z  dt          dz  z
  t          |d          z  z  |                                z  S )NT)polysr+   r;   )r   r"   diffr   rF   r   as_expr)r%   r&   mPs       r'   r(   zassoc_legendre._eval_at_order  s\    !Rt,,,112q'::}a1r1u9x1~~"==		KKr)   c                    |                                 rIt          j        | z  t          ||z             t          ||z
            z  z  t	          || |          z  S |dk    rt          ||          S |dk    rQd|z  t          t          j                  z  t          d|z
  |z
  dz            t          d||z
  dz  z
            z  z  S |j	        r|j	        r|j
        r|j
        r|j        rt          | d|d          t          |          |k    rt          | d|d|d          |                     t          |          t          t          |                                                  t"          |          S d S d S d S d S )Nr   r;   r+   z. : 1st index must be nonnegative integer (got )z0 : abs('2nd index') must be <= '1st index' (got z, )rE   r   rF   r	   rC   r@   r   rl   r   rD   r   rZ   rJ   absr(   r!   r#   r"   )r%   r&   r   r   s       r'   rM   zassoc_legendre.eval  s   %%'' 	h=A2&)AE*:*:9QU;K;K*KL~^_bcacefOgOggg66Aq>>!66a4QT

?eQUQYM&:&:5a!eQY;O;O&OPP; 	G1; 	G1< 	GAL 	G} c Z]Z]Z]_`_`_`!abbb1vvzz `c`c`cefefefhihihi!jkkk%%c!ffc#a&&kk::??AFFF	G 	G 	G 	G 	G 	G 	G 	Gr)   r<   c                    |dk    rt          | |          |dk    rt          | |          |dk    rI| j        \  }}}d|dz  dz
  z  ||z  t          |||          z  ||z   t          |dz
  ||          z  z
  z  S t          | |          )Nr+   r;   r<   )r   r-   rC   )r/   rT   r&   r   r   s        r'   rW   zassoc_legendre.fdiff  s    q==$T8444]]$T8444]] iGAq!adQh<1^Aq!%<%<!<A~VWZ[V[]^`aGbGb?b!bcc$T8444r)   c           
         ddl m} t          d          }t          d|z  d|z  z
            d|z  t          ||z
            z  t          |          z  t          |d|z  z
  |z
            z  z  t          j        |z  z  |||z
  d|z  z
  z  z  }d|dz  z
  |dz  z   |||dt          ||z
  t          j        z            f          z  S r|   )rS   rQ   r   r	   r   rF   r   r=   )r/   r&   r   r   r[   rQ   rR   r\   s           r'   r]   z#assoc_legendre._eval_rewrite_as_Sum  s    111111#JJ1qs##QT)AE*:*:%:9< < &QqS1%%&& ''(}a'7889AEAaCK8HIAqDAaC 33taE1q5!&.4I4I-J#K#KKKr)   c                 "     | j         |||fi |S r_   r`   )r/   r&   r   r   r[   s        r'   ra   z*assoc_legendre._eval_rewrite_as_polynomial  rr   r)   c                     | j         \  }}}|                     ||                                |                                          S r_   rc   )r/   r&   r   r   s       r'   r0   zassoc_legendre._eval_conjugate  rt   r)   Nru   )r1   r2   r3   r4   r5   r(   rM   rW   r]   ra   r0   r6   r)   r'   rC   rC   y  s        8 8t L L [L G G [G 5 5 5 5L L L< < <
: : : : :r)   rC   c                   X    e Zd ZdZ ee          Zed             Zd	dZ	d Z
d Zd ZdS )
hermitea.  
    ``hermite(n, x)`` gives the $n$th Hermite polynomial in $x$, $H_n(x)$.

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

    The Hermite polynomials are orthogonal on $(-\infty, \infty)$
    with respect to the weight $\exp\left(-x^2\right)$.

    Examples
    ========

    >>> from sympy import hermite, diff
    >>> from sympy.abc import x, n
    >>> hermite(0, x)
    1
    >>> hermite(1, x)
    2*x
    >>> hermite(2, x)
    4*x**2 - 2
    >>> hermite(n, x)
    hermite(n, x)
    >>> diff(hermite(n,x), x)
    2*n*hermite(n - 1, x)
    >>> hermite(n, -x)
    (-1)**n*hermite(n, x)

    See Also
    ========

    jacobi, gegenbauer,
    chebyshevt, chebyshevt_root, chebyshevu, chebyshevu_root,
    legendre, assoc_legendre,
    hermite_prob,
    laguerre, assoc_laguerre,
    sympy.polys.orthopolys.jacobi_poly
    sympy.polys.orthopolys.gegenbauer_poly
    sympy.polys.orthopolys.chebyshevt_poly
    sympy.polys.orthopolys.chebyshevu_poly
    sympy.polys.orthopolys.hermite_poly
    sympy.polys.orthopolys.hermite_prob_poly
    sympy.polys.orthopolys.legendre_poly
    sympy.polys.orthopolys.laguerre_poly

    References
    ==========

    .. [1] https://en.wikipedia.org/wiki/Hermite_polynomial
    .. [2] https://mathworld.wolfram.com/HermitePolynomial.html
    .. [3] https://functions.wolfram.com/Polynomials/HermiteH/

    c                    |j         s|                                r!t          j        |z  t	          ||           z  S |j        r?d|z  t          t          j                  z  t          t          j	        |z
  dz            z  S |t          j
        u rt          j
        S d S |j        rt          d|z            |                     ||          S )Nr;   0The index n must be nonnegative integer (got %r))rD   rE   r   rF   r   r?   r   rl   r   rG   rH   rZ   rJ   r(   r$   s      r'   rM   zhermite.eval&  s    { 	0 ))++ 9}a''!aR..88y "!td14jj(5!%!)Q+?+???ajz! ! } 0 FJL L L ))!Q///r)   r;   c                     |dk    rt          | |          |dk    r#| j        \  }}d|z  t          |dz
  |          z  S t          | |          ry   )r   r-   r   rz   s       r'   rW   zhermite.fdiff:  s\    q==$T8444]]9DAqQ3wq1ua(((($T8444r)   c           
         ddl m} t          d          }t          j        |z  t          |          t          |d|z  z
            z  z  d|z  |d|z  z
  z  z  }t          |           |||dt          |dz            f          z  S r   r   r}   s          r'   r]   zhermite._eval_rewrite_as_SumE  s    111111#JJ}a9Q<<	!ac'0B0B#BCqsaRSTURUgFVV||CCq!U1Q3ZZ&89999r)   c                       | j         ||fi |S r_   r`   r   s       r'   ra   z#hermite._eval_rewrite_as_polynomialK  r   r)   c                 h    t          d          |z  t          ||t          d          z            z  S r   )r   hermite_probr   s       r'   _eval_rewrite_as_hermite_probz%hermite._eval_rewrite_as_hermite_probP  s+    AwwzLAd1ggI6666r)   Nr   )r1   r2   r3   r4   r   r   r    r5   rM   rW   r]   ra   r   r6   r)   r'   r   r     s        3 3j ,|,,K0 0 [0&	5 	5 	5 	5: : :9 9 9
7 7 7 7 7r)   r   c                   X    e Zd ZdZ ee          Zed             Zd	dZ	d Z
d Zd ZdS )
r   a  
    ``hermite_prob(n, x)`` gives the $n$th probabilist's Hermite polynomial
    in $x$, $He_n(x)$.

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

    The probabilist's Hermite polynomials are orthogonal on $(-\infty, \infty)$
    with respect to the weight $\exp\left(-\frac{x^2}{2}\right)$. They are monic
    polynomials, related to the plain Hermite polynomials (:py:class:`~.hermite`) by

    .. math :: He_n(x) = 2^{-n/2} H_n(x/\sqrt{2})

    Examples
    ========

    >>> from sympy import hermite_prob, diff, I
    >>> from sympy.abc import x, n
    >>> hermite_prob(1, x)
    x
    >>> hermite_prob(5, x)
    x**5 - 10*x**3 + 15*x
    >>> diff(hermite_prob(n,x), x)
    n*hermite_prob(n - 1, x)
    >>> hermite_prob(n, -x)
    (-1)**n*hermite_prob(n, x)

    The sum of absolute values of coefficients of $He_n(x)$ is the number of
    matchings in the complete graph $K_n$ or telephone number, A000085 in the OEIS:

    >>> [hermite_prob(n,I) / I**n for n in range(11)]
    [1, 1, 2, 4, 10, 26, 76, 232, 764, 2620, 9496]

    See Also
    ========

    jacobi, gegenbauer,
    chebyshevt, chebyshevt_root, chebyshevu, chebyshevu_root,
    legendre, assoc_legendre,
    hermite,
    laguerre, assoc_laguerre,
    sympy.polys.orthopolys.jacobi_poly
    sympy.polys.orthopolys.gegenbauer_poly
    sympy.polys.orthopolys.chebyshevt_poly
    sympy.polys.orthopolys.chebyshevu_poly
    sympy.polys.orthopolys.hermite_poly
    sympy.polys.orthopolys.hermite_prob_poly
    sympy.polys.orthopolys.legendre_poly
    sympy.polys.orthopolys.laguerre_poly

    References
    ==========

    .. [1] https://en.wikipedia.org/wiki/Hermite_polynomial
    .. [2] https://mathworld.wolfram.com/HermitePolynomial.html
    c                    |j         s|                                r!t          j        |z  t	          ||           z  S |j        r9t          t          j                  t          t          j	        |z
  dz            z  S |t          j
        u rt          j
        S d S |j        rt          d|z             d S |                     ||          S )Nr;   z'n must be a nonnegative integer, not %r)rD   rE   r   rF   r   r?   r   rl   r   rG   rH   rZ   rJ   r(   r$   s      r'   rM   zhermite_prob.eval  s    { 	0))++ >}a',q1"*=*===y "ADzzE157a-$8$888ajz! ! } 0DqHIIIII))!Q///r)   r;   c                 n    |dk    r | j         \  }}|t          |dz
  |          z  S t          | |          )Nr;   r+   )r-   r   r   rz   s       r'   rW   zhermite_prob.fdiff  s?    q==9DAq\!A#q))))$T8444r)   c           
         ddl m} t          d          }t          j         |z  ||d|z  z
  z  z  t          |          t          |d|z  z
            z  z  }t          |           |||dt          |dz            f          z  S r   )rS   rQ   r   r   r=   r	   r   r}   s          r'   r]   z!hermite_prob._eval_rewrite_as_Sum  s    111111#JJ!|a!AaC%j(IaLL9QqsU;K;K,KL||CCq!U1Q3ZZ&89999r)   c                       | j         ||fi |S r_   r`   r   s       r'   ra   z(hermite_prob._eval_rewrite_as_polynomial  r   r)   c                 j    t          d          | z  t          ||t          d          z            z  S r   )r   r   r   s       r'   _eval_rewrite_as_hermitez%hermite_prob._eval_rewrite_as_hermite  s-    Aww!}wq!DGG)4444r)   Nr   )r1   r2   r3   r4   r   r   r    r5   rM   rW   r]   ra   r   r6   r)   r'   r   r   T  s        7 7r ,011K0 0 [05 5 5 5: : :9 9 9
5 5 5 5 5r)   r   c                   R    e Zd ZdZ ee          Zed             ZddZ	d Z
d ZdS )	laguerreaL  
    Returns the $n$th Laguerre polynomial in $x$, $L_n(x)$.

    Examples
    ========

    >>> from sympy import laguerre, diff
    >>> from sympy.abc import x, n
    >>> laguerre(0, x)
    1
    >>> laguerre(1, x)
    1 - x
    >>> laguerre(2, x)
    x**2/2 - 2*x + 1
    >>> laguerre(3, x)
    -x**3/6 + 3*x**2/2 - 3*x + 1

    >>> laguerre(n, x)
    laguerre(n, x)

    >>> diff(laguerre(n, x), x)
    -assoc_laguerre(n - 1, 1, x)

    Parameters
    ==========

    n : int
        Degree of Laguerre polynomial. Must be `n \ge 0`.

    See Also
    ========

    jacobi, gegenbauer,
    chebyshevt, chebyshevt_root, chebyshevu, chebyshevu_root,
    legendre, assoc_legendre,
    hermite, hermite_prob,
    assoc_laguerre,
    sympy.polys.orthopolys.jacobi_poly
    sympy.polys.orthopolys.gegenbauer_poly
    sympy.polys.orthopolys.chebyshevt_poly
    sympy.polys.orthopolys.chebyshevu_poly
    sympy.polys.orthopolys.hermite_poly
    sympy.polys.orthopolys.hermite_prob_poly
    sympy.polys.orthopolys.legendre_poly
    sympy.polys.orthopolys.laguerre_poly

    References
    ==========

    .. [1] https://en.wikipedia.org/wiki/Laguerre_polynomial
    .. [2] https://mathworld.wolfram.com/LaguerrePolynomial.html
    .. [3] https://functions.wolfram.com/Polynomials/LaguerreL/
    .. [4] https://functions.wolfram.com/Polynomials/LaguerreL3/

    c                    |j         du rt          d          |j        s|                                r=| dz
                                  s%t	          |          t          | dz
  |           z  S |j        rt          j        S |t          j	        u rt          j
        S |t          j
        u rt          j        |z  t          j
        z  S d S |j        r%t	          |          t          | dz
  |           z  S |                     ||          S )NFError: n should be an integer.r+   )r   rJ   rD   rE   r   r   r?   r   rG   NegativeInfinityrH   rF   rZ   r(   r$   s      r'   rM   zlaguerre.eval  s   <5  =>>>{ 	0 ))++ 3QBF3T3T3V3V 31vvhrAvr2222y 5ua(((z!aj}a'!*44 ! } 01vvhrAvr2222))!Q///r)   r;   c                     |dk    rt          | |          |dk    r| j        \  }}t          |dz
  d|           S t          | |          ry   )r   r-   assoc_laguerrerz   s       r'   rW   zlaguerre.fdiff  sX    q==$T8444]]9DAq"1q5!Q////$T8444r)   c                 $   ddl m} |j        r$t          |           | j        | dz
  | fi |z  S |j        du rt          d          t          d          }t          | |          t          |          dz  z  ||z  z  } |||d|f          S )Nr   rP   r+   Fr   rR   r;   )
rS   rQ   rZ   r   r]   r   rJ   r   r
   r	   r}   s          r'   r]   zlaguerre._eval_rewrite_as_Sum  s    111111= 	Lq665D5qb1fqbKKFKKKK<5  =>>>#JJr1%%	!a7!Q$>s4!Q###r)   c                       | j         ||fi |S r_   r`   r   s       r'   ra   z$laguerre._eval_rewrite_as_polynomial"  r   r)   Nr   )r1   r2   r3   r4   r   r   r    r5   rM   rW   r]   ra   r6   r)   r'   r   r     s{        6 6p ,}--K0 0 [0,	5 	5 	5 	5	$ 	$ 	$9 9 9 9 9r)   r   c                   B    e Zd ZdZed             Zd	dZd Zd Zd Z	dS )
r   aj  
    Returns the $n$th generalized Laguerre polynomial in $x$, $L_n(x)$.

    Examples
    ========

    >>> from sympy import assoc_laguerre, diff
    >>> from sympy.abc import x, n, a
    >>> assoc_laguerre(0, a, x)
    1
    >>> assoc_laguerre(1, a, x)
    a - x + 1
    >>> assoc_laguerre(2, a, x)
    a**2/2 + 3*a/2 + x**2/2 + x*(-a - 2) + 1
    >>> assoc_laguerre(3, a, x)
    a**3/6 + a**2 + 11*a/6 - x**3/6 + x**2*(a/2 + 3/2) +
        x*(-a**2/2 - 5*a/2 - 3) + 1

    >>> assoc_laguerre(n, a, 0)
    binomial(a + n, a)

    >>> assoc_laguerre(n, a, x)
    assoc_laguerre(n, a, x)

    >>> assoc_laguerre(n, 0, x)
    laguerre(n, x)

    >>> diff(assoc_laguerre(n, a, x), x)
    -assoc_laguerre(n - 1, a + 1, x)

    >>> diff(assoc_laguerre(n, a, x), a)
    Sum(assoc_laguerre(_k, a, x)/(-a + n), (_k, 0, n - 1))

    Parameters
    ==========

    n : int
        Degree of Laguerre polynomial. Must be `n \ge 0`.

    alpha : Expr
        Arbitrary expression. For ``alpha=0`` regular Laguerre
        polynomials will be generated.

    See Also
    ========

    jacobi, gegenbauer,
    chebyshevt, chebyshevt_root, chebyshevu, chebyshevu_root,
    legendre, assoc_legendre,
    hermite, hermite_prob,
    laguerre,
    sympy.polys.orthopolys.jacobi_poly
    sympy.polys.orthopolys.gegenbauer_poly
    sympy.polys.orthopolys.chebyshevt_poly
    sympy.polys.orthopolys.chebyshevu_poly
    sympy.polys.orthopolys.hermite_poly
    sympy.polys.orthopolys.hermite_prob_poly
    sympy.polys.orthopolys.legendre_poly
    sympy.polys.orthopolys.laguerre_poly

    References
    ==========

    .. [1] https://en.wikipedia.org/wiki/Laguerre_polynomial#Generalized_Laguerre_polynomials
    .. [2] https://mathworld.wolfram.com/AssociatedLaguerrePolynomial.html
    .. [3] https://functions.wolfram.com/Polynomials/LaguerreL/
    .. [4] https://functions.wolfram.com/Polynomials/LaguerreL3/

    c                 n   |j         rt          ||          S |j        sn|j         rt          ||z   |          S |t          j        u r"|dk    rt          j        |z  t          j        z  S |t          j        u r|dk    rt          j        S d S d S |j        rt          d|z            t          |||          S )Nr   r   )r?   r   rD   r   r   rH   rF   r   rZ   rJ   r   )r%   r&   alphar   s       r'   rM   zassoc_laguerre.evalo  s     = 	"Aq>>!{ 	2y "E	5111ajQUU}a'!*44a(((QUUz! )(UU } 2 FJL L L %Q5111r)   r<   c                 :   ddl m} |dk    rt          | |          |dk    rA| j        \  }}}t	          d          } |t          |||          ||z
  z  |d|dz
  f          S |dk    r#| j        \  }}}t          |dz
  |dz   |           S t          | |          )Nr   rP   r+   r;   rR   r<   )rS   rQ   r   r-   r   r   )r/   rT   rQ   r&   r   r   rR   s          r'   rW   zassoc_laguerre.fdiff  s    111111q==$T8444]])KAuac

A3~a22a%i@1aQ-PPP]])KAua"1q5%!)Q7777$T8444r)   c                 N   ddl m} |j        s	|j        du rt	          d          t          d          }t          | |          t          ||z   dz             t          |          z  z  ||z  z  }t          ||z   dz             t          |          z   |||d|f          z  S )Nr   rP   FrY   rR   r+   )	rS   rQ   rZ   r   rJ   r   r
   r   r	   )r/   r&   r   r   r[   rQ   rR   r\   s           r'   r]   z#assoc_laguerre._eval_rewrite_as_Sum  s    111111= 	KALE11IJJJ#JJB AIM**Yq\\9;=>TBQY]##ill2SS1ay5I5IIIr)   c                 "     | j         |||fi |S r_   r`   )r/   r&   r   r   r[   s        r'   ra   z*assoc_laguerre._eval_rewrite_as_polynomial  s#     )t(E1?????r)   c                     | j         \  }}}|                     ||                                |                                          S r_   rc   )r/   r&   r   r   s       r'   r0   zassoc_laguerre._eval_conjugate  s7    i5!yyEOO--q{{}}===r)   Nru   rd   r6   r)   r'   r   r   (  s        D DL 2 2 [2*5 5 5 5"J J J@ @ @
> > > > >r)   r   N)5r4   
sympy.corer   sympy.core.functionr   r   sympy.core.singletonr   sympy.core.symbolr   (sympy.functions.combinatorial.factorialsr   r	   r
   $sympy.functions.elementary.complexesr   &sympy.functions.elementary.exponentialr   #sympy.functions.elementary.integersr   (sympy.functions.elementary.miscellaneousr   (sympy.functions.elementary.trigonometricr   r   'sympy.functions.special.gamma_functionsr   sympy.functions.special.hyperr   sympy.polys.orthopolysr   r   r   r   r   r   r   r   r"   r   r8   rg   rB   r>   rA   r   r   r@   rC   r   r   r   r   r6   r)   r'   <module>r      s=           < < < < < < < < " " " " " " # # # # # # Y Y Y Y Y Y Y Y Y Y 3 3 3 3 3 3 6 6 6 6 6 6 5 5 5 5 5 5 9 9 9 9 9 9 = = = = = = = = 9 9 9 9 9 9 / / / / / /O O O O O O O O O O O O O O O O O O O O U3ZZ
A 
A 
A 
A 
A8 
A 
A 
A"dI dI dI dI dI! dI dI dINF. F. F.\R: R: R: R: R:% R: R: R:rs9 s9 s9 s9 s9% s9 s9 s9l{9 {9 {9 {9 {9% {9 {9 {9|&) &) &) &) &)h &) &) &)R&) &) &) &) &)h &) &) &)Zq9 q9 q9 q9 q9# q9 q9 q9hn: n: n: n: n:X n: n: n:jc7 c7 c7 c7 c7" c7 c7 c7L^5 ^5 ^5 ^5 ^5' ^5 ^5 ^5Lk9 k9 k9 k9 k9# k9 k9 k9\> > > > >) > > > > >r)   