the math is
 
Magnets