scipy.special.eval_hermite#
- scipy.special.eval_hermite(n, x, out=None) = <wrapped_ufunc 'eval_hermite'>#
Evaluate physicist’s Hermite polynomial at a point.
Defined by
\[H_n(x) = (-1)^n e^{x^2} \frac{d^n}{dx^n} e^{-x^2};\]\(H_n\) is a polynomial of degree \(n\). See 22.11.7 in [AS] or [DLMF] for details.
- Parameters:
- narray_like
Degree of the polynomial
- xarray_like
Points at which to evaluate the Hermite polynomial
- outndarray, optional
Optional output array for the function values
- Returns:
- Hscalar or ndarray
Values of the Hermite polynomial
See also
roots_hermiteroots and quadrature weights of physicist’s Hermite polynomials
hermitephysicist’s Hermite polynomial object
numpy.polynomial.hermite.HermitePhysicist’s Hermite series
eval_hermitenormevaluate Probabilist’s Hermite polynomials
Notes
Array API Standard Support
eval_hermitehas 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.With PyTorch, noninteger values of the degree n are cast to integers before evaluation.
See Support for the array API standard for more information.
References
[AS]Milton Abramowitz and Irene A. Stegun, eds. Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables. New York: Dover, 1972.
[DLMF]NIST Digital Library of Mathematical Functions, https://dlmf.nist.gov/18.5.T1
Examples
>>> import numpy as np >>> from scipy.special import eval_hermite >>> import matplotlib.pyplot as plt
Evaluate the order 3 polynomial at a few values of x.
>>> eval_hermite(3, [0, 0.25, 0.5]) array([-0. , -2.875, -5. ])
Plot the polynomials of order 0 through 4.
>>> x = np.linspace(-1.6, 1.6, 800) >>> fig, ax = plt.subplots(1, 1, constrained_layout=True) >>> for n in range(5): ... y = eval_hermite(n, x) ... ax.plot(x, y, label=f'{n = }') >>> ax.grid() >>> ax.set_title("Physicist's Hermite Polynomials") >>> ax.set_xlabel("$x$") >>> ax.set_ylabel("$H_n(x)$") >>> ax.legend(loc='upper left', bbox_to_anchor=(1, 1), shadow=True) >>> plt.show()