MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: variable dimension of domain of integration

  • To: mathgroup at
  • Subject: [mg115975] Re: variable dimension of domain of integration
  • From: Leonid Shifrin <lshifr at>
  • 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.


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

  • Prev by Date: Re: About Table
  • Next by Date: Anyone know of a book on Mathematica suitable for 16-18 year old?
  • Previous by thread: Re: variable dimension of domain of integration
  • Next by thread: Select non-mathematica font for graphics ?