# Divergence theorem non continuously differentiable

In class we calculated the electric field in- and outside a charge distribution: $$\rho(r)= \begin{cases} \cos(r)+\frac{1}{r}\sin(r) &\text{if }r\leq R \\ 0 &\text{if }r>R \end{cases}$$

We used the divergence theorem to calculate this. But as far as I know, this theorem only applies if $\rho$ is continuously differentiable. Why can we apply this then?

• Your function $\rho$ is $C^\infty(\mathbb R^3\setminus S^2)$, and the two-sphere has zero measure, so everything works just fine. To be pedantic, you can consider the integral over $\mathbb R^3$ minus $B(R+\epsilon)-B(R-\epsilon)$, and take the limit $\epsilon\to0$. – AccidentalFourierTransform Mar 12 '18 at 13:59