# Computing 10-dimensional volume of a 9-sphere [closed]

I'm trying to compute 10-dimensional volume of a 9-sphere with radius r using Monte Carlo.

r = 1000
F = Piecewise[{{1, Sum[x[i]^2, {i, 10}] <= r}}, 0]
NIntegrate[F, {x[1], -1000, 1000}, {x[2], -1000, 1000}, {x[3], -1000, 1000}, {x[4], -1000, 1000}, {x[5], -1000, 1000}, {x[6], -1000, 1000}, {x[7], -1000, 1000}, {x[8], -1000, 1000}, {x[9], -1000, 1000}, {x[10], -1000, 1000}, Method -> {"MonteCarloRule", "Points" -> 1000000}]


But the results always off by the factor of 1e(P/2), where 1eP = The correct factoring. I'm wondering where did I do wrong?

Also I want to clean up the code

NIntegrate[F, {x[1], -1000, 1000}, {x[2], -1000, 1000}, {x[3], -1000, 1000}, {x[4], -1000, 1000}, {x[5], -1000, 1000}, {x[6], -1000, 1000}, {x[7], -1000, 1000}, {x[8], -1000, 1000}, {x[9], -1000, 1000}, {x[10], -1000, 1000}, Method -> {"MonteCarloRule", "Points" -> 1000000}]


I try to do this

NIntegrate[F, Table[{x[i], -r, r}, {i, 10}], Method -> {"MonteCarloRule", "Points" -> 1000000}]


But it doesn't work as Table[] gives list. I need to make it into sequence somehow. But trying to apply Sequence[] to Table[] still give me a list. Is there anyway to get around this?

-

## closed as off-topic by RunnyKine, m_goldberg, Öskå, Oleksandr R., bobthechemistAug 22 '14 at 23:28

• The question does not concern the technical computing software Mathematica by Wolfram Research. Please see the help center to find out about the topics that can be asked here.
If this question can be reworded to fit the rules in the help center, please edit the question.

The sum of the squares should be less than or equal to r^2 rather than r.

d = 10;
r = 1000;
F = Piecewise[{{1, Sum[x[i]^2, {i, d}] <= r^2}}, 0];

NIntegrate[F, {x[1], -1000, 1000}, {x[2], -1000, 1000},
{x[3], -1000, 1000}, {x[4], -1000, 1000},
{x[5], -1000, 1000}, {x[6], -1000, 1000},
{x[7], -1000, 1000}, {x[8], -1000, 1000},
{x[9], -1000, 1000}, {x[10], -1000, 1000},
Method -> {"MonteCarloRule", "Points" -> 1000000}]


2.54812*10^30

Attributes[NIntegrate]


{HoldAll, Protected}

The iterators must be a Sequence of lists rather than a list of lists and must be evaluated since NIntegrate has attribute HoldAll

NIntegrate[F, Evaluate[Sequence @@ Table[{x[i], -r, r}, {i, d}]],
Method -> {"MonteCarloRule", "Points" -> 1000000}]


2.5401*10^30

-

In Mathematica 10, this computation may be made as follows:

Clear @ r
volSphere9[r_] = RegionMeasure[Ball[ConstantArray[0, 10], r]]


(π^5 r^10)/120

volSphere9[1000.]

2.55016*10^30

-
You can also integrate over regions: Integrate[1, Table[Unique[], {10}] \[Element] Ball[ConstantArray[0, 10], 10]]. – kirma Aug 23 '14 at 8:25