Gauss-Hermite Quadrature Nodes and Weights Calculator

Gauss-Hermite Quadrature Nodes and Weights Calculator

Growing AI Skill PRO

Enter Calculation

Formula

∫−∞∞e−x2f(x)dx≈∑i=1Order nwif(xi)where{Jvi=xivi,Jkk=0,Jk,k+1=Jk+1,k=k2wi=π(vi,1)2\begin{gathered} \int_{-\infty}^{\infty} e^{-x^2} f(x)\,dx \approx \sum_{i=1}^{{{\text{Order }n}}} w_i\, f(x_i) \\[1.5em] \text{where}\quad \left\{ \begin{aligned} J\,v_i &= x_i\,v_i, \quad J_{kk}=0,\; J_{k,k+1}=J_{k+1,k}=\sqrt{\tfrac{k}{2}} \\ w_i &= \sqrt{\pi}\,\big(v_{i,1}\big)^2 \end{aligned} \right. \end{gathered}
Usage stats

Advertisement

Results

Gauss-Hermite Quadrature (n = 20)
n = 20
nodes and weights for the physicists' weight e^(-x^2)
i Node x_i Weight w_i
1 -5.38748089001123 2.22939364553414e-13
2 -4.60368244955075 4.39934099227314e-10
3 -3.94476404011563 1.08606937076927e-07
4 -3.34785456738322 7.80255647853208e-06
5 -2.78880605842813 0.000228338636016353
6 -2.25497400208928 0.00324377334223785
7 -1.73853771211659 0.0248105208874637
8 -1.23407621539532 0.109017206020023
9 -0.737473728545394 0.286675505362834
10 -0.245340708300901 0.462243669600610
11 0.245340708300901 0.462243669600610
12 0.737473728545395 0.286675505362835
13 1.23407621539532 0.109017206020023
14 1.73853771211659 0.0248105208874636
15 2.25497400208928 0.00324377334223785
16 2.78880605842813 0.000228338636016355
17 3.34785456738322 7.80255647853212e-06
18 3.94476404011563 1.08606937076928e-07
19 4.60368244955074 4.39934099227318e-10
20 5.38748089001123 2.22939364553414e-13

Self-check: sum of all weights = 1.7724538509055163, which should equal sqrt(pi) = 1.7724538509055159.

Report an error on this page

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)$$
Bell-shaped weight curve with sample points and vertical bars at the nodes
Gauss-Hermite quadrature approximates an integral weighted by \(e^{-x^2}\) using a few cleverly placed nodes.

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.

Advertisement

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.

Two symmetric nodes on an axis with equal-height weight bars under a bell curve
For \(n = 2\) the two nodes sit symmetrically at \(\pm\sqrt{1/2}\) with equal weights.

How to Apply the Nodes and Weights to an Integral

Gauss-Hermite quadrature approximates integrals over the whole real line that contain the physicists' weight \(e^{-x^2}\):

$$\int_{-\infty}^{\infty} e^{-x^2} f(x)\,dx \approx \sum_{i=1}^{n} w_i\, f(x_i)$$

  1. Choose n. A larger n integrates higher-degree polynomials exactly, but it only helps if f is smooth.
  2. Get the nodes and weights. Read \(x_i\) and \(w_i\) for your chosen order from the calculator.
  3. Identify f(x). Factor \(e^{-x^2}\) out of the integrand. What remains is \(f(x)\).
  4. Evaluate f at each node: compute \(f(x_1), \dots, f(x_n)\).
  5. Multiply by the weights: form each product \(w_i f(x_i)\).
  6. Sum the products to get the approximation.

Example: n = 2

Evaluate \(\int_{-\infty}^{\infty} e^{-x^2} x^2\,dx\). Here \(f(x)=x^2\). The 2-point rule has nodes \(x_{1,2}=\pm 1/\sqrt{2}\approx \pm 0.70710678\) and weights \(w_1=w_2=\sqrt{\pi}/2\approx 0.88622693\).

$$\sum w_i f(x_i) = \frac{\sqrt{\pi}}{2}\left(\tfrac12\right) + \frac{\sqrt{\pi}}{2}\left(\tfrac12\right) = \frac{\sqrt{\pi}}{2} \approx 0.886227$$

This equals the exact value \(\sqrt{\pi}/2\). The result is exact because \(f\) has degree 2, which is at most \(2n-1 = 3\).

Integrals without a Gaussian factor

To integrate a function \(g(x)\) that has no \(e^{-x^2}\) factor, write

$$\int_{-\infty}^{\infty} g(x)\,dx = \int_{-\infty}^{\infty} e^{-x^2}\,\big(g(x)\,e^{x^2}\big)\,dx,$$

so \(f(x)=g(x)\,e^{x^2}\). This works well only if \(g\) decays faster than a Gaussian. Otherwise \(f\) grows rapidly and the rule performs poorly.

Normal expectations

For \(T\sim N(\mu,\sigma^2)\), substitute \(x=(t-\mu)/(\sqrt{2}\,\sigma)\), that is \(t=\mu+\sqrt{2}\,\sigma x\):

$$E[h(T)] = \frac{1}{\sqrt{\pi}} \int_{-\infty}^{\infty} e^{-x^2}\, h(\mu+\sqrt{2}\,\sigma x)\,dx \approx \frac{1}{\sqrt{\pi}} \sum_{i=1}^{n} w_i\, h(\mu+\sqrt{2}\,\sigma x_i)$$

Advertisement

Interpreting the Nodes, Weights and Accuracy

  • Symmetry. The nodes are symmetric about zero: if \(x_i\) is a node, so is \(-x_i\), with the same weight. For odd n, zero is itself a node.
  • Node range. The largest node grows on the order of \(\sqrt{2n}\) and approaches that rate from below. The nodes cover a wider interval as n increases.
  • Weights. All weights are positive and sum to \(\int e^{-x^2}dx=\sqrt{\pi}\approx 1.7724539\). Positive weights make the rule numerically stable. The outer weights are extremely small. For n = 20 the smallest is about \(10^{-13}\), and it keeps shrinking as n grows. A naive computation of these weights can underflow or lose relative accuracy at large n.
  • Degree of exactness. An n-point rule is exact for every polynomial \(f\) of degree up to \(2n-1\).
  • Error term. For a sufficiently smooth \(f\), the error is

$$E_n = \frac{n!\,\sqrt{\pi}}{2^n\,(2n)!}\, f^{(2n)}(\xi)$$

for some \(\xi\) on the real line. The result depends on the \(2n\)-th derivative of \(f\), so the rule works best when those derivatives stay small.

  • Poor cases. Accuracy drops for non-smooth integrands (kinks, jumps, discontinuities) and for integrands that grow faster than polynomially, such as \(e^{x^2}\) or faster. Increasing n does not reliably fix these cases.
  • Precision limits. In double precision (about 15–16 significant digits), results at high n are limited by rounding error. This affects the tiny outer weights most, and the relative accuracy of the nodes and weights can degrade. Treat very high orders with caution and compare results at neighbouring values of n.

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)\).

Last updated:

Most popular in Math and Statistics

View all Math and Statistics calculators