create_gram_weights {GramQuad}R Documentation

Compute Gram weights

Description

Computes weights for Gram quadrature ofm+1 points.

Usage

create_gram_weights(m)

Arguments

m

a positive integer value, the number of points minus one for which weights will be computed. See 'Details'.

Details

The numerical integration of an analytical function f(x) using a finite set of equidistant points can be performed by quadrature formulas like the Newton-Cotes. Unlike Gaussian quadrature formulas however, higher-order Newton-Cotes formulas are not stable, limiting the usable order of such formulas. Existing work showed that by the use of orthogonal polynomials, stable high-order quadrature formulas with equidistant points can be developed. This algorithm improves upon such work by making use of (orthogonal) Gram polynomials and deriving an iterative algorithm, together allowing us to reduce the space-complexity of the original algorithm significantly.

Value

A double-precision vector of the specified length plus one, whose elements are the weights for the Gram quadratures of the m+1 points in the interval [-1,1].

Author(s)

Iago Giné-Vázquez, iago.gin-vaz@protonmail.com

References

Muhammad, Irfan (2021) Gram quadrature: Numerical integration with Gram polynomials. arXiv:2106.14875 [math.NA]

See Also

gaussLegendre

Examples

m <- 100
xs <- seq(-1, 1, length.out = m + 1)
gram_weights <- create_gram_weights(m)

# the sum of  stable  weights is  equal  to 2.
cat("Sum of Gram weights:", sum(gram_weights), "\n")

# test integration, integrate f below between [-1,1]
f = function(x){ 9 * x ^ 2 + 45 * 13 * x ^ 3 + 16 * x ^ 4}
gram_quad <- sum(gram_weights * f(xs))
cat("Approx. integration:", gram_quad, "\n")

[Package GramQuad version 0.1.1 Index]