
    sg~                        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'      Z4y+),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y)OrthogonalPolynomialz+Base class for orthogonal polynomials.
    c                     |j                   r9|dk\  r3| j                  t        |      t              j	                  t        |      S y y )Nr   )
is_integer_ortho_polyint_xsubsclsnr   s      V/var/www/html/venv/lib/python3.12/site-packages/sympy/functions/special/polynomials.py_eval_at_orderz#OrthogonalPolynomial._eval_at_order    s8    <<AF??3q62.33B:: #<    c                 v    | j                  | j                  d   | j                  d   j                               S )Nr      )funcargs	conjugate)selfs    r'   _eval_conjugatez$OrthogonalPolynomial._eval_conjugate%   s,    yy1tyy|'='='?@@r)   N)__name__
__module____qualname____doc__classmethodr(   r0    r)   r'   r   r      s!     ; ;Ar)   r   c                   :    e Zd ZdZed        ZddZd Zd Zd Z	y)	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                    ||k(  r|t        dd      k(  r3t        t        j                  |      t	        |      z  t        ||      z  S |j                  rt        ||      S |t        j                  k(  r9t        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(  rGt        ||z   dz         t        |dz         z  d|z   |dz  z  z  d|z
  |dz  z  z  t        || |      z  S |j                  s|j                         r#t        j                  |z  t        ||||       z  S |j                  rLd| 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 rS|j&                  rF||z   d|z  z   j(                  rt+        d      t        ||z   |z   dz   |      t        j$                  z  S y y 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~   sb    6HRO#&qvvq1IaL@:aQRCSSS1~%aff&qx3iA6FFTUWXIYYY&q1ua0?1Q37A3NNQ[\]_`cdcici_iklQmmm1"WQ#eAEl2a!eqs^Cq1uPQRSPSnTWefgjkikmnWooo{{ ))+}}a'&Aq1"*===yyQB%A	"22eAElYq\6QRrAvrlQUGR89 :AEEz&q1ua09Q<??ajj==A!//()WXX*1q519q=!<qzzII	 ! ! 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(  rE| j                  \  }}}}t        j                  ||z   |z   dz   z  t        |dz
  |dz   |dz   |      z  S t        | |      )	Nr   Sumr+   r;   kr<   r:      )	sympy.concrete.summationsrP   r   r-   r   r
   r8   r   r=   )
r/   argindexrP   r&   rK   rL   r   rQ   f1f2s
             r'   fdiffzjacobi.fdiff   s*   1q=$T844]JAq!Qc
Aa!eai!ma'(Bq51Q3;?oa!eaiQ&GGE_QUQY]AEBBDBrVAq!Q/"VAq!Q5G2GGH1aQRUVQV-XX]JAq!Qc
Aa!eai!ma'(BA1q51Q3;?oa!eaiQRUVQV6W"WE_QUQY]AEBB#D EBrVAq!Q/"VAq!Q5G2GGH1aQRUVQV-XX]JAq!Q66QUQY]+fQUAE1q5!.LLL$T844r)   c                 F   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   rO   F*Error: n should be a non-negative integer.rQ   r+   r;   )rS   rP   is_negativer   rJ   r   r
   r	   )	r/   r&   rK   rL   r   kwargsrP   rQ   kerns	            r'   _eval_rewrite_as_Sumzjacobi._eval_rewrite_as_Sum   s    1==ALLE1IJJ#JA&QQ)JJ_]^ab]bef]fhilmhmMnn!!"Q	A~.9Q<#dQ1I"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                   \  }}}}| j                  ||j                         |j                         |j                               S r_   r-   r,   r.   )r/   r&   rK   rL   r   s        r'   r0   zjacobi._eval_conjugate   s:    YY
1ayyAKKM1;;=!++-HHr)   N)rR   
r1   r2   r3   r4   r5   rM   rW   r]   ra   r0   r6   r)   r'   r8   r8   -   s3    N` #+ #+J587?
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 ta!eai E!a%!)$4uQUQY7G$GHA#'A+/#&/lU1q519q=5I&IKG !Q1W--r)   c                   :    e Zd ZdZed        ZddZd Zd Zd Z	y)	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                  kD  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 |j                         r"t        j                  |z  t!        |||       z  S |j"                  rld|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 y y 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    ==66M ;Aq>!!%%Za##!--66M{{AMM!qEAFFNt+,,,ac
Oc!$$q&k9E!A#a%LH!&qseAaCj!8: ;
 ))+}}a'*QA2*>>>yy1tADDz)E!affQh,,??Aqy)E!a%L858CE GAEEzQqS1W~qseAEl)BCCajj==*1a01::== ! !
 #1a++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   rO   r+   r;   rQ   r:   r<   )rS   rP   r   r-   r   rB   )
r/   rT   rP   r&   rK   r   rQ   factor1factor2r\   s
             r'   rW   zgegenbauer.fdiff  sG   1q=$T844]iiGAq!c
A1a!e},-Q7A= s=#'(1u<. /GQiA!G!ac	A#>?QUQqS[!"G:aA..Aq!9L1LLDtaAE]++]iiGAq!Q3z!a%Q222$T8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   rO   rQ   r:   r;   )rS   rP   r   r
   r	   r   )r/   r&   rK   r   r[   rP   rQ   r\   s           r'   r]   zgegenbauer._eval_rewrite_as_Sum  sw    1#Ja/!QU33qsa!A#g6FF1	!ac' 2244!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                   \  }}}| j                  ||j                         |j                               S r_   rc   )r/   r&   rK   r   s       r'   r0   zgegenbauer._eval_conjugate  0    ))1ayyAKKM1;;=99r)   Nr<   rd   r6   r)   r'   rB   rB   "  s2    BH &, &,P5,-<
:r)   rB   c                   D    e Zd ZdZ ee      Zed        ZddZ	d Z
d Zy)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|j                         r!t        j                  |z  t	        ||       z  S |j                         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 y |j                  r| j                  | |      S | j                  ||      S r_   )rD   rE   r   rF   r>   r?   r   r=   rl   rG   rH   rZ   r(   r$   s      r'   rM   zchebyshevt.eval  s    {{ ))+}}a'*Q*;;;))+!1"a((yy166ADD=1,--AEEzuuajjzz! ! }}))1"a00))!Q//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  sM    q=$T844]99DAqz!a%+++$T8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   rO   rQ   r;   r+   )rS   rP   r   r   r   r/   r&   r   r[   rP   rQ   r\   s          r'   r]   zchebyshevt._eval_rewrite_as_Sum%  s\    1#J1Q31a4!8a-/!a!A#g,>4!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8r)   Nr;   )r1   r2   r3   r4   staticmethodr   r    r5   rM   rW   r]   ra   r6   r)   r'   r>   r>     s6    AF /K0 00	5-9r)   r>   c                   D    e Zd ZdZ ee      Zed        ZddZ	d Z
d Zy)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|j                         r!t        j                  |z  t	        ||       z  S |j                         rH|t        j                  k(  rt        j
                  S | dz
  j                         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 y |j                  r:|t        j                  k(  rt        j
                  S | j                  | dz
  |       S | j                  ||      S Nr;   )rD   rE   r   rF   rA   rj   r?   r   r=   rl   rG   rH   rZ   r(   r$   s      r'   rM   zchebyshevu.evalw  s    {{ ))+}}a'*Q*;;;))+%66M"q&::<&rAvq111yy166ADD=1,--AEEzuuqy ajjzz! ! }}%66M..rAvq999))!Q//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  sq    q=$T844]99DAqUjQ22QAq9I5IIaQRdUVhWW$T8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   rO   rQ   r;   rS   rP   r   r   rF   r	   r   r}   s          r'   r]   zchebyshevu._eval_rewrite_as_Sum  s    1#J}}a)E# cQ1W%&)21	!ac'8J)JL4!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  s6    AF /K0 0>	5-9r)   rA   c                        e Zd ZdZed        Zy)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&   rQ   s      r'   rM   zchebyshevt_root.eval  sJ    aa!e+,a1 2 2144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y)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  sF    aa!e+,a1 2 2144Q<Q'((r)   Nr   r6   r)   r'   r   r     s    @ ) )r)   r   c                   D    e Zd ZdZ ee      Zed        ZddZ	d Z
d Zy)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|j                         r!t        j                  |z  t	        ||       z  S |j                         r2| dz
  j                         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 y |j                  r| t        j
                  z
  }| j                  ||      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F3T3T3VQUU
A..yyADDz5!A##6uQUUQqS[7I#IJJaeeuuajjzz! !
 }}BJ%%a++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  sk    q=$T844] 99DAqadQh<8Aq>!1HQUA4F!FGG$T8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   rP   r   r   rF   r   r}   s          r'   r]   zlegendre._eval_rewrite_as_Summ  sh    1#J}}aA 11AE19A2FFQPQ	TU~U4!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@     s5    3j }-K, ,.50$9r)   r@   c                   J    e Zd ZdZed        Zed        Zd	dZd Zd Z	d Z
y)
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      j                  t        |f      }t        j                  |z  dt        dz  z
  t        |d      z  z  |j                         z  S )NT)polysr+   r;   )r   r"   diffr   rF   r   as_expr)r%   r&   mPs       r'   r(   zassoc_legendre._eval_at_order  sQ    !Rt,112q':}}a1r1u9x1~"==		KKr)   c                    |j                         rAt        j                  | z  t        ||z         t        ||z
        z  z  t	        || |      z  S |dk(  rt        ||      S |dk(  rId|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        |      |kD  rt        | d|d|d      | j                  t        |      t        t        |                  j!                  t"        |      S y y y y )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  s5   %%'==A2&)AE*:9QU;K*KL~^_bcacefOggg6Aq>!6a4QTT
?eQUQYM&:5a!eQY;O&OPP;;1;;1<<ALL}} Z]_`!abb1vz `cefhi!jkk%%c!fc#a&k:??AFF =I<;;r)   c                     |dk(  rt        | |      |dk(  rt        | |      |dk(  rF| 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]$T844] iiGAq!adQh<1^Aq!%<!<A~VWZ[V[]^`aGb?b!bcc$T844r)   c           
      n   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   rP   r   r	   r   rF   r   r=   )r/   r&   r   r   r[   rP   rQ   r\   s           r'   r]   z#assoc_legendre._eval_rewrite_as_Sum  s    1#J1qs#QT)AE*:%:9< &QqS1%&& ''(}}a'7889AEAaCK8HIAqDAaC 3taE1q5!&&.4I-J#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                   \  }}}| j                  ||j                         |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  sI    8t L L G G 5L<
:r)   rC   c                   J    e Zd ZdZ ee      Zed        ZddZ	d Z
d Zd Zy)	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|j                         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 y |j                  rt        d|z        | j                  ||      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    {{ ))+}}a''!aR.88yy!td144j(5!%%!)Q+???ajjzz! ! }} FJL L ))!Q//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:  sQ    q=$T844]99DAqQ3wq1ua((($T8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  su    1#J}}a9Q<	!ac'0B#BCqsaRSTURUgFVV|Cq!U1Q3Z&8999r)   c                 *     | j                   ||fi |S r_   r`   r   s       r'   ra   z#hermite._eval_rewrite_as_polynomialK  r   r)   c                 P    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$    AwzLAd1gI666r)   Nr   )r1   r2   r3   r4   r   r   r    r5   rM   rW   r]   ra   r   r6   r)   r'   r   r     s:    3j |,K0 0&	5:9
7r)   r   c                   J    e Zd ZdZ ee      Zed        ZddZ	d Z
d Zd Zy)	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|j                         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 y |j                  rt        d|z         y | j                  ||      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    {{))+}}a',q1"*===yyADDzE1557a-$888ajjzz! ! }}DqHI))!Q//r)   c                 f    |dk(  r!| j                   \  }}|t        |dz
  |      z  S t        | |      )Nr;   r+   )r-   r   r   rz   s       r'   rW   zhermite_prob.fdiff  s9    q=99DAq\!A#q)))$T8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   rP   r   r   r=   r	   r   r}   s          r'   r]   z!hermite_prob._eval_rewrite_as_Sum  sn    1#J!|a!AaC%j(IaL9QqsU;K,KL|Cq!U1Q3Z&8999r)   c                 *     | j                   ||fi |S r_   r`   r   s       r'   ra   z(hermite_prob._eval_rewrite_as_polynomial  r   r)   c                 R    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&    Aw!}wq!DG)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r 01K0 05:9
5r)   r   c                   D    e Zd ZdZ ee      Zed        ZddZ	d Z
d Zy)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|j                         r1| dz
  j                         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 y |j                  rt	        |      t        | dz
  |       z  S | j                  ||      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 =>>{{ ))+QBF3T3T3V1vhrAvr222yyuua(((zz!ajj}}a'!**44 ! }}1vhrAvr222))!Q//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  sM    q=$T844]99DAq"1q5!Q///$T8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   rO   r+   Fr   rQ   r;   )
rS   rP   rZ   r   r]   r   rJ   r   r
   r	   r}   s          r'   r]   zlaguerre._eval_rewrite_as_Sum  s    1==q65D55qb1fqbKFKKK<<5 =>>#Jr1%	!a7!Q$>4!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     s5    6p }-K0 0,	5	$9r)   r   c                   :    e Zd ZdZed        ZddZd Zd Zd Z	y)	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                    |j                   rt        ||      S |j                  s|j                   rt        ||z   |      S |t        j
                  u r)|dkD  r$t        j                  |z  t        j
                  z  S |t        j                  u r|dkD  rt        j
                  S y y |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>!{{yyE	511ajjQU}}a'!**44a(((QUzz! .3( }} FJL L %Q511r)   c                    ddl m} |dk(  rt        | |      |dk(  r;| j                  \  }}}t	        d      } |t        |||      ||z
  z  |d|dz
  f      S |dk(  r$| j                  \  }}}t        |dz
  |dz   |       S t        | |      )Nr   rO   r+   r;   rQ   r<   )rS   rP   r   r-   r   r   )r/   rT   rP   r&   r   r   rQ   s          r'   rW   zassoc_laguerre.fdiff  s    1q=$T844]))KAuac
A~a2a%i@1aQ-PP]))KAua"1q5%!)Q777$T844r)   c                 $   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   rO   FrY   rQ   r+   )	rS   rP   rZ   r   rJ   r   r
   r   r	   )r/   r&   r   r   r[   rP   rQ   r\   s           r'   r]   z#assoc_laguerre._eval_rewrite_as_Sum  s    1==ALLE1IJJ#JBAIM*Yq\9;=>TBQY]#il2S1ay5I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                   \  }}}| j                  ||j                         |j                               S r_   rc   )r/   r&   r   r   s       r'   r0   zassoc_laguerre._eval_conjugate  s1    ii5!yyEOO-q{{}==r)   Nru   rd   r6   r)   r'   r   r   (  s3    DL 2 2*5"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 3 6 5 9 = 9 /O O O 3Z
A8 
A"dI! dINF.\R:% R:rs9% s9l{9% {9|&)h &)R&)h &)Zq9# q9hn:X n:jc7" c7L^5' ^5Lk9# k9\>) >r)   