text:
# A New Geometric Probability Technique for an N-dimensional Sphere and Its Applications to Physics

## I Introduction

In a recent paper , geometric probability techniques were developed to calculate the probability density functions (PDFs) which describe the probability density of finding a distance $`s`$ separating two points distributed in a uniform $`3`$-dimensional sphere and in a uniform ellipsoid. Our focus in the present paper will be on the probability density functions $`P_n(s)`$ for an $`n`$-dimensional sphere of radius $`R`$ characterized by $`x_1^2+x_2^2+\mathrm{}+x_n^2R^2`$, where $`x_1`$, $`x_2`$, and $`x_n`$ are the corresponding Cartesian coordinates. (In the mathematical literature this is sometimes termed an $`n`$-dimensional ball). As discussed in Refs. , these results are of interest both as pure mathematics and as tools in mathematical physics. Specifically, it was demonstrated in Ref.  that geometric probability techniques greatly facilitate the calculation of the self-energies for spherical matter distributions arising from electromagnetic, gravitational, or weak interactions. The functional form of $`P_n(s)`$ is known for a sphere of uniform density, and hence the object of the present paper is to generalize the results of Refs.  to the case of an arbitrarily non-uniform density distribution by using our method. As an application of these results we will consider the neutrino-exchange contribution to the self-energy of a neutron star modeled as series of concentric shells of different constant density. Other applications will also be discussed.

In this paper we present a new technique for obtaining the analytical probability density function $`P_n(s)`$ for a sphere of $`n`$ dimensions having an arbitrary density distribution. To illustrate this technique, we begin by deriving the PDF, $`P_n(s)`$, for an $`n`$-dimensional uniform sphere of radius $`R`$, and compare our results to those obtained earlier by other means . We then extend this technique to an $`n`$-dimensional sphere with a non-uniform but spherically symmetric density distribution. We explicitly evaluate the analytical probability density functions for certain specific density distributions, and then use numerical Monte Carlo simulations to verify the analytical results.

Finally our formalism is generalized to an $`n`$-dimensional sphere with an arbitrary density distribution, and leads to a general-purpose master formula. This formula allows one to evaluate the PDF for a sphere in $`n`$ dimensions with an arbitrary density distribution. After verifying that the master formula reproduces the results for uniform and spherically symmetric density distributions, we analytically evaluate the probability density functions, for 2, 3, and 4-dimensional spheres having non-uniform density distributions. The analytical results are then verified by the use of Monte Carlo simulations. The outline of this paper is as follows. In Sec. II we present our new formalism and illustrate it by rederiving the well-known results for a circle and for a sphere of uniform density. In Sec. III we extend this formalism to the case of non-uniform but spherically symmetric density distributions. In Sec. IV we develop the formalism for the most general case of an arbitrary non-uniform density distribution. In Sec. V we present some applications of our formalism to physics. These include the $`m`$th moment $`s^m`$ for a sphere of uniform and Gaussian density distribution, Coulomb self-energy for a collection of charges, $`\nu \overline{\nu }`$-exchange interactions, obtaining the probability density functions for multiple-shell density distributions found in neutron star models , and the evaluation of some geometric probability constants .

## II Uniform density distributions

### A Theory for a uniform circle

In this section we illustrate our formalism by deriving the PDF for a circle of radius $`R`$ having a spatially uniform density distribution characterized by $`\rho =`$ constant. For two points randomly sampled inside the circle located at $`\stackrel{}{r}_1`$ and $`\stackrel{}{r}_2`$ measured from the center, define $`\stackrel{}{s}=\stackrel{}{s}(\stackrel{}{r}_1,\stackrel{}{r}_2)=\stackrel{}{r}_2\stackrel{}{r}_1`$ and $`s=\left|\stackrel{}{s}\right|`$. To simplify the discussion, we translate the center of the circle to the origin so that the equation for the circle is $`x^2+y^2=R^2`$. It is sufficient to initially consider those vectors $`\stackrel{}{s}`$ which are aligned in the positive $`\widehat{x}`$ direction, since rotational symmetry can eventually be used to extend our results to those vectors $`\stackrel{}{s}`$ with arbitrary orientations. We begin by identifying those pairs of points, $`\stackrel{}{r}_1`$ and $`\stackrel{}{r}_2`$, which satisfy $`\stackrel{}{s}=\stackrel{}{r}_2\stackrel{}{r}_1=s\widehat{x}`$, where $`0s2R`$. One set of points is obtained if the points 1 are uniformly located on a line $`L_1`$ given by $`x=s/2`$ and the corresponding points 2 are on a line $`L_2`$ given by $`x=+s/2`$ as shown in Fig. 1. Notice that $`x=\pm s/2`$ are two symmetric lines with respect to reflection about $`x=0`$. Another set of points is obtained if $`\stackrel{}{r}_1`$ is uniformly located in the area $`A_1`$ and $`\stackrel{}{r}_2`$ is located in the area $`A_2`$ as shown in Fig. 2(a). Note that $`A_1`$ and $`A_2`$ are congruent. The only remaining set of points that need to be considered are those for which $`\stackrel{}{r}_1`$ is uniformly located in the area $`A_3`$ while $`\stackrel{}{r}_2`$ is in the area $`A_4`$ as shown in Fig. 2(b). As before $`A_3`$ and $`A_4`$ are congruent. Furthermore, $`A_4`$ is a reflection of $`A_2`$ about $`x=s/2`$, while $`A_3`$ is a reflection of $`A_1`$ about $`x=s/2`$. As discussed in Appendix A, the union of $`A_2`$ and $`A_4`$ ($`A_2A_4`$) is the overlap area between the original circle $`C_0`$ and an identical circle $`C_1`$ whose center is shifted from $`(0,0)`$ to $`(\left|\stackrel{}{s}\right|,0)`$. Similarly, $`A_1A_3`$ is the overlap area between the original circle and an identical circle $`C_2`$ whose center is shifted from $`(0,0)`$ to $`(\left|\stackrel{}{s}\right|,0)`$ as shown in Fig. 3. Since $`A_1A_3`$ and $`A_2A_4`$ are identical, it follows that the probability of finding a given $`s=\left|s\widehat{x}\right|`$ in a uniform circle is proportional to

$$A_2A_4=_{\frac{s}{2}}^R𝑑x_{\sqrt{R^2x^2}}^{\sqrt{R^2x^2}}𝑑y+_{sR}^{\frac{s}{2}}𝑑x_{\sqrt{R^2(xs)^2}}^{\sqrt{R^2(xs)^2}}𝑑y.$$
(1)
Notice that

$`{\displaystyle _{\frac{s}{2}}^R}𝑑x{\displaystyle _{\sqrt{R^2x^2}}^{\sqrt{R^2x^2}}}𝑑y={\displaystyle _{sR}^{\frac{s}{2}}}𝑑x{\displaystyle _{\sqrt{R^2(xs)^2}}^{\sqrt{R^2(xs)^2}}}𝑑y.`$

Using rotational symmetry of $`C_0`$, this result can apply to any orientation of $`\stackrel{}{s}`$ between $`0`$ and $`2\pi `$, and hence the probability of finding a given $`s=\left|\stackrel{}{s}\right|`$ is proportional to $`|\stackrel{}{s}|_0^{2\pi }𝑑\varphi =2\pi s`$. We denote this PDF for a uniform circle by $`P_2(s)`$, and impose the normalization requirement

$$_0^{2R}P_2(s)𝑑s=1.$$
(2)
We then have

$`P_2(s)`$ $`=`$ $`{\displaystyle \frac{2\pi s\left(_{\frac{s}{2}}^R𝑑x_{\sqrt{R^2x^2}}^{\sqrt{R^2x^2}}𝑑y+_{sR}^{\frac{s}{2}}𝑑x_{\sqrt{R^2(xs)^2}}^{\sqrt{R^2(xs)^2}}𝑑y\right)}{_0^{2R}2\pi s\left(_{\frac{s}{2}}^R𝑑x_{\sqrt{R^2x^2}}^{\sqrt{R^2x^2}}𝑑y+_{sR}^{\frac{s}{2}}𝑑x_{\sqrt{R^2(xs)^2}}^{\sqrt{R^2(xs)^2}}𝑑y\right)𝑑s}}.`$ (3)
Equation (3) can be simplified to

$`P_2(s)`$ $`=`$ $`{\displaystyle \frac{s_{\frac{s}{2}}^R𝑑x_{\sqrt{R^2x^2}}^{\sqrt{R^2x^2}}𝑑y}{_0^{2R}\left(s_{\frac{s}{2}}^R𝑑x_{\sqrt{R^2x^2}}^{\sqrt{R^2x^2}}𝑑y\right)𝑑s}}`$ (4)
$`=`$ $`{\displaystyle \frac{2s}{R^2}}{\displaystyle \frac{s^2}{\pi R^4}}\sqrt{4R^2s^2}{\displaystyle \frac{4s}{\pi R^2}}\mathrm{sin}^1\left({\displaystyle \frac{s}{2R}}\right).`$ (5)
Equation (5) is identical to the results obtained in Refs.  by other means.

The conclusion that emerges from this formalism is that the probability of finding two random points separated by a vector $`\stackrel{}{s}`$ in a uniform circle can be derived by simply calculating the overlap region of that circle with an identical circle obtained by shifting the center from the origin to $`\stackrel{}{s}`$. In the following sections, we show that this result generalizes to higher dimensions, and provides a simple way of calculating $`P_n(s)`$ for $`n3`$.

### B Theory for a uniform sphere

The above formalism for a $`2`$-dimensional uniform circle can be extended to a $`3`$-dimensional uniform sphere with radius $`R`$. For a given $`s`$, we arbitrarily select the positive $`\widehat{z}`$ direction and study the distribution of vectors $`\stackrel{}{s}=\stackrel{}{r}_2\stackrel{}{r}_1`$ in this direction. The areas $`A_1`$, $`A_2`$, $`A_3`$, and $`A_4`$ in Sec. II A are replaced by the volumes $`V_1`$, $`V_2`$, $`V_3`$, and $`V_4`$. The PDF $`P_3(s)`$ is therefore proportional to the overlap volume $`V_1V_3=V_2V_4`$, where

$$V_2V_4=_{\frac{s}{2}}^R𝑑z_{\sqrt{R^2z^2}}^{\sqrt{R^2z^2}}𝑑x_{\sqrt{R^2z^2x^2}}^{\sqrt{R^2z^2x^2}}𝑑y+_{sR}^{\frac{s}{2}}𝑑z_{\sqrt{R^2(zs)^2}}^{\sqrt{R^2(zs)^2}}𝑑x_{\sqrt{R^2(zs)^2x^2}}^{\sqrt{R^2(zs)^2x^2}}𝑑y.$$
(6)
Notice that

$$_{\frac{s}{2}}^R𝑑z_{\sqrt{R^2z^2}}^{\sqrt{R^2z^2}}𝑑x_{\sqrt{R^2z^2x^2}}^{\sqrt{R^2z^2x^2}}𝑑y=_{sR}^{\frac{s}{2}}𝑑z_{\sqrt{R^2(zs)^2}}^{\sqrt{R^2(zs)^2}}𝑑x_{\sqrt{R^2(zs)^2x^2}}^{\sqrt{R^2(zs)^2x^2}}𝑑y.$$
(7)
In a $`3`$-dimensional space, $`\stackrel{}{s}`$ can range from $`0`$ to $`\pi `$ in the $`\widehat{\theta }`$ direction, and from $`0`$ to $`2\pi `$ in the $`\widehat{\varphi }`$ direction. For a given $`s`$ with any orientation, the PDF $`P_3(s)`$ is also proportional to $`4\pi s^2`$ by using rotational symmetry of a uniform sphere. Following the previous discussion, we thus arrive at the following expression for the PDF for a uniform sphere:

$`P_3(s)`$ $`=`$ $`{\displaystyle \frac{4\pi s^2\left(_{\frac{s}{2}}^R𝑑z_{\sqrt{R^2z^2}}^{\sqrt{R^2z^2}}𝑑x_{\sqrt{R^2z^2x^2}}^{\sqrt{R^2z^2x^2}}𝑑y\right)}{_0^{2R}4\pi s^2\left(_{\frac{s}{2}}^R𝑑z_{\sqrt{R^2z^2}}^{\sqrt{R^2z^2}}𝑑x_{\sqrt{R^2z^2x^2}}^{\sqrt{R^2z^2x^2}}𝑑y\right)𝑑s}}`$ (8)
$`=`$ $`3{\displaystyle \frac{s^2}{R^3}}{\displaystyle \frac{9}{4}}{\displaystyle \frac{s^3}{R^4}}+{\displaystyle \frac{3}{16}}{\displaystyle \frac{s^5}{R^6}}.`$ (9)
The result in Eq. (9) agrees exactly with the expression obtained previously in Refs. .

### C Representations , general properties, recursion relations, and generating functions of $`P_n(s)`$

The present formalism can be readily generalized to obtain $`P_n(s)`$ for an $`n`$-dimensional sphere ($`n`$-sphere or $`n`$-ball) of radius $`R`$. From Eqs. (4) and (8) we find

$$P_n(s)=\frac{s^{n1}_{\frac{s}{2}}^R𝑑x_n_{\sqrt{R^2x_n^2}}^{\sqrt{R^2x_n^2}}𝑑x_1_{\sqrt{R^2x_n^2x_1^2}}^{\sqrt{R^2x_n^2x_1^2}}𝑑x_2\mathrm{}_{\sqrt{R^2x_n^2\mathrm{}x_{n2}^2}}^{\sqrt{R^2x_n^2\mathrm{}x_{n2}^2}}𝑑x_{n1}}{_0^{2R}\left(s^{n1}_{\frac{s}{2}}^R𝑑x_n_{\sqrt{R^2x_n^2}}^{\sqrt{R^2x_n^2}}𝑑x_1_{\sqrt{R^2x_n^2x_1^2}}^{\sqrt{R^2x_n^2x_1^2}}𝑑x_2\mathrm{}_{\sqrt{R^2x_n^2\mathrm{}x_{n2}^2}}^{\sqrt{R^2x_n^2\mathrm{}x_{n2}^2}}𝑑x_{n1}\right)𝑑s}.$$
(10)
We can rewrite Eq. (10) as

$$P_n(s)=\frac{s^{n1}_{\frac{s}{2}}^R𝑑x_n_{\overline{R}}^{\overline{R}}𝑑x_1_{\sqrt{\overline{R}^2x_1^2}}^{\sqrt{\overline{R}^2x_1^2}}𝑑x_2\mathrm{}_{\sqrt{\overline{R}^2x_1^2\mathrm{}x_{n2}^2}}^{\sqrt{\overline{R}^2x_1^2\mathrm{}x_{n2}^2}}𝑑x_{n1}}{_0^{2R}\left(s^{n1}_{\frac{s}{2}}^R𝑑x_n_{\overline{R}}^{\overline{R}}𝑑x_1_{\sqrt{\overline{R}^2x_1^2}}^{\sqrt{\overline{R}^2x_1^2}}𝑑x_2\mathrm{}_{\sqrt{\overline{R}^2x_1^2\mathrm{}x_{n2}^2}}^{\sqrt{\overline{R}^2x_1^2\mathrm{}x_{n2}^2}}𝑑x_{n1}\right)𝑑s},$$
(11)
where

$$\overline{R}=\sqrt{R^2x_n^2}.$$
(12)
As shown in Refs. , the volume $`V(n,R)`$ of an $`n`$-dimensional sphere of radius $`R`$ is given by

$$V(n,R)=_R^R𝑑x_1_{\sqrt{R^2x_1^2}}^{\sqrt{R^2x_1^2}}𝑑x_2\mathrm{}_{\sqrt{R^2x_1^2x_2^2\mathrm{}x_{n1}^2}}^{\sqrt{R^2x_1^2x_2^2\mathrm{}x_{n1}^2}}𝑑x_n=\frac{\pi ^{\frac{n}{2}}R^n}{\mathrm{\Gamma }\left(1+\frac{n}{2}\right)}.$$
(13)
Equations. (10) and (11) can then be reduced to a general simplified equation for an $`n`$-dimensional uniform sphere of radius $`R`$:

$`P_n(s)`$ $`=`$ $`{\displaystyle \frac{s^{n1}_{\frac{s}{2}}^R\frac{\pi ^{\frac{n1}{2}}}{\mathrm{\Gamma }\left(1+\frac{n1}{2}\right)}\left(\sqrt{R^2x_n^2}\right)^{\left(n1\right)}𝑑x_n}{_0^{2R}\left[s^{n1}_{\frac{s}{2}}^R\frac{\pi ^{\frac{n1}{2}}}{\mathrm{\Gamma }\left(1+\frac{n1}{2}\right)}\left(\sqrt{R^2x_n^2}\right)^{\left(n1\right)}𝑑x_n\right]𝑑s}}`$ (14)
$`=`$ $`{\displaystyle \frac{s^{n1}_{\frac{s}{2}}^R\left(R^2x^2\right)^{\frac{n1}{2}}𝑑x}{_0^{2R}\left[s^{n1}_{\frac{s}{2}}^R\left(R^2x^2\right)^{\frac{n1}{2}}𝑑x\right]𝑑s}}.`$ (15)
If $`n`$ is an even number,

$$P_n(s)=n\times \frac{s^{n1}}{R^n}\left[\frac{2}{\pi }\mathrm{cos}^1\left(\frac{s}{2R}\right)\frac{s}{\pi }\underset{k=1}{\overset{\frac{n}{2}}{}}\frac{(n2k)!!}{(n2k+1)!!}\left(R^2\frac{s^2}{4}\right)^{\frac{n2k+1}{2}}R^{2k2n}\right],$$
(16)
where $`0!=0!!=1`$. If $`n`$ is an odd number,

$$P_n(s)=n\times \frac{s^{n1}}{R^n}\frac{n!!}{(n1)!!}\underset{k=0}{\overset{\frac{n1}{2}}{}}\frac{(1)^k}{2k+1}\frac{\left(\frac{n1}{2}\right)!}{k!\left(\frac{n1}{2}k\right)!}\left[1\left(\frac{s}{2R}\right)^{2k+1}\right].$$
(17)
Using Eqs. (16) and (17) the explicit functional forms of $`P_n(s)`$ for $`n=2`$, $`3`$, $`4`$, and $`5`$ are as follows:

$`P_2(s)`$ $`=`$ $`{\displaystyle \frac{4}{\pi }}{\displaystyle \frac{s}{R^2}}\mathrm{cos}^1\left({\displaystyle \frac{s}{2R}}\right){\displaystyle \frac{2}{\pi }}{\displaystyle \frac{s^2}{R^3}}\left(1{\displaystyle \frac{s^2}{4R^2}}\right)^{1/2},`$ (18)
$`P_4(s)`$ $`=`$ $`{\displaystyle \frac{8}{\pi }}{\displaystyle \frac{s^3}{R^4}}\mathrm{cos}^1\left({\displaystyle \frac{s}{2R}}\right){\displaystyle \frac{8}{3\pi }}{\displaystyle \frac{s^4}{R^5}}\left(1{\displaystyle \frac{s^2}{4R^2}}\right)^{3/2}{\displaystyle \frac{4}{\pi }}{\displaystyle \frac{s^4}{R^5}}\left(1{\displaystyle \frac{s^2}{4R^2}}\right)^{1/2},`$ (19)
$`P_3(s)`$ $`=`$ $`3{\displaystyle \frac{s^2}{R^3}}{\displaystyle \frac{9}{4}}{\displaystyle \frac{s^3}{R^4}}+{\displaystyle \frac{3}{16}}{\displaystyle \frac{s^5}{R^6}},`$ (20)
$`P_5(s)`$ $`=`$ $`5{\displaystyle \frac{s^4}{R^5}}{\displaystyle \frac{75}{16}}{\displaystyle \frac{s^5}{R^6}}+{\displaystyle \frac{25}{32}}{\displaystyle \frac{s^7}{R^8}}{\displaystyle \frac{15}{256}}{\displaystyle \frac{s^9}{R^{10}}}.`$ (21)
The Monte Carlo results for $`n4`$, and the simulation techniques for producing random points uniformly inside an $`n`$-sphere will be presented elsewhere .

It is of interest to verify that Eq. (15), obtained via the present formalism, agrees with results obtained earlier by other means . This is most easily done by introducing the the function $`C(a;m,n)`$ defined by

$$C(a;m,n)=_0^as^mT_n(s)𝑑s=_0^as^{m+n1}Q_n(s)𝑑s=_0^as^{m+n1}𝑑s_{\frac{s}{2}}^R\left(R^2x^2\right)^{\frac{n1}{2}}𝑑x,$$
(22)
where

$`Q_n(s)`$ $`=`$ $`{\displaystyle _{\frac{s}{2}}^R}\left(R^2x^2\right)^{\frac{n1}{2}}𝑑x,`$ (23)
$`T_n(s)`$ $`=`$ $`s^{n1}{\displaystyle _{\frac{s}{2}}^R}\left(R^2x^2\right)^{\frac{n1}{2}}𝑑x.`$ (24)
It follows that the denominator of Eq. (15), which is the normalization constant, can be written as $`C(2R;\mathrm{\hspace{0.17em}0},n)`$ where

$`C(2R;\mathrm{\hspace{0.17em}0},n)`$ $`=`$ $`{\displaystyle _0^{2R}}T_n(s)𝑑s.`$ (25)
When $`n`$ is an even integer, $`C(2R;\mathrm{\hspace{0.17em}0},n)`$ can be expressed in terms of the gamma and beta functions by noting that

$$C(2R;\mathrm{\hspace{0.17em}0},n)=\frac{\pi }{2n}\frac{(n1)!!}{n!!}R^{2n}=\frac{1}{2n}\frac{\mathrm{\Gamma }\left(\frac{1}{2}\right)\mathrm{\Gamma }\left(\frac{n}{2}+\frac{1}{2}\right)}{\mathrm{\Gamma }\left(\frac{n}{2}+1\right)}R^{2n}=\frac{1}{2n}B(\frac{n}{2}+\frac{1}{2},\frac{1}{2})R^{2n}.$$
(26)
Similarly, when $`n`$ is an odd integer,

$$C(2R;\mathrm{\hspace{0.17em}0},n)=\frac{1}{n}\frac{(n1)!!}{n!!}R^{2n}=\frac{1}{2n}B(\frac{n}{2}+\frac{1}{2},\frac{1}{2})R^{2n}.$$
(27)
We thus find that the normalization constant has the same functional form irrespective of whether $`n`$ is even or odd, when expressed in terms of the beta function.

If we introduce the variable $`t=R^2x^2`$ and note that

$$Q_n(s)=\frac{R^n}{2}B_{1\frac{s^2}{4R^2}}(\frac{n}{2}+\frac{1}{2},\frac{1}{2})=\frac{R^n}{2}B(\frac{n}{2}+\frac{1}{2},\frac{1}{2})I_{1\frac{s^2}{4R^2}}(\frac{n}{2}+\frac{1}{2},\frac{1}{2}),$$
(28)
we can then rewrite $`P_n(s)`$ in the form

$`P_n(s)`$ $`=`$ $`n{\displaystyle \frac{s^{n1}}{R^n}}{\displaystyle \frac{B_x(\frac{n}{2}+\frac{1}{2},\frac{1}{2})}{B(\frac{n}{2}+\frac{1}{2},\frac{1}{2})}}`$ (29)
$`=`$ $`n{\displaystyle \frac{s^{n1}}{R^n}}I_x({\displaystyle \frac{n}{2}}+{\displaystyle \frac{1}{2}},{\displaystyle \frac{1}{2}}),`$ (30)
where

$$x=1\frac{s^2}{4R^2}.$$
(31)
$`B_x(p,q)`$ is the incomplete beta function defined by

$$B_x(p,q)=_0^xt^{p1}\left(1t\right)^{q1}𝑑t,$$
(32)
and $`I_x`$ is the normalized incomplete beta function defined by

$$I_x(p,q)=\frac{\mathrm{\Gamma }\left(p+q\right)}{\mathrm{\Gamma }\left(p\right)\mathrm{\Gamma }\left(q\right)}_0^xt^{p1}\left(1t\right)^{q1}𝑑t=\frac{B_x(p,q)}{B(p,q)}.$$
(33)
Eq. (30) is the expression for $`P_n(s)`$ obtained in Refs. , and hence we have demonstrated that the classical results can be reproduced by using the formalism developed here.

We find the following general properties of $`P_n(s)`$ and its derivative $`P_n^{}(s)`$ at the lower bound $`s=0`$ and at the upper bound $`s=2R`$: $`P_1(0)=1/R`$, $`P_n(0)=0`$ for $`n2`$, $`P_n(2R)=0`$, $`P_1^{}(0)=1/2R^2`$, $`P_2^{}(0)=2/R^2`$, $`P_n^{}(0)=0`$ for $`n3`$, $`P_1^{}(2R)=1/2R^2`$, and $`P_n^{}(2R)=0`$ for $`n2`$.

It is of interest to express the probability density functions $`P_n(s)`$ in terms of generating functions from which several representations and recursion relations for $`P_n(s)`$ can be derived. This can be achieved by observing that

$$B_x(\frac{n}{2}+\frac{1}{2},\frac{1}{2})=\frac{1}{n!}\left(\frac{}{h}\right)^nF(h=0,x),$$
(34)
where

$$F(h,x)=\frac{2}{\sqrt{1h^2}}\left[\mathrm{sin}^1(h)\mathrm{sin}^1\left(\frac{h\sqrt{x}}{1h\sqrt{x}}\right)\right],$$
(35)
and where $`0x1`$ and $`1h1`$. Similarly, $`Q_n(s)`$ in Eq. (23) can be defined in terms of a generating function $`F_1(h,s)`$ of the form

$$F_1(h,s)=\underset{n=0}{\overset{\mathrm{}}{}}Q_n(s)h^n=\frac{1}{\sqrt{1h^2R^2}}\left[\mathrm{sin}^1(hR)\mathrm{sin}^1\left(\frac{hR\sqrt{1\frac{s^2}{4R^2}}}{1hR\sqrt{1\frac{s^2}{4R^2}}}\right)\right],$$
(36)
where $`\left|hR\right|<1`$. $`Q_n(s)`$ is then given by

$$Q_n(s)=\frac{1}{n!}\left(\frac{}{h}\right)^nF_1(h=0,s).$$
(37)
$`T_n(s)`$ in Eq. (24) can also be defined in terms of a generating function $`F_2(h,s)`$,

$$F_2(h,s)=\underset{n=0}{\overset{\mathrm{}}{}}T_n(s)h^n=\left(\frac{1}{s}\right)\frac{1}{\sqrt{1h^2R^2s^2}}\left[\mathrm{sin}^1(hRs)\mathrm{sin}^1\left(\frac{hRs\sqrt{1\frac{s^2}{4R^2}}}{1hRs\sqrt{1\frac{s^2}{4R^2}}}\right)\right],$$
(38)
where $`\left|hRs\right|<1`$. $`T_n(s)`$ is then given by

$$T_n(s)=\frac{1}{n!}\left(\frac{}{h}\right)^nF_2(h=0,s).$$
(39)
It follows from the previous results that $`P_n(s)`$ can be expressed in terms of two unique elementary functions, $`F_1(h,s)`$ in Eq. (36) and $`F_2(h,s)`$ in Eq. (38), such that

$$P_n(s)=\frac{\frac{1}{n!}\left(\frac{}{h}\right)^nF_2(h=0,s)}{\frac{1}{2n}B(\frac{n}{2}+\frac{1}{2},\frac{1}{2})R^{2n}}=\frac{s^{n1}\frac{1}{n!}\left(\frac{}{h}\right)^nF_1(h=0,s)}{\frac{1}{2n}B(\frac{n}{2}+\frac{1}{2},\frac{1}{2})R^{2n}}.$$
(40)
It is convenient to summarize the different expressions we have obtained for the PDF of a uniform $`n`$-dimensional sphere with radius $`R`$:

1. Integral representation:

$$P_n(s)=\frac{s^{n1}_{\frac{s}{2}}^R\left(R^2x^2\right)^{\frac{n1}{2}}𝑑x}{\frac{1}{2n}B(\frac{n}{2}+\frac{1}{2},\frac{1}{2})R^{2n}},$$
(41)
2. Normalized incomplete beta function representation:

$$P_n(s)=n\frac{s^{n1}}{R^n}I_{1\frac{s^2}{4R^2}}(\frac{n}{2}+\frac{1}{2},\frac{1}{2}),$$
(42)
3. Incomplete beta function representation:

$$P_n(s)=n\frac{s^{n1}B_{1\frac{s^2}{4R^2}}(\frac{n}{2}+\frac{1}{2},\frac{1}{2})}{B(\frac{n}{2}+\frac{1}{2},\frac{1}{2})R^n},$$
(43)
4. Odd-integer finite series expansion representation ($`n=`$ odd):

$$P_n(s)=n\times \frac{s^{n1}}{R^n}\frac{n!!}{(n1)!!}\underset{i=0}{\overset{\frac{n1}{2}}{}}\frac{(1)^i}{2i+1}\frac{\left(\frac{n1}{2}\right)!}{i!\left(\frac{n1}{2}i\right)!}\left[1\left(\frac{s}{2R}\right)^{2i+1}\right],$$
(44)
5. Even-integer finite series expansion representation ($`n=`$ even):

$$P_n(s)=n\times \frac{s^{n1}}{R^n}\left[\frac{2}{\pi }\mathrm{cos}^1\left(\frac{s}{2R}\right)\frac{s}{\pi }\underset{i=1}{\overset{\frac{n}{2}}{}}\frac{(n2i)!!}{(n2i+1)!!}\left(R^2\frac{s^2}{4}\right)^{\frac{n2i+1}{2}}R^{2i2n}\right],$$
(45)
6. Infinite series expansion representation:

$$P_n(s)=\frac{s^{n1}_{i=0}^{\mathrm{}}\left(1\right)^i\frac{2^i}{2i+1}\frac{\left(2i1\right)!!}{\left(2i\right)!!}\frac{\left(\frac{n1}{2}\right)!}{\left(\frac{n1}{2}i\right)!}\left[1\left(\frac{s}{2R}\right)^{2i+1}\right]}{\frac{1}{2n}B(\frac{n}{2}+\frac{1}{2},\frac{1}{2})R^n},$$
(46)
7. Generating function representation I:

$`P_n(s)`$ $`=`$ $`{\displaystyle \frac{\frac{1}{n!}\left(\frac{}{h}\right)_{h=0}^n\left\{\left(\frac{1}{s}\right)\frac{1}{\sqrt{1h^2R^2s^2}}\left[\mathrm{sin}^1(hRs)\mathrm{sin}^1\left(\frac{hRs\sqrt{1\frac{s^2}{4R^2}}}{1hRs\sqrt{1\frac{s^2}{4R^2}}}\right)\right]\right\}}{\frac{1}{2n}B(\frac{n}{2}+\frac{1}{2},\frac{1}{2})R^{2n}}},`$ (47)
8. Generating function representation II:

$$P_n(s)=\frac{s^{n1}\frac{1}{n!}\left(\frac{}{h}\right)_{h=0}^n\left\{\frac{1}{\sqrt{1h^2R^2}}\left[\mathrm{sin}^1(hR)\mathrm{sin}^1\left(\frac{hR\sqrt{1\frac{s^2}{4R^2}}}{1hR\sqrt{1\frac{s^2}{4R^2}}}\right)\right]\right\}}{\frac{1}{2n}B(\frac{n}{2}+\frac{1}{2},\frac{1}{2})R^{2n}},$$
(48)
9. Hypergeometric function representation:

$$P_n(s)=\frac{2n}{B(\frac{n}{2}+\frac{1}{2},\frac{1}{2})}\frac{s^{n1}}{R^{n+1}}\left[R_2F_1(\frac{1}{2},\frac{1}{2}\frac{n}{2};\frac{3}{2};1)\frac{s}{2}_2F_1(\frac{1}{2},\frac{1}{2}\frac{n}{2};\frac{3}{2};\frac{s^2}{4R^2})\right],$$
(49)
where

$$\left(R^2x^2\right)^{\frac{n1}{2}}𝑑x=R^{n1}x_2F_1(\frac{1}{2},\frac{1}{2}\frac{n}{2};\frac{3}{2};\frac{x^2}{R^2}),$$
(50)
and

$`y(x)`$ $``$ $`{}_{2}{}^{}F_{1}^{}(a,b;c;x)`$ (51)
$`=`$ $`1+{\displaystyle \frac{ab}{c}}{\displaystyle \frac{x}{1!}}+{\displaystyle \frac{a(a+1)b(b+1)}{c(c+1)}}{\displaystyle \frac{x^2}{2!}}+{\displaystyle \frac{a(a+1)(a+2)b(b+1)(b+2)}{c(c+1)(c+2)}}{\displaystyle \frac{x^3}{3!}}+\mathrm{},`$ (52)
is one of the solutions for the hypergeometric equation

$$x(1x)y^{\prime \prime }(x)+\left[c(a+b+1)x\right]y^{}(x)aby(x)=0.$$
(53)

Using the previous results one can obtain a number of identities and recursion relations for the probability density functions $`P_n(s)`$, as we discuss in Appendix B.

## III Spherically symmetric density distributions

In this section we generalize the previous results to the case of an $`n`$-dimensional sphere of radius $`R`$ with a variable (but spherically symmetric) density distribution of the form $`\rho =\rho (r)`$, where $`r=\sqrt{x_1^2+x_2^2+\mathrm{}x_n^2}`$ is measured from the center and

$`x_1^2+x_2^2+\mathrm{}+x_n^2R^2.`$

As before we begin with the example of a circle ($`n=2`$) and generalize to a sphere ($`n3`$) later. Following the derivation presented in the previous section, the positive $`\widehat{x}`$ direction is chosen to specify the distribution of those $`\stackrel{}{s}`$ vectors that are aligned along the positive $`\widehat{x}`$ direction. At this stage we must consider the differences between uniform and non-uniform density distributions. For a given $`s,`$ if point $`2`$ carries the density information $`\rho (x,y)`$, then point $`1`$ should have the density information $`\rho (xs,y).`$ It follows that to incorporate the effects of a spherically symmetric density distribution the following substitution should be made:

$$\rho (\stackrel{}{r}_2)\times \rho (\stackrel{}{r}_1)\rho (x,y)\times \rho (xs,y).$$
(54)
Since the density distributions considered are spherically symmetric, the probability of finding a given $`s`$ in any orientation is still proportional to $`2\pi s.`$ The PDF $`P_2(s)`$ can then be expressed in the form

$$P_2(s)=\frac{n_d(s)\times \left(n_1(s)+n_2(s)\right)}{_0^{2R}n_d(s)\times \left(n_1(s)+n_2(s)\right)𝑑s},$$
(55)
where

$`n_d(s)`$ $`=`$ $`2\pi s,`$ (56)
$`n_1(s)`$ $`=`$ $`{\displaystyle _{sR}^{\frac{s}{2}}}𝑑x{\displaystyle _{\sqrt{R^2(xs)^2}}^{\sqrt{R^2(xs)^2}}}\rho (x,y)\times \rho (xs,y)𝑑y,`$ (57)
$`n_2(s)`$ $`=`$ $`{\displaystyle _{\frac{s}{2}}^R}𝑑x{\displaystyle _{\sqrt{R^2x^2}}^{\sqrt{R^2x^2}}}\rho (x,y)\times \rho (xs,y)𝑑y.`$ (58)
Substituting $`xs=x^{}`$ and using $`\rho (x,y)=\rho (x,y)`$ it can be shown that $`n_1(s)=n_2(s).`$ The expression for $`P_2(s)`$ can then be simplified to read

$`P_2(s)`$ $`=`$ $`{\displaystyle \frac{s_{\frac{s}{2}}^R𝑑x_{\sqrt{R^2x^2}}^{\sqrt{R^2x^2}}\rho (x,y)\times \rho (xs,y)𝑑y}{_0^{2R}\left(s_{\frac{s}{2}}^R𝑑x_{\sqrt{R^2x^2}}^{\sqrt{R^2x^2}}\rho (x,y)\times \rho (xs,y)𝑑y\right)𝑑s}}.`$ (59)
The formalism leading to Eq. (59) can be extended to a $`3`$-dimensional sphere of radius $`R`$. For a given $`s`$, the $`z`$-axis is chosen arbitrarily as our reference axis to examine the distribution of those $`\stackrel{}{s}`$ vectors that are aligned along the positive $`\widehat{z}`$ direction. If the density at point $`2`$ is $`\rho (x,y,z),`$ then the density at point $`1`$ will be $`\rho (x,y,zs).`$ In analogy with the $`2`$-dimensional case discussed above, the expression in Eq. (54) must be replaced by

$$\rho (\stackrel{}{r}_2)\times \rho (\stackrel{}{r}_1)=\rho (x,y,z)\times \rho (x,y,zs).$$
(60)
Since the density distributions considered here are spherically symmetric, the probability of finding a given $`s`$ in any orientation is proportional to $`4\pi s^2`$. Hence $`P_3(s)`$ can be expressed as

$`P_3(s)`$ $`=`$ $`{\displaystyle \frac{s^2_{\frac{s}{2}}^R𝑑z_{\sqrt{R^2z^2}}^{\sqrt{R^2z^2}}𝑑x_{\sqrt{R^2z^2x^2}}^{\sqrt{R^2z^2x^2}}\rho (x,y,z)\times \rho (x,y,zs)𝑑y}{_0^{2R}\left(s^2_{\frac{s}{2}}^R𝑑z_{\sqrt{R^2z^2}}^{\sqrt{R^2z^2}}𝑑x_{\sqrt{R^2z^2x^2}}^{\sqrt{R^2z^2x^2}}\rho (x,y,z)\times \rho (x,y,zs)𝑑y\right)𝑑s}}`$ (61)
$`=`$ $`{\displaystyle \frac{s^2_{\frac{s}{2}}^R𝑑x_3_{\sqrt{R^2x_3^2}}^{\sqrt{R^2x_3^2}}𝑑x_1_{\sqrt{R^2x_3^2x_1^2}}^{\sqrt{R^2x_3^2x_1^2}}𝑑x_2\rho (x_1,x_2,x_3)\rho (x_1,x_2,x_3^{})}{_0^{2R}s^2𝑑s_{\frac{s}{2}}^R𝑑x_3_{\sqrt{R^2x_3^2}}^{\sqrt{R^2x_3^2}}𝑑x_1_{\sqrt{R^2x_3^2x_1^2}}^{\sqrt{R^2x_3^2x_1^2}}𝑑x_2\rho (x_1,x_2,x_3)\rho (x_1,x_2,x_3^{})}},`$ (62)
where $`x_3^{}=x_3s`$.

Up to this point our discussion has been completely general. To continue we next evaluate $`P_3(s)`$ for a $`3`$-dimensional sphere of radius $`R`$ using two different spherically symmetric density distributions. Consider first

$$\rho (r)=\frac{5N}{4\pi R^5}r^2,$$
(63)
where $`N=4\pi _0^Rr^2\rho (r)𝑑r`$, and $`r`$ is measured from the center of the spherical distribution. Combining Eqs. (62) and (63) we find

$$P_3(s)=\frac{25}{7}\frac{s^2}{R^3}\frac{25}{4}\frac{s^3}{R^4}+5\frac{s^4}{R^5}\frac{25}{16}\frac{s^5}{R^6}+\frac{5}{448}\frac{s^9}{R^{10}}.$$
(64)
A plot of Eq. (64) when $`R=1`$, along with the corresponding Monte Carlo results, is shown in Fig. 4. The second spherically symmetric distribution we consider is

$$\rho (r)=\frac{N}{4\pi \left(\frac{1}{3}\frac{\alpha }{5}\right)R^3}\left[1\alpha \left(\frac{r}{R}\right)^2\right],$$
(65)
where $`N=4\pi _0^Rr^2\rho (r)𝑑r`$, $`0\alpha 1`$, and $`r`$ is measured from the center. Combining Eqs. (62) and (65) we find

$`P_3(s)`$ $`=`$ $`{\displaystyle \frac{15(3542\alpha +15\alpha ^2)s^2}{7(53\alpha )^2R^3}}{\displaystyle \frac{225(1\alpha )^2s^3}{4(53\alpha )^2R^4}}{\displaystyle \frac{15\alpha s^4}{(53\alpha )R^5}}`$ (67)
$`+{\displaystyle \frac{75(1+6\alpha 3\alpha ^2)s^5}{16(53\alpha )^2R^6}}{\displaystyle \frac{15\alpha s^7}{8(53\alpha )^2R^8}}+{\displaystyle \frac{45\alpha ^2s^9}{448(53\alpha )^2R^{10}}}.`$
A plot of Eq. (67) when $`R=\alpha =1`$ is shown in Fig. 5, along with the corresponding Monte Carlo results.

A general formula for the probability density function for an $`n`$-dimensional sphere with radius $`R`$ having a spherically symmetric density distribution can be derived from the previous results. We find

$$P_n(s)=\frac{s^{n1}_{\frac{s}{2}}^R𝑑x_n_{\sqrt{R^2x_n^2}}^{\sqrt{R^2x_n^2}}𝑑x_1\mathrm{}\mathrm{}_{\sqrt{R^2x_n^2x_1^2\mathrm{}x_{n1}^2}}^{\sqrt{R^2x_n^2x_1^2\mathrm{}x_{n1}^2}}\rho \left(𝐗\right)\rho \left(𝐗^{}\right)𝑑x_{n1}}{_0^{2R}\left[s^{n1}_{\frac{s}{2}}^R𝑑x_n_{\sqrt{R^2x_n^2}}^{\sqrt{R^2x_n^2}}𝑑x_1\mathrm{}\mathrm{}_{\sqrt{R^2x_n^2x_1^2\mathrm{}x_{n1}^2}}^{\sqrt{R^2x_n^2x_1^2\mathrm{}x_{n1}^2}}\rho \left(𝐗\right)\rho \left(𝐗^{}\right)𝑑x_{n1}\right]𝑑s},$$
(68)
where

$`\rho (𝐗)`$ $`=`$ $`\rho (x_1,x_2,x_3,\mathrm{}\mathrm{},x_n),`$ (69)
$`\rho (𝐗^{})`$ $`=`$ $`\rho (x_1,x_2,x_3,\mathrm{}\mathrm{},x_ns).`$ (70)
Another density distribution we wish to study is a Gaussian. As an example, consider the case of an $`n`$-dimensional sphere of radius $`R\mathrm{}`$ with a Gaussian density distribution $`\rho (r)`$ given by

$$\rho _n(r)=\frac{N}{(2\pi )^{\frac{n}{2}}\sigma ^n}e^{\frac{1}{2}\frac{r^2}{\sigma ^2}},$$
(71)
where

$$N=\underset{R\mathrm{}}{lim}n\frac{\pi ^{\frac{n}{2}}}{\mathrm{\Gamma }\left(\frac{n}{2}+1\right)}_0^R\rho _n(r)r^{n1}𝑑r.$$
(72)
In Eq. (72) $`r`$ is measured from the center of the spherical distribution and the integral is over all space. Recall that

$`{\displaystyle _0^{\mathrm{}}}x^ne^{\frac{x^2}{2\sigma ^2}}𝑑x`$ $`=`$ $`2^{\frac{n1}{2}}\mathrm{\Gamma }\left({\displaystyle \frac{n+1}{2}}\right)\sigma ^{n+1}.`$ (73)
Combining Eqs. (71) and (73), the PDF for an $`n`$-dimensional sphere in an infinite space with a Gaussian density distribution can be expressed as

$$P_n(s)=\underset{R\mathrm{}}{lim}\frac{s^{n1}e^{\frac{s^2}{4\sigma ^2}}}{_0^{2R}s^{n1}e^{\frac{s^2}{4\sigma ^2}}𝑑s}=\frac{1}{2^{n1}\mathrm{\Gamma }\left(\frac{n}{2}\right)\sigma ^n}s^{n1}e^{\frac{s^2}{4\sigma ^2}}.$$
(74)
For $`n=3`$, Eq. (74) agrees with the result obtained earlier in Ref. . Finally, we note that the maximum probability, denoted by $`S_{max}`$, occurs at

$$S_{max}=\sqrt{2(n1)}\sigma .$$
(75)
## IV Arbitrary density distributions

We consider in this section the probability density functions for an $`n`$-dimensional sphere of radius $`R`$ having an arbitrary density distribution,

$$\rho =\rho (𝐗)=\rho (x_1,x_2,\mathrm{},x_n),$$
(76)
where

$$x_1^2+x_2^2+\mathrm{}+x_n^2R^2,$$
(77)
The proportionality factors, $`2\pi s`$ ($`n=2`$) and $`4\pi s^2`$ ($`n=3`$), cannot be applied here directly because the density function is not spherically symmetric. For a given $`s,`$ each direction of $`\stackrel{}{s}`$ carries different information specified by the density distribution function.

We begin with a circle of radius $`R`$ and the conventional notation for polar coordinates, $`x=r\mathrm{cos}\varphi `$ and $`y=r\mathrm{sin}\varphi `$. For a given $`\stackrel{}{s}=\stackrel{}{r}_2\stackrel{}{r}_1,`$ the PDF, $`P_2(s),`$ is proportional to $`A_\stackrel{}{s}\times \rho (\stackrel{}{r}_2)\times \rho (\stackrel{}{r}_1),`$ where $`A_\stackrel{}{s}`$ is the overlapping area between the original circle and a second identical one whose center is shifted to $`\stackrel{}{s}`$, as described in the previous sections. In $`2`$-dimensional space $`\stackrel{}{s}`$ can be characterized by an angle $`\varphi `$ in the range $`0\varphi 2\pi `$. One can understand the new features that arise for a non-uniform density distribution by referring back to Fig. 1. In the case of a uniform density distribution the picture formed by the vector $`\stackrel{}{s}`$ extending between $`L_1`$ and $`L_2`$ is unchanged by a rotation of the entire pattern about the positive $`x`$-axis. However, for a non-uniform distribution the effect of such a rotation is to shift the vectors into a new region for which the density of points is not the same as it was initially. Stated another way, for a fixed $`\left|\stackrel{}{s}\right|`$ the shape of the overlapping area or volume is the same, but will contain a different fraction of the points depending on the orientation of $`\stackrel{}{s}`$. To deal with this effect, one can rotate the coordinate system so that the pattern remains as shown in Fig. 1, but with an appropriately transformed density distribution. To specify this transformation, we associate $`\stackrel{}{s}`$ with a rotation operator $`𝐑(\stackrel{}{s})`$ such that the direction of $`\stackrel{}{s}`$ is the new $`\widehat{x}`$ direction where $`\widehat{s}=\widehat{x}^{}`$, $`\widehat{x}^{}\widehat{x}=\mathrm{cos}\varphi `$, $`\widehat{x}^{}\widehat{y}=\mathrm{sin}\varphi `$, $`\widehat{y}^{}\widehat{x}=\mathrm{sin}\varphi `$ and $`\widehat{y}^{}\widehat{y}=\mathrm{cos}\varphi `$. We utilize the transformation matrix for a $`2`$-dimensional rotation

$$R_{2\times 2}(\varphi )=\left[\begin{array}{cc}\mathrm{cos}\varphi & \mathrm{sin}\varphi \\ \mathrm{sin}\varphi & \mathrm{cos}\varphi \end{array}\right]$$
(78)
to describe $`𝐑(\stackrel{}{s})`$. Notice that $`R_{2\times 2}(\varphi )`$ is an orthogonal matrix which satisfies $`R_{2\times 2}^1(\varphi )=R_{2\times 2}^T(\varphi )`$, where $`T`$ denotes the transpose. Recall that the functional form of the density distribution in Eq. (76) is written in the original coordinate system. The inverse transformation matrix, $`R_{2\times 2}^1(\varphi )=R_{2\times 2}^T(\varphi )`$, should be used to transmit the correct density information to the new coordinate system $`\widehat{s}`$ ($`\widehat{x}^{}`$).

It is convenient to introduce the following general notations,

$`\stackrel{}{𝐗}^{}`$ $`=`$ $`R_{2\times 2}^T(\varphi )\stackrel{}{𝐗},`$ (79)
$`\left[\begin{array}{c}x^{}\\ y^{}\end{array}\right]`$ $`=`$ $`\left[\begin{array}{cc}\mathrm{cos}\varphi & \mathrm{sin}\varphi \\ \mathrm{sin}\varphi & \mathrm{cos}\varphi \end{array}\right]\left[\begin{array}{c}x\\ y\end{array}\right],`$ (86)
and

$`\stackrel{}{𝐗}^{\prime \prime }`$ $`=`$ $`R_{2\times 2}^T(\varphi )(\stackrel{}{𝐗}\stackrel{}{𝐒}),`$ (87)
$`\left[\begin{array}{c}x^{\prime \prime }\\ y^{\prime \prime }\end{array}\right]`$ $`=`$ $`\left[\begin{array}{cc}\mathrm{cos}\varphi & \mathrm{sin}\varphi \\ \mathrm{sin}\varphi & \mathrm{cos}\varphi \end{array}\right]\left[\begin{array}{c}xs\\ y\end{array}\right],`$ (94)
where

$$\stackrel{}{𝐗}=\left[\begin{array}{c}x\\ y\end{array}\right],\stackrel{}{𝐗}^{}=\left[\begin{array}{c}x^{}\\ y^{}\end{array}\right],\stackrel{}{𝐗}^{\prime \prime }=\left[\begin{array}{c}x^{\prime \prime }\\ y^{\prime \prime }\end{array}\right],\stackrel{}{𝐒}=\left[\begin{array}{c}s\\ 0\end{array}\right].$$
(95)
We can then express the PDF for a circle of radius $`R`$ with an arbitrary density distribution as

$$P_2(s)=\frac{s_0^{2\pi }𝑑\varphi _{\frac{s}{2}}^R𝑑x_{\sqrt{R^2x^2}}^{\sqrt{R^2x^2}}\rho (𝐗^{})\rho (𝐗^{\prime \prime })𝑑y}{_0^{2R}\left[s_0^{2\pi }𝑑\varphi _{\frac{s}{2}}^R𝑑x_{\sqrt{R^2x^2}}^{\sqrt{R^2x^2}}\rho (𝐗^{})\rho (𝐗^{\prime \prime })𝑑y\right]𝑑s},$$
(96)
where

$$\rho (𝐗^{})=\rho (\mathrm{cos}\varphi x\mathrm{sin}\varphi y,\mathrm{sin}\varphi x+\mathrm{cos}\varphi y),$$
(97)
$$\rho (𝐗^{\prime \prime })=\rho (\mathrm{cos}\varphi (xs)\mathrm{sin}\varphi y,\mathrm{sin}\varphi (xs)+\mathrm{cos}\varphi y).$$
(98)
As an example , consider a circle of radius $`R`$ and non-uniform density distribution $`\rho (x,y)`$ given by

$$\rho (x,y)=\frac{640N}{3\pi R^{10}}x^4y^4=\frac{640N}{3\pi R^{10}}r^8\mathrm{cos}^4\varphi \mathrm{sin}^4\varphi ,$$
(99)
where $`N`$ is a normalization constant

$$N=_R^R𝑑x_{\sqrt{R^2x^2}}^{\sqrt{R^2x^2}}\rho (x,y)𝑑y.$$
(100)
For this example the $`2`$-dimensional PDF $`P_2(s)`$ is then given by

$`P_2(s)`$ $`=`$ $`{\displaystyle \frac{875}{81}}{\displaystyle \frac{s}{R^2}}+{\displaystyle \frac{500}{3}}{\displaystyle \frac{s^3}{R^4}}+{\displaystyle \frac{7400}{21}}{\displaystyle \frac{s^5}{R^6}}+{\displaystyle \frac{400}{3}}{\displaystyle \frac{s^7}{R^8}}+10{\displaystyle \frac{s^9}{R^{10}}}`$ (103)
$`{\displaystyle \frac{\sqrt{4R^2s^2}}{\pi }}\left[f_1(s)+f_2(s)f_3(s)\right]`$
$`{\displaystyle \frac{\mathrm{sin}^1\left(\frac{s}{2R}\right)}{\pi }}\left({\displaystyle \frac{1750}{81}}{\displaystyle \frac{s}{R^2}}+{\displaystyle \frac{1000}{3}}{\displaystyle \frac{s^3}{R^4}}+{\displaystyle \frac{14800}{21}}{\displaystyle \frac{s^5}{R^6}}+{\displaystyle \frac{800}{3}}{\displaystyle \frac{s^7}{R^8}}+20{\displaystyle \frac{s^9}{R^{10}}}\right),`$
where

$`f_1(s)`$ $`=`$ $`{\displaystyle \frac{14875}{162}}{\displaystyle \frac{s^2}{R^4}}+{\displaystyle \frac{92500}{243}}{\displaystyle \frac{s^4}{R^6}}+{\displaystyle \frac{553985}{1701}}{\displaystyle \frac{s^6}{R^8}},`$ (104)
$`f_2(s)`$ $`=`$ $`{\displaystyle \frac{260315}{10206}}{\displaystyle \frac{s^{10}}{R^{12}}}+{\displaystyle \frac{113693}{47628}}{\displaystyle \frac{s^{14}}{R^{16}}}+{\displaystyle \frac{2509}{142884}}{\displaystyle \frac{s^{18}}{R^{20}}},`$ (105)
$`f_3(s)`$ $`=`$ $`{\displaystyle \frac{2725}{1134}}{\displaystyle \frac{s^8}{R^{10}}}+{\displaystyle \frac{1438825}{142884}}{\displaystyle \frac{s^{12}}{R^{14}}}+{\displaystyle \frac{89189}{285768}}{\displaystyle \frac{s^{16}}{R^{18}}}.`$ (106)
Figure 6 exhibits $`P_2(s)`$ when $`R=1`$, and illustrates the agreement between the Monte Carlo simulation and the analytical result given above.

The preceding discussion can be extended to a $`3`$-dimensional sphere of radius $`R`$ with an arbitrary density distribution $`\rho =\rho (x,y,z)`$, where $`x=r\mathrm{sin}\theta \mathrm{cos}\varphi `$, $`y=r\mathrm{sin}\theta \mathrm{sin}\varphi `$, and $`z=r\mathrm{cos}\theta `$ are the usual $`3`$-dimensional spherical coordinates, and $`x^2+y^2+z^2R^2`$. For a given $`\stackrel{}{s}=\stackrel{}{r}_2\stackrel{}{r}_1,`$ the PDF $`P_3(s)`$ is proportional to $`\rho (\stackrel{}{r}_2)\times \rho (\stackrel{}{r}_1)\times V_\stackrel{}{s},`$ where $`V_\stackrel{}{s}`$ is the overlapping volume between the original sphere and a second identical one whose center is shifted to $`\stackrel{}{s}`$. In $`3`$-dimensional space $`\stackrel{}{s}`$ can be oriented at any angle $`\varphi `$ between $`0`$ and $`2\pi `$, and the angle $`\theta `$ can lie between $`0`$ and $`\pi `$. A rotation matrix $`R_{3\times 3}(\theta ,\varphi )`$ is used to represent the rotation operator $`𝐑(\stackrel{}{s})`$ associated with a given $`\stackrel{}{s}`$ such that

$$R_{3\times 3}(\theta ,\varphi )=R_{3\times 3}(\theta )\times R_{3\times 3}(\varphi )=\left[\begin{array}{ccc}\mathrm{cos}\theta \mathrm{cos}\varphi & \mathrm{cos}\theta \mathrm{sin}\varphi & \mathrm{sin}\theta \\ \mathrm{sin}\varphi & \mathrm{cos}\varphi & \mathrm{\hspace{0.17em}0}\\ \mathrm{sin}\theta \mathrm{cos}\varphi & \mathrm{sin}\theta \mathrm{sin}\varphi & \mathrm{cos}\theta \end{array}\right],$$
(107)
where

$`R_{3\times 3}(\theta )`$ $`=`$ $`\left[\begin{array}{ccc}\mathrm{cos}\theta & \mathrm{\hspace{0.17em}0}& \mathrm{sin}\theta \\ 0& \mathrm{\hspace{0.17em}1}& \mathrm{\hspace{0.17em}0}\\ \mathrm{sin}\theta & \mathrm{\hspace{0.17em}0}& \mathrm{cos}\theta \end{array}\right],`$ (111)
$`R_{3\times 3}(\varphi )`$ $`=`$ $`\left[\begin{array}{ccc}\mathrm{cos}\varphi & \mathrm{sin}\varphi & \mathrm{\hspace{0.17em}0}\\ \mathrm{sin}\varphi & \mathrm{cos}\varphi & \mathrm{\hspace{0.17em}0}\\ 0& \mathrm{\hspace{0.17em}0}& \mathrm{\hspace{0.17em}1}\end{array}\right].`$ (115)
We observe the following:

1. The rotation matrices $`R_{3\times 3}(\theta ,\varphi )`$, $`R_{3\times 3}(\theta )`$, and $`R_{3\times 3}(\varphi )`$ are orthogonal so that

$$R_{3\times 3}^1(\theta ,\varphi )=R_{3\times 3}^T(\theta ,\varphi )=R_{3\times 3}^T(\varphi )R_{3\times 3}^T(\theta ).$$
(116)
2. The purpose of $`R_{3\times 3}(\varphi )`$ is to transform the coordinate system from $`(x,y,z)`$ to a second coordinate system $`(x^1,y^1,z^1)`$ given by

$$\left[\begin{array}{c}x^1\\ y^1\\ z^1\end{array}\right]=\left[\begin{array}{ccc}\mathrm{cos}\varphi & \mathrm{sin}\varphi & \mathrm{\hspace{0.17em}0}\\ \mathrm{sin}\varphi & \mathrm{cos}\varphi & \mathrm{\hspace{0.17em}0}\\ 0& \mathrm{\hspace{0.17em}0}& \mathrm{\hspace{0.17em}1}\end{array}\right]\left[\begin{array}{c}x\\ y\\ z\end{array}\right].$$
(117)
3. The purpose of $`R_{3\times 3}(\theta )`$ is to transform the coordinate system from $`(x^1,y^1,z^1)`$ to a third coordinate system $`(x^2,y^2,z^2)`$ where

$$\left[\begin{array}{c}x^2\\ y^2\\ z^2\end{array}\right]=\left[\begin{array}{ccc}\mathrm{cos}\theta & \mathrm{\hspace{0.17em}0}& \mathrm{sin}\theta \\ 0& \mathrm{\hspace{0.17em}1}& \mathrm{\hspace{0.17em}0}\\ \mathrm{sin}\theta & \mathrm{\hspace{0.17em}0}& \mathrm{cos}\theta \end{array}\right]\left[\begin{array}{c}x^1\\ y^1\\ z^1\end{array}\right].$$
(118)

Define the following notations,

$`\stackrel{}{𝐗}^{}`$ $`=`$ $`R_{3\times 3}^T(\theta ,\varphi )\stackrel{}{𝐗},`$ (119)
$`=`$ $`R_{3\times 3}^T(\varphi )R_{3\times 3}^T(\theta )\stackrel{}{𝐗},`$ (120)
$`\stackrel{}{𝐗}^{\prime \prime }`$ $`=`$ $`R_{3\times 3}^T(\theta ,\varphi )(\stackrel{}{𝐗}\stackrel{}{𝐒})`$ (121)
$`=`$ $`R_{3\times 3}^T(\varphi )R_{3\times 3}^T(\theta )(\stackrel{}{𝐗}\stackrel{}{𝐒}),`$ (122)
where

$$\stackrel{}{𝐗}=\left[\begin{array}{c}x\\ y\\ z\end{array}\right],\stackrel{}{𝐗}^{}=\left[\begin{array}{c}x^{}\\ y^{}\\ z^{}\end{array}\right],\stackrel{}{𝐗}^{\prime \prime }=\left[\begin{array}{c}x^{\prime \prime }\\ y^{\prime \prime }\\ z^{\prime \prime }\end{array}\right],\stackrel{}{𝐒}=\left[\begin{array}{c}0\\ 0\\ 1\end{array}\right].$$
(123)
The PDF $`P_3(s)`$ can then be expressed in the form

$$P_3(s)=\frac{s^2_0^\pi \mathrm{sin}\theta d\theta _0^{2\pi }𝑑\varphi _{\frac{s}{2}}^R𝑑z_{\sqrt{R^2z^2}}^{\sqrt{R^2z^2}}𝑑x_{\sqrt{R^2z^2x^2}}^{\sqrt{R^2z^2x^2}}\rho (𝐗^{})\rho (𝐗^{\prime \prime })𝑑y}{_0^{2R}\left[s^2_0^\pi \mathrm{sin}\theta d\theta _0^{2\pi }𝑑\varphi _{\frac{s}{2}}^R𝑑z_{\sqrt{R^2z^2}}^{\sqrt{R^2z^2}}𝑑x_{\sqrt{R^2z^2x^2}}^{\sqrt{R^2z^2x^2}}\rho (𝐗^{})\rho (𝐗^{\prime \prime })𝑑y\right]𝑑s},$$
(124)
where

$`\rho (𝐗^{})`$ $`=`$ $`\rho (x^{},y^{},z^{}),`$ (125)
$`x^{}`$ $`=`$ $`\mathrm{cos}\theta \mathrm{cos}\varphi x\mathrm{sin}\varphi y+\mathrm{sin}\theta \mathrm{cos}\varphi z,`$ (126)
$`y^{}`$ $`=`$ $`\mathrm{cos}\theta \mathrm{sin}\varphi x+\mathrm{cos}\varphi y+\mathrm{sin}\theta \mathrm{sin}\varphi z,`$ (127)
$`z^{}`$ $`=`$ $`\mathrm{sin}\theta x+\mathrm{cos}\theta z,`$ (128)
$`\rho (𝐗^{\prime \prime })`$ $`=`$ $`\rho (x^{\prime \prime },y^{\prime \prime },z^{\prime \prime }),`$ (129)
$`x^{\prime \prime }`$ $`=`$ $`\mathrm{cos}\theta \mathrm{cos}\varphi x\mathrm{sin}\varphi y+\mathrm{sin}\theta \mathrm{cos}\varphi (zs),`$ (130)
$`y^{\prime \prime }`$ $`=`$ $`\mathrm{cos}\theta \mathrm{sin}\varphi x+\mathrm{cos}\varphi y+\mathrm{sin}\theta \mathrm{sin}\varphi (zs),`$ (131)
$`z^{\prime \prime }`$ $`=`$ $`\mathrm{sin}\theta x+\mathrm{cos}\theta (zs).`$ (132)
As an example, consider a $`3`$-dimensional sphere of radius $`R`$ and non-uniform density distribution $`\rho (x,y,z)`$ given by

$$\rho (x,y,z)=\frac{945N}{4\pi R^9}x^2y^2z^2=\frac{945N}{4\pi R^9}r^6\mathrm{sin}^4\theta \mathrm{cos}^2\theta \mathrm{cos}^2\varphi \mathrm{sin}^2\varphi ,$$
(133)
where $`N`$ is the normalizing factor

$$N=_R^R𝑑x_{\sqrt{R^2x^2}}^{\sqrt{R^2x^2}}𝑑y_{\sqrt{R^2x^2y^2}}^{\sqrt{R^2x^2y^2}}\rho (x,y,z)𝑑z.$$
(134)
Then

$`P_3(s)`$ $`=`$ $`{\displaystyle \frac{1701}{143}}{\displaystyle \frac{s^2}{R^3}}{\displaystyle \frac{25515}{572}}{\displaystyle \frac{s^3}{R^4}}+{\displaystyle \frac{8505}{143}}{\displaystyle \frac{s^4}{R^5}}{\displaystyle \frac{8505}{208}}{\displaystyle \frac{s^5}{R^6}}+{\displaystyle \frac{567}{11}}{\displaystyle \frac{s^6}{R^7}}{\displaystyle \frac{6237}{104}}{\displaystyle \frac{s^7}{R^8}}+9{\displaystyle \frac{s^8}{R^9}}`$ (136)
$`+{\displaystyle \frac{201285}{9152}}{\displaystyle \frac{s^9}{R^{10}}}{\displaystyle \frac{181629}{18304}}{\displaystyle \frac{s^{11}}{R^{12}}}+{\displaystyle \frac{16443}{6656}}{\displaystyle \frac{s^{13}}{R^{14}}}{\displaystyle \frac{6075}{18304}}{\displaystyle \frac{s^{15}}{R^{16}}}+{\displaystyle \frac{10899}{585728}}{\displaystyle \frac{s^{17}}{R^{18}}}.`$
Figure 7 is the plot of $`P_3(s)`$ for $`R=1`$, and illustrates the agreement between Monte Carlo simulation and the analytical result.

We can extend the discussion to a $`4`$-dimensional sphere of radius $`R`$ and arbitrary density distribution function,

$$\rho =\rho (x_1,x_2,x_3,x_4),$$
(137)
where

$$x_1^2+x_2^2+x_3^2+x_4^2R^2.$$
(138)
The $`4`$-dimensional hyperspherical coordinates  that are a generalization of the conventional $`3`$-dimensional spherical coordinates are defined as follows:

$`x_1`$ $`=`$ $`r\mathrm{sin}\theta _2\mathrm{sin}\theta _1\mathrm{cos}\varphi ,`$ (139)
$`x_2`$ $`=`$ $`r\mathrm{sin}\theta _2\mathrm{sin}\theta _1\mathrm{sin}\varphi ,`$ (140)
$`x_3`$ $`=`$ $`r\mathrm{sin}\theta _2\mathrm{cos}\theta _1,`$ (141)
$`x_4`$ $`=`$ $`r\mathrm{cos}\theta _2,`$ (142)
and

$`r`$ $`=`$ $`\sqrt{x_1^2+x_2^2+x_3^2+x_4^2},`$ (143)
$`\theta _1`$ $`=`$ $`\mathrm{tan}^1{\displaystyle \frac{\sqrt{x_1^2+x_2^2}}{x_3}},`$ (144)
$`\theta _2`$ $`=`$ $`\mathrm{tan}^1{\displaystyle \frac{\sqrt{x_1^2+x_2^2+x_3^2}}{x_4}},`$ (145)
$`\varphi `$ $`=`$ $`\mathrm{tan}^1{\displaystyle \frac{x_2}{x_1}},`$ (146)
where

$$0rR,\mathrm{\hspace{0.17em}\hspace{0.17em}\hspace{0.17em}\hspace{0.17em}\hspace{0.17em}0}\theta _1,\theta _2\pi ,\mathrm{\hspace{0.17em}\hspace{0.17em}\hspace{0.17em}\hspace{0.17em}\hspace{0.17em}0}\varphi 2\pi ,$$
(147)
and the volume element dV is given by

$$dV=dx_1dx_2dx_3dx_4=r^3\mathrm{sin}^2\theta _2\mathrm{sin}\theta _1drd\theta _2d\theta _1d\varphi .$$
(148)
The representation of the rotation operator $`𝐑(\stackrel{}{s})`$ for a given $`\stackrel{}{s}`$ is a $`4`$-dimensional rotation matrix

$`R_{4\times 4}(\theta _2,\theta _1,\varphi )`$ $`=`$ $`R_{4\times 4}(\theta _2)\times R_{4\times 4}(\theta _1)\times R_{4\times 4}(\varphi )`$ (149)
$`=`$ $`\left[\begin{array}{cccc}\mathrm{cos}\theta _1\mathrm{cos}\varphi & \mathrm{cos}\theta _1\mathrm{sin}\varphi & \mathrm{sin}\theta & \mathrm{\hspace{0.17em}0}\\ \mathrm{sin}\varphi & \mathrm{cos}\varphi & \mathrm{\hspace{0.17em}0}& \mathrm{\hspace{0.17em}0}\\ \mathrm{cos}\theta _2\mathrm{sin}\theta _1\mathrm{cos}\varphi & \mathrm{cos}\theta _2\mathrm{sin}\theta _1\mathrm{sin}\varphi & \mathrm{cos}\theta _2\mathrm{cos}\theta _1& \mathrm{sin}\theta _2\\ \mathrm{sin}\theta _2\mathrm{sin}\theta _1\mathrm{cos}\varphi & \mathrm{sin}\theta _2\mathrm{sin}\theta _1\mathrm{sin}\varphi & \mathrm{sin}\theta _2\mathrm{cos}\theta _1& \mathrm{cos}\theta _2\end{array}\right],`$ (154)
where

$`R_{4\times 4}(\theta _2)`$ $`=`$ $`\left[\begin{array}{cccc}1& \mathrm{\hspace{0.17em}0}& \mathrm{\hspace{0.17em}0}& \mathrm{\hspace{0.17em}0}\\ 0& \mathrm{\hspace{0.17em}1}& \mathrm{\hspace{0.17em}0}& \mathrm{\hspace{0.17em}0}\\ 0& \mathrm{\hspace{0.17em}0}& \mathrm{cos}\theta _2& \mathrm{sin}\theta _2\\ 0& \mathrm{\hspace{0.17em}0}& \mathrm{sin}\theta _2& \mathrm{cos}\theta _2\end{array}\right],`$ (159)
$`R_{4\times 4}(\theta _1)`$ $`=`$ $`\left[\begin{array}{cccc}\mathrm{cos}\theta _1& \mathrm{\hspace{0.17em}0}& \mathrm{sin}\theta _1& \mathrm{\hspace{0.17em}0}\\ 0& \mathrm{\hspace{0.17em}1}& \mathrm{\hspace{0.17em}0}& \mathrm{\hspace{0.17em}0}\\ \mathrm{sin}\theta _1& \mathrm{\hspace{0.17em}0}& \mathrm{cos}\theta _1& \mathrm{\hspace{0.17em}0}\\ 0& \mathrm{\hspace{0.17em}0}& \mathrm{\hspace{0.17em}0}& \mathrm{\hspace{0.17em}1}\end{array}\right],`$ (164)
$`R_{4\times 4}(\varphi )`$ $`=`$ $`\left[\begin{array}{cccc}\mathrm{cos}\varphi & \mathrm{sin}\varphi & \mathrm{\hspace{0.17em}0}& \mathrm{\hspace{0.17em}0}\\ \mathrm{sin}\varphi & \mathrm{cos}\varphi & \mathrm{\hspace{0.17em}0}& \mathrm{\hspace{0.17em}0}\\ 0& \mathrm{\hspace{0.17em}0}& \mathrm{\hspace{0.17em}1}& \mathrm{\hspace{0.17em}0}\\ 0& \mathrm{\hspace{0.17em}0}& \mathrm{\hspace{0.17em}0}& \mathrm{\hspace{0.17em}1}\end{array}\right].`$ (169)
It is convenient to introduce the notations,

$`\stackrel{}{𝐗}^{}`$ $`=`$ $`R_{4\times 4}^T(\theta _2,\theta _1,\varphi )\stackrel{}{𝐗},`$ (170)
$`=`$ $`R_{4\times 4}^T(\varphi )R_{4\times 4}^T(\theta _1)R_{4\times 4}^T(\theta _2)\stackrel{}{𝐗},`$ (171)
$`\stackrel{}{𝐗}^{\prime \prime }`$ $`=`$ $`R_{4\times 4}^T(\theta _2,\theta _1,\varphi )(\stackrel{}{𝐗}\stackrel{}{𝐒}),`$ (172)
$`=`$ $`R_{4\times 4}^T(\varphi )R_{4\times 4}^T(\theta _1)R_{4\times 4}^T(\theta _2)(\stackrel{}{𝐗}\stackrel{}{𝐒}),`$ (173)
where

$$\stackrel{}{𝐗}=\left[\begin{array}{c}x_1\\ x_2\\ x_3\\ x_4\end{array}\right],\stackrel{}{𝐗}^{}=\left[\begin{array}{c}x_1^{}\\ x_2^{}\\ x_3^{}\\ x_4^{}\end{array}\right],\stackrel{}{𝐗}^{\prime \prime }=\left[\begin{array}{c}x_1^{\prime \prime }\\ x_2^{\prime \prime }\\ x_3^{\prime \prime }\\ x_4^{\prime \prime }\end{array}\right],\stackrel{}{𝐒}=\left[\begin{array}{c}0\\ 0\\ 0\\ s\end{array}\right].$$
(174)
The PDF $`P_4(s)`$ can then be written as

$$P_4(s)=\frac{s^3[\theta _2,\theta _1,\varphi ]\times [x_1,x_2,x_3,x_4]\times \rho (𝐗^{})\times \rho (𝐗^{\prime \prime })}{_0^{2R}\left\{s^3[\theta _2,\theta _1,\varphi ]\times [x_1,x_2,x_3,x_4]\times \rho (𝐗^{})\times \rho (𝐗^{\prime \prime })\right\}𝑑s},$$
(175)
where

$`{\displaystyle [\theta _2,\theta _1,\varphi ]}`$ $``$ $`{\displaystyle _0^\pi }\mathrm{sin}^2\theta _2d\theta _2{\displaystyle _0^\pi }\mathrm{sin}\theta _1d\theta _1{\displaystyle _0^{2\pi }}𝑑\varphi ,`$ (176)
$`{\displaystyle [x_1,x_2,x_3,x_4]}`$ $``$ $`{\displaystyle _{\frac{s}{2}}^R}𝑑x_4{\displaystyle _{\sqrt{R^2x_4^2}}^{\sqrt{R^2x_4^2}}}𝑑x_1{\displaystyle _{\sqrt{R^2x_4^2x_1^2}}^{\sqrt{R^2x_4^2x_1^2}}}𝑑x_2{\displaystyle _{\sqrt{R^2x_4^2x_1^2x_2^2}}^{\sqrt{R^2x_4^2x_1^2x_2^2}}}𝑑x_{3,}`$ (177)
$`\rho (𝐗^{})`$ $`=`$ $`\rho (x_1^{},x_2^{},x_3^{},x_4^{}),`$ (178)
$`x_1^{}`$ $`=`$ $`\mathrm{cos}\theta _1\mathrm{cos}\varphi x_1\mathrm{sin}\varphi x_2+\mathrm{cos}\theta _2\mathrm{sin}\theta _1\mathrm{cos}\varphi x_3+\mathrm{sin}\theta _2\mathrm{sin}\theta _1\mathrm{cos}\varphi x_4,`$ (179)
$`x_2^{}`$ $`=`$ $`\mathrm{cos}\theta _1\mathrm{sin}\varphi x_1+\mathrm{cos}\varphi x_2+\mathrm{cos}\theta _2\mathrm{sin}\theta _1\mathrm{sin}\varphi x_3+\mathrm{sin}\theta _2\mathrm{sin}\theta _1\mathrm{sin}\varphi x_4,`$ (180)
$`x_3^{}`$ $`=`$ $`\mathrm{sin}\theta _1x_1+\mathrm{cos}\theta _2\mathrm{cos}\theta _1x_3+\mathrm{sin}\theta _2\mathrm{cos}\theta _1x_4,`$ (181)
$`x_4^{}`$ $`=`$ $`\mathrm{sin}\theta _2x_3+\mathrm{cos}\theta _2x_4,`$ (182)
$`\rho (𝐗^{\prime \prime })`$ $`=`$ $`\rho (x_1^{\prime \prime },x_2^{\prime \prime },x_3^{\prime \prime },x_4^{\prime \prime }),`$ (183)
$`x_1^{\prime \prime }`$ $`=`$ $`\mathrm{cos}\theta _1\mathrm{cos}\varphi x_1\mathrm{sin}\varphi x_2+\mathrm{cos}\theta _2\mathrm{sin}\theta _1\mathrm{cos}\varphi x_3+\mathrm{sin}\theta _2\mathrm{sin}\theta _1\mathrm{cos}\varphi (x_4s),`$ (184)
$`x_2^{\prime \prime }`$ $`=`$ $`\mathrm{cos}\theta _1\mathrm{sin}\varphi x_1+\mathrm{cos}\varphi x_2+\mathrm{cos}\theta _2\mathrm{sin}\theta _1\mathrm{sin}\varphi x_3+\mathrm{sin}\theta _2\mathrm{sin}\theta _1\mathrm{sin}\varphi (x_4s),`$ (185)
$`x_3^{\prime \prime }`$ $`=`$ $`\mathrm{sin}\theta _1x_1+\mathrm{cos}\theta _2\mathrm{cos}\theta _1x_3+\mathrm{sin}\theta _2\mathrm{cos}\theta _1(x_4s),`$ (186)
$`x_4^{\prime \prime }`$ $`=`$ $`\mathrm{sin}\theta _2x_3+\mathrm{cos}\theta _2(x_4s).`$ (187)
As an example, consider a $`4`$-dimensional sphere of radius $`R`$ and non-uniform density distribution

$$\rho (x_1,x_2,x_3,x_4)=\frac{32N}{\pi ^2R^8}x_1^4=\frac{12N}{\pi ^2R^6}r^4\mathrm{sin}^4\theta _2\mathrm{sin}^4\theta _1\mathrm{cos}^4\varphi ,$$
(188)
where the normalizing factor $`N`$ is given by

$$N=_R^R𝑑x_1_{\sqrt{R^2x_1^2}}^{\sqrt{R^2x_1^2}}𝑑x_2_{\sqrt{R^2x_1^2x_2^2}}^{\sqrt{R^2x_1^2x_2^2}}𝑑x_3_{\sqrt{R^2x_1^2x_2^2x_3^2}}^{\sqrt{R^2x_1^2x_2^2x_3^2}}\rho (x_1,x_2,x_3,x_4)𝑑x_4.$$
(189)
Then

$`P_4(s)`$ $`=`$ $`{\displaystyle \frac{56}{3}}{\displaystyle \frac{s^3}{R^4}}+48{\displaystyle \frac{s^5}{R^6}}+8{\displaystyle \frac{s^7}{R^8}}`$ (192)
$`{\displaystyle \frac{1}{\pi }}\left({\displaystyle \frac{196}{3}}{\displaystyle \frac{s^4}{R^6}}+{\displaystyle \frac{114}{5}}{\displaystyle \frac{s^6}{R^8}}+{\displaystyle \frac{28}{15}}{\displaystyle \frac{s^8}{R^{10}}}{\displaystyle \frac{4}{5}}{\displaystyle \frac{s^{10}}{R^{12}}}+{\displaystyle \frac{2}{9}}{\displaystyle \frac{s^{12}}{R^{14}}}{\displaystyle \frac{1}{45}}{\displaystyle \frac{s^{14}}{R^{16}}}\right)\times \sqrt{4R^2s^2}`$
$`{\displaystyle \frac{1}{\pi }}\left({\displaystyle \frac{112}{3}}{\displaystyle \frac{s^3}{R^4}}+96{\displaystyle \frac{s^5}{R^6}}+16{\displaystyle \frac{s^7}{R^8}}\right)\times \mathrm{sin}^1\left({\displaystyle \frac{s}{2R}}\right).`$
Figure 8 is the plot of $`P_4(s)`$ for $`R=1`$, and illustrates the agreement between the Monte Carlo simulation and the analytical result.

We turn next to the general case of an $`n`$-dimensional sphere of radius $`R`$ and arbitrary density distribution,

$$\rho =\rho (x_1,x_2,\mathrm{},x_n),$$
(193)
where

$$x_1^2+x_2^2+\mathrm{}+x_n^2R^2.$$
(194)
Define the following $`n`$-dimensional spherical coordinates $`x_1,\mathrm{},x_n`$ ,

$`x_1`$ $`=`$ $`r\mathrm{sin}\theta _{n2}\mathrm{sin}\theta _{n3}\mathrm{}\mathrm{}\mathrm{}\mathrm{}\mathrm{}\mathrm{}\mathrm{sin}\theta _2\mathrm{sin}\theta _1\mathrm{cos}\varphi ,`$ (195)
$`x_2`$ $`=`$ $`r\mathrm{sin}\theta _{n2}\mathrm{sin}\theta _{n3}\mathrm{}\mathrm{}\mathrm{}\mathrm{}\mathrm{}\mathrm{}\mathrm{sin}\theta _2\mathrm{sin}\theta _1\mathrm{sin}\varphi ,`$ (196)
$`x_3`$ $`=`$ $`r\mathrm{sin}\theta _{n2}\mathrm{sin}\theta _{n3}\mathrm{}\mathrm{}\mathrm{}\mathrm{}\mathrm{}\mathrm{}\mathrm{sin}\theta _2\mathrm{cos}\theta _1,`$ (197)
$`\mathrm{}`$ $`\mathrm{}`$ $`\mathrm{}`$ (198)
$`x_i`$ $`=`$ $`r\mathrm{sin}\theta _{n2}\mathrm{sin}\theta _{n3}\mathrm{}\mathrm{}\mathrm{sin}\theta _{i1}\mathrm{cos}\theta _{i2},`$ (199)
$`\mathrm{}`$ $`\mathrm{}`$ $`\mathrm{}`$ (200)
$`x_{n2}`$ $`=`$ $`r\mathrm{sin}\theta _{n2}\mathrm{sin}\theta _{n3}\mathrm{cos}\theta _{n4},`$ (201)
$`x_{n1}`$ $`=`$ $`r\mathrm{sin}\theta _{n2}\mathrm{cos}\theta _{n3},`$ (202)
$`x_n`$ $`=`$ $`r\mathrm{cos}\theta _{n2},`$ (203)
where

$`dV`$ $`=`$ $`dx_1dx_2\mathrm{}dx_n`$ (204)
$`=`$ $`r^{n1}\mathrm{sin}^{n2}\theta _{n2}\mathrm{sin}^{n3}\theta _{n3}\mathrm{}\mathrm{}\mathrm{sin}^2\theta _2\mathrm{sin}\theta _1drd\theta _{n2}d\theta _{n3}\mathrm{}\mathrm{}d\theta _2d\theta _1d\varphi ,`$ (205)
and

$$0rR,\mathrm{\hspace{0.17em}\hspace{0.17em}\hspace{0.17em}\hspace{0.17em}\hspace{0.17em}0}\theta _1,\theta _2,\mathrm{}\mathrm{},\theta _{n3},\theta _{n2}\pi ,\mathrm{\hspace{0.17em}\hspace{0.17em}\hspace{0.17em}\hspace{0.17em}\hspace{0.17em}0}\varphi 2\pi .$$
(206)
The rotation operator $`𝐑(\stackrel{}{s})`$ for a given $`\stackrel{}{s}`$ is

$$R_{n\times n}(\theta _{n2},\theta _{n3},\mathrm{}\theta _2,\theta _1,\varphi )=R_{n\times n}(\theta _{n2})R_{n\times n}(\theta _{n3})\mathrm{}R_{n\times n}(\theta _2)R_{n\times n}(\theta _1)R_{n\times n}(\varphi ).$$
(207)
The matrix $`R_{n\times n}(\varphi )`$ appearing in Eq. (207) has the following elements: $`R_{11}(\varphi )=\mathrm{cos}\varphi `$, $`R_{12}(\varphi )=\mathrm{sin}\varphi `$, $`R_{21}(\varphi )=\mathrm{sin}\varphi `$ , $`R_{22}(\varphi )=\mathrm{cos}\varphi `$ , and $`R_{lm}(\varphi )=\delta _{lm}`$ where $`l,m1,2`$ and $`1l,mn`$. The matrix $`R_{n\times n}(\theta _1)`$ has the following elements: $`R_{11}(\theta _1)=\mathrm{cos}\theta _1`$, $`R_{13}(\theta _1)=\mathrm{sin}\theta _1`$, $`R_{31}(\theta _1)=\mathrm{sin}\theta _1`$, $`R_{33}(\theta _1)=\mathrm{cos}\theta _1`$, and $`R_{lm}(\theta _1)=\delta _{lm}`$ where $`l,m1,3`$ and $`1l,mn`$. The matrix $`R_{n\times n}(\theta _i)`$ has the following elements: $`R_{i+1,i+1}(\theta _i)=\mathrm{cos}\theta _i`$, $`R_{i+1,i+2}(\theta _i)=\mathrm{sin}\theta _i`$, $`R_{i+2,i+1}(\theta _i)=\mathrm{sin}\theta _i`$, $`R_{i+2,i+2}(\theta _i)=\mathrm{cos}\theta _i`$, and $`R_{lm}(\theta _i)=\delta _{lm}`$ where $`2in2`$, $`l,mi+1,i+2`$, and $`1l,mn`$. Notice that $`R_{n\times n}(\theta _{n2},\theta _{n3},\mathrm{}\theta _2,\theta _1,\varphi )`$ has the following properties:

1. $`R_{n\times n}(\theta _{n2},\theta _{n3},\mathrm{}\theta _2,\theta _1,\varphi )`$ is an orthogonal matrix such that $`R_{n\times n}^1=R_{n\times n}^T`$.
2. The $`1`$st row matrix elements are $`R_{11}=\mathrm{cos}\theta _1\mathrm{cos}\varphi `$, $`R_{12}=\mathrm{cos}\theta _1\mathrm{sin}\varphi `$, $`R_{13}=\mathrm{sin}\theta _1`$, and $`R_{1j}=0`$ for $`4jn`$.
3. The $`2`$nd row matrix elements are $`R_{21}=\mathrm{sin}\varphi `$, $`R_{22}=\mathrm{cos}\varphi `$, and $`R_{2j}=0`$ for $`3jn`$.
4. The $`i`$th row matrix elements, where $`3in1`$, are $`R_{i1}=\mathrm{cos}\theta _{i1}\times x_1[i]`$, $`R_{i2}=\mathrm{cos}\theta _{i1}\times x_2[i]`$, $`R_{im}=\mathrm{cos}\theta _{i1}\times x_m[i]`$ for $`1mi`$, $`R_{ii}=\mathrm{cos}\theta _{i1}\times x_i[i]`$, $`R_{ii+1}=\mathrm{sin}\theta _{i1}`$, and $`R_{ij}=0`$ for $`i+2jn`$, where $`x_m[i]`$ is the $`m`$th component of the $`i`$-dimensional Cartesian coordinate system in the representation of the $`i`$-dimensional spherical coordinate system for a unit vector. Some examples are $`x_3[3]=\mathrm{cos}\theta _1`$, $`x_3[4]=\mathrm{sin}\theta _2\mathrm{cos}\theta _1`$, $`x_3[5]=\mathrm{sin}\theta _3\mathrm{sin}\theta _2\mathrm{cos}\theta _1`$, and $`x_3[6]=\mathrm{sin}\theta _4\mathrm{sin}\theta _3\mathrm{sin}\theta _2\mathrm{cos}\theta _1`$.
5. The $`n`$th row matrix elements are $`R_{nj}=x_j[n]`$ for $`1jn`$, where $`x_j[n]`$ is the $`j`$th component of the $`n`$-dimensional Cartesian coordinate in the representation of the $`n`$-dimensional spherical coordinate system for a unit vector. Some examples are

$`x_1[n]`$ $`=`$ $`\mathrm{sin}\theta _{n2}\mathrm{sin}\theta _{n3}\mathrm{}\mathrm{}\mathrm{sin}\theta _2\mathrm{sin}\theta _1\mathrm{cos}\varphi ,`$ (208)
$`x_2[n]`$ $`=`$ $`\mathrm{sin}\theta _{n2}\mathrm{sin}\theta _{n3}\mathrm{}\mathrm{}\mathrm{sin}\theta _2\mathrm{sin}\theta _1\mathrm{sin}\varphi ,`$ (209)
$`x_3[n]`$ $`=`$ $`\mathrm{sin}\theta _{n2}\mathrm{sin}\theta _{n3}\mathrm{}\mathrm{}\mathrm{sin}\theta _2\mathrm{cos}\theta _1,`$ (210)
$`x_n[n]`$ $`=`$ $`\mathrm{cos}\theta _{n2.}`$ (211)

The final master probability density function formula $`P_n(s)`$ for an $`n`$-dimensional sphere of radius $`R`$ and arbitrary density distribution has the following mathematical representation:

$$P_n(s)=\frac{s^{n1}[\theta _{n2},\theta _{n3},\mathrm{}\mathrm{}\theta _2,\theta _1,\varphi ][x_1,x_2,\mathrm{}\mathrm{},x_n]\rho (𝐗^{})\rho (𝐗^{\prime \prime })}{_0^{2R}\left\{s^{n1}[\theta _{n2},\theta _{n3},\mathrm{}\mathrm{}\theta _2,\theta _1,\varphi ][x_1,x_2,\mathrm{}\mathrm{},x_n]\rho (𝐗^{})\rho (𝐗^{\prime \prime })\right\}𝑑s},$$
(212)
where

$`{\displaystyle [\theta _{n2},\theta _{n3},\mathrm{}\mathrm{}\theta _2,\theta _1,\varphi ]}`$ $``$ $`{\displaystyle _0^\pi }\mathrm{sin}^{n2}\theta _{n2}d\theta _{n2}{\displaystyle _0^\pi }\mathrm{sin}^{n3}\theta _{n3}d\theta _{n3}\mathrm{}\mathrm{}`$ (214)
$`\mathrm{}\mathrm{}{\displaystyle _0^\pi }\mathrm{sin}^2\theta _2d\theta _2{\displaystyle _0^\pi }\mathrm{sin}\theta _1d\theta _1{\displaystyle _0^{2\pi }}𝑑\varphi ,`$
$`{\displaystyle [x_1,x_2,\mathrm{}\mathrm{},x_n]}`$ $``$ $`{\displaystyle _{\frac{s}{2}}^R}𝑑x_n{\displaystyle _{\sqrt{R^2x_n^2}}^{\sqrt{R^2x_n^2}}}𝑑x_1{\displaystyle _{\sqrt{R^2x_n^2x_1^2}}^{\sqrt{R^2x_n^2x_1^2}}}𝑑x_2\mathrm{}\mathrm{}`$ (216)
$`\mathrm{}\mathrm{}{\displaystyle _{\sqrt{R^2x_n^2x_1^2\mathrm{}x_{n3}^2}}^{\sqrt{R^2x_n^2x_1^2\mathrm{}x_{n3}^2}}}𝑑x_{n2}{\displaystyle _{\sqrt{R^2x_n^2x_1^2\mathrm{}x_{n2}^2}}^{\sqrt{R^2x_n^2x_1^2\mathrm{}x_{n2}^2}}}𝑑x_{n1},`$
$`\rho (𝐗^{})`$ $`=`$ $`\rho (x_1^{},x_2^{},\mathrm{}\mathrm{}x_n^{}),`$ (217)
$`\rho (𝐗^{\prime \prime })`$ $`=`$ $`\rho (x_1^{\prime \prime },x_2^{\prime \prime },\mathrm{}\mathrm{}x_n^{\prime \prime }).`$ (218)
Additionally, we introduce the following notations:

$`\stackrel{}{𝐗}^{}`$ $`=`$ $`R_{n\times n}^T(\theta _{n2},\theta _{n3},\mathrm{}\mathrm{}\theta _2,\theta _1,\varphi )\stackrel{}{𝐗}`$ (219)
$`=`$ $`R_{n\times n}^T(\varphi )R_{n\times n}^T(\theta _1)R_{n\times n}^T(\theta _2)\mathrm{}\mathrm{}R_{n\times n}^T(\theta _{n3})R_{n\times n}^T(\theta _{n2})\stackrel{}{𝐗},`$ (220)
$`\stackrel{}{𝐗}^{\prime \prime }`$ $`=`$ $`R_{n\times n}^T(\theta _{n2},\theta _{n3},\mathrm{}\mathrm{}\theta _2,\theta _1,\varphi )(\stackrel{}{𝐗}\stackrel{}{𝐒})`$ (221)
$`=`$ $`R_{n\times n}^T(\varphi )R_{n\times n}^T(\theta _1)R_{n\times n}^T(\theta _2)\mathrm{}\mathrm{}R_{n\times n}^T(\theta _{n3})R_{n\times n}^T(\theta _{n2})(\stackrel{}{𝐗}\stackrel{}{𝐒}),`$ (222)
where

$$\stackrel{}{𝐗}=\left[\begin{array}{c}x_1\\ x_2\\ \mathrm{}\\ \mathrm{}\\ x_{n1}\\ x_n\end{array}\right],\stackrel{}{𝐗}^{}=\left[\begin{array}{c}x_1^{}\\ x_2^{}\\ \mathrm{}\\ \mathrm{}\\ x_{n1}^{}\\ x_n^{}\end{array}\right],\stackrel{}{𝐗}^{\prime \prime }=\left[\begin{array}{c}x_1^{\prime \prime }\\ x_2^{\prime \prime }\\ \mathrm{}\\ \mathrm{}\\ x_{n1}^{\prime \prime }\\ x_n^{\prime \prime }\end{array}\right],\stackrel{}{𝐒}=\left[\begin{array}{c}0\\ 0\\ \mathrm{}\\ \mathrm{}\\ 0\\ s\end{array}\right].$$
(223)
The technique for generating random points within an $`n`$-dimensional sphere having an arbitrary density distribution will be discussed elsewhere .

## V Applications

### A $`m`$th moment

We first calculate the $`m`$th moment $`s^m`$ for the case of $`n`$-dimensional uniform sphere, where

$$s^m=_0^{2R}s^mP_n(s)𝑑s,$$
(224)
and $`m`$ is a positive integer. Evidently $`s^m`$ gives the expectation (average) value of the $`m`$th power of the distance between two independent random points generated inside a uniform $`n`$-dimensional sphere. By utilizing the function $`C(a;m,n)`$ defined in Eq. (22), we can write $`s^m`$ as

$$s^m=\frac{C(2R;m,n)}{C(2R;0,n)}=2^{m+n}\left(\frac{n}{m+n}\right)\frac{B(\frac{n}{2}+\frac{1}{2},\frac{n}{2}+\frac{1}{2}+\frac{m}{2})}{B(\frac{n}{2}+\frac{1}{2},\frac{1}{2})}R^m,$$
(225)
where we have used the following identity:

$`C(a;m,n)`$ $`=`$ $`{\displaystyle \frac{1}{2}}{\displaystyle \frac{a^{m+n}}{m+n}}B({\displaystyle \frac{1}{2}},{\displaystyle \frac{n}{2}}+{\displaystyle \frac{1}{2}})R^n{\displaystyle \frac{1}{2}}{\displaystyle \frac{a^{m+n}}{m+n}}B_{\left(\frac{a}{2R}\right)^2}({\displaystyle \frac{1}{2}},{\displaystyle \frac{n}{2}}+{\displaystyle \frac{1}{2}})R^n`$ (227)
$`+{\displaystyle \frac{1}{2}}{\displaystyle \frac{(2R)^{m+n}}{m+n}}B_{\left(\frac{a}{2R}\right)^2}({\displaystyle \frac{n}{2}}+{\displaystyle \frac{1}{2}}+{\displaystyle \frac{m}{2}},{\displaystyle \frac{n}{2}}+{\displaystyle \frac{1}{2}})R^n.`$
Furthermore we can rewrite Eq. (225) in terms of the gamma function by replacing the beta functions as follows:

$`s^m`$ $`=`$ $`(2R)^m\left({\displaystyle \frac{n}{m+n}}\right){\displaystyle \frac{\mathrm{\Gamma }\left(\frac{n}{2}+\frac{m}{2}+\frac{1}{2}\right)\mathrm{\Gamma }\left(n+1\right)}{\mathrm{\Gamma }\left(n+1+\frac{m}{2}\right)\mathrm{\Gamma }\left(\frac{n}{2}+\frac{1}{2}\right)}}`$ (228)
$`=`$ $`\left({\displaystyle \frac{n}{m+n}}\right)^2{\displaystyle \frac{\mathrm{\Gamma }\left(n+m+1\right)\mathrm{\Gamma }\left(\frac{n}{2}\right)}{\mathrm{\Gamma }\left(\frac{n}{2}+\frac{m}{2}\right)\mathrm{\Gamma }\left(n+1+\frac{m}{2}\right)}}R^m.`$ (229)
The results in Eqs. (228) and (229) are identical to those given in Refs. . They can be extended to evaluate $`s^m`$ and we find

$$\frac{1}{s^m}=\frac{n}{nm}\frac{2^{nm}}{R^m}\frac{B(\frac{n}{2}+\frac{1}{2},\frac{n}{2}+\frac{1}{2}\frac{m}{2})}{B(\frac{n}{2}+\frac{1}{2},\frac{1}{2})},$$
(230)
where

$$mn1.$$
(231)
Combining Eqs. (225) and (230), the $`m`$th moment $`s^m`$ has the general form

$$s^m=2^{n+m}\left(\frac{n}{n+m}\right)\frac{B(\frac{n}{2}+\frac{1}{2},\frac{n}{2}+\frac{1}{2}+\frac{m}{2})}{B(\frac{n}{2}+\frac{1}{2},\frac{1}{2})}R^m,$$
(232)
where

$$m=(n1),(n2),\mathrm{},2,1,\mathrm{\hspace{0.17em}0},\mathrm{\hspace{0.17em}1},\mathrm{\hspace{0.17em}2},\mathrm{}\mathrm{}.$$
(233)
Following is a short list of $`s^m`$ in $`3`$ dimensions: $`1/s^2`$=$`9/4`$, $`1/s`$=$`6/5`$, $`s`$=$`36/35`$, $`s^2`$=$`6/5`$, $`s^3`$=$`32/21`$, $`s^4`$=$`72/35`$, and $`s^5`$=$`32/11`$, where the radius $`R`$ has been set to unity.

Additionally, $`s^m`$ can be evaluated for a sphere having a Gaussian density distribution and radius $`R\mathrm{}`$. From Eq. (74) we have,

$$s^m=\underset{R\mathrm{}}{lim}_0^{2R}s^mP_n(s)𝑑s=(2\sigma )^m\frac{\mathrm{\Gamma }\left(\frac{n+m}{2}\right)}{\mathrm{\Gamma }\left(\frac{n}{2}\right)}.$$
(234)
In some applications involving low-energy interactions among nucleons the lower limit (zero) should be replaced by the hard-core radius $`r_c0.5\times 10^{13}`$ cm . In such cases the expressions for $`P_n(s)`$ and $`s^m`$ assume the form:

$$P_n(s)=\frac{s^{n1}_{\frac{s}{2}}^R\left(R^2x^2\right)^{\frac{n1}{2}}𝑑x}{_{r_c}^{2R}𝑑s_{\frac{s}{2}}^R𝑑xs^{n1}\left(R^2x^2\right)^{\frac{n1}{2}}}=\frac{s^{n1}_{\frac{s}{2}}^R\left(R^2x^2\right)^{\frac{n1}{2}}𝑑x}{C(2R;0,n)C(r_c;0,n)}$$
(235)
and

$$s^m=_{r_c}^{2R}s^mP_n(s)𝑑s=\frac{H(R,r_{c;}m,n)}{H(R,r_c;\mathrm{\hspace{0.17em}0},n)},$$
(236)
where

$`H(R,r_c;m,n)`$ $`=`$ $`{\displaystyle \frac{(2R)^{n+m}}{n+m}}\left[B({\displaystyle \frac{n}{2}}+{\displaystyle \frac{1}{2}},{\displaystyle \frac{n}{2}}+{\displaystyle \frac{1}{2}}+{\displaystyle \frac{m}{2}})B_{\left(\frac{r_c}{2R}\right)^2}({\displaystyle \frac{n}{2}}+{\displaystyle \frac{1}{2}},{\displaystyle \frac{n}{2}}+{\displaystyle \frac{1}{2}}+{\displaystyle \frac{m}{2}})\right]`$ (238)
$`{\displaystyle \frac{r_c^{n+m}}{n+m}}\left[B({\displaystyle \frac{1}{2}},{\displaystyle \frac{n}{2}}+{\displaystyle \frac{1}{2}})B_{\left(\frac{r_c}{2R}\right)^2}({\displaystyle \frac{1}{2}},{\displaystyle \frac{n}{2}}+{\displaystyle \frac{1}{2}})\right],`$
and $`m`$ is an integer.

### B Coulomb Self-Energy of a Collection of Charges

As an application of the preceding formalism we evaluate the electrostatic energy $`W_n`$ of a collection of $`Z`$ charges in $`n`$ dimensions by applying geometric probability techniques. Consider first the familiar case of a spherical charge distribution in $`3`$ dimensions. For each pair of charges the potential energy due to the Coulomb interaction in Gaussian units is

$$V\left(\left|\stackrel{}{r}_2\stackrel{}{r}_1\right|\right)=\frac{e_0^2}{\left|\stackrel{}{r}_2\stackrel{}{r}_1\right|},$$
(239)
where $`e_0`$ is the elementary charge ($`e_0^2/\mathrm{}c1/137`$). Hence if we assume that the charges in each pair are uniformly distributed within the same spherical volume of radius $`R`$ then the average Coulomb energy $`U_3`$ of each pair of charges is

$$U_3=e^2_0^{2R}\frac{1}{s}P_3(s)𝑑s=\frac{6}{5}\frac{e_0^2}{R}.$$
(240)
For a collection of $`Z`$ charges there are $`Z(Z1)/2`$ such pairs, and hence the total Coulomb energy $`W_3`$ is

$$W_3=\frac{Z(Z1)}{2}U_3=\frac{3}{5}Z(Z1)\frac{e_0^2}{R}.$$
(241)
For $`n3`$ the Coulomb potential energy between two charges has the general form

$$V_n\left(\left|\stackrel{}{r}_2\stackrel{}{r}_1\right|\right)=\frac{q_n^2}{\left|\stackrel{}{r}_2\stackrel{}{r}_1\right|^{n2}},$$
(242)
where $`q_n`$ is a suitably defined charge with appropriate dimensions. Hence Eq. (240) generalizes to

$$U_n=q_n^2_0^{2R}\frac{1}{s^{n2}}P_n(s)𝑑s=q_n^2\frac{1}{s^{n2}}.$$
(243)
Using the results of Eq. (232) with $`m=n2`$ we then find

$$W_n=Z(Z1)\frac{B(\frac{n}{2}+\frac{1}{2},\frac{3}{2})}{B(\frac{n}{2}+\frac{1}{2},\frac{1}{2})}\frac{q_n^2}{R^{n2}}=\left(\frac{2n}{n+2}\right)\frac{Z(Z1)q_n^2}{R^{n2}}.$$
(244)
For $`n`$ very large $`W_n`$ assumes the limiting form

$$\underset{n\mathrm{}}{lim}W_n2\frac{Z(Z1)q_n^2}{R^{n2}}.$$
(245)
If the density distribution $`\rho _n(r)`$ of the charges is Gaussian rather than uniform, where

$$\rho _n(r)=\frac{q_n}{(2\pi )^{\frac{n}{2}}\sigma _n^n}e^{\frac{1}{2}\frac{r^2}{\sigma _n^2}},$$
(246)
then

$$W_n=\frac{1}{2^{n2}\mathrm{\Gamma }\left(\frac{n}{2}\right)}\frac{q_n^2}{\sigma ^{n2}}.$$
(247)
In the limit $`n\mathrm{}`$,

$$W_n\frac{2}{\pi }e^{n/2}n^{n/2}\frac{q_n^2}{\sigma ^{n2}}.$$
(248)
These results are of interest in the context of recent work on modifications to the Newtonian inverse-square law arising from the existence of extra spatial dimensions . It is well known that the gravitational interaction is weaker in a space with $`n>3`$ spatial dimensions, this weakness being manifested by an inverse-power-law for the force $`F_n`$, $`F_n1/r^{n1}`$.

### C Neutrino-Pair Exchange Interactions

A second example of interest is the $`\nu \overline{\nu }`$-exchange (neutrino-pair exchange) contribution to the self energy of a nucleus or a neutron star. For two point masses the $`2`$-body potential energy is given by

$$V_{\nu \overline{\nu }}\left(\left|\stackrel{}{r}_i\stackrel{}{r}_j\right|\right)=\frac{G_F^2a_ia_j}{4\pi ^3\left|\stackrel{}{r}_i\stackrel{}{r}_j\right|^5},$$
(249)
where $`a_i`$ and $`a_j`$ are coupling constants which characterize the strength of the neutrino coupling to fermions $`i`$ and $`j`$ ($`i`$, $`j`$ = electron, proton, or neutron). In the standard model ,

$`a_e`$ $`=`$ $`{\displaystyle \frac{1}{2}}+2\mathrm{sin}^2\theta _W=0.964`$
$`a_p`$ $`=`$ $`{\displaystyle \frac{1}{2}}2\mathrm{sin}^2\theta _W=0.036`$
$`a_n`$ $`=`$ $`{\displaystyle \frac{1}{2}}.`$
In contrast to the Coulomb interaction, the functional form of $`V_{\nu \overline{\nu }}(r)`$ cannot be determined in a space of arbitrary dimensions on the basis of a general argument utilizing Gauss’ law. Hence we restrict our attention here to $`3`$ spatial dimensions and consider the case of a sphere of radius $`R`$ containing $`N`$ neutrons. For the case of a uniform density distribution we then find

$$W_3=\frac{N(N1)}{2}\left(\frac{3}{2r_c^2R^3}\frac{9}{4r_cR^4}+\frac{9}{8R^5}\frac{3r_c}{16R^6}\right)\frac{G_F^2}{4\pi ^3}\frac{3N(N1)G_F^2}{16\pi ^3r_c^2R^3},$$
(250)
where $`r_c`$ is the hard-core radius. The analogous result for a Gaussian density distribution is

$$W_3=\left[\frac{1}{r_c^2}e^{r_c^2/4\sigma ^2}\frac{\mathrm{\Gamma }(0,r_c^2/4\sigma ^2)}{4\sigma ^2}\right]\frac{N(N1)G_F^2}{32\sigma ^3\pi ^{7/2}},$$
(251)
where $`\mathrm{\Gamma }(a,b)`$ is the incomplete gamma function. The expression in Eq. (250) agrees with the result obtained in Refs. .

### D Neutron Star Models

Another application of current interest is the self-energy of neutron star arising from the exchange of $`\nu \overline{\nu }`$ pairs. Here we evaluate the probability density functions in $`3`$ dimensions for neutron stars with a multiple-shell uniform density distribution, which is what is typically assumed in neutron star models . For illustrative purposes, we discuss spherically symmetric models with spherical $`2`$, $`3`$, and $`4`$ shells, where for simplicity we assume shells of equal thickness. Some other multiple-shell models and their $`n`$-dimensional probability density functions can be found in .

For a $`2`$-shell model with a uniform density in each shell define $`\rho =\rho _1`$ for $`0rR/2`$ and $`\rho =\rho _2`$ for $`R/2rR`$, where $`\rho _1`$ and $`\rho _2`$ are constants and $`r`$ is measured from the center of the neutron star in $`3`$ dimensions. Using the preceding formalism we can show that the PDF has $`4`$ different functional forms specified by $`4`$ regions:

1. $`0s\frac{1}{2}R:`$

$$P_3(s)=\frac{24(\rho _1^2+7\rho _2^2)s^2}{\left(\rho _1+7\rho _2\right)^2R^3}\frac{36(\rho _1^22\rho _1\rho _2+5\rho _2^2)s^3}{\left(\rho _1+7\rho _2\right)^2R^4}+\frac{12(\rho _1^22\rho _1\rho _2+2\rho _2^2)s^5}{\left(\rho _1+7\rho _2\right)^2R^6},$$
(252)
2. $`\frac{1}{2}RsR:`$

$`P_3(s)`$ $`=`$ $`{\displaystyle \frac{81(\rho _1\rho _2)\rho _2s}{2\left(\rho _1+7\rho _2\right)^2R^2}}+{\displaystyle \frac{24\rho _1s^2}{\left(\rho _1+7\rho _2\right)R^3}}{\displaystyle \frac{36\rho _1(\rho _1+3\rho _2)s^3}{\left(\rho _1+7\rho _2\right)^2R^4}}`$ (254)
$`+{\displaystyle \frac{12\rho _1^2s^5}{\left(\rho _1+7\rho _2\right)^2R^6}},`$
3. $`Rs\frac{3}{2}R:`$

$`P_3(s)`$ $`=`$ $`{\displaystyle \frac{81(\rho _1\rho _2)\rho _2s}{2\left(\rho _1+7\rho _2\right)^2R^2}}+{\displaystyle \frac{24(9\rho _1\rho _2)\rho _2s^2}{\left(\rho _1+7\rho _2\right)^2R^3}}{\displaystyle \frac{36(5\rho _1\rho _2)\rho _2s^3}{\left(\rho _1+7\rho _2\right)^2R^4}}`$ (256)
$`+{\displaystyle \frac{12(2\rho _1\rho _2)\rho _2s^5}{\left(\rho _1+7\rho _2\right)^2R^6}},`$
4. $`\frac{3}{2}Rs2R:`$

$$P_3(s)=\frac{192\rho _2^2s^2}{\left(\rho _1+7\rho _2\right)^2R^3}\frac{144\rho _2^2s^3}{\left(\rho _1+7\rho _2\right)^2R^4}+\frac{12\rho _2^2s^5}{\left(\rho _1+7\rho _2\right)^2R^6}.$$
(257)

We observe that the PDFs defined in adjacent regions are continuous across the boundaries separating the regions.

For a $`3`$-shell model of a sphere of radius $`R`$ in $`3`$ dimensions, with a different uniform density in each shell, define $`\rho =\rho _1`$ for $`0rR/3`$, $`\rho =\rho _2`$ for $`R/3r2R/3`$, and $`\rho =\rho _3`$ for $`2R/3rR`$, where $`\rho _1`$, $`\rho _2`$, and $`\rho _3`$ are constants and $`r`$ is measured from the center of the neutron star. In this case the PDF has $`6`$ different functional forms specified by $`6`$ regions:

1. $`0s\frac{1}{3}R:`$

$`P_3(s)`$ $`=`$ $`{\displaystyle \frac{81(\rho _1^2+7\rho _2^2+19\rho _3^2)s^2}{(\rho _1+7\rho _2+19\rho _3)^2R^3}}{\displaystyle \frac{729(\rho _1^22\rho _1\rho _2+5\rho _2^28\rho _2\rho _3+13\rho _3^2)s^3}{4(\rho _1+7\rho _2+19\rho _3)^2R^4}}`$ (259)
$`+{\displaystyle \frac{2187(\rho _1^22\rho _1\rho _2+2\rho _2^22\rho _2\rho _3+2\rho _3^2)s^5}{16(\rho _1+7\rho _2+19\rho _3)^2R^6}},`$
2. $`\frac{1}{3}Rs\frac{2}{3}R:`$

$`P_3(s)`$ $`=`$ $`{\displaystyle \frac{81(\rho _2\rho _3)(9\rho 19\rho _2+25\rho _3)s}{8(\rho _1+7\rho _2+19\rho _3)^2R^2}}+{\displaystyle \frac{81(\rho _1^2+7\rho _1\rho _27\rho _1\rho _3+26\rho _2\rho _3)s^2}{(\rho _1+7\rho _2+19\rho _3)^2R^3}}`$ (261)
$`{\displaystyle \frac{729(\rho _1^2+3\rho _1\rho _25\rho _1\rho _3+10\rho _2\rho _3)s^3}{4(\rho _1+7\rho _2+19\rho _3)^2R^4}}+{\displaystyle \frac{2187(\rho _1^22\rho _1\rho _3+2\rho _2\rho _3)s^5}{16(\rho _1+7\rho _2+19\rho _3)^2R^6}},`$
3. $`\frac{2}{3}RsR:`$

$`P_3(s)`$ $`=`$ $`{\displaystyle \frac{81(9\rho _1\rho _29\rho _2^2+55\rho _1\rho _330\rho _2\rho _325\rho _3^2)s}{8(\rho _1+7\rho _2+19\rho _3)^2R^2}}+{\displaystyle \frac{81(9\rho _1\rho _2\rho _2^2+19\rho _1\rho _3)s^2}{(\rho _1+7\rho _2+19\rho _3)^2R^3}}`$ (263)
$`{\displaystyle \frac{729(5\rho _1\rho _2\rho _2^2+5\rho _1\rho _3)s^3}{4(\rho _1+7\rho _2+19\rho _3)^2R^4}}+{\displaystyle \frac{2187(2\rho _1\rho _2)\rho _2s^5}{16(\rho _1+7\rho _2+19\rho _3)^2R^6}},`$
4. $`Rs\frac{4}{3}R:`$

$`P_3(s)`$ $`=`$ $`{\displaystyle \frac{81(64\rho _139\rho _225\rho _3)\rho _3s}{8(\rho _1+7\rho _2+19\rho _3)^2R^2}}+{\displaystyle \frac{81(8\rho _2^2+28\rho _1\rho _39\rho _2\rho _3)s^2}{(\rho _1+7\rho _2+19\rho _3)^2R^3}}`$ (265)
$`{\displaystyle \frac{729(4\rho _2^2+10\rho _1\rho _35\rho _2\rho _3)s^3}{4(\rho _1+7\rho _2+19\rho _3)^2R^4}}+{\displaystyle \frac{2187(\rho _2^2+2\rho _1\rho _32\rho _2\rho _3)s^5}{16(\rho _1+7\rho _2+19\rho _3)^2R^6}},`$
5. $`\frac{4}{3}Rs\frac{5}{3}R:`$

$`P_3(s)`$ $`=`$ $`{\displaystyle \frac{2025(\rho _2\rho _3)\rho _3s}{8(\rho _1+7\rho _2+19\rho _3)^2R^2}}+{\displaystyle \frac{81(35\rho _28\rho _3)\rho _3s^2}{(\rho _1+7\rho _2+19\rho _3)^2R^3}}`$ (267)
$`{\displaystyle \frac{729(13\rho _24\rho _3)\rho _3s^3}{4(\rho _1+7\rho _2+19\rho _3)^2R^4}}+{\displaystyle \frac{2187(2\rho _2\rho _3)\rho _3s^5}{16(\rho _1+7\rho _2+19\rho _3)^2R^6}},`$
6. $`\frac{5}{3}Rs2R:`$

$$P_3(s)=\frac{2187\rho _3^2s^2}{(\rho _1+7\rho _2+19\rho _3)^2R^3}\frac{6561\rho _3^2s^3}{4(\rho _1+7\rho _2+19\rho _3)^2R^4}+\frac{2187\rho _3^2s^5}{16(\rho _1+7\rho _2+19\rho _3)^2R^6}.$$
(268)

As in the previous case, the various functional forms for $`P_3(s)`$ are continuous across the boundaries separating the regions.

The $`3`$-shell model is of interest since actual models of neutron stars often invoke a $`3`$-shell picture . We note to start with that although our $`3`$-shell model assumes that all shells have the same thickness (shell radii of $`r`$, $`2r`$, and $`3r`$), we can relax this assumption by substituting $`rr_1`$, $`2rr_2`$, and $`3rr_3`$, where $`r_1`$, $`r_2`$, and $`r_3`$ are arbitrary numbers. Similarly, the densities $`\rho _1`$, $`\rho _2`$, and $`\rho _3`$ can also assume arbitrary values, so that the results of Eqs. (259)–(268) can be applied to any realistic neutron star model .

The preceding formalism can be extended to any number of shells. For a $`4`$-shell model define $`\rho =\rho _1`$ for $`0rR/4`$, $`\rho =\rho _2`$ for $`R/4rR/2`$ , $`\rho =\rho _3`$ for $`R/2r3R/4`$, and $`\rho =\rho _4`$ for $`3R/4rR`$. Here $`\rho _1`$, $`\rho _2`$, $`\rho _3`$, and $`\rho _4`$ are constants, and $`r`$ is measured from the center of the neutron star. The PDF has $`8`$ different functional forms specified by $`8`$ regions:

1. $`Rs\frac{1}{4}R:`$

$`P_3(s)`$ $`=`$ $`{\displaystyle \frac{192(\rho _1^2+7\rho _2^2+19\rho _3^2+37\rho _4^2)s^2}{(\rho _1+7\rho _2+19\rho _3+37\rho _4)^2R^3}}`$ (271)
$`{\displaystyle \frac{576(\rho _1^22\rho _1\rho _2+5\rho _2^28\rho _2\rho _3+13\rho _3^218\rho _3\rho _4+25\rho _4^2)s^3}{(\rho _1+7\rho _2+19\rho _3+37\rho _4)^2R^4}}`$
$`+{\displaystyle \frac{768(\rho _1^22\rho _1\rho _2+2\rho _2^22\rho _2\rho _3+2\rho _3^22\rho _3\rho _4+2\rho _4^2)s^5}{(\rho _1+7\rho _2+19\rho _3+37\rho _4)^2R^6}},`$
2. $`\frac{1}{4}Rs\frac{1}{2}R:`$

$`P_3(s)`$ $`=`$ $`{\displaystyle \frac{18(9\rho _1\rho _29\rho _2^29\rho _1\rho _3+34\rho _2\rho _325\rho _3^225\rho _2\rho _4+74\rho _3\rho _449\rho _4^2)s}{(\rho _1+7\rho _2+19\rho _3+37\rho _4)^2R^2}}`$ (275)
$`+{\displaystyle \frac{192(\rho _1^2+7\rho _1\rho _27\rho _1\rho _3+26\rho _2\rho _319\rho _2\rho _4+56\rho _3\rho _4)s^2}{(\rho _1+7\rho _2+19\rho _3+37\rho _4)^2R^3}}`$
$`{\displaystyle \frac{576(\rho _1^2+3\rho _1\rho _25\rho _1\rho _3+10\rho _2\rho _313\rho _2\rho _4+20\rho _3\rho _4)s^3}{(\rho _1+7\rho _2+19\rho _3+37\rho _4)^2R^4}}`$
$`+{\displaystyle \frac{768(\rho _1^22\rho _1\rho _3+2\rho _2\rho _32\rho _2\rho _4+2\rho _3\rho _4)s^5}{(\rho _1+7\rho _2+19\rho _3+37\rho _4)^2R^6}},`$
3. $`\frac{1}{2}Rs\frac{3}{4}R:`$

$`P_3(s)`$ $`=`$ $`{\displaystyle \frac{18(9\rho _2^29\rho _1\rho _255\rho _1\rho _3+30\rho _2\rho _3+25\rho _3^2)s}{(\rho _1+7\rho _2+19\rho _3+37\rho _4)^2R^2}}`$ (280)
$`+{\displaystyle \frac{18(64\rho _1\rho _4183\rho _2\rho _4+70\rho _3\rho _4+49\rho _4^2)s}{(\rho _1+7\rho _2+19\rho _3+37\rho _4)^2R^2}}`$
$`+{\displaystyle \frac{192(9\rho _1\rho _2\rho _2^2+19\rho _1\rho _326\rho _1\rho _4+63\rho _2\rho _4)s^2}{(\rho _1+7\rho _2+19\rho _3+37\rho _4)^2R^3}}`$
$`{\displaystyle \frac{576(5\rho _1\rho _2\rho _2^2+5\rho _1\rho _310\rho _1\rho _4+17\rho _2\rho _4)s^3}{(\rho _1+7\rho _2+19\rho _3+37\rho _4)^2R^4}}`$
$`+{\displaystyle \frac{768(2\rho _1\rho _3\rho _2^22\rho _1\rho _4+2\rho _2\rho _4)s^5}{(\rho _1+7\rho _2+19\rho _3+37\rho _4)^2R^6}},`$
4. $`\frac{3}{4}RsR:`$

$`P_3(s)`$ $`=`$ $`{\displaystyle \frac{18(64\rho _1\rho _339\rho _2\rho _325\rho _3^2+161\rho _1\rho _442\rho _2\rho _470\rho _3\rho _449\rho _4^2)s}{(\rho _1+7\rho _2+19\rho _3+37\rho _4)^2R^2}}`$ (284)
$`+{\displaystyle \frac{192(8\rho _2^2+28\rho _1\rho _39\rho _2\rho _3+37\rho _1\rho _4)s^2}{(\rho _1+7\rho _2+19\rho _3+37\rho _4)^2R^3}}`$
$`{\displaystyle \frac{576(4\rho _2^2+10\rho _1\rho _35\rho _2\rho _3+7\rho _1\rho _4)s^3}{(\rho _1+7\rho _2+19\rho _3+37\rho _4)^2R^4}}`$
$`+{\displaystyle \frac{768(\rho _2^2+2\rho _1\rho _32\rho _2\rho _3)s^5}{(\rho _1+7\rho _2+19\rho _3+37\rho _4)^2R^6}},`$
5. $`Rs\frac{5}{4}R:`$

$`P_3(s)`$ $`=`$ $`{\displaystyle \frac{18(25\rho _2\rho _325\rho _3^2+225\rho _1\rho _4106\rho _2\rho _470\rho _3\rho _449\rho _4^2)s}{(\rho _1+7\rho _2+19\rho _3+37\rho _4)^2R^2}}`$ (288)
$`+{\displaystyle \frac{192(35\rho _2\rho _38\rho _3^2+65\rho _1\rho _428\rho _2\rho _4)s^2}{(\rho _1+7\rho _2+19\rho _3+37\rho _4)^2R^3}}`$
$`{\displaystyle \frac{576(13\rho _2\rho _34\rho _3^2+17\rho _1\rho _410\rho _2\rho _4)s^3}{(\rho _1+7\rho _2+19\rho _3+37\rho _4)^2R^4}}`$
$`+{\displaystyle \frac{768(2\rho _2\rho _3\rho _3^2+2\rho _1\rho _42\rho _2\rho _4)s^5}{(\rho _1+7\rho _2+19\rho _3+37\rho _4)^2R^6}},`$
6. $`\frac{5}{4}Rs\frac{3}{2}R:`$

$`P_3(s)`$ $`=`$ $`{\displaystyle \frac{18(144\rho _295\rho _349\rho _4)\rho _4s}{(\rho _1+7\rho _2+19\rho _3+37\rho _4)^2R^2}}+{\displaystyle \frac{192(27\rho _3^2+72\rho _2\rho _435\rho _3\rho _4)s^2}{(\rho _1+7\rho _2+19\rho _3+37\rho _4)^2R^3}}`$ (290)
$`{\displaystyle \frac{576(9\rho _3^2+20\rho _2\rho _413\rho _3\rho _4)s^3}{(\rho _1+7\rho _2+19\rho _3+37\rho _4)^2R^4}}+{\displaystyle \frac{768(\rho _3^2+2\rho _2\rho _42\rho _3\rho _4)s^5}{(\rho _1+7\rho _2+19\rho _3+37\rho _4)^2R^6}},`$
7. $`\frac{3}{2}Rs\frac{7}{4}R:`$

$`P_3(s)`$ $`=`$ $`{\displaystyle \frac{882(\rho _3\rho _4)\rho _4s}{(\rho _1+7\rho _2+19\rho _3+37\rho _4)^2R^2}}+{\displaystyle \frac{192(91\rho _327\rho _4)\rho _4s^2}{(\rho _1+7\rho _2+19\rho _3+37\rho _4)^2R^3}}`$ (292)
$`{\displaystyle \frac{576(25\rho _39\rho _4)\rho _4s^3}{(\rho _1+7\rho _2+19\rho _3+37\rho _4)^2R^4}}+{\displaystyle \frac{768(2\rho _2\rho _4)\rho _4s^5}{(\rho _1+7\rho _2+19\rho _3+37\rho _4)^2R^6}},`$
8. $`\frac{7}{4}Rs2R:`$

$`P_3(s)`$ $`=`$ $`{\displaystyle \frac{12288\rho _4^2s^2}{(\rho _1+7\rho _2+19\rho _3+37\rho _4)^2R^3}}{\displaystyle \frac{9216\rho _4^2s^3}{(\rho _1+7\rho _2+19\rho _3+37\rho _4)^2R^4}}`$ (294)
$`+{\displaystyle \frac{768\rho _4^2s^5}{(\rho _1+7\rho _2+19\rho _3+37\rho _4)^2R^6}}.`$

A statistically tested random number generator and a special simulation technique  have been employed to numerically simulate the probability density functions, and the numerical results agree with our analytical results as discussed in Refs .

### E Geometric Probability Constants

We can also apply the preceding geometric probability techniques to evaluate the expectation values of $`\stackrel{}{r}_{12}\stackrel{}{r}_{23}`$ in $`n`$ dimensions, where $`\stackrel{}{r}_{12}=\stackrel{}{r}_2\stackrel{}{r}_1`$, $`\stackrel{}{r}_{23}=\stackrel{}{r}_3\stackrel{}{r}_2`$, and $`\stackrel{}{r}_1`$, $`\stackrel{}{r}_2`$ and $`\stackrel{}{r}_3`$ are three independent points produced randomly inside an $`n`$-dimensional uniform sphere of radius $`R`$. The quantity $`\stackrel{}{r}_{12}\stackrel{}{r}_{23}_n`$ is one of the geometric probability constants of interest and has important applications in physics . In $`3`$ dimensions,

$$\stackrel{}{r}_{12}\stackrel{}{r}_{23}_3=\left(x_2x_1\right)\left(x_3x_2\right)+\left(y_2y_1\right)\left(y_3y_2\right)+\left(z_2z_1\right)\left(z_3z_2\right).$$
(295)
Following Refs ,

$$\stackrel{}{r}_{12}\stackrel{}{r}_{23}_n=n\frac{_R^Rx^2V(n1,\sqrt{R^2x^2})𝑑x}{V(n,R)}=\frac{n}{n+2}R^2,$$
(296)
where

$$V(n,R)=\frac{\pi ^{\frac{n}{2}}R^n}{\mathrm{\Gamma }\left(\frac{n}{2}+1\right)}.$$
(297)
We can verify Eq. (296) by applying the geometric probability techniques directly so that

$$\stackrel{}{r}_{12}\stackrel{}{r}_{23}_n=\frac{1}{2}_0^{2R}s^2P_n(s)𝑑s=\frac{n}{n+2}R^2.$$
(298)
Following is a short list of $`\stackrel{}{r}_{12}\stackrel{}{r}_{23}_n`$ for selected values of $`n`$:

$`\stackrel{}{r}_{12}\stackrel{}{r}_{23}_1`$ $`=`$ $`{\displaystyle \frac{1}{3}}R^2,`$ (299)
$`\stackrel{}{r}_{12}\stackrel{}{r}_{23}_2`$ $`=`$ $`{\displaystyle \frac{1}{2}}R^2,`$ (300)
$`\stackrel{}{r}_{12}\stackrel{}{r}_{23}_3`$ $`=`$ $`{\displaystyle \frac{3}{5}}R^2,`$ (301)
$`\stackrel{}{r}_{12}\stackrel{}{r}_{23}_4`$ $`=`$ $`{\displaystyle \frac{2}{3}}R^2,`$ (302)
$`\stackrel{}{r}_{12}\stackrel{}{r}_{23}_5`$ $`=`$ $`{\displaystyle \frac{5}{7}}R^2.`$ (303)
Notice that as $`n`$ becomes large $`\stackrel{}{r}_{12}\stackrel{}{r}_{23}_nR^2`$. If we evaluate $`\stackrel{}{r}_{12}\stackrel{}{r}_{23}_n`$ in an $`n`$-dimensional spherical space with a Gaussian density distribution as defined in Eq. (71) and radius $`R\mathrm{}`$, then

$$\stackrel{}{r}_{12}\stackrel{}{r}_{23}_n=n\sigma ^2.$$
(304)
An interesting application of our formalism in biomedical physics is the calculation of the dynamic probability density function $`P(s,t)`$ in $`3`$ dimensions, as discussed in Ref. .

## VI Conclusions

A new formalism has been presented in this paper for evaluating the analytical probability density function of distance between two randomly sampled points in an $`n`$-dimensional sphere with an arbitrary density. We illustrate the power of this new geometric probability technique by demonstrating how $`n`$-dimensional integrals can be reduced $`1`$-dimensional integrals, even in the presence of $`r_c`$. We have shown that the classical result of Eq. (30) can be rederived from a simple intuitive picture, and that it can also be extended to an $`n`$-dimensional sphere with a non-uniform density distribution. Several density examples (Eqs. (63), (65), (99), (133), and (188)) were presented, and the analytical results were shown to be in agreement with Monte Carlo simulations. Applications to a variety of physical systems, such as neutron star models, have also been discussed.

## VII Acknowledgments

The authors wish to thank A. W. Overhauser, Michelle Parry, David Schleef, and Christopher Tong for helpful discussions. One of the authors (S. J. T.) also wishes to thank the Purdue University Computing Center for computing support. Conversations on numerical algorithms with Dave Seaman and Chinh Le are also acknowledged. This work was supported in part by the U.S. Department of Energy under Contract No. DE-AC02-76ER01428.

## A Geometry of Intersecting Circles

Here we briefly show why circles $`O_1`$ and $`O_2`$ are identical with the center of $`O_1`$ located at $`(0,0)`$ and $`O_2`$ located at $`(s,0)`$ as shown in Fig. 9. Following the discussion in Sec. II A, define a Cartesian coordinate system for points 1, 2, 3, and 4 as

$`(x_1,y_1)`$ $`=`$ $`(s/2,\sqrt{R^2s^2/4}),`$ (A1)
$`(x_2,y_2)`$ $`=`$ $`(s/2,\sqrt{R^2s^2/4}),`$ (A2)
$`(x_3,y_3)`$ $`=`$ $`(sR,\mathrm{\hspace{0.17em}0}),`$ (A3)
$`(x_4,y_4)`$ $`=`$ $`(R,\mathrm{\hspace{0.17em}0}).`$ (A4)
Assume that the equation for the circle $`O_2`$ is

$$(x\alpha )^2+y^2=r^2,$$
(A5)
where $`(\alpha ,0)`$ is the center and $`r`$ is the radius. Inserting Eqs. (A1), (A2), and (A3) into Eq. (A5) which expresses the fact that the circle $`O_2`$ contains points 1, 2, and 3. If $`s2R`$, then the only solution is $`\alpha =s`$ and $`r=R`$. This result means that circles $`O_1`$ and $`O_2`$ have identical radii and the center of $`O_2`$ is located at $`(s,0)`$.

## B Recursion Relations of $`𝑷_𝒏\mathbf{(}𝒔\mathbf{)}`$

We present in this Appendix some recursion relations for the probability density functions $`P_n(s)`$ which follow from the results in the text.

$$P_n^{}(s)=\frac{n1}{s}P_n(s)\frac{n}{B(\frac{n}{2}+\frac{1}{2},\frac{1}{2})}\frac{s^{n1}}{R^{n+1}}\left(1\frac{s^2}{4R^2}\right)^{\frac{n1}{2}}.$$
(B1)
$$P_n^{\prime \prime }(s)=\frac{n(n1)}{s^2}P_n(s)+\frac{2(n1)}{s}P_n^{}(s)+\frac{n(n1)}{4B(\frac{n}{2}+\frac{1}{2},\frac{1}{2})}\frac{s^n}{R^{n+3}}\left(1\frac{s^2}{4R^2}\right)^{\frac{n3}{2}}.$$
(B2)
$$\left(1\frac{s^2}{4R^2}\right)P_n^{\prime \prime }(s)\frac{n1}{s}\left(2\frac{3}{4}\frac{s^2}{R^2}\right)P_n^{}(s)+\frac{n1}{s^2}\left[n\left(\frac{2n1}{4}\right)\frac{s^2}{R^2}\right]P_n(s)=0.$$
(B3)
$`\left(1{\displaystyle \frac{s^2}{4R^2}}\right)\left[P_n^{\prime \prime }(s){\displaystyle \frac{2(n1)}{s}}P_n^{}(s)+{\displaystyle \frac{n(n1)}{s^2}}P_n(s)\right]`$ (B4)
$`(n1)\left({\displaystyle \frac{s^2}{4R^2}}\right)\left[{\displaystyle \frac{1}{s}}P_n^{}(s)+{\displaystyle \frac{n1}{s^2}}P_n(s)\right]=0.`$ (B5)
$$P_{n+2}(s)=\frac{n+2}{n}\frac{s^2}{R^2}P_n(s)\frac{1}{\pi }\frac{(n+2)!!}{(n+1)!!}\frac{s^{n+2}}{R^{n+3}}\left(1\frac{s^2}{4R^2}\right)^{\frac{n+1}{2}}(n=\mathrm{even}).$$
(B6)
$`2P_n(s)`$ $`=`$ $`{\displaystyle \frac{n}{n+2}}{\displaystyle \frac{R^2}{s^2}}P_{n+2}(s)+{\displaystyle \frac{n}{n2}}{\displaystyle \frac{s^2}{R^2}}P_{n2}(s)`$ (B8)
$`{\displaystyle \frac{1}{\pi }}{\displaystyle \frac{n!!}{(n+1)!!}}{\displaystyle \frac{s^n}{R^{n+1}}}\left(1+n{\displaystyle \frac{s^2}{4R^2}}\right)\left(1{\displaystyle \frac{s^2}{4R^2}}\right)^{\frac{n1}{2}}(n=\mathrm{even}).`$
$$P_{n+2}(s)=\frac{n+2}{n}\frac{s^2}{R^2}P_n(s)\frac{1}{2}\frac{(n+2)!!}{(n+1)!!}\frac{s^{n+2}}{R^{n+3}}\left(1\frac{s^2}{4R^2}\right)^{\frac{n+1}{2}}(n=\mathrm{odd}).$$
(B9)
$`2P_n(s)`$ $`=`$ $`{\displaystyle \frac{n}{n+2}}{\displaystyle \frac{R^2}{s^2}}P_{n+2}(s)+{\displaystyle \frac{n}{n2}}{\displaystyle \frac{s^2}{R^2}}P_{n2}(s)`$ (B11)
$`{\displaystyle \frac{1}{2}}{\displaystyle \frac{n!!}{(n+1)!!}}{\displaystyle \frac{s^n}{R^{n+1}}}\left(1+n{\displaystyle \frac{s^2}{4R^2}}\right)\left(1{\displaystyle \frac{s^2}{4R^2}}\right)^{\frac{n1}{2}}(n=\mathrm{odd}).`$
$$P_{n+2}(s)=\frac{n+2}{n}\frac{s^2}{R^2}P_n(s)\frac{1}{B(\frac{n}{2}+\frac{3}{2},\frac{1}{2})}\frac{s^{n+2}}{R^{n+3}}\left(1\frac{s^2}{4R^2}\right)^{\frac{n+1}{2}}.$$
(B12)
$`2P_n(s)`$ $`=`$ $`{\displaystyle \frac{n}{n+2}}{\displaystyle \frac{R^2}{s^2}}P_{n+2}(s)+{\displaystyle \frac{n}{n2}}{\displaystyle \frac{s^2}{R^2}}P_{n2}(s)`$ (B14)
$`{\displaystyle \frac{1}{n+2}}{\displaystyle \frac{1}{B(\frac{n}{2}+\frac{3}{2},\frac{1}{2})}}{\displaystyle \frac{s^n}{R^{n+1}}}\left(1+n{\displaystyle \frac{s^2}{4R^2}}\right)\left(1{\displaystyle \frac{s^2}{4R^2}}\right)^{\frac{n1}{2}}.`$