# Physics of donut magnets levitating vertically on a pencil?

When you put identical donut magnets on a pencil horizontally, the magnets all repel from each other in a way that creates equal spacing between each magnet. However, spacing is not equal when the pencil is held vertically and spacing increases from the bottom up so it looks like this:

I think that the weight of each magnet has something to do with this, but I cannot figure out exactly why. Help?

-
Here's a related question: consider a chain (or any other rope whose linear mass density is non-negligible) suspended from the ceiling with lower end free. What is the tension on this chain as a function of the distance from the ceiling? –  josh Jun 7 '13 at 3:50

This trend continues, with the $n$-th magnet bearing about $n$ times the weight of one of them. The spacings decrease as a result. Note that the force of repulsion depends strongly on distance, so the space below the $n$-th magnet does not have to be $1/n$ the spacing below the first magnet for equilibrium to be achieved.