Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #16009
| From | Leonid Shifrin <lshifr@gmail.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: variable dimension of domain of integration |
| Date | 2011-01-28 11:13 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <ihu8bu$1im$1@smc.vnet.net> (permalink) |
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@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
>
>
Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread
Re: variable dimension of domain of integration Leonid Shifrin <lshifr@gmail.com> - 2011-01-28 11:13 +0000
csiph-web