Tell me more ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

This is not a new problem but I would like to understand why Mathematica gives the result that it does. (Volume of a hypersphere)

In[4]:= Integrate[
  Boole[x1^2 + x2^2 + x3^2 + x4^2 + x5^2 + x6^2 < r^2], {x1, -Infinity,
  Infinity}, {x2, -Infinity, Infinity}, {x3, -Infinity, 
  Infinity}, {x4, -Infinity, Infinity}, {x5, -Infinity, 
  Infinity}, {x6, -Infinity, Infinity}, Assumptions -> {r > 0}]

Out[4]= -(1/6) \[Pi]^3 r^6

A negative answer is obviously incorrect. Replace r^2 by 4

In[3]:= Integrate[
  Boole[x1^2 + x2^2 + x3^2 + x4^2 + x5^2 + x6^2 < 4], {x1, -Infinity, 
  Infinity}, {x2, -Infinity, Infinity}, {x3, -Infinity, 
  Infinity}, {x4, -Infinity, Infinity}, {x5, -Infinity, 
  Infinity}, {x6, -Infinity, Infinity}, Assumptions -> {r > 0}]

Out[3]= (32 \[Pi]^3)/3

This is correct.

If we reduce the number of variables, then we obtain a correct answer:

In[5]:= Integrate[
  Boole[(x1^2 + x2^2 + x3^2 + x4^2 ) < r^2], {x1, -Infinity, 
  Infinity}, {x2, -Infinity, Infinity}, {x3, -Infinity, 
  Infinity}, {x4, -Infinity, Infinity}, Assumptions -> {r > 0}]

Out[5]= (\[Pi]^2 r^4)/2
share|improve this question
3  
This is a known buggy area. If I recall correctly it undersimplifies assumptions somewhere inside due to either internal limitations or time constraints. You might get a better outcome if you first do this (it will influence that former issue): SetSystemOptions["SimplificationOptions"->{"AssumptionsMaxNonlinearVariables"->‌​7}]; – Daniel Lichtblau Apr 26 at 18:48
1  
At v8.04.0 it gives the correct result what's your version? – Spawn1701D Apr 26 at 19:35
In 9.0.1 Mathematica also gives a negative answer and then fails to return any answer for the 8 dimensional cases. If memory serves, version 8 gave correct answers up through 6 dimensions and then failed on 7 dimensions. I note that the 9.0.1 answers would be correct if the sign was positive. – TC Jones Apr 26 at 22:33
Daniel's suggestion is good but the problem remains. – TC Jones Apr 26 at 23:49

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.