# Divergence theorem does not hold for this vector field?

I'm trying to verify the divergence theorem for the vector field $$\vec F = r^2\cos\theta\vec e_r + r^2\cos\phi\vec e_\theta - r^2\cos \theta\sin\phi \vec e_\phi$$ over the part of the sphere of radius $R$ in the positive octant of $\Bbb R^3$.

I'm pretty sure I did the volume part correctly. I got $\frac{1}{4}\pi R^4$. But in the surface part I'm getting an extra term: $-\frac 12R^4$. Here's what I did:

I split the surface into $4$ parts:

The first is the spherical part. It has outward normal $\vec e_r$ and is described by $r=R$, $0\le \theta \le \frac {\pi}2$, and $0 \le \phi \le \frac {\pi}2$.

\begin{align*} \int \vec F \cdot \vec e_r\ da &= \int_{0}^{\pi/2}\int_{0}^{\pi/2} r^2\cos(\theta)\ r^2\sin(\theta)d\theta d\phi \\ &= \frac 14\pi R^4 \end{align*}

Since this should be the correct answer (I think), the others parts should add to zero.

Next the part in the $xy$-plane. It has outward normal $-\vec e_z$ and is described by $0 \le r \le R$, $\theta=\frac{\pi}{2}$, and $0 \le \phi \le \frac{\pi}{2}$.

\begin{align*} \int \vec F\cdot -\vec e_z\ da &= -\int_0^{\pi/2}\int_0^{R} \left[r^2\cos^2(\theta)+r^2\cos(\phi)\sin(\theta)\right]\ r\sin(\theta)drd\phi \\ &= -\int_0^{\pi/2}\int_0^{R} r^3\cos(\phi)\ drd\phi \\ &= -\frac{1}{4}R^4 \end{align*}

The other two planar parts are described similarly by $0\le r\le R$, $0 \le \theta \le \frac{\pi}{2}$, and $\phi = \frac{\pi}{2}$ and by $0\le r\le R$, $0 \le \theta \le \frac{\pi}{2}$, and $\phi = 0$. Here are the integrals I computed:

\begin{align*} \int \vec F\cdot -\vec e_x\ da &= -\int_0^{\pi/2}\int_0^R \left[r^2\cos(\theta)\sin(\theta)\cos(\phi) +r^2\cos(\theta)\cos^2(\phi) +r^2\cos(\theta)\sin^2(\phi) \right]\ rdrd\theta \\ &= -\int_0^{\pi/2}\int_0^R r^3\cos(\theta)\ drd\theta \\ &= -\frac{1}{4}R^4 \\ \int \vec F \cdot -\vec e_y\ da &= -\int_0^{\pi/2}\int_0^R r^3\left[\cos(\theta)\sin(\theta)\sin(\phi) + \cos(\phi)\cos(\theta)\sin(\phi) - \cos(\theta)\sin(\phi)\cos(\phi)\right]\ drd\theta \\ &= 0 \end{align*}

It seems like I must have just made a sign mistake in either my second or third integral, but I'm not seeing it. Can anyone see where I'm going wrong?

• I figured it out. When I did $\vec e_\theta \cdot (-\vec e_z)$ for the second integral I left off one of the negative signs. That fixed it. – user364501 Aug 28 '16 at 19:54