Question: what is the mathematical relationship between magnetic force and distance between the two magnets?
Answer: 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).