I was searching for a fundamental proof of Gauss Law using the divergence of the electric field. In three dimensions the divergence of $\hat{r}/r^2$ evaluates to 0. So a book I was reading said that since the divergence is 0 it is expected that the flux through a closed 3D volume is also 0. However if we calculate the flux through a 3D closed body then it evaluates to $q/e_0$. The explanation given is that the divergence of the electric field of a point charge can be considered to be a Dirac delta function which I have not completely understood why. Interestingly I observed that the divergence was only equal to 0 in 3 dimensions. For arbitrary $n$ spacial dimensions I observed a pattern: $$\nabla (\frac{\hat{r}} {r^2})= \frac{(n-3)}{r^3}. $$
Now according to what the book said we also need to consider a term which incorporates the Dirac delta function.
So $$\nabla (\frac{\hat{r}} {r^2} )= 4\pi\delta^n(r) + \frac{(n-3)}{r^3}. $$
(The constant $4\pi $ appears so as to satisfy the conditions for a 3D closed sphere.)
Now what I thought of doing here was taking the integral of the divergence over a n-dimensional sphere. Thus I thought of defining flux through a n-dimensional closed surface as the $n$-volume integral of the divergence.
So, $$ \int_{0}^{r}\frac{q}{4\pi e_0}\nabla (\frac{\hat{r}} {r^2} ) d\tau_n = \frac{q}{4\pi e_0}\int_{0} ^{r} 4\pi\delta^n(r) d\tau_n + \frac{q}{4\pi e_0} \int_{0} ^{r} \frac{(n-3)}{r^3}d\tau_n$$
Where $d\tau_n$ is the elemental of a $n$-volume sphere.
After surfing the web I found an expression for the $n-1$-volume (which I have represented by $\tau_{n-1} $ and then related it to $d\tau_n$.
$$\tau_{n-1}= \frac{n\pi^{\frac{n}{2}} r^{n-1}}{\gamma(\frac{n}{2})}$$
Where $ \gamma(\frac{n}{2})$ is the gamma function.
Thus, using $d\tau_n= \tau_{n-1}* dr$
Sparing the calculation over here , the integral evaluates to :
$ \frac{q}{4\pi e_0} \frac{n\pi^{\frac{n}{2}} r^{n-3} (n-3)}{\gamma(\frac{n}{2})( n-3)} $ for n $ \neq3$ as the integral containing the Dirac Delta function vanishes for all n $ \neq3$.
Also I have purposely written the n-3 terms which appear while integrating to comment on the continuity of this expression around n = 3.
For n = 3, we have to explicitly solve the expression because the integral containing the Dirac delta function does not vanish.
Calculating we get $\frac{q}{e_0} $ which was expected.
The problem that arose with this is that it is not continuous at n=3.
So this is leading me to believe that our assumption of the Dirac delta function was wrong. If we completely ignore the term of the Dirac delta function and take the limit as n approaches 3 then I observed that :
$ \int_{0}^{r}\frac{q}{4\pi e_0}\nabla (\frac{\hat{r}} {r^2} ) d\tau_n = \frac{q}{4\pi e_0} \frac{n\pi^{\frac{n}{2}} r^{n-3} (n-3)}{\gamma(\frac{n}{2})( n-3)} $
This is continuous around n = 3 and approaches the value $\frac{q}{e_0} $ !!
So I think that the assumption that the divergence is a Dirac delta function seems mathematically wrong and the above result seems to justify this. However all the sources I referred to have done the same and further I do not exactly know why we can make this assumption. I would like to know why we do so and also why the above result is not consistent with this assumption.