ó
Ê½÷Xc           @` sI  d  Z  d d l m Z m Z m Z d d l Z d d l m Z m Z m	 Z	 m
 Z
 m Z m Z m Z m Z m Z m Z m Z m Z d d l m Z d d l m Z d d l m Z e j Z d d	 l m Z d
 d d d d d d d d d d d d d d g Z i d d 6d d 6d d 6d d  6d! d" 6d# d$ 6d% d& 6d' d( 6d) d* 6d+ d, 6d- d. 6d/ d0 6d1 d2 6d3 d4 6d5 d6 6Z d7 d8 d9 d: d; d< d= d> d? d@ dA dB dC dD dE g Z e e  e j! ƒ  ƒ e dF dG g Z" dH e j# f dI „  ƒ  YZ$ dJ „  Z% e& dK „ Z' e& dL „ Z( e& dM „ Z) e& dN „ Z* e& dO „ Z+ e& dP „ Z, e& dQ „ Z- e& dR „ Z. e& dS „ Z/ dT dU „ Z0 dV „  Z1 dW „  Z2 dX „  Z3 dY „  Z4 dT dZ „ Z5 d[ „  Z6 e& d\ „ Z7 e& d] „ Z8 e& d^ „ Z9 e& d_ „ Z: e& d` „ Z; e& da „ Z< e& db „ Z= e& dc „ Z> e& dd „ Z? e& de „ Z@ e& df „ ZA e& dg „ ZB e& dh „ ZC e& di „ ZD e& dj „ ZE e& dk „ ZF e& dl „ ZG e& dm „ ZH e& dn „ ZI e& do „ ZJ e& dp „ ZK e jL ZL d dq l mM ZM mN ZN mO ZO mP ZP mQ ZQ mR ZR mS ZS mT ZT mU ZU mV ZV mW ZW mX ZX mY ZY mZ ZZ m[ Z[ m\ Z\ e] ƒ  Z^ x5 e j_ ƒ  D]' \ Z` Za e^ e` e^ ea <e" jb ea ƒ qWd S(r   sI  
A collection of functions to find the weights and abscissas for
Gaussian Quadrature.

These calculations are done by finding the eigenvalues of a
tridiagonal matrix whose entries are dependent on the coefficients
in the recursion formula for the orthogonal polynomials with the
corresponding weighting function over the interval.

Many recursion relations for orthogonal polynomials are given:

.. math::

    a1n f_{n+1} (x) = (a2n + a3n x ) f_n (x) - a4n f_{n-1} (x)

The recursion relation of interest is

.. math::

    P_{n+1} (x) = (x - A_n) P_n (x) - B_n P_{n-1} (x)

where :math:`P` has a different normalization than :math:`f`.

The coefficients can be found as:

.. math::

    A_n = -a2n / a3n
    \qquad
    B_n = ( a4n / a3n \sqrt{h_n-1 / h_n})^2

where

.. math::

    h_n = \int_a^b w(x) f_n(x)^2

assume:

.. math::

    P_0 (x) = 1
    \qquad
    P_{-1} (x) == 0

For the mathematical background, see [golub.welsch-1969-mathcomp]_ and
[abramowitz.stegun-1965]_.

References
----------
.. [golub.welsch-1969-mathcomp]
   Golub, Gene H, and John H Welsch. 1969. Calculation of Gauss
   Quadrature Rules. *Mathematics of Computation* 23, 221-230+s1--s10.

.. [abramowitz.stegun-1965]
   Abramowitz, Milton, and Irene A Stegun. (1965) *Handbook of
   Mathematical Functions: with Formulas, Graphs, and Mathematical
   Tables*. Gaithersburg, MD: National Bureau of Standards.
   http://www.math.sfu.ca/~cbm/aands/

.. [townsend.trogdon.olver-2014]
   Townsend, A. and Trogdon, T. and Olver, S. (2014)
   *Fast computation of Gauss quadrature nodes and
   weights on the whole real line*. :arXiv:`1410.5286`.

.. [townsend.trogdon.olver-2015]
   Townsend, A. and Trogdon, T. and Olver, S. (2015)
   *Fast computation of Gauss quadrature nodes and
   weights on the whole real line*.
   IMA Journal of Numerical Analysis
   :doi:`10.1093/imanum/drv002`.
i    (   t   divisiont   print_functiont   absolute_importN(   t   expt   inft   pit   sqrtt   floort   sint   cost   aroundt   intt   hstackt   arccost   arange(   t   linalg(   t   airyi   (   t   _ufuncs(   t   specfunt   legendret   chebytt   chebyut   chebyct   chebyst   jacobit   laguerret   genlaguerret   hermitet   hermitenormt
   gegenbauert   sh_legendret	   sh_chebytt	   sh_chebyut	   sh_jacobit   p_rootst   roots_legendret   t_rootst   roots_chebytt   u_rootst   roots_chebyut   c_rootst   roots_chebyct   s_rootst   roots_chebyst   j_rootst   roots_jacobit   l_rootst   roots_laguerret   la_rootst   roots_genlaguerret   h_rootst   roots_hermitet   he_rootst   roots_hermitenormt   cg_rootst   roots_gegenbauert   ps_rootst   roots_sh_legendret   ts_rootst   roots_sh_chebytt   us_rootst   roots_sh_chebyut   js_rootst   roots_sh_jacobit   eval_legendret   eval_chebytt   eval_chebyut   eval_chebyct   eval_chebyst   eval_jacobit   eval_laguerret   eval_genlaguerret   eval_hermitet   eval_hermitenormt   eval_gegenbauert   eval_sh_legendret   eval_sh_chebytt   eval_sh_chebyut   eval_sh_jacobit   pocht   binomt   orthopoly1dc           B` s8   e  Z d d  d  d d e d d „ Z d „  Z d „  Z RS(   g      ð?c	         ` s  t  j j |  | d d ƒg  t t | ƒ ƒ D] }	 | |	 | | |	 ƒ ^ q, }
 t  j t t | | |
 ƒ ƒ ƒ |  j d <| |  j d <| |  j d <t	 | ƒ } | rÞ | ‰  ˆ  rÅ ‡  ‡ f d †  } n  | t
 ˆ ƒ } d ‰ n  | |  j d <|  j d	 c t ˆ ƒ 9<| |  j d
 <d  S(   Nt   ri   t   weightst   weight_funct   limitsc         ` s   ˆ  |  ƒ ˆ S(   N(    (   t   x(   t   evft   kn(    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyt   <lambda>Š   s    g      ð?t   normcoeft   coeffst
   _eval_func(   t   npt   poly1dt   __init__t   ranget   lent   arrayt   listt   zipt   __dict__R   t   abst   float(   t   selft   rootsRS   t   hnRX   t   wfuncRU   t   monict	   eval_funct   kt   equiv_weightst   mu(    (   RW   RX   s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyR_   }   s"    4	c         C` s@   |  j  r) t | t j ƒ r) |  j  | ƒ St j j |  | ƒ Sd  S(   N(   R\   t
   isinstanceR]   R^   t   __call__(   Rh   t   v(    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRr   “   s    c         ` si   ˆ d k r d  S|  j  d c ˆ 9<|  j  d ‰  ˆ  rR ‡  ‡ f d †  |  j  d <n  |  j  d c ˆ 9<d  S(   Ng      ð?R[   R\   c         ` s   ˆ  |  ƒ ˆ S(   N(    (   RV   (   RW   t   p(    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRY   Ÿ   s    RZ   (   Re   (   Rh   Rt   (    (   RW   Rt   s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyt   _scale™   s    N(   t   __name__t
   __module__t   Nonet   FalseR_   Rr   Ru   (    (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRQ   {   s   	c         C` sn  t  j |  d d ƒ} t  j d |  f ƒ }	 | | d ƒ |	 d d d … f <| | ƒ |	 d d d … f <t j |	 d t ƒ}
 | |  |
 ƒ } | |  |
 ƒ } |
 | | 8}
 | |  d |
 ƒ } | t  j | ƒ j ƒ  } | t  j | ƒ j ƒ  } d | | } | r9| | d d d	 … d } |
 |
 d d d	 … d }
 n  | | | j ƒ  9} | r`|
 | | f S|
 | f Sd S(
   s  [x,w] = gen_roots_and_weights(n,an_func,sqrt_bn_func,mu)

    Returns the roots (x) of an nth order orthogonal polynomial,
    and weights (w) to use in appropriate Gaussian quadrature with that
    orthogonal polynomial.

    The polynomials have the recurrence relation
          P_n+1(x) = (x - A_n) P_n(x) - B_n P_n-1(x)

    an_func(n)          should return A_n
    sqrt_bn_func(n)     should return sqrt(B_n)
    mu ( = h_0 )        is the integral of the weight over the orthogonal
                        interval
    t   dtypet   di   i   i    Nt   overwrite_a_bandg      ð?iÿÿÿÿ(	   R]   R   t   zerosR   t   eigvals_bandedt   TrueRf   t   maxt   sum(   t   nt   mu0t   an_funct   bn_funct   ft   dft
   symmetrizeRp   Rn   t   cRV   t   yt   dyt   fmt   w(    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyt   _gen_roots_and_weights£   s&     c   
      ` sa  t  |  ƒ } |  d k  s$ |  | k r3 t d ƒ ‚ n  | d k sK | d k rZ t d ƒ ‚ n  | d k r | d k r t | | ƒ S| | k rŸ t | | d | ƒ Sd | | d t j | d | d ƒ } | ‰  | ‰ ˆ  ˆ d k rú ‡  ‡ f d †  } n ‡  ‡ f d	 †  } ‡  ‡ f d
 †  } ‡  ‡ f d †  } ‡  ‡ f d †  }	 t | | | | | |	 t | ƒ S(   sy  Gauss-Jacobi quadrature.

    Computes the sample points and weights for Gauss-Jacobi quadrature. The
    sample points are the roots of the n-th degree Jacobi polynomial,
    :math:`P^{\alpha, \beta}_n(x)`.  These sample points and weights
    correctly integrate polynomials of degree :math:`2n - 1` or less over the
    interval :math:`[-1, 1]` with weight function
    :math:`f(x) = (1 - x)^{\alpha} (1 + x)^{\beta}`.

    Parameters
    ----------
    n : int
        quadrature order
    alpha : float
        alpha must be > -1
    beta : float
        beta must be > 0
    mu : bool, optional
        If True, return the sum of the weights, optional.

    Returns
    -------
    x : ndarray
        Sample points
    w : ndarray
        Weights
    mu : float
        Sum of the weights

    See Also
    --------
    scipy.integrate.quadrature
    scipy.integrate.fixed_quad
    i   s   n must be a positive integer.iÿÿÿÿs'   alpha and beta must be greater than -1.g        g      à?g       @c         ` s)   t  j |  d k ˆ ˆ  d ˆ  ˆ d ƒ S(   Ni    i   g        (   R]   t   where(   Rn   (   t   at   b(    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRY     s    c         ` sY   t  j |  d k ˆ ˆ  d ˆ  ˆ ˆ ˆ ˆ  ˆ  d |  ˆ  ˆ d |  ˆ  ˆ d ƒ S(   Ni    i   g       @(   R]   R   (   Rn   (   R   R‘   (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRY     s   "c         ` sƒ   d d |  ˆ  ˆ t  j |  ˆ  |  ˆ d |  ˆ  ˆ d ƒ t  j |  d k d t  j |  |  ˆ  ˆ d |  ˆ  ˆ d ƒ ƒ S(   Ng       @i   i   g      ð?(   R]   R   R   (   Rn   (   R   R‘   (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRY     s    c         ` s   t  j |  ˆ  ˆ | ƒ S(   N(   t   cephesRE   (   R‚   RV   (   R   R‘   (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRY   
  s    c         ` s6   d |  ˆ  ˆ d t  j |  d ˆ  d ˆ d | ƒ S(   Ng      à?i   (   R’   RE   (   R‚   RV   (   R   R‘   (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRY     s    (   R   t
   ValueErrorR#   R7   R’   t   betaRŽ   Ry   (
   R‚   t   alphaR”   Rp   t   mRƒ   R„   R…   R†   R‡   (    (   R   R‘   s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyR-   Ð   s&    #*c         ` sU  ˆ d k  r t  d ƒ ‚ n  ‡  ‡ f d †  } ˆ d k r^ t g  g  d d | d | d t j ƒSt ˆ ˆ  ˆ d t ƒ\ } } } ˆ  ˆ d } d	 | d	 ˆ | t ˆ ˆ  d ƒ }	 |	 t ˆ ˆ d ƒ t ˆ d ƒ t ˆ | ƒ 9}	 t d	 ˆ | ƒ d
 ˆ t ˆ d ƒ t ˆ | ƒ }
 t | | |	 |
 | d | ‡  ‡ ‡ f d †  ƒ } | S(   sÞ  Jacobi polynomial.

    Defined to be the solution of

    .. math::
        (1 - x^2)\frac{d^2}{dx^2}P_n^{(\alpha, \beta)}
          + (\beta - \alpha - (\alpha + \beta + 2)x)
            \frac{d}{dx}P_n^{(\alpha, \beta)}
          + n(n + \alpha + \beta + 1)P_n^{(\alpha, \beta)} = 0

    for :math:`\alpha, \beta > -1`; :math:`P_n^{(\alpha, \beta)}` is a
    polynomial of degree :math:`n`.

    Parameters
    ----------
    n : int
        Degree of the polynomial.
    alpha : float
        Parameter, must be greater than -1.
    beta : float
        Parameter, must be greater than -1.
    monic : bool, optional
        If `True`, scale the leading coefficient to be 1. Default is
        `False`.

    Returns
    -------
    P : orthopoly1d
        Jacobi polynomial.

    Notes
    -----
    For fixed :math:`\alpha, \beta`, the polynomials
    :math:`P_n^{(\alpha, \beta)}` are orthogonal over :math:`[-1, 1]`
    with weight function :math:`(1 - x)^\alpha(1 + x)^\beta`.

    i    s   n must be nonnegative.c         ` s   d |  ˆ  d |  ˆ S(   Ni   (    (   RV   (   R•   R”   (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRY   9  s    g      ð?iÿÿÿÿi   Rm   Rp   i   g       @c         ` s   t  ˆ ˆ  ˆ |  ƒ S(   N(   RE   (   RV   (   R•   R”   R‚   (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRY   D  s    (   iÿÿÿÿi   (   iÿÿÿÿi   (   R“   RQ   R]   t	   ones_likeR-   R   t   _gam(   R‚   R•   R”   Rl   Rk   RV   R   Rp   t   ab1Rj   RX   Rt   (    (   R•   R”   R‚   s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyR     s    &
!(48c         C` sž   | | d k s | d k r+ t  d ƒ ‚ n  t |  | | | d t ƒ \ } } } | d d } d | } | | } | | } | r | | | f S| | f Sd S(   s{  Gauss-Jacobi (shifted) quadrature.

    Computes the sample points and weights for Gauss-Jacobi (shifted)
    quadrature. The sample points are the roots of the n-th degree shifted
    Jacobi polynomial, :math:`G^{p,q}_n(x)`.  These sample points and weights
    correctly integrate polynomials of degree :math:`2n - 1` or less over the
    interval :math:`[0, 1]` with weight function
    :math:`f(x) = (1 - x)^{p-q} x^{q-1}`

    Parameters
    ----------
    n : int
        quadrature order
    p1 : float
        (p1 - q1) must be > -1
    q1 : float
        q1 must be > 0
    mu : bool, optional
        If True, return the sum of the weights, optional.

    Returns
    -------
    x : ndarray
        Sample points
    w : ndarray
        Weights
    mu : float
        Sum of the weights

    See Also
    --------
    scipy.integrate.quadrature
    scipy.integrate.fixed_quad
    iÿÿÿÿi    s>   (p - q) must be greater than -1, and q must be greater than 0.i   i   g       @N(   R“   R-   R   (   R‚   t   p1t   q1Rp   RV   R   R–   t   scale(    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyR?   J  s    #&


c         ` s5  ˆ  d k  r t  d ƒ ‚ n  ‡ ‡ f d †  } ˆ  d k r^ t g  g  d d | d | d t j ƒSˆ  } t | ˆ ˆ d t ƒ\ } } } t ˆ  d ƒ t ˆ  ˆ ƒ t ˆ  ˆ ƒ t ˆ  ˆ ˆ d ƒ }	 |	 d	 ˆ  ˆ t d	 ˆ  ˆ ƒ d	 }	 d }
 t | | |	 |
 d
 | d d d | d ‡  ‡ ‡ f d †  ƒ} | S(   s   Shifted Jacobi polynomial.

    Defined by

    .. math::

        G_n^{(p, q)}(x) 
          = \binom{2n + p - 1}{n}^{-1}P_n^{(p - q, q - 1)}(2x - 1),

    where :math:`P_n^{(\cdot, \cdot)}` is the nth Jacobi polynomial.

    Parameters
    ----------
    n : int
        Degree of the polynomial.
    p : float
        Parameter, must have :math:`p > q - 1`.
    q : float
        Parameter, must be greater than 0.
    monic : bool, optional
        If `True`, scale the leading coefficient to be 1. Default is
        `False`.

    Returns
    -------
    G : orthopoly1d
        Shifted Jacobi polynomial.

    Notes
    -----
    For fixed :math:`p, q`, the polynomials :math:`G_n^{(p, q)}` are
    orthogonal over :math:`[0, 1]` with weight function :math:`(1 -
    x)^{p - q}x^{q - 1}`.

    i    s   n must be nonnegative.c         ` s   d |  ˆ  ˆ |  ˆ d S(   Ng      ð?(    (   RV   (   Rt   t   q(    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRY      s    g      ð?iÿÿÿÿi   Rm   Rp   i   Rk   RU   Rl   c         ` s   t  ˆ  ˆ ˆ |  ƒ S(   N(   RN   (   RV   (   R‚   Rt   R   (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRY   «  s    (   iÿÿÿÿi   (   i    i   (   R“   RQ   R]   R—   R?   R   R˜   (   R‚   Rt   R   Rl   Rk   t   n1RV   R   Rƒ   Rj   RX   t   pp(    (   R‚   Rt   R   s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyR!   y  s    $
!B($c      
   ` s  t  |  ƒ } |  d k  s$ |  | k r3 t d ƒ ‚ n  ˆ  d k  rN t d ƒ ‚ n  t j ˆ  d ƒ } | d k r» t j ˆ  d g d ƒ } t j | g d ƒ } | r® | | | f S| | f Sn  ‡  f d †  } ‡  f d †  } ‡  f d	 †  }	 ‡  f d
 †  }
 t | | | | |	 |
 t | ƒ S(   sg  Gauss-generalized Laguerre quadrature.

    Computes the sample points and weights for Gauss-generalized Laguerre
    quadrature. The sample points are the roots of the n-th degree generalized
    Laguerre polynomial, :math:`L^{\alpha}_n(x)`.  These sample points and
    weights correctly integrate polynomials of degree :math:`2n - 1` or less
    over the interval :math:`[0, \infty]` with weight function
    :math:`f(x) = x^{\alpha} e^{-x}`.

    Parameters
    ----------
    n : int
        quadrature order
    alpha : float
        alpha must be > -1
    mu : bool, optional
        If True, return the sum of the weights, optional.

    Returns
    -------
    x : ndarray
        Sample points
    w : ndarray
        Weights
    mu : float
        Sum of the weights

    See Also
    --------
    scipy.integrate.quadrature
    scipy.integrate.fixed_quad
    i   s   n must be a positive integer.iÿÿÿÿs   alpha must be greater than -1.g      ð?R{   c         ` s   d |  ˆ  d S(   Ni   i   (    (   Rn   (   R•   (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRY   â  s    c         ` s   t  j |  |  ˆ  ƒ S(   N(   R]   R   (   Rn   (   R•   (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRY   ã  s    c         ` s   t  j |  ˆ  | ƒ S(   N(   R’   RG   (   R‚   RV   (   R•   (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRY   ä  s    c         ` s:   |  t  j |  ˆ  | ƒ |  ˆ  t  j |  d ˆ  | ƒ | S(   Ni   (   R’   RG   (   R‚   RV   (   R•   (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRY   å  s   (   R   R“   R’   t   gammaR]   Rb   RŽ   Ry   (   R‚   R•   Rp   R–   Rƒ   RV   R   R„   R…   R†   R‡   (    (   R•   s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyR1   ±  s"    !c      
   ` s  ˆ  d k r t  d ƒ ‚ n  ˆ d k  r6 t  d ƒ ‚ n  ˆ d k rO ˆ d } n ˆ } t | ˆ  d t ƒ\ } } } ‡  f d †  } ˆ d k rž g  g  } } n  t ˆ ˆ  d ƒ t ˆ d ƒ } d ˆ t ˆ d ƒ }	 t | | | |	 | d t f | ‡  ‡ f d †  ƒ }
 |
 S(	   sß  Generalized (associated) Laguerre polynomial.

    Defined to be the solution of

    .. math::
        x\frac{d^2}{dx^2}L_n^{(\alpha)} 
          + (\alpha + 1 - x)\frac{d}{dx}L_n^{(\alpha)}
          + nL_n^{(\alpha)} = 0,

    where :math:`\alpha > -1`; :math:`L_n^{(\alpha)}` is a polynomial
    of degree :math:`n`.

    Parameters
    ----------
    n : int
        Degree of the polynomial.
    alpha : float
        Parameter, must be greater than -1.
    monic : bool, optional
        If `True`, scale the leading coefficient to be 1. Default is
        `False`.

    Returns
    -------
    L : orthopoly1d
        Generalized Laguerre polynomial.

    Notes
    -----
    For fixed :math:`\alpha`, the polynomials :math:`L_n^{(\alpha)}`
    are orthogonal over :math:`[0, \infty)` with weight function
    :math:`e^{-x}x^\alpha`.

    The Laguerre polynomials are the special case where :math:`\alpha
    = 0`.

    See Also
    --------
    laguerre : Laguerre polynomial.

    iÿÿÿÿs   alpha must be > -1i    s   n must be nonnegative.i   Rp   c         ` s   t  |  ƒ |  ˆ  S(   N(   R   (   RV   (   R•   (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRY     s    c         ` s   t  ˆ ˆ  |  ƒ S(   N(   RG   (   RV   (   R•   R‚   (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRY   $  s    (   R“   R1   R   R˜   RQ   R   (   R‚   R•   Rl   Rž   RV   R   Rƒ   Rk   Rj   RX   Rt   (    (   R•   R‚   s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyR   ê  s     *"c         C` s   t  |  d d | ƒS(   s%  Gauss-Laguerre quadrature.

    Computes the sample points and weights for Gauss-Laguerre quadrature.
    The sample points are the roots of the n-th degree Laguerre polynomial,
    :math:`L_n(x)`.  These sample points and weights correctly integrate
    polynomials of degree :math:`2n - 1` or less over the interval
    :math:`[0, \infty]` with weight function :math:`f(x) = e^{-x}`.

    Parameters
    ----------
    n : int
        quadrature order
    mu : bool, optional
        If True, return the sum of the weights, optional.

    Returns
    -------
    x : ndarray
        Sample points
    w : ndarray
        Weights
    mu : float
        Sum of the weights

    See Also
    --------
    scipy.integrate.quadrature
    scipy.integrate.fixed_quad
    numpy.polynomial.laguerre.laggauss
    g        Rp   (   R1   (   R‚   Rp   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyR/   *  s    c   	   
   ` sÆ   ˆ  d k  r t  d ƒ ‚ n  ˆ  d k r4 ˆ  d } n ˆ  } t | d t ƒ\ } } } ˆ  d k rq g  g  } } n  d } d ˆ  t ˆ  d ƒ } t | | | | d „  d t f | ‡  f d †  ƒ } | S(	   sR  Laguerre polynomial.

    Defined to be the solution of

    .. math::
        x\frac{d^2}{dx^2}L_n + (1 - x)\frac{d}{dx}L_n + nL_n = 0;

    :math:`L_n` is a polynomial of degree :math:`n`.

    Parameters
    ----------
    n : int
        Degree of the polynomial.
    monic : bool, optional
        If `True`, scale the leading coefficient to be 1. Default is
        `False`.

    Returns
    -------
    L : orthopoly1d
        Laguerre Polynomial.

    Notes
    -----
    The polynomials :math:`L_n` are orthogonal over :math:`[0,
    \infty)` with weight function :math:`e^{-x}`.

    i    s   n must be nonnegative.i   Rp   g      ð?iÿÿÿÿc         S` s   t  |  ƒ S(   N(   R   (   RV   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRY   u  s    c         ` s   t  ˆ  |  ƒ S(   N(   RF   (   RV   (   R‚   (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRY   v  s    (   R“   R/   R   R˜   RQ   R   (	   R‚   Rl   Rž   RV   R   Rƒ   Rj   RX   Rt   (    (   R‚   s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyR   L  s    !c   
   
   C` sÇ   t  |  ƒ } |  d k  s$ |  | k r3 t d ƒ ‚ n  t j t j ƒ } |  d k r” d „  } d „  } t j } d „  } t | | | | | | t | ƒ St	 | ƒ \ } }	 | r¹ | |	 | f S| |	 f Sd S(   s[  Gauss-Hermite (physicst's) quadrature.

    Computes the sample points and weights for Gauss-Hermite quadrature.
    The sample points are the roots of the n-th degree Hermite polynomial,
    :math:`H_n(x)`.  These sample points and weights correctly integrate
    polynomials of degree :math:`2n - 1` or less over the interval
    :math:`[-\infty, \infty]` with weight function :math:`f(x) = e^{-x^2}`.

    Parameters
    ----------
    n : int
        quadrature order
    mu : bool, optional
        If True, return the sum of the weights, optional.

    Returns
    -------
    x : ndarray
        Sample points
    w : ndarray
        Weights
    mu : float
        Sum of the weights

    Notes
    -----
    For small n up to 150 a modified version of the Golub-Welsch
    algorithm is used. Nodes are computed from the eigenvalue
    problem and improved by one step of a Newton iteration.
    The weights are computed from the well-known analytical formula.

    For n larger than 150 an optimal asymptotic algorithm is applied
    which computes nodes and weights in a numerically stable manner.
    The algorithm has linear runtime making computation for very
    large n (several thousand or more) feasible.

    See Also
    --------
    scipy.integrate.quadrature
    scipy.integrate.fixed_quad
    numpy.polynomial.hermite.hermgauss
    roots_hermitenorm

    References
    ----------
    .. [townsend.trogdon.olver-2014]
       Townsend, A. and Trogdon, T. and Olver, S. (2014)
       *Fast computation of Gauss quadrature nodes and
       weights on the whole real line*. :arXiv:`1410.5286`.

    .. [townsend.trogdon.olver-2015]
       Townsend, A. and Trogdon, T. and Olver, S. (2015)
       *Fast computation of Gauss quadrature nodes and
       weights on the whole real line*.
       IMA Journal of Numerical Analysis
       :doi:`10.1093/imanum/drv002`.
    i   s   n must be a positive integer.i–   c         S` s   d |  S(   Ng        (    (   Rn   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRY   ¼  s    c         S` s   t  j |  d ƒ S(   Ng       @(   R]   R   (   Rn   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRY   ½  s    c         S` s   d |  t  j |  d | ƒ S(   Ng       @i   (   R’   RH   (   R‚   RV   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRY   ¿  s    N(
   R   R“   R]   R   R   R’   RH   RŽ   R   t   _roots_hermite_asy(
   R‚   Rp   R–   Rƒ   R„   R…   R†   R‡   t   nodesRS   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyR3   |  s    :				i   c         ` s§   |  d d } d t  |  d ƒ d | d t d t  |  d ƒ d | d ‰  ‡  f d †  } d „  } d t } x. t | ƒ D]  } | | | ƒ | | ƒ } q W| S(   s  Helper function for Tricomi initial guesses

    For details, see formula 3.1 in lemma 3.1 in the
    original paper.

    Parameters
    ----------
    n : int
        Quadrature order
    k : ndarray of type int
        Index of roots :math:`	au_k` to compute
    maxit : int
        Number of Newton maxit performed, the default
        value of 5 is sufficient.

    Returns
    -------
    tauk : ndarray
        Roots of equation 3.1

    See Also
    --------
    initial_nodes_a
    roots_hermite_asy
    i   g      à?g      @g       @g      @c         ` s   |  t  |  ƒ ˆ  S(   N(   R   (   RV   (   R‰   (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRY   å  s    c         S` s   d t  |  ƒ S(   Ng      ð?(   R	   (   RV   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRY   æ  s    (   R   R   R`   (   R‚   Rn   t   maxitR   R†   R‡   t   xit   i(    (   R‰   s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyt   _compute_taukÉ  s    B	
c         C` s   t  |  | ƒ } t d | ƒ d } |  d d } d t |  d ƒ d | d } | | d d | d d d | d d d | d } | S(	   se  Tricomi initial guesses

    Computes an initial approximation to the square of the `k`-th
    (positive) root :math:`x_k` of the Hermite polynomial :math:`H_n`
    of order :math:`n`. The formula is the one from lemma 3.1 in the
    original paper. The guesses are accurate except in the region
    near :math:`\sqrt{2n + 1}`.

    Parameters
    ----------
    n : int
        Quadrature order
    k : ndarray of type int
        Index of roots to compute

    Returns
    -------
    xksq : ndarray
        Square of the approximate roots

    See Also
    --------
    initial_nodes
    roots_hermite_asy
    g      à?i   g      @g       @g      ð?g      @g      @g      Ð?(   R¦   R	   R   (   R‚   Rn   t   taukt   sigkR   t   nut   xksq(    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyt   _initial_nodes_aí  s     :c         C` sõ   |  d d } d t  |  d ƒ d | d } t j | j ƒ  d ƒ d d d d … } | d d | | d d  d d! | d | d" d# d$ | d | d d% | d& | d d d' | d( d) | d d* | d d d+ | d, } | S(-   se  Gatteschi initial guesses

    Computes an initial approximation to the square of the `k`-th
    (positive) root :math:`x_k` of the Hermite polynomial :math:`H_n`
    of order :math:`n`. The formula is the one from lemma 3.2 in the
    original paper. The guesses are accurate in the region just
    below :math:`\sqrt{2n + 1}`.

    Parameters
    ----------
    n : int
        Quadrature order
    k : ndarray of type int
        Index of roots to compute

    Returns
    -------
    xksq : ndarray
        Square of the approximate root

    See Also
    --------
    initial_nodes
    roots_hermite_asy
    i   g      à?g      @g       @i   i    Niÿÿÿÿg      @g      ð?g      @g      ð¿g      "@g     €a@g      (@g     àe@i   g      0@g     œ˜@g      W@g     Ã¾@i   g      Àg     ˜Í@g   €¡!GAi   g      ‘@g    °›ý@g      ÀgUUUUUUå?gUUUUUUÕ?gš™™™™™É?gUUUUUUõ?gUUUUUUÕ¿gPuPu°?gE'«å±?gH³g®Î„?g`A÷îí‡?gUUUUUUå?g«ªªªªªú¿g^PTxt?gÅôJ±‘_‚?gUUUUUUÕ?g«ªªªªªÀ(   R   R   t   airyzoR€   (   R‚   Rn   R   R©   t   akRª   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyt   _initial_nodes_b  s     )o+c         C` sÈ   d |  d } t  | ƒ j t ƒ } t d t t |  d ƒ d ƒ ƒ } | d d d … } t |  | | d  ƒ } t |  | | d ƒ } t t | | g ƒ ƒ } |  d d k rÄ t d | g ƒ } n  | S(	   sÐ  Initial guesses for the Hermite roots

    Computes an initial approximation to the non-negative
    roots :math:`x_k` of the Hermite polynomial :math:`H_n`
    of order :math:`n`. The Tricomi and Gatteschi initial
    guesses are used in the region where they are accurate.

    Parameters
    ----------
    n : int
        Quadrature order

    Returns
    -------
    xk : ndarray
        Approximate roots

    See Also
    --------
    roots_hermite_asy
    g_—Dj˜iß?g•ê
Ï®ƒ@i   g      à?Niÿÿÿÿi   g        (	   R
   t   astypeR   R   R   R«   R®   R   R   (   R‚   t   fitt   turnovert   iat   ibt   xasqt   xbsqt   iv(    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyt   _initial_nodes8  s    #c   6      C` s

  t  | ƒ } t | ƒ } d |  d } d | d | | } d | d dQ } | | d d } d } d }	 d }
 d	 } d
 } d } d } d } d } d } d } d } | t d ƒ j dR ƒ } d } d | d d d … f d | d } d | d d d … f d | d d d … f d d } d | d d d … f d | d  d d … f d! | d" d d … f d# | d d d … f d$ | d% } d& | d' d d … f d( | d) d d … f d* | d+ d d … f d, | d d d … f d- | d d d … f d. d/ } d0 | d1 d d … f d2 | d3 d d … f d4 | d5 d d … f d6 | d d d … f d7 | d  d d … f d8 | d" d d … f d9 | d d d … f d: | d; } d } d | d d d … f d | d } d< | d d d … f d= | d d d … f d> d } d | d d d … f d | d  d d … f d? | d" d d … f d@ | d d d … f d$ | d% } dA | d' d d … f dB | d) d d … f dC | d+ d d … f dD | d d d … f dE | d d d … f dF d/ } d0 | d1 d d … f d2 | d3 d d … f dG | d5 d d … f dH | d d d … f dI | d  d d … f dJ | d" d d … f dK | d d d … f dL | d; }  t | dS | ƒ \ }! }" }# }$ d t t ƒ | dT | }% | t d+ dN d+ ƒ j dU ƒ }& | | }' | | |& dO d d … f | | |& d d d … f | | | d }( | | |& dO d d … f | | |& d d d … f | | |& d d d … f | | |& d d d … f | | | d+ }) |	 | |& dO d d … f | | | d }* | | |& dO d d … f |
 | |& d d d … f |	 | |& d d d … f | | | d" }+ | | |& dO d d … f | | |& d d d … f | | |& d d d … f |
 | |& d d d … f |	 | |& d d d … f | | | d) }, |% |! |' |( | d |) | dM |" |* |+ | d |, | dM | dV }- t d t ƒ | dW | }. | | |& dO d d … f | | | }/ | | |& dO d d … f | | |& d d d … f | | |& d d d … f | | | d }0 | | |& dO d d … f | | |& d d d … f | | |& d d d … f | | |& d d d … f | | |& d d d … f | |  | d  }1 | | }2 |
 | |& dO d d … f |	 | |& d d d … f | | | d }3 | | |& dO d d … f | | |& d d d … f |
 | |& d d d … f |	 | |& d d d … f | | | d+ }4 |. |! |/ |0 | d |1 | dM | dX |" |2 |3 | d |4 | dM }5 |- |5 f S(Y   sÇ  Asymptotic series expansion of parabolic cylinder function

    The implementation is based on sections 3.2 and 3.3 from the
    original paper. Compared to the published version this code
    adds one more term to the asymptotic series. The detailed
    formulas can be found at [parabolic-asymptotics]_. The evaluation
    is done in a transformed variable :math:`\theta := \arccos(t)`
    where :math:`t := x / \mu` and :math:`\mu := \sqrt{2n + 1}`.

    Parameters
    ----------
    n : int
        Quadrature order
    theta : ndarray
        Transformed position variable

    Returns
    -------
    U : ndarray
        Value of the parabolic cylinder function :math:`U(a, \theta)`.
    Ud : ndarray
        Value of the derivative :math:`U^{\prime}(a, \theta)` of
        the parabolic cylinder function.

    See Also
    --------
    roots_hermite_asy

    References
    ----------
    .. [parabolic-asymptotics]
       http://dlmf.nist.gov/12.10#vii
    g       @g      ð?g      à?g      @i   g      Ð?g«ªªªªªº?g9Žã8Žcµ?g±HxºiÀ?gdŠ§­Ò?g_ÙcJ6ì?g«ªªªªªÂ¿grÇqG¹¿gk~X¤XÂ¿g@ñ9SsMÔ¿g:¼(,a(î¿i   iÿÿÿÿi   i   Ng      @g      8@g      "Ài   g      o@g      b@g      ’@g     ”¯Ài	   g    @ÃÑ@i   g    ÀŸÛ@i   g    ØAg    Ð¦Ag     PAg    @Ãñ@i
   g    ìœAi   g    0ëAi   g   8JˆAg   H;Ag    ß\hAg     ü‚Ag   Àå¤“Ai   g   d—jÂAi   g  Àm6ºÝAi   g   âïëAg  P”/„ðAg  ìâf!Bg  …Ý±×;Bg  h¬d¬Bg    ÀêøAg      .@g     pt@g     àa@g    `Äá@g    ÈAg    ÀšýÀg    jÖ Ag    °ŒAg   H$i‹Ag   ¸¦ŸAiÇê¸ g  ÀÁÇ.ÞAg  €(òëAg   ÓìAg  È5¿e Bg  ãëd{>BI+ë   g      @i   i    g       @gUUUUUUå?(   iÿÿÿÿi   gUUUUUUå?gUUUUUUÅ?(   iÿÿÿÿi   gUUUUUUõ?gUUUUUUÕ?gUUUUUUå?(   R   R	   R   t   reshapeR   R   R   (6   R‚   t   thetat   stt   ctRp   t   etat   zetat   phit   a0t   a1t   a2t   a3t   a4t   a5t   b0t   b1t   b2t   b3t   b4t   b5t   ctpt   u0t   u1t   u2t   u3t   u4t   u5t   v0t   v1t   v2t   v3t   v4t   v5t   Ait   Aipt   Bit   Bipt   Pt   phipt   A0t   A1t   A2t   B0t   B1t   B2t   Ut   Pdt   C0t   C1t   C2t   D0t   D1t   D2t   Ud(    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyt   _pbcf_  sh    "&:n‚¶&:n‚¶ 
J‚/gŸ",+gŸ
J‚*$c         C` sò   t  d |  d ƒ } | | } t | ƒ } xq t | ƒ D]c } t |  | ƒ \ } } | t  d ƒ | t | ƒ | }	 | |	 } t t |	 ƒ ƒ d k  r7 Pq7 q7 W| t | ƒ }
 |  d d k rË d |
 d <n  t |
 d ƒ d | d } |
 | f S(   s+  Newton iteration for polishing the asymptotic approximation
    to the zeros of the Hermite polynomials.

    Parameters
    ----------
    n : int
        Quadrature order
    x_initial : ndarray
        Initial guesses for the roots
    maxit : int
        Maximal number of Newton iterations.
        The default 5 is sufficient, usually
        only one or two steps are needed.

    Returns
    -------
    nodes : ndarray
        Quadrature nodes
    weights : ndarray
        Quadrature weights

    See Also
    --------
    roots_hermite_asy
    g       @g      ð?g›+¡†›„=i   i   g        i    (	   R   R   R`   Rí   R   R€   Rf   R	   R   (   R‚   t	   x_initialR£   Rp   t   tR¹   R¥   t   ut   udt   dthetaRV   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyt   _newtonÍ  s    
"
c         C` sÖ   t  |  ƒ } t |  | ƒ \ } } |  d d k rs t | d d d … | g ƒ } t | d d d … | g ƒ } n? t | d d d … | g ƒ } t | d d d … | g ƒ } | t t ƒ t | ƒ 9} | | f S(   s-  Gauss-Hermite (physicst's) quadrature for large n.

    Computes the sample points and weights for Gauss-Hermite quadrature.
    The sample points are the roots of the n-th degree Hermite polynomial,
    :math:`H_n(x)`.  These sample points and weights correctly integrate
    polynomials of degree :math:`2n - 1` or less over the interval
    :math:`[-\infty, \infty]` with weight function :math:`f(x) = e^{-x^2}`.

    This method relies on asymptotic expansions which work best for n > 150.
    The algorithm has linear runtime making computation for very large n
    feasible.

    Parameters
    ----------
    n : int
        quadrature order

    Returns
    -------
    nodes : ndarray
        Quadrature nodes
    weights : ndarray
        Quadrature weights

    See Also
    --------
    roots_hermite

    References
    ----------
    .. [townsend.trogdon.olver-2014]
       Townsend, A. and Trogdon, T. and Olver, S. (2014)
       *Fast computation of Gauss quadrature nodes and
       weights on the whole real line*. :arXiv:`1410.5286`.

    .. [townsend.trogdon.olver-2015]
       Townsend, A. and Trogdon, T. and Olver, S. (2015)
       *Fast computation of Gauss quadrature nodes and
       weights on the whole real line*.
       IMA Journal of Numerical Analysis
       :doi:`10.1093/imanum/drv002`.
    i   i    Niÿÿÿÿ(   R·   Ró   R   R   R   R   (   R‚   R¶   R¢   RS   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyR¡   ü  s    + " c   
   
   ` sÛ   ˆ  d k  r t  d ƒ ‚ n  ˆ  d k r4 ˆ  d } n ˆ  } t | d t ƒ\ } } } d „  } ˆ  d k rz g  g  } } n  d ˆ  t ˆ  d ƒ t t ƒ } d ˆ  } t | | | | | t t f | ‡  f d †  ƒ }	 |	 S(   sH  Physicist's Hermite polynomial.

    Defined by

    .. math::

        H_n(x) = (-1)^ne^{x^2}\frac{d^n}{dx^n}e^{-x^2};

    :math:`H_n` is a polynomial of degree :math:`n`.

    Parameters
    ----------
    n : int
        Degree of the polynomial.
    monic : bool, optional
        If `True`, scale the leading coefficient to be 1. Default is
        `False`.

    Returns
    -------
    H : orthopoly1d
        Hermite polynomial.

    Notes
    -----
    The polynomials :math:`H_n` are orthogonal over :math:`(-\infty,
    \infty)` with weight function :math:`e^{-x^2}`.

    i    s   n must be nonnegative.i   Rp   c         S` s   t  |  |  ƒ S(   N(   R   (   RV   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRY   [  s    i   c         ` s   t  ˆ  |  ƒ S(   N(   RH   (   RV   (   R‚   (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRY   a  s    (   R“   R3   R   R˜   R   R   RQ   R   (
   R‚   Rl   Rž   RV   R   Rƒ   Rk   Rj   RX   Rt   (    (   R‚   s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyR   5  s    	"
c   
   
   C` së   t  |  ƒ } |  d k  s$ |  | k r3 t d ƒ ‚ n  t j d t j ƒ } |  d k r˜ d „  } d „  } t j } d „  } t | | | | | | t | ƒ St	 | ƒ \ } }	 | t d ƒ 9} |	 t d ƒ 9}	 | rÝ | |	 | f S| |	 f Sd	 S(
   sN  Gauss-Hermite (statistician's) quadrature.

    Computes the sample points and weights for Gauss-Hermite quadrature.
    The sample points are the roots of the n-th degree Hermite polynomial,
    :math:`He_n(x)`.  These sample points and weights correctly integrate
    polynomials of degree :math:`2n - 1` or less over the interval
    :math:`[-\infty, \infty]` with weight function :math:`f(x) = e^{-x^2/2}`.

    Parameters
    ----------
    n : int
        quadrature order
    mu : bool, optional
        If True, return the sum of the weights, optional.

    Returns
    -------
    x : ndarray
        Sample points
    w : ndarray
        Weights
    mu : float
        Sum of the weights

    Notes
    -----
    For small n up to 150 a modified version of the Golub-Welsch
    algorithm is used. Nodes are computed from the eigenvalue
    problem and improved by one step of a Newton iteration.
    The weights are computed from the well-known analytical formula.

    For n larger than 150 an optimal asymptotic algorithm is used
    which computes nodes and weights in a numerical stable manner.
    The algorithm has linear runtime making computation for very
    large n (several thousand or more) feasible.

    See Also
    --------
    scipy.integrate.quadrature
    scipy.integrate.fixed_quad
    numpy.polynomial.hermite_e.hermegauss
    i   s   n must be a positive integer.g       @i–   c         S` s   d |  S(   Ng        (    (   Rn   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRY   ˜  s    c         S` s   t  j |  ƒ S(   N(   R]   R   (   Rn   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRY   ™  s    c         S` s   |  t  j |  d | ƒ S(   Ni   (   R’   RI   (   R‚   RV   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRY   ›  s    i   N(
   R   R“   R]   R   R   R’   RI   RŽ   R   R¡   (
   R‚   Rp   R–   Rƒ   R„   R…   R†   R‡   R¢   RS   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyR5   g  s     +				c   
      ` sß   ˆ  d k  r t  d ƒ ‚ n  ˆ  d k r4 ˆ  d } n ˆ  } t | d t ƒ\ } } } d „  } ˆ  d k rz g  g  } } n  t d t ƒ t ˆ  d ƒ } d } t | | | | d | d	 t t f d
 | d ‡  f d †  ƒ}	 |	 S(   sb  Normalized (probabilist's) Hermite polynomial.

    Defined by

    .. math::

        He_n(x) = (-1)^ne^{x^2/2}\frac{d^n}{dx^n}e^{-x^2/2};

    :math:`He_n` is a polynomial of degree :math:`n`.

    Parameters
    ----------
    n : int
        Degree of the polynomial.
    monic : bool, optional
        If `True`, scale the leading coefficient to be 1. Default is
        `False`.

    Returns
    -------
    He : orthopoly1d
        Hermite polynomial.

    Notes
    -----

    The polynomials :math:`He_n` are orthogonal over :math:`(-\infty,
    \infty)` with weight function :math:`e^{-x^2/2}`.

    i    s   n must be nonnegative.i   Rp   c         S` s   t  |  |  d ƒ S(   Ng       @(   R   (   RV   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRY   Ï  s    i   g      ð?Rk   RU   Rl   Rm   c         ` s   t  ˆ  |  ƒ S(   N(   RI   (   RV   (   R‚   (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRY   Õ  s    (   R“   R5   R   R   R   R˜   RQ   R   (
   R‚   Rl   Rž   RV   R   Rƒ   Rk   Rj   RX   Rt   (    (   R‚   s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyR   ¨  s    	+c   	   
   ` sð   t  |  ƒ } |  d k  s$ |  | k r3 t d ƒ ‚ n  ˆ  d k  rN t d ƒ ‚ n ˆ  d k rg t |  | ƒ St j t j ƒ t j ˆ  d ƒ t j ˆ  d ƒ } d „  } ‡  f d †  } ‡  f d	 †  } ‡  f d
 †  } t | | | | | | t	 | ƒ S(   sN  Gauss-Gegenbauer quadrature.

    Computes the sample points and weights for Gauss-Gegenbauer quadrature.
    The sample points are the roots of the n-th degree Gegenbauer polynomial,
    :math:`C^{\alpha}_n(x)`.  These sample points and weights correctly
    integrate polynomials of degree :math:`2n - 1` or less over the interval
    :math:`[-1, 1]` with weight function
    :math:`f(x) = (1 - x^2)^{\alpha - 1/2}`.

    Parameters
    ----------
    n : int
        quadrature order
    alpha : float
        alpha must be > -0.5
    mu : bool, optional
        If True, return the sum of the weights, optional.

    Returns
    -------
    x : ndarray
        Sample points
    w : ndarray
        Weights
    mu : float
        Sum of the weights

    See Also
    --------
    scipy.integrate.quadrature
    scipy.integrate.fixed_quad
    i   s   n must be a positive integer.g      à¿s    alpha must be greater than -0.5.g        g      à?c         S` s   d |  S(   Ng        (    (   Rn   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRY     s    c         ` s5   t  j |  |  d ˆ  d d |  ˆ  |  ˆ  d ƒ S(   Ni   i   i   (   R]   R   (   Rn   (   R•   (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRY     s   c         ` s   t  j |  ˆ  | ƒ S(   N(   R’   RJ   (   R‚   RV   (   R•   (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRY     s    c         ` sO   |  | t  j |  ˆ  | ƒ |  d ˆ  d t  j |  d ˆ  | ƒ d | d S(   Ni   i   (   R’   RJ   (   R‚   RV   (   R•   (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRY     s   (
   R   R“   R%   R]   R   R   R’   R    RŽ   R   (	   R‚   R•   Rp   R–   Rƒ   R„   R…   R†   R‡   (    (   R•   s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyR7   Ý  s    !4	c         ` s–   t  ˆ ˆ  d ˆ  d d | ƒ} | r* | St d ˆ  ˆ ƒ t ˆ  d ƒ t d ˆ  ƒ t ˆ  d ˆ ƒ } | j | ƒ ‡  ‡ f d †  | j d <| S(   sÿ  Gegenbauer (ultraspherical) polynomial.

    Defined to be the solution of

    .. math::
        (1 - x^2)\frac{d^2}{dx^2}C_n^{(\alpha)}
          - (2\alpha + 1)x\frac{d}{dx}C_n^{(\alpha)}
          + n(n + 2\alpha)C_n^{(\alpha)} = 0

    for :math:`\alpha > -1/2`; :math:`C_n^{(\alpha)}` is a polynomial
    of degree :math:`n`.

    Parameters
    ----------
    n : int
        Degree of the polynomial.
    monic : bool, optional
        If `True`, scale the leading coefficient to be 1. Default is
        `False`.

    Returns
    -------
    C : orthopoly1d
        Gegenbauer polynomial.

    Notes
    -----
    The polynomials :math:`C_n^{(\alpha)}` are orthogonal over
    :math:`[-1,1]` with weight function :math:`(1 - x^2)^{(\alpha -
    1/2)}`.

    g      à?Rl   i   c         ` s   t  t ˆ ƒ ˆ  |  ƒ S(   N(   RJ   Rg   (   RV   (   R•   R‚   (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRY   <  s    R\   (   R   R˜   Ru   Re   (   R‚   R•   Rl   t   baset   factor(    (   R•   R‚   s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyR     s    ! Bc         C` s¦   t  |  ƒ } |  d k  s$ |  | k r3 t d ƒ ‚ n  t j t j d | d d d ƒ t d | ƒ } t j | ƒ } | j t | ƒ | r˜ | | t f S| | f Sd S(   sO  Gauss-Chebyshev (first kind) quadrature.

    Computes the sample points and weights for Gauss-Chebyshev quadrature.
    The sample points are the roots of the n-th degree Chebyshev polynomial of
    the first kind, :math:`T_n(x)`.  These sample points and weights correctly
    integrate polynomials of degree :math:`2n - 1` or less over the interval
    :math:`[-1, 1]` with weight function :math:`f(x) = 1/\sqrt{1 - x^2}`.

    Parameters
    ----------
    n : int
        quadrature order
    mu : bool, optional
        If True, return the sum of the weights, optional.

    Returns
    -------
    x : ndarray
        Sample points
    w : ndarray
        Weights
    mu : float
        Sum of the weights

    See Also
    --------
    scipy.integrate.quadrature
    scipy.integrate.fixed_quad
    numpy.polynomial.chebyshev.chebgauss
    i   s   n must be a positive integer.i   i    iþÿÿÿN(   R   R“   R]   R	   R   R   t
   empty_liket   fill(   R‚   Rp   R–   RV   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyR%   D  s    2c   
   
   ` s¿   ˆ  d k  r t  d ƒ ‚ n  d „  } ˆ  d k rX t g  g  t d | d | ‡  f d †  ƒ Sˆ  } t | d t ƒ\ } } } t d	 } d	 ˆ  d } t | | | | | d | ‡  f d
 †  ƒ }	 |	 S(   sÓ  Chebyshev polynomial of the first kind.

    Defined to be the solution of

    .. math::
        (1 - x^2)\frac{d^2}{dx^2}T_n - x\frac{d}{dx}T_n + n^2T_n = 0;

    :math:`T_n` is a polynomial of degree :math:`n`.

    Parameters
    ----------
    n : int
        Degree of the polynomial.
    monic : bool, optional
        If `True`, scale the leading coefficient to be 1. Default is
        `False`.

    Returns
    -------
    T : orthopoly1d
        Chebyshev polynomial of the first kind.

    Notes
    -----
    The polynomials :math:`T_n` are orthogonal over :math:`[-1, 1]`
    with weight function :math:`(1 - x^2)^{-1/2}`.

    See Also
    --------
    chebyu : Chebyshev polynomial of the second kind.

    i    s   n must be nonnegative.c         S` s   d t  d |  |  ƒ S(   Ng      ð?i   (   R   (   RV   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRY   “  s    g      ð?iÿÿÿÿi   c         ` s   t  ˆ  |  ƒ S(   N(   RA   (   RV   (   R‚   (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRY   –  s    Rp   i   c         ` s   t  ˆ  |  ƒ S(   N(   RA   (   RV   (   R‚   (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRY   œ  s    (   iÿÿÿÿi   (   iÿÿÿÿi   (   R“   RQ   R   R%   R   (
   R‚   Rl   Rk   Rž   RV   R   Rp   Rj   RX   Rt   (    (   R‚   s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyR   o  s    !	
c         C` s§   t  |  ƒ } |  d k  s$ |  | k r3 t d ƒ ‚ n  t j | d d ƒ t | d } t j | ƒ } t t j | ƒ d | d } | r™ | | t d f S| | f Sd S(   s&  Gauss-Chebyshev (second kind) quadrature.

    Computes the sample points and weights for Gauss-Chebyshev quadrature.
    The sample points are the roots of the n-th degree Chebyshev polynomial of
    the second kind, :math:`U_n(x)`.  These sample points and weights correctly
    integrate polynomials of degree :math:`2n - 1` or less over the interval
    :math:`[-1, 1]` with weight function :math:`f(x) = \sqrt{1 - x^2}`.

    Parameters
    ----------
    n : int
        quadrature order
    mu : bool, optional
        If True, return the sum of the weights, optional.

    Returns
    -------
    x : ndarray
        Sample points
    w : ndarray
        Weights
    mu : float
        Sum of the weights

    See Also
    --------
    scipy.integrate.quadrature
    scipy.integrate.fixed_quad
    i   s   n must be a positive integer.i    iÿÿÿÿi   N(   R   R“   R]   R   R   R	   R   (   R‚   Rp   R–   Rï   RV   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyR'   £  s    !c         C` s_   t  |  d d d | ƒ} | r" | St t ƒ d t |  d ƒ t |  d ƒ } | j | ƒ | S(   sã  Chebyshev polynomial of the second kind.

    Defined to be the solution of

    .. math::
        (1 - x^2)\frac{d^2}{dx^2}U_n - 3x\frac{d}{dx}U_n
          + n(n + 2)U_n = 0;

    :math:`U_n` is a polynomial of degree :math:`n`.

    Parameters
    ----------
    n : int
        Degree of the polynomial.
    monic : bool, optional
        If `True`, scale the leading coefficient to be 1. Default is
        `False`.

    Returns
    -------
    U : orthopoly1d
        Chebyshev polynomial of the second kind.

    Notes
    -----
    The polynomials :math:`U_n` are orthogonal over :math:`[-1, 1]`
    with weight function :math:`(1 - x^2)^{1/2}`.

    See Also
    --------
    chebyt : Chebyshev polynomial of the first kind.

    g      à?Rl   g       @i   g      ø?(   R   R   R   R˜   Ru   (   R‚   Rl   Rô   Rõ   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyR   Í  s    ",c         C` sW   t  |  t ƒ \ } } } | d 9} | d 9} | d 9} | rI | | | f S| | f Sd S(   s*  Gauss-Chebyshev (first kind) quadrature.

    Computes the sample points and weights for Gauss-Chebyshev quadrature.
    The sample points are the roots of the n-th degree Chebyshev polynomial of
    the first kind, :math:`C_n(x)`.  These sample points and weights correctly
    integrate polynomials of degree :math:`2n - 1` or less over the interval
    :math:`[-2, 2]` with weight function :math:`f(x) = 1/\sqrt{1 - (x/2)^2}`.

    Parameters
    ----------
    n : int
        quadrature order
    mu : bool, optional
        If True, return the sum of the weights, optional.

    Returns
    -------
    x : ndarray
        Sample points
    w : ndarray
        Weights
    mu : float
        Sum of the weights

    See Also
    --------
    scipy.integrate.quadrature
    scipy.integrate.fixed_quad
    i   N(   R%   R   (   R‚   Rp   RV   R   R–   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyR)   ù  s    


c   	      ` só   ˆ  d k  r t  d ƒ ‚ n  ˆ  d k r4 ˆ  d } n ˆ  } t | d t ƒ\ } } } ˆ  d k rq g  g  } } n  d t ˆ  d k d } d } t | | | | d d „  d	 d d | ƒ} | sï | j d | d ƒ ƒ ‡  f d †  | j d <n  | S(   sg  Chebyshev polynomial of the first kind on :math:`[-2, 2]`.

    Defined as :math:`C_n(x) = 2T_n(x/2)`, where :math:`T_n` is the
    nth Chebychev polynomial of the first kind.

    Parameters
    ----------
    n : int
        Degree of the polynomial.
    monic : bool, optional
        If `True`, scale the leading coefficient to be 1. Default is
        `False`.

    Returns
    -------
    C : orthopoly1d
        Chebyshev polynomial of the first kind on :math:`[-2, 2]`.

    Notes
    -----
    The polynomials :math:`C_n(x)` are orthogonal over :math:`[-2, 2]`
    with weight function :math:`1/\sqrt{1 - (x/2)^2}`.

    See Also
    --------
    chebyt : Chebyshev polynomial of the first kind.

    References
    ----------
    .. [1] Abramowitz and Stegun, "Handbook of Mathematical Functions"
           Section 22. National Bureau of Standards, 1972.

    i    s   n must be nonnegative.i   Rp   i   g      ð?Rk   c         S` s   d t  d |  |  d ƒ S(   Ng      ð?i   g      @(   R   (   RV   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRY   P  s    RU   iþÿÿÿi   Rl   g       @c         ` s   t  ˆ  |  ƒ S(   N(   RC   (   RV   (   R‚   (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRY   T  s    R\   (   iþÿÿÿi   (   R“   R)   R   R   RQ   Ru   Re   (	   R‚   Rl   Rž   RV   R   Rƒ   Rj   RX   Rt   (    (   R‚   s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyR   !  s"    "	c         C` sW   t  |  t ƒ \ } } } | d 9} | d 9} | d 9} | rI | | | f S| | f Sd S(   s*  Gauss-Chebyshev (second kind) quadrature.

    Computes the sample points and weights for Gauss-Chebyshev quadrature.
    The sample points are the roots of the n-th degree Chebyshev polynomial of
    the second kind, :math:`S_n(x)`.  These sample points and weights correctly
    integrate polynomials of degree :math:`2n - 1` or less over the interval
    :math:`[-2, 2]` with weight function :math:`f(x) = \sqrt{1 - (x/2)^2}`.

    Parameters
    ----------
    n : int
        quadrature order
    mu : bool, optional
        If True, return the sum of the weights, optional.

    Returns
    -------
    x : ndarray
        Sample points
    w : ndarray
        Weights
    mu : float
        Sum of the weights

    See Also
    --------
    scipy.integrate.quadrature
    scipy.integrate.fixed_quad
    i   N(   R'   R   (   R‚   Rp   RV   R   R–   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyR+   Z  s    


c   
      ` së   ˆ  d k  r t  d ƒ ‚ n  ˆ  d k r4 ˆ  d } n ˆ  } t | d t ƒ\ } } } ˆ  d k rq g  g  } } n  t } d } t | | | | d d „  d d d | ƒ} | sç ˆ  d | d
 ƒ }	 | j |	 ƒ ‡  f d †  | j d <n  | S(   sf  Chebyshev polynomial of the second kind on :math:`[-2, 2]`.

    Defined as :math:`S_n(x) = U_n(x/2)` where :math:`U_n` is the
    nth Chebychev polynomial of the second kind.

    Parameters
    ----------
    n : int
        Degree of the polynomial.
    monic : bool, optional
        If `True`, scale the leading coefficient to be 1. Default is
        `False`.

    Returns
    -------
    S : orthopoly1d
        Chebyshev polynomial of the second kind on :math:`[-2, 2]`.

    Notes
    -----
    The polynomials :math:`S_n(x)` are orthogonal over :math:`[-2, 2]`
    with weight function :math:`\sqrt{1 - (x/2)}^2`.

    See Also
    --------
    chebyu : Chebyshev polynomial of the second kind

    References
    ----------
    .. [1] Abramowitz and Stegun, "Handbook of Mathematical Functions"
           Section 22. National Bureau of Standards, 1972.

    i    s   n must be nonnegative.i   Rp   g      ð?Rk   c         S` s   t  d |  |  d ƒ S(   Ni   g      @(   R   (   RV   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRY   ±  s    RU   iþÿÿÿi   Rl   c         ` s   t  ˆ  |  ƒ S(   N(   RD   (   RV   (   R‚   (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRY   ¶  s    R\   (   iþÿÿÿi   (   R“   R+   R   R   RQ   Ru   Re   (
   R‚   Rl   Rž   RV   R   Rƒ   Rj   RX   Rt   Rõ   (    (   R‚   s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyR   ‚  s$    "	c         C` s*   t  |  | ƒ } | d d d f | d S(   s:  Gauss-Chebyshev (first kind, shifted) quadrature.

    Computes the sample points and weights for Gauss-Chebyshev quadrature.
    The sample points are the roots of the n-th degree shifted Chebyshev
    polynomial of the first kind, :math:`T_n(x)`.  These sample points and
    weights correctly integrate polynomials of degree :math:`2n - 1` or less
    over the interval :math:`[0, 1]` with weight function
    :math:`f(x) = 1/\sqrt{x - x^2}`.

    Parameters
    ----------
    n : int
        quadrature order
    mu : bool, optional
        If True, return the sum of the weights, optional.

    Returns
    -------
    x : ndarray
        Sample points
    w : ndarray
        Weights
    mu : float
        Sum of the weights

    See Also
    --------
    scipy.integrate.quadrature
    scipy.integrate.fixed_quad
    i    i   i   (   R%   (   R‚   Rp   t   xw(    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyR;   ¼  s    c         C` sV   t  |  d d d | ƒ} | r" | S|  d k r? d |  d } n d } | j | ƒ | S(   sX  Shifted Chebyshev polynomial of the first kind.

    Defined as :math:`T^*_n(x) = T_n(2x - 1)` for :math:`T_n` the nth
    Chebyshev polynomial of the first kind.

    Parameters
    ----------
    n : int
        Degree of the polynomial.
    monic : bool, optional
        If `True`, scale the leading coefficient to be 1. Default is
        `False`.

    Returns
    -------
    T : orthopoly1d
        Shifted Chebyshev polynomial of the first kind.

    Notes
    -----
    The polynomials :math:`T^*_n` are orthogonal over :math:`[0, 1]`
    with weight function :math:`(x - x^2)^{-1/2}`.

    g        g      à?Rl   i    i   g       @g      ð?(   R!   Ru   (   R‚   Rl   Rô   Rõ   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyR   ß  s    c         C` sg   t  |  t ƒ \ } } } | d d } t j d d ƒ } | | | 9} | rY | | | f S| | f Sd S(   s:  Gauss-Chebyshev (second kind, shifted) quadrature.

    Computes the sample points and weights for Gauss-Chebyshev quadrature.
    The sample points are the roots of the n-th degree shifted Chebyshev
    polynomial of the second kind, :math:`U_n(x)`.  These sample points and
    weights correctly integrate polynomials of degree :math:`2n - 1` or less
    over the interval :math:`[0, 1]` with weight function
    :math:`f(x) = \sqrt{x - x^2}`.

    Parameters
    ----------
    n : int
        quadrature order
    mu : bool, optional
        If True, return the sum of the weights, optional.

    Returns
    -------
    x : ndarray
        Sample points
    w : ndarray
        Weights
    mu : float
        Sum of the weights

    See Also
    --------
    scipy.integrate.quadrature
    scipy.integrate.fixed_quad
    i   i   g      ø?N(   R'   R   R’   R”   (   R‚   Rp   RV   R   R–   t   m_us(    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyR=     s    c         C` s=   t  |  d d d | ƒ} | r" | Sd |  } | j | ƒ | S(   sZ  Shifted Chebyshev polynomial of the second kind.

    Defined as :math:`U^*_n(x) = U_n(2x - 1)` for :math:`U_n` the nth
    Chebyshev polynomial of the second kind.

    Parameters
    ----------
    n : int
        Degree of the polynomial.
    monic : bool, optional
        If `True`, scale the leading coefficient to be 1. Default is
        `False`.

    Returns
    -------
    U : orthopoly1d
        Shifted Chebyshev polynomial of the second kind.

    Notes
    -----
    The polynomials :math:`U^*_n` are orthogonal over :math:`[0, 1]`
    with weight function :math:`(x - x^2)^{1/2}`.

    g       @g      ø?Rl   i   (   R!   Ru   (   R‚   Rl   Rô   Rõ   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyR    -  s    
c      
   C` s|   t  |  ƒ } |  d k  s$ |  | k r3 t d ƒ ‚ n  d } d „  } d „  } t j } d „  } t | | | | | | t | ƒ S(   s  Gauss-Legendre quadrature.

    Computes the sample points and weights for Gauss-Legendre quadrature.
    The sample points are the roots of the n-th degree Legendre polynomial
    :math:`P_n(x)`.  These sample points and weights correctly integrate
    polynomials of degree :math:`2n - 1` or less over the interval
    :math:`[-1, 1]` with weight function :math:`f(x) = 1.0`.

    Parameters
    ----------
    n : int
        quadrature order
    mu : bool, optional
        If True, return the sum of the weights, optional.

    Returns
    -------
    x : ndarray
        Sample points
    w : ndarray
        Weights
    mu : float
        Sum of the weights

    See Also
    --------
    scipy.integrate.quadrature
    scipy.integrate.fixed_quad
    numpy.polynomial.legendre.leggauss
    i   s   n must be a positive integer.g       @c         S` s   d |  S(   Ng        (    (   Rn   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRY   t  s    c         S` s!   |  t  j d d |  |  d ƒ S(   Ng      ð?i   i   (   R]   R   (   Rn   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRY   u  s    c         S` s=   |  | t  j |  | ƒ |  t  j |  d | ƒ d | d S(   Ni   i   (   R’   R@   (   R‚   RV   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRY   w  s   (   R   R“   R’   R@   RŽ   R   (   R‚   Rp   R–   Rƒ   R„   R…   R†   R‡   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyR#   P  s    				c   	      ` sî   ˆ  d k  r t  d ƒ ‚ n  ˆ  d k r4 ˆ  d } n ˆ  } t | d t ƒ\ } } } ˆ  d k rq g  g  } } n  d d ˆ  d } t d ˆ  d ƒ t ˆ  d ƒ d d ˆ  } t | | | | d d „  d	 d d | d ‡  f d †  ƒ} | S(   s*  Legendre polynomial.

    Defined to be the solution of

    .. math::
        \frac{d}{dx}\left[(1 - x^2)\frac{d}{dx}P_n(x)\right]
          + n(n + 1)P_n(x) = 0;

    :math:`P_n(x)` is a polynomial of degree :math:`n`.

    Parameters
    ----------
    n : int
        Degree of the polynomial.
    monic : bool, optional
        If `True`, scale the leading coefficient to be 1. Default is
        `False`.

    Returns
    -------
    P : orthopoly1d
        Legendre polynomial.

    Notes
    -----
    The polynomials :math:`P_n` are orthogonal over :math:`[-1, 1]`
    with weight function 1.

    Examples
    --------
    Generate the 3rd-order Legendre polynomial 1/2*(5x^3 + 0x^2 - 3x + 0):

    >>> from scipy.special import legendre
    >>> legendre(3)
    poly1d([ 2.5,  0. , -1.5,  0. ])

    i    s   n must be nonnegative.i   Rp   g       @i   Rk   c         S` s   d S(   Ng      ð?(    (   RV   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRY   ®  s    RU   iÿÿÿÿRl   Rm   c         ` s   t  ˆ  |  ƒ S(   N(   R@   (   RV   (   R‚   (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRY   ¯  s    (   iÿÿÿÿi   (   R“   R#   R   R˜   RQ   (	   R‚   Rl   Rž   RV   R   Rƒ   Rj   RX   Rt   (    (   R‚   s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyR   |  s    &.!c         C` sK   t  |  ƒ \ } } | d d } | d } | r= | | d f S| | f Sd S(   s	  Gauss-Legendre (shifted) quadrature.

    Computes the sample points and weights for Gauss-Legendre quadrature.
    The sample points are the roots of the n-th degree shifted Legendre
    polynomial :math:`P^*_n(x)`.  These sample points and weights correctly
    integrate polynomials of degree :math:`2n - 1` or less over the interval
    :math:`[0, 1]` with weight function :math:`f(x) = 1.0`.

    Parameters
    ----------
    n : int
        quadrature order
    mu : bool, optional
        If True, return the sum of the weights, optional.

    Returns
    -------
    x : ndarray
        Sample points
    w : ndarray
        Weights
    mu : float
        Sum of the weights

    See Also
    --------
    scipy.integrate.quadrature
    scipy.integrate.fixed_quad
    i   i   g      ð?N(   R#   (   R‚   Rp   RV   R   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyR9   µ  s    
c   	      ` sâ   ˆ  d k  r t  d ƒ ‚ n  d „  } ˆ  d k rX t g  g  d d | d | ‡  f d †  ƒ St ˆ  d t ƒ\ } } } d d ˆ  d } t d ˆ  d ƒ t ˆ  d ƒ d } t | | | | | d	 d d
 | d ‡  f d †  ƒ} | S(   s  Shifted Legendre polynomial.

    Defined as :math:`P^*_n(x) = P_n(2x - 1)` for :math:`P_n` the nth
    Legendre polynomial.

    Parameters
    ----------
    n : int
        Degree of the polynomial.
    monic : bool, optional
        If `True`, scale the leading coefficient to be 1. Default is
        `False`.

    Returns
    -------
    P : orthopoly1d
        Shifted Legendre polynomial.

    Notes
    -----
    The polynomials :math:`P^*_n` are orthogonal over :math:`[0, 1]`
    with weight function 1.

    i    s   n must be nonnegative.c         S` s   d |  d S(   Ng        g      ð?(    (   RV   (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRY   ÷  s    g      ð?i   c         ` s   t  ˆ  |  ƒ S(   N(   RK   (   RV   (   R‚   (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRY   ú  s    Rp   i   RU   Rl   Rm   c         ` s   t  ˆ  |  ƒ S(   N(   RK   (   RV   (   R‚   (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyRY   ÿ  s    (   i    i   (   i    i   (   R“   RQ   R9   R   R˜   (	   R‚   Rl   Rk   RV   R   Rƒ   Rj   RX   Rt   (    (   R‚   s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyR   Û  s    	&!(   RP   RE   RN   RJ   RA   RB   RD   RC   RL   RM   R@   RK   RG   RF   RH   RI   (c   t   __doc__t
   __future__R    R   R   t   numpyR]   R   R   R   R   R   R   R	   R
   R   R   R   R   t   scipyR   t   scipy.specialR   t    R   R’   R    R˜   R   t	   _polyfunst   _rootfuns_mapt	   _evalfunsRc   t   keyst   __all__R^   RQ   RŽ   Ry   R-   R   R?   R!   R1   R   R/   R   R3   R¦   R«   R®   R·   Rí   Ró   R¡   R   R5   R   R7   R   R%   R   R'   R   R)   R   R+   R   R;   R   R=   R    R#   R   R9   R   RO   RP   RE   RN   RJ   RA   RB   RD   RC   RL   RM   R@   RK   RG   RF   RH   RI   t   globalst	   _modattrst   itemst   newfunt   oldfunt   append(    (    (    s7   /tmp/pip-build-7oUkmx/scipy/scipy/special/orthogonal.pyt   <module>H   sž   R	

					$(	-@:/89@"0M$	#	(	'	n/	92A570+4*,(9(:#%)#,9&.	j	