search for: gauss_legendre2d

Displaying 2 results from an estimated 2 matches for "gauss_legendre2d".

Did you mean: gauss_legendre
2008 Sep 27
3
Double integration - Gauss Quadrature
Hi, I would like to solve a double integral of the form \int_0^1 \int_0^1 x*y dx dy using Gauss Quadrature. I know that I can use R's integrate function to calculate it: integrate(function(y) { sapply(y, function(y) { integrate(function(x) x*y, 0, 1)$value }) }, 0, 1) but I would like to use Gauss Quadrature to do it. I have written the following code (using R's statmod package)
2008 Oct 15
0
R-help Digest, Vol 67, Issue 31
...## # 1D Gauss-Legendre gauss_legendre <- function(f, a, b, nodes, weights) { C <- (b - a) / 2 D <- (b + a) / 2 sum <- 0.0 for (i in 1:length(nodes)) { sum <- sum + weights[i] * f(nodes[i]*C + D) } return(C * sum) } ############################################## gauss_legendre2D_helper <- function(f, x, a2,b2, nodes, weights) { C <- (b2 - a2) / 2 D <- (b2 + a2) / 2 sum <- 0.0 for (i in 1:length(nodes)) { y <- nodes[i]*C + D sum <- sum + weights[i] * f(x,y) } return(C * sum) } gauss_legendre2D <- function(f, a1,b1, a2,b2, nodes,...