What is Gauss-Hermite quadrature?
Gauss-Hermite quadrature is a numerical method for approximating integrals over the whole real line that carry the Gaussian weight \(e^{-x^2}\). The n-point rule approximates the integral as a weighted sum of the integrand evaluated at n carefully chosen points: the integral from minus infinity to plus infinity of \(e^{-x^2}\,f(x)\,dx\) is approximately the sum over i of \(w_i\,f(x_i)\). The nodes \(x_i\) are the roots of the physicists' Hermite polynomial \(H_n\), and the weights \(w_i\) are determined by the orthogonality of those polynomials.
$$\int_{-\infty}^{\infty} e^{-x^2} f(x)\,dx \approx \sum_{i=1}^{\text{Order }n} w_i\, f(x_i)$$
How to use the calculator
Pick the order \(n\) (the number of points, from 2 to 100) and the number of display digits, then read off the table of nodes and weights. Because the rebuild uses standard double precision, displayed precision is capped at about 15 significant figures - beyond that, arbitrary-precision arithmetic would be required for the extra digits to be meaningful. The n-point rule integrates every polynomial of degree up to \(2n-1\) exactly.
The formula explained
The nodes are the \(n\) real zeros of \(H_n(x)\), defined by the recurrence \(H_0=1\), \(H_1=2x\), \(H_{k+1}=2x\,H_k - 2k\,H_{k-1}\). The weights are $$w_i = \frac{2^{n-1}\, n!\, \sqrt{\pi}}{n^2\, [H_{n-1}(x_i)]^2}.$$ This calculator uses the stable Golub-Welsch method: it builds the symmetric tridiagonal Jacobi matrix (zero diagonal, off-diagonal \(\sqrt{k/2}\)), finds its eigenvalues (the nodes) and eigenvectors, and sets each weight to \(\sqrt{\pi}\) times the square of the first component of the corresponding normalized eigenvector. This avoids overflow from large factorials.
Worked example (n = 2)
\(H_2(x) = 4x^2 - 2\) has roots \(x = \pm \frac{1}{\sqrt{2}} = \pm 0.7071067811865475\). Each weight is \(\frac{2^1 \cdot 2! \cdot \sqrt{\pi}}{2^2 \cdot [H_1(x_i)]^2}\). With \(H_1(x)=2x\), \([H_1]^2 = 2\), so each weight $$= \frac{2 \cdot 2 \cdot 1.7724538509055160}{4 \cdot 2} = 0.8862269254527580.$$ Their sum is \(\sqrt{\pi} = 1.7724538509055160\), a useful self-check.
FAQ
Why do the weights always sum to sqrt(pi)? Setting \(f(x)=1\) gives the integral of \(e^{-x^2}\) over the real line, which equals \(\sqrt{\pi}\); the quadrature reproduces it exactly.
Which Hermite convention is this? The physicists' convention with weight \(e^{-x^2}\). For the probabilists' weight \(e^{-x^2/2}\) the nodes and weights differ by scaling.
Can I integrate a function without the e^(-x^2) factor? Yes - write \(g(x) = e^{x^2}\,f(x)\), so the integral of \(g\) is approximately the sum of \(w_i\,e^{x_i^2}\,g(x_i)\).