In an arbitrary field
The easiest way to get the force over a dipole is to consider it as the limit of two oppositely charged monopoles that are closely spaced. If the dipole has moment and is at position , it can be considered as the limit of two monopoles, one with charge at position and the other with charge at position , when goes to zero.
If we consider the finite size dipole immersed in a (let’s say magnetic) field , the total force will be
We can get the force for the infinitesimal dipole by taking the limit when goes to zero
where is the (tensor) derivative of the magnetic field.
Between two antialigned dipoles
The general field of a magnetic dipole of moment at position is
If we assume we have one dipole at with its moment and the other at with its moment , we get a field at of
By symmetry, we are only interested in the x-component of the x-derivative of the field,
And the force on the dipole at will be
a repulsive force as expected of antialigned dipoles.