I am working in a project where I am using different shaped permanent magnets for levitation of diamagnets. I am facing problem while calculating the magnetic field around these permanent magnets. To be specific I am using cylindric magnet and cubic ($\rm NdFeB$) magnets. And I want to find the magnetic field around these shapes of magnet. Only the remanence and the size of the magnet of the are provided. I have come across a formula for cylindrical magnet where it calculates the magnetic field along the symmetry axis of the magnet. But I want to get the magnetic field at any point in space around the cylindrical magnet. Here is the formula:
$$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, D is the height of cylinder, R is the radius of cylinder, z is the distance from a pole face on the symmetry axis.
I tried first finding out the scalar potential Φaxis(z) and expanding it to Φ(r, θ) using Legendre polynomial but it doesn’t work. I have already come across $$B_Z,B_X,B_Y (x,y,z)$$ for the cube from one of the paper means now I can easily find $$B(x,y,z)=\sqrt{B_x^2+B_y^2+B_z^2}$$ Can anyone help me to find B(x,y,z) for the cylinder ?