\documentclass[a4paper,11pt]{article}
\parskip=1.5ex
\usepackage{verbatim,a4margins,amsmath,amssymb,bm,hyperref}

\newcommand{\dd}[2]{\frac{\mathrm d #1}{\mathrm d #2}}
\newcommand{\dds}[2]{\frac{\mathrm d^2 #1}{{\mathrm d #2}^2}}
\newcommand{\pdd}[2]{\frac{\partial #1}{\partial #2}}
\newcommand{\pdds}[2]{\frac{\partial^2 #1}{\partial{#2}^2}}
\newcommand{\pddd}[3]{\frac{\partial^2 #1}{\partial #2\partial #3}}

\newcommand{\rowfour}[4]{\left[\begin{array}{cccc}#1&#2&#3&#4\end{array}\right]}
\newcommand{\vectwo}[2]{\left[\begin{array}{c}#1\\#2\end{array}\right]}
\newcommand{\mxtwo}[4]{\left[\begin{array}{cc}#1&#2\\#3&#4\end{array}\right]}

\newcommand{\sq}[1]{\left(#1\right)^2}
\newcommand{\floor}[1]{\left\lfloor#1\right\rfloor}
\newcommand{\abs}[1]{\left|#1\right|}

\newcommand{\rem}[1]{}

\newcommand{\A}{\mathbf A}
\newcommand{\E}{\mathbf E}
\newcommand{\B}{\mathbf B}
\newcommand{\J}{\mathbf J}
\newcommand{\0}{\mathbf 0}

\newcommand{\f}{\mathbf f}
\newcommand{\uv}{\mathbf u}
\newcommand{\vv}{\mathbf v}
\newcommand{\w}{\mathbf w}
\newcommand{\x}{\mathbf x}
\newcommand{\y}{\mathbf y}
\newcommand{\z}{\mathbf z}

\newcommand{\s}{\mathbf s}
\newcommand{\rv}{\mathbf r}
\newcommand{\cv}{\mathbf c}

\newcommand{\e}{\mathbf e}
\newcommand{\m}{\mathbf m}
\newcommand{\M}{\mathbf M}

\newcommand{\de}{\,\mathrm d}

\newcommand{\ii}{\mathrm i}

\begin{document}

\title{Integrals of Polynomial Functions over Spheres and Balls}
\author{Stephen Brooks}
\date{June 27, 2023}
\maketitle

\section{Definitions and Problem}
Let $B_n=\{\x:|\x|\le1\}$ be the unit $n$-dimensional ball and $S_{n-1}=\{\x:|\x|=1\}$ be the unit $(n-1)$-dimensional sphere.  Note that this sphere is the surface of the ball: $S_{n-1}=\partial B_n$.

We want to evaluate the integral
\[ I^{B_n}_{a_1\ldots a_n} = \int_{B_n}\left(\prod_{i=1}^n x_i^{a_i}\right) \de^n\x \]
of a general monomial term over the $n$-dimensional ball.  It will be helpful to define a similar integral 
\[ I^{S_{n-1}}_{a_1\ldots a_n} = \int_{S_{n-1}}\left(\prod_{i=1}^n x_i^{a_i}\right) \de^{n-1}\x \]
over the surface of the sphere.  Finally, an integral over all space but weighted by an $n$-dimensional unit Gaussian distribution will also be useful:
\[ I^{g_n}_{a_1\ldots a_n} = \int_{\mathbb{R}^n}\left(\prod_{i=1}^n x_i^{a_i}\right) \frac1{\sqrt{2\pi}^n} e^{-\frac12|\x|^2} \de^n\x. \]

\section{Separability of Gaussian Integral}
The Gaussian integrand can be written as a product
\[ I^{g_n}_{a_1\ldots a_n} = \int_{\mathbb{R}^n}\left(\prod_{i=1}^n x_i^{a_i} \frac1{\sqrt{2\pi}} e^{-\frac12 x_i^2}\right) \de^n\x. \]
Since each term in the product only depends on $x_i$, this is a separable integral that is the product of one-dimensional integrals:
\[ I^{g_n}_{a_1\ldots a_n} = \prod_{i=1}^n \int_\mathbb{R} x_i^{a_i} \frac1{\sqrt{2\pi}} e^{-\frac12 x_i^2} \de x_i 
 =  \prod_{i=1}^n I^{g_1}_{a_i}. \]
 
\section{Values of One-Dimensional Gaussian Integral $I^{g_1}_a$}
The one-dimensional Gaussian integrals can be evaluated by noting
\[ \dd{}{x}\left[ x^a \frac1{\sqrt{2\pi}} e^{-\frac12 x^2} \right] = (ax^{a-1}-x^{a+1}) \frac1{\sqrt{2\pi}} e^{-\frac12 x^2} \]
and therefore by integrating both sides over $\mathbb R$, 
\[ 0 = aI^{g_1}_{a-1} - I^{g_1}_{a+1}. \]
The recurrence of values can be started by noting $I^{g_1}_0=1$ because the Gaussian is normalised and $I^{g_1}_1=0$ because it is the integral of an odd function.  Writing the recurrence as $I^{g_1}_{a+2}=(a+1)I^{g_1}_a$ makes it clear that $I^{g_1}_a=0$ for $a$ odd.  For even values, 
\[ I^{g_1}_2 = 1,
\quad I^{g_1}_4 = 3,
\quad I^{g_1}_6 = 3\times5,
\quad I^{g_1}_8 = 3\times5\times7, \quad \cdots, \]
giving the general formula
\[ I^{g_1}_{2a} = \prod_{b=1}^a (2b-1) = (2a-1)!! = \frac{(2a)!}{2^a a!}. \]

\subsection{Integrals on the Half Real Line $I^{h_1}_a$}
The following calculations will also need 1D Gaussian integrals on the half real line defined by
\[ I^{h_1}_a =  \int_0^\infty x^a \frac1{\sqrt{2\pi}} e^{-\frac12 x^2} \de x. \]
Starting as before but integrating over $[0,\infty)$ gives
\[ \left[ x^a \frac1{\sqrt{2\pi}} e^{-\frac12 x^2} \right]_{x=0}^\infty = aI^{h_1}_{a-1} - I^{h_1}_{a+1}. \]
The left hand side is equal to $\frac{-1}{\sqrt{2\pi}}$ when $a=0$ and zero otherwise.  The recurrence can still be rewritten $I^{h_1}_{a+2}=(a+1)I^{h_1}_a$ valid for $a\ge0$.  The original $a=0$ case gives
\[ \frac{-1}{\sqrt{2\pi}} = -I^{h_1}_1 \qquad \Rightarrow \qquad I^{h_1}_1=\frac{1}{\sqrt{2\pi}}. \]
For even functions we have $I^{h_1}_{2a}=\frac12I^{g_1}_{2a}$ and in particular $I^{h_1}_0=\frac12$.  The recurrence gives the general formulae
\[ I^{h_1}_{2a}=\frac12(2a-1)!! \qquad \mbox{and} \qquad I^{h_1}_{2a+1}=\frac{1}{\sqrt{2\pi}}\prod_{b=1}^a 2b=\frac{1}{\sqrt{2\pi}}(2a)!!=\frac{1}{\sqrt{2\pi}}2^a a!. \]


\section{Relation of Gaussian to Spherical Integral}
The Gaussian integrand can also be split into parts that depend on radius $r=|\x|$ and parts that do not:
\[ I^{g_n}_{a_1\ldots a_n} = \int_{\mathbb{R}^n} \frac1{\sqrt{2\pi}^n} e^{-\frac12 r^2} r^{\sum a_i} \left(\prod_{i=1}^n \left(\frac{x_i}{r}\right)^{a_i}\right) \de^n\x. \]
Defining $\x=r\uv$ so that $\uv\in S_{n-1}$ gives $\de^n\x=r^{n-1}\de r\de^{n-1}\uv$ and
\begin{eqnarray*}
 I^{g_n}_{a_1\ldots a_n} &=& \int_0^\infty \frac1{\sqrt{2\pi}^n} e^{-\frac12 r^2} r^{\sum a_i} r^{n-1}\de r \int_{S_{n-1}} \left(\prod_{i=1}^n u_i^{a_i}\right) \de^{n-1}\uv \\
 &=& \frac1{\sqrt{2\pi}^{n-1}} I^{h_1}_{n-1+\sum a_i} I^{S_{n-1}}_{a_1\ldots a_n}.
\end{eqnarray*}

\section{Evaluating the Spherical Integral}
By the formula in the previous section,
\[ I^{S_{n-1}}_{a_1\ldots a_n} = \frac{\sqrt{2\pi}^{n-1} I^{g_n}_{a_1\ldots a_n}}{I^{h_1}_{n-1+\sum a_i}}. \]
The separability of the Gaussian integrals allows this to be written with only $I^{g_1}_a$ and $I^{h_1}_a$ terms:
\[ I^{S_{n-1}}_{a_1\ldots a_n} = \sqrt{2\pi}^{n-1} \frac{\prod_{i=1}^n I^{g_1}_{a_i}}{I^{h_1}_{n-1+\sum a_i}}. \]

\section{Evaluating the Ball Integral}
Integrating over a smaller sphere of radius $r$ will introduce a factor of $r^{n-1}$ from the change in surface area and a factor of $r^{\sum a_i}$ from the change in the monomial term itself.  Thus,
\[ I^{B_n}_{a_1\ldots a_n} = \int_0^1 r^{n-1+\sum a_i}  I^{S_{n-1}}_{a_1\ldots a_n} \de r = \frac1{n+\sum a_i} I^{S_{n-1}}_{a_1\ldots a_n}. \]
Using the formula from the previous section, this can be written in terms of $I^{g_1}_a$  and $I^{h_1}_a$:
\[ I^{B_n}_{a_1\ldots a_n} = \frac{\sqrt{2\pi}^{n-1}}{n+\sum a_i} \frac{\prod_{i=1}^n I^{g_1}_{a_i}}{I^{h_1}_{n-1+\sum a_i}}. \]

\end{document}