scipy.special.k0#
- scipy.special.k0(x, out=None) = <ufunc 'k0'>#
Modified Bessel function of the second kind of order 0, \(K_0\).
This function is also sometimes referred to as the modified Bessel function of the third kind of order 0.
- Parameters:
- xarray_like
Argument (float).
- outndarray, optional
Optional output array for the function values
- Returns:
- Kscalar or ndarray
Value of the modified Bessel function \(K_0\) at x.
See also
Notes
The range is partitioned into the two intervals [0, 2] and (2, infinity). Chebyshev polynomial expansions are employed in each interval.
This function is a wrapper for the Cephes [1] routine
k0
.k0
has experimental support for Python Array API Standard compatible backends in addition to NumPy. Please consider testing these features by setting an environment variableSCIPY_ARRAY_API=1
and providing CuPy, PyTorch, JAX, or Dask arrays as array arguments. The following combinations of backend and device (or other capability) are supported.Library
CPU
GPU
NumPy
✅
n/a
CuPy
n/a
✅
PyTorch
✅
✅
JAX
⚠️ no JIT
⛔
Dask
✅
n/a
See Support for the array API standard for more information.
References
[1]Cephes Mathematical Functions Library, http://www.netlib.org/cephes/
Examples
Calculate the function at one point:
>>> from scipy.special import k0 >>> k0(1.) 0.42102443824070823
Calculate the function at several points:
>>> import numpy as np >>> k0(np.array([0.5, 2., 3.])) array([0.92441907, 0.11389387, 0.0347395 ])
Plot the function from 0 to 10.
>>> import matplotlib.pyplot as plt >>> fig, ax = plt.subplots() >>> x = np.linspace(0., 10., 1000) >>> y = k0(x) >>> ax.plot(x, y) >>> plt.show()