1

My question is similar to "double integral in R.", but in my case, I want to do a triple integration where each limit depends on the outer integral.

I wnat to calculate

enter image description here

How do I define the inner dependencies?

RGG
  • 21
  • 4
  • 1
    Question to the flagging team: Does this question really follow the category "too broad"? I agree that OP should have presented what he or she had tried to do, but The question seems clear: given a function f:R->R calculate the triple integral of the above form. Am I missing something about "too broad" category? – storaged Dec 14 '17 at 19:24
  • Agreed with @storaged. RGG: to evaluate this integral, one can split the domain of integration into simplices and integrate with the SimplicialCubature package. But I need the answer space to develop... – Stéphane Laurent Jan 05 '18 at 15:18
  • @storaged I voted to reopen. I'd like to post an answer. Please vote to reopen if you agree. – Stéphane Laurent Jul 26 '18 at 10:33
  • @Stéphane Laurent ...it's embarassing, but I don't know how to vote for the reopening... – storaged Jul 27 '18 at 11:15
  • See https://laustep.github.io/stlahblog/posts/integralPolyhedron.html – Stéphane Laurent Feb 27 '19 at 13:29

1 Answers1

1

I think, that basing on the suggestion from the post you have attached the key is to add the Vectorize function and we come up with something like this:

# Example function 
phi <- function(t){t}

integrate(Vectorize(function(x) { 
  integrate(Vectorize(function(y) { 
    integrate(function(z) { 
      phi(x)*phi(y)*phi(z)   ## function you want to calculate
    }, -10, 6-x-y)$value     ## 2nd level interval
   }), -5, 3-x)$value        ## 1st level interval
}), -5,4)                    ## top interval

# 16480.2 with absolute error < 1.8e-10

the above approach is quite general, so you can test on other functions. (The answer is the same as provided by WolframAlpha)

storaged
  • 1,837
  • 20
  • 34