\chapter{Spatial Boris Integrator}
\label{chapter:spatial-boris}

This chapter describes the spatial Boris-like integration method implemented
in the Xsuite \texttt{SplineBoris} element. The method builds on the original
Boris particle pusher~\cite{Boris1970}, its analyses in
Refs.~\cite{Qin2013,HairerLubich2018}, and spatial-stepping formulations in
Refs.~\cite{Stoltz2002,Penn2003}. It integrates the relativistic Lorentz--force
equations in a general, possibly nonuniform magnetic field, using the
longitudinal coordinate \(z\) as the independent variable. Tracking is
performed in a straight reference frame; curved reference frames are not
supported. The algorithm has a symmetric
drift--kick--rotation--kick--drift structure.

The magnetic-field representation supplied to the integrator is described in
Chap.~\ref{chapter:splineboris-field-expansion}.

The method preserves the total momentum magnitude exactly. Its reduced map in
the variables \((x,y,P_x,P_y)\), as well as its extension to the accelerator
variables \((x,y,P_x,P_y,t,E)\), preserves phase--space volume exactly. For
smooth magnetic fields away from \(P_z=0\), the fixed-length transfer map is
reversible and second-order accurate in \(C^1\). Under field-free entrance and
exit conditions, its symplectic defect is of order
\(\mathcal O(\Delta z^2)\).

% ---------------------------------------------------------------------
\section{Lorentz-force equations in spatial form}
\label{boris:sec:lorentz}

For a charged particle in a static magnetic field \( \bm{B}(\bm{r}) \),
\[
\totder{\bm{P}}{t} = q\,(\bm{v}\times\bm{B}),
\qquad
\totder{\bm{r}}{t} = \bm{v} = \frac{\bm{P}}{\gamma m},
\]
with relativistic factor
\[
\gamma = \sqrt{1+\Big(\frac{P}{m c}\Big)^2}.
\]
In the absence of electric fields, the total momentum magnitude
\[
P = |\bm{P}| = \sqrt{P_x^2 + P_y^2 + P_z^2}
\]
is constant in time.

Switching from time to the spatial coordinate \(z\) as the independent variable:
\[
\totder{}{t} = v_z\,\totder{}{z}
\quad\Longrightarrow\quad
\totder{\bm{P}}{z} = \frac{q}{P_z}(\bm{P}\times\bm{B}),
\qquad
\totder{\bm{r}}{z} = \frac{\bm{P}}{P_z}.
\]
This reformulation is meaningful only on intervals where \(P_z\) stays
nonzero and does not change sign, so that \(z\) can be used as a valid
independent variable.
In what follows we restrict to the forward branch
\[
P_z>0,
\]
so every occurrence of \(P_z\) is understood as the positive root
\[
P_z = +\sqrt{P^2-P_x^2-P_y^2}.
\]
For backward propagation one would instead keep the negative branch
consistently throughout.

% ---------------------------------------------------------------------
\section{Integration algorithm}
\label{boris:sec:algorithm}

Since \(v_z = P_z/(\gamma m)\), the infinitesimal relation between \(t\) and
\(z\) is
\begin{equation}
\totder{t}{z} = \frac{1}{v_z} = \frac{\gamma m}{P_z}
= \frac{E}{c^2 P_z},
\label{boris:eq:dt_dz}
\end{equation}
where \(E=\gamma m c^2\) is constant in the magnetic-only case.
For a finite step \(\Delta z\), the elapsed time is approximated by a midpoint
rule:
\begin{equation}
\Delta t \simeq \frac{\gamma m\,\Delta z}{P_{z,\mathrm{mid}}}
= \frac{E\,\Delta z}{c^2 P_{z,\mathrm{mid}}},
\label{boris:eq:dt}
\end{equation}
where \(P_{z,\mathrm{mid}}\) is the longitudinal momentum evaluated at the
midpoint of the step (after the first half-kick).

Writing \(\bm{B}=(B_x,B_y,B_z)\), the equations of motion are
\begin{align}
\totder{x}{z} & = \frac{P_x}{P_z},\\
\totder{y}{z} & = \frac{P_y}{P_z},\\
\totder{t}{z} & = \frac{\gamma m}{P_z} = \frac{E}{c^2 P_z},\\
\totder{P_x}{z} &= \frac{q}{P_z}(P_y B_z - P_z B_y)
           = \frac{q}{P_z}(P_y B_z) - q B_y,\\
\totder{P_y}{z} &= \frac{q}{P_z}(P_z B_x - P_x B_z)
           = q B_x - \frac{q}{P_z}(P_x B_z),\\
\totder{P_z}{z} &= \frac{q}{P_z}(P_x B_y - P_y B_x).
\end{align}
The constant-magnitude constraint
\[
P_z = +\sqrt{P^2 - P_x^2 - P_y^2}
\]
is enforced algebraically at each sub-step on the forward branch.

The motion is advanced over a spatial step \(\Delta z\) by a symmetric
Boris-type composition.
More precisely, one first performs a half drift to the midpoint
\((x_h,y_h,z_h)\), evaluates the magnetic field there, and then keeps the
resulting midpoint field \(\bm B(x_h,y_h,z_h)\) fixed during the central
kick--rotate--kick sequence.
Thus, for general nonuniform \(\bm B(x,y,z)\), the implemented step is not
literally the exact Strang splitting of the full variable-coefficient operator
\(D+K+R\); rather, it is a symmetric midpoint-frozen approximation of that
splitting.
Here \(D\) denotes the drift in \((x,y)\), \(K\) the transverse kicks from
\(B_x,B_y\), and \(R\) the rotation generated by \(B_z\).

\subsection{Step 1: Half drift in \((x,y)\)}
\[
x_h = x + \frac{\Delta z}{2}\frac{P_x}{P_z}, \qquad
y_h = y + \frac{\Delta z}{2}\frac{P_y}{P_z}, \qquad
z_h = z + \frac{\Delta z}{2}.
\]
The magnetic field is evaluated at \((x_h,y_h,z_h)\).

\subsection{Step 2: First half-kick from \(B_x,B_y\)}
\[
P_x^- = P_x - \frac{q\,\Delta z}{2}B_y, \qquad
P_y^- = P_y + \frac{q\,\Delta z}{2}B_x.
\]
At this midpoint, compute
\[
P_{z,\mathrm{mid}} = \sqrt{P^2 - (P_x^-)^2 - (P_y^-)^2}.
\]
Using Eq.~\eqref{boris:eq:dt}, the elapsed time increment is
\[
\Delta t = \frac{\gamma m\,\Delta z}{P_{z,\mathrm{mid}}}.
\]
The total time is updated as \(t' = t + \Delta t\).

\subsection{Step 3: Rotation from \(B_z\)}

During this sub-step, \(B_x=B_y=0\) and only \(B_z\) acts.
The transverse equations become
\begin{equation}
\totder{P_x}{z} = \frac{qB_z}{P_z} P_y, \qquad
\totder{P_y}{z} = -\frac{qB_z}{P_z} P_x.
\label{boris:eq:rot_eqs}
\end{equation}

The exact solution over one step \(\Delta z\) is a planar rotation with angle
\begin{equation}
\theta = \frac{q B_z \Delta z}{P_z}.
\label{boris:eq:rotation_exact}
\end{equation}
The Boris update replaces this with the Cayley-transform rotation
\[
T = \frac{qB_z \Delta z}{2P_{z,\mathrm{mid}}}, \qquad
S = \frac{2T}{1+T^2}, \qquad
C = \frac{1-T^2}{1+T^2},
\]
so that
\begin{align}
P_x^+ &= C\,P_x^- + S\,P_y^-,\\
P_y^+ &= -\,S\,P_x^- + C\,P_y^-.
\end{align}
Equivalently,
\[
\bm{P}^{*} = \bm{P}^- + \bm{P}^- \times \bm{t}, \qquad
\bm{P}^+ = \bm{P}^- + \bm{P}^{*} \times \bm{s},
\]
with \(\bm{t} = (0,0,T)\) and \(\bm{s} = (0,0,S)\).
This is a planar rotation by the angle \(2\arctan T\), so it preserves
\(|\bm{P}_\perp|\) exactly while approximating the exact angle \(\theta\) to
second order in \(\Delta z\).

\subsection{Step 4: Second half-kick}
Repeat the same transverse increments:
\[
P_x' = P_x^+ - \frac{q\,\Delta z}{2}B_y, \qquad
P_y' = P_y^+ + \frac{q\,\Delta z}{2}B_x.
\]

\subsection{Step 5: Recompute \(P_z\) and second half-drift}
\[
P_z' = \sqrt{P^2 - (P_x')^2 - (P_y')^2}.
\]
Advance the positions by another half drift:
\[
x' = x_h + \frac{\Delta z}{2}\frac{P_x'}{P_z'}, \qquad
y' = y_h + \frac{\Delta z}{2}\frac{P_y'}{P_z'}, \qquad
z' = z + \Delta z.
\]

\subsection{Complete algorithm summary}
\begin{align*}
&\text{Given }(x,y,z,P_x,P_y,P,t):\\[3pt]
\text{(i)}\;& P_z = \sqrt{P^2 - P_x^2 - P_y^2},\\
\text{(ii)}\;& x_h = x + \frac{\Delta z}{2}\frac{P_x}{P_z},\;
               y_h = y + \frac{\Delta z}{2}\frac{P_y}{P_z},\;
               z_h = z + \frac{\Delta z}{2},\\
\text{(iii)}\;& P_x^- = P_x - \frac{q\Delta z}{2}B_y,\;
                P_y^- = P_y + \frac{q\Delta z}{2}B_x,\\
\text{(iv)}\;& P_{z,\mathrm{mid}} = \sqrt{P^2 - (P_x^-)^2 - (P_y^-)^2},\;
                \gamma = \sqrt{1+\!\Big(\frac{P}{mc}\Big)^2},\;
                \Delta t = \frac{\gamma m\Delta z}{P_{z,\mathrm{mid}}},\\
\text{(v)}\;& t' = t + \Delta t,\\
\text{(vi)}\;& T = \frac{qB_z\Delta z}{2P_{z,\mathrm{mid}}},\;
                S = \frac{2T}{1+T^2},\;
                C = \frac{1-T^2}{1+T^2},\\
& P_x^+ = C\,P_x^- + S\,P_y^-,\;
  P_y^+ = -S\,P_x^- + C\,P_y^-,\\
\text{(vii)}\;& P_x' = P_x^+ - \frac{q\Delta z}{2}B_y,\;
                P_y' = P_y^+ + \frac{q\Delta z}{2}B_x,\\
\text{(viii)}\;& P_z' = \sqrt{P^2 - (P_x')^2 - (P_y')^2},\\
\text{(ix)}\;& x' = x_h + \frac{\Delta z}{2}\frac{P_x'}{P_z'},\;
                y' = y_h + \frac{\Delta z}{2}\frac{P_y'}{P_z'},\;
                z' = z + \Delta z.
\end{align*}

% ---------------------------------------------------------------------
\section{Phase-space volume preservation}
\label{boris:sec:volumepreservation}

The spatial Boris step preserves volume exactly in both the reduced mechanical
variables and in the extended accelerator variables:
\[
\boxed{
\begin{gathered}
\det(D\Phi)=1
\quad\text{for } (x,y,P_x,P_y),\\
\det(D\Psi)=1
\quad\text{for } (x,y,P_x,P_y,t,E).
\end{gathered}
}
\]
The proof is given in the following subsections by decomposing the method into
its elementary substeps.

The continuous Lorentz flow in time preserves the six-dimensional Liouville
volume element
\[
dx\,dy\,dz\,dP_x\,dP_y\,dP_z.
\]
The spatial Boris algorithm studied here is a different object: after fixing
the momentum magnitude \(P\) and using \(z\) as the independent variable, the
discrete dynamics is a reduced map in the variables \((x,y,P_x,P_y)\), with
\[
P_z = \sqrt{P^2-P_x^2-P_y^2}
\]
reconstructed algebraically.
We first show that this reduced four-dimensional map preserves the Euclidean
volume element \(dx\,dy\,dP_x\,dP_y\) exactly, and then extend the result to
the accelerator variables \((x,y,P_x,P_y,t,E)\).

\subsection{Reduced four-dimensional map}
Denote by \(D_{\frac12}\) the half drift in coordinates, by \(K_{\frac12}\)
the half kick from the transverse field \((B_x,B_y)\), and by \(R\) the
rotation generated by \(B_z\).
The full step is their composition:
\begin{equation}
\label{boris:maps-composition}
\Phi_{\Delta z}
= D_{\frac12}\circ K_{\frac12}\circ R\circ K_{\frac12}\circ D_{\frac12}.
\end{equation}
Since the determinant of the total Jacobian is the product of those of the
individual substeps, it is enough to show that each one has determinant one.

\begin{itemize}
\item \textbf{(a) Half drift in \((x,y)\):}
\[
x' = x + \frac{\Delta z}{2}\frac{P_x}{P_z}, \qquad
y' = y + \frac{\Delta z}{2}\frac{P_y}{P_z}, \qquad
P_x' = P_x, \quad P_y' = P_y.
\]
Since \(P_z\) depends only on \((P_x,P_y)\), the Jacobian has block form
\[
D\Phi_{D_{\frac12}}=
\begin{pmatrix}
I & *\\
0 & I
\end{pmatrix},
\]
and therefore
\[
\det(D\Phi_{D_{\frac12}}) = 1.
\]

\item \textbf{(b) Half kick from \((B_x,B_y)\):}
During the kick the coordinates are fixed,
\[
P_x' = P_x - \frac{q\Delta z}{2}B_y(x,y,z_h), \qquad
P_y' = P_y + \frac{q\Delta z}{2}B_x(x,y,z_h),
\qquad x'=x,\; y'=y,
\]
so the Jacobian has block form
\[
D\Phi_{K_{\frac12}} =
\begin{pmatrix}
I & 0\\[4pt]
* & I
\end{pmatrix},
\]
and hence
\[
\det(D\Phi_{K_{\frac12}})=1.
\]

\item \textbf{(c) Rotation from \(B_z\):}
During this substep the midpoint coordinates \((x,y,z_h)\) are held fixed, so
\(B_z=B_z(x,y,z_h)\) is a frozen parameter of the rotation map.
Write the transverse momentum in polar coordinates,
\[
P_x = r\cos\phi,\qquad P_y = r\sin\phi,\qquad
P_z = \sqrt{P^2-r^2}.
\]
The Boris rotation preserves the transverse norm exactly, so
\[
r' = r,
\qquad
\phi' = \phi - \alpha(r;x,y,z_h),
\]
where
\[
\alpha(r;x,y,z_h)=2\arctan\!\left(\frac{qB_z(x,y,z_h)\Delta z}{2P_z}\right).
\]
For each fixed \((x,y)\), the Jacobian in the momentum variables
\((r,\phi)\) is
\[
D_{(r,\phi)}\Phi_R =
\begin{pmatrix}
1 & 0\\[2pt]
-\partial_r\alpha(r;x,y,z_h) & 1
\end{pmatrix},
\]
whose determinant is \(1\).
Since \(dP_x\,dP_y = r\,dr\,d\phi\) and \(r'=r\), the Cartesian area element is
also preserved:
\[
dP_x'\,dP_y' = dP_x\,dP_y.
\]
Because the rotation leaves the coordinates unchanged,
\[
x'=x,\qquad y'=y,
\]
the full four-dimensional Jacobian has block lower-triangular form
\[
D\Phi_R=
\begin{pmatrix}
I & 0\\[4pt]
* & \displaystyle\frac{\partial(P_x',P_y')}{\partial(P_x,P_y)}
\end{pmatrix},
\]
where the lower-right block has determinant \(1\).
Therefore
\[
\det(D\Phi_R)=1.
\]
\end{itemize}

\subsection{Composition of the substeps}
Combining the three determinants gives
\[
\det(D\Phi_{\Delta z})
= \det(D\Phi_{D_{\frac12}})\,\det(D\Phi_{K_{\frac12}})\,\det(D\Phi_R)\,
  \det(D\Phi_{K_{\frac12}})\,\det(D\Phi_{D_{\frac12}})
= 1.
\]
Therefore the full reduced map preserves the four-dimensional volume element
exactly:
\[
dx'\,dy'\,dP_x'\,dP_y' = dx\,dy\,dP_x\,dP_y.
\]

\subsection{Extension to accelerator variables}
Introduce the extended variables
\[
U = (x,y,P_x,P_y,t,E),
\]
where \(E=\gamma mc^2\) is constant in the magnetic-only problem.
On the positive-energy shell one may write
\[
P(E)=\frac{1}{c}\sqrt{E^2-m^2c^4},
\qquad
P_z=\sqrt{P(E)^2-P_x^2-P_y^2},
\]
so the reduced map depends smoothly on \(E\) away from \(P_z=0\), and the
arrival time is updated by
\[
t' = t + g(x,y,P_x,P_y,E),
\]
with \(g\) given by the midpoint rule in Eq.~\eqref{boris:eq:dt}.
The extended one-step map has the form
\[
\Psi(U) = \bigl(\Phi_{\Delta z}(x,y,P_x,P_y;E),\, t+g,\, E\bigr).
\]
Its Jacobian matrix is block triangular:
\[
D\Psi =
\begin{pmatrix}
\displaystyle \frac{\partial \Phi_{\Delta z}}{\partial (x,y,P_x,P_y)} & 0 &
\displaystyle \frac{\partial \Phi_{\Delta z}}{\partial E}\\[10pt]
\displaystyle \frac{\partial g}{\partial (x,y,P_x,P_y)} & 1 &
\displaystyle \frac{\partial g}{\partial E}\\[10pt]
0 & 0 & 1
\end{pmatrix}.
\]
This matrix is not block diagonal: the row associated with the time update may
be full, because the arrival-time increment \(g\) depends on
\((x,y,P_x,P_y,E)\).  The determinant is nevertheless unaffected by this row.
Indeed, writing
\[
X=(x,y,P_x,P_y),\qquad
A=\frac{\partial\Phi_{\Delta z}}{\partial X},\quad
b=\frac{\partial\Phi_{\Delta z}}{\partial E},\quad
c=\frac{\partial g}{\partial X},\quad
d=\frac{\partial g}{\partial E},
\]
one has
\[
D\Psi=
\begin{pmatrix}
A & 0 & b\\
c & 1 & d\\
0 & 0 & 1
\end{pmatrix}.
\]
Expanding the determinant along the column associated with \(t\), which has
only one nonzero entry, gives
\[
\det(D\Psi)
=
\det
\begin{pmatrix}
A & b\\
0 & 1
\end{pmatrix}
=\det(A).
\]
Therefore
\[
\det(D\Psi)
= \det\!\left(
\frac{\partial \Phi_{\Delta z}}{\partial (x,y,P_x,P_y)}
\right)
= 1.
\]
Hence the extended map preserves the six-dimensional Euclidean volume element
\[
dx\,dy\,dP_x\,dP_y\,dt\,dE
\]
exactly.

\subsection{Interpretation}
The precise statement proved here is a Jacobian statement:
\[
\det(D\Phi_{\Delta z})=1
\quad\text{for the reduced map,}\qquad
\det(D\Psi)=1
\quad\text{for the extended map.}
\]
This establishes exact volume preservation in the chosen reduced and extended
variables.
It should not be confused with a proof of symplecticity.

% ---------------------------------------------------------------------
\section{Reversibility and second-order accuracy}
\label{boris:sec:accuracy}

It is possible to prove that one step is reversible,
\[
\boxed{\Phi_{-h}=\Phi_h^{-1}},
\]
and that the full fixed-length transfer map is second-order accurate in
\(C^1\):
\[
\boxed{
\begin{gathered}
\Phi_h^L-\varphi_L=\mathcal O(h^2),\\
D\Phi_h^L-D\varphi_L=\mathcal O(h^2).
\end{gathered}
}
\]
Second-order accuracy in \(C^1\) means that both:
\begin{itemize}
\item the tracked particle coordinates converge with error
\(\mathcal O(h^2)\); and
\item the map's first derivatives with respect to the initial coordinates---its
Jacobian or response matrix---also converge with error \(\mathcal O(h^2)\).
\end{itemize}

The asymptotic notation is defined first, while the proof of the statements
above is given in the following subsections.

\subsection{Asymptotic notation}
All order estimates in this section are meant uniformly on the compact region
of phase space under consideration, for sufficiently small step size.
For a family of maps \(R_h(U)\), the notation
\[
R_h(U)=\mathcal O(h^p)
\]
means that there are constants \(C>0\) and \(h_0>0\), independent of \(U\) in
that compact region, such that
\[
\|R_h(U)\|\le C h^p
\qquad
\text{for } 0<h<h_0.
\]
The notation
\[
R_h(U)=\mathcal O_{C^1}(h^p)
\]
means that both the map and its derivative with respect to the initial
condition \(U\) satisfy this bound:
\[
\|R_h(U)\|\le C h^p,
\qquad
\|DR_h(U)\|\le C h^p.
\]
Thus, if two maps differ by an \(\mathcal O_{C^1}(h^p)\) remainder, then both
the maps themselves and their Jacobians differ by \(\mathcal O(h^p)\).

\subsection{Extended mechanical system}
Let
\[
U=(x,y,P_x,P_y,t,E,z),
\]
and let the exact spatial dynamics be the autonomous ODE
\[
\totder{U}{z}=F(U),
\]
with
\[
F(U)=\left(
\frac{P_x}{P_z},
\frac{P_y}{P_z},
q\frac{P_y}{P_z}B_z-qB_y,
qB_x-q\frac{P_x}{P_z}B_z,
\frac{E}{c^2P_z},
0,
1
\right),
\]
where
\[
P(E)=\frac{1}{c}\sqrt{E^2-m^2c^4},
\qquad
P_z=\sqrt{P(E)^2-P_x^2-P_y^2},
\]
and the magnetic field is evaluated at \((x,y,z)\).
On compact sets where \(E\ge E_0>mc^2\) and \(P_z\ge c_0>0\), this vector
field is smooth whenever \(\bm B\) is smooth.

\subsection{Smoothness of one step}
Each substep of the algorithm is obtained from finitely many additions,
multiplications, evaluations of \(\bm B\), the square root
\[
P_z=\sqrt{P(E)^2-P_x^2-P_y^2},
\]
and the rational functions defining the Cayley rotation.
Since \(P_z\ge c_0>0\), all denominators stay uniformly away from zero, so for
\(|h|\) small enough the one-step map \(\Phi_h\) is \(C^1\) in \(U\), and in
fact \(C^2\) in \(U\) and \(C^3\) in \(h\), uniformly on the compact region.

\subsection{Proof of reversibility}
For every step for which the construction is well defined, the spatial Boris
step is reversible:
\begin{equation}
\Phi_{-h}=\Phi_h^{-1}.
\label{boris:eq:reversibility}
\end{equation}
The step is the symmetric composition
\[
\Phi_h = D_{\frac h2}\circ K_{\frac h2}\circ R_h\circ K_{\frac h2}\circ D_{\frac h2}.
\]
Starting from the final state and applying the same construction with step
\(-h\), the first backward half drift returns exactly to the same midpoint
\((x_h,y_h,z_h)\), so the same magnetic field is used.
The backward half kick undoes the last forward half kick, the Cayley rotation
with parameter \(-T\) is the inverse of the forward rotation, the second
backward half kick undoes the first forward half kick, and the final backward
half drift returns to the initial position. \hfill\(\Box\)

\subsection{Proof of second-order accuracy}
Assume \(\bm B\in C^3\) on a neighborhood of the compact region visited by the
exact and numerical trajectories, and assume \(P_z\ge c_0>0\) there.
Then, for \(h\) sufficiently small, one Boris step is a \(C^1\) map of \(U\).
Moreover, if \(h=L/N\) with \(N\in\mathbb N\), the projected full map over
fixed length \(L\) in the six variables \((x,y,P_x,P_y,t,E)\) is second-order
accurate in \(C^1\):
\begin{equation}
\Phi_h^L-\varphi_L=\mathcal O(h^2),
\qquad
D\Phi_h^L-D\varphi_L=\mathcal O(h^2),
\label{boris:eq:C1_accuracy}
\end{equation}
uniformly on the region of interest, where \(\varphi_L\) denotes the exact
transfer map of the spatial Lorentz system over length \(L\).

\subsubsection{First-order consistency}
Write
\[
d(U)=\left(\frac{P_x}{P_z},\frac{P_y}{P_z}\right),\qquad
k(U)=(-qB_y,qB_x),\qquad
\omega(U)=\frac{qB_z}{P_z}.
\]
The first half drift gives
\[
x_h=x+\frac h2 d_x(U),\qquad
y_h=y+\frac h2 d_y(U),\qquad
z_h=z+\frac h2,
\]
and therefore, by smoothness of \(\bm B\),
\[
\bm B(x_h,y_h,z_h)=\bm B(x,y,z)+\mathcal O(h).
\]
Equivalently,
\[
k(x_h,y_h,z_h)=k(U)+\mathcal O(h),
\]
where the \(\mathcal O(h)\) term denotes the difference between the
midpoint-evaluated kick field and the kick field at the initial state.
The first half kick gives
\[
\binom{P_x^-}{P_y^-}
=
\binom{P_x}{P_y}
+ \frac h2\,k(x_h,y_h,z_h)
=
\binom{P_x}{P_y}
+ \frac h2\,k(U) + \mathcal O(h^2),
\]
and smoothness of \(P_z\) on the region \(P_z\ge c_0\) gives
\[
P_{z,\mathrm{mid}}=P_z+\mathcal O(h),
\qquad
\frac{1}{P_{z,\mathrm{mid}}}=\frac{1}{P_z}+\mathcal O(h).
\]
Thus
\[
T
=
\frac{h}{2}\,\frac{qB_z(x_h,y_h,z_h)}{P_{z,\mathrm{mid}}}
=
\frac h2\,\omega(U)+\mathcal O(h^2),
\]
and the Cayley coefficients satisfy
\[
C=1+\mathcal O(h^2),\qquad S=h\,\omega(U)+\mathcal O(h^2).
\]
The rotation step therefore yields
\[
\binom{P_x^+}{P_y^+}
=
\binom{P_x^-}{P_y^-}
+ h\,\omega(U)
\binom{P_y}{-P_x}
+ \mathcal O(h^2).
\]
After the second half kick,
\[
\binom{P_x'}{P_y'}
=
\binom{P_x}{P_y}
+ h
\binom{q\frac{P_y}{P_z}B_z-qB_y}{qB_x-q\frac{P_x}{P_z}B_z}
+ \mathcal O(h^2).
\]
Since \(P_x'-P_x=\mathcal O(h)\) and \(P_y'-P_y=\mathcal O(h)\), the second
half drift gives
\[
x'=x+h\frac{P_x}{P_z}+\mathcal O(h^2),\qquad
y'=y+h\frac{P_y}{P_z}+\mathcal O(h^2).
\]
Similarly,
\[
t'=t+h\frac{E}{c^2P_z}+\mathcal O(h^2),
\qquad
E'=E,
\qquad
z'=z+h.
\]
Collecting all components,
\begin{equation}
\Phi_h(U)=U+hF(U)+\mathcal O(h^2),
\label{boris:eq:first_order_consistency}
\end{equation}
uniformly on the compact region.

\subsubsection{Second-order local defect}
Because \(\Phi_h\) is \(C^2\) in \(U\) and \(C^3\) in \(h\), consistency gives
an expansion
\[
\Phi_h(U)=U+hF(U)+h^2 A(U)+\mathcal O_{C^1}(h^3)
\]
for some \(C^1\) function \(A(U)\).
Using the same expansion for \(\Phi_{-h}\), inserting
\[
V=\Phi_h(U)=U+hF(U)+\mathcal O(h^2),
\]
and expanding \(F(V)\) and \(A(V)\) around \(U\), one obtains
\[
\Phi_{-h}(V)
=
U+h^2\!\left(2A(U)-F'(U)F(U)\right)+\mathcal O_{C^1}(h^3).
\]
By reversibility, Eq.~\eqref{boris:eq:reversibility}, this must equal \(U\).
Hence
\[
A(U)=\frac12 F'(U)F(U),
\]
and therefore
\begin{equation}
\Phi_h(U)=U+hF(U)+\frac{h^2}{2}F'(U)F(U)+\mathcal O_{C^1}(h^3).
\label{boris:eq:local_C1_second_order}
\end{equation}
The exact flow \(\varphi_h\) of the ODE has the same Taylor expansion, as
shown in Sec.~\ref{boris:sec:exactflowtaylor}, so
the difference between Eqs.~\eqref{boris:eq:local_C1_second_order} and
\eqref{boris:eq:exact_flow_taylor_C1} is an \(\mathcal O_{C^1}(h^3)\) remainder.
In particular, both the maps and their Jacobians differ by order \(h^3\):
\begin{equation}
\Phi_h(U)-\varphi_h(U)=\mathcal O(h^3),
\qquad
D\Phi_h(U)-D\varphi_h(U)=\mathcal O(h^3),
\label{boris:eq:local_C1_defect}
\end{equation}
uniformly on the compact region.

\subsubsection{Global state error over fixed length \(L\)}
Let \(U_n=\Phi_h^n(U_0)\) and \(V_n=\varphi_{nh}(U_0)\), with \(nh\le L\), and
let \(e_n=U_n-V_n\).
The next-step error is
\[
e_{n+1}
=
U_{n+1}-V_{n+1}
=
\Phi_h(U_n)-\varphi_h(V_n).
\]
Add and subtract \(\Phi_h(V_n)\):
\[
e_{n+1}
=
\bigl(\Phi_h(U_n)-\Phi_h(V_n)\bigr)
+
\bigl(\Phi_h(V_n)-\varphi_h(V_n)\bigr).
\]
Taking norms gives
\[
\|e_{n+1}\|
\le
\|\Phi_h(U_n)-\Phi_h(V_n)\|
+
\|\Phi_h(V_n)-\varphi_h(V_n)\|.
\]
The second term is the one-step local defect. By
Eq.~\eqref{boris:eq:local_C1_defect},
\[
\|\Phi_h(V_n)-\varphi_h(V_n)\|\le Ch^3.
\]
For the first term, Eq.~\eqref{boris:eq:first_order_consistency} implies
\[
D\Phi_h(U)=I+hF'(U)+\mathcal O(h^2),
\]
uniformly on the compact region.
Since \(F'\) is bounded on the compact region, this gives the operator-norm
bound
\[
\|D\Phi_h(U)\|\le 1+Ch
\]
for all \(U\) in the region and all sufficiently small \(h\).
To compare \(\Phi_h(U_n)\) and \(\Phi_h(V_n)\), write
\[
\Phi_h(U_n)-\Phi_h(V_n)
=
\int_0^1
D\Phi_h\!\left(V_n+s(U_n-V_n)\right)(U_n-V_n)\,ds.
\]
Taking norms and using the uniform bound on \(D\Phi_h\) gives
\[
\|\Phi_h(U_n)-\Phi_h(V_n)\|
\le
(1+Ch)\|U_n-V_n\|
=
(1+Ch)\|e_n\|.
\]
Combining the two bounds yields the recurrence
\[
\|e_{n+1}\|\le (1+Ch)\|e_n\| + Ch^3.
\]
Since \(e_0=0\), the discrete Gronwall lemma in Sec.~\ref{boris:sec:gronwall}
gives
\begin{equation}
\|e_n\|\le C h^2
\qquad \text{for } 0\le nh\le L.
\label{boris:eq:global_state_error}
\end{equation}

\subsubsection{Global tangent-map error}
Let
\[
A_n = D\Phi_h^n(U_0),\qquad B_n = D\varphi_{nh}(U_0).
\]
Thus \(A_n\) is the Jacobian, with respect to the initial condition \(U_0\),
of the numerical transfer map after \(n\) steps, while \(B_n\) is the
corresponding Jacobian of the exact transfer map over the same distance
\(nh\).
For the numerical map,
\[
U_{n+1}
=
\Phi_h^{n+1}(U_0)
=
\Phi_h\!\left(\Phi_h^n(U_0)\right).
\]
Differentiating with respect to the initial condition \(U_0\) and applying the
chain rule gives
\[
D\Phi_h^{n+1}(U_0)
=
D\Phi_h\!\left(\Phi_h^n(U_0)\right)\,D\Phi_h^n(U_0).
\]
Since \(\Phi_h^n(U_0)=U_n\) and \(A_n=D\Phi_h^n(U_0)\), this becomes
\[
A_{n+1}=D\Phi_h(U_n)\,A_n.
\]
Similarly, for the exact flow,
\[
V_{n+1}
=
\varphi_{(n+1)h}(U_0)
=
\varphi_h\!\left(\varphi_{nh}(U_0)\right).
\]
Differentiating gives
\[
D\varphi_{(n+1)h}(U_0)
=
D\varphi_h\!\left(\varphi_{nh}(U_0)\right)\,D\varphi_{nh}(U_0).
\]
Since \(\varphi_{nh}(U_0)=V_n\) and \(B_n=D\varphi_{nh}(U_0)\), we obtain
\[
B_{n+1}=D\varphi_h(V_n)\,B_n.
\]
We next compare the one-step tangent maps evaluated at \(U_n\) and \(V_n\).
By the triangle inequality,
\[
\begin{aligned}
\|D\Phi_h(U_n)-D\varphi_h(V_n)\|
&\le
\|D\Phi_h(U_n)-D\varphi_h(U_n)\| \\
&\quad
+\|D\varphi_h(U_n)-D\varphi_h(V_n)\|.
\end{aligned}
\]
The first term is bounded by Eq.~\eqref{boris:eq:local_C1_defect}:
\[
\|D\Phi_h(U_n)-D\varphi_h(U_n)\|\le Ch^3.
\]
For the second term, set \(G_h(U)=D\varphi_h(U)\).  The mean-value theorem,
applied now to the map \(G_h\), gives
\[
\|G_h(U_n)-G_h(V_n)\|
\le
\sup_{0\le s\le 1}
\|DG_h(V_n+s(U_n-V_n))\|\,\|U_n-V_n\|.
\]
Here \(DG_h=D^2\varphi_h\).  From the Taylor expansion of the exact flow,
\[
\varphi_h(U)=U+hF(U)+\mathcal O(h^2),
\]
we obtain, after differentiating twice with respect to \(U\),
\[
D^2\varphi_h(U)=hF''(U)+\mathcal O(h^2).
\]
Since \(F''\) is bounded on the compact region under consideration, it follows
that
\[
\|D^2\varphi_h(U)\|\le Ch .
\]
Therefore
\[
\|D\varphi_h(U_n)-D\varphi_h(V_n)\|
\le
Ch\,\|U_n-V_n\|.
\]
Using the state-error estimate \eqref{boris:eq:global_state_error}, this gives
\[
\|D\varphi_h(U_n)-D\varphi_h(V_n)\|
\le
Ch\,Ch^2
\le
Ch^3.
\]
Combining the two bounds, we obtain
\[
\|D\Phi_h(U_n)-D\varphi_h(V_n)\|\le Ch^3.
\]
Since \(\|D\Phi_h(U_n)\|\le 1+Ch\) and \(\|B_n\|\le C\) uniformly on
\(0\le nh\le L\),
\[
\|A_{n+1}-B_{n+1}\|
\le
(1+Ch)\|A_n-B_n\| + Ch^3.
\]
With \(A_0=B_0=I\), another application of Sec.~\ref{boris:sec:gronwall} yields
\begin{equation}
\|A_n-B_n\|\le Ch^2
\qquad \text{for } 0\le nh\le L.
\label{boris:eq:global_jacobian_error_mech}
\end{equation}
Equations \eqref{boris:eq:global_state_error} and
\eqref{boris:eq:global_jacobian_error_mech} prove Eq.~\eqref{boris:eq:C1_accuracy} in the
autonomous variables \(U=(x,y,P_x,P_y,t,E,z)\).
Because both the numerical and exact updates advance \(z\) exactly by \(h\),
projecting after \(N=L/h\) steps onto the six variables
\((x,y,P_x,P_y,t,E)\) preserves the same \(C^1\) error order. \hfill\(\Box\)

% ---------------------------------------------------------------------
\section{Global symplectic defect at field-free boundaries}
\label{boris:sec:sympldefect}

The reduced mechanical variables used inside the algorithm are not canonical
variables in the presence of a magnetic field, so there is no reason to expect
the interior slice-to-slice map to be exactly symplectic with respect to the
constant canonical matrix \(S\).
However, a different statement becomes available for the \emph{full} transfer
map from entrance to exit when the two ends of the region are field-free.
The statement in this section is formulated entirely in the canonical
entrance/exit variables and does not rely on interpreting the interior
slice-to-slice Boris map as symplectic.
Under the field-free boundary assumptions made precise below, the Jacobian \(M\)
of the full numerical entrance-to-exit map satisfies
\[
\boxed{M^\top S M - S = \mathcal O(h^2)}
\]
over any fixed propagation length \(L\).
The mechanism behind the scaling is simple.
In canonical boundary coordinates, the exact full transfer map is symplectic.
If the numerical full transfer map and its tangent map both approximate the
exact ones with global error \(\mathcal O(h^2)\), then inserting
\(M=T+\mathcal O(h^2)\) into \(M^\top S M-S\) immediately yields an
\(\mathcal O(h^2)\) symplectic defect for the full map.
This is a statement about the entrance-to-exit transfer map only; it does not
assert symplecticity, or a canonical symplectic-defect estimate, for the
interior slice-to-slice Boris updates.
The proof is given in the following subsections by combining exact symplecticity
of the continuous boundary map with the \(C^1\) accuracy estimate from
Sec.~\ref{boris:sec:accuracy}.

\subsection{Additional boundary assumptions}
In addition to the regularity and \(P_z\ge c_0>0\) assumptions of
Sec.~\ref{boris:sec:accuracy}, assume that the entrance and exit lie in field-free
neighborhoods and choose a gauge such that \(A=0\) in those neighborhoods.
Then canonical and mechanical transverse momenta coincide at the entrance and
exit:
\[
p_x = P_x,\qquad p_y = P_y.
\]

\subsection{Boundary variables and symplectic matrix}
Let
\[
\xi = (x,p_x,y,p_y,t,-E)
\]
be the canonical boundary state vector.
At the entrance and exit, this is equivalently
\[
\xi = (x,P_x,y,P_y,t,-E).
\]
In this ordering, the canonical symplectic matrix is
\[
S =
\begin{pmatrix}
0 & 1 & 0 & 0 & 0 & 0\\
-1 & 0 & 0 & 0 & 0 & 0\\
0 & 0 & 0 & 1 & 0 & 0\\
0 & 0 & -1 & 0 & 0 & 0\\
0 & 0 & 0 & 0 & 0 & 1\\
0 & 0 & 0 & 0 & -1 & 0
\end{pmatrix}.
\]

To justify the exact symplecticity of the entrance-to-exit map, recall the
standard spatial Hamiltonian reduction for a static magnetic field.
Let \(\bm A(x,y,z)\) be a vector potential with \(\nabla\times\bm A=\bm B\) and
\(\phi=0\).
The relativistic energy relation in canonical variables is
\[
E^2
=
m^2c^4
+ c^2\!\left[(p_x-qA_x)^2+(p_y-qA_y)^2+(p_z-qA_z)^2\right].
\]
On the forward branch \(P_z>0\), solving for \(p_z\) gives
\[
p_z
=
qA_z
+ \sqrt{\frac{E^2}{c^2}-m^2c^2-(p_x-qA_x)^2-(p_y-qA_y)^2}.
\]
Using \(z\) as the independent variable, the associated spatial Hamiltonian is
\[
\mathcal K(x,y,z,p_x,p_y,E)
= -\,p_z.
\]
Then the exact dynamics of
\(\xi=(x,p_x,y,p_y,t,-E)\) is governed by the canonical Hamilton equations
\[
\totder{\xi}{z} = S\,\nabla_\xi \mathcal K(\xi,z).
\]
Therefore, for every fixed propagation length \(L\), the exact transfer map in
the boundary variables is symplectic.

\subsection{Exact and numerical maps}
Let \(\Psi^L\) be the exact transfer map over a fixed length \(L\), and let
\[
T = D\Psi^L
\]
be its Jacobian matrix in the boundary variables \(\xi\).
Since \(\Psi^L\) is the exact flow of the spatial Hamiltonian system in
canonical variables, its Jacobian satisfies
\begin{equation}
T^\top S T = S.
\label{boris:eq:exact_symplectic}
\end{equation}

Let \(\Phi_h^L\) be the full numerical map over the same fixed length
\(L=Nh\), and let
\[
M = D\Phi_h^L
\]
be its Jacobian matrix in the boundary variables.
By Eq.~\eqref{boris:eq:C1_accuracy}, and because canonical and mechanical momenta
coincide at the field-free boundaries,
\begin{equation}
M-T = \mathcal O(h^2).
\label{boris:eq:global_jacobian_error}
\end{equation}

\subsection{Proof of the main result}
Under the assumptions stated above, for any fixed propagation length \(L\),
\begin{equation}
M^\top S M - S = \mathcal O(h^2)
\qquad \text{as } h\to 0.
\label{boris:eq:global_sympl_defect}
\end{equation}
Write
\[
M = T + E,
\qquad E = \mathcal O(h^2).
\]
Then
\[
M^\top S M - S
=
(T+E)^\top S (T+E) - S.
\]
Expanding gives
\[
M^\top S M - S
=
T^\top S T - S
+ T^\top S E
+ E^\top S T
+ E^\top S E.
\]
By Eq.~\eqref{boris:eq:exact_symplectic}, the first term vanishes.
Since \(T=\mathcal O(1)\) and \(E=\mathcal O(h^2)\), the remaining terms are
\(\mathcal O(h^2)\), \(\mathcal O(h^2)\), and \(\mathcal O(h^4)\),
respectively.
This proves Eq.~\eqref{boris:eq:global_sympl_defect}. \hfill\(\Box\)

\section{Volume preservation of the exact spatial flow}
\label{boris:sec:exactvolume}

The volume-preservation result proved in Sec.~\ref{boris:sec:volumepreservation} is
a property of the discrete spatial Boris map.  The corresponding exact
magnetic-only dynamics has the same volume-preservation property, away from
the singular set \(P_z=0\).
We use the standard implication recalled in Sec.~\ref{boris:sec:liouville}: a
smooth vector field with zero divergence has a flow with unit Jacobian
determinant.

First, in the original time-parametrized Cartesian variables, the Lorentz
equations preserve the six-dimensional Liouville volume element
\[
dx\,dy\,dz\,dP_x\,dP_y\,dP_z.
\]
Indeed, writing
\[
\totder{\bm r}{t}=\frac{\bm P}{\gamma m},
\qquad
\totder{\bm P}{t}=q\,\frac{\bm P}{\gamma m}\times\bm B(\bm r),
\]
the position part has zero divergence with respect to \(\bm r\), since
\(\bm P/(\gamma m)\) is independent of position.  The momentum part also has
zero divergence.  Explicitly, since \(\bm B\) is independent of \(\bm P\),
\[
\nabla_{\bm P}\cdot\left(q\,\frac{\bm P}{\gamma m}\times\bm B\right)
=\frac{q}{m}\,
 \nabla_{\bm P}\cdot\left(\frac{1}{\gamma}\,\bm P\times\bm B\right)
\]
\[
=\frac{q}{m}\left[
\nabla_{\bm P}\!\left(\frac{1}{\gamma}\right)\cdot(\bm P\times\bm B)
+\frac{1}{\gamma}\,\nabla_{\bm P}\cdot(\bm P\times\bm B)
\right].
\]
The first term is zero because
\[
\nabla_{\bm P}\!\left(\frac{1}{\gamma}\right)
=-\frac{\bm P}{\gamma^3 m^2c^2},
\]
which is parallel to \(\bm P\), and hence orthogonal to
\(\bm P\times\bm B\).  The second term is also zero, since
\[
\nabla_{\bm P}\cdot(\bm P\times\bm B)
=\partial_{P_x}(P_yB_z-P_zB_y)
+\partial_{P_y}(P_zB_x-P_xB_z)
+\partial_{P_z}(P_xB_y-P_yB_x)
=0.
\]

This is consistent with the usual Hamiltonian statement in canonical
variables.  Let \(\bm A(\bm r)\) be a vector potential, \(\bm B=\nabla\times
\bm A\), and define the canonical momentum
\[
\bm p=\bm P+q\bm A(\bm r).
\]
In the canonical variables \((\bm r,\bm p)\), the magnetic-only motion is
Hamiltonian, and therefore preserves the canonical phase-space volume element
\[
dx\,dy\,dz\,dp_x\,dp_y\,dp_z.
\]
The change of variables from mechanical to canonical momentum has Jacobian
\[
\frac{\partial(\bm r,\bm p)}{\partial(\bm r,\bm P)}
=
\begin{pmatrix}
I & 0\\
q\,\partial_{\bm r}\bm A & I
\end{pmatrix},
\]
whose determinant is one.  Hence
\[
dx\,dy\,dz\,dp_x\,dp_y\,dp_z
=
dx\,dy\,dz\,dP_x\,dP_y\,dP_z.
\]
Thus the canonical Liouville volume and the mechanical Cartesian volume used
above are the same volume element.

Now fix the energy, equivalently the momentum magnitude \(P\), and use \(z\)
as independent variable on the branch \(P_z>0\).  The exact reduced spatial
system in \(X=(x,y,P_x,P_y)\) is
\[
\totder{x}{z}=\frac{P_x}{P_z},
\qquad
\totder{y}{z}=\frac{P_y}{P_z},
\]
\[
\totder{P_x}{z}=q\frac{P_y}{P_z}B_z-qB_y,
\qquad
\totder{P_y}{z}=qB_x-q\frac{P_x}{P_z}B_z,
\]
where
\[
P_z=\sqrt{P^2-P_x^2-P_y^2},
\]
and the magnetic field is evaluated at \((x,y,z)\).  Since \(P_z\) depends only
on \((P_x,P_y)\), and \(\bm B\) depends only on position, the divergence with
respect to \(X\) is
\begin{align*}
\nabla_X\cdot F
&=
\partial_x\!\left(\frac{P_x}{P_z}\right)
+\partial_y\!\left(\frac{P_y}{P_z}\right)\\
&\quad
+\partial_{P_x}\!\left(q\frac{P_y}{P_z}B_z-qB_y\right)
+\partial_{P_y}\!\left(qB_x-q\frac{P_x}{P_z}B_z\right)\\
&=
qB_z P_y\,\partial_{P_x}\!\left(\frac{1}{P_z}\right)
-qB_z P_x\,\partial_{P_y}\!\left(\frac{1}{P_z}\right).
\end{align*}
Using
\[
\partial_{P_x}\!\left(\frac{1}{P_z}\right)=\frac{P_x}{P_z^3},
\qquad
\partial_{P_y}\!\left(\frac{1}{P_z}\right)=\frac{P_y}{P_z^3},
\]
the two remaining terms cancel, and therefore
\[
\nabla_X\cdot F=0.
\]
By Sec.~\ref{boris:sec:liouville}, the exact reduced spatial flow therefore
preserves
\[
dx\,dy\,dP_x\,dP_y.
\]
Equivalently, at fixed \(z\), one may introduce transverse canonical momenta
\[
p_x=P_x+qA_x(x,y,z),
\qquad
p_y=P_y+qA_y(x,y,z).
\]
The transverse change of variables
\[
(x,y,P_x,P_y)\mapsto(x,y,p_x,p_y)
\]
again has triangular Jacobian
\[
\frac{\partial(x,y,p_x,p_y)}{\partial(x,y,P_x,P_y)}
=
\begin{pmatrix}
I & 0\\
* & I
\end{pmatrix},
\]
and determinant one.  Therefore
\[
dx\,dy\,dp_x\,dp_y
=
dx\,dy\,dP_x\,dP_y.
\]
The reduced mechanical volume preserved by the spatial flow is therefore the
same volume as the corresponding transverse canonical volume.

The extended accelerator variables add
\[
\totder{t}{z}=\frac{E}{c^2P_z},
\qquad
\totder{E}{z}=0.
\]
The corresponding vector field in \((x,y,P_x,P_y,t,E)\) has divergence
\[
\nabla_X\cdot F
+\partial_t\!\left(\frac{E}{c^2P_z}\right)
+\partial_E(0)
=0.
\]
Again by Sec.~\ref{boris:sec:liouville}, the exact magnetic-only spatial flow
also preserves the extended Euclidean volume element
\[
dx\,dy\,dP_x\,dP_y\,dt\,dE.
\]
Since the change from \((P_x,P_y)\) to \((p_x,p_y)\) has unit Jacobian and
leaves \(t\) and \(E\) unchanged, this is equivalently the preservation of
\[
dx\,dy\,dp_x\,dp_y\,dt\,dE.
\]
The discrete result in Sec.~\ref{boris:sec:volumepreservation} may therefore be
viewed as exact preservation, by the algorithm, of the same reduced and
extended volume elements preserved by the continuous spatial dynamics.

\section{Divergence-free vector fields and volume preservation}
\label{boris:sec:liouville}

For completeness we recall the standard argument connecting zero divergence
with volume preservation.  Let
\[
\totder{U}{z}=F(U)
\]
be a smooth autonomous system in \(\mathbb R^n\), and let
\(\varphi_z(U_0)\) be its flow.  Define the Jacobian matrix of the flow with
respect to the initial condition,
\[
J(z)=D\varphi_z(U_0).
\]
Differentiating the flow with respect to \(U_0\) gives the variational equation
\[
\totder{J}{z}=DF(\varphi_z(U_0))\,J,
\qquad
J(0)=I.
\]
By Jacobi's formula for the derivative of a determinant,
\[
\totder{}{z}\det J
=\det J\,
\operatorname{tr}\!\left(J^{-1}\totder{J}{z}\right).
\]
Substituting the variational equation gives
\[
\totder{}{z}\det J
=\det J\,
\operatorname{tr}\!\left(J^{-1}DF(\varphi_z(U_0))J\right).
\]
Using cyclic invariance of the trace,
\[
\operatorname{tr}\!\left(J^{-1}DFJ\right)
=\operatorname{tr}(DF)
=\nabla\cdot F.
\]
Therefore
\[
\totder{}{z}\det D\varphi_z(U_0)
=
\bigl(\nabla\cdot F\bigr)(\varphi_z(U_0))\,
\det D\varphi_z(U_0).
\]
If \(\nabla\cdot F=0\), then
\[
\totder{}{z}\det D\varphi_z(U_0)=0.
\]
Since \(D\varphi_0(U_0)=I\), one obtains
\[
\det D\varphi_z(U_0)=1
\]
for all \(z\) for which the flow is defined.  Thus the Euclidean volume
element is preserved by the flow.

\section{Consistency check for the parallel case}
\label{boris:sec:parallelcase}

To verify the accuracy when the true Lorentz force vanishes, consider a
uniform magnetic field \(\bm{B}=(B_x,B_y,B_z)\) and an initial momentum
exactly parallel to it, \(\bm{P}^0 = \alpha\,\bm{B}\) with constant
\(\alpha>0\).
Physically, \(\bm{P}\) must remain constant:
\[
\frac{d\bm{P}}{dz}=\frac{q}{P_z}(\bm{P}\times\bm{B})=0,
\qquad
\bm{P}(z)=\bm{P}^0.
\]

\subsection{Step 1: Half-kick}
\[
P_x^- = \alpha B_x - \frac{q\Delta z}{2} B_y, \qquad
P_y^- = \alpha B_y + \frac{q\Delta z}{2} B_x .
\]

\subsection{Step 2: Rotation expanded}
Let \(B_\perp^2 := B_x^2 + B_y^2\).
From the half-kick we have
\[
P_x^- = \alpha B_x - \frac{q\Delta z}{2} B_y,
\qquad
P_y^- = \alpha B_y + \frac{q\Delta z}{2} B_x .
\]
Compute the transverse magnitude:
\[
(P_x^-)^2 + (P_y^-)^2
= \alpha^2 B_\perp^2 + \frac{q^2\Delta z^2}{4} B_\perp^2.
\]
Hence
\[
P_{z,\mathrm{mid}}^2 = P^2 - (P_x^-)^2 - (P_y^-)^2
= \alpha^2 B_z^2 - \frac{q^2\Delta z^2}{4} B_\perp^2.
\]
Expanding the square root,
\[
P_{z,\mathrm{mid}}
= \alpha B_z \left(1 - \frac{q^2\Delta z^2}{8\alpha^2}\frac{B_\perp^2}{B_z^2}\right)
+ O(\Delta z^4).
\]
Therefore
\[
\frac{1}{P_{z,\mathrm{mid}}}
= \frac{1}{\alpha B_z}\!\left(1 + \frac{q^2\Delta z^2}{8\alpha^2}\frac{B_\perp^2}{B_z^2}\right)
+ O(\Delta z^4).
\]
The exact spatial rotation angle is
\[
\theta = \frac{q B_z \Delta z}{P_{z,\mathrm{mid}}}
       = \frac{q}{\alpha}\,\Delta z + O(\Delta z^3),
\]
whereas the Boris map rotates by
\[
\theta_B = 2\arctan\!\left(\frac{q B_z \Delta z}{2P_{z,\mathrm{mid}}}\right)
= \theta + O(\Delta z^3).
\]
Using
\(\sin\theta_B = \theta_B + O(\Delta z^3)\)
and
\(\cos\theta_B = 1 - \tfrac12\theta_B^2 + O(\Delta z^4)\),
we obtain
\begin{align*}
P_x^+ &= (1-\tfrac12\theta_B^2)P_x^- + \theta_B P_y^-
       = \alpha B_x + \frac{q\Delta z}{2}B_y + O(\Delta z^3),\\[3pt]
P_y^+ &= -\theta_B P_x^- + (1-\tfrac12\theta_B^2)P_y^-
       = \alpha B_y - \frac{q\Delta z}{2}B_x + O(\Delta z^3).
\end{align*}

\subsection{Step 3: Second half-kick}
\[
P_x' = P_x^+ - \frac{q\Delta z}{2}B_y = \alpha B_x + O(\Delta z^3), \qquad
P_y' = P_y^+ + \frac{q\Delta z}{2}B_x = \alpha B_y + O(\Delta z^3).
\]

All \(O(\Delta z)\) and \(O(\Delta z^2)\) terms cancel exactly.
Therefore
\[
\bm{P}' = \bm{P}^0 + O(\Delta z^3).
\]
The local truncation error per step is \(O(\Delta z^3)\), leading to a global
error \(O(\Delta z^2)\) over a fixed distance.
Hence even when \(\bm{P}\!\parallel\!\bm{B}\), the algorithm preserves the
momentum direction up to second order in \(\Delta z\), and any residual
spurious kick decreases quadratically with step size.

\section{Taylor expansion of the exact flow}
\label{boris:sec:exactflowtaylor}

Let \(\varphi_h(U)\) be the exact flow of
\[
\totder{U}{z}=F(U).
\]
Writing \(U(z)=\varphi_z(U)\), Taylor's theorem gives
\[
U(h)=U(0)+hU'(0)+\frac{h^2}{2}U''(0)+\mathcal O(h^3).
\]
Since
\[
U'(z)=F(U(z)),
\]
we have
\[
U'(0)=F(U).
\]
Differentiating once more gives
\[
U''(z)=F'(U(z))\,U'(z)=F'(U(z))F(U(z)),
\]
and therefore
\[
U''(0)=F'(U)F(U).
\]
Thus the exact flow satisfies
\begin{equation}
\varphi_h(U)
=
U+hF(U)+\frac{h^2}{2}F'(U)F(U)+\mathcal O_{C^1}(h^3).
\label{boris:eq:exact_flow_taylor_C1}
\end{equation}
Here \(\mathcal O_{C^1}(h^3)\) means that both the remainder and its derivative
with respect to the initial condition \(U\) are bounded by \(Ch^3\), uniformly
on the compact region under consideration.
This \(C^1\) version is the expansion used in Sec.~\ref{boris:sec:accuracy}.

\section{Discrete Gronwall Lemma}
\label{boris:sec:gronwall}

For completeness we record the elementary discrete estimate used in the proof
of the \(C^1\) global error bounds.

\subsection{Lemma}
Let \(h>0\), let \(\alpha,\beta\ge 0\), let \(p\ge 1\), and let
\(\{a_n\}_{n\ge 0}\) be a nonnegative sequence satisfying
\begin{equation}
a_{n+1}\le (1+\alpha h)a_n + \beta h^p
\qquad \text{for all } n\ge 0.
\label{boris:eq:discrete_gronwall_rec}
\end{equation}
Then for every \(n\ge 0\),
\begin{equation}
a_n \le (1+\alpha h)^n a_0
     + \beta h^p \sum_{j=0}^{n-1}(1+\alpha h)^j.
\label{boris:eq:discrete_gronwall_sum}
\end{equation}
In particular, if \(nh\le L\), then
\begin{equation}
a_n \le e^{\alpha L} a_0
     + \frac{\beta}{\alpha}\bigl(e^{\alpha L}-1\bigr) h^{p-1}
\qquad (\alpha>0),
\label{boris:eq:discrete_gronwall_bound}
\end{equation}
while for \(\alpha=0\) one has
\begin{equation}
a_n \le a_0 + \beta L h^{p-1}.
\label{boris:eq:discrete_gronwall_bound_zero}
\end{equation}

\subsection{Proof}
Iterating Eq.~\eqref{boris:eq:discrete_gronwall_rec} gives
\begin{align*}
a_n
&\le (1+\alpha h)^n a_0
+ \beta h^p \sum_{k=0}^{n-1}(1+\alpha h)^k,
\end{align*}
which is Eq.~\eqref{boris:eq:discrete_gronwall_sum}.
If \(\alpha>0\), then
\[
\sum_{k=0}^{n-1}(1+\alpha h)^k
= \frac{(1+\alpha h)^n-1}{\alpha h}
\le \frac{e^{\alpha nh}-1}{\alpha h}
\le \frac{e^{\alpha L}-1}{\alpha h},
\]
which proves Eq.~\eqref{boris:eq:discrete_gronwall_bound}.
If \(\alpha=0\), Eq.~\eqref{boris:eq:discrete_gronwall_sum} reduces to
\[
a_n\le a_0 + n\beta h^p \le a_0 + \beta L h^{p-1},
\]
which proves Eq.~\eqref{boris:eq:discrete_gronwall_bound_zero}. \hfill\(\Box\)

\subsection{Corollary used in the main text}
If \(a_0=0\), \(p=3\), and \(nh\le L\), then the lemma gives
\[
a_n \le C h^2,
\]
where \(C\) depends only on \(\alpha\), \(\beta\), and \(L\), but not on \(h\)
or \(n\).
