Gradient of an Electric Dipole This may seem like a physics question but I am trying to solve it from a mathematics book actually. An electric dipole is given as:
$$\psi(\overrightarrow r) = \frac{\overrightarrow p ⋅ \overrightarrow r}{4\pi\epsilon_0r^3} $$
Now I need to prove that 
$$\overrightarrow ∇\psi(\overrightarrow r) =  \frac{\overrightarrow p - 3\hat{r}(\overrightarrow p ⋅ \hat r)}{4\pi\epsilon_0r^3}$$
I used $∇$ in spherical coordinates and put $\overrightarrow r = r × \hat{r}$. No matter what I do I can only find
$$ \overrightarrow ∇\psi(\overrightarrow r) = \frac{-3\overrightarrow p}{4\pi\epsilon_0r^3}$$
Could you please help me with this? Thank you very much in advance!!
 A: To reduce some of the visual clutter in the problem statement, define 2 new variables 
$$\eqalign{
 a &= \frac{p}{4\pi\epsilon_0} \cr
 \lambda &= \|r\| \cr
}$$
Note that 
$$\eqalign{
 \lambda^2 &= r\cdot r \cr
 \lambda\,d\lambda &= r\cdot dr \cr\cr
}$$
Write the function in terms of these new variables, then find its differential and gradient
$$\eqalign{
 \psi &= \frac{a\cdot r}{\lambda^3} \cr
\cr
d\psi
 &= \frac{a\cdot dr}{\lambda^3} -\frac{3(a\cdot r)\,d\lambda}{\lambda^4} \cr
 &= \frac{a\cdot dr}{\lambda^3} -\frac{3(a\cdot r)\,(r\cdot dr)}{\lambda^5} \cr
 &= \frac{a-(3a\cdot{\hat r})\,{\hat r}}{\lambda^3}\cdot dr \cr
\cr
\nabla\psi
  &= \frac{a-(3a\cdot {\hat r})\,{\hat r}}{\lambda^3} \cr
  &= (I-3{\hat r}{\hat r})\cdot a\lambda^{-3} \cr\cr
}$$
A: Using vector calculus identity
$$\nabla\left(\vec{p}\cdot\frac{\vec{r}}{r^3}\right)=\left(\vec{p}\cdot\nabla\right)\frac{\vec{r}}{r^3}+\left(\frac{\vec{r}}{r^3}\cdot\nabla\right)\vec{p}+\vec{p}\times\left(\nabla\times\frac{\vec{r}}{r^3}\right)+\frac{\vec{r}}{r^3}\times\left(\nabla\times\vec{p}\right)$$
$$=\left(\vec{p}\cdot\nabla\right)\frac{\vec{r}}{r^3}+\vec{p}\times\left(\nabla\times\frac{\vec{r}}{r^3}\right)$$
$$=\left(\vec{p}\cdot\nabla\right)\frac{\vec{r}}{r^3}$$
Consider
$$p_x\frac{\partial}{\partial x}\left(\frac{x}{r^3}\hat{i}+\frac{y}{r^3}\hat{j}+\frac{z}{r^3}\hat{k}\right)$$
$$=p_x\left(\frac{1}{r^3}\hat{i}-3\frac{x^2}{r^5}\hat{i}-3\frac{xy}{r^5}\hat{j}-3\frac{xz}{r^5}\hat{k}\right)$$
Similarly,
$$p_y\frac{\partial}{\partial y}\left(\frac{x}{r^3}\hat{i}+\frac{y}{r^3}\hat{j}+\frac{z}{r^3}\hat{k}\right)$$
$$=p_y\left(\frac{1}{r^3}\hat{j}-3\frac{xy}{r^5}\hat{i}-3\frac{y^2}{r^5}\hat{j}-3\frac{yz}{r^5}\hat{k}\right)$$
$$p_z\frac{\partial}{\partial z}\left(\frac{x}{r^3}\hat{i}+\frac{y}{r^3}\hat{j}+\frac{z}{r^3}\hat{k}\right)$$
$$=p_z\left(\frac{1}{r^3}\hat{k}-3\frac{xz}{r^5}\hat{i}-3\frac{yz}{r^5}\hat{j}-3\frac{z^2}{r^5}\hat{k}\right)$$
So
$$(\vec{p}\cdot\nabla)\frac{\vec{r}}{r^3}=\frac{p_x\hat{i}+p_y\hat{j}+p_z\hat{k}}{r^3}-3p_xx\frac{\vec{r}}{r^5}-3p_yy\frac{\vec{r}}{r^5}-3p_zz\frac{\vec{r}}{r^5}$$
$$=\frac{\vec{p}}{r^3}-3\left(p_xx+p_yy+p_zz\right)\frac{\vec{r}}{r^5}$$
$$=\frac{\vec{p}}{r^3}-3\left(\vec{p}\cdot\vec{r}\right)\frac{\vec{r}}{r^5}$$
$$=\frac{\vec{p}-3\left(\vec{p}\cdot\hat{r}\right)\hat{r}}{r^3}$$
A: If we define the gradient operator as:
$$\frac{\partial}{\partial\vec{r}}$$
One has for your expression (Note that because we derive a quotient we must end with two terms
):
$$\vec{\mathrm{grad}}\psi(\vec{r})=\frac{\partial\psi(\vec{r})}{\partial\vec{r}}=\frac{\partial}{\partial\vec{r}}\left(\frac{\vec{p}\cdot\vec{r}}{|\vec{r}|^3}\right)=\frac{\vec{p}}{|\vec{r}|^3}-{\vec{p}\cdot{\vec{r}}}\frac{\partial}{\partial\vec{r}}\left(\frac{1}{|\vec{r}|^3}\right)$$
For the second term we have:
$$\frac{\partial}{\partial\vec{r}}\left(\frac{1}{|\vec{r}|^3}\right)=\frac{\partial}{\partial\vec{r}}\left(\sqrt{\vec{r}\cdot\vec{r}}\right)^{-3}=-3(\vec{r}\cdot\vec{r})^{-2}\frac{\vec{r}}{\sqrt{\vec{r}\cdot\vec{r}}}=-\frac{3\vec{r}}{|\vec{r}|^5}$$
Finally leading to 
$$\vec{\mathrm{grad}}\psi(\vec{r})= \frac{\vec{p}}{|\vec{r}|^3}-\frac{3(\vec{p}\cdot\vec{r})\vec{r}}{|\vec{r}|^5}$$
