\section*{Numerical evaluation of Efield and pitch contributions to $\omega_a$}
In smulation $\omega_a$ is most directly determined by spin tracking. The trajectory of the muon is established by numerically integrating
the equations of motion, and the spin by integration of the BMT equation along that trajectory. We would like to explore the contribution 
to $\omega_a$ due the
electric field of the quads and the vertical pitching (vertical betatron motion). Spin tracking includes both effects. 
But spin tracking is inconvenient for at least 3 reasons
\begin{enumerate}
\item Integration of the BMT equation is computationally intensive (and slow).
\item The change in $\omega_a$ due to the electric field and the pitch is of order 1 part in $10^7$. Extracting their contribution depends
on the difference of large numbers, and subject to error.
\item There is no simple way to distinguish contributions from Efield, and pitch, and whatever else.
\end{enumerate}
As an alternative to spin tracking, we revisit the expressions for the contributions to Efield and pitch and proceed as follows.
\subsection*{Electric field contribution}
Recall that electric field appears as
\begin{equation}
\vec{\omega_a}=-\frac{q}{m}\left[a_\mu \vec B\left(a_\mu-\frac{m^2}{p^2}\right)\frac{\vec\beta\times\vec E}{c}\right]\label{eq:intb}
\end{equation} 
Define
$\phi_a = \int_0^T\omega_a dt$. In the absence of $\vec E$, we compute $\phi_a$ by integrating $\vec B_\perp$ along the muon trajectory.
Evidently, the contribution from the the electric field to $\phi_a$ is given by
\begin{equation}
\frac{\Delta \phi_E}{\phi_a} = \left(a_\mu-\frac{m^2}{p^2}\right)\frac{1}{c}\int_0^T\vec\beta\times\vec E dt
\approx -2\frac{\Delta p}{p}\frac{1}{c}\int_0^T\vec\beta\times\vec E dt\label{eq:inte}
\end{equation}
where $\Delta p = p-p_{magic}$.
In the tracking code it is straightforward to compute the sums in Equations ~\ref{eq:intb} and ~\ref{eq:inte}.
Then the efield correction for the trajectory is
\begin{equation}
C_e(T) = -2\frac{\Delta p}{p}\frac{1}{T}\int^T\frac{\vec\beta\times\vec E}{Bc} dt
\end{equation}
(We assume that $\vec B$ is parallel to $\vec\beta\times \vec E$.)
\subsection*{Pitch}
Consider the trajectory shown in ~\ref{fg:pitchpicture} of a muon executing betatron oscillations in the vertical plane. The pitching angle
is $\psi_0$. The magnetic field is in the vertical direction and $y_0$ is the associated vertical displacement. We are interested in the 
precession of the spin with respect to the muon momentum and therefore its projection onto the plane that contains the velocity 
and $\vec \beta\times \vec B$. The component of the magnetic field along the perpendicular to the plane is $B_\perp=B\cos\psi$.
The spin tune, that is the advance of the spin phase per turn is then
\begin{equation}
\nu_{spin}=\oint B_\perp dl = \oint B\cos\psi dl
\end{equation}
where the integration is through a single turn.
The path length of the pitching trajectory is 
\begin{equation}
\oint \sqrt{dx^2 + dy^2} =\oint \sqrt{1+\left(\frac{dy}{dx}\right)^2}dx \sim\oint 1+\frac{1}{2}\psi_0^2\sin\left(\frac{2\pi\nu_y}{L}\right)^2) = L(1+\frac{1}{4}\psi_0^2)
\end{equation}
The pathlength increases with the square of the pitching angle. Therefore the spin tune is independent of the pitching angle.
On the other hand, the cyclotron frequency decreases with pitching angle according to  $\omega_c(\psi_0) \sim \omega_c(0)(1-\frac{1}{4}\psi^2)$ and
then $$\omega_a (\psi_0)=\omega_a(0)(1-\frac{1}{4}\psi_0^2)$$
\begin{figure}[tb]
 \begin{center}
    \includegraphics*[width=0.8\textwidth,angle=0, trim= 0 0 0 0, clip=.true.]{figures/pitchpicture.pdf}
\caption{pitching trajectory}
 \label{fg:pitchpicture}
 \end{center}
 \end{figure}

Then
%\frac{\Delta \phi_p}{\phi_a} = \frac{1}{T} \int^T(\vec \beta\cdot\vec B)\vec\beta dt\\
\begin{equation}
\frac{\Delta \phi_p}{\phi_a} = \frac{1}{T} \int^T(|B|-|\hat\beta\times B|) dt
\end{equation}
\subsection{Efield - Equivalence of spin tracking and integration of $\phi_a$.}
\begin{figure}[tb]
 \begin{center}
    \includegraphics*[width=0.8\textwidth,angle=0, trim= 0 0 0 0, clip=.true.]{figures/efield-spin_track_vs_int.pdf}
\caption{Spin tracking and integration}
 \label{fg:spintrackint}
 \end{center}
 \end{figure}
\begin{figure}[tb]
 \begin{center}
    \includegraphics*[width=0.8\textwidth,angle=0, trim= 0 0 0 0, clip=.true.]{figures/efield-spintrack-int-lin.pdf}
\caption{Spin tracking, integration, linear}
 \label{fg:spintrackintlin}
 \end{center}
 \end{figure}
\begin{figure}[tb]
 \begin{center}
    \includegraphics*[width=0.8\textwidth,angle=0, trim= 0 0 0 0, clip=.true.]{figures/efield-convolve.pdf}
\caption{Spin tracking and integration and convolve}
 \label{fg:spintrackingintconvolve}
 \end{center}
 \end{figure}


\subsection{Pitch - Equivalence of spin tracking and integration of $\phi_a$.}
\begin{figure}[tb]
 \begin{center}
    \includegraphics*[width=0.8\textwidth,angle=0, trim= 0 0 0 0, clip=.true.]{figures/pitch-spin_track_vs_int.pdf}
\caption{Spin tracking and integration}
 \label{fg:spintrackint}
 \end{center}
 \end{figure}
\begin{figure}[tb]
 \begin{center}
    \includegraphics*[width=0.8\textwidth,angle=0, trim= 0 0 0 0, clip=.true.]{figures/pitch-spintrack-int-lin.pdf}
\caption{Spin tracking, integration, linear}
 \label{fg:spintrackintlin}
 \end{center}
 \end{figure}


\subsection{Misalignment and Voltage errors}
\begin{figure}[tb]
 \begin{center}
    \includegraphics*[width=0.45\textwidth,angle=0, trim= 0 0 0 0, clip=.true.]{figures/efield-4mmerror.pdf}
    \includegraphics*[width=0.45\textwidth,angle=0, trim= 0 0 0 0, clip=.true.]{figures/efield-4mmerror-closedorbit.pdf}
\caption{E-field alignment error}
 \label{fg:efield-4mmerror}
 \end{center}
 \end{figure}
\begin{figure}[tb]
 \begin{center}
    \includegraphics*[width=0.45\textwidth,angle=0, trim= 0 0 0 0, clip=.true.]{figures/pitch-quadplatevoltageerror.pdf}
    \includegraphics*[width=0.45\textwidth,angle=0, trim= 0 0 0 0, clip=.true.]{figures/pitch_quadplatevoltageerror_closed_orbit.pdf}
\caption{pitch alignment error}
 \label{fg:pitchvoltageerror}
 \end{center}
 \end{figure}


