\section{Pitching Velocity}
\label{ap:pitchvelocity}
\subsection{Equations of Motion}
The equation of motion for a muon in the electromagnetic fields in the g-2 ring is reproduced here.
\begin{equation}
\frac{d\bm\beta}{dt}=\frac{e}{\gamma m c}[\bfE + \bm\beta\times\bfB - \bm\beta(\bm\beta\cdot\bfE)]\\
\end{equation}
Let's try to find the solution for the simple case of a straight channel (no magnetic field) with continuous focusing vertically focuelectrostatic quadrupole.
We will use a fixed cartesian coordinate system where x-horizontal, y-longitudinal (along the axis of the quad) and z-vertical.
The electric field is given by $E_z = kz$. The EOM become
\begin{eqnarray}
\frac{d\beta_z}{dt}&=&\frac{e}{\gamma m c}[E_z - \beta_z(\beta_z E_z]\nonumber\\
&=&\frac{ek}{\gamma m c}z(1 - \beta_z^2)\label{eq:betazeom}\\
\frac{d\beta_y}{dt}&=&-\frac{e}{\gamma m c}\beta_y(\beta_z E_z)\nonumber\\
&=&-\frac{ek}{\gamma m c}z\beta_y\beta_z \label{eq:betayeom}
\end{eqnarray}
Since $\beta_z = \frac{1}{c}\frac{d z}{dt}$ and in the limit where $\beta_z\ll 1$ and where we ignore the time dependence of $\gamma$
the zeroth order solution to ~\ref{eq:betazeom} is
\begin{eqnarray*}
z&=&z_0\cos\omega_p t\\
\beta_z&=& -\frac{z_0\omega_p}{c}\sin\omega_p t = -\psi_0\sin\omega_p t
\end{eqnarray*}
 where $\omega_p^2 = -\frac{ek}{\gamma m}$ and $\psi_0 = \frac{z_0\omega_p}{c}$. 
The correction will be of order $\psi_0^3$.
\begin{comment}

A more general solution might include higher harmonics. Let's try something of the form
\begin{equation}
z = z_0\cos\alpha t + b\cos 3\alpha t+\ldots\label{eq:trial}
\end{equation}
where $b$ and $\alpha$ are to be determined.
We include only odd harmonics in order to preserve the odd symmetry of the solution. Substituting~\ref{eq:trial} into ~\ref{eq:betazeom}
\begin{eqnarray*}
-\frac{1}{c}\alpha^2(z_0\cos\alpha t + 9b\cos 3\alpha t) &=& -\frac{\omega_p^2}{c}(z_0\cos\alpha t + b\cos 3\alpha t)(1-\frac{\alpha^2}{c^2}(z^2_0\sin^2\alpha t + 9b^2\sin^2 3\alpha t+
(6z_0b\sin\alpha t \sin 3\alpha t))\\
\end{eqnarray*}
Next we want to equate coefficients of $\cos\alpha t$ on left and right, then coefficients of $\cos 3\alpha t$ etc. To that end expand the right hand side
We have to rewrite each of the six terms in terms of $\cos(n\alpha t)$
\begin{eqnarray*}
\cos\alpha t \sin^2\alpha t &=& -\frac{1}{8}(e^{i\alpha t}+e^{-i\alpha t})(e^{2i\alpha t}+e^{-2i\alpha t} - 2)\\
&=& -\frac{1}{4}(\cos 3\alpha t + \cos\alpha t - 2\cos\alpha t) = -\frac{1}{4}(\cos 3\alpha t - \cos\alpha t)\\
\cos\alpha t \sin^23\alpha t &=& -\frac{1}{8}(e^{i\alpha t}+e^{-i\alpha t})(e^{6i\alpha t}+e^{-6i\alpha t} - 2)\\
&=& -\frac{1}{4}(\cos 7\alpha t + \cos 5\alpha t -2\cos\alpha t)\\
\cos\alpha t \sin\alpha t\sin 3\alpha t &=& -\frac{1}{8}(e^{i\alpha t}+e^{-i\alpha t})(e^{i\alpha t}-e^{-i\alpha t})(e^{3i\alpha t}-e^{-3i\alpha t})\\
&=& -\frac{1}{8}(e^{2i\alpha t}-e^{-2i\alpha t})(e^{3i\alpha t}-e^{-3i\alpha t})\\
&=& -\frac{1}{8}(e^{5i\alpha t}+e^{-5i\alpha t} - e^{i\alpha t}-e^{-i\alpha t})\\
&=&-\frac{1}{4}(\cos 5\alpha t - \cos\alpha t)\\
\cos 3\alpha t \sin^2\alpha t&=& -\frac{1}{8}(e^{3i\alpha }+e^{-3i\alpha t})(e^{2i\alpha t}+e^{-2i\alpha t}-2)\\
&=& -\frac{1}{8}(e^{5i\alpha t }+e^{-5i\alpha t}+e^{i\alpha t}+e^{-i\alpha t}-2(e^{3i\alpha t}+e^{-3i\alpha t}))\\
&=& -\frac{1}{4}(\cos{5\alpha t }+\cos{\alpha t}-2\cos{3\alpha t})\\
\cos 3\alpha t\sin^2 3\alpha t&=& -\frac{1}{8}(e^{3i\alpha }+e^{-3i\alpha t})(e^{6i\alpha t}+e^{-6i\alpha t}-2)\\
&=& -\frac{1}{8}(e^{9i\alpha t}+e^{-9i\alpha t} + e^{3i\alpha t}+e^{-3i\alpha t}-2(e^{3i\alpha t}+e^{-3i\alpha t}))\\
&=& -\frac{1}{4}(\cos{9\alpha t }+ \cos{3\alpha t}-2\cos{3\alpha t}) = -\frac{1}{4}(\cos{9\alpha t }-\cos{3\alpha t})\\
\cos 3\alpha t\sin \alpha\sin 3\alpha t&=& -\frac{1}{8}(e^{3i\alpha }+e^{-3i\alpha t})(e^{3i\alpha t}-e^{-3i\alpha t})(e^{i\alpha t}-e^{-i\alpha t})\\
&=& -\frac{1}{8}(e^{6i\alpha t }-e^{-6i\alpha t})(e^{i\alpha t}-e^{-i\alpha t})\\
&=& -\frac{1}{8}(e^{7i\alpha  t}+e^{-7i\alpha t} + e^{5i\alpha t}+e^{-5i\alpha t})\\
&=& -\frac{1}{4}(\cos{7\alpha t}+\cos{5\alpha t})
\end{eqnarray*}
Equating coefficients on left and right of $\cos\alpha t$
\begin{eqnarray*}
-\frac{1}{c}\alpha^2 z_0 &=& -\frac{\omega_p^2}{c}(z_0 -\frac{\alpha^2 z_0^3}{4c^2}-\frac{9 z_0b^2\alpha^2}{2c^2} -\frac{6z_0^2 b\alpha^2}{4c^2} +\frac{b z_0^2\alpha^2}{4c^2})\\
\omega_p^2z_0 &=&\alpha^2 z_0(1-\frac{\omega_p^2}{c^2}(\frac{z_0^2}{4}-\frac{9 b^2}{2} - \frac{5bz_0}{4}))\sim \alpha^2 z_0(1-\frac{\omega_p^2z_0^2}{4c^2})\\  
\omega_p^2 &=&\alpha^2 (1-\frac{\omega_p^2}{c^2}(\frac{z_0^2}{4}-\frac{9 b^2}{2} - \frac{5bz_0}{4}))\\  
\rightarrow \alpha^2 &=& \frac{\omega_p^2}{1+\frac{\omega_p^2}{c^2}(z_0^2/4c^2+9b^2/2c^2+5z_0b/4c^2)}
\end{eqnarray*} 
Equating coefficients of $\cos 3\alpha t$
\begin{eqnarray*}
-9b\alpha^2&=&-\omega_p^2(\frac{\alpha^2 z_0^3}{4 c^2} + b -\frac{\alpha^2 b z_0^2}{2c^2}-\frac{9\alpha^2b^3}{4c^2}  )\\
\omega_p^2 b&=& \alpha^2(\frac{\omega_p^2}{c^2}(\frac{z_0^3}{4}-\frac{bz_0^2}{2}- \frac{9b^3}{4}) +9b)\sim \alpha^2(\frac{\omega_p^2 z_0^2}{4c^2}z_0 + 9b)\\
\alpha^2&=& \frac{\omega_p^2 b}{\frac{\omega_p^2}{c^2}(\frac{\alpha^2 z_0^3}{4} + b -\frac{\alpha^2 b z_0^2}{2}-\frac{9\alpha^2b^3}{4}  )+9b}\\
\end{eqnarray*}
Combining
\begin{eqnarray*}
 b(1-\frac{\omega_p^2}{c^2}(\frac{z_0^2}{4}-\frac{9 b^2}{2} - \frac{5bz_0}{4})) &=& (\frac{\omega_p^2}{c^2}(\frac{z_0^3}{4}-\frac{bz_0^2}{2}- \frac{9b^3}{4}) +9b))\\
0&=&-8b -\frac{\omega_p^2}{c^2}(\frac{9b^3}{4}-\frac{bz_0^2}{4}-\frac{z_0^3}{4})\\
0&=&-8b -\psi_0^2(\frac{9b^3}{4z_0^2}-\frac{b}{4}-\frac{z_0}{4})\\
\rightarrow b&\sim&\psi_0^2 \frac{z_0}{32}
\end{eqnarray*}
Or keeping only leading order in $b$,
\begin{eqnarray*}
b \sim \frac{(\frac{1}{4}\psi_0^2 z_0 +9b)}{(1-\frac{1}{4}\psi_0^2)}\\
\rightarrow b\sim \frac{1}{8}\psi_0^2 z_0
\end{eqnarray*}
where $\psi_0 = \frac{\omega_p z_0}{c}$.
Putting the pieces together,
\begin{eqnarray*}
z&\sim& z_0(\cos\alpha t + \frac{1}{32}\psi_0^2\cos 3\alpha t)\\
\beta_z&=&-\psi_0(\sin\alpha t +\frac{3}{32}\psi_0^2\sin 3\alpha t)\\
\beta_z&=&-\psi_0((1+\frac{9}{32}\psi_0^2)\sin\alpha t -\frac{3}{8}\psi_0^2\sin^3\alpha t)\\
\end{eqnarray*}
where we use $\sin 3\theta=-4\sin^3\theta+3\sin\theta$.

\end{comment}  
Next substitute our solution for $\beta_z$ into ~\ref{eq:betayeom} and rearrange to get
\begin{eqnarray*}
\int \frac{d\beta_y}{\beta_y}&=&-\int \frac{ek}{\gamma m c}z_0\cos\omega_p t\left(\psi_0\sin\omega_p t +\ldots\right) dt\\
\ln \beta_y &=& -\omega_p\frac{z_0}{c}\psi_0\onehalf\sin^2\omega_p t +\ldots\\
\rightarrow\beta_y&=& \exp\left(-\psi^2_0\onehalf\sin^2\omega_p t +\ldots\right)\\
&\sim & 1-\onehalf \psi^2_0\sin^2\omega_pt\\
&\sim & \cos(\psi_0\sin\omega_p t)
\end{eqnarray*}
\subsection{Pitching Velocity Revisited}
The muons oscillate vertically in the electric field of the quadrupoles. In the continuous quad approximation the time dependence of the pitch angle is
$$\psi(t) = \psi_0\cos(\omega_p t)$$ where $\omega_p$ is the vertical betatron frequency. 
 The momentum $p_\phi$ in the azimuthal direction is constant, that is,  independent of the pitch angle $\psi$.
The force on the muons due to the electric field of the quadrupoles is in the vertical direction.
The pitch angle is related to momenta according to $p_z/ p_\phi= \tan\psi$. Since the muon gains and loses energy
to the electric field of the quadrupoles, the magnitude of the energy and the velocity vector ${\bm \beta}$ will, like the z-component of the  momentum,  be time dependent.  
We can write the azimuthal and vertical components of the velocity as
\begin{eqnarray*}
\beta_\phi &=& \frac{p_\phi}{E}\\
\beta_z &=& \frac{p_z}{E}
\end{eqnarray*}
Then
\begin{eqnarray}
\bmbetahat_\phi &=& \frac{\beta_\phi}{[\beta_\phi^2+\beta_z^2]^\onehalf}\nonumber\\
&=& \frac{p_\phi/E}{[p_\phi^2/E^2+p_z^2/E^2]^\onehalf}\nonumber\\
&=& \frac{p_\phi}{p_\phi[1+p_z^2/p_\phi^2]^\onehalf}\nonumber\\
&\sim& (1-\onehalf\frac{p_z^2}{p_\phi^2}) = 1-\onehalf\tan^2\psi \label{eq:betaphi}
\end{eqnarray}
Also
\begin{eqnarray}
\bmbetahat_z &=& \frac{\beta_z}{[\beta_\phi^2+\beta_z^2]^\onehalf}\nonumber\\
&=& \frac{p_z/E}{[p_\phi^2/E^2+p_z^2/E^2]^\onehalf}\nonumber\\
&=& \frac{p_z}{p_\phi[1+p_z^2/p_\phi^2]^\onehalf}\nonumber\\
&\sim& \frac{p_z}{p_\phi}(1-\onehalf\frac{p_z^2}{p_\phi^2}) = \tan\psi(1-\onehalf\tan^2\psi)\label{eq:betaz}
\end{eqnarray}
We might use this more precise form for $\bmbetahat$ in Equation~\ref{eq:integrate} (rather than what is given in Equation~\ref{eq:beta}).
However, to order $\psi^2$ the result is the same.
That is $$\bmbetahat_\phi = 1-\onehalf\tan^2\psi \sim 1-\onehalf\psi^2 \sim \cos\psi$$
and
$$\bmbetahat_z = \tan\psi(1-\onehalf\tan^2\psi) \sim  \sin\psi$$
Recall that $\bmbetahat$ appears in the integral in the cross product with $\bfB$ and $\bfB = B\hat\bfz$.
\begin{eqnarray*}
\bmbetahat\times\bfB &=& \bmbetahat_\phi B\\
&\sim & B(1-\onehalf\tan^2\psi)\sim B(1-\onehalf\psi^2)
\end{eqnarray*}
Since $$\cos\psi\sim 1-\onehalf\psi^2,$$  
to order $\psi^2$, $|\bmbetahat\times\bfB| \sim\cos\psi$, and consistent with the approximations used throughout.
That is because $\cos\psi \sim 1-\onehalf\tan^2\psi$ for small $\psi$.
The near equivalence is evident in a comparsion (see Fig~\ref{fig:velocity}) of $\bmbeta$ derived from integration of the equations of motion and the formula used above, namely
\begin{eqnarray}
\bmbetahat &=& \cos(\psi(t))\bmhp+\sin(\psi(t)){\hat\bfz}\nonumber\\
&=& \cos(\psi_0\cos\omega_p t)\bmhp+\sin(\psi_0\cos(\omega_p t)){\hat\bfz}\label{eq:betaagain}
\end{eqnarray}
\begin{figure}[h]
\centering
\includegraphics{velocity_vector_z.pdf}
\includegraphics{velocity_vector_f.pdf}
\caption{$\beta_z$ (top) and $\beta_\phi$ (bottom) are determined by integration of the equations of motion through a model of the g-2 ring with discrete quadrupoles and equivalent field index $n=0.1058$. The initial
coordinates of the trajectory are on the magic orbit ($\rho = 7.112$ m, $z=0$) and pitch angle $\psi = 0.002$). Equation~\ref{eq:betaagain} is in good agreement with the 'exact' result.}
\label{fig:velocity}
\end{figure}
   
Note that if the focusing were magnetic rather than electric,  the total momentum would be constant and independent of pitch, in which case 
\begin{eqnarray*}
p_\phi^2+p_z^2 &=& p^2 \\ 
p_\phi^2/p^2+p_z^2/p^2 &=& 1 \\ 
\rightarrow (\beta_\phi/\beta)^2+(\beta_z/\beta)^2 &=& 1\\
= \cos^2\psi +\sin^2\psi
\end{eqnarray*}
But we see that
for $\psi \ll 1$ the time dependence of $\bmbetahat$ is the same for electric and magnetic focusing.
(Note also that the second order dependence of azimuthal momentum on pitch angle is typically ignored in the first order solution of the equations of motion for the weak focusing storage ring. )
