Library: | math |
See also: | simpsonint |
Quantlet: | GaussLegendre | |
Description: | abscissas and weights of the Gauss-Legendre n-point quadrature. |
Usage: | {X,W} = GaussLegendre(x1,x2,n,EPS) | |
Input: | ||
x1 | scalar, lower limit of integretion | |
x2 | scalar, upper limit of integration | |
n | scalar, integer, number of points of integration | |
EPS | scalar, relative prcision | |
Output: | ||
X | n x 1 vector of abscissas | |
W | n x 1 vector of weights |
y=GaussLegendre(0,20,3,0.00001) y
Contents of y.X [1,] 2.254 [2,] 10 [3,] 17.746 Contents of y.W [1,] 5.5556 [2,] 8.8889 [3,] 5.5556
library("math") y=GaussLegendre(-3,3,10,0.00001) ;calculate an integral on(-3,3) interval sum(pdfn(y.X).*y.W)
Contents of sum [1,] 0.9973