# Surface integral and divergence theorem do not match, cylindrical coordinates

I want to solve the following problem using both direct surface integration and divergence theorem, but the results somehow do not match. I could not troubleshoot where do I do wrong. Please help me troubleshoot this.

Calculate the flux of the flux $\vec{J}$ going through the surface of the cylinder (including both circle cap at z = 0 and z = L) for $0 < r < R$, $0 < z < L$, and $0 < \theta < 2\pi$. $\vec{J}$ is already in cylindrical coordinates.

$$\vec{J}(r,\theta,z) = [(1-r^2)z,\, r-z,\,ln(z+1)]$$

Using divergence theorem, I get the below results. I am able to check this one using Mathematica so I am thinking this should be the right results for both methods: $$\iiint_Vdiv\vec{J}dV = \pi R[L^2(1-R^2)+Rln(L+1)]$$

Using surface integrals: $$\iint_S\vec{J}.d\vec{S} = \iint_{circle\,cap\,at\,z=0}T + \iint_{circle\,cap\,at\,z=L}T + \iint_{cylinder}T$$ where $$T=\vec{J}(\vec{r}(u,v)).||\frac{\partial \vec{r}}{\partial u} \times \frac{\partial \vec{r}}{\partial v}||\,dudv$$

For circle cap at z = 0, $\vec{r}(r,\theta)=[r cos\theta, \,rsin\theta,\,0]$. Doing integration I get 0.

For circle cap at z = L, $\vec{r}(r,\theta)=[r cos\theta, \,rsin\theta,\,0]$. Doing integration I get $\pi R^2 ln(L+1)$. This is the second term in divergence theorem result.

For cylinder, $\vec{r}(\theta,z)=[R cos\theta, \,R sin\theta,\,z]$. Doing integration I get zero. I believe this is where I do wrong so I will put some details here: $$\vec{N}=||\frac{\partial \vec{r}}{\partial \theta} \times \frac{\partial \vec{r}}{\partial z}|| = [Rcos\theta,\,Rsin\theta,\,0]$$ $$\vec{J}.\vec{N}=(R-R^3)z\,cos\theta + (R^2-Rz)\,sin\theta$$ Plut in expression for $\vec{J}.\vec{N}$ for the below integration to calculate surface flux, I will get zero because integral of sin/cos equal to -cos/sin, from 0 to $2\pi$, will produce zero term in the product. $$\int_0^L \int_0^{2\pi} \vec{J}.\vec{N}\,d\theta dz=0$$

Thus, the overall sum of surface integrals will only be $\pi R^2 ln(L+1)$, which doesn't match the divergence theorem method result.

Your surface integrals look correct. I suspect a problem with the divergence theorem. $\vec{J}$ should be a continuously differentiable vector field, and I don't believe it is. $\nabla \cdot \vec{J}=\frac{z}{r}-3rz+\frac{1}{z+1}$, which is not well defined on $\mathbb{R}^3$.