Off-axis magnetic field strength for permanent magnet calculation/equation I'm working on a project which uses cylindrical permanent magnets, and I'm trying to determine the expected magnetic field due to these magnets. One problem I run into is that these magnets are usually not completely horizontal above the point at which I want to calculate the expected magnetic field. Assuming the point is on the axis of the cylinder, it's easy enough to calculate the expected magnetic field using the following equation:
$$B = \frac{B_r}{2}\left[\frac{D + z}{\sqrt{R^2+(D+z)^2}} - \frac{z}{\sqrt{R^2+z^2}}\right]$$
where $B_r$ is the remanence field (found in a magnet's data sheet), $z$ is the distance from a face of the cylinder on the axis, $D$ is the thickness of the magnet, and $R$ is the radius of the cylinder. However, this equation only works on the axis of the cylinder itself. How can I calculate the off-axis magnetic field for a cylindrical permanent magnet?
Note: I don't particularly need the derivation for the off-axis equation for now, although it would definitely be helpful.
 A: It looks like there are no way avoiding solving the elliptical integral equations.
More details you can find in this article (check chapter 3 and mentioned references): https://webspace.science.uu.nl/~kuipe103/Publications/JournalOfMagnetism2018.pdf [https://doi.org/10.1016/j.jmmm.2018.02.003]
Two articles below are about the solenoids, but since the cylindrical (bar) magnet are equivalent to the solenoid in terms of the field lines, they still can be useful:

*

*https://arxiv.org/abs/0909.3880 [arXiv:0909.3880v1 [physics.class-ph]]. This article contains theory and a code example for solving that integrals (not tested). Also it worth checking the reference #7 (or #6).


*Another quite elegant approach (result is derived from the magnetic scalar potential) you can find here: https://phys.libretexts.org/Bookshelves/Electricity_and_Magnetism/Book%3A_Applications_of_Maxwells_Equations_(Cochran_and_Heinrich)/05%3A_The_Magnetostatic_Field_II/5.02%3A_Calculation_of_off-axis_Fields
Hope this may help a bit.
UPDATE 2021.09.04: there is a free Python package Magpylib which may help you to solve magnetic field calculation problems just in a couple of lines of code (https://doi.org/10.1016/j.softx.2020.100466)
A: "Another quite elegant approach (result is derived from the magnetic scalar potential)"
Yes, the scalar potential, $\phi_m$, easily found from $B_z=-\partial_z \phi_m$,
can be extended off axis by a Legendre polynomial expansion.
This is done on pp. 228-229 of my EM textbook for a current loop, but the same procedure will work for your case.
