Gregory_weights {GregoryQuadrature} | R Documentation |
f %*% t(w)
where w are the returned weights. Translated
from https://www.colorado.edu/amath/sites/default/files/attached-files/gregory.pdf.Calculate the Gregory quadrature weights for equispaced integration. If f is
a row vector containing the function values, the integral is approximated by
the statement f %*% t(w)
where w are the returned weights. Translated
from https://www.colorado.edu/amath/sites/default/files/attached-files/gregory.pdf.
Gregory_weights(n_nodes, h, order)
n_nodes |
Total number of nodes |
h |
Step size |
order |
Order of accuracy desired. 2, 3, 4, ... (with 2 giving the trapezoidal rule). The value must satisfy 2 <= order <= n_nodes |
The weights to be used for the successive function values
n_nodes = 11
order = 8
h = 2/(n_nodes-1)
x = pracma::linspace(-1, 1, n_nodes)
f = exp(x)
w = GregoryQuadrature::Gregory_weights(n_nodes, h, order)
int = f %*% w
# Exact value for integral
exact = exp(1) - exp(-1)
error = int - exact