\documentclass[a4paper,11pt]{article}
\parskip=1.5ex
\usepackage{verbatim,a4margins}

\newcommand{\dd}[2]{\frac{\mathrm d #1}{\mathrm d #2}}
\newcommand{\dds}[2]{\frac{\mathrm d^2 #1}{{\mathrm d #2}^2}}
\newcommand{\pdd}[2]{\frac{\partial #1}{\partial #2}}
\newcommand{\pdds}[2]{\frac{\partial^2 #1}{\partial{#2}^2}}
\newcommand{\pddd}[3]{\frac{\partial^2 #1}{\partial #2\partial #3}}

\newcommand{\rowfour}[4]{\left[\begin{array}{cccc}#1&#2&#3&#4\end{array}\right]}
\newcommand{\vectwo}[2]{\left[\begin{array}{c}#1\\#2\end{array}\right]}
\newcommand{\mxtwo}[4]{\left[\begin{array}{cc}#1&#2\\#3&#4\end{array}\right]}

\newcommand{\sq}[1]{\left(#1\right)^2}
\newcommand{\floor}[1]{\left\lfloor#1\right\rfloor}
\newcommand{\mod}[1]{\left|#1\right|}

\newcommand{\rem}[1]{}

\newcommand{\B}{\mathbf B}
\newcommand{\s}{\mathbf s}

\newcommand{\e}{\mathrm e}
\newcommand{\de}{\,\mathrm d}

\begin{document}

\title{Magnet Field of a Finite Wire}
\author{Stephen Brooks}
\maketitle

\section{Assumptions}
\newcommand{\va}{\mathbf a}
\newcommand{\vb}{\mathbf b}
\newcommand{\x}{\mathbf x}
\newcommand{\I}{\mathbf I}
\newcommand{\vr}{\mathbf r}
The wire segment in question travels in a straight line from position $\va$ to $\vb$ and carries current $I$ in the direction towards $\vb$.  The magnetic field of this segment alone will not be Maxwellian because the current does not satisfy the continuity equation.  However, the field sum of a loop of such wires will be.

\section{Derivation}

The Biot-Savart law is 
\[ \B(\x) = \frac{\mu_0}{4\pi} \int \frac{\I\times\vr}{\mod{\vr}^3} \de s, \] 
where $\vr$ is the vector to $\x$ from the relevant point on the conductor.  In this case the parametrisation
\[ \vr = \x - (\va + \lambda(\vb-\va)), \qquad \de s=\mod{\vb-\va}\de\lambda, \qquad \I=\frac{I(\vb-\va)}{\mod{\vb-\va}}, \]
for $\lambda\in[0,1]$, is used.  Now
\[ \I\times\vr = \frac{I(\vb-\va)\times(\x-\va)}{\mod{\vb-\va}} \qquad \Rightarrow \qquad \I\times\vr\de s = I(\vb-\va)\times(\x-\va)\de\lambda \]
\[ \Rightarrow \qquad \B(\x) = \frac{\mu_0I}{4\pi}(\vb-\va)\times(\x-\va) \int_0^1 \frac{\de\lambda}{\mod{\vr}^3}. \]
The length of $\vr$ can be calculated via
\[ \mod{\vr}^2 = \vr\cdot\vr = \mod{\x-\va}^2 - 2\lambda (\x-\va)\cdot(\vb-\va) + \lambda^2\mod{\vb-\va}^2 \]
and the scalar integral from
\[ \int_0^1 \frac{\de x}{(ax^2+bx+c)^{3/2}} = \left[ \frac{4ax+2b}{(4ac-b^2)\sqrt{ax^2+bx+c}} \right]_0^{x=1}
 = \frac{2}{4ac-b^2} \left( \frac{2a+b}{\sqrt{a+b+c}} - \frac{b}{\sqrt{c}} \right). \]

\section{Curved Coil Elements}
\newcommand{\f}{\mathbf f}
Suppose a coil piece is shaped as the image of a function $\f(u,v,w)$ applied to $(u,v,w)\in[0,1]^3$.  The total current in the coil is $I$ and is distributed so that $I\de u \de v$ flows in the piece that is the image of $[u,u+\de u]\times[v,v+\de v]\times[0,1]$, in the direction of `increasing $w$'.  The single Biot-Savart integral is
\[ \de^2\B_\mathrm{piece}(\x;u,v) = \frac{\mu_0}{4\pi} \int_{w=0}^1 \frac{\de^2\I_\mathrm{piece}\times\vr}{\mod{\vr}^3} \de s, \] 
where $\de^2\I_\mathrm{piece}\de s = I\de u \de v \pdd{\f}{w}\de w$, $\vr=\x-\f$ and $\f$ means $\f(u,v,w)$ unless otherwise stated.  Thus
\[ \de^2\B_\mathrm{piece}(\x;u,v) = \frac{\mu_0I\de u \de v}{4\pi} \int_0^1 \frac{\pdd{\f}{w}\times(\x-\f)}{\mod{\x-\f}^3} \de w \] 
and the total field (triple integral) is
\[ \B(\x) = \int_{u=0}^1\int_{v=0}^1 \de^2\B_\mathrm{piece}(\x;u,v) = \frac{\mu_0I}{4\pi} \int_0^1\int_0^1\int_0^1  \frac{\pdd{\f}{w}\times(\x-\f)}{\mod{\x-\f}^3} \de u \de v \de w. \]

\end{document}