gaussHermite: Gauss-Hermite Quadrature Formula In pracma: Practical Numerical Math Functions

Description

Nodes and weights for the n-point Gauss-Hermite quadrature formula.

Usage

 1 gaussHermite(n)

Arguments

 n Number of nodes in the interval ]-Inf, Inf[.

Details

Gauss-Hermite quadrature is used for integrating functions of the form

\int_{-∞}^{∞} f(x) e^{-x^2} dx

over the infinite interval ]-∞, ∞[.

x and w are obtained from a tridiagonal eigenvalue problem. The value of such an integral is then sum(w*f(x)).

Value

List with components x, the nodes or points in]-Inf, Inf[, and w, the weights applied at these nodes.

Note

The basic quadrature rules are well known and can, e. g., be found in Gautschi (2004) — and explicit Matlab realizations in Trefethen (2000). These procedures have also been implemented in Matlab by Geert Van Damme, see his entries at MatlabCentral since 2010.

References

Gautschi, W. (2004). Orthogonal Polynomials: Computation and Approximation. Oxford University Press.

Trefethen, L. N. (2000). Spectral Methods in Matlab. SIAM, Society for Industrial and Applied Mathematics.

Examples

 1 2 3 4 5 6 7 cc <- gaussHermite(17) # Integrate exp(-x^2) from -Inf to Inf sum(cc$w) #=> 1.77245385090552 == sqrt(pi) # Integrate x^2 exp(-x^2) sum(cc$w * cc$x^2) #=> 0.88622692545276 == sqrt(pi) /2 # Integrate cos(x) * exp(-x^2) sum(cc$w * cos(cc\$x)) #=> 1.38038844704314 == sqrt(pi)/exp(1)^0.25

Example output

 1.772454
 0.8862269
 1.380388

pracma documentation built on Dec. 11, 2021, 9:57 a.m.