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