MathGroup Archive 2011

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

Search the Archive

Re: variable dimension of domain of integration


Ulvi Yurtsever 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

One possibility:

f[n_] := Module[
   {dims,x},
   dims = Array[x,n];
   NIntegrate[Evaluate[Sqrt[dims.dims]],
     Evaluate[Sequence@@Map[{#,0,1}&,dims]]]
   ]

f[4]
Out[20]= 1.1219

Daniel Lichtblau
Wolfram Research


  • Prev by Date: Re: About Table
  • Next by Date: Mathematica 8 Integration Bug
  • Previous by thread: Re: variable dimension of domain of integration
  • Next by thread: Re: variable dimension of domain of integration