I am currently a first year graduate student in theoretical chemistry, and for a subsection of my research project, I am trying to numerically integrate a 3-dimensional function using Gauss-Legendre quadrature over the the excluded space between an inscribed sphere and the faces of a cube using spherical polar coordinates. This a quick drawing of the geometric system for clarity.


The excluded volume outside of the sphere and inside the cube can can be split into 48 equal slices and one of these $\frac{1}{48}$ regions can be integrated using the integral $I_1$ below:

$$I_1 = \int_0^{\pi/4} d\phi \int_{arctan[csc(\phi)]}^{\pi/2} sin\theta d\theta \int_L^{L/sin\theta cos\phi} F(r,\theta,\phi)r^2 dr$$

In this system, the length of the cube is $2L$ where $L$ is the radius of the inscribed sphere. $F(r,\theta,\phi)$ is an arbitrary 3D function and a snapshot of this region with quadrature points graphed with matplotlib in cartesian coordinates is here. (In this plot $L = 11.34$, and the blue points are the corners of the cube)


I have no trouble getting the correct numerical value for this specific $\frac{1}{48}$ slice in $I_1$, but when I try to reflect or rotate these quadrature points to fill the entire excluded cubic space, (keeping the weights matched with the point in space being transformed) I get wildly incorrect answers with the exception of a $\pi$ rotation about the z-axis unit vector.

This likely has to do with an integral bound transformation, as I found one more exception through guessing and checking that works for the reflection of the original slice in $I_1$ where the x and y cartesian coordinates are swapped. The following integral that works for this reflected slice is shown below as $I_2$:

$$I_2 = \int_{\pi/4}^{\pi/2} d\phi \int_{arctan[sec(\phi)]}^{\pi/2} sin\theta d\theta \int_L^{L/sin\theta sin\phi} F(r,\theta,\phi)r^2 dr$$

The heart of my question is then: Do I need to find specific integral bounds for each of the 48 individual slices, or is there a general rule that can be used to easily reflect and transform my bounds to integrate my quadrature points correctly, since the magnitude of the bounds of every single slice is the same?

Side note: I am just integrating the unit function $F(r,\theta,\phi) = 1$, so I should get the same volume back as my integral value for every slice.


Answer: For anyone who comes across a similar problem, I found that my problem was with numerical integration, and that only $I_1$ is necessary to use as the original bound.

More specifically, you can store the bounds over the original $\frac{1}{48}$ slice into your values for the weights, and subsequently use these original weights for any other slice to evaluate your function in the entire excluded cubic region.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.