qnwlege: Gauss-Legendre quadrature nodes and weights

Description Usage Arguments Value Author(s) References See Also Examples

View source: R/qnwlege.R

Description

Generates Guass-Legendre quadrature nodes and weights for computing the definite integral of a real-valued function defined on a hypercube [a,b] in R^d.

Usage

1
qnwlege(n, a = matrix(0, 1, length(n)), b = matrix(1, 1, length(n)))

Arguments

n

1.d number of nodes per dimension

a

1.d left endpoints

b

1.d right endpoints

Value

List with fields

Author(s)

Randall Romero-Aguilar, based on Miranda & Fackler's CompEcon toolbox

References

Miranda, Fackler 2002 Applied Computational Economics and Finance

See Also

Other quadrature functions: qnwequi; qnwlogn; qnwnorm; qnwsimp; qnwtrap; qnwunif; quadrature

Examples

1
2
3
4
5
6
7
8
#' # To compute definte integral of a real-valued function f defined on a hypercube
# [a,b] in R^d, write a function f that returns an m.1 vector when passed an
# m.d matrix, and write
q <- qnwlege(n,a,b);
Intf <- crossprod(q$w, f(q$x))

# Alternatively, use the quadrature function
Intf <- quadrature(f,qnwlege,n,a,b)

randall-romero/CompEconR documentation built on May 26, 2019, 10:56 p.m.