Calculate nodes and weights for Gaussian quadrature.
- number of nodes and weights
- kind of Gaussian quadrature, one of
- parameter for Jacobi or Laguerre quadrature, must be greater than -1
- parameter for Jacobi quadrature, must be greater than -1
The integral from
w(x)*f(x) is approximated by
x is the vector of nodes and
w is the vector of weights. The approximation is exact if
f(x) is a polynomial of order no more than
The possible choices for
b are as follows:
Chebyshev quadrature of the 1st kind:
Chebyshev quadrature of the 2nd kind:
(-1,1). Note that Chebyshev quadrature is a special case of this.
The method is explained in Golub and Welsch (1969).
- A list containing the components
nodes vector of values at which to evaluate the function weights vector of weights to give the function values
This function solves a dense
n eigenvector problem and is therefore slow for large
It could be made far more efficient by using an eigenvector function designed to compute the leading terms of the eigenvectors for tridiagonal matrices.
Golub, G. H., and Welsch, J. H. (1969). Calculation of Gaussian quadrature rules. Mathematics of Computation 23, 221-230. Golub, G. H. (1973). Some modified matrix eigenvalue problems. Siam Review 15, 318-334. Stroud and Secrest (1966). Gaussian Quadrature Formulas. Prentice- Hall, Englewood Cliffs, N.J.
out <- gauss.quad(10,"laguerre",alpha=5) sum(out$weights * out$nodes) / gamma(6) # mean of gamma distribution with alpha=6