Consider a continuous charge distribution in volume $V'$. Draw a closed surface $S$ inside the volume $V'$.
Consider the following multiple integral:
$$A=\iiint_{V'} \left[ \iint_S \dfrac{\cos(\hat{R},\hat{n})}{R^2} dS \right] \rho'\ dV' =4 \pi\ m_s$$
where
$R=|\mathbf{r}-\mathbf{r'}|$
$\mathbf{r'}=(x',y',z')$ is coordinates of source points
$\mathbf{r}=(x,y,z)$ is coordinates of field points
$\cos(\hat{R},\hat{n})$ is the angle between $R$ and normal to surface element
$\rho'$ is the charge density and is continuous throughout the volume $V'$
$m_s$ is the total charge inside surface $S$
Also consider the following multiple integral:
$$B= \iint_S \left[ \iiint_{V'} \dfrac{\cos(\hat{R},\hat{n})}{R^2} \rho'\ dV' \right] dS$$
where the symbols have the meanings stated above.
\begin{align} B &= \iint_S \left[ \iiint_{V'} \rho' \dfrac{\hat{R} \cdot \hat{n}}{R^2} \ dV' \right] dS\\ &=\iint_S \left[ \iiint_{V'} \rho' \dfrac{\hat{R} }{R^2} \ dV' \right] \cdot \hat{n}\ dS\\ &=\iint_S \mathbf{E} \cdot \hat{n}\ dS \end{align}
Is $A=B\ ?$
i.e. Is interchanging the order of surface and volume integration valid? I know it is usually valid but my doubt is due to the following reasons:
- In the surface integral of equation $A$, when $\mathbf{r'} \in S$, we can only use spherical coordinate system with origin at point $\mathbf{r'}$ (in order to avoid improper integral with limits). So while computing $A$, we cannot use only one coordinate system. Instead, we have to use infinitely many coordinate systems.
- In the volume integral of equation $B$, for all $\mathbf{r}$, i.e. for all $\mathbf{r} \in S$, we can only use spherical coordinate system with origin at point $\mathbf{r}$ (in order to avoid improper integral with limits). So while computing $B$, we cannot use only one coordinate system. Instead, we have to use infinitely many coordinate systems.
Edit:
I know $\int \left[\int f(x,y)\,dx \right]dy = \int \left[\int f(x,y)\,dy \right]dx$ is true usually. Also, if in the diagram, if the volume $V'$ is contained within the surface $S$, then it is valid to change the order of integration. But here the issue is a little different. The surface $S$ is inside the volume $V'$ (please have a look at my diagram) and thus improper integral comes into play.
While computing $A$, if we need to avoid improper integrals, we have no choice except to work with infinitely many spherical coordinate systems each having their origin at points $\in V'$.
Similarly while computing $B$, if we need to avoid improper integrals, we have no choice except to work with infinitely many spherical coordinate systems each having their origin at points $\in S$.
Then how is it valid to change the order of integration in this situation? That is, how can $A=B?$