% !TEX TS-program = pdflatexmk

%\documentclass[12pt]{amsart}
\documentclass[prbg,preprint]{revtex4-1}
%Manuscripts that demonstrate new relations between apparently unrelated areas of physics are appropriate.
\usepackage{geometry} % see geometry.pdf on how to lay out the page. There's lots.
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{bm}
%\usepackage{subfig}
\usepackage{mathtools}
\usepackage{svg}
%\usepackage{authblk}
\geometry{a4paper} % or letter or a5paper or ... etc
\newcommand{\cvec}[1]{{\rm{\bf{#1}}}}
% \geometry{landscape} % rotated page geometry

% See the ``Article customise'' template for come common customisations

%\date{} % delete this line to display the current date

%%% BEGIN DOCUMENT
\begin{document}

\title{Dynamics of Two Freely Rotating Dipoles}
\author{Peter T. Haugen}
\author{Boyd F. Edwards}
\affiliation{Utah State University}

\maketitle
%05/07 get dipole_driving web page listed in project
\section{Abstract}
	The equations of motion for two spherical dipoles moving freely in a plane are obtained. Special consideration is given to when the two spheres are in contact. Investigations of equilibria, small amplitude motion, and large amplitude motion reveal that possible motions are exclusively quasi-periodic.
	Two distinct modes are identified, one of which is isomorphic with the simple pendulum complete with continual spinning at high energy.

%Increasing the degrees of freedom of a simpler system we find the equations of motion for two spherical dipoles and discover more predictable motion rather than less. The equilibria are found and distinct modes of motion are described. One mode is shown to be equivalent to the simple pendulum including continual spinning at high energy.

\section{Introduction}

In looking at a pair of unrestrained magnetized spheres we've taken a simpler system and increased its degrees of freedom.
While it's common to maintain the same level of complexity of the motion or increase it, here we find that making the phase space more complex decreases the complexity of the motion.

Examining the interactions between rotating magnets has interesting applications when we consider how magnetic gears \cite{doi:10.1119/1.5029823} are being used in engineering contexts where friction or operational life span are the dominant considerations \cite{Modaresahmadi:2019aa}.
Magnetic gears are appealing as you can transmit rotational motion without the teeth that experience wear and tear.
This can be achieved with magnetic components, as a small rotation in one element will prompt a rotation in nearby elements to maintain a minimal energy state.

Several simple cases have been examined analytically.
Pollack \cite{doi:10.1139/p96-151} has investigated interactions between point dipoles fixed in space but which are free to rotate, and finds quasi periodic motion.
Edwards et al.\ has taken advantage of some work that shows magnetized spheres experience magnetic fields as though those spheres were point dipoles \cite{Edwards:2017aa} to discover how one sphere freely sliding around on the surface of another sphere that is fixed in space and orientation leads to chaotic motion \cite{Edwards:2017ab}.
Fixing one sphere breaks the symmetry in space equivalent to an external torque and prevents conserved total angular momentum from arising.

We take a union of the Pollack and Edwards systems by allowing both spheres to freely rotate and slide along each other.
While each of these systems has two degrees of freedom, they are different pairs chosen from the more general case and thus not immediately comparable.
Our combined system has three degrees of freedom.
%making it distinctly more complicated than either of the earlier two.
While Edwards' system exhibited chaos, this new system does not, even at large amplitudes.

Numerical methods have been developed for arbitrarily complicated arrangements \cite{Furlani:1995aa} and by examining this simple case analytically we can provide an additional check on their results.
As this is a system where magnetic interactions and fields dominate, it can make accounting for all the forces a point of contention
\cite{Boyer:1988aa, Vaidman:1990aa, Griffiths:1992aa, Brownstein:1993aa, Hnizdo:1997aa}
.
However, there is little disagreement on the energy for a dipole in a magnetic field \cite{Greene:1971aa, Griffiths:1992aa}.
Starting from the potential and kinetic energies of the sphere and using the Hamiltonian approach we find equations of motion and conserved quantities.
This makes examining the dynamics of these two spheres an excellent pedagogical opportunity for using the Hamiltonian approach.

\begin{figure}[h]
  \centering
  \includegraphics[width=.85\linewidth]{./images/coordinates_scalable_2.pdf}
  \caption{Schematic of labeling system describing two spheres in the plane featuring both the independent coordinates and the center of mass coordinates.}
\end{figure}

\section{Describing the System}
Intrinsic properties of the two dipoles are: their respective radii, which we shall label as $a_1$ and $a_2$, their masses, $m_1$ and $m_2$, and magnitudes of their dipole moments, $\mu_1$ and $\mu_2$.
\subsection{Coordinates}
\subsubsection{Cartesian}

Each of the dipoles has a location constrained to the x-y plane $\cvec{r_1}$ and $\cvec r_2$ along with an orientation for the dipole $\phi_1$ and $\phi_2$ which we will also constrain to the x-y plane, measured from the x-axis.
\subsubsection{Center Of Mass}
We can define a set of composite coordinates and quantities more appropriate for analyzing two-body system using the aforementioned independent coordinates following Taylor's approach \cite{taylor2005classical}.

These composite coordinates are as follows: the total and reduced mass,

\begin{equation}
m_t = m_1+m_2,
\qquad
m_r = \frac{m_1m_2}{m_1+m_2},
\end{equation}

the center of mass,
\begin{equation}
\cvec{R} = \frac{m_1 \cvec{r}_1+m_2 \cvec{r}_2}{m_t},
% R = \frac{m_1  r_1+m_2 r_2}{m_t},
\end{equation}

and the displacement of dipole 2 from dipole 1,
\begin{equation}
\cvec{r}
=  \cvec r_2-\cvec r_1
= \textrm{r} [\cos(\theta) \hat {\cvec x}+\sin(\theta) \hat {\cvec y}].
\end{equation}

\subsection{Hamiltonian}
To take advantage of the numerous analytic techniques that can be applied to a system's Hamiltonian, it must first be calculated. Which in turn requires that we find its kinetic and potential energy in terms of its coordinates.
\subsubsection{Energies}
The kinetic energy, $T$, is \cite{taylor2005classical}
%citing taylor mechanics for the reduced kinetic
\begin{equation}
	\begin{multlined}
            T =
            \frac{1}{2}(
            	m_1 \dot {\cvec{r}_1}^2
            	+m_2 \dot {\cvec{r}_2}^2
            	+ I_1 \dot \phi_1^2
            	+ I_2 \dot \phi_2^2
            )
            \\
            =\frac{1}{2}(
            	m_t \dot R^2
            	+m_r \dot r^2
            	+m_r r^2 \dot \theta^2
            	+ I_1 \dot \phi_1^2
            	+ I_2 \dot \phi_2^2
).
  \end{multlined}
\end{equation}
%BFE:rederive kinetic energy
%PTH: or cite taylor's result have done the derivation before but this paper is already a bit long of tooth and we want to get to the novelty sooner rather than later
The first three terms in the second equation are for two bodies in center of mass coordinates with the final two terms accounting for the internal degrees of freedom of the spheres.
%cite prior edwards work for energy interaction here

The potential energy for dipole 1 is the dot product of its dipole moment with the local field \cite{Edwards:2017aa}, which in this case is caused entirely by dipole 2.
\begin{equation}
U_1 = -\boldsymbol \mu_1 \cdot \cvec B_2.
\end{equation}

The magnetic field for a dipole at some point of interest $\cvec r_i$ being taken from \cite{griffiths2013introduction}

\begin{equation}
\cvec B_2 =
\frac{\mu_0}{4\pi}\left[
	3\frac{\boldsymbol \mu_2 \cdot (\cvec r_i - \cvec r_2)}{|\cvec r_i - \cvec r_2|^5}(
	\cvec r_i - \cvec r_2
	)
	-\frac{\boldsymbol \mu_2}{|\cvec r_i - \cvec r_2|^3}
\right].
\end{equation}

Using our definition for $\cvec r$ we can simplify the potential energy to

\begin{equation}
U_1 =
\frac{\mu_0}{4\pi}
\frac{1}{r^3}\left[
	\boldsymbol \mu_1 \cdot \boldsymbol \mu_2
	-3(
		\boldsymbol \mu_2 \cdot \hat {\cvec r}
		)(
		\boldsymbol \mu_1 \cdot \hat {\cvec r}
		)
\right].
\end{equation}

The $\boldsymbol \mu_1 \cdot \boldsymbol \mu_2$ term accounts
for the direct contribution of the relative orientation of the two dipole moments on $U$,
%for the direct relation of the two dipoles' relative orientation have with $U$,
and the $\boldsymbol \mu_i \cdot \hat {\cvec r}$ term accounts for the impact on $U$ due to the orientation of their dipole moments relative to their spatial position.
This is symmetric under substitution of 1 for 2 and vice versa so we have a total interaction potential of

\begin{equation}
U =
U_1+U_2
=
2U_1.
\end{equation}

This potential when expanding the dot products out in terms of all three respective angles leaves us with

\begin{equation}
  \begin{multlined}
\hat {\boldsymbol \mu_i} =  \cos \phi_i \hat {\cvec x} + \sin \phi_i \hat {\cvec y}
\\
\hat {\cvec r} =  \cos \theta \hat {\cvec x} + \sin \theta \hat {\cvec y}
\\
U(\phi_1, \phi_2, \theta, r) =
-\frac{\mu_0}{4\pi}
\frac{\mu_1 \mu_2}{2}
\frac{1}{r^3}\left[
	\cos(\phi_1-\phi_2)
	+3\cos(\phi_1+\phi_2 -2\theta)
\right].
  \end{multlined}
\end{equation}

Having an expression for kinetic and potential energy, the Lagrangian is
%good place to talk about why we're neglecting radiation losses in stump_damping
\begin{equation}
  \begin{multlined}
    L=T-U=
    \frac{1}{2}(
        m_t \dot R^2
        +m_r \dot r^2
        +m_r r^2 \dot \theta^2
        + I_1 \dot \phi_1^2
        + I_2 \dot \phi_2^2
    )
    \\
    +
    \frac{\mu_0}{4\pi}
    \frac{\mu_1 \mu_2}{2}
    \frac{1}{r^3}
%    \left[
    [
        \cos(\phi_1-\phi_2)
        +3\cos(\phi_1+\phi_2 -2\theta)
%    \right]
    ].
  \end{multlined}
\end{equation}

It might be noted that this Lagrangian takes into account only magnetostatic interactions which ignores the resulting damping one would see from accelerating dipoles which would necessarily happen anytime the system is away from equilibrium. The scale of those corrections will be addressed in  later section.
%section labeling
\subsubsection{Momenta}

The first observation we make is that the Lagrangian is independent of the center of mass position making the corresponding momenta a constant of motion and we will proceed assuming we are in the inertial frame where it is 0 and R is 0. Determining the other momenta we use the relationship $\partial_{\dot q_i} L =p_i$ to arrive at

\begin{subequations}
    \begin{equation}
        \partial_{\dot \phi_1} L = I_1\dot \phi_1 = p_{\phi_1},
    \end{equation}
    \begin{equation}
        \partial_{\dot \phi_2} L =I_2\dot \phi_2 = p_{\phi_2},
    \end{equation}
    \begin{equation}
        \partial_{\dot \theta} L =m_r r^2 \dot \theta = p_{\theta},
    \end{equation}
    \begin{equation}
        \partial_{\dot r} L = m_r \dot r = p_r.
    \end{equation}
\end{subequations}

Allowing us to find the Hamiltonian with the expression of

\begin{equation}
H=\Sigma_i p_i \dot q_i - L
=
\frac{1}{2}\left(
	\frac{p_r^2}{m_r}
	+\frac{p_\theta^2}{m_r r^2}
	+\frac{p_{\phi_1}^2}{I_1}
	+\frac{p_{\phi_2}^2}{I_2}
\right)+U(\phi_1,\phi_2,\theta, r).
\end{equation}
\subsection{Dimensionless coordinates}
To get at the essentials of the system we will examine it in a natural set of dimensions. First we will characterize the second dipole in terms of the first such that
$m_2=\alpha m_1$,
$a_2=\beta a_1$,
$\mu_2=\gamma \mu_1$. This lets us rewrite the energies as
%I = 2/5 mr^2
\begin{subequations}
    \begin{equation}
        T=\frac{1}{2}\left [
	\frac{(1+\alpha)m_1}{\alpha m_1^2} p_r^2
	+\frac{(1+\alpha)m_1}{\alpha m_1^2} \frac{p_\theta^2}{r^2}
	+p_{\phi_1}^2 \frac{5}{2m_1a_1^2}
	+p_{\phi_2}^2 \frac{1}{\alpha\beta^2} \frac{5}{2m_1a_1^2}
        \right ],
    \end{equation}
    \begin{equation}
        U=
	    -\frac{\mu_0}{4\pi}
	    \frac{\gamma \mu_1^2}{2}
	    \frac{1}{r^3}[
	        \cos(\phi_1-\phi_2)
	        +3\cos(\phi_1+\phi_2 -2\theta)
	    ].
    \end{equation}
\end{subequations}

We go on to define our units as follows:
$L_0=2a_1$ for length,
$\mu_1$ for magnetic moment,
$F_0=3\mu_0 \mu_1^2/(2\pi L_0^4)$ for force,
$F_0L_0$ for energy,
$T_0=\sqrt{m_1L_0/F_0}$ for time,
$T_0^{-1},T_0^{-2}$ for angular velocities and accelerations,
$m_1L_0/T_0$ for linear momentum and
$m_1L_0^2/T_0$ for angular momentum. This lets us rewrite the energies as

\begin{subequations}\label{gen_ham}
    \begin{equation}
        T=\frac{1}{2}\left [
	\frac{(1+\alpha)}{\alpha } p_r^2
	+\frac{(1+\alpha)}{\alpha } \frac{p_\theta^2}{r^2}
	+10 p_{\phi_1}^2
	+\frac{10}{\alpha\beta^2} p_{\phi_2}^2
        \right ],
    \end{equation}
    \begin{equation}
        U=
	    -\frac{\gamma}{12}
	    \frac{1}{r^3}[
	        \cos(\phi_1-\phi_2)
	        +3\cos(\phi_1+\phi_2 -2\theta)
	    ].
    \end{equation}
\end{subequations}

Let us finally make two more assumptions. First, that the two spheres are identical, $\alpha=\beta=\gamma=1$. Second, that there is some contact potential energy $U_C$ preventing the two spheres from overlapping that prohibits $r$ from getting less than 1. These two assumptions produce the Hamiltonian we'll be investigating for the remainder of our discussion

\begin{equation}
  \begin{multlined}
	H=T+U=
	\frac{1}{2}\left (
	2 p_r^2
	+2 \frac{p_\theta^2}{r^2}
	+10 p_{\phi_1}^2
	+10 p_{\phi_2}^2
        \right )
        \\
	-
	\frac{1}{12}
	\frac{1}{r^3}[
	        \cos(\phi_1-\phi_2)
	        +3\cos(\phi_1+\phi_2 -2\theta)
	    ]+U_C.
  \end{multlined}
\end{equation}

\section{Analysis}
\subsection{Analytic Results}

\subsubsection{Equilibrium Analysis}
Let us first examine the equations of motion and see if there exist any equilibria between the spheres while they are in contact with each other ($r=1$). The Hamiltonian equations of motion we find are
%04/15 include the p dots in equations, make the contact term on a second line
\begin{subequations}
    \begin{equation}\label{fphi1}
       \dot p_{\phi_1}=
       -\partial_{\phi_1} H =
	- \frac{1}{12} \sin{\left (\phi_{1} - \phi_{2} \right )} - \frac{1}{4} \sin{\left (\phi_{1} + \phi_{2} - 2 \theta \right )},
    \end{equation}
    \begin{equation}\label{fphi2}
        \dot p_{\phi_2}=
        -\partial_{\phi_2} H =
	\frac{1}{12} \sin{\left (\phi_{1} - \phi_{2} \right )} - \frac{1}{4} \sin{\left (\phi_{1} + \phi_{2} - 2 \theta \right )},
    \end{equation}
    \begin{equation}\label{ftht}
        \dot p_{\theta}=
        -\partial_{\theta} H =
        \frac{1}{2} \sin{\left (\phi_{1} + \phi_{2} - 2 \theta \right )},
    \end{equation}
    \begin{equation}\label{fr}
        \dot p_{r}=
        -\partial_{r} H =
        2 p_{\theta}^{2}r^{-3}
        - \left[
            \frac{1}{4} \cos{\left (\phi_{1}- \phi_{2} \right )}
            + \frac{3}{4} \cos{\left (\phi_{1} + \phi_{2} - 2 \theta \right )}
            \right]r^{-4}+F_C.
    \end{equation}
\end{subequations}
%04/15 static vs constant, edwards leans towards constant
%American journal of physics reference equations
Inspecting Eq.~(\ref{ftht}) we see immediately that the orbital momentum, $p_\theta$, is static if and only if $\phi_{1} + \phi_{2} - 2 \theta = j \pi$ where $j$ is any integer. Using that as a constraint we then see that spin momenta are both static if the previous equation holds and $\phi_{1} + \phi_{2} = k\pi$ where $k$ is an integer independent of $j$. These two constraints produce a set of equilibrium curves where

\begin{subequations}
	\begin{equation}
		\phi_1 = \frac{j+k}{2}\pi +\theta,
	\end{equation}
	\begin{equation}
		\phi_2 = \frac{j-k}{2}\pi +\theta,
	\end{equation}
\end{subequations}
%04/15 do a more thorough explanation of symmetry of hamiltonian
%list out different j,k's, converge on (j,k)
and all the forces on the three angular momenta are 0. However since our Hamiltonian is periodic over $2\pi$ we're interested in $(j,k)$ permuting through 0 and 1. This leaves us with 4 curves, until we consider the constraint that Eq.~(\ref{fr}) must be negative to maintain contact. If j is odd, then we're left with a resulting positive radial force of $1/2$, and we lose contact. So we've narrowed down from an infinite number of equilibrium curves to two, which, using the j-k notation are (0,0) and (0,1). These curves correspond with the continuous ground states Schönke \cite{PhysRevApplied.4.064007} found despite not fixing the dipoles to rotate in place.

\subsubsection{Normal Mode Analysis}
Equilibria and equations of motion in hand we can do small angle perturbations. Noting that near an equilibrium point
$\Gamma_i =
(
\phi_{1i},\phi_{2i},\theta_{i},
p_{\phi_{1i}},p_{\phi_{2i}},p_{\theta_{i}}
)
=
(\phi_{1i},\phi_{2i},\theta_{i},0,0,0)
$
the changes in momenta will be small, we can do a multi-variable Taylor expansion and produce

\begin{equation}\label{taylor_force}
	\dot p_n
	=
	-\partial_{q_n}H
	\approx
	\Sigma_m \partial_{q_m}(-\partial_{q_n} H)|_{\Gamma_i} q_m .
\end{equation}

If we define elements in a matrix
$K_{n,m}= \partial_{q_m}(-\partial_{q_n} H)|_{\Gamma_i}$
We can rephrase Eq.~(\ref{taylor_force}) as

\begin{equation} \label{matrix_force}
	\cvec{ \dot{ p }} \approx \widehat K \cvec q.
\end{equation}

To get this amenable to simple periodic solutions, we would like to recast the momentum vector in terms of a time derivative of our position

\begin{equation}
	\ddot{ q_n } =\frac{d}{dt} \partial_{p_n} H = m_n \dot p_n.
\end{equation}

Given our Hamiltonian and additional constraint of contact we get a constant effective mass. If we define elements in a diagonal matrix as
$M_{n,n}=1/m_n$
then we can rewrite Eq.~(\ref{matrix_force}) as

\begin{equation}
	\widehat M \cvec{ \ddot{ q }} \approx \widehat K \cvec q.
\end{equation}

Assuming simple periodic solutions of the form $\cvec q = \cvec a e^{i\omega t}$ allows us to recast the above as

\begin{equation}
	(
	\widehat K + \omega^2 \widehat M
	)  \cvec{ a}e^{i\omega t} \approx 0 .
\end{equation}

If we treat the approximation as an equality, it will only hold for non-trivial motion if the determinant of the matrix $\widehat K - \omega^2 \widehat M$ (referred to here on as the perturbation matrix) is 0. The normal modes are the eigenvectors with frequencies equal to the eigenvalues of the perturbation matrix.

For the (0,0) equilibrium we find the perturbation matrix to be
\begin{equation}
	\left[\begin{matrix}
	\frac{\omega^{2}}{10} - \frac{1}{3} & - \frac{1}{6} & \frac{1}{2}\\
	- \frac{1}{6} & \frac{\omega^{2}}{10} - \frac{1}{3} & \frac{1}{2}\\
	\frac{1}{2} & \frac{1}{2} & \frac{\omega^{2}}{2} - 1
	\end{matrix}\right]
\end{equation}

Which only has two non-zero eigenmodes corresponding to when $\omega^2$ is equal to 5/3 and 7. The lower frequency mode has an eigenvector of [1, -1, 0], indicating it has no motion in the orbital angle, $\theta$. For this reason we shall refer to it as the spinning mode for its sole form of motion. It possesses an interesting isomorphism we shall examine in more depth later. The second, higher, frequency's eigenvector is [5/2, 5/2,-1] indicating it does possess orbital motion and thus earns the moniker of orbital mode. These modes correspond to the $\alpha$ and $\beta$ modes in Pollack \cite{doi:10.1139/p96-151} respectively. The spinning mode matches exactly.
Allowing for $\theta$ to be dynamical appears to result in a higher restoring force as the frequency is higher.
Brief algebra will reveal that both modes have net-0 angular momentum.

Additionally this result along with the work Stump did on radiation damping of oscillating dipoles \cite{Stump:1997aa} lets us estimate the significance of that phenomenon on this system. When approximating the damping effect as leading to exponential decay leads to a time constant, that when expressed in our units, is
\begin{equation}
\tau_{decay}=180 c^3 \left (L_0^2 \omega_0^2\frac{L_0}{T_0} \right)^{-1}T_0.
\end{equation}
Which means for reasonably sized dipoles we would observe an enormous amount of oscillations before any significant energy was lost to simple dipole radiation. Other forms of dissipation would certainly dominate.

\begin{figure}[h]
	\includegraphics[width=0.9\linewidth ]{./images/animatic.pdf}
%  \caption{The top row features four frames of an orbital mode with period 4, while the bottom row a spinning mode with period 8. Numerical results.}
  \caption{Numerical results for  four frames of an orbital mode with period 3 (top row), and a spinning mode with period 8 (bottom row).}

\end{figure}

For the (0,1) equilibrium the perturbation matrix is
\begin{equation}
	\left[\begin{matrix}\frac{\omega^{2}}{10} - \frac{1}{6} & - \frac{1}{3} & \frac{1}{2}\\
	- \frac{1}{3} & \frac{\omega^{2}}{10} - \frac{1}{6} & \frac{1}{2}\\
	\frac{1}{2} & \frac{1}{2} & \frac{\omega^{2}}{2} - 1\end{matrix}\right]\end{equation}

Which merits two points of observation. First, all the same eigenvectors come forth along with 2 non-zero fundamental frequencies. Second, while the orbital mode has the same frequency, the spinning mode's $\omega^2=-5/3$. It follows then that the frequency has a negative complex component. When that frequency is put back into the periodic solution of $e^{i\omega t}$ we'll have a growing exponential indicating that it is unstable.

Both the (0,0) and (0,1) equilibria points have an $\omega^2=0$ mode where all the angles have been translated by some equal amount. With all the translation being the same, there's no restoring force and thus no oscillation.

\subsubsection{Isomorphisms} Examining the spinning mode in more depth we present the variable substitution for the difference and sum of the dipole orientations and corresponding velocity

\begin{subequations}
	\begin{gather}
		\phi_d = \phi_1-\phi_2 \\
		\phi_t = \phi_1+\phi_2 \\
		\dot\phi_d = \dot\phi_1-\dot\phi_2 \\
		\dot\phi_t = \dot\phi_1+\dot\phi_2
	\end{gather}
\end{subequations}

%\end{align}
%Squaring and summing these new velocities we find
%%04/15 rewrite to emphasize going over from the langragnian
%$\frac{1}{2}(\dot\phi_d^2 + \dot\phi_t^2) = \dot\phi_1^2+\dot\phi_2^2$ and similarly $\frac{1}{20}(\dot\phi_d^2 + \dot\phi_t^2) = \frac{1}{10}(\dot\phi_1^2+\dot\phi_2^2)$.
Making these substitutions in the original Lagrangian we find new momenta and a new Hamiltonian.
The momenta are $p_{\phi_d}=\dot\phi_d/20$ and $p_{\phi_t}=\dot\phi_t/20$ while the contact Hamiltonian in these coordinates to is

\begin{equation}
  \begin{multlined}
	H=T+U=
	\frac{1}{2}\left (
	2 p_\theta^2
	+20 p_{\phi_d}^2
	+20 p_{\phi_t}^2
        \right )
        \\
	-
	\frac{1}{12}
	[
	        \cos \phi_d
	        +3\cos(\phi_t-2\theta)
	    ]
  \end{multlined}
\end{equation}

Let us consider just the spinning mode with $\phi_t=\theta=p_{\phi_t}=p_\theta=0$. Using this Hamiltonian it becomes clear that when those four variables all start at 0 they stay at 0, reducing this phase space from 6 dimensions to 2.

\begin{equation}
	H_{\phi_d}=
	10 p_{\phi_d}^2
	-
	\frac{1}{12}
        \cos \phi_d
\end{equation}

%04/15 tweak phrasing
%04/30 how?
It is important to note the similarities with the Hamiltonian for a simple pendulum. As is the case for a pendulum, the Hamilton equations lead us to  a second order differential equation $\ddot \phi_d = - \frac{5}{3}\sin \phi_d$ providing a second check that the frequency is correct.

\subsubsection{Coupling}

Considering now the Hamiltonian for the other two angles we have

\begin{equation}
	H_{\phi_t, \theta}=
	\frac{1}{2}\left (
	2 p_\theta^2
	+20 p_{\phi_t}^2
        \right )
	-
	\frac{1}{12}
	[
	        3\cos(\phi_t-2\theta)
	    ],
\end{equation}

which holds while the contact criterion is observed.

\begin{subequations}
	\begin{equation}\label{f_phit}
		-\partial_{\phi_t}H= \dot p_{\phi_t}
		= - \frac{1}{4} \sin{\left (\phi_{t} - 2 \theta \right )}
	\end{equation}
	\begin{equation}\label{f_tht}
		-\partial_{\theta}H= \dot p_{\theta}
		= \frac{1}{2} \sin{\left (\phi_{t} - 2 \theta \right )}
		=-2\dot p_{\phi_t}
	\end{equation}
	\begin{equation}
		\partial_{p_{\phi_t}}H= \dot \phi_t
		= 20 p_{\phi_t}
	\end{equation}
	\begin{equation}
		\partial_{p_{\theta}}H= \dot \theta
		= 2 p_{\theta}
	\end{equation}
\end{subequations}

The rates of change for the momenta clearly denote a conserved quantity we'll call total angular momentum and denote as
$L_\textrm{t} = p_\theta + 2p_{\phi_t}$.
%06/11 compare with conventional total angular momentum
With this we can produce the expression

\begin{equation}
  \begin{multlined}
	\phi_t(t)
	= \phi_{t0} + \int_0^t \kern-.33em  \dot \phi_t  dt
	= \phi_{t0} + \int_0^t \kern-.33em 20 p_{ \phi_t } dt
	= \phi_{t0} + \int_0^t \kern-.33em 10 (L_\textrm{t}-p_{ \theta }) dt
	\\
	= \phi_{t0} + 10L_\textrm{t} t -10 \int_0^t \kern-.33em p_{ \theta } dt.
  \end{multlined},
\end{equation}
which we'll rearrange to get
\begin{equation}\label{phi_int}
	\int_0^t  p_{ \theta } dt
	= L_\textrm{t} t + (\phi_{t0}  - \phi_t(t))/10.
\end{equation}
%04/16 rewrite to be more stand alone
A similar integral can be set up for $\theta$
\begin{equation}\label{tht_int}
  \begin{multlined}
	\theta(t)
	= \theta_{ 0} + \int_0^t  \dot \theta  dt
	= \theta_{ 0} + \int_0^t  2 p_{\theta} dt
	\\
	\int_0^t  p_{\theta} dt = \frac{1}{2}[\theta(t)-\theta_{0}].
  \end{multlined}
\end{equation}

While the integral of $p_\theta$ is not analytic, the equality between the two holds while contact is maintained which allows us to algebraically rearrange Eq.~(\ref{phi_int}) and Eq.~(\ref{tht_int}) to get

\begin{equation}
	\phi_t(t)=  -5
	\left[
	\theta(t)-\theta_{0}-\frac{1}{5}\phi_{t0}
	\right]
	+ 10L_\textrm{t} t .
\end{equation}

Considering the force on $p_\theta$ from Eq.~(\ref{f_tht}) and making this new substitution starting from equilibrium and a zero angular momentum starting condition we have

\begin{equation}
	\ddot \theta = \sin(-5\theta -2\theta) = -\sin 7\theta \approx -7\theta
\end{equation}

And doing the same with $p_{\phi_t}$ from Eq.~(\ref{f_phit}) produces

\begin{equation}
	\ddot \phi_t = -\frac{20}{4}\sin(\phi_t +\frac{2}{5}\phi_t) =  -5\sin\left ( \frac{7}{5}\phi_t \right )\approx -7\phi_t
\end{equation}

Showing that while the contact constraint holds, the orbital state is also isomorphic with the simple pendulum with the same asymptotic behavior as the small amplitude oscillations we found earlier. With this we see that when $L_\textrm{t}=0$ and contact maintained we have reduced the problem to two independent pendula. While the periods are independent of each other and unlikely to form a rational fraction, both are periodic. This fact makes the system as a whole no more complicated than quasi-periodic.
%05/07 explain how these pendulum results imply quasi-periodicity at the most complex

\subsection{Numerical Results}
\subsubsection{Method}
An adaptive fourth order Runge-Kutta method was implemented to calculate the trajectory of the system using two different sized time steps, both made smaller until they agreed within a specified precision. To determine if a trajectory has returned through it's original point in phase space $\boldsymbol{\Gamma}(0)=\boldsymbol{\Gamma}_0$ linear interpolation was used between steps $\boldsymbol{\Gamma}_n$ and $\boldsymbol{\Gamma}_{n+1}$ to get an estimated time for when the initial value was revisited. This generated six estimated recurrence times. If all six calculated values fell between $t_n$ and $t_{n+1}$ the average was taken and stored. This process was continued until 75 time units had elapsed. The stored recurrence times were fit to the equation $t_m = t_0m$, the slope $t_0$ was taken to be the period.

\subsubsection{Period vs Energy curves}
The spinning and orbital modes were examined independently as they are not coupled together when the contact criterion is maintained. Two hundred initial conditions were simulated with closer resolution taken near transition points. In the case of the spinning mode, the maximum initial kinetic energy was 1/2, taking it well past the point where it begins spinning freely. In the case of the orbital mode, the maximum energy was just below the point where the contact criterion was broken, 1/3 units of initial kinetic energy.

\begin{figure}[h]
	\centering
	\includegraphics[width=0.85\textwidth]{./images/plot.png}
	\caption{Above is a plot of large amplitude period vs total system energy. Solid lines denote numerical results, dashed lines denote asymptotic small amplitude limit}
\end{figure}

\section{Conclusions}

In the analysis of this system so far we have found an interesting example of coupled non-linear hamiltonian that counter intuitively does not produce chaotic motion. However this is only the first of many questions this system leaves open for discussion. Using equation Eq.~(\ref{gen_ham}) we can explore if this splitting of the Hamiltonian works for any set of spheres or if there are certain ratios that must hold. We can also explore stability of circular orbits that likely exist. With the appropriate numerical techniques we can examine how these spheres interact with bouncing. These questions and more are available for investigation.

\section{Acknowledgements}

I'd like to thank my peer Tyler Markham for expressing his opinions on the conveyance of various illustrations in this paper, my peer Jacob Ciafre for listening to me speculate in our kitchen, Alice Haugen for prose editing and most importantly Amy Whillock for her patience and support.

%needed diagrams;
%numerical values of period vs energy
%geometry layout/labels
%animatique of basic modes
%revtek4.1

%go through the logs on AJP again incase there's something else to be cited
\bibliographystyle{unsrt}

%05/07 go through edwards ajp chaos paper and grab all the AJP that might be pertinent  (12~,13~ 18~, 24, 25, 26, 27, 33, 34)

\bibliography{double_magnet_bib}

\end{document}


% -*- mode: latex; TeX-master: "Vorbis_I_spec"; -*-
%!TEX root = Vorbis_I_spec.tex
% $Id$
\section{Floor type 1 setup and decode} \label{vorbis:spec:floor1}

\subsection{Overview}

Vorbis floor type one uses a piecewise straight-line representation to
encode a spectral envelope curve. The representation plots this curve
mechanically on a linear frequency axis and a logarithmic (dB)
amplitude axis. The integer plotting algorithm used is similar to
Bresenham's algorithm.

\subsection{Floor 1 format}

\subsubsection{model}

Floor type one represents a spectral curve as a series of
line segments.  Synthesis constructs a floor curve using iterative
prediction in a process roughly equivalent to the following simplified
description:

\begin{itemize}
 \item  the first line segment (base case) is a logical line spanning
from x_0,y_0 to x_1,y_1 where in the base case x_0=0 and x_1=[n], the
full range of the spectral floor to be computed.

\item the induction step chooses a point x_new within an existing
logical line segment and produces a y_new value at that point computed
from the existing line's y value at x_new (as plotted by the line) and
a difference value decoded from the bitstream packet.

\item floor computation produces two new line segments, one running from
x_0,y_0 to x_new,y_new and from x_new,y_new to x_1,y_1. This step is
performed logically even if y_new represents no change to the
amplitude value at x_new so that later refinement is additionally
bounded at x_new.

\item the induction step repeats, using a list of x values specified in
the codec setup header at floor 1 initialization time.  Computation
is completed at the end of the x value list.

\end{itemize}

Consider the following example, with values chosen for ease of
understanding rather than representing typical configuration:

For the below example, we assume a floor setup with an [n] of 128.
The list of selected X values in increasing order is
0,16,32,48,64,80,96,112 and 128.  In list order, the values interleave
as 0, 128, 64, 32, 96, 16, 48, 80 and 112.  The corresponding
list-order Y values as decoded from an example packet are 110, 20, -5,
-45, 0, -25, -10, 30 and -10.  We compute the floor in the following
way, beginning with the first line:

\begin{center}
\includegraphics[width=8cm]{floor1-1}
\captionof{figure}{graph of example floor}
\end{center}

We now draw new logical lines to reflect the correction to new_Y, and
iterate for X positions 32 and 96:

\begin{center}
\includegraphics[width=8cm]{floor1-2}
\captionof{figure}{graph of example floor}
\end{center}

Although the new Y value at X position 96 is unchanged, it is still
used later as an endpoint for further refinement.  From here on, the
pattern should be clear; we complete the floor computation as follows:

\begin{center}
\includegraphics[width=8cm]{floor1-3}
\captionof{figure}{graph of example floor}
\end{center}

\begin{center}
\includegraphics[width=8cm]{floor1-4}
\captionof{figure}{graph of example floor}
\end{center}

A more efficient algorithm with carefully defined integer rounding
behavior is used for actual decode, as described later.  The actual
algorithm splits Y value computation and line plotting into two steps
with modifications to the above algorithm to eliminate noise
accumulation through integer roundoff/truncation.

\subsubsection{header decode}

A list of floor X values is stored in the packet header in interleaved
format (used in list order during packet decode and synthesis).  This
list is split into partitions, and each partition is assigned to a
partition class.  X positions 0 and [n] are implicit and do not belong
to an explicit partition or partition class.

A partition class consists of a representation vector width (the
number of Y values which the partition class encodes at once), a
'subclass' value representing the number of alternate entropy books
the partition class may use in representing Y values, the list of
[subclass] books and a master book used to encode which alternate
books were chosen for representation in a given packet.  The
master/subclass mechanism is meant to be used as a flexible
representation cascade while still using codebooks only in a scalar
context.

\begin{Verbatim}[commandchars=\\\{\}]

  1) [floor1\_partitions] = read 5 bits as unsigned integer
  2) [maximum\_class] = -1
  3) iterate [i] over the range 0 ... [floor1\_partitions]-1 \{

        4) vector [floor1\_partition\_class\_list] element [i] = read 4 bits as unsigned integer

     \}

  5) [maximum\_class] = largest integer scalar value in vector [floor1\_partition\_class\_list]
  6) iterate [i] over the range 0 ... [maximum\_class] \{

        7) vector [floor1\_class\_dimensions] element [i] = read 3 bits as unsigned integer and add 1
	8) vector [floor1\_class\_subclasses] element [i] = read 2 bits as unsigned integer
        9) if ( vector [floor1\_class\_subclasses] element [i] is nonzero ) \{

             10) vector [floor1\_class\_masterbooks] element [i] = read 8 bits as unsigned integer

           \}

       11) iterate [j] over the range 0 ... (2 exponent [floor1\_class\_subclasses] element [i]) - 1 \{

             12) array [floor1\_subclass\_books] element [i],[j] =
                 read 8 bits as unsigned integer and subtract one
           \}
      \}

 13) [floor1\_multiplier] = read 2 bits as unsigned integer and add one
 14) [rangebits] = read 4 bits as unsigned integer
 15) vector [floor1\_X\_list] element [0] = 0
 16) vector [floor1\_X\_list] element [1] = 2 exponent [rangebits];
 17) [floor1\_values] = 2
 18) iterate [i] over the range 0 ... [floor1\_partitions]-1 \{

       19) [current\_class\_number] = vector [floor1\_partition\_class\_list] element [i]
       20) iterate [j] over the range 0 ... ([floor1\_class\_dimensions] element [current\_class\_number])-1 \{
             21) vector [floor1\_X\_list] element ([floor1\_values]) =
                 read [rangebits] bits as unsigned integer
             22) increment [floor1\_values] by one
           \}
     \}

 23) done
\end{Verbatim}

An end-of-packet condition while reading any aspect of a floor 1
configuration during setup renders a stream undecodable.  In addition,
a \varname{[floor1\_class\_masterbooks]} or
\varname{[floor1\_subclass\_books]} scalar element greater than the
highest numbered codebook configured in this stream is an error
condition that renders the stream undecodable.  Vector
[floor1\_x\_list] is limited to a maximum length of 65 elements; a
setup indicating more than 65 total elements (including elements 0 and
1 set prior to the read loop) renders the stream undecodable.  All
vector [floor1\_x\_list] element values must be unique within the
vector; a non-unique value renders the stream undecodable.

\subsubsection{packet decode} \label{vorbis:spec:floor1-decode}

Packet decode begins by checking the \varname{[nonzero]} flag:

\begin{Verbatim}[commandchars=\\\{\}]
  1) [nonzero] = read 1 bit as boolean
\end{Verbatim}

If \varname{[nonzero]} is unset, that indicates this channel contained
no audio energy in this frame.  Decode immediately returns a status
indicating this floor curve (and thus this channel) is unused this
frame.  (A return status of 'unused' is different from decoding a
floor that has all points set to minimum representation amplitude,
which happens to be approximately -140dB).

Assuming \varname{[nonzero]} is set, decode proceeds as follows:

\begin{Verbatim}[commandchars=\\\{\}]
  1) [range] = vector \{ 256, 128, 86, 64 \} element ([floor1\_multiplier]-1)
  2) vector [floor1\_Y] element [0] = read \link{vorbis:spec:ilog}{ilog}([range]-1) bits as unsigned integer
  3) vector [floor1\_Y] element [1] = read \link{vorbis:spec:ilog}{ilog}([range]-1) bits as unsigned integer
  4) [offset] = 2;
  5) iterate [i] over the range 0 ... [floor1\_partitions]-1 \{

       6) [class] = vector [floor1\_partition\_class]  element [i]
       7) [cdim]  = vector [floor1\_class\_dimensions] element [class]
       8) [cbits] = vector [floor1\_class\_subclasses] element [class]
       9) [csub]  = (2 exponent [cbits])-1
      10) [cval]  = 0
      11) if ( [cbits] is greater than zero ) \{

             12) [cval] = read from packet using codebook number
                 (vector [floor1\_class\_masterbooks] element [class]) in scalar context
          \}

      13) iterate [j] over the range 0 ... [cdim]-1 \{

             14) [book] = array [floor1\_subclass\_books] element [class],([cval] bitwise AND [csub])
             15) [cval] = [cval] right shifted [cbits] bits
	     16) if ( [book] is not less than zero ) \{

	           17) vector [floor1\_Y] element ([j]+[offset]) = read from packet using codebook
                       [book] in scalar context

                 \} else [book] is less than zero \{

	           18) vector [floor1\_Y] element ([j]+[offset]) = 0

                 \}
          \}

      19) [offset] = [offset] + [cdim]

     \}

 20) done
\end{Verbatim}

An end-of-packet condition during curve decode should be considered a
nominal occurrence; if end-of-packet is reached during any read
operation above, floor decode is to return 'unused' status as if the
\varname{[nonzero]} flag had been unset at the beginning of decode.

Vector \varname{[floor1\_Y]} contains the values from packet decode
needed for floor 1 synthesis.

\subsubsection{curve computation} \label{vorbis:spec:floor1-synth}

Curve computation is split into two logical steps; the first step
derives final Y amplitude values from the encoded, wrapped difference
values taken from the bitstream.  The second step plots the curve
lines.  Also, although zero-difference values are used in the
iterative prediction to find final Y values, these points are
conditionally skipped during final line computation in step two.
Skipping zero-difference values allows a smoother line fit.

Although some aspects of the below algorithm look like inconsequential
optimizations, implementors are warned to follow the details closely.
Deviation from implementing a strictly equivalent algorithm can result
in serious decoding errors.

{\em Additional note:} Although \varname{[floor1\_final\_Y]} values in
the prediction loop and at the end of step 1 are inherently limited by
the prediction algorithm to [0, \varname{[range]}), it is possible to
  abuse the setup and codebook machinery to produce negative or
  over-range results.  We suggest that decoder implementations guard
  the values in vector \varname{[floor1\_final\_Y]} by clamping each
  element to [0, \varname{[range]}) after step 1.  Variants of this
    suggestion are acceptable as valid floor1 setups cannot produce
    out of range values.

\begin{description}
\item[step 1: amplitude value synthesis]

Unwrap the always-positive-or-zero values read from the packet into
+/- difference values, then apply to line prediction.

\begin{Verbatim}[commandchars=\\\{\}]
  1) [range] = vector \{ 256, 128, 86, 64 \} element ([floor1\_multiplier]-1)
  2) vector [floor1\_step2\_flag] element [0] = set
  3) vector [floor1\_step2\_flag] element [1] = set
  4) vector [floor1\_final\_Y] element [0] = vector [floor1\_Y] element [0]
  5) vector [floor1\_final\_Y] element [1] = vector [floor1\_Y] element [1]
  6) iterate [i] over the range 2 ... [floor1\_values]-1 \{

       7) [low\_neighbor\_offset] = \link{vorbis:spec:low:neighbor}{low\_neighbor}([floor1\_X\_list],[i])
       8) [high\_neighbor\_offset] = \link{vorbis:spec:high:neighbor}{high\_neighbor}([floor1\_X\_list],[i])

       9) [predicted] = \link{vorbis:spec:render:point}{render\_point}( vector [floor1\_X\_list] element [low\_neighbor\_offset],
				      vector [floor1\_final\_Y] element [low\_neighbor\_offset],
                                      vector [floor1\_X\_list] element [high\_neighbor\_offset],
				      vector [floor1\_final\_Y] element [high\_neighbor\_offset],
                                      vector [floor1\_X\_list] element [i] )

      10) [val] = vector [floor1\_Y] element [i]
      11) [highroom] = [range] - [predicted]
      12) [lowroom]  = [predicted]
      13) if ( [highroom] is less than [lowroom] ) \{

            14) [room] = [highroom] * 2

          \} else [highroom] is not less than [lowroom] \{

            15) [room] = [lowroom] * 2

          \}

      16) if ( [val] is nonzero ) \{

            17) vector [floor1\_step2\_flag] element [low\_neighbor\_offset] = set
            18) vector [floor1\_step2\_flag] element [high\_neighbor\_offset] = set
            19) vector [floor1\_step2\_flag] element [i] = set
            20) if ( [val] is greater than or equal to [room] ) \{

                  21) if ( [highroom] is greater than [lowroom] ) \{

                        22) vector [floor1\_final\_Y] element [i] = [val] - [lowroom] + [predicted]

		      \} else [highroom] is not greater than [lowroom] \{

                        23) vector [floor1\_final\_Y] element [i] = [predicted] - [val] + [highroom] - 1

                      \}

                \} else [val] is less than [room] \{

                    24) if ([val] is odd) \{

                        25) vector [floor1\_final\_Y] element [i] =
                            [predicted] - (([val] + 1) divided by  2 using integer division)

                      \} else [val] is even \{

                        26) vector [floor1\_final\_Y] element [i] =
                            [predicted] + ([val] / 2 using integer division)

                      \}

                \}

          \} else [val] is zero \{

            27) vector [floor1\_step2\_flag] element [i] = unset
            28) vector [floor1\_final\_Y] element [i] = [predicted]

          \}

     \}

 29) done

\end{Verbatim}

\item[step 2: curve synthesis]

Curve synthesis generates a return vector \varname{[floor]} of length
\varname{[n]} (where \varname{[n]} is provided by the decode process
calling to floor decode).  Floor 1 curve synthesis makes use of the
\varname{[floor1\_X\_list]}, \varname{[floor1\_final\_Y]} and
\varname{[floor1\_step2\_flag]} vectors, as well as [floor1\_multiplier]
and [floor1\_values] values.

Decode begins by sorting the scalars from vectors
\varname{[floor1\_X\_list]}, \varname{[floor1\_final\_Y]} and
\varname{[floor1\_step2\_flag]} together into new vectors
\varname{[floor1\_X\_list]'}, \varname{[floor1\_final\_Y]'} and
\varname{[floor1\_step2\_flag]'} according to ascending sort order of the
values in \varname{[floor1\_X\_list]}.  That is, sort the values of
\varname{[floor1\_X\_list]} and then apply the same permutation to
elements of the other two vectors so that the X, Y and step2\_flag
values still match.

Then compute the final curve in one pass:

\begin{Verbatim}[commandchars=\\\{\}]
  1) [hx] = 0
  2) [lx] = 0
  3) [ly] = vector [floor1\_final\_Y]' element [0] * [floor1\_multiplier]
  4) iterate [i] over the range 1 ... [floor1\_values]-1 \{

       5) if ( [floor1\_step2\_flag]' element [i] is set ) \{

             6) [hy] = [floor1\_final\_Y]' element [i] * [floor1\_multiplier]
 	     7) [hx] = [floor1\_X\_list]' element [i]
             8) \link{vorbis:spec:render:line}{render\_line}( [lx], [ly], [hx], [hy], [floor] )
             9) [lx] = [hx]
	    10) [ly] = [hy]
          \}
     \}

 11) if ( [hx] is less than [n] ) \{

        12) \link{vorbis:spec:render:line}{render\_line}( [hx], [hy], [n], [hy], [floor] )

     \}

 13) if ( [hx] is greater than [n] ) \{

            14) truncate vector [floor] to [n] elements

     \}

 15) for each scalar in vector [floor], perform a lookup substitution using
     the scalar value from [floor] as an offset into the vector \link{vorbis:spec:floor1:inverse:dB:table}{[floor1\_inverse\_dB\_static\_table]}

 16) done

\end{Verbatim}

\end{description}


\chapter{Interactions}

In this chapter, we are going to investigate the effects of interactions.
When the field theory is no longer free, the notion of free particle is not very well defined.
Also, the interactions actually gives the physical quantities that can be measured.
For example the scattering amplitudes.

We will mainly focus on the scalar field theory, as the complexity of the vector or spinor field mainly comes from the algebraic structures of themselves.
After explaining the stories of the scalar filed, we will try to generalize them to the vector and spinor cases.

\section{Perturbation Theory}
\subsection{Real-space Formalism}
For interaction theory, the partition function can be formally expressed as:
\begin{equation}
	Z[J] = \exp\left(i\int d^dx \mathcal{L}_{\mathrm{int}}\left[\frac{\delta}{i\delta J(x)}\right]\right)Z_0[J].
\end{equation}
The expectation values for a generic operator of the form $O(\phi)$ can be evaluated by the true partition function
\begin{equation}\label{eq:ptb-exp-val}
	\langle O(\phi)\rangle
	= \frac{1}{Z[0]} \left. O\left[\frac{\delta}{i\delta J(x)}\right] Z[J] \right|_{J=0}.
\end{equation}

The expression (\ref{eq:ptb-exp-val}) can be expanded order by order using the Feynman diagram.
Since the unconnected diagram can be absorbed into $Z[0]$, we only need to calculate the connected diagram.

The procedure of perturbative expansion with only connected diagrams can be formally represented by introducing the quantity
\begin{equation}
	Z[J] = Z[0]\exp\left(i W[J]\right).
\end{equation}
The perturbative expansion of $W[J]$ contain only the connected diagrams.
Note that for the free theory,
\begin{equation*}
	\frac{Z_0[J]}{Z_0[0]} = \exp\left[-\frac{i}{2}\int d^d x_1 d^d x_2 J(x_1) \Delta(x_1-x_2)J(x_2)\right],
\end{equation*}
which means
\begin{equation*}
	W_0 = -\frac{1}{2}\int d^d x_1 d^d x_2 J(x_1) \Delta(x_1-x_2)J(x_2).
\end{equation*}
For the interaction theory, the expectation (\ref{eq:ptb-exp-val}) can then be replaced by the connected expectation:
\begin{equation}
	\langle O(\phi)\rangle_c
	\equiv i\left. O\left[\frac{\delta}{i\delta J(x)}\right] W[J] \right|_{J=0}.
\end{equation}

Consider the two-point connected correlation (propagator):
\begin{equation}
\begin{aligned}
	i\Delta(x_1-x_2)
	&= \langle \mathcal{T}\phi(x_1) \phi(x_2)\rangle_c \\
	&= i\left.\frac{\delta^2 W[J]}{i\delta J(x_1) i\delta J(x_2)}\right|_{J=0} \\
	&= \left.\frac{\delta^2 \ln Z[J]}{i\delta J(x_1) i\delta J(x_2)}\right|_{J=0}\\
	&= \frac{1}{Z[0]}\left.\frac{\delta^2 Z[J]}{i\delta J(x_1)i\delta J(x_2)}\right|_{J=0},
\end{aligned}
\end{equation}
where we have used the fact that
\begin{equation}
	\frac{\delta Z^n[J]}{\delta J(x_1) \cdots \delta J(x_n)} = 0,\ \forall n = 1\ \mathrm{mod}\ 2.
\end{equation}
The result is the same as the original definition.

Further, we can consider the four-point connected correlation:
\begin{equation}
	iV_4 \equiv \langle \mathcal{T}\phi(x_1) \phi(x_2) \phi(x_3) \phi(x_4)\rangle_c
\end{equation}
Following the same procedure,
\begin{equation}
\begin{aligned}
	iV_4
	=&\ i\left.\frac{\delta^4 W[J]}{i\delta J(x_1)i\delta J(x_2)i\delta J(x_3)i\delta J(x_4)}\right|_{J=0} \\
	=&\ \frac{1}{Z[0]}\left.\frac{\delta^4 Z[J]}{i\delta J(x_1)i\delta J(x_2)i\delta J(x_3)i\delta J(x_4)}\right|_{J=0} \\
	& -i\Delta(x_1-x_2) i\Delta(x_3-x_4) \\
	& -i\Delta(x_1-x_3) i\Delta(x_2-x_4) \\
	& -i\Delta(x_1-x_4) i\Delta(x_2-x_3).
\end{aligned}
\end{equation}
The connected correlation function automatically omit those disconnected components.

\subsection{Momentum-space Formalism}
In momentum space, the theory is expressed as
\begin{equation}
\begin{aligned}
	S_0[\phi(k)] &= \frac{1}{2} \int\frac{d^4 k}{(2\pi)^4}\ \phi_R^*(k)(k^2-m_R^2) \phi_R(k), \\
	S_\mathrm{int}[\phi(k)] &= \frac{g_R}{4!} \left(\prod_{i=1}^{4} \int \frac{d^4 k_i}{(2\pi)^4} \right) \left[\prod_{i=1}^4 \phi_R(k_i)\right] \delta^{(4)}\left(\sum_{i=1}^4 k_i\right), \\
	S_{\mathrm{ct}}[\phi(k)] &= \frac{1}{2} \int\frac{d^4 k}{(2\pi)^4}\ \tilde\phi_R^*(k)(A k^2 - B m_R^2) \tilde\phi_R(k) - C \cdot S_\mathrm{int}.
\end{aligned}
\end{equation}
For the free theory:
\begin{equation}
\begin{aligned}
	\frac{Z_0[J]}{Z_0[0]} &= \frac{1}{Z_0[0]}\int D[\phi] \exp\left\{ -S_0[\phi(k)] + i \int\frac{d^4 k}{(2\pi)^4} J_k^* \phi(k) \right\} \\
	&= \exp\left\{ -i \int\frac{d^4 k}{(2\pi)^4} J^*_k \Delta(k) J_k \right\}.
\end{aligned}
\end{equation}
Similarly, the expectation in momentum space is
\begin{equation}
	\langle O(\phi_k)\rangle
	= \frac{1}{Z[0]} \left. O\left[\frac{\delta}{i\delta J^*_k}\right] Z[J] \right|_{J=0}.
\end{equation}
The Feynman diagrams in momentum space is the same as that in real space, just replace the propagator from the real space to the momentum space.
Also, at each vertex, the momentum conservation is automatically satisfied.

\section{Renormalized Field Theory}

For the interacting scalar field, the Hamiltonian do not conserve particle number any more, and the ground state $|\Omega\rangle$ is no longer the vacuum $|0\rangle$.
Consider the Green's function
\begin{equation}
	iG(x_1-x_2) = \langle\Omega|T\phi(x_1)\phi(x_2)|\Omega\rangle
\end{equation}
We can insert a complete basis into the correlation function:\footnote{Here we assume $\langle\Omega|\phi(x)|\Omega\rangle=0$ unless there is spontaneously symmetry breaking happening.}
\begin{equation}
	1 = |\Omega\rangle\langle\Omega| + \sum_\lambda\int\frac{d^3 k}{(2\pi)^3}\frac{1}{2\omega_k}|\lambda_{\bm k}\rangle \langle\lambda_{\bm k}|,
\end{equation}
and the Green's function takes the form:
\begin{equation*}
	iG(x_1-x_2) = \sum_\lambda \int\frac{d^3 k}{(2\pi)^3}
	\left[\theta(t_1-t_2)\langle\Omega|\phi(x_1)|\lambda_{\vec k}\rangle\langle\lambda_{\vec k}|\phi(x_2)|\Omega\rangle + (t_1\leftrightarrow t_2, x_1 \leftrightarrow x_2)\right].
\end{equation*}
Note that $\phi(x)=e^{iP\cdot x}\phi(0) e^{-iP\cdot x}$, so that
\begin{equation}
	\langle\lambda_{\bm k}|\phi(x)|\Omega\rangle
	= e^{ik\cdot x} \left.\langle\lambda_{0}|\phi(0)|\Omega\rangle\right|_{k^0=\omega_{\bm k}}.
\end{equation}
Following the same procedure as we do for the free field theory,
\begin{equation}
	G(x_1-x_2) = \int_0^\infty \frac{dM^2}{2\pi} \rho(M^2) G_0(x_1-x_2;M^2),
\end{equation}
where the \textit{spectral function} $\rho(M^2)$ is
\begin{equation}
	\rho(M^2) = \sum_\lambda(2\pi)\delta(M^2-m_\lambda^2)|\langle\Omega|\phi(0)|\lambda_0\rangle|^2.
\end{equation}
In particle, near the one-particle state the Green's function looks like:
\begin{equation}\label{eq:scalar-prop-lehmann}
	i\tilde G(k) = \frac{iZ_{\phi}}{k^2-m^2+i\epsilon} + \mathrm{regular\ terms}.
\end{equation}
Physically, Eq.~(\ref{eq:scalar-prop-lehmann}) states that in the interacting theory, the field operator $\tilde\phi(k)$ acting on the vacuum only only generate a single particle state, but also multi-particle states with total momentum $k$.
However, those multi-particle state have different singularity structure in the Greens function, as they only contribute regular terms.
If we only care about the propagator of the single particle states, we simply need to extract the singular part of of the Green's function.
That is, the singularity of $\tilde{G}(k)$ gives the (addresses) mass, and the residue
\begin{equation*}
	\lim_{k^2 \rightarrow m^2} (k^2-m^2)\tilde{G}(k)
\end{equation*}
gives the wave-function normalization factor $Z_\phi$.
Trying to restore the original form of the free theory, we consider a renormalized field:
\begin{equation}
	\phi_R(x) = \frac{1}{\sqrt{Z_\phi}}\phi_0(x).
\end{equation}
The Green's function of $\phi_R$ has the same form as free theory.
For this reason, we generate the asymptotic single-particle state using the renormalized field operator:
\begin{equation}\label{eq:scalar-field-generate-particle}
	\phi_R(k)|\Omega\rangle = \frac{1}{2\omega_{\bm k}}|k\rangle + \text{multi-particle states}.
\end{equation}

If we want to create a single-particle state, say at time $t=0$.
We can do this by acting the operator $\tilde{\phi}(k)$ on the vacuum state at time $-T$, then we know when the system evolves for time $T$, it becomes:
\begin{equation}
	e^{-i E_{\bm k} T}|k\rangle + e^{-iHT} \cdot \text{multi-particle states}.
\end{equation}
Here comes the trick.
Assuming the theory is gapped (with mass $m^2>0$), the multi-particle states have higher energy than the single particle states.
We then replace the $t$ by $(1-i\epsilon)t$, which effectives impose a suppression factor $e^{-\epsilon H T}$ to the state.
In the $T\rightarrow \infty$ limit, the amplitude of the multi-particle states vanishes.

The story for the spinor field is exactly the same as the scalar field (also assume the particle has nonzero mass).
However, the story for the photon field is different, since the photon is massless.
A quick escape from the conundrum is to assume the photon has a small mass $m_\gamma$, and latter set $m_\gamma \rightarrow 0$.

\section{Cross Section and Decay Rates}

One important physical observable is the transition amplitude from initial state $|i;t_i\rangle$ and initial time $t_i$ to the finial state $|f;t_f\rangle$ at $t_f$.
In the scattering experiment, the initial and final states are assumed to be ``free''.
For this reason, we can think of the process as start from $t=-\infty$ to $t=+\infty$, where free states at $t=\pm \infty$ are known as \textit{asymptotic states}.
We give the time-evolution operator a special name: the \textit{S-matrix}, defined as:
\begin{equation}
	\langle f|S| i\rangle_{\text{Heisenberg}}
	= \langle f ; \infty \mid i ;-\infty\rangle.
\end{equation}
The S-matrix is related to quantities experimentally measurable, for example the cross sections or decay rates, as discussed in the following.

\subsubsection{Cross Sections}
The \textit{cross section} is an analogy from classical scattering experiment.
For example, Rutherford was interested in the size $r$ of an atomic nucleus.
By colliding $\alpha$-particles with gold foil and measuring how many $\alpha$-particles were scattered, he could determine the cross-sectional area $\sigma=\pi r^{2}$ of the nucleus.

Imagine there is just a single nucleus.
Then the \textit{cross-sectional area} is given by
\begin{equation}
	\sigma=\frac{\text { number of particles scattered }}{\text { time } \times \text { number density in beam } \times \text { velocity of beam }}=\frac{1}{T} \frac{1}{\Phi} N,
\end{equation}
where $T$ is the time for the experiment and $\Phi$ is the incoming flux:
\begin{equation*}
	\Phi= \text{number density} \times \text{velocity of beam},
\end{equation*}
and $N$ is the number of particles scattered.

In quantum mechanical generalization of the notion of cross-sectional area is the cross section, which still has units of area, but has a more abstract meaning as a measure of the interaction strength.
While classically an $\alpha$-particle either scatters off the nucleus or it does not scatter, quantum mechanically it has a probability for scattering.
The classical differential probability is
\begin{equation*}
	P=\frac{N}{N_{\text{inc}}},
\end{equation*}
where $N$ is the number of particles scattering into a given area and $N_{\text {inc }}$ is the number of incident particles.
So the quantum mechanical cross section is then naturally
\begin{equation}
	d \sigma=\frac{1}{T} \frac{1}{\Phi} d P,
\end{equation}
where $\Phi$ is the flux, now normalized as if the beam has just one particle, and $P$ is now the quantum mechanical probability of scattering.
The differential quantities $d \sigma$ and $d P$ are differential in kinematical variables, such as the angles and energies of the final state particles.
The differential number of scattering events measured in a collider experiment is
\begin{equation}
	d N=L \times d \sigma,
\end{equation}
where $L$ is the \textit{luminosity}, which is defined by this equation.

Now let us relate the formula for the differential cross section to S-matrix elements.
From a practical point of view it is impossible to collide more than two particles at a time, thus we can focus on the special case of S-matrix elements where $|i\rangle$ is a two-particle state.
So, we are interested in the differential cross section for the ($2 \rightarrow n$) process:
\begin{equation}
	p_{1}+p_{2} \rightarrow\left\{p_{j}\right\}.
\end{equation}
In the rest frame of one of the colliding particles, the flux is just the magnitude of the velocity of the incoming particle divided by the total volume: $\Phi=|\vec{v}| / V$.
In a different frame, such as the center-of-mass frame, beams of particles come in from both sides, and the flux is then determined by the difference between the particles' velocities.
So, $\Phi=$ $\left|\vec{v}_{1}-\vec{v}_{2}\right| / V$.
This should be familiar from classical scattering.
Thus,
\begin{equation}
	d \sigma=\frac{V}{T} \frac{1}{\left|\vec{v}_{1}-\vec{v}_{2}\right|} d P.
\end{equation}
From quantum mechanics we know that probabilities are given by the square of amplitudes.
Since quantum field theory is just quantum mechanics with a lot of fields, the normalized differential probability is
\begin{equation}
	dP=\frac{|\langle f|S| i\rangle|^{2}}{\langle f | f\rangle\langle i | i\rangle} d \Pi.
\end{equation}
Here, $d \Pi$ is the region of final state momenta at which we are looking.
It is proportional to the product of the differential momentum, $d^{3} p_{j}$, of each final state and must integrate to 1.
So
\begin{equation}
	d \Pi=\prod_{j} \frac{V}{(2 \pi)^{3}} d^{3} p_{j}.
\end{equation}
This has $\int d \Pi=1$, since $\int \frac{d p}{2 \pi}=\frac{1}{L}$ (by dimensional analysis and our $2 \pi$ convention).
According to our normalization convention for single-particle state,
\begin{equation}
	\langle p|p\rangle = (2\omega_p)(2\pi)^3\delta^{(3)}(0) = 2\omega_p V.
\end{equation}
Now let us turn to the S-matrix element $\langle f|S| i\rangle$.
We usually calculate S-matrix elements perturbatively.
In a free theory, where there are no interactions, the S-matrix is simply the identity matrix.
We can therefore write
\begin{equation}
	S=1+i \mathcal{T},
\end{equation}
where $\mathcal{T}$ is called the transfer matrix and describes deviations from the free theory.
Since the S-matrix should vanish unless the initial and final states have the same total 4-momentum, it is helpful to factor an overall momentum-conserving $\delta$-function:
\begin{equation}
	\mathcal{T}=(2 \pi)^{4} \delta^{4}(\Sigma p) \mathcal{M}
\end{equation}
Here, $\delta^{4}(\Sigma p)$ is shorthand for $\delta^{4}\left(\Sigma p_{i}-\Sigma p_{f}\right)$, where $p_{i}$ are the initial particles' momenta and $p_{f}$ are the final particles' momenta.
In this way, we can focus on computing the nontrivial part of the S-matrix, $\mathcal{M}$.
In quantum field theory, ``matrix elements'' usually means $\langle f|\mathcal{M}| i\rangle$. Thus we have
\begin{equation}
	\langle f|\mathcal T| i\rangle=(2 \pi)^{4} \delta^{4}(\Sigma p)\langle f|\mathcal{M}| i\rangle.
\end{equation}
So,
\begin{equation}
\begin{aligned}
	d P &=\frac{\delta^{4}(\Sigma p) T V(2 \pi)^{4}}{\left(2 E_{1} V\right)\left(2 E_{2} V\right)} \frac{|\mathcal{M}|^{2}}{\prod_{j}\left(2 E_{j} V\right)} \prod_{j} \frac{V}{(2 \pi)^{3}} d^{3} p_{j} \\
	&=\frac{T}{V} \frac{1}{\left(2 E_{1}\right)\left(2 E_{2}\right)}|\mathcal{M}|^{2} d \Pi_{\mathrm{LIPS}}
\end{aligned}
\end{equation}
where
\begin{equation}
	d \Pi_{\text {LIPS }} \equiv \prod_{\text {final states } j} \frac{d^{3} p_{j}}{(2 \pi)^{3}} \frac{1}{2 E_{p_{j}}}(2 \pi)^{4} \delta^{4}(\Sigma p)
\end{equation}
is called the \textit{Lorentz-invariant phase space} (LIPS).
Putting everything together, we have
\begin{equation}
	d \sigma=\frac{1}{\left(2 E_{1}\right)\left(2 E_{2}\right)\left|\vec{v}_{1}-\vec{v}_{2}\right|}|\mathcal{M}|^{2} d \Pi_{\text {LIPS }}
\end{equation}
All the factors of $V$ and $T$ have dropped out, so now it is trivial to take $V \rightarrow \infty$ and $T \rightarrow \infty$. Recall also that velocity is related to momentum by $\vec{v}=\vec{p} / p_{0}$.

\subsubsection{Decay Rates}
An unstable particle may decays to other particle(s), the rate of which is called the \textit{decay rate}.
A \textit{differential decay rate} is the probability that a one-particle state with momentum $p_{1}$ turns into a multi-particle state with momenta $\left\{p_{j}\right\}$ over a time $T$:
\begin{equation}
	d \Gamma=\frac{1}{T} d P .
\end{equation}
Of course, it is impossible for the incoming particle to be an asymptotic state at $-\infty$ if it is to decay, and so we should not be able to use the $S$-matrix to describe decays.
The reason this is not a problem is that we calculate the decay rate in perturbation theory assuming the interactions happen only over a finite time $T$.
Thus, a decay is really just like a ($1 \rightarrow n$) scattering process.

Following the same steps as for the differential cross section, the decay rate can be written as
\begin{equation}
	d \Gamma=\frac{1}{2 E_{1}}|\mathcal{M}|^{2} d \Pi_{\text {LIPS }}
\end{equation}
Note that this is the decay rate in the rest frame of the particle.
If the particle is moving at relativistic velocities, it will decay much slower due to time dilation.
The rate in the boosted frame can be calculated from the rest-frame decay rate using special relativity.

\section{LSZ Reduction Formula}

The LSZ reduction formula is used to simplify the calculation of the S-matrix in the momentum space.
It essentially states that for the S-matrix of an ($n \rightarrow m$) process, the matrix element equals to the \textit{amputated Green's function}, which is the Green's function with in and out states propagators amputated:
\begin{equation}
	\tilde{G}(k_1,\cdots,k_n) = \left[\prod_{i=1}^n \tilde{G}(k_i) \right] \tilde{G}_{\mathrm{amp}}(k_1,\cdots,k_n).
\end{equation}
Or, in the coordinate space (for scalar field),
\begin{equation}
	\tilde{G}_{\mathrm{amp}}(k_1,\cdots,k_n) = \left[\prod_{i=1}^n \int d x_i e^{-i k_i x_i} \frac{-\partial^2-m^2}{i\sqrt Z} \right] G(x_1,\cdots,x_n).
\end{equation}
Note that since the in and out states are on-shell, the factor $-\partial^2-m^2$ effectively filter out the singularity $\frac{i}{k^2-m^2}$, and any regular term without singularity will not affect the result.

\subsection{Asymptotic Process}
To get the basis idea how it happens, consider the correlation function
\begin{equation}
	iG(y_m,\cdots,y_1,x_1,\cdots,x_n) = \langle\Omega|\phi(y_m)\cdots\phi(y_1) \phi(x_1)\cdots\phi(x_n)|\Omega\rangle.
\end{equation}
Now we are going to Fourier transform this function for the variable $x_1$.
First we split the time to three domains: $(-\infty,T_-]$, $(T_-,T_+)$, and $[T_+,+\infty)$ such that at time $T_{\pm}$ the particles are well-separated.
Consider first the integral over the first domain:
\begin{equation}
	\int_{-\infty}^{T_-} dx_1^0 \int d^3 x\ e^{i k\cdot x_1} \int \frac{d^3q}{(2\pi)^3}\frac{1}{2\omega_q}\langle \Omega|\phi(y_m)\cdots\phi(y_1) \phi(x_2)\cdots\phi(x_n)|q\rangle \langle q|\phi(x_1) |\Omega\rangle,
\end{equation}
where we have inserted the complete set of intermediate states.\footnote{Note that the multi-particle state are discarded as discussed. Also, the single particle state $|k\rangle$ shall be think as a concentrated wave packet near the particle at $\bm x_1$, so that it has negligible overlap with other particle states.}
Then use the fact $\langle q|\phi(x_1)|\Omega\rangle = \sqrt{Z_\phi} e^{i q \cdot x_1}$,
\begin{equation}
	\int_{-\infty}^{T_-} dx_1^0 \ e^{i (k^0+\omega_q-i\epsilon)\cdot x_1^0}\frac{\sqrt{Z_\phi}}{2\omega_k}\langle \Omega|\phi(y_m)\cdots\phi(y_1) \phi(x_2)\cdots\phi(x_n)|k\rangle,
\end{equation}
The time integral gives the singularity at $k^0=-\omega_k$:
\begin{equation}
	\frac{1}{2\omega_k} \frac{i}{\omega_k+k^0 + i\epsilon} = \frac{i\sqrt{Z_\phi}}{k^2-m^2+i\epsilon} + \text{regular terms}.
\end{equation}

Now consider the integral over the third time domain.
The calculation is basically the same, the difference is the insertion gives
\begin{equation*}
	\langle\Omega| \phi(x_1) |q\rangle = \sqrt{Z_\phi} e^{i q \cdot x_1},
\end{equation*}
which leads to a singularity at $k^0=\omega_k$:
\begin{equation}
	\frac{1}{2\omega_k} \frac{i}{\omega_k-k^0 + i\epsilon} = \frac{i\sqrt{Z_\phi}}{k^2-m^2+i\epsilon} + \text{regular terms}.
\end{equation}
Note that although for the above two cases, the final singular expression can be brought to the same form, the location of the singularity is different, which indicate whether it is the in or out state.
Specific frequency filter can be chosen to select out the component accordingly.

Finally, consider the integral over time interval $(T_-,T_+)$, where the particle are interacting and single particles are not well defined.
On this interval the correlation will not have any singularity.\footnote{some branch cuts are possible, but they will also be annihilated by $k^2-m^2$ term.}
We then know that if we choose $\phi(x_1)$ to create the in state, and we only care about the singular structure, then the Fourier transformation produce the factor
\begin{equation}
	\frac{i\sqrt{Z_\phi}}{k_1^2-m_1^2}.
\end{equation}
The same procedure applies to every field operator, and the final result is
\begin{equation}
\begin{aligned}
	S &= \langle p_1,\cdots,p_1;T_+|k_1,\cdots,k_n;T_-\rangle \\
	&= i\tilde{G}_{\mathrm{amp}}(p_m,\cdots,p_1;-k_1,\cdots,-k_n) \delta^{(4)}\left(\sum p-\sum k \right).
\end{aligned}
\end{equation}
Or, the matrix element satisfies
\begin{equation}
	\mathcal M_{fi} = \tilde{G}_{\mathrm{amp}}(p_m,\cdots,p_1;-k_1,\cdots,-k_n).
\end{equation}

\subsection{Operator Proof for Scalar Field}
Here we choose another way to prove the LSZ formula.
We think a single-particle state to be created by the particle creation operator $a^\dagger$.
For free theory, we have
\begin{equation}
\begin{aligned}
	\sqrt{2\omega_k} a_k &= i \int d^3 x\ e^{ik\cdot x}(-i\omega_k+\partial_t)\phi(x), \\
	\sqrt{2\omega_k} a^\dagger_k &= -i \int d^3 x\ e^{-ik\cdot x}(i\omega_k+\partial_t)\phi(x).
\end{aligned}
\end{equation}
When interaction is turned on, the field operator $\phi(x)$ is renormalized as
\begin{equation*}
	\phi_R(x) \sim \sqrt{Z_{\phi}} \phi_{\mathrm{in}}(x) \sim \sqrt{Z_{\phi}} \phi_{\mathrm{out}}(x),
\end{equation*}
so we define the particle creation operator as
\begin{equation}
	a_R^\dagger \equiv -i \int d^3 x\ e^{-ik\cdot x}(i\omega_k+\partial_t)\phi_R(x).
\end{equation}
When acting on the vacuum:
\begin{equation}
	\sqrt{2\omega_k} a_R^\dagger(k) |\Omega\rangle = |k\rangle + \text{multi-particle states}.
\end{equation}
On may wonder why $a_{\mathrm{in}}(k)$ do not contribute to the single-particle state.
To see that, one can think of the original particle-creation operator $a^\dagger(k)$ in the frequency domain to have a delta function peak at $\omega_k$.
While for the $a(k)$ in the interacting theory, although it can have weight at the frequency $\omega_k$, there will be no delta-function-like peak.

The in and out state are though to be created by the operator $a_R^\dagger(k)$.
Note that as discussed, the multi-particle contribution is discarded.
In the Heisenberg picture, the particle-creation operator satisfies:
\begin{equation}
\begin{aligned}
	a_{R}^\dagger(-\infty) - a_{R}^\dagger(+\infty)
	&= \frac{i}{\sqrt{2\omega_k}} \int dt\ \partial_t \left[\int d^{3}x\ e^{-ikx}(i\omega_k+\partial_t)\phi_R(x)\right] \\
	&= \frac{i}{\sqrt{2\omega_k}} \int d^4 x e^{-ik\cdot x}(\omega_k^2+\partial_t^2)\phi_R(x) \\
	&= \frac{i}{\sqrt{2\omega_k}} \int d^4 x e^{-ik\cdot x}\partial_t^2\phi_0(x) + \phi_R(x)(-\nabla^2+m^2)e^{-i k\cdot x} \\
	&= \frac{i}{\sqrt{2\omega_k}} \int d^4 x e^{-ik\cdot x}(\partial^2+m^2)\phi_R(x)
\end{aligned}
\end{equation}
The initial and final states are:
\begin{equation}
\begin{aligned}
	|k_1, \cdots, k_m; \mathrm{in}\rangle &= \left[\prod_{j=1}^m \sqrt{2\omega_{k_j}} a^\dagger_{R}(k_j;-\infty)\right] |\Omega\rangle, \\
	|p_1, \cdots, p_n, \mathrm{out}\rangle &= \left[\prod_{j=1}^n \sqrt{2\omega_{p_j}}a^\dagger_{R}(p_j;+\infty)\right] |\Omega\rangle.
\end{aligned}
\end{equation}
The S-matrix is
\begin{equation*}
\begin{aligned}
	S_{fi} &= \langle p_1, \cdots, p_n;\mathrm{out}| S |k_1, \cdots, k_m; \mathrm{in}\rangle \\
	&= \frac{\langle 0|T
		\left(\prod \sqrt{2\omega_{p_j}} a_{p_j;\mathrm{out}} \right)
		\int d^4 x \exp(i\mathcal{L}_{\mathrm{int}})
		\left(\prod \sqrt{2\omega_{k_j}} a^\dagger_{k_j;\mathrm{in}} \right)|0\rangle}
		{\langle 0|T\int d^4 x \exp(i\mathcal{L}_{\mathrm{int}})|0\rangle}
\end{aligned}
\end{equation*}
Since the scattering process correspond to the connected diagram, meaning that the initial and final state has distinct momentum particles.
We are free to make the substitution
\begin{equation*}
	a^\dagger_{\mathrm{in}} \rightarrow (a_{\mathrm{in}}^\dagger - a_{\mathrm{out}}^\dagger),\
	a_{\mathrm{out}} \rightarrow -(a_{\mathrm{in}}^\dagger - a_{\mathrm{out}}^\dagger)^\dagger.
\end{equation*}
In this way, the S-matrix is
\begin{equation}
\begin{aligned}
	& \langle p_1, \cdots, p_n| S |k_1, \cdots, k_m\rangle  \\
	=& \prod_{i=1}^{m}\left[ \int d^dx_i \ e^{ip_i\cdot x_i}i(\partial^2+m_i^2)\right]
	\prod_{j=m+1}^{m+n}\left[\int d^dx_j \ e^{-ik_j\cdot x_j}i(\partial^2+m_j^2)\right] iG(\{x\}).
	\label{eq:K-G-LSZ}
\end{aligned}
\end{equation}
In momentum space
\begin{equation}
	\mathcal M = \prod_{i=1}^{m}\left[\frac{p_i^2-m_i^2}{i\sqrt{Z_\phi}}\right]
		\prod_{j=m+1}^{m+n}\left[\frac{k_j^2-m_j^2}{i\sqrt{Z_\phi}}\right]
		\tilde{G}(\{p_i\};\{-k_j\}).
\end{equation}
We thus proved the LSZ reduction formula again.

Note that in the second equality, we move the operator $\partial^2$ out of the time-ordering operator, which will actually create \textit{contact terms}.
We will show the contact term can be safely neglected.
To see this, first consider the time-ordered two-point function:
\begin{equation}
	\langle 0|T\phi(x_1)\phi(x_2)|0\rangle
	= \theta(t_1-t_2)\langle 0|\phi(x_1)\phi(x_2)|0\rangle -
	\theta(t_2-t_1)\langle 0|\phi(x_2)\phi(x_1)|0\rangle.
\end{equation}
Take time derivative on both side:
\begin{equation*}
\begin{aligned}
	\partial_{t_1} \langle 0|T\phi(x_1)\phi(x_2)|0\rangle
	&= \langle 0|T\partial_{t_1}\phi(x_1)\phi(x_2)|0\rangle +
	\delta(t_1-t_2)\langle 0|[\phi(x_1),\phi(x_2)]|0\rangle \\
	&= \langle 0|T\partial_{t_1}\phi(x_1)\phi(x_2)|0\rangle.
\end{aligned}
\end{equation*}
The second equality follows from the fact that $x_1,x_2$ is equal-time.
Take the the time derivative once more:
\begin{equation*}
	\partial^2_{t_1} \langle 0|T\phi(x_1)\phi(x_2)|0\rangle
	= \langle 0|T\partial^2_{t_1}\phi(x_1)\phi(x_2)|0\rangle +
	\delta(t_1-t_2)\langle 0|[\partial_{t_1}\phi(x_1),\phi(x_2)]|0\rangle.
\end{equation*}
The second term on the right hand side is the contact term.
For free theory, $\partial_{t_1}\phi(x_1)$ is the canonical momentum, meaning that
\begin{equation}
	[\phi(\vec x_1, t),\partial_{t}\phi(\vec x_1,t)] = i \delta^{3}(\vec x_1-\vec x_2).
\end{equation}
In general, for $n$-point correlation,
\begin{equation}
\begin{aligned}
	 \partial_{t_1}^2 \langle T\phi_{x_1}\cdots\phi_{x_n} \rangle
	= \langle T\partial_{t_1}^2\phi_{x_1}\cdots\phi_{x_n}\rangle -i \sum_j \delta^4(x_1-x_j)\langle T\phi_{x_2}\cdots\cancel{\phi_{x_j}}\cdots\phi_{x_n}\rangle.
\end{aligned}
\end{equation}
In the LSZ formula, the contact term do not have any singularity.
When the external legs approach to momentum shell, these regular terms vanishes, so the contact will not contribute to the S-matrix.

\subsection{LSZ for Dirac Field}
Use the field expansion
\begin{equation}
\begin{aligned}
	\psi(x) &=\int \frac{d^{3} p}{(2 \pi)^{3}} \frac{1}{\sqrt{2 \omega_{\mathbf{p}}}}
		\sum_{s}\left(a_{\mathbf{p}}^{s} u^{s}(p) e^{-i p \cdot x}
		+b_{\mathbf{p}}^{s \dagger} v^{s}(p) e^{i p \cdot x}\right), \\
	\bar{\psi}(x) &=\int \frac{d^{3} p}{(2 \pi)^{3}} \frac{1}{\sqrt{2 \omega_{\mathbf{p}}}}
		\sum_{s}\left(b_{\mathbf{p}}^{s} \bar{v}^{s}(p) e^{-i p \cdot x}
		+a_{\mathbf{p}}^{s \dagger} \bar{u}^{s}(p) e^{i p \cdot x}\right),
\end{aligned}
\end{equation}
and the orthogonality relation
\begin{equation}
\begin{aligned}
	u^{r \dagger}(p) u^{s}(p) &= 2 \omega_{\bm p} \delta^{r s}, &
	u^{r \dagger}(\bm p,\omega_{\bm p}) v^{s}(-\bm p,\omega_{\bm p}) &= 0,\\
	v^{r \dagger}(p) v^{s}(p) &= 2\omega_{\bm p} \delta^{r s}, &
	v^{r \dagger}(\bm p,\omega_{\bm p}) u^{s}(-\bm p,\omega_{\bm p}) &= 0.
\end{aligned}
\end{equation}
The spatial Fourier transformation gives:
\begin{equation}
	\int d^3x e^{ip\cdot x}\psi(x) = \frac{1}{\sqrt{2\omega_{\bm p}}}\sum_s a^s_{\bm p}u^s(p) +\frac{1}{\sqrt{2\omega_{\bm p}}}\sum_s b^{s \dagger}_{\bm p} v^s(-\bm p,\omega) e^{2i\omega t}
\end{equation}
Left-multiply on both hand side by $\bar u^{s}(p) \gamma^0$, we then get
\begin{equation}
\begin{aligned}
	\sqrt{2\omega_{\bm p}}a^{s}_{\bm p} &= \int d^3 x e^{ip\cdot x}\bar u^{s}(p)\gamma^0 \psi(x), \\
	\sqrt{2\omega_{\bm p}}a^{s \dagger}_{\bm p} &= \int d^3 x e^{-ip\cdot x}\bar\psi(x)\gamma^0 u^{s}(p).
\end{aligned}
\end{equation}
Similarly, we consider
\begin{equation}
	\int d^3x e^{ip\cdot x}\bar\psi(x) = \frac{1}{\sqrt{2\omega_{\bm p}}}\sum_s b^s_{\bm p}\bar v^s(p) +\frac{1}{\sqrt{2\omega_{\bm p}}}\sum_s a^{s \dagger}_{\bm p} \bar u^s(-\bm p,\omega) e^{2i\omega t}
\end{equation}
Right-multiply on both hand side by $\gamma^0 v^{s}(p)$, we then get
\begin{equation}
\begin{aligned}
	\sqrt{2\omega_{\bm p}}b^{s}_{\bm p} &= \int d^3 x e^{ip\cdot x}\bar\psi(x)\gamma^0 v^s(p), \\
	\sqrt{2\omega_{\bm p}}b^{s \dagger}_{\bm p} &= \int d^3 x e^{-ip\cdot x}\bar v^s(p)\gamma^0 \psi(x).
\end{aligned}
\end{equation}
Following the same strategy as we did for the scalar field, we consider
\begin{equation}
\begin{aligned}
	\sqrt{2\omega_{\bm p}}a^{s}_{\bm p;\mathrm{out}} -
	\sqrt{2\omega_{\bm p}}a^{s}_{\bm p;\mathrm{in}}
	&= \int dt\ \partial_t \sqrt{2\omega_{\bm p}}a^s_{\bm p} \\
	&= \int dt\ \int d^3x e^{ip\cdot x}\bar u(p)(\gamma^0 \partial_t +i\gamma^0 p^0)\psi(x) \\
	&= \int d^4x e^{ip\cdot x}\bar u(p)(\gamma^0 \partial_t +i\gamma^i p^i +i m)\psi(x) \\
	&= i\int d^4x e^{ip\cdot x}\bar u(p)(-i\cancel\partial + m)\psi(x)
\end{aligned}
\end{equation}
where we have used the fact $\bar u(p) (\cancel p - m) = 0$.
Take hermitian conjugate,
\begin{equation}
\begin{aligned}
	\sqrt{2\omega_{\bm p}}a^{s \dagger}_{\bm p;\mathrm{in}} -
	\sqrt{2\omega_{\bm p}}a^{s \dagger}_{\bm p;\mathrm{out}}
	&= i\int d^4x e^{-ip\cdot x}\bar\psi(x)\gamma^0(-i\cancel\partial + m)^\dagger \gamma^0 u(p) \\
	&= i\int d^4x e^{-ip\cdot x}\bar\psi(x)(i \overleftarrow{\cancel\partial} + m) u(p)
\end{aligned}
\end{equation}
Similarly, using the fact $(\cancel p + m)v(p) =0$,
\begin{equation}
\begin{aligned}
	\sqrt{2\omega_{\bm p}}b^{s}_{\bm p;\mathrm{out}} -
	\sqrt{2\omega_{\bm p}}b^{s}_{\bm p;\mathrm{in}}
	&= \int d^4x e^{ip\cdot x}\bar\psi(x)(\gamma^0 \overleftarrow{\partial_t} +i\gamma^0 p^0)v(p) \\
	&= \int d^4x e^{ip\cdot x}\bar\psi(x)(\gamma^0 \overleftarrow{\partial_t} +i\gamma^i p^i -i m)v(p) \\
	&= -i\int d^4x e^{ip\cdot x}\bar\psi(x)(i\overleftarrow{\cancel\partial} + m)v(p).
\end{aligned}
\end{equation}
Again, take the hermitian conjugate,
\begin{equation}
\begin{aligned}
	\sqrt{2\omega_{\bm p}}b^{s \dagger}_{\bm p;\mathrm{in}} -
	\sqrt{2\omega_{\bm p}}b^{s \dagger}_{\bm p;\mathrm{out}}
	&= -i\int d^4x e^{ip\cdot x}\bar v(p)\gamma^0(i\overleftarrow{\cancel\partial} + m)^\dagger \gamma^0 \psi(x) \\
	&= -i\int d^4x e^{-ip\cdot x}\bar v(p)(-i \cancel\partial + m) \psi(x)
\end{aligned}
\end{equation}
The same strategy gives the LSZ reduction formula for Dirac field.
Consider the S-matrix for particles:
\begin{equation}
\begin{aligned}
	& \langle p_1, \cdots, p_n| S |k_1, \cdots, k_m\rangle  \\
	=& \prod_{i=1}^{m}\left[ \int d^dx_i \ e^{ip_i\cdot x_i} u^{s_1}(p_i)\frac{i\cancel\partial-m_i}{i\sqrt{Z_\phi}}\right] iG(\{x\})
	\prod_{j=m+1}^{m+n}\left[\int d^dx_j \ e^{-ik_j\cdot x_j}\frac{-i\overleftarrow{\cancel\partial}-m_j}{i\sqrt{Z_\phi}}u^{s_j}(k_j)\right].
\end{aligned}
\end{equation}
In the momentum space:
\begin{equation}
	\mathcal M = \prod_{i=1}^{m}\left[\frac{\cancel p-m_i}{i\sqrt{Z_\phi}}u^{s_i}(p_i)\right]
		\tilde{G}(\{p_i\};\{-k_j\})
		\prod_{j=m+1}^{m+n}\left[u^{s_j}(k_j)\frac{\cancel k-m_j}{i\sqrt{Z_\phi}}\right].
\end{equation}


\section{Experiment}
While the modified Count-min sketch algorithm provides an error bound for the
estimated movie averages, what we are really interested in is how much it
affects the ordering of the movies when sorted by these estimated averages
compared to the real averages. In this section, we evaluate the modified
Count-min sketch algorithm by running it on real-life data, and comparing the
order it produces with the correct order.

We quantify the error in ordering by the Kendall tau distance. For a permutation
of movies $\pi$, we say that $x <_\pi y$ if $x$ comes before $y$ in $\pi$. The
Kendall tau distance between two orderings of our movie set is then $\mathrm{KT}
\left(\pi_1,\pi_2\right) = \left|\{x,y\}: x <_{\pi_1} y \wedge y <_{\pi_2}
x\right|$. The Kendall distance is often normalized to the maximum number of
inversions between the orderings, $n(n-1)/2$ for $n$ elements. We expect random
orderings to have a normalized Kendall tau distance of $\frac{1}{2}$, so
only results with a lower distance can be considered useful.

\subsection{Results}
Our data is sampled from the \textit{Netflix
Prize}\footnotemark \ data set.
The full data set contains more than 100 million user ratings, for more than 17
thousand movies.
We test the algorithm on three samples of the \texttt{Netflix} data:

\footnotetext{http://academictorrents.com/details/9b13183dc4d60676b773c9e2cd6de5e5542cee9a}
\begin{itemize}
	\item \textit{100M ratings} contains all ratings for the $13726$ most
		frequently rated movies. Roughly 100 million ratings total,
	\item \textit{50Mmin ratings} contains all ratings for the $17146$ least
		frequently rated movies. Roughly 50 million ratings total,
	\item \textit{50M ratings} contains all ratings for the $611$ most
		frequently rated movies. Roughly 50 million ratings total,
	\item \textit{min10K ratings} contains all ratings for the $2042$ movies that have more
		than $10.000$ ratings.

\end{itemize}

\pgfplotsset{scaled x ticks=false}
\begin{center}
\begin{tikzpicture}
\begin{axis}[
	title=Count-min order error,
	xlabel={Error bound $\varepsilon$},
	ylabel={KT. norm.},
	legend pos=south east,
	xticklabel style={
		/pgf/number format/.cd,
		fixed,
		fixed zerofill,
		precision=3,
		/tikz/.cd
	},
]
\addplot table [y=100M,x=E]{allresults};
\addlegendentry{\textit{100M ratings}}
\addplot table [y=50M,x=E]{allresults};
\addlegendentry{\textit{50M ratings}}
\addplot table [y=min10K,x=E]{allresults};
\addlegendentry{\textit{min10K ratings}}
\addplot table [y=50Mmin,x=E]{allresults};
\addlegendentry{\textit{50Mmin ratings}}
\end{axis}
\end{tikzpicture}
\end{center}

All trials are run with $\delta = 0.01$.

As expected, the algorithm performs much worse on the large, $100M raitings$
dataset than on the smaller data sets.
For $\varepsilon = 0.001$, the normalized Kendall-Tau distance is $0.33$, and it
rapidly approaches $0.5$.

The obvious explanation is the error's dependency on the length of the stream,
but there is another factor at play.

Because of the way the Count-Min algorithm works --- adding up the ratings when the
hash functions have collisions --- there is a tendency that movies with fewer
ratings will cause inversions more often than movies with many ratings.
Futhermore, we see that that the algorithm performs reasonable well in the two
other data sets, containing only movies with many ratings.

We see however, that in order to save memory compared to the simple
approaches described in section \ref{sec:sorting}, we have to accept a
normalized Kendall tau distance of at least $0.1$, or choose a higher value for $\delta$

\subsection{Implementation}
The implementation can be found in the appendices.
We Note that the implementation does not live up to the performance
bounds stated in section \ref{sec:sketching}. This is not a problem, since we
are assessing the correctness of the algorithm, not it's throughput. The
implementation differs in two ways: To emulate querying all data points, a list
of all observed movies is kept, requiring $O(|U|)$ extra memory. Furthermore the
ratings are sorted when queried, rather than maintaining the ordering
dynamically. Again, this does not effect the experiment.


\documentclass{article}
    \usepackage{subcaption}
    \usepackage{amsmath, amssymb}
    \usepackage{graphicx, float}
    \usepackage[hidelinks]{hyperref}
    \usepackage[bottom]{footmisc}
    \usepackage[margin=.8in, tmargin=.8in]{geometry}
    \usepackage{esint} % for double line integrals

    \renewcommand{\baselinestretch}{1.2}
    \newcommand{\eps}{\epsilon}
    \newcommand{\der}{\partial}
    \newcommand{\del}{\nabla}
    \newcommand{\bm}[1]{\mathbf{#1}}
    \newcommand{\vf}[1]{\vec{\mathbf{#1}}}
    \newcommand{\norm}{\hat{\bm{n}}}

    \setlength\parindent{0pt}
    \captionsetup{justification=centering}

    \title{Vector Calculus}
    \date{\today}
    \author{Traiko Dinev \textless traiko.dinev@gmail.com\textgreater}

\begin{document}
\maketitle

\textit{NOTE: This partially follows Engineering Mathematics 2, a second year engineering course at the University of Edinburgh and partially follows MIT's 18.02, Multivariable Calculus.}

\textit{NOTE: Note this "summary" is NOT a reproduction of the course materials nor is it copied from the corresponding courses. It was entirely written and typeset from scratch.}

\textit{License: Creative Commons public license; See README.md of repository}

\textit{NOTE: Images are to be added soon!}

\section{Introduction}

Define the following:

\begin{align*}
    \del &=
        \bigg\langle
            \frac{\partial}{\partial x},
            \frac{\partial}{\partial y},
            \frac{\partial}{\partial z}
        \bigg\rangle
            && \text{gradient vector} \\
    \del f &=
        \bigg\langle
            \frac{\partial f}{\partial x},
            \frac{\partial f}{\partial y},
            \frac{\partial f}{\partial z}
        \bigg\rangle
            && \text{vector derivative}\\
    %
    \vf{F} &=
        \langle
            f(x, y, z), g(x, y, z), h(x, y, z)
        \rangle =
        f(...) \mathbf{i} + g(...)\mathbf{j} + h(...) \mathbf{k}
            && \text{Vector field}\\
    %
    \del \cdot \vf{F} &=
        \frac{\der f(x, y, z)}{\der x} +
        \frac{\der g(x, y, z)}{\der y} +
        \frac{\der h(x, y, z)}{\der z}
            && \text{Divergence (dot product)} \\
    %
    \del \times \vf{F} &=
        \begin{pmatrix}
            i & j & k \\
            \frac{\der}{\der x} &
                \frac{\der}{\der x} &
                    \frac{\der}{\der x} \\
            f(...) & g(...) & h(...)
        \end{pmatrix}
            && \text{Curl (cross product)} \\
\end{align*}

Gradients are just the derivatives in each dimension. Vector fields define a vector at each point in space, as defined by (x, y, z).
\vskip 0.1in
Here divergence gives the change in the vector field outwards (source of flux). This can also be defined as the limit of the net flow. Curl defines a rotational field (3D). It is the limit of the path integral. These two are neat relations, but I've never actually had to use them:

\begin{align*}
    \del \cdot \vf{F} &=
        \lim_{V \to p} \iint
            \frac{\vf{F} \cdot \norm}{|V|} dS \\
    (\del \times \vf{F}) \cdot \norm &=
        \lim_{A \to 0}\frac{1}{|A|} \int_c \vf{F} \cdot d\vf{r}
\end{align*}

\section{Double Integrals}
On to double (and triple) integrals. A double integral is just two single integrals stacked together. These are good to know:

\begin{align*}
    &\iint_R dA && \text{Area of R} \\
    &\iint_R \rho\ dA && \text{Mass, where $\rho$ is the density} \\
    &\bar{x} = \frac{1}{M}\iint_R x\ \rho\ dA && \text{Center of mass} \\
    &\iint_R r^2\ \rho\ dA && \text{Moment of intertia, $r$ is the distance from the axis}
\end{align*}

\subsection{Change of Variables}
Let:

\begin{align*}
    u &= u(x, y) \\
    v &= v(x, y)
\end{align*}

then:
\begin{equation*}
dx dy = \bigg|\frac{\der(u, v)}{\der(x, y)}\bigg|^{-1} du dv = \begin{pmatrix} \frac{\der u}{\der x} & \frac{\der u}{\der y} \\ \frac{\der v}{\der x} & \frac{\der v}{\der y} \end{pmatrix} du dv
\end{equation*}

This is derived from the following, which is just from the definition of derivatives:
\begin{equation*}
    \begin{pmatrix}\Delta u \\ \Delta v\end{pmatrix} \approx
        \begin{pmatrix}
            \frac{\der u}{\der x} & \frac{\der u}{\der y} \\
             \frac{\der v}{\der x} & \frac{\der v}{\der y}
        \end{pmatrix}
        \begin{pmatrix} \Delta x \\ \Delta y \end{pmatrix}
\end{equation*}

Or you could consider a parallelogram.. check out MIT's derivation for this one.

\section{Line Integration}
Consider a vector field $\vec{\mathbf{F}}$ and a path $c$. This could be a line or some parametric curve as defined by:

\begin{align}
    x &= x(t) \\
    y &= y(t) \\
    \vf{r} &= (x(t), y(t)) \\
    \frac{d\vec{r}}{dt} &= \langle \frac{dx}{dt}, \frac{dy}{dt} \rangle
\end{align}

for $t$ between 0 and 1. Or any other limit, but you can always scale it. You could also have more parameters.
\vskip 0.1in
Then the line (or path) integral is defined as follows:
\begin{equation*}
    \int_c \vf{F} \cdot d\vf{r} =
        \int_c Mdx + Ndy + Pdz = \int_c \vf{F} \cdot \vf{T} ds
\end{equation*}

Here $\vf{F} = (M, N, P)$ but the summation is not three separate integrals. Change of variables is needed. $\vf{T}$ is a tangent vector to the curve. $ds$ is the change along the curve.
\vskip 0.1in
Perhaps a better way to view this is by considering that work is force times distance: $W = \vf{F} \cdot \Delta \vf{r}$. Note this is a dot product between the force vector and the r defined above. When we sum, we obtain the integral:
\begin{equation}
    W = \lim_{i \to \infty} \sum_i \vf{F} \cdot \Delta \vf{r}_i = \int_C \vf{F} \cdot d\vf{r}
\end{equation}

Now we can break this up using the parametrization of $\vf{r}(t)$ above to arrive at:

\begin{equation}
    \int_c \vf{F} \cdot \Delta \vf{r} = \int_{0}^{1} (\vf{F} \cdot \frac{d\vf{r}}{dt})\ dt
\end{equation}

If you want a more rigorous derivation, you can start with the definition of derivatives and take the limit. The above is how we usually calculate line integrals. Note the derivative of r is just a vector, as defined above in (4). So path integrals are in reality just single variable integrals. Neat-o.
\vskip 0.1in
We can also do the integral in normal form. As opposed to a dot product with the tangent vector $\vf{T}$ we consider the (perpendicular) normal vector $\norm$. This is defined as the \textbf{flux} of the vector field $\vf{F}$. The flux measures how much "stuff" would be displaced by the vector field for a unit of time. It actually technically measures the force through a curve. Useful for magnetic fields:

\begin{equation}
    \int_c \vf{F} \cdot \norm\ ds \approx \sum_i (\vf{F} \cdot \norm)\ \Delta \vec{s}_i
\end{equation}

\textit{TODO: Insert parallelogram picture of normal and tangential path integrals and derivation.}

\subsection{Gradient Field Theorem}
\textit{A.k.a. the fundamental theorem of (vector) calculus}
If $\vf{F}$ is a gradient field, i.e. $\vf{F} = \nabla f$.

\begin{equation}
    \int_c \vf{F} \cdot d\vf{r} = \int \nabla f \cdot d\vf{r} = f(p_1) - f(p_0)
\end{equation}

where $p_0$ and $p_1$ are the endpoints of the curve $c$. A.k.a Stoke's theorem in 2D. \textit{TODO: add intuition}

\subsection{Green's Theorem}
This, where $c$ is counter-clockwise:

\begin{equation}
    \oint_c \vf{F} \cdot d\vf{r} = \iint_R (\nabla \times \vf{F})\ dA
\end{equation}

where $R$ is the region bounded by $c$.
\vskip 0.1in
Green's theorem also works for normal form (flux) integrals. Also known as the divergence theorem when we do in 3D.

\begin{equation}
    \oint_c \vf{F} \cdot \norm\ ds = \iint_R (\nabla \cdot \vf{F})\ dA
\end{equation}

\section{Triple Integration}
Area integrals become volume integrals:

\begin{align*}
    &\iiint_R dV && \text{volume} \\
    &dV = dx\ dy\ dz \\
    &\iiint_R \rho\ dV && \text{Mass} \\
    &\hat{f} = \frac{1}{\text{Volume}(R)}
        \iiint_R f\ dV && \text{Center of mass} \\
    &\iiint_R (\text{distance to axis})^2\delta\ dV
        && \text{Moment of inertia} \\
    &\mathbb{I}_z = \iiint_R (x^2 + y^2)^2\delta\ dV
        && \text{Moment of inertia around z-axis} \\
\end{align*}

\subsection{Cylindrical Coordinates}
\textit{TODO: add image}

\begin{align*}
    x &= \rho\ \cos \phi \\
    y &= \rho\ \sin \phi \\
    z &= z \\
    dV &= r\ dr\ d\theta\ dz
\end{align*}

\subsection{Spherical Coordinates}
\textit{TODO: add image}

\begin{align*}
    x = r\ \cos\theta = \rho \sin\phi\ \cos\theta\\
    y = r\ \sin\theta = \rho \sin\phi\ \sin\theta\\
    z = \rho \cos\theta \\
    dV = \rho^2 \sin\phi\ d\rho\ d\phi\ d\theta
\end{align*}

\section{Surface Integrals}
\textit{TODO: add image}
Natural extension to normal integration (see path integral) to three dimensions. This gives us the amount of "stuff" that goes through a patch in 3D. A patch (surface) would be the equivalent of a parametric curve in 2D.

\begin{equation}
    \iint_S \vf{F} \cdot d\vf{S} = \iint_S \vf{F} \cdot \norm\ dS
\end{equation}

Here $d\vf{S} = \norm\ dS$. Now these are a pain to calculate, but there are shortcuts:

\subsection{On a sphere}
\begin{equation*}
    dS = r^2\ \sin\phi\ d\phi\ d\theta
\end{equation*}

Here the normal vector is $\norm = \pm \frac{1}{a} \langle x, y, z \rangle$.

\subsection{Horizontal plane}
Three separate cases, we will consider when $z = a$. Hence:
\begin{align*}
    z &= a \\
    \norm &= \pm \mathbf{\hat{k}} \\
    dS &= dx\ dy
\end{align*}

\subsection{Cylinder of $r = a$ centered on the z axis}
\begin{align*}
    \norm &= \pm \langle x, y, 0, \rangle \frac{1}{a} \\
    dS &= a\ dz\ d\theta
\end{align*}

\subsection{Graph of function}
\begin{align*}
    z &= f(x, y) \\
    \norm\ dS &= \pm \langle -f_x, -f_y, 1\rangle\ dx\ dy
\end{align*}

\subsection{Parametric Surface}
\begin{align*}
    x &= x(u, v) \\
    y &= y(u, v) \\
    z &= z(u, v) \\
    \norm\ dS &= \pm
        \bigg(\frac{\der \vf{r}}{\der u}
            \times \frac{\der \vf{r}}{\der v} \bigg) du\ dv
\end{align*}

here $\times$ is a cross product. Why? Stay tuned.. I might add a derivation. Check MIT's course.

\subsection{Slanted plane with normal $\mathbf{\hat{N}}$}
\textit{TODO}

\section{Divergence Theorem}
This is the 3D analogue of Green's theorem for flux in 2D. If:

\begin{itemize}
    \item $S$ encloses $D$ in space, where $S$ is a closed surface
    \item $\norm$ is the normal vector pointing
        \textit{outwards} and $\vf{F}$ is defined and differentiable within $D$
\end{itemize}

Then:
\begin{equation}
    \oiint_S \vf{F} \cdot d\vf{S} = \iiint_D \nabla \cdot \vf{F}\ dV
\end{equation}

This means the total stuff escaping $S$ is the net sum of all the sources within it.

\section{Stoke's Theorem}
If $C$ is a closed curve and $S$ is any surface bounded by C.

\begin{equation}
    \oint_C \vf{F} s\vf{r} = \iint_S (\nabla \times \vf{F}) \cdot \norm \ dS
\end{equation}

If I walk along $C$ with $S$ to my left, then $\norm$ is pointing up.

\end{document}