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

\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{\A}{\mathbf A}
\newcommand{\s}{\mathbf s}

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

\begin{document}

\title{Magnetic Potential 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}
\newcommand{\vu}{\mathbf u}
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 for Vector Potential}

The Biot-Savart law for the magnetic potential is 
\[ \A(\x) = \frac{\mu_0}{4\pi} \int \frac{\I}{\mod{\vr}} \de s, \] 
where $\vr$ is the vector to $\x$ from the relevant point on the conductor.  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]$, can be used.  Now
\[ \I\de s = I(\vb-\va)\de\lambda \]
\[ \Rightarrow \qquad \A(\x) = \frac{\mu_0I}{4\pi}(\vb-\va) \int_0^1 \frac{\de\lambda}{\mod{\vr}}. \]
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}{\sqrt{ax^2+bx+c}} = \left[ \frac{\ln\left(2\sqrt{a}\sqrt{ax^2+bx+c}+2ax+b\right)}{\sqrt{a}} \right]_0^{x=1} \]
\[ = \frac{1}{\sqrt{a}} \left( \ln\left(2\sqrt{a(a+b+c)}+2a+b\right) - \ln\left(2\sqrt{ac}+b\right) \right). \]
Some further simplifications may be possible since
\[ \sqrt{a} = \mod{\vb-\va} \]
\[ \sqrt{c} = \mod{\x-\va} \]
\[ \sqrt{a+b+c} = \sqrt{ \mod{\vb-\va}^2 - 2(\x-\va)\cdot(\vb-\va) + \mod{\x-\va}^2 } = \mod{\x-\vb} \]
\[ 2a+b = 2\mod{\vb-\va}^2 - 2(\x-\va)\cdot(\vb-\va) = -2(\x-\vb)\cdot(\vb-\va) \]
so that
\begin{eqnarray*}
\qquad \A(\x) &=& \frac{\mu_0I}{4\pi}(\vb-\va)
\frac{1}{\mod{\vb-\va}} \bigg(\ln\left(2\mod{\vb-\va}\mod{\x-\vb}-2(\x-\vb)\cdot(\vb-\va)\right)  \\
&&  - \ln\left(2\mod{\vb-\va}\mod{\x-\va}-2(\x-\va)\cdot(\vb-\va)\right)\bigg) \\
&=& \frac{\mu_0\I}{4\pi}
\ln\left(\frac{\mod{\x-\vb}\mod{\vb-\va}-(\x-\vb)\cdot(\vb-\va)}{\mod{\x-\va}\mod{\vb-\va}-(\x-\va)\cdot(\vb-\va)}\right) \\
&=& \frac{\mu_0\I}{4\pi}
\ln\left(\frac{\mod{\x-\vb}-(\x-\vb)\cdot\vu}{\mod{\x-\va}-(\x-\va)\cdot\vu}\right), \\
\end{eqnarray*}
if the unit vector along the wire direction is written $\vu=\frac{\vb-\va}{\mod{\vb-\va}}$.

\subsection{Special case: wire pointing at evaluation point}
If $\x$ is colinear with $\va\vb$, the expressions in the logarithms above become zero, so the previous formula cannot be used.  To see where things went wrong, reexamine the formula for $\mod{\vr}$ in the case where $\x$ is beyond the $\vb$ end of the line:
\begin{eqnarray*}
\mod{\vr}^2 &=& \mod{\x-\va}^2 - 2\lambda (\x-\va)\cdot(\vb-\va) + \lambda^2\mod{\vb-\va}^2 \\
&=& \mod{\x-\va}^2 - 2\lambda \mod{\x-\va}\mod{\vb-\va} + \lambda^2\mod{\vb-\va}^2 \\
&=& \left( \mod{\x-\va} - \lambda\mod{\vb-\va} \right)^2.
\end{eqnarray*}
Now $\mod{\vr}$ in the scalar integral does not contain a square root:
\[ \int_0^1 \frac{\de x}{ax+b} = \left[ \frac{\ln(ax+b)}{a} \right]_0^{x=1} = \frac{\ln(a+b)-\ln(b)}{a}. \]
The potential becomes
\begin{eqnarray*}
\qquad \A(\x) &=& \frac{\mu_0I}{4\pi}(\vb-\va)\left(\frac{\ln(-\mod{\vb-\va}+\mod{\x-\va})-\ln(\mod{\x-\va})}{-\mod{\vb-\va}}\right) \\
 &=& \frac{\mu_0\I}{4\pi}\left(\ln(\mod{\x-\va})-\ln(-\mod{\vb-\va}+\mod{\x-\va})\right) \\
 &=& \frac{\mu_0\I}{4\pi}\ln\left(\frac{\mod{\x-\va}}{\mod{\x-\va}-\mod{\vb-\va}}\right)
 = \frac{\mu_0\I}{4\pi}\ln\frac{\mod{\x-\va}}{\mod{\x-\vb}}.
\end{eqnarray*}
If $\x$ is beyond the $\va$ end of the line, the coefficient $a$ changes sign
\begin{eqnarray*}
\qquad \A(\x) &=& \frac{\mu_0I}{4\pi}(\vb-\va)\left(\frac{\ln(\mod{\vb-\va}+\mod{\x-\va})-\ln(\mod{\x-\va})}{\mod{\vb-\va}}\right) \\
 &=& \frac{\mu_0\I}{4\pi}\left(\ln(\mod{\vb-\va}+\mod{\x-\va})-\ln(\mod{\x-\va})\right) \\
 &=& \frac{\mu_0\I}{4\pi}\ln\left(\frac{\mod{\vb-\va}+\mod{\x-\va}}{\mod{\x-\va}}\right)
 = \frac{\mu_0\I}{4\pi}\ln\frac{\mod{\x-\vb}}{\mod{\x-\va}}.
\end{eqnarray*}
By considering which distance is larger in these two cases, it can be seen that the log is always positive, so the formulae may be combined into
\[ \qquad \A(\x) = \frac{\mu_0\I}{4\pi}\mod{\ln\frac{\mod{\x-\vb}}{\mod{\x-\va}}}. \]


\section{Derivation for Scalar Potential}

\subsection{General Formula}
\newcommand{\B}{\mathbf B}
\newcommand{\ve}{\mathbf e}
\newcommand{\arb}{\hat{\boldsymbol{\alpha}}}
\newcommand{\ur}{\hat\mathbf r}
I can't find a version of the Biot-Savart law that gives the \textit{scalar} potential, so here is some educated guesswork.  First consider the magnetic field of an infinite wire in the $z$ direction in cylindrical polar coordinates $\B=\frac{\mu_0I_z}{2\pi}\frac1r\ve_\phi$.  If the potential satisfies $\nabla\Phi=\B$ then choosing $\Phi=\frac{\mu_0I_z}{2\pi}\phi$ works because the $\phi$ coordinate satisfies $\nabla\phi=\frac1r\ve_\phi$.  This introduces a `cut sheet' or discontinuity at some $\phi$ value where it wraps by $2\pi$; the cut sheet is a half-plane ending at the wire in this case.

The website \texttt{http://web.mit.edu/6.013\_book/www/chapter8/8.3.html} suggests that the magnetic scalar potential of an arbitrary current loop is given by $\Phi=\frac{\mu_0I}{4\pi}\Omega$ where $\Omega$ is the solid angle subtended by the loop at the evaluation point.  This seems dimensionally correct with the previous result, since $\frac{\phi}{2\pi}$ has been replaced by $\frac{\Omega}{4\pi}$, both of which are angular measures as a fraction of all directions.  The correspondence can be made more precise by considering the view from a point near the infinite straight wire but turned into a loop at great distance around half the horizontal `horizon'.  The wire appears to go along half the horizon and then join in a great circle at some other orientation (possibly diagonally above or below) depending on $\phi$.  The solid angle of the sector seen within the complete loop is $\Omega=2\phi$ if $\phi=0$ is chosen to be when the near and far wire appear coincident.

Converting the whole-loop formula into an integral that could be used with line elements gives
\[ \Phi=\frac{\mu_0}{4\pi}\int I \de\Omega \]
where $\de\Omega$ is somehow the solid angle that can be ascribed to each infinitesimal bit of wire.  One way of counting the area of a curve in a plane is to pick an arbitrary point and integrate signed areas swept out by the line elements subtended to that point.  Here this has to be done on the surface of a unit sphere, so pick an arbitrary unit vector $\arb$ and define $0\le\theta\le\pi$ to be the observed angle from $\arb$ to the wire piece, with $\phi$ being the other spherical angular coordinate `around' $\arb$.  Some infinitesimal geometry and integrating area from $0$ to $\theta$ gives 
\[ \de\Omega = (1-\cos\theta)\de\phi = (1-\arb\cdot\ur)\de\phi, \]
where $\ur=\vr/\mod{\vr}$.  To find $\de\phi$ we use
\[ \de\phi = \nabla\phi \cdot \de\vr 
 = \frac{1}{r_{cyl}}\ve_\phi \cdot \de\vr, \]
where $r_{cyl}$ is the old `$r$' coordinate from the cylindrical polar coordinate system above.  In terms of our new vectors, $r_{cyl}=\mod{\vr\times\arb}$, which measures radius in the plane perpendicular to $\arb$.  A suitable $\ve_\phi$ can be found by normalising $\vr\times\arb$, which perpendicular to both the axis $\arb$ and the radial direction:
\[ \ve_\phi = \frac{\vr\times\arb}{\mod{\vr\times\arb}}
\qquad \Rightarrow \qquad 
\de\phi = \frac{1}{r_{cyl}}\frac{\vr\times\arb}{\mod{\vr\times\arb}} \cdot \de\vr
 = \frac{\vr\times\arb}{\mod{\vr\times\arb}^2} \cdot \de\vr. \]
Putting this all together gives
\[ \Phi=\frac{\mu_0}{4\pi}\int I (1-\arb\cdot\ur)\frac{\vr\times\arb}{\mod{\vr\times\arb}^2} \cdot \de\vr \]
and the relation with the vector current $I\de\vr=\I\de s$ can be used to make it a normal line integral
\[ \Phi=\frac{\mu_0}{4\pi}\int (1-\arb\cdot\ur)\frac{(\vr\times\arb)\cdot\I}{\mod{\vr\times\arb}^2} \de s. \]
The identity $\mod{\va\times\vb}^2=\mod{\va}^2\mod{\vb}^2-(\va\cdot\vb)^2$ allows a factor in the above to be simplified slightly:
\[ \frac{1-\arb\cdot\ur}{\mod{\vr\times\arb}^2} 
 = \frac{1-\arb\cdot\ur}{\mod{\vr}^2-(\vr\cdot\arb)^2}
 = \frac{1-\arb\cdot\ur}{(\mod{\vr}+\vr\cdot\arb)(\mod{\vr}-\vr\cdot\arb)}
 = \frac{1-\ur\cdot\arb}{(\mod{\vr}+\vr\cdot\arb)(1-\ur\cdot\arb)\mod{\vr}}
 = \frac{1}{(\mod{\vr}+\vr\cdot\arb)\mod{\vr}} \]
so that
\[ \Phi=\frac{\mu_0}{4\pi}\int\frac{(\vr\times\arb)\cdot\I}{\mod{\vr}(\mod{\vr}+\vr\cdot\arb)} \de s. \]
Note the numerator is a scalar triple product so the order of the three vectors can be rotated.

\subsection{Finite Wire Segment}
As before, take the parameterisation
\[ \vr = \x - (\va + \lambda(\vb-\va)), \qquad \de s=\mod{\vb-\va}\de\lambda, \qquad \I=\frac{I(\vb-\va)}{\mod{\vb-\va}}, \]
and substitute into the integral.  The last two are simpler and give
\[ \Phi(\x)=\frac{\mu_0I}{4\pi}\int_0^1\frac{(\vr\times\arb)\cdot(\vb-\va)}{\mod{\vr}(\mod{\vr}+\vr\cdot\arb)} \de\lambda. \]
The new terms are
\begin{eqnarray*}
 \vr\cdot\arb &=& (\x-\va)\cdot\arb+\lambda((\va-\vb)\cdot\arb), \\
 \vr\times\arb &=& (\x-\va)\times\arb+\lambda((\va-\vb)\times\arb) \\
\Rightarrow \qquad (\vr\times\arb)\cdot(\vb-\va) &=& ((\x-\va)\times\arb)\cdot(\vb-\va).
\end{eqnarray*}
The last cancellation (via the vector triple product) means that the numerator in the integral is constant.  The first formula means that $\vr\cdot\arb$ is of the form $d\lambda+e$, while $\mod{\vr}=\sqrt{a\lambda^2+b\lambda+c}$ as before.  Thus
\[ \Phi(\x)=\frac{\mu_0I}{4\pi}((\x-\va)\times\arb)\cdot(\vb-\va)\int_0^1\frac{1}{\sqrt{ax^2+bx+c}\left(\sqrt{ax^2+bx+c}+dx+e\right)} \de x. \]

\end{document}