I'm trying to find the electric field due to an electric dipole $\mathbf{d}$. There are plenty of approaches to doing this online, but I want to do it "my way," which doesn't seem to be working (and I have yet to find this approach in textbooks/online). I start with the potential:
$$ \phi(\mathbf{r}) = \frac{\mathbf{d}\cdot \mathbf{r}}{4\pi\epsilon_0 r^3} = \frac{d\cos\theta}{4\pi\epsilon_0 r^2} $$
And then take the negative gradient to find:
$$ \mathbf{E} = -\nabla \phi = \frac{2d\cos\theta}{4\pi \epsilon_0 r^3} \hat{r} + \frac{d\sin\theta}{4\pi\epsilon_0 r^3}\hat{\theta} $$
But I don't see how to manipulate this into the form that I expect:
$$ \mathbf{E} = \frac{1}{4\pi\epsilon_0}\left[ \frac{3(\mathbf{d}\cdot\hat{r})\hat{r}-\mathbf{d}}{r^3} \right] - \frac{1}{3\epsilon_0}\mathbf{d} \delta^3(\mathbf{r}) $$
Since I haven't done anything mathematically illegal, I don't see why my approach shouldn't get me to the correct answer - but I can't figure out what to do (and I've also been unable to find this derivation online).