I'm having trouble writing code in Mathematica for this multi variable integration: $\int_0^1\int_0^1...\int_0^1F[x_1,x_2,...,x_n]dx_1dx_2...dx_n$

If I already know the number of elements of A it is easy: Integrate[F[x1,x2],{x1,0,1},{x2,0,1}]. I also tried using Nest[Integrate[#,{?,0,1]&, F[x],Length[X]} but for ? I have no idea what to use.

Also how should I define the $x$s? I have defined F[_X] with X being a vector (I have a certain function in mind).

  • $\begingroup$ Try this: Integrate[F @@ X, Sequence @@ Thread[{X, 0, 1}]] $\endgroup$ – Anjan Kumar Feb 14 '18 at 16:14
  • $\begingroup$ @AnjanKumar thank you, it works. With X = {a,b,c,d}, doing F @@ X is like calling F[a,b,c,d] based on what I read now. But how does Sequence @@ Thread work? $\endgroup$ – Felix Mada Feb 14 '18 at 16:45
  • $\begingroup$ Sequence@@ basically removes the external brackets and Thread creates a list of {xi, 0, 1} where xi is an element of X. I would suggest you to go through the documentation to get a good feel of those functions. $\endgroup$ – Anjan Kumar Feb 14 '18 at 16:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.