search for: mixedrul

Displaying 1 result from an estimated 1 matches for "mixedrul".

Did you mean: mixedrule
2010 Sep 21
3
bivariate vector numerical integration with infinite range
...jj], y[ii], ...) } value <- value + C2 * weights[ii] * tmp } value } ## test function, the result is pi for y=1 f <- function(x, y) { res <- 1 / (sqrt(x)*(1+x)) c(res, res/2, 2*res) } ## Transformation rule from Numerical Recipes ## to deal with the [0, infty) range of x mixedrule <- function(x, y, f, ...) { t <- exp(pi*sinh(x)) dtdx <- t*(pi*cosh(x)) f(t, y, ...)*dtdx } vAverage(mixedrule, -4, 4, 0.0, 1, 20, f) - c(pi, pi/2, 2*pi) ## -3.535056e-06 -1.767528e-06 -7.070112e-06 So it seems to work. I wonder though if I may have missed an easier (and more re...