Search code examples
rcalculationintegral

Double integral in R with variable in the bound


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


Solution

  • 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