Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #16009 > unrolled thread
| Started by | Leonid Shifrin <lshifr@gmail.com> |
|---|---|
| First post | 2011-01-28 11:13 +0000 |
| Last post | 2011-01-28 11:13 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.soft-sys.math.mathematica
Re: variable dimension of domain of integration Leonid Shifrin <lshifr@gmail.com> - 2011-01-28 11:13 +0000
| From | Leonid Shifrin <lshifr@gmail.com> |
|---|---|
| Date | 2011-01-28 11:13 +0000 |
| Subject | Re: variable dimension of domain of integration |
| Message-ID | <ihu8bu$1im$1@smc.vnet.net> |
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 top | Article view | comp.soft-sys.math.mathematica
csiph-web