  A method is derived to obtain an expansion formula for the magnetic field
$\boldsymbol{B}(\boldsymbol{r})$ generated by a closed planar wire carrying a
steady electric current. The parametric equation of the loop is
$\mathcal{R}(\phi)=R+Hf(\phi)$, with $R$ the radius of the circle, $H \in
[0,R)$ the radial deformation amplitude, and $f(\phi)\in[-1,1]$ a periodic
function. The method is based on the replacement of the $1/|\boldsymbol{r} -
\boldsymbol{r}'|^3$ factor by an infinite series in terms of Gegenbauer
polynomials, as well as the use of the Taylor series. This approach makes it
feasible to write $\boldsymbol{B}(\boldsymbol{r})$ as the circular loop
magnetic field contribution plus a sum of powers of $H/R$. Analytic formulas
for the magnetic field are obtained from truncated finite expansions outside
the neighborhood of the wire. These showed to be computationally less expensive
than numerical integration in regions where the dipole approximation is not
enough to describe the field properly. Illustrative examples of the magnetic
field due to circular wires deformed harmonically are developed in the article,
obtaining exact expansion coefficients and accurate descriptions. Error
estimates are calculated to identify the regions in $\mathbb{R}^3$ where the
analytical expansions perform well. Finally, first-order deformation formulas
for the magnetic field are studied for generic even deformation functions
$f(\phi)$.
  Keywords: Magnetic Field, Gegenbauer Polynomials, Arbitrary current loop,
Biot-Savart law.
