\documentclass[../main.tex]{subfiles}
\graphicspath{{\subfix{../images/}}}

\begin{document}
\section{Derivation of equations}\label{sec:appendix_b}
% Problem 1
\subsection{Equations of motion}\label{sec:eq_motion} %
First, we need to define the velocity of the particle
\begin{align*}
    \mathbf{v} \equiv \frac{d \mathbf{r}}{dt} &= \bigg( \frac{dx}{dt}, \frac{dy}{dt}, \frac{dz}{dt} \bigg).
\end{align*} %
We can rewrite the velocity as $\dot{r} = (\dot{x}, \dot{y}, \dot{z})$, and find the cross product
\begin{align*}
    q \mathbf{v} \cross \mathbf{B} &= 
    q \begin{vmatrix}
        \hat{e}_{x} & \hat{e}_{y} & \hat{e}_{z} \\
        \dot{x} & \dot{y} & \dot{z} \\
        0 & 0 & B_{0}
    \end{vmatrix}
    = q \big( B_{0} \dot{y}, -B_{0} \dot{x}, 0 \big).
\end{align*} %
We are considering an ideal Penning traps, where we define the electric potential as
\begin{align*}
    V(x, y, z) &= \frac{V_{0}}{2 d^{2}}(2z^{2} - x^{2} - y^{2}).
\end{align*} %
The relationship between the electric field $\mathbf{E}$ and the electric potential of the field is given by
\begin{align*}
    \mathbf{E} &= - \nabla V \\
    &= - \bigg( \frac{dV}{dx}, \frac{dV}{dy} \frac{dV}{dz} \bigg) \\
    &= \frac{V_{0}}{d^{2}} \big( x, y, -2z \big).
\end{align*} %
We can now express the Lorentz force as
\begin{align*}
    \mathbf{F} &= q \mathbf{E} + q \mathbf{v} \cross \mathbf{B} \\
    &= \frac{q V_{0}}{d^{2}} \big( x, y, -2z \big) + \big(q B_{0} \dot{y}, -q B_{0} \dot{x}, 0 \big),
\end{align*} %
and insert it into Newtons equation \eqref{eq:newton_second}. We get
\begin{align*}
    \ddot{\mathbf{r}} &= \bigg( \frac{q V_{0}}{m d^{2}} x, \frac{q V_{0}}{m d^{2}} y, -\frac{2 q V_{0}}{m d^{2}} z \bigg) + \bigg(\frac{q B_{0}}{m} \dot{y}, -\frac{q B_{0}}{m} \dot{x}, 0 \bigg),
\end{align*} %
which can be written as
\begin{align*}
    \ddot{x} &= \frac{q V_{0}}{m d^{2}} x + \frac{q B_{0}}{m} \dot{y}, \\
    \ddot{y} &= \frac{q V_{0}}{m d^{2}} y - \frac{q B_{0}}{m} \dot{x}, \\
    \ddot{z} &= -\frac{2 q V_{0}}{m d^{2}} z.
\end{align*}
If we define
\begin{equation*}
    \omega_{0} \equiv \frac{q B_{0}}{m}, \quad \omega_{z}^{2} \equiv \frac{2 q V_{0}}{m d^{2}},
\end{equation*}
the equations of motion can be written as
\begin{align*}
    \ddot{x} &= \frac{1}{2} \omega_{z}^{2} x + \omega_{0} \dot{y}, \\
    \ddot{y} &= \frac{1}{2} \omega_{z}^{2} y - \omega_{0} \dot{x}, \\
    \ddot{z} &= -\omega_{z}^{2} z. \\
\end{align*}

\subsection{General solution}\label{sec:eq_general}
We consider the characteristic equation of a second order differential equation \cite{lindstrom:2016:ch10:5},  
\begin{align*}
    r^{2} + \omega_{z}^{2} &= 0 \\
    r &= \pm \sqrt{- \omega_{z}^{2}}.
\end{align*} %
The characteristic equation has two complex roots
\begin{equation*}
     r_{1} = - i \omega_{z}, \quad r_{2} = i \omega_{z},
\end{equation*}
which give us solutions in the general form
\begin{equation*}
    z = c_{1} e^{i \omega_{z} t} + c_{2} e^{-i \omega_{z} t}.
\end{equation*}
In addition, for a complex number $z = a + ib$, we can define $e^{z} \equiv e^{a} (\cos{b} + i \sin{b})$ \cite{lindstrom:2016:ch3}. We can rewrite the general solution as
\begin{align*}
    c_{1} e^{i \omega_{z} t} + c_{2} e^{-i \omega_{z} t} &= c_{1} (\cos{\omega_{z} t} + i \sin{\omega_{z} t}) \\
    & \quad + c_{2} (\cos{\omega_{z} t} - i \sin{\omega_{z} t} \\
    &= E \cos{\omega_{z} t} + i F \sin{\omega_{z} t}.
\end{align*} %
%
\subsection{Complex function}\label{sec:eq_complex} %
In sec. \ref{sec:eq_motion} we found the differential equations for $\ddot{x}$ and $\ddot{y}$. To derive a single differential equation, we introduce the complex function $f(t) = x(t) + iy(t)$, which gives us
\begin{align*}
    0 &= \Big(\ddot{x} - \omega_{0} \dot{y} - \frac{1}{2} \omega_{z}^{2} x \Big) + i \Big(\ddot{y} + \omega_{0} \dot{x} - \frac{1}{2} \omega_{z}^{2} y \Big) \\
    &= \ddot{x} - \omega_{0} \dot{y} - \frac{1}{2} \omega_{z}^{2} x + i\ddot{y} + i\omega_{0} \dot{x} - i \frac{1}{2} \omega_{z}^{2} y \\
    &= \ddot{x} + i\ddot{y} + i\omega_{0} \dot{x} - \omega_{0} \dot{y} - \frac{1}{2} \omega_{z}^{2} x - i \frac{1}{2} \omega_{z}^{2} y. \\ 
\end{align*}
Using the definition $i = \sqrt{-1}$, we can rewrite 
\begin{equation*}
    i \omega_{0} \dot{x} + (-1) \omega_{0} \dot{y} = i \omega_{0} \dot{x} + i^{2} \omega_{0} \dot{y}.
\end{equation*} 
This gives us a single differential equation
\begin{align*}
    0 &= \ddot{x} + i\ddot{y} + i\omega_{0} (\dot{x} + i \dot{y}) - \frac{1}{2} \omega_{z}^{2} x - i \frac{1}{2} \omega_{z}^{2} y \\
    &= \ddot{f} + i \omega_{0} \dot{f} - \frac{1}{2} \omega_{z}^{2} f.
\end{align*}
%
\subsection{Physical coordinates}\label{sec:eq_coord}
We can rewrite eq. \eqref{eq:general_solution}, as
\begin{align*}
    f(t) &= A_{+}e^{-i(\omega_{+} t + \phi_{+})} + A_{-}e^{-i(\omega_{-} t + \phi_{-})} \\
    &= A_{+}(\cos{(\omega_{+} t + \phi_{+})} - i \sin{(\omega_{+} t + \phi_{+})}) \\
    % \numberthis \label{eq:general_solution_trig}
    & \quad + A_{-}(\cos{(\omega_{-} t + \phi_{-})} - i \sin{(\omega_{-} t + \phi_{-})}).
\end{align*} %
%
\subsection{Upper and lower bounds}\label{sec:upper_lower_bound}
To obtain the upper and lower bounds of the particle's distance from the origin, we first find an expression for the second norm (?) defined as $|f(t)| = \sqrt{(x(t))^{2} + (y(t))^{2}}$. 
\begin{align*}
    (x(t))^{2} &= \big( A_{+}\cos(\omega_{+} t + \phi_{+}) + A_{-}\cos(\omega_{-} t + \phi_{-}) \big)^{2} \\
    &= A_{+}^{2} \cos^{2}(\omega_{+} t + \phi_{+}) \\
    & \quad + 2 A_{+}A_{-} \cos(\omega_{+} t + \phi_{+})\cos(\omega_{-} t + \phi_{-}) \\
    & \quad + A_{-}^{2}\cos^{2}(\omega_{-} t + \phi_{-}), \\
\end{align*} %
\begin{align*}
    (y(t))^{2} &= \big( - A_{+} \sin(\omega_{+} t + \phi_{+}) - A_{-} \sin(\omega_{-} t + \phi_{-}) \big)^{2} \\
    &= A_{+}^{2} \sin^{2}(\omega_{+} t + \phi_{+}) \\
    & \quad + 2 A_{+}A_{-} \sin(\omega_{+} t + \phi_{+})\sin(\omega_{-} t + \phi_{-}) \\
    & \quad + A_{-}^{2} \sin^{2}(\omega_{-} t + \phi_{-}).
\end{align*} %
We insert these expressions, and find 
\begin{align*}
    |f(t)| &= \sqrt{(x(t))^{2} + (y(t))^{2}} \\
    &= \sqrt{A_{+}^{2} + 2 A_{+} A_{-} \cos^{2}(\alpha) + A_{-}^{2}},
\end{align*} %
where $\alpha = (\omega_{+} - \omega_{-}) t +( \phi_{+} -  \phi_{-})$. If we set $\alpha = 0$ we get $\cos(0) = 1$, and obtain the upper bound
\begin{align*}
    R_{+} &= \sqrt{A_{+}^{2} + 2 A_{+} A_{-} + A_{-}^{2}} \\
    &= \sqrt{(A_{+} + A_{-})^{2}} \\
    &= A_{+} + A_{-}.
\end{align*}
If $\alpha = \pi$ we get $\cos(\pi) = -1$, and find the lower bound
\begin{align*}
    R_{-} &= \sqrt{A_{+}^{2} - 2 A_{+} A_{-} + A_{-}^{2}} \\
    &= \sqrt{(A_{+} - A_{-})^{2}} \\
    &= |A_{+} - A_{-}|.
\end{align*} %
%
\subsection{Bounded solution}\label{sec:bounded_solution}


\end{document}

% \begin{align*}
%     \omega_{+} - \omega_{-} &= \frac{\omega_{0} + \sqrt{\omega_{0}^{2} - 2 \omega_{z}^{2}}}{2} - \frac{\omega_{0} - \sqrt{\omega_{0}^{2} - 2 \omega_{z}^{2}}}{2} \\
%     &= 
% \end{align*}