torch.special.hermite_polynomial_h
function hermite_polynomial_h<S extends Shape>(x: Tensor<S, 'float32'>, n: number | Tensor, _options?: SpecialPolynomialOptions<S>): Tensor<S, 'float32'>Computes Hermite polynomial (physicist's convention) H_n(x).
The Hermite polynomials of the physicist's type H_n(x) are orthogonal on (-∞, ∞) with weight exp(-x²). Fundamental to quantum mechanics: eigenfunctions of the harmonic oscillator and Schrödinger equation. Central to many ML/physics applications including:
- Quantum mechanics: quantum harmonic oscillator wavefunctions, ladder operators, Fock states
- Gaussian process modeling: Hermite polynomial basis for smooth function approximation
- Signal processing: Hermite expansion of Gaussian signals, time-frequency analysis
- Orthogonal function expansion: natural basis for problems with Gaussian weight exp(-x²)
- Approximation theory: optimal for Gaussian-weighted L² spaces
- Probabilistic models: related to Gaussian density, moments, cumulants
Physicist's vs Probabilist's: H_n(x) grows as 2^n·x^n for large x (physicist); He_n grows as x^n (probabilist). Physicist convention (factor 2^n) is standard in physics/engineering; probabilist's convention in statistics.
Quantum Oscillator: H_n appears directly in quantum harmonic oscillator eigenfunctions: ψ_n(x) = (2^n √(n! √π))^{-1/2} exp(-x²/2) H_n(x).
- Physicist's convention: H_n has leading coefficient 2^n (not normalized to 1)
- Rapid growth: H_n(x) ~ 2^n x^n for large x; overflow risk for n 20 and |x| 5
- Quantum mechanics: H_n is fundamental to quantum harmonic oscillator; natural basis for many quantum problems
- Recurrence efficiency: Three-term recurrence easy to compute; H_0, H_1, then H_n+1 from prior two
- Gaussian weight: Orthogonal with weight exp(−x²), not 1; integrate with exp(−x²) dx for orthogonality
- Even/odd symmetry: H_n(-x) = (-1)^n H_n(x) (even if n even, odd if n odd)
- Asymptotic behavior: H_n(x) ≈ 2^n x^n for |x| → ∞ (dominant term)
- Numerical overflow: Grows rapidly; H_n(x) ~ 2^n for large n and x. Overflow for n 20 with double precision
- Unbounded domain: Defined for all real x; no restriction unlike Chebyshev [-1, 1] or Laguerre [0, ∞)
- Not normalized: Physicist's convention uses 2^n factor; not monic (use hermite_polynomial_he for probabilist's)
Parameters
xTensor<S, 'float32'>- Input tensor (unbounded real; well-defined for all x ∈ ℝ)
nnumber | Tensor- Polynomial degree (non-negative integer). Can be scalar or Tensor
_optionsSpecialPolynomialOptions<S>optional
Returns
Tensor<S, 'float32'>– Tensor with H_n(x) valuesExamples
// Basic evaluation
const x = torch.linspace(-2, 2, 5);
const H_0 = torch.special.hermite_polynomial_h(x, 0); // [1, 1, 1, 1, 1]
const H_1 = torch.special.hermite_polynomial_h(x, 1); // 2*x
const H_2 = torch.special.hermite_polynomial_h(x, 2); // 4*x^2 - 2
// Quantum harmonic oscillator eigenfunctions
const x_range = torch.linspace(-3, 3, 100); // Position space
const n_level = 3; // Quantum number
const H_n = torch.special.hermite_polynomial_h(x_range, n_level);
const weight = x_range.pow(2).neg().exp(); // exp(-x²)
const psi_n = H_n.mul(weight); // (unnormalized) wavefunction
// Each H_n is eigenfunction of quantum oscillator Hamiltonian
// Gaussian process regression basis
const x_train = torch.randn(50); // Training points
const n_terms = 5; // Order of expansion
const hermite_features = [];
for (let i = 0; i < n_terms; i++) {
hermite_features.push(torch.special.hermite_polynomial_h(x_train, i));
}
// [0..4] form orthogonal basis for Gaussian-weighted approximation
// Extreme values grow rapidly (2^n scaling)
const x_large = torch.tensor([10.0]);
const H_10_large = torch.special.hermite_polynomial_h(x_large, 10); // H_10(10) ≈ 4.16e18
// Explosive growth; careful with numerical stability for large n and |x|
// Recurrence verification
const x_test = torch.tensor([1.5]);
const H_2 = torch.special.hermite_polynomial_h(x_test, 2); // 4*1.5^2 - 2 = 7
const H_1 = torch.special.hermite_polynomial_h(x_test, 1); // 2*1.5 = 3
const H_0 = torch.special.hermite_polynomial_h(x_test, 0); // 1
// H_2 = 2*x*H_1 - 2*1*H_0 = 2*1.5*3 - 2*1 = 7 ✓See Also
- PyTorch torch.special.hermite_polynomial_h()
- torch.special.hermite_polynomial_he - Probabilist's convention He_n(x) (slower growth, 2^n/2 scaling)
- torch.special.laguerre_polynomial_l - Laguerre L_n on [0, ∞) with exp(−x) weight
- torch.special.legendre_polynomial_p - Legendre on [−1, 1] with constant weight