3

How can the below integral be calculated in R? :

enter image description here

The difficulty is that in the inner integral the upper bound contains one of the variables.

Anyone knows ?

The result must be : 0.0104166666666667

Homer Jay Simpson
  • 1,043
  • 6
  • 19

1 Answers1

3

You can get this from:

integrate(Vectorize(function(y) {
    integrate(function(x) {x*y}, 0, 1-2*y)$value }), 0,0.5)
0.01041667  with absolute error < 1.2e-16
G5W
  • 36,531
  • 10
  • 47
  • 80
  • I also found that pracma library is useful for that:`> f <- function(x, y){x*y} > xmin <- 0; xmax <- 1/2 > ymin <- 0; ymax <- function(y){1 -2*y} > I <- pracma::integral2(f, xmin, xmax, ymin, ymax) > I $Q [1] 0.01041667` – Homer Jay Simpson Jan 01 '23 at 16:24