This paper presents a general method for deriving a closed-form solution for precise calculation of the magnetic field around a permanent magnet (PM) or an electromagnet (EM). The method, referred here as distributed multipole (DMP) modeling, inherits many advantages of the dipole model originally conceptualized in the context of physics, but provides an effective means to account for the shape and magnetization of the physical magnet. Three examples are given to illustrate the procedure of developing a DMP model, which derives an appropriate set of distributed dipoles from a limited set of known field points, for a general cylindrical PM, a customized PM, and a multilayer coil. The DMP modeling method has been validated by comparing simulated fields and calculated forces against data obtained experimentally and numerically; the comparisons show excellent agreement. Finally, we illustrate how the closed-form DMP models can offer an inexpensive means to visualize the effect of the EM fields on the leakage and unexpected flux paths, which have significant influences on the magnetic torque of a spherical motor.