I am using pracma::integral2
to integrate a function that sometimes requires additional parameters, but integral2
seems not to recognise the parameters I supply.
Consider these two functions:
fun1 <- function(x, y) exp(-x^2 - y^2)
fun2 <- function(x, y, a) (1 / a) * exp(-x^2 - y^2)
If I then run
integral2(fun1,
xmin = 0,
xmax = 1,
ymin = 0,
ymax = 1)$Q
I get 0.5577463 as expected. But if I run:
integral2(fun2,
xmin = 0,
xmax = 1,
ymin = 0,
ymax = 1,
a = 1)$Q
I get:
Error in fun(x, y, ...) : argument "a" is missing, with no default
Trackback shows the following:
- fun(x, y, ...)
- FUN(X, Y)
- .tensor(xmin, xmax, thetaL, thetaR, phiB, phiT, FUN, phiBvar, phiTvar, vectorized = vectorized, singular = singular)
- integral2(fun2, xmin = 0, xmax = 1, ymin = 0, ymax = 1, a = 1)
I don't know what .tensor
is, but it looks as if its product FUN(X,Y)
has lost the ...
.
What is going wrong here?