Second law of thermodynamics and a bunch of magnets

It's actually a nice example of why the 2nd law is useful: if you go around trying to account in microscopic detail the balance of things like energy and entropy, then you can easily go wrong. I used to have a student who would do this all the time; I don't know if he ever learnt the lesson...

In this specific case, you neglected damping --- without it, you would never come to an equilibrium and the 2nd law does not apply. With damping, you necessarily dissipate heat, and that loss will more than make up for the macroscopic ordering. This dissipation can be either mechanical friction, or (as an example of why you would be wrong about this situation being "closed") electro-magnetic --- oscillating dipoles emit radiation!


The magnets will indeed attract each other. This attraction will put them in motion, and they will head towards each other, converting electromagnetic energy into kinetic energy. Then they will collide, and loose their kinetic energies in the collision, finally coming to rest in a more ordered, low-energy state.

In terms of energy, the outcome of the experiment is that you have converted electromagnetic energy into heat: the heat released in the collisions. This conversion creates far more entropy than the entropy lost by arranging the magnets in a more ordered fashion.