# `special.basic`¶

## Module Contents¶

### Functions¶

 `_nonneg_int_or_fail`(n,var_name,strict=True) `diric`(x,n) Periodic sinc function, also called the Dirichlet function. `jnjnp_zeros`(nt) Compute zeros of integer-order Bessel functions Jn and Jn’. `jnyn_zeros`(n,nt) Compute nt zeros of Bessel functions Jn(x), Jn’(x), Yn(x), and Yn’(x). `jn_zeros`(n,nt) Compute zeros of integer-order Bessel function Jn(x). `jnp_zeros`(n,nt) Compute zeros of integer-order Bessel function derivative Jn’(x). `yn_zeros`(n,nt) Compute zeros of integer-order Bessel function Yn(x). `ynp_zeros`(n,nt) Compute zeros of integer-order Bessel function derivative Yn’(x). `y0_zeros`(nt,complex=False) Compute nt zeros of Bessel function Y0(z), and derivative at each zero. `y1_zeros`(nt,complex=False) Compute nt zeros of Bessel function Y1(z), and derivative at each zero. `y1p_zeros`(nt,complex=False) Compute nt zeros of Bessel derivative Y1’(z), and value at each zero. `_bessel_diff_formula`(v,z,n,L,phase) `jvp`(v,z,n=1) Compute nth derivative of Bessel function Jv(z) with respect to z. `yvp`(v,z,n=1) Compute nth derivative of Bessel function Yv(z) with respect to z. `kvp`(v,z,n=1) Compute nth derivative of real-order modified Bessel function Kv(z) `ivp`(v,z,n=1) Compute nth derivative of modified Bessel function Iv(z) with respect `h1vp`(v,z,n=1) Compute nth derivative of Hankel function H1v(z) with respect to z. `h2vp`(v,z,n=1) Compute nth derivative of Hankel function H2v(z) with respect to z. `riccati_jn`(n,x) rCompute Ricatti-Bessel function of the first kind and its derivative. `riccati_yn`(n,x) Compute Ricatti-Bessel function of the second kind and its derivative. `erfinv`(y) Inverse function for erf. `erfcinv`(y) Inverse function for erfc. `erf_zeros`(nt) Compute nt complex zeros of error function erf(z). `fresnelc_zeros`(nt) Compute nt complex zeros of cosine Fresnel integral C(z). `fresnels_zeros`(nt) Compute nt complex zeros of sine Fresnel integral S(z). `fresnel_zeros`(nt) Compute nt complex zeros of sine and cosine Fresnel integrals S(z) and C(z). `assoc_laguerre`(x,n,k=0.0) Compute the generalized (associated) Laguerre polynomial of degree n and order k. `polygamma`(n,x) Polygamma function n. `mathieu_even_coef`(m,q) rFourier coefficients for even Mathieu and modified Mathieu functions. `mathieu_odd_coef`(m,q) rFourier coefficients for even Mathieu and modified Mathieu functions. `lpmn`(m,n,z) Sequence of associated Legendre functions of the first kind. `clpmn`(m,n,z,type=3) Associated Legendre function of the first kind for complex arguments. `lqmn`(m,n,z) Sequence of associated Legendre functions of the second kind. `bernoulli`(n) Bernoulli numbers B0..Bn (inclusive). `euler`(n) Euler numbers E0..En (inclusive). `lpn`(n,z) Legendre function of the first kind. `lqn`(n,z) Legendre function of the second kind. `ai_zeros`(nt) Compute nt zeros and values of the Airy function Ai and its derivative. `bi_zeros`(nt) Compute nt zeros and values of the Airy function Bi and its derivative. `lmbda`(v,x) rJahnke-Emden Lambda function, Lambdav(x). `pbdv_seq`(v,x) Parabolic cylinder functions Dv(x) and derivatives. `pbvv_seq`(v,x) Parabolic cylinder functions Vv(x) and derivatives. `pbdn_seq`(n,z) Parabolic cylinder functions Dn(z) and derivatives. `ber_zeros`(nt) Compute nt zeros of the Kelvin function ber(x). `bei_zeros`(nt) Compute nt zeros of the Kelvin function bei(x). `ker_zeros`(nt) Compute nt zeros of the Kelvin function ker(x). `kei_zeros`(nt) Compute nt zeros of the Kelvin function kei(x). `berp_zeros`(nt) Compute nt zeros of the Kelvin function ber’(x). `beip_zeros`(nt) Compute nt zeros of the Kelvin function bei’(x). `kerp_zeros`(nt) Compute nt zeros of the Kelvin function ker’(x). `keip_zeros`(nt) Compute nt zeros of the Kelvin function kei’(x). `kelvin_zeros`(nt) Compute nt zeros of all Kelvin functions. `pro_cv_seq`(m,n,c) Characteristic values for prolate spheroidal wave functions. `obl_cv_seq`(m,n,c) Characteristic values for oblate spheroidal wave functions. `ellipk`(m) rComplete elliptic integral of the first kind. `comb`(N,k,exact=False,repetition=False) The number of combinations of N things taken k at a time. `perm`(N,k,exact=False) Permutations of N things taken k at a time, i.e., k-permutations of N. `_range_prod`(lo,hi) Product of a range of numbers. `factorial`(n,exact=False) The factorial of a number or array of numbers. `factorial2`(n,exact=False) Double factorial. `factorialk`(n,k,exact=True) Multifactorial of n of order k, n(!!…!). `zeta`(x,q=None,out=None) r
`_nonneg_int_or_fail`(n, var_name, strict=True)
`diric`(x, n)

Periodic sinc function, also called the Dirichlet function.

The Dirichlet function is defined as:

```diric(x) = sin(x * n/2) / (n * sin(x / 2)),
```

where n is a positive integer.

x : array_like
Input data
n : int
Integer defining the periodicity.

diric : ndarray

```>>> from scipy import special
>>> import matplotlib.pyplot as plt
```
```>>> x = np.linspace(-8*np.pi, 8*np.pi, num=201)
>>> plt.figure(figsize=(8, 8));
>>> for idx, n in enumerate([2, 3, 4, 9]):
...     plt.subplot(2, 2, idx+1)
...     plt.plot(x, special.diric(x, n))
...     plt.title('diric, n={}'.format(n))
>>> plt.show()
```

The following example demonstrates that diric gives the magnitudes (modulo the sign and scaling) of the Fourier coefficients of a rectangular pulse.

Suppress output of values that are effectively 0:

```>>> np.set_printoptions(suppress=True)
```

Create a signal x of length m with k ones:

```>>> m = 8
>>> k = 3
>>> x = np.zeros(m)
>>> x[:k] = 1
```

Use the FFT to compute the Fourier transform of x, and inspect the magnitudes of the coefficients:

```>>> np.abs(np.fft.fft(x))
array([ 3.        ,  2.41421356,  1.        ,  0.41421356,  1.        ,
0.41421356,  1.        ,  2.41421356])
```

Now find the same values (up to sign) using diric. We multiply by k to account for the different scaling conventions of numpy.fft.fft and diric:

```>>> theta = np.linspace(0, 2*np.pi, m, endpoint=False)
>>> k * special.diric(theta, k)
array([ 3.        ,  2.41421356,  1.        , -0.41421356, -1.        ,
-0.41421356,  1.        ,  2.41421356])
```
`jnjnp_zeros`(nt)

Compute zeros of integer-order Bessel functions Jn and Jn’.

Results are arranged in order of the magnitudes of the zeros.

nt : int
Number (<=1200) of zeros to compute
zo[l-1] : ndarray
Value of the lth zero of Jn(x) and Jn’(x). Of length nt.
n[l-1] : ndarray
Order of the Jn(x) or Jn’(x) associated with lth zero. Of length nt.
m[l-1] : ndarray
Serial number of the zeros of Jn(x) or Jn’(x) associated with lth zero. Of length nt.
t[l-1] : ndarray
0 if lth zero in zo is zero of Jn(x), 1 if it is a zero of Jn’(x). Of length nt.

jn_zeros, jnp_zeros : to get separated arrays of zeros.

 [1] Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996, chapter 5. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
`jnyn_zeros`(n, nt)

Compute nt zeros of Bessel functions Jn(x), Jn’(x), Yn(x), and Yn’(x).

Returns 4 arrays of length nt, corresponding to the first nt zeros of Jn(x), Jn’(x), Yn(x), and Yn’(x), respectively.

n : int
Order of the Bessel functions
nt : int
Number (<=1200) of zeros to compute

See jn_zeros, jnp_zeros, yn_zeros, ynp_zeros to get separate arrays.

 [1] Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996, chapter 5. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
`jn_zeros`(n, nt)

Compute zeros of integer-order Bessel function Jn(x).

n : int
Order of Bessel function
nt : int
Number of zeros to return
 [1] Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996, chapter 5. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
`jnp_zeros`(n, nt)

Compute zeros of integer-order Bessel function derivative Jn’(x).

n : int
Order of Bessel function
nt : int
Number of zeros to return
 [1] Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996, chapter 5. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
`yn_zeros`(n, nt)

Compute zeros of integer-order Bessel function Yn(x).

n : int
Order of Bessel function
nt : int
Number of zeros to return
 [1] Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996, chapter 5. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
`ynp_zeros`(n, nt)

Compute zeros of integer-order Bessel function derivative Yn’(x).

n : int
Order of Bessel function
nt : int
Number of zeros to return
 [1] Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996, chapter 5. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
`y0_zeros`(nt, complex=False)

Compute nt zeros of Bessel function Y0(z), and derivative at each zero.

The derivatives are given by Y0’(z0) = -Y1(z0) at each zero z0.

nt : int
Number of zeros to return
complex : bool, default False
Set to False to return only the real zeros; set to True to return only the complex zeros with negative real part and positive imaginary part. Note that the complex conjugates of the latter are also zeros of the function, but are not returned by this routine.
z0n : ndarray
Location of nth zero of Y0(z)
y0pz0n : ndarray
Value of derivative Y0’(z0) for nth zero
 [1] Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996, chapter 5. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
`y1_zeros`(nt, complex=False)

Compute nt zeros of Bessel function Y1(z), and derivative at each zero.

The derivatives are given by Y1’(z1) = Y0(z1) at each zero z1.

nt : int
Number of zeros to return
complex : bool, default False
Set to False to return only the real zeros; set to True to return only the complex zeros with negative real part and positive imaginary part. Note that the complex conjugates of the latter are also zeros of the function, but are not returned by this routine.
z1n : ndarray
Location of nth zero of Y1(z)
y1pz1n : ndarray
Value of derivative Y1’(z1) for nth zero
 [1] Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996, chapter 5. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
`y1p_zeros`(nt, complex=False)

Compute nt zeros of Bessel derivative Y1’(z), and value at each zero.

The values are given by Y1(z1) at each z1 where Y1’(z1)=0.

nt : int
Number of zeros to return
complex : bool, default False
Set to False to return only the real zeros; set to True to return only the complex zeros with negative real part and positive imaginary part. Note that the complex conjugates of the latter are also zeros of the function, but are not returned by this routine.
z1pn : ndarray
Location of nth zero of Y1’(z)
y1z1pn : ndarray
Value of derivative Y1(z1) for nth zero
 [1] Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996, chapter 5. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
`_bessel_diff_formula`(v, z, n, L, phase)
`jvp`(v, z, n=1)

Compute nth derivative of Bessel function Jv(z) with respect to z.

v : float
Order of Bessel function
z : complex
Argument at which to evaluate the derivative
n : int, default 1
Order of derivative

The derivative is computed using the relation DLFM 10.6.7 [2]_.

 [1] Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996, chapter 5. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
 [2] NIST Digital Library of Mathematical Functions. http://dlmf.nist.gov/10.6.E7
`yvp`(v, z, n=1)

Compute nth derivative of Bessel function Yv(z) with respect to z.

v : float
Order of Bessel function
z : complex
Argument at which to evaluate the derivative
n : int, default 1
Order of derivative

The derivative is computed using the relation DLFM 10.6.7 [2]_.

 [1] Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996, chapter 5. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
 [2] NIST Digital Library of Mathematical Functions. http://dlmf.nist.gov/10.6.E7
`kvp`(v, z, n=1)

Compute nth derivative of real-order modified Bessel function Kv(z)

Kv(z) is the modified Bessel function of the second kind. Derivative is calculated with respect to z.

v : array_like of float
Order of Bessel function
z : array_like of complex
Argument at which to evaluate the derivative
n : int
Order of derivative. Default is first derivative.
out : ndarray
The results

Calculate multiple values at order 5:

```>>> from scipy.special import kvp
>>> kvp(5, (1, 2, 3+5j))
array([-1849.0354+0.j    ,   -25.7735+0.j    ,    -0.0307+0.0875j])
```

Calculate for a single value at multiple orders:

```>>> kvp((4, 4.5, 5), 1)
array([ -184.0309,  -568.9585, -1849.0354])
```

The derivative is computed using the relation DLFM 10.29.5 [2]_.

 [1] Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996, chapter 6. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
 [2] NIST Digital Library of Mathematical Functions. http://dlmf.nist.gov/10.29.E5
`ivp`(v, z, n=1)

Compute nth derivative of modified Bessel function Iv(z) with respect to z.

v : array_like of float
Order of Bessel function
z : array_like of complex
Argument at which to evaluate the derivative
n : int, default 1
Order of derivative

The derivative is computed using the relation DLFM 10.29.5 [2]_.

 [1] Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996, chapter 6. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
 [2] NIST Digital Library of Mathematical Functions. http://dlmf.nist.gov/10.29.E5
`h1vp`(v, z, n=1)

Compute nth derivative of Hankel function H1v(z) with respect to z.

v : float
Order of Hankel function
z : complex
Argument at which to evaluate the derivative
n : int, default 1
Order of derivative

The derivative is computed using the relation DLFM 10.6.7 [2]_.

 [1] Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996, chapter 5. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
 [2] NIST Digital Library of Mathematical Functions. http://dlmf.nist.gov/10.6.E7
`h2vp`(v, z, n=1)

Compute nth derivative of Hankel function H2v(z) with respect to z.

v : float
Order of Hankel function
z : complex
Argument at which to evaluate the derivative
n : int, default 1
Order of derivative

The derivative is computed using the relation DLFM 10.6.7 [2]_.

 [1] Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996, chapter 5. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
 [2] NIST Digital Library of Mathematical Functions. http://dlmf.nist.gov/10.6.E7
`riccati_jn`(n, x)

rCompute Ricatti-Bessel function of the first kind and its derivative.

The Ricatti-Bessel function of the first kind is defined as , where is the spherical Bessel function of the first kind of order .

This function computes the value and first derivative of the Ricatti-Bessel function for all orders up to and including n.

n : int
Maximum order of function to compute
x : float
Argument at which to evaluate
jn : ndarray
Value of j0(x), …, jn(x)
jnp : ndarray
First derivative j0’(x), …, jn’(x)

The computation is carried out via backward recurrence, using the relation DLMF 10.51.1 [2]_.

Wrapper for a Fortran routine created by Shanjie Zhang and Jianming Jin [1]_.

 [1] Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
 [2] NIST Digital Library of Mathematical Functions. http://dlmf.nist.gov/10.51.E1
`riccati_yn`(n, x)

Compute Ricatti-Bessel function of the second kind and its derivative.

The Ricatti-Bessel function of the second kind is defined as , where is the spherical Bessel function of the second kind of order .

This function computes the value and first derivative of the function for all orders up to and including n.

n : int
Maximum order of function to compute
x : float
Argument at which to evaluate
yn : ndarray
Value of y0(x), …, yn(x)
ynp : ndarray
First derivative y0’(x), …, yn’(x)

The computation is carried out via ascending recurrence, using the relation DLMF 10.51.1 [2]_.

Wrapper for a Fortran routine created by Shanjie Zhang and Jianming Jin [1]_.

 [1] Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
 [2] NIST Digital Library of Mathematical Functions. http://dlmf.nist.gov/10.51.E1
`erfinv`(y)

Inverse function for erf.

`erfcinv`(y)

Inverse function for erfc.

`erf_zeros`(nt)

Compute nt complex zeros of error function erf(z).

 [1] Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
`fresnelc_zeros`(nt)

Compute nt complex zeros of cosine Fresnel integral C(z).

 [1] Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
`fresnels_zeros`(nt)

Compute nt complex zeros of sine Fresnel integral S(z).

 [1] Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
`fresnel_zeros`(nt)

Compute nt complex zeros of sine and cosine Fresnel integrals S(z) and C(z).

 [1] Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
`assoc_laguerre`(x, n, k=0.0)

Compute the generalized (associated) Laguerre polynomial of degree n and order k.

The polynomial is orthogonal over `[0, inf)`, with weighting function `exp(-x) * x**k` with `k > -1`.

assoc_laguerre is a simple wrapper around eval_genlaguerre, with reversed argument order `(x, n, k=0.0) --> (n, k, x)`.

`polygamma`(n, x)

Polygamma function n.

This is the nth derivative of the digamma (psi) function.

n : array_like of int
The order of the derivative of psi.
x : array_like
Where to evaluate the polygamma function.
polygamma : ndarray
The result.
```>>> from scipy import special
>>> x = [2, 3, 25.5]
>>> special.polygamma(1, x)
array([ 0.64493407,  0.39493407,  0.03999467])
>>> special.polygamma(0, x) == special.psi(x)
array([ True,  True,  True], dtype=bool)
```
`mathieu_even_coef`(m, q)

rFourier coefficients for even Mathieu and modified Mathieu functions.

The Fourier series of the even solutions of the Mathieu differential equation are of the form

This function returns the coefficients for even input m=2n, and the coefficients for odd input m=2n+1.

m : int
Order of Mathieu functions. Must be non-negative.
q : float (>=0)
Parameter of Mathieu functions. Must be non-negative.
Ak : ndarray
Even or odd Fourier coefficients, corresponding to even or odd m.
 [1] Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
 [2] NIST Digital Library of Mathematical Functions http://dlmf.nist.gov/28.4#i
`mathieu_odd_coef`(m, q)

rFourier coefficients for even Mathieu and modified Mathieu functions.

The Fourier series of the odd solutions of the Mathieu differential equation are of the form

This function returns the coefficients for even input m=2n+2, and the coefficients for odd input m=2n+1.

m : int
Order of Mathieu functions. Must be non-negative.
q : float (>=0)
Parameter of Mathieu functions. Must be non-negative.
Bk : ndarray
Even or odd Fourier coefficients, corresponding to even or odd m.
 [1] Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
`lpmn`(m, n, z)

Sequence of associated Legendre functions of the first kind.

Computes the associated Legendre function of the first kind of order m and degree n, `Pmn(z)` = , and its derivative, `Pmn'(z)`. Returns two arrays of size `(m+1, n+1)` containing `Pmn(z)` and `Pmn'(z)` for all orders from `0..m` and degrees from `0..n`.

This function takes a real argument `z`. For complex arguments `z` use clpmn instead.

m : int
`|m| <= n`; the order of the Legendre function.
n : int
where `n >= 0`; the degree of the Legendre function. Often called `l` (lower case L) in descriptions of the associated Legendre function
z : float
Input value.
Pmn_z : (m+1, n+1) array
Values for all orders 0..m and degrees 0..n
Pmn_d_z : (m+1, n+1) array
Derivatives for all orders 0..m and degrees 0..n

clpmn: associated Legendre functions of the first kind for complex z

In the interval (-1, 1), Ferrer’s function of the first kind is returned. The phase convention used for the intervals (1, inf) and (-inf, -1) is such that the result is always real.

 [1] Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
 [2] NIST Digital Library of Mathematical Functions http://dlmf.nist.gov/14.3
`clpmn`(m, n, z, type=3)

Associated Legendre function of the first kind for complex arguments.

Computes the associated Legendre function of the first kind of order m and degree n, `Pmn(z)` = , and its derivative, `Pmn'(z)`. Returns two arrays of size `(m+1, n+1)` containing `Pmn(z)` and `Pmn'(z)` for all orders from `0..m` and degrees from `0..n`.

m : int
`|m| <= n`; the order of the Legendre function.
n : int
where `n >= 0`; the degree of the Legendre function. Often called `l` (lower case L) in descriptions of the associated Legendre function
z : float or complex
Input value.
type : int, optional
takes values 2 or 3 2: cut on the real axis `|x| > 1` 3: cut on the real axis `-1 < x < 1` (default)
Pmn_z : (m+1, n+1) array
Values for all orders `0..m` and degrees `0..n`
Pmn_d_z : (m+1, n+1) array
Derivatives for all orders `0..m` and degrees `0..n`

lpmn: associated Legendre functions of the first kind for real z

By default, i.e. for `type=3`, phase conventions are chosen according to [1]_ such that the function is analytic. The cut lies on the interval (-1, 1). Approaching the cut from above or below in general yields a phase factor with respect to Ferrer’s function of the first kind (cf. lpmn).

For `type=2` a cut at `|x| > 1` is chosen. Approaching the real values on the interval (-1, 1) in the complex plane yields Ferrer’s function of the first kind.

 [1] Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
 [2] NIST Digital Library of Mathematical Functions http://dlmf.nist.gov/14.21
`lqmn`(m, n, z)

Sequence of associated Legendre functions of the second kind.

Computes the associated Legendre function of the second kind of order m and degree n, `Qmn(z)` = , and its derivative, `Qmn'(z)`. Returns two arrays of size `(m+1, n+1)` containing `Qmn(z)` and `Qmn'(z)` for all orders from `0..m` and degrees from `0..n`.

m : int
`|m| <= n`; the order of the Legendre function.
n : int
where `n >= 0`; the degree of the Legendre function. Often called `l` (lower case L) in descriptions of the associated Legendre function
z : complex
Input value.
Qmn_z : (m+1, n+1) array
Values for all orders 0..m and degrees 0..n
Qmn_d_z : (m+1, n+1) array
Derivatives for all orders 0..m and degrees 0..n
 [1] Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
`bernoulli`(n)

Bernoulli numbers B0..Bn (inclusive).

 [1] Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
`euler`(n)

Euler numbers E0..En (inclusive).

 [1] Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
`lpn`(n, z)

Legendre function of the first kind.

Compute sequence of Legendre functions of the first kind (polynomials), Pn(z) and derivatives for all degrees from 0 to n (inclusive).

 [1] Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
`lqn`(n, z)

Legendre function of the second kind.

Compute sequence of Legendre functions of the second kind, Qn(z) and derivatives for all degrees from 0 to n (inclusive).

 [1] Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
`ai_zeros`(nt)

Compute nt zeros and values of the Airy function Ai and its derivative.

Computes the first nt zeros, a, of the Airy function Ai(x); first nt zeros, ap, of the derivative of the Airy function Ai’(x); the corresponding values Ai(a’); and the corresponding values Ai’(a).

nt : int
Number of zeros to compute
a : ndarray
First nt zeros of Ai(x)
ap : ndarray
First nt zeros of Ai’(x)
ai : ndarray
Values of Ai(x) evaluated at first nt zeros of Ai’(x)
aip : ndarray
Values of Ai’(x) evaluated at first nt zeros of Ai(x)
 [1] Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
`bi_zeros`(nt)

Compute nt zeros and values of the Airy function Bi and its derivative.

Computes the first nt zeros, b, of the Airy function Bi(x); first nt zeros, b’, of the derivative of the Airy function Bi’(x); the corresponding values Bi(b’); and the corresponding values Bi’(b).

nt : int
Number of zeros to compute
b : ndarray
First nt zeros of Bi(x)
bp : ndarray
First nt zeros of Bi’(x)
bi : ndarray
Values of Bi(x) evaluated at first nt zeros of Bi’(x)
bip : ndarray
Values of Bi’(x) evaluated at first nt zeros of Bi(x)
 [1] Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
`lmbda`(v, x)

rJahnke-Emden Lambda function, Lambdav(x).

This function is defined as [2]_,

where is the gamma function and is the Bessel function of the first kind.

v : float
Order of the Lambda function
x : float
Value at which to evaluate the function and derivatives
vl : ndarray
Values of Lambda_vi(x), for vi=v-int(v), vi=1+v-int(v), …, vi=v.
dl : ndarray
Derivatives Lambda_vi’(x), for vi=v-int(v), vi=1+v-int(v), …, vi=v.
 [1] Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
 [2] Jahnke, E. and Emde, F. “Tables of Functions with Formulae and Curves” (4th ed.), Dover, 1945
`pbdv_seq`(v, x)

Parabolic cylinder functions Dv(x) and derivatives.

v : float
Order of the parabolic cylinder function
x : float
Value at which to evaluate the function and derivatives
dv : ndarray
Values of D_vi(x), for vi=v-int(v), vi=1+v-int(v), …, vi=v.
dp : ndarray
Derivatives D_vi’(x), for vi=v-int(v), vi=1+v-int(v), …, vi=v.
 [1] Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996, chapter 13. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
`pbvv_seq`(v, x)

Parabolic cylinder functions Vv(x) and derivatives.

v : float
Order of the parabolic cylinder function
x : float
Value at which to evaluate the function and derivatives
dv : ndarray
Values of V_vi(x), for vi=v-int(v), vi=1+v-int(v), …, vi=v.
dp : ndarray
Derivatives V_vi’(x), for vi=v-int(v), vi=1+v-int(v), …, vi=v.
 [1] Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996, chapter 13. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
`pbdn_seq`(n, z)

Parabolic cylinder functions Dn(z) and derivatives.

n : int
Order of the parabolic cylinder function
z : complex
Value at which to evaluate the function and derivatives
dv : ndarray
Values of D_i(z), for i=0, …, i=n.
dp : ndarray
Derivatives D_i’(z), for i=0, …, i=n.
 [1] Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996, chapter 13. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
`ber_zeros`(nt)

Compute nt zeros of the Kelvin function ber(x).

 [1] Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
`bei_zeros`(nt)

Compute nt zeros of the Kelvin function bei(x).

 [1] Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
`ker_zeros`(nt)

Compute nt zeros of the Kelvin function ker(x).

 [1] Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
`kei_zeros`(nt)

Compute nt zeros of the Kelvin function kei(x).

`berp_zeros`(nt)

Compute nt zeros of the Kelvin function ber’(x).

 [1] Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
`beip_zeros`(nt)

Compute nt zeros of the Kelvin function bei’(x).

 [1] Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
`kerp_zeros`(nt)

Compute nt zeros of the Kelvin function ker’(x).

 [1] Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
`keip_zeros`(nt)

Compute nt zeros of the Kelvin function kei’(x).

 [1] Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
`kelvin_zeros`(nt)

Compute nt zeros of all Kelvin functions.

Returned in a length-8 tuple of arrays of length nt. The tuple contains the arrays of zeros of (ber, bei, ker, kei, ber’, bei’, ker’, kei’).

 [1] Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
`pro_cv_seq`(m, n, c)

Characteristic values for prolate spheroidal wave functions.

Compute a sequence of characteristic values for the prolate spheroidal wave functions for mode m and n’=m..n and spheroidal parameter c.

 [1] Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
`obl_cv_seq`(m, n, c)

Characteristic values for oblate spheroidal wave functions.

Compute a sequence of characteristic values for the oblate spheroidal wave functions for mode m and n’=m..n and spheroidal parameter c.

 [1] Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996. https://people.sc.fsu.edu/~jburkardt/f_src/special_functions/special_functions.html
`ellipk`(m)

rComplete elliptic integral of the first kind.

This function is defined as

m : array_like
The parameter of the elliptic integral.
K : array_like
Value of the elliptic integral.

For more precision around point m = 1, use ellipkm1, which this function calls.

The parameterization in terms of follows that of section 17.2 in [1]_. Other parameterizations in terms of the complementary parameter , modular angle , or modulus are also used, so be careful that you choose the correct parameter.

ellipkm1 : Complete elliptic integral of the first kind around m = 1 ellipkinc : Incomplete elliptic integral of the first kind ellipe : Complete elliptic integral of the second kind ellipeinc : Incomplete elliptic integral of the second kind

 [1] Milton Abramowitz and Irene A. Stegun, eds. Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables. New York: Dover, 1972.
`comb`(N, k, exact=False, repetition=False)

The number of combinations of N things taken k at a time.

This is often expressed as “N choose k”.

N : int, ndarray
Number of things.
k : int, ndarray
Number of elements taken.
exact : bool, optional
If exact is False, then floating point precision is used, otherwise exact long integer is computed.
repetition : bool, optional
If repetition is True, then the number of combinations with repetition is computed.
val : int, float, ndarray
The total number of combinations.

binom : Binomial coefficient ufunc

• Array arguments accepted only for exact=False case.
• If k > N, N < 0, or k < 0, then a 0 is returned.
```>>> from scipy.special import comb
>>> k = np.array([3, 4])
>>> n = np.array([10, 10])
>>> comb(n, k, exact=False)
array([ 120.,  210.])
>>> comb(10, 3, exact=True)
120L
>>> comb(10, 3, exact=True, repetition=True)
220L
```
`perm`(N, k, exact=False)

Permutations of N things taken k at a time, i.e., k-permutations of N.

It’s also known as “partial permutations”.

N : int, ndarray
Number of things.
k : int, ndarray
Number of elements taken.
exact : bool, optional
If exact is False, then floating point precision is used, otherwise exact long integer is computed.
val : int, ndarray
The number of k-permutations of N.
• Array arguments accepted only for exact=False case.
• If k > N, N < 0, or k < 0, then a 0 is returned.
```>>> from scipy.special import perm
>>> k = np.array([3, 4])
>>> n = np.array([10, 10])
>>> perm(n, k)
array([  720.,  5040.])
>>> perm(10, 3, exact=True)
720
```
`_range_prod`(lo, hi)

Product of a range of numbers.

Returns the product of lo * (lo+1) * (lo+2) * … * (hi-2) * (hi-1) * hi = hi! / (lo-1)!

Breaks into smaller products first for speed: _range_prod(2, 9) = ((2*3)*(4*5))*((6*7)*(8*9))

`factorial`(n, exact=False)

The factorial of a number or array of numbers.

The factorial of non-negative integer n is the product of all positive integers less than or equal to n:

```n! = n * (n - 1) * (n - 2) * ... * 1
```
n : int or array_like of ints
Input values. If `n < 0`, the return value is 0.
exact : bool, optional
If True, calculate the answer exactly using long integer arithmetic. If False, result is approximated in floating point rapidly using the gamma function. Default is False.
nf : float or int or ndarray
Factorial of n, as integer or float depending on exact.

For arrays with `exact=True`, the factorial is computed only once, for the largest input, with each other result computed in the process. The output dtype is increased to `int64` or `object` if necessary.

With `exact=False` the factorial is approximated using the gamma function:

```>>> from scipy.special import factorial
>>> arr = np.array([3, 4, 5])
>>> factorial(arr, exact=False)
array([   6.,   24.,  120.])
>>> factorial(arr, exact=True)
array([  6,  24, 120])
>>> factorial(5, exact=True)
120L
```
`factorial2`(n, exact=False)

Double factorial.

This is the factorial with every second value skipped. E.g., ```7!! = 7 * 5 * 3 * 1```. It can be approximated numerically as:

```n!! = special.gamma(n/2+1)*2**((m+1)/2)/sqrt(pi)  n odd
= 2**(n/2) * (n/2)!                           n even
```
n : int or array_like
Calculate `n!!`. Arrays are only supported with exact set to False. If `n < 0`, the return value is 0.
exact : bool, optional
The result can be approximated rapidly using the gamma-formula above (default). If exact is set to True, calculate the answer exactly using integer arithmetic.
nff : float or int
Double factorial of n, as an int or a float depending on exact.
```>>> from scipy.special import factorial2
>>> factorial2(7, exact=False)
array(105.00000000000001)
>>> factorial2(7, exact=True)
105L
```
`factorialk`(n, k, exact=True)

Multifactorial of n of order k, n(!!…!).

This is the multifactorial of n skipping k values. For example,

factorialk(17, 4) = 17!!!! = 17 * 13 * 9 * 5 * 1

In particular, for any integer `n`, we have

factorialk(n, 1) = factorial(n)

factorialk(n, 2) = factorial2(n)

n : int
Calculate multifactorial. If n < 0, the return value is 0.
k : int
Order of multifactorial.
exact : bool, optional
If exact is set to True, calculate the answer exactly using integer arithmetic.
val : int
Multifactorial of n.
NotImplementedError
Raises when exact is False
```>>> from scipy.special import factorialk
>>> factorialk(5, 1, exact=True)
120L
>>> factorialk(5, 3, exact=True)
10L
```
`zeta`(x, q=None, out=None)

r Riemann or Hurwitz zeta function.

x : array_like of float
Input data, must be real
q : array_like of float, optional
Input data, must be real. Defaults to Riemann zeta.
out : ndarray, optional
Output array for the computed values.

The two-argument version is the Hurwitz zeta function:

Riemann zeta function corresponds to `q = 1`.

zetac