Re: variable dimension of domain of integration
- To: mathgroup at smc.vnet.net
- Subject: [mg115975] Re: variable dimension of domain of integration
- From: Leonid Shifrin <lshifr at gmail.com>
- Date: Fri, 28 Jan 2011 06:12:38 -0500 (EST)
Hi Ulvi, I would do this: In[16]:= Clear[f]; f[n_] := With[{vars = Table[Unique[], {n}]}, NIntegrate @@ {Total[vars^2], Sequence @@ Table[{v, 0, 1}, {v, vars}]}] In[18]:= f /@ Range[5] Out[18]= {0.333333, 0.666667, 1., 1.33333, 1.66667} This basically constructs programmatically the same NIntegrate that you would write by hand, so not sure if this can be called elegant. Regards, Leonid On Thu, Jan 27, 2011 at 11:41 AM, Ulvi Yurtsever <a at b.c> wrote: > Consider the function $f(n) = \int_{{0,1}^n} > \sqrt{\sum_{i=1}^{n} {x_i}^2} dx_1 ... dx_n$. > How would you define a mathematica function > F[n_] (using NIntegrate) that computes this > integral over the n-cube? I can think of several > inelegant solutions; but surely there are neat > ways of doing things of this sort... > > > thanks > >