scipy.special.besselpoly#
- scipy.special.besselpoly(a, lmb, nu, out=None) = <wrapped_ufunc 'besselpoly'>#
Weighted integral of the Bessel function of the first kind.
Computes
\[\int_0^1 x^\lambda J_\nu(2 a x) \, dx\]where \(J_\nu\) is a Bessel function and \(\lambda=lmb\), \(\nu=nu\).
- Parameters:
- aarray_like
Scale factor inside the Bessel function.
- lmbarray_like
Power of x
- nuarray_like
Order of the Bessel function.
- outndarray, optional
Optional output array for the function results.
- Returns:
- scalar or ndarray
Value of the integral.
Notes
Array API Standard Support
besselpolyhas support for Python Array API Standard compatible backends in addition to NumPy. The following combinations of backend and device (or other capability) are supported.Library
CPU
GPU
NumPy
✅
n/a
CuPy
n/a
⛔
PyTorch
✅
⛔
JAX
✅
⛔
Dask
✅
n/a
For the NumPy backend, this function supports all NumPy ufunc keyword arguments. Other backends may support
out, but typically none of the other ufunc kwargs.outis typically supported for CuPy and PyTorch, but not currently in cases where SciPy relies on a generic Array API implementation or, for PyTorch on CPU, falls back to the NumPy backend.outis never supported for JAX because JAX arrays are immutable.besselpolydoes not currently supportoutfor the PyTorch backend.See Support for the array API standard for more information.
References
[1]Cephes Mathematical Functions Library, http://www.netlib.org/cephes/
Examples
Evaluate the function for one parameter set.
>>> from scipy.special import besselpoly >>> besselpoly(1, 1, 1) 0.24449718372863877
Evaluate the function for different scale factors.
>>> import numpy as np >>> factors = np.array([0., 3., 6.]) >>> besselpoly(factors, 1, 1) array([ 0. , -0.00549029, 0.00140174])
Plot the function for varying powers, orders and scales.
>>> import matplotlib.pyplot as plt >>> fig, ax = plt.subplots() >>> powers = np.linspace(0, 10, 100) >>> orders = [1, 2, 3] >>> scales = [1, 2] >>> all_combinations = [(order, scale) for order in orders ... for scale in scales] >>> for order, scale in all_combinations: ... ax.plot(powers, besselpoly(scale, powers, order), ... label=rf"$\nu={order}, a={scale}$") >>> ax.legend() >>> ax.set_xlabel(r"$\lambda$") >>> ax.set_ylabel(r"$\int_0^1 x^{\lambda} J_{\nu}(2ax)\,dx$") >>> plt.show()