Computing (distributional) gradient of a singular function This question could well belong better to the physics stackexchange, but I'm hoping that posting it here could give me a more mathematical perspective.
I am trying to find the expression for the electric field of a point dipole $\vec{d}$, which I have figured out the expression for its potential to be $\phi = \frac{\vec{d}\cdot\vec{r}}{4\pi|\vec{r}|^3}$. To find the electric field I need to take its gradient, to which I get:
\begin{align}
\vec{E} = -\nabla\phi = \frac{3(\vec{d}\cdot\hat{r})\hat{r}-\vec{d}}{4\pi|\vec{r}|^3}
\end{align}
However I was told that the expression is not valid at the origin, and one has to add a correction term:
\begin{align}
\vec{E} = -\nabla\phi = \frac{3(\vec{d}\cdot\hat{r})\hat{r}-\vec{d}}{4\pi|\vec{r}|^3}-\frac{4\pi}{3}\delta^3(\vec{r})\vec{d},
\end{align}where $\delta^3(\vec{r})$ is the three dimensional dirac delta function. Could someone explain the reasoning behind this? Does this have something to do with ensuring that $\vec{E}$ acts correctly on the some space of compactly supported functions?
 A: From what I gathered when checking some sources, the dirac delta at the origin comes from an ad-hoc argument rather than anything mathematical (cf. also this preprint which shortly revises how one can justify the delta). Mathematically speaking, the mapping in question is
$$
\phi_{\vec d}: \mathbb R^3\setminus\lbrace0\rbrace\to\mathbb R^3\quad\qquad \vec r\mapsto \frac{\langle\vec d,\vec r\rangle}{4\pi\|\vec r\|^3}
$$
for some fix $\vec d\in\mathbb R^3$ which is infinitely differentiable on the open set $\mathbb R^3\setminus\lbrace0\rbrace$ but can not be continuously extended to $\mathbb R^3$ let alone be differentiated at the origin, unless we are in the trivial case $\vec d=0$ (which we shall exclude explicitely for what follows).
At first glance it seems that $\lim_{\|\vec r\|\to 0}\phi_\vec d(\vec r)=\infty$, so this is what we define as $\phi_\vec d(0)$ to in same rather "weird" way justify a delta "function" - this however is not true (check the example below). Even the limit $\lim_{\vec r\to 0}|\phi_{\vec d}(\vec r)|$ usually does not exist as it depends on the direction at which one approaches the origin. 
To be more precise, as an example we may choose $\vec d=(1,0,-1)$ so
$$
\phi_{\vec d}(r_1,r_2,r_3)=\frac{r_1-r_3}{4\pi(r_1^2+r_2^2+r_3^2)^{3/2}}\,.
$$
Choosing the real null sequences $\vec r_n=(\frac 1n,0,0)$, $\vec s_n=(0,\frac 1n,0)$ and $\vec t_n=(0,0,\frac1n)$ for $n\in\mathbb N$ yields
$$
\lim_{n\to\infty} \phi_{\vec d}(\vec r_n)= +\infty\qquad \lim_{n\to\infty} \phi_{\vec d}(\vec s_n)=0 \qquad\lim_{n\to\infty} \phi_{\vec d}(\vec t_n)= -\infty
$$
so the path on which you approach the origin does matter for the limit (even for the limit of the absolute value $|\phi_\vec d(\vec r)|$), which would not happen if the limit in question existed in the usual sense. Of course if there is no meaningful continuous extension of the mapping to the origin, speaking about differentiating it in the usual way is out of the question per se.
