Magnetism (Dec 2022)
Numerically Stable and Computationally Efficient Expression for the Magnetic Field of a Current Loop
Abstract
In this work, it is demonstrated that straightforward implementations of the well-known textbook expressions of the off-axis magnetic field of a current loop are numerically unstable in a large region of interest. Specifically, close to the axis of symmetry and at large distances from the loop, complete loss of accuracy happens surprisingly fast. The origin of the instability is catastrophic numerical cancellation, which cannot be avoided with algebraic transformations. All exact expressions found in the literature exhibit similar instabilities. We propose a novel exact analytic expression, based on Bulirsch’s complete elliptic integral, which is numerically stable (15–16 significant figures in 64 bit floating point arithmetic) everywhere. Several field approximation methods (dipole, Taylor expansions, Binomial series) are studied in comparison with respect to accuracy, numerical stability and computation performance. In addition to its accuracy and global validity, the proposed method outperforms the classical solution, and even most approximation schemes in terms of computational efficiency.
Keywords