# Integrate upper $n$-sphere

For a class on Monte-Carlo simulation methods I want to do a comparison of Monte-Carlo integration and numerical integration on sparse grids. For this purpose I need a function $f$ defined over the $n$-dimensional hypercube $[-1,1]^n$ of which I know the value of the integral $\int_{[-1,1]^n} f$ in order to compare the calculation errors of the different methods. I thought about integrating the unit $n$-sphere as this is defined over the hypercube and the exact volume of the unit $n$-sphere is given by

$$V_n=\frac{\pi^{\frac{n}{2}}}{\Gamma (\frac{n}{2} +1)}$$

Now integrating the whole $n$-sphere will result in the integral being 0 as it is symmetric. That's why I thought about using only the upper unit $n$-sphere. Then the value of the integral would be given by $V_n/2$. However, I did not manage to come up with a function describing this upper half of the $n$-sphere. In the 2-dimensional case the upper sphere $U_2$ would be given by $U_2=\{ x_2= \sqrt{1-x_1^2},x_2\geq 0\}$ or in the more general case of the unit $n$-ball $U_n = \{ \sqrt{1- \sum_{i=1}^{n-1} x_i^2 }, x_n \geq 0 \}$.

Is there a way to express $U_n$ as a function that I could plug into my implemented integration algorithms to integrate it over the $n$-dimensional hypercube?

• The assertion "[the unit $n$-sphere] is defined over the hypercube..." is not true if $n \geq 2$. (The "shadow" of an ordinary hemisphere is a disk, not a square.) Separately, it's not clear what you mean by "integrating the whole $n$-sphere will result in the integral being $0$ as it is symmetric". – Andrew D. Hwang Jan 19 '17 at 21:22
• So on which set is the unit $n$-sphere defined? – YukiJ Jan 19 '17 at 21:26
• I think you want: The unit sphere is the union of two graphs $x_{n+1} = \pm\sqrt{1 - \|x\|^{2}}$ over the unit ball, the set of $x = (x_{1}, \dots, x_{n})$ in $\mathbf{R}^{n}$ where $\|x\|^{2} \leq 1$. – Andrew D. Hwang Jan 19 '17 at 21:39
• @YukiJ: Offering a bounty but not awarding it is like making a promise but not keeping it: a very ugly kind of behaviour. – Alex M. Jan 28 '17 at 9:18
• I am sorry @AlexM. But I Received an e-mail that the bounty will be automatically given to the best answer? Why has this not happened?! – YukiJ Jan 28 '17 at 9:20

Why don't you try polynomials - the simplest of the non-trivial examples? Choose a degree $d \in \Bbb N$ and a set of coefficients $\{a_{i_1, \dots, i_n} \mid i_1 + \dots + i_n \le d\} \subset \Bbb C$ and consider the associated polynomial $p(x_1, \dots, x_n) = \sum _{i_1 + \dots + i_n \le d} a_{i_1, \dots, i_n} x_1 ^{i_1} \dots x_n ^{i_n}$. Then
$$\int \limits _{[-1,1]^n} p(x_1, \dots, x_n) \ \Bbb d x_1 \dots \Bbb d x_n = \int \limits _{-1} ^1 \dots \int \limits _{-1} ^1 \sum _{i_1 + \dots + i_n \le d} a_{i_1, \dots, i_n} x_1 ^{i_1} \dots x_n ^{i_n} \ \Bbb d x_1 \dots \Bbb d x_n = \\ \sum _{i_1 + \dots + i_n \le d} a_{i_1, \dots, i_n} \frac {1 + (-1)^{i_1}} {i_1 + 1} \dots \frac {1 + (-1)^{i_n}} {i_n + 1} ,$$