Magnetic force obeys an inverse square law with distance. The equation for magnetic force is similar to Coulomb's law (if you are familiar with it). But the key point is that the force is inversely proportional to the distance squared (i.e. it obeys an inverse square law with distance). (F∝1r2) Where r is the distance between the magnets.