scipy.special.struve#

scipy.special.struve(v, x, out=None) = <wrapped_ufunc 'struve'>#

Struve function.

Return the value of the Struve function of order v at x. The Struve function is defined as,

\[H_v(x) = (x/2)^{v + 1} \sum_{n=0}^\infty \frac{(-1)^n (x/2)^{2n}}{\Gamma(n + \frac{3}{2}) \Gamma(n + v + \frac{3}{2})},\]

where \(\Gamma\) is the gamma function.

Parameters:
varray_like

Order of the Struve function (float).

xarray_like

Argument of the Struve function (float; must be positive unless v is an integer).

outndarray, optional

Optional output array for the function results.

Returns:
Hscalar or ndarray

Value of the Struve function of order v at x.

See also

modstruve

Modified Struve function

Notes

Three methods discussed in [1] are used to evaluate the Struve function:

  • power series

  • expansion in Bessel functions (if \(|x| < |v| + 20\))

  • asymptotic large-x expansion (if \(x \geq 0.7v + 12\))

Rounding errors are estimated based on the largest terms in the sums, and the result associated with the smallest error is returned.

Array API Standard Support

struve has 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. out is 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. out is never supported for JAX because JAX arrays are immutable. struve does not currently support out for the PyTorch backend.

See Array API coverage for more information.

References

[1]

NIST Digital Library of Mathematical Functions https://dlmf.nist.gov/11

Examples

Calculate the Struve function of order 1 at 2.

>>> import numpy as np
>>> from scipy.special import struve
>>> import matplotlib.pyplot as plt
>>> struve(1, 2.)
0.6467637282835622

Calculate the Struve function at 2 for orders 1, 2 and 3 by providing a list for the order parameter v.

>>> struve([1, 2, 3], 2.)
array([0.64676373, 0.28031806, 0.08363767])

Calculate the Struve function of order 1 for several points by providing an array for x.

>>> points = np.array([2., 5., 8.])
>>> struve(1, points)
array([0.64676373, 0.80781195, 0.48811605])

Compute the Struve function for several orders at several points by providing arrays for v and x. The arrays have to be broadcastable to the correct shapes.

>>> orders = np.array([[1], [2], [3]])
>>> points.shape, orders.shape
((3,), (3, 1))
>>> struve(orders, points)
array([[0.64676373, 0.80781195, 0.48811605],
       [0.28031806, 1.56937455, 1.51769363],
       [0.08363767, 1.50872065, 2.98697513]])

Plot the Struve functions of order 0 to 3 from -10 to 10.

>>> fig, ax = plt.subplots()
>>> x = np.linspace(-10., 10., 1000)
>>> for i in range(4):
...     ax.plot(x, struve(i, x), label=f'$H_{i!r}$')
>>> ax.legend(ncol=2)
>>> ax.set_xlim(-10, 10)
>>> ax.set_title(r"Struve functions $H_{\nu}$")
>>> plt.show()
../../_images/scipy-special-struve-1.png