Torques and forces between two magnets? How do we typically calculate the torques and forces that two magnets with arbitrary positions and orientations exert on each other? Is it possible to, given two magnetic fields $B_1(\vec{x})$ and $B_2(\vec{x})$, created by the first and the second magnet, respectively, calculate a potential energy that we can use in a Lagrangian to in turn calculate how each magnet will be accelerated and rotated by the other magnet, or is there a much more straight-forward approach to calculating the torques and forces experienced by each magnet?
 A: Torque can be computed knowing that for a single magnet of manetic moment $\vec{m}$ under a external field $\vec{B}$ is
$$
\vec{\tau}=\vec{m}\times \vec{B}
$$
For more magnets, just use the superposition principle to add all the fields.
The force is more interesting, suppose you have two magnets, each with a certain magnetic moment associated $\vec{m_1}$ and $\vec{m_2}$ aligned in $z$ axis (see figure below!). Virtual of work is defined
$$
\delta W= Q \delta q 
$$
We are interested in the work done on a magnet, so in our case
$$ \delta W = F_z \delta z $$
Since work done is caused by the magnetic potential energy, then $\delta W = - \delta U_m $. This way, recalling that $U_m= -\vec{B}·\vec{m}$ we find
$$
F_z=-\frac{\delta U_m }{\delta z} = \vec{m_1}·\frac{\delta \vec{B_2} }{\delta z}
$$
Which can be generalized for all spatial directions and a set of magnets as
$$
\vec{F_i}=\vec{\nabla} (\sum_{j\neq i} \vec{m_i}·\vec{B_j})
$$
Now if the magnets are not fixed and can move, you would have to take into account infinitesimal rotations and displacements, creating some mess of differential equations. Still, as you say, you could use a Lagrangian using the magnetic potential energy and give all the degrees of freedom that you want and see what happens!

A: The problem is:  The field from magnet 1 varies in magnitude and direction from one atomic dipole in magnet 2 to another. Each dipole is subject to a force which depends on the gradient of the field, and a torque which may modify its orientation in magnet 2.  As a first approximation, (to be used in a numeric integration), you might replace each magnet with a current carrying solenoid of the same shape, size, and dipole moment/unit volume.
As an alternative you can treat the magnets like electric dipoles, but that works best when the pole separations are large relative to the pole diameter.
