# Leibniz integral rule for an arbitrary number of dimensions

Suppose we have $$N$$ particles whose coordinates are given by $$\mathbf{r}_{i}$$. These coordinates are confined to be within a three-dimensional unit cell defined by $$\mathcal{V}=\left[0,L_{x}\right]\times\left[0,L_{y}\right]\times\left[0,L_{z}\right]$$

(For simplicity, we may assume $$L_{x}=L_{y}=L_{z}\equiv L$$). We shall also assume periodic boundary conditions, i.e., for example, $$f\left(x_i=0\right)=f\left(x_i=L_{x}\right)$$ (and same for the other Cartesian components and particles). Consider the integral

$$I = \int_{\Omega}dR\;f\left(R,t\right)$$

where $$R$$ represents the collection of coordinates $$\mathbf{r}_1,\dots,\mathbf{r}_N$$ and $$dR=d\mathbf{r}_{1}\dots d\mathbf{r}_{N}$$. The volume of integration $$\Omega$$ is essentially the hyper-volume $$\mathcal{V}^{N}$$ formed by the unit cell $$\mathcal{\mathcal{V}}$$.

Now, suppose we perform the change of coordinates $$\bar{\mathbf{r}}_{i}=c\left(t\right)\mathbf{r}_{i}$$, where $$c\left(t\right)$$ is some function of $$t$$. For example, $$\bar{\mathbf{r}}_{i}=t^{\alpha}\mathbf{r}_{i}$$, where $$\alpha$$ is some constant.

I would like to calculate the derivative of the transformed $$I$$ with respect to $$t$$, i.e.,

$$\frac{d}{dt}\int_{\bar{\Omega}\left(t\right)}d\bar{R}\;f\left(\bar{R},t\right) J(t)$$

where the transformed quantities are marked with a bar, and $$J(t)$$ is the Jacobian term that results from the change of coordinates. Note that after this substitution, the volume of integration depends on $$t$$, because $$\bar{\mathcal{V}}=\left[0,c(t) L_{x}\right]\times\left[0,c(t) L_{y}\right]\times\left[0, c(t) L_{z}\right]$$. According to Leibniz integral rule,

$$\frac{d}{dt}\int_{\bar{\Omega}\left(t\right)}d\bar{R}\;f\left(\bar{R},t\right)J(t)=\int_{\bar{\Omega}\left(t\right)}d\bar{R}\;\frac{\partial}{\partial t}\left[f\left(\bar{R},t\right)J(t)\right]+\underbrace{\int_{\partial\bar{\Omega}\left(t\right)}f\left(\bar{R},t\right)J(t)\;U\cdot d\mathbf{\Sigma}}_{\text{boundary term}}$$

where $$\partial\bar{\Omega}\left(t\right)$$ is the boundary of the integration hyper-volume, $$U$$ is the velocity of the boundary (rate of change with $$t$$) and $$d\mathbf{\Sigma}$$ is a surface element.

However, I have trouble evaluating $$U\cdot d\mathbf{\Sigma}$$ even for the simple cubic geometry provided here. For example, I am unsure how to calculate $$U$$, or how to properly account for the orientation of the surface element.

This question could be asked just as well for any integral of the form $${\cal I}:=\int_{\bar{\Omega}(t)}d\bar{R}\;G(\bar{R},t).$$ Since there are $$N$$ particles, the box $$\bar{\Omega}(t)$$ will be a product of $$3N$$ intervals: $$\bar{\Omega}(t)=([0,c(t) L_{x}]\times[0,c(t) L_{y}]\times[0, c(t) L_{z}])^N.$$ If you increase $$t$$ by an infinitesimal amount $$dt$$, $$\cal I$$ will change in two ways: first because the integrand changes, giving an increment of $$dt \int_{\bar{\Omega}(t)}d\bar{R}\;\frac{\partial }{\partial t}G(\bar{R},t),$$ and second because the volume of integration changes. For example, if you take the $$y$$ coordinate of the $$i$$th particle, its interval of integration will change from $$[0, c(t)L_y]$$ to $$[0, c(t)L_y + (d c/d t) L_y dt]$$, adding (assuming that $$d c/d t>0$$) the interval $$[c(t)L_y, c(t)L_y + (d c/d t) L_y dt]$$. Taking the product of this with the $$3N-1$$ other intervals of those whose product equals $$\bar\Omega(t)$$ then gives a small extra slice of volume that you must integrate over. You can approximate this by a surface integral over the portion of $$\partial \bar\Omega(t)$$ where $$\bar y_i=c(t)L_y$$, giving an increment of $$\frac{d c}{d t} L_y dt \int_{\partial\bar\Omega(t),\ \bar y_i=c(t)L_y} d{\bar R'_{y,i}} G(\bar R, t)$$ where you are now integrating only over the $$3N-1$$ coordinates $$\bar R'_{y,i}$$ which exclude $$\bar y_i$$. Since the box $$\bar\Omega(t)$$ has $$3N$$ moving boundaries, you will get $$3N$$ increments of this sort. Adding them up will give $$\begin{eqnarray*} d{\cal I}&=&dt \int_{\bar{\Omega}(t)}d\bar{R}\;\frac{\partial }{\partial t}G(\bar{R},t)\\ &+&\sum_{1\le i\le N}\frac{d c}{d t} L_x dt \int_{\partial\bar\Omega(t),\ \bar x_i=c(t)L_x} d{\bar R'_{x,i}} G(\bar R, t)\\ &+&\sum_{1\le i\le N}\frac{d c}{d t} L_y dt \int_{\partial\bar\Omega(t),\ \bar y_i=c(t)L_y} d{\bar R'_{y,i}} G(\bar R, t)\\ &+&\sum_{1\le i\le N}\frac{d c}{d t} L_z dt \int_{\partial\bar\Omega(t),\ \bar z_i=c(t)L_z} d{\bar R'_{z,i}} G(\bar R, t). \end{eqnarray*}$$ You can express the $$3N$$ boundary terms as a surface integral $$dt \int_{\partial\bar{\Omega}\left(t\right)}G\left(\bar{R},t\right) U\cdot d\mathbf{\Sigma}$$ if you let $$d\mathbf{\Sigma}$$ have the same magnitude as $$d{\bar R'_{x,i}}$$, $$d{\bar R'_{y,i}}$$ or $$d{\bar R'_{z,i}}$$ (so, it measures $$3N-1$$-dimensional hypervolume in the usual way), and let it point outwards from the cube (for example, towards the negative $$x$$ axis for $${\bf\bar r}_i$$ on the hyperface $$\bar x_i=0$$, and towards the positive $$z$$ axis for $${\bf\bar r}_j$$ on the hyperface $$\bar z_j=c(t) L_z.$$) $$U$$ can be taken to be zero on the $$3N$$ hyperfaces where $$\bar x_i=0$$, $$\bar y_i=0$$, or $$\bar z_i=0$$, since they are not moving, and you can take it to have the same direction as $$d\mathbf{\Sigma}$$ and magnitude $$L_x (dc/dt)$$, $$L_y (dc/dt)$$, and $$L_z (dc/dt)$$ on the $$3N$$ hyperfaces where $$\bar x_i=c(t)L_x$$, $$\bar y_i=c(t)L_y$$, and $$\bar z_i=c(t)L_z$$, respectively. The choice of $$U$$ is somewhat arbitrary since you could add to it any vector perpendicular to $$d\mathbf{\Sigma}$$, corresponding to a sidewise translation of the cube hyperface, without changing the result. (If $$dc/dt<0$$, the box will be shrinking instead of expanding, so $$U$$ should point in the opposite direction to $$d\mathbf{\Sigma}$$.)