# Understanding a computation of a surface integral on a cube

Calculate the flow of the vector field $$\mathbf{A} = \nabla \dfrac{\mathbf{a}\cdot\mathbf{r}}{r^3}$$ from a cube with side length $1$, centered at origin and with one space diagonal parallel with the constant vector $\mathbf{a}$.

Attempted solution

Let the $z$-axis run parallel to $\mathbf{a}$ in a cartesian coordinate system. Introduce spherical coordinates so that $$\mathbf{A} = \nabla \dfrac{\mathbf{a}\cdot\mathbf{r}}{r^3} = \nabla \dfrac{a\cos\theta}{r^2} = \sum_{i} \dfrac{1}{h_i} \dfrac{\partial (\dfrac{a\cos\theta}{r^2})}{\partial u_i} \hat{e}_i = \dfrac{-2a\cos\theta}{r^3}\hat{e}_r - \dfrac{a\sin\theta}{r^3}\hat{e}_{\theta}$$ Now what my book does is saying that $\nabla \cdot\mathbf{A}=0$ for $r\neq0$ and that the flow out of the cube is the same as the flow out ofa sphere centered at origin. It then goes to show that $$\iint_{r=R}\mathbf{A}\cdot \hat{e}_r dS = -\dfrac{2a}{R}2\pi \int_{0}^{\pi}\cos\theta\sin\theta d\theta=0$$ I understand every step except for:

1) Why did they calculate the divergence? (If Gauss' theorem is applicable here (which it should be) then that would give the result instantly).

2) How can they claim the flow is the same for the cube as it is for some sphere with radius $R$?

• I have changed your title. I wish you agree it. Two reasons: 1) "Weird", "extraordinary difficult", "I will commit suicide if I don't have the solution" etc. should not be part of a title. 2) A title should contain as much keywords as possible for subsequent searches. – Jean Marie May 19 '17 at 12:17
• Why in the world would you "introduce polar coordinates" when each side is a square? That makes the limits of integration very complicated! A cube has six faces. For the unit cube, with side length 1, those faces are: the z= 0 plane, the z= 1 plane, the x= 0 plane, the x= 1 plane, the y= 0 plane, and the y= 1 plane. – user247327 May 19 '17 at 12:18
• "2) How can they claim the flow is the same for the cube as it is for some sphere with radius R?" Imagine the sphere surrounding the cube. Anything that flows out of the cube doesn't just "stop flowing". It flows on out of the sphere. – user247327 May 19 '17 at 12:21
• Now, I see why they use spherical coordinates- using a sphere that contains the cube allows us to do one integration rather than the 6 needed for the 6 sides of the cube. But they are not that difficult. I would recommend actually integrating over the cube itself as a check. – user247327 May 19 '17 at 12:23

Since the divergence vanishes away from the origin, the volume integral $\int_V (\nabla\cdot\mathbf{A})dV$ will be unchanged if we replace $V$ with some other volume $V'$ that also contains the origin; in particular, we can take $V'$ to be the unit ball $B$ with boundary $S^2$. We can then use the divergence theorem once again, so that in total we have $$\iint_{\partial V} \mathbf{A}\cdot d\mathbf{S}=\iiint_{V} (\nabla \cdot\mathbf{A})\,dV=\iiint_{B} (\nabla \cdot\mathbf{A})\,dV=\iint_{S^2} \mathbf{A}\cdot d\mathbf{S}.$$
As for why one can't use Gauss's law to immediately conclude that the integral is zero, suppose we instead had $\mathbf{A}=\nabla(1/r)$: this still has divergence zero away from the origin, but there's now a net flux through the unit sphere. So evidently knowing that $\nabla\cdot \mathbf{A}=0$ away from the origin isn't enough to conclude that the integral vanishes. (The point is that $\mathbf{A}\to \infty$ at the origin, so one shouldn't expect $\nabla\cdot \mathbf{A}=0$ at $r=0$. For details see the solutions to this question: https://physics.stackexchange.com/q/14095/55641.)