Magnetic field of square loop

Magnetic Line

Find the exact magnetic files in a distance $z$ above the center of a square loop of side $a$ carrying a current $I$. Show that if $z>>a$, it reduces to the field of a dipole.

First we deduce the magnetic field at a point $P$ in space above a finite wire carrying a current $I$. The figure is below.  The field of an element

$d L$ from the wire having distance $r$ to point $P$ is (Biot Savart)

$dB(r)= \frac{\mu}{4\pi}*\frac{I(dL\times r)}{r^3} =\frac{\mu I*d L*\sin\theta}{4\pi*r^2}=\frac{\mu I*d L*\sin\gamma}{4\pi*r^2}=\frac{\mu I}{4\pi}*d x*\frac{R}{r^3}$

$B= \frac{\mu Ir}{4\pi} \int_{-a/2}^{a/2} \frac{d x}{(x^2+R^2)^{3/2}} =\frac{\mu I r}{4\pi}\frac{x}{R^2(x^2+R^2)^{1/2}}|_{-a/2}^{a/2}$

$B=\frac{\mu I}{4\pi R}(\cos \gamma_1-\cos\gamma_2)$

Since $R=\sqrt{z^2+\frac{a^2}{4}}$  and


so that

$B=\frac{\mu I}{4\pi R} \frac{a}{\sqrt{z^2+a^2/2}}$


Magnetic Loop

The rectangle has 4 sides and the total field along z axis is

$B_{tot}=4B*\sin\beta=4\frac{\mu I}{4\pi R}*\frac{a}{\sqrt{z^2+a^2/2}}*\frac{a}{2R}=\frac{\mu I}{2\pi R^2}\frac{a^2}{\sqrt{z^2+a^2/2}}$

If $z>>a$ one has $R=z$ and

$B_{tot}=\frac{\mu I}{2\pi z^2}\frac{a^2}{z}=\frac{\mu (Ia^2)}{2\pi z^3}= \frac{\mu m}{2\pi z^3}$

The magnetic filed of a dipole  $m=I*a^2=I*S$   is

$B(z) =\frac{\mu}{4\pi}*\frac{2m}{z^3}$