Spacial dipol density so I have a hard time grasping this exercise:
Problem:
Spacial dipole density  $\vec{P}(\vec{x})$: The volume element $d^3y$ has a dipole moment $\vec{P}(\vec{y})d^3y$. Find the equivalent charge density $\rho(\vec{y})$, i.e. the one that generates the same field.
Solution:
First of we know that
$$\rho=-\vec{p}(\vec{y})\cdot \nabla \delta \tag{1}$$
so the charge distribution for $\vec{P}(\vec{y})d^3y$ is, acording to (1):
$$-\vec{P}(\vec{y})\nabla_x\delta(\vec{x}-\vec{y})d^3y \tag{2}$$
so, using $\nabla_x f(\vec{x}-\vec{y})=-\nabla_y f(\vec{x}-\vec{y})$ we get:
$\begin{align}
    \rho(\vec{x}) &= \int\vec{P}(\vec{y})\cdot\nabla_y\delta(\vec{x}-\vec{y})d^3y\\
    &= -\int(\text{div}\vec{P}(\vec{y}))\delta(\vec{x}-\vec{y})d^3y\\
    &=-\text{div}\vec{P}(\vec{x})
\end{align} \tag{3}$
Questions:
so in (3) I don't get the second equal sign. Don't we need $\vec{P}(\vec{y})\cdot \nabla_y=-\text{div}\vec{P}(\vec{y})$for that to hold? How can I see that this is true?
Also, in the delta function, how exactly do we get the argument $\vec{x}-\vec{y}$? 
 A: In (3), the second step is obtained via integration by parts.  Using the identity $\vec{\nabla}( f \vec{v}) = \vec{v} \cdot \vec{\nabla} f + f (\vec{\nabla} \cdot \vec{v})$, we have
$$
\int_\mathcal{V} f (\vec{\nabla} \cdot \vec{v}) d^3 y = \int_\mathcal{V} \vec{\nabla}( f \vec{v}) d^3 y - \int_\mathcal{V} f (\vec{\nabla} \cdot \vec{v}) d^3 y = \int_\mathcal{\partial V}  (f \vec{v}) \cdot \hat{n} \, d^2 y - \int_\mathcal{V} f (\vec{\nabla} \cdot \vec{v}) d^3 y
$$
where we have used the divergence theorem in the second step.  Frequently, one can then argue that the surface integral vanishes.  It does in this case;  see if you can figure out why.  (If you can't figure it out yourself, see here.)
Concerning the argument of the delta function:  for a single ideal dipole at the origin, we have $\rho(\vec{x}) = - \vec{p} \cdot \vec{\nabla} \delta(\vec{x})$.  The charge density due to that same dipole at the location $\vec{y}$ is then obtained by changing $\vec{x} \to \vec{x} - \vec{y}$ on the right-hand side.
