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

\newcommand{\dd}[2]{\frac{\mathrm d #1}{\mathrm d #2}}
\newcommand{\ddh}[2]{\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{\vecthree}[3]{\left[\begin{array}{c}#1\\#2\\#3\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{\B}{\mathbf B}
\newcommand{\F}{\mathbf F}
\newcommand{\x}{\mathbf x}
\newcommand{\p}{\mathbf p}
\newcommand{\vv}{\mathbf v}
\newcommand{\uv}{\mathbf u}

\begin{document}

\title{Exact Tracking in $z$ in a Magnetic Field}
\author{Stephen Brooks}
\maketitle

\section{The Lorentz Force Law}
Assuming there is no electric field, in a magnetic field~$\B(\x)$ a particle of momentum~$\p$, charge~$q$ and velocity~$\vv$ experiences a force
\[ \dd{\p}{t} = \F = q\vv\times\B. \]
Since this force (or change in momentum, or acceleration) is perpendicular to the direction of motion, it does not change the speed of the particle.  Therefore its velocity and momentum have constant magnitudes ($v$ and $p$) and can be written in terms of a single variable unit vector~$\uv$:
\[ \p=p\uv \qquad \vv=v\uv \qquad |\uv|=1. \]
Substituting into the force law gives
\[ p\dd{\uv}{t} = qv\uv\times\B. \]

\section{Making $z$ the Independent Variable}
The chain rule allows derivatives with respect to $z$ to be introduced:
\[ p\dd{\uv}{z}\dd{z}{t} = qv\uv\times\B, \]
where it should be noted that $\ddh{z}{t} = v_z = vu_z$ and thus
\[ p\dd{\uv}{z}vu_z = qv\uv\times\B \qquad \Rightarrow \qquad \dd{\uv}{z} = \frac{q}{p}\frac{1}{u_z}\uv\times\B. \]

\section{Geometrical Variables $x'$ and $y'$}

The variables $x'=u_x/u_z$ and $y'=u_y/u_z$ together with the condition that $|\uv|=1$ determine $\uv$ completely provided that $u_z>0$.  The cross product term in the previous section can be written
\[ \uv\times\B = \vecthree{u_yB_z-u_zB_y}{u_zB_x-u_xB_z}{u_xB_y-u_yB_x}
\qquad \Rightarrow \qquad
\frac{1}{u_z}\uv\times\B = \vecthree{y'B_z-B_y}{B_x-x'B_z}{x'B_y-y'B_x}. \]

The $z$-derivatives of these new variables will be required:
\[ \dd{x'}{z} = \dd{}{z}\frac{u_x}{u_z} = \frac{1}{u_z}\dd{u_x}{z} + u_x\frac{-1}{u_z^2}\dd{u_z}{z}  = 
\frac{1}{u_z}\left(\dd{u_x}{z} - x'\dd{u_z}{z}\right) \]
...with a similar formula for $y'$, while previous work already shows that 
\[ \dd{\uv}{z} = \frac{q}{p}\frac{1}{u_z}\uv\times\B = \frac{q}{p}\vecthree{y'B_z-B_y}{B_x-x'B_z}{x'B_y-y'B_x}. \]
This only leaves $1/u_z$ to be expressed in terms of $x'$ and $y'$, which can be done as follows:
\[ |\uv|=1  \quad \Rightarrow \quad u_x^2+u_y^2+u_z^2=1
\quad \Rightarrow \quad x'^2+y'^2+1=\frac{1}{u_z^2}
\quad \Rightarrow \quad \frac{1}{u_z} = \sqrt{1+x'^2+y'^2}. \]

\section{Conclusion}

Putting everything together gives the evolution of $x'$ and $y'$ as a function of $z$:
\[ \dd{}{z}\vectwo{x'}{y'} = \frac{1}{u_z}\vectwo{\dd{u_x}{z} - x'\dd{u_z}{z}}{\dd{u_y}{z} - y'\dd{u_z}{z}}
 = \sqrt{1+x'^2+y'^2}\ \frac{q}{p} \vectwo{y'B_z-B_y - x'^2B_y+x'y'B_x}{B_x-x'B_z - x'y'B_y+y'^2B_x}. \]
If the variables $(x,x',y,y')$ are being used as phase space, then $\ddh{x}{z} = \dd{x}{t}/\dd{z}{t} = v_x/v_z = u_x/u_z = x'$ and the final two evolution equations are trivially
\[ \dd{}{z}\vectwo{x}{y} = \vectwo{x'}{y'}. \]
It is important to note that no `paraxial' approximations have been used in the derivation of these formulae: they are exact.  The only time they will run into trouble is if a particle turns back on itself such that $v_z\le0$.

\end{document}