% declare document class and geometry
\documentclass[12pt]{article} % use larger type; default would be 10pt
\usepackage[margin=1in]{geometry} % handle page geometry

% import packages and commands
\input{../header.tex}

\title{Phys 221A -- Quantum Mechanics -- Lec02}
\author{UCLA, Fall 2014}
\date{\formatdate{08}{10}{2014}} % Activate to display a given date or no date (if empty),
         % otherwise the current date is printed

\begin{document}
\maketitle

\section{Introduction}

Preliminary notes
\begin{itemize}
\item TA (Shahriar) office hours changed: Wednesday 3-4 PM in Knudsen 3-111.
\end{itemize}

\subsection{More on Hilbert spaces}

From now on we will be living in Hilbert space $G$ with vectors, for example $\psi$ or $\phi$. Recall that in the bra-ket notation we have $\psi = | \psi \rangle$ in the Hilbert space, a ``ket''. The inner product is given by
\begin{equation}
\begin{matrix}
G \times G & \rightarrow & \mathbb{C} \\
\ket{\phi}, \ket{\psi} & \mapsto & \braket{\phi}{\psi}.
\end{matrix}
\end{equation}
We write elements in the dual space as $\bra{\psi}$, a ``bra''. This is a linear map taking $G \rightarrow \mathbb{C}$ and mapping $\ket{\phi} \mapsto \braket{\psi}{\phi}$.

Consider an operator $O : G \rightarrow G$ mapping $\ket{\psi} \mapsto O \ket{\psi}$. For example, $O = \ket{\phi} \bra{\psi}$ for some $\phi, \psi \in G$. Then
\begin{equation}
O \ket{\xi} = (\ket{\phi} \bra{\psi}) \ket{\xi} = \ket{\phi} \braket{\psi}{\xi}.
\end{equation}
Given operators $A, B, C$ we have
\begin{equation}
(AB) \ket{\psi} = A (B \ket{\psi}), \qquad ABC = A(BC) = (AB)C.
\end{equation}
Recall the closure relation
\begin{equation}
1 = \sum_i \ket{\alpha_i} \bra{\alpha_i}
\end{equation}
where $\set{ \ket{\alpha_i} }$ forms an orthonormal basis (so $\braket{\alpha_i}{\alpha_j} = \delta_{ij}$).

Given an operator $O$, we have that $O$ is linear iff
\begin{equation}
O (c_1 \ket{\psi_1} + c_2 \ket{\psi_2}) = c_1 O \ket{\psi_1} + c_2 O \ket{\psi_2}
\end{equation}
for all $c_i \in \mathbb{C}$, $\ket{\psi_i} \in G$. The operator $O^\dagger$ is the Hermitian conjugate or adjoint of $O$ iff
\begin{equation}
\braket{\psi}{O\phi} = \braket{O^\dagger \psi}{\phi}
\end{equation}
for all $\psi, \phi \in G$. If $O^\dagger$ is the adjoint then $(O^\dagger)^\dagger = O$ and furthermore $\braket{O\phi}{\psi} = \braket{\phi}{O^\dagger \psi}$.

If $O^\dagger = O$ then $O$ is Hermitian or self-adjoint. If $UU^\dagger = 1$ (i.e. $U^\dagger = U^{-1}$) then $U$ is called unitary. Note that we have
\begin{equation}
\bra{O\psi} = \bra{\psi} O^\dagger,
\end{equation}
or in other words
\begin{equation}
\braket{O\psi}{\phi} = \bra{\psi} O^\dagger \ket{\phi} = \braket{\psi}{O^\dagger \phi}.
\end{equation}

A physical observable, i.e. a dynamical variable, must be represented by a linear operator $O$. Given a physical state $\psi$, where $\braket{\psi}{\psi} = 1$, the ``expectation value'' of $O$ in the state $\ket{\psi}$ is given by
\begin{equation}
\avg{O} = \braket{\psi}{O\psi}.
\end{equation}
Note that if $O$ is Hermitian, i.e. $O = O^\dagger$, then $\avg{O} \in \mathbb{R}$ for any $\psi$.

\subsection{Representation in a basis}

In an orthonormal basis $\ket{\alpha_i}$ we have
\begin{equation}
\ket{\psi} = \sum_i \ket{\alpha_i} \braket{\alpha_i}{\psi} = \sum_i c_i \ket{\alpha_i}
\end{equation}
so we can write
\begin{align}
O \ket{\psi} &= O \sum_i c_i \ket{\alpha_i} = \sum_i c_i O \ket{\alpha_i} \\
	&= \sum_{ij} c_i \ket{\alpha_j} \bra{\alpha_j} O \ket{\alpha_i}.
\end{align}
Thus we can write $O\ket{\psi}$ in the basis as $\sum_j b_j \ket{\alpha_j}$ where $b_j = \sum_i O_{ji} c_i$ and
\begin{equation}
O_{ij} = \bra{\alpha_i} O \ket{\alpha_j}
\end{equation}
is called the matrix element.

There is a one-to-one map from vectors $\psi$ to column vectors $\v{c} = (c_1, \dots, c_n)^\top$ (where $n = \opname{dim} G$) such that $\psi = \sum_i c_i \ket{\alpha_i}$, as well as a map from operators $O$ to $n \times n$ matrices $\hat{O} = (O_{ij})$. Thus we can write $G \cong \mathbb{C}^n$ (note that $n$ is not necessarily finite). Note that given a vector $\phi$ represented by $\v{b}$, we can write $\braket{\phi}{\psi} = \v{b}^\dagger \cdot \v{c}$. Furthermore if $\ket{\phi} = O \ket{\psi}$ then $\v{b} = \hat{O} \v{c}$.

A Hermitian operator $O$ corresponds to a Hermitian matrix $\hat{O}$, and similarly a unitary operator $U$ corresponds to a unitary matrix $\hat{U}$. Thus given Hermitian $O$ and unitary $U$ we have $O_{ij} = O_{ji}^*$ and $\hat{U} \hat{U}^\dagger = \hat{1}$. Given two orthonormal bases $\set{ \ket{\alpha_i} }$ and $\set{ \ket{\alpha'_i} }$ we can always write $\hat{O}' = \hat{U}^\dagger \hat{O} \hat{U}$ where $U_{ij} = \braket{\alpha_i}{\alpha_j'}$ and happens to be unitary. We can show this last statement:
\begin{equation}
(\hat{U} \hat{U}^\dagger)_{ij} = \sum_k U_{ik} U_{jk}^* = \sum_k \braket{\alpha_i}{\alpha'_k} \braket{\alpha'_k}{\alpha_j} = \braket{\alpha_i}{\alpha_j} = \delta_{ij}.
\end{equation}

A little more on operators. We define
\begin{align}
[A,B] &= AB - BA, \qquad \text{the commutator, and} \\
\set{ A,B } &= AB + BA, \qquad \text{the anti-commutator}.
\end{align}
Then we have
\begin{align}
AB &= \frac{1}{2} [A,B] + \frac{1}{2} \set{A,B} \\
	&= BA = -\frac{1}{2} [A,B] + \frac{1}{2} \set{A,B}
\end{align}
Notice that $\set{A,B}$ is Hermitian and $[A,B]$ is anti-Hermitian ($O^\dagger = -O$). Furthermore, if $A$ and $B$ are Hermitian then
\begin{equation}
(AB)^\dagger = B^\dagger A^\dagger = BA \neq AB.
\end{equation}
Finally we can split any operator $O$ into a Hermitian part $\zeta_+$ and an anti-Hermitian part $\zeta_-$:
\begin{equation}
O = \frac{1}{2} (\zeta_+ + \zeta_i), \quad \zeta_+ = O + O^\dagger, \quad \zeta_- = O - O^\dagger.
\end{equation}

\subsection{Onward to physics}

The eigenvectors of a Hermitian operator yield a complete orthonormal basis. If $A$ and $B$ are Hermitian operators and $[A,B] = 0$ then the operators yield a complete set of simultaneous eigenvectors (which form an orthonormal basis). When this happens we call $A, B$ compatible observables.

In the hydrogen atom we have quantum numbers:
\begin{itemize}
\item principle quantum number $n = 1, 2, \dots$ where $E \sim -1/n^2$, eigenvalues of the Hamiltonian $H$,
\item angular momentum quantum number $\ell = 0, 1, \dots, n-1$, eigenvalues of $L^2$,
\item magnetic quantum number $m = -\ell, \dots, \ell$, eigenvalues of $L_z$,
\item spin quantum number $s = \pm 1/2$, eigenvalues of $S_z$.
\end{itemize}
We can show that
\begin{equation}
[H, L^2] = [L^2, L_z] = [H, L_z] = 0
\end{equation}
so that $H, L^2, L_z$, and $S_z$ are compatible observables uniquely identified by their quantum numbers $(n,\ell,m,s)$.

Generally, a complete set of compatible observables whose eigenvalues, or quantum numbers, uniquely label their common eigenvectors (resolving all degeneracies). Thus each $\ket{\alpha_i}$ in the corresponding orthonormal basis is labelled by the set of quantum numbers. Typically this complete set is provided by $H$ and corresponding symmetry generators.

\begin{comment}
\begin{figure}
\centering
\includegraphics{3a.pdf}
\caption{Half the diagrams for photon-photon scattering.}
\label{fig:3a}
\end{figure}
\end{comment}

\end{document}


\documentclass[12pt]{article}
\usepackage[margin=2cm]{geometry}
\usepackage{amsmath}
\usepackage{slashed}
\usepackage{tikz}

\begin{document}

\noindent
The following diagram shows the geometry of a typical collider experiment
that generates electron scattering data.
\begin{center}
\begin{tikzpicture}
\draw[dashed] (0,0) circle (0.5cm);
\draw[thick,->] (2,0) node[anchor=west] {$e^-$} -- (0.6,0);
\draw[thick,->] (-2,0) node[anchor=east] {$e^-$} -- (-0.6,0);
\draw[thick,->] (0.40,0.40) -- (1.3,1.3) node[anchor=south west] {$e^-$};
\draw[thick,->] (-0.4,-0.4) -- (-1.3,-1.3) node[anchor=north east] {$e^-$};
\draw (1,0.5) node {$\theta$};
\end{tikzpicture}
\end{center}

\noindent
Here is the same diagram with momentum labels $p$ and Dirac spinor labels $u$.

\begin{center}
\begin{tikzpicture}
\draw[dashed] (0,0) circle (0.5cm);
\draw[thick,->] (2,0) node[anchor=west] {$p_2, u_2$} -- (0.6,0);
\draw[thick,->] (-2,0) node[anchor=east] {$p_1, u_1$} -- (-0.6,0);
\draw[thick,->] (0.40,0.40) -- (1.3,1.3) node[anchor=south west] {$p_3, u_3$};
\draw[thick,->] (-0.4,-0.4) -- (-1.3,-1.3) node[anchor=north east] {$p_4, u_4$};
\draw (1,0.5) node {$\theta$};
\end{tikzpicture}
\end{center}

\noindent
In center of mass coordinates the momentum vectors are
\begin{align*}
p_1&=
\underset{\substack{\phantom{0}\\ \text{particle 1}}}
{\begin{pmatrix}E\\0\\0\\p\end{pmatrix}}
&
p_2&=
\underset{\substack{\phantom{0}\\ \text{particle 2}}}
{\begin{pmatrix}E\\0\\0\\-p\end{pmatrix}}
&
p_3&=
\underset{\substack{\phantom{0}\\ \text{particle 3}}}
{\begin{pmatrix}
E\\
p\sin\theta\cos\phi\\
p\sin\theta\sin\phi\\
p\cos\theta
\end{pmatrix}}
&
p_4&=
\underset{\substack{\phantom{0}\\ \text{particle 4}}}
{\begin{pmatrix}
E\\
-p\sin\theta\cos\phi\\
-p\sin\theta\sin\phi\\
-p\cos\theta
\end{pmatrix}}
\end{align*}

\noindent
Symbol $p$ is incident momentum,
$E$ is total energy $E=\sqrt{p^2+m^2}$,
and $m$ is electron mass.
Polar angle $\theta$ is the observed scattering angle.
Azimuth angle $\phi$ cancels out in scattering calculations.

\bigskip
\noindent
The spinors are
\begin{align*}
u_{11}&=
\underset{\substack{\phantom{0}\\ \text{particle 1}\\ \text{spin up}}}
{\begin{pmatrix}E+m\\0\\p\\0\end{pmatrix}}
&
u_{12}&=
\underset{\substack{\phantom{0}\\ \text{particle 1}\\ \text{spin down}}}
{\begin{pmatrix}0\\E+m\\0\\-p\end{pmatrix}}
&
u_{21}&=
\underset{\substack{\phantom{0}\\ \text{particle 2}\\ \text{spin up}}}
{\begin{pmatrix}E+m\\0\\-p\\0\end{pmatrix}}
&
u_{22}&=
\underset{\substack{\phantom{0}\\ \text{particle 2}\\ \text{spin down}}}
{\begin{pmatrix}0\\E+m\\0\\p\end{pmatrix}}
\\[2ex]
u_{31}&=
\underset{\substack{\phantom{0}\\ \text{particle 3}\\ \text{spin up}}}
{\begin{pmatrix}E+m\\0\\p_{3z}\\p_{3x}+ip_{3y}\end{pmatrix}}
&
u_{32}&=
\underset{\substack{\phantom{0}\\ \text{particle 3}\\ \text{spin down}}}
{\begin{pmatrix}0\\E+m\\p_{3x}-ip_{3y}\\-p_{3z}\end{pmatrix}}
&
u_{41}&=
\underset{\substack{\phantom{0}\\ \text{particle 4}\\ \text{spin up}}}
{\begin{pmatrix}E+m\\0\\p_{4z}\\p_{4x}+ip_{4y}\end{pmatrix}}
&
u_{42}&=
\underset{\substack{\phantom{0}\\ \text{particle 4}\\ \text{spin down}}}
{\begin{pmatrix}0\\E+m\\p_{4x}-ip_{4y}\\-p_{4z}\end{pmatrix}}
\end{align*}

\noindent
The spinors shown above are not individually normalized.
Instead, a combined spinor normalization constant
$N=(E+m)^4$ will be used.

\bigskip
\noindent
The following formula computes a probability density $|\mathcal{M}_{abcd}|^2$
for electron scattering where the subscripts $abcd$ are the spin states of the electrons.
\begin{equation*}
|\mathcal{M}_{abcd}|^2=\frac{e^4}{N}
\bigg|
\underset{\substack{\phantom{0}\\ \text{from Feynman diagram with}\\ \text{photon exchange}\\ \text{no electron interchange}}}
{\frac{1}{t}(\bar{u}_{3c}\gamma^\mu u_{1a})(\bar{u}_{4d}\gamma_\mu u_{2b})}
-
\underset{\substack{\phantom{0}\\ \text{from Feynman diagram with}\\ \text{photon exchange}\\ \text{electron interchange}}}
{\frac{1}{u}(\bar{u}_{4d}\gamma^\nu u_{1a})(\bar{u}_{3c}\gamma_\nu u_{2b})}
\bigg|^2
\end{equation*}

\noindent
Symbol $e$ is electron charge.
Symbols $t$ and $u$ are Mandelstam variables
\begin{align*}
t&=(p_1-p_3)^2
\\
u&=(p_1-p_4)^2
\end{align*}

\noindent
Let
\begin{equation*}
a_1=(\bar{u}_{3c}\gamma^\mu u_{1a})(\bar{u}_{4d}\gamma_\mu u_{2b})
\qquad
a_2=(\bar{u}_{4d}\gamma^\nu u_{1a})(\bar{u}_{3c}\gamma_\nu u_{2b})
\end{equation*}

\noindent
Then
\begin{align*}
|\mathcal{M}_{abcd}|^2
&=
\frac{e^4}{N}
\left|\frac{a_1}{t} - \frac{a_2}{u}\right|^2\\
&=
\frac{e^4}{N}
\left(\frac{a_1}{t} - \frac{a_2}{u}\right)\left(\frac{a_1}{t} - \frac{a_2}{u}\right)^*\\
&=
\frac{e^4}{N}
\left(
\frac{a_1a_1^*}{t^2} - \frac{a_1a_2^*}{tu} -
\frac{a_1^*a_2}{tu} + \frac{a_2a_2^*}{u^2}
\right)
\end{align*}

\noindent
The expected probability density $\langle|\mathcal{M}|^2\rangle$ is computed by
summing $|\mathcal{M}_{abcd}|^2$ over all spin states and dividing by the number
of inbound states.
There are four inbound states.
\begin{align*}
\langle|\mathcal{M}|^2\rangle
&=
\frac{1}{4}\sum_{a=1}^2\sum_{b=1}^2\sum_{c=1}^2\sum_{d=1}^2
|\mathcal{M}_{abcd}|^2\\
&=
\frac{e^4}{4N}\sum_{a=1}^2\sum_{b=1}^2\sum_{c=1}^2\sum_{d=1}^2
\left(
\frac{a_1a_1^*}{t^2}-\frac{a_1a_2^*}{tu}-\frac{a_1^*a_2}{tu}+\frac{a_2a_2^*}{u^2}
\right)
\end{align*}

\noindent
Use the Casimir trick to replace sums over spins with matrix products.
\begin{align*}
f_{11}&=\frac{1}{N}\sum_{abcd}a_1a_1^*=
\mathop{\rm Tr}\left(
(\slashed{p}_3+m)\gamma^\mu(\slashed{p}_1+m)\gamma^\nu
\right)
\mathop{\rm Tr}\left(
(\slashed{p}_4+m)\gamma_\mu(\slashed{p}_2+m)\gamma_\nu
\right)
\\
f_{12}&=\frac{1}{N}\sum_{abcd}a_1a_2^*=
\mathop{\rm Tr}\left(
(\slashed{p}_3+m)\gamma^\mu(\slashed{p}_1+m)\gamma^\nu
(\slashed{p}_4+m)\gamma_\mu(\slashed{p}_2+m)\gamma_\nu
\right)
\\
f_{22}&=\frac{1}{N}\sum_{abcd}a_2a_2^*=
\mathop{\rm Tr}\left(
(\slashed{p}_4+m)\gamma^\mu(\slashed{p}_1+m)\gamma^\nu
\right)
\mathop{\rm Tr}\left(
(\slashed{p}_3+m)\gamma_\mu(\slashed{p}_2+m)\gamma_\nu
\right)
\end{align*}

\noindent
Hence
\begin{equation*}
\langle|\mathcal{M}|^2\rangle
=\frac{e^4}{4}
\left(
\frac{f_{11}}{t^2}-\frac{f_{12}}{tu}-\frac{f_{12}^*}{tu}+\frac{f_{22}}{u^2}
\right)
\end{equation*}

\noindent
The following formulas are equivalent to the Casimir trick.
(Recall that $a\cdot b=a^\mu g_{\mu\nu}b^\nu$)
\begin{align*}
f_{11}&=
32 (p_1\cdot p_2)^2 +
32 (p_1\cdot p_4)^2 -
64 m^2 (p_1\cdot p_3) + 64 m^4
\\
f_{12}&=
-32 (p_1\cdot p_2)^2 +
32 m^2 (p_1\cdot p_2) +
32 m^2 (p_1\cdot p_3) +
32 m^2 (p_1\cdot p_4) - 32m^4
\\
f_{22}&=
32 (p_1\cdot p_2)^2 +
32 (p_1\cdot p_3)^2 -
64 m^2 (p_1\cdot p_4) + 64 m^4
\end{align*}

\noindent
In Mandelstam variables
\begin{align*}
s&=(p_1+p_2)^2
\\
t&=(p_1-p_3)^2
\\
u&=(p_1-p_4)^2
\end{align*}
the formulas are
\begin{align*}
f_{11} &= 8 s^2 + 8 u^2 - 64 s m^2 - 64 u m^2 + 192 m^4
\\
f_{12} &= -8 s^2 + 64 s m^2 - 96 m^4
\\
f_{22} &= 8 s^2 + 8 t^2 - 64 s m^2 - 64 t m^2 + 192 m^4
\end{align*}

\subsection*{High energy approximation}
When $E\gg m$ a useful approximation is to set $m=0$ and obtain
\begin{align*}
f_{11}&=8s^2+8u^2\\
f_{12}&=-8s^2\\
f_{22}&=8s^2+8t^2
\end{align*}

\noindent
Hence
\begin{align*}
\langle|\mathcal{M}|^2\rangle
&=\frac{e^4}{4}
\left(
\frac{f_{11}}{t^2}-\frac{f_{12}}{tu}-\frac{f_{12}^*}{tu}+\frac{f_{22}}{u^2}
\right)
\\
&=\frac{e^4}{4}
\left(
\frac{8s^2+8u^2}{t^2}-\frac{-8s^2}{tu}-\frac{-8s^2}{tu}+\frac{8s^2+8t^2}{u^2}
\right)
\\
&=2e^4
\left(
\frac{s^2+u^2}{t^2}+\frac{2s^2}{tu}+\frac{s^2+t^2}{u^2}
\right)
\end{align*}

\noindent
Combine terms so $\langle|\mathcal{M}|^2\rangle$ has a common denominator.
\begin{equation*}
\langle|\mathcal{M}|^2\rangle
=2e^4
\left(
\frac{u^2(s^2+u^2)+2s^2tu+t^2(s^2+t^2)}{t^2u^2}
\right)
\end{equation*}

\noindent
For $m=0$ the Mandelstam variables are
\begin{align*}
s&=4E^2
\\
t&=2E^2(\cos\theta-1)
\\
u&=-2E^2(\cos\theta+1)
\end{align*}

\noindent
Hence
\begin{align*}
\langle|\mathcal{M}|^2\rangle
&=2e^4
\left(
\frac{32E^8\cos^4\theta+192E^8\cos^2\theta+288E^8}{16E^8(\cos\theta-1)^2(\cos\theta+1)^2}
\right)
\\
&=4e^4\frac{\left(\cos^2\theta+3\right)^2}{(\cos\theta-1)^2(\cos\theta+1)^2}
\\
&=4e^4
\left(
\frac{\cos^2\theta+3}{\cos^2\theta-1}
\right)^2
\end{align*}

\noindent
The following equivalent formula can also be used.
\begin{multline*}
\langle|\mathcal{M}|^2\rangle
=2e^4
\left(
\frac{s^2+u^2}{t^2}+\frac{2s^2}{tu}+\frac{s^2+t^2}{u^2}
\right)
\\
=2e^4\bigg(
\underset{\substack{\phantom{0}\\ \text{from Feynman diagram with}\\ \text{photon exchange}\\ \text{no electron interchange}}}
{\frac{1+\cos^4(\theta/2)}{\sin^4(\theta/2)}}
+
\underset{\substack{\phantom{0}\\ \text{interaction term}}}
{\frac{2}{\sin^2(\theta/2)\cos^2(\theta/2)}}
+
\underset{\substack{\phantom{0}\\ \text{from Feynman diagram with}\\ \text{photon exchange}\\ \text{electron interchange}}}
{\frac{1+\sin^4(\theta/2)}{\cos^4(\theta/2)}}
\bigg)
\end{multline*}
For example, see A.~Zee, p.~134.

\subsection*{Cross section}
The differential cross section is
\begin{equation*}
\frac{d\sigma}{d\Omega}
=\frac{\langle|\mathcal{M}|^2\rangle}{64\pi^2s}
=\frac{e^4}{16\pi^2s}
\left(
\frac{\cos^2\theta+3}{\cos^2\theta-1}
\right)^2,\quad s\gg m
\end{equation*}

\noindent
Substituting $e^4=16\pi^2\alpha^2$ yields
\begin{equation*}
\frac{d\sigma}{d\Omega}=\frac{\alpha^2}{s}
\left(
\frac{\cos^2\theta+3}{\cos^2\theta-1}
\right)^2
\end{equation*}

\noindent
We can integrate $d\sigma$ to obtain a cumulative distribution function.
Recall that
\begin{equation*}
d\Omega=\sin\theta\,d\theta\,d\phi
\end{equation*}
Hence
\begin{equation*}
d\sigma=\frac{\alpha^2}{s}
\left(
\frac{\cos^2\theta+3}{\cos^2\theta-1}
\right)^2
\sin\theta\,d\theta\,d\phi
\end{equation*}

\noindent
Let $I(\theta)$ be the following integral of $d\sigma$.
\begin{align*}
I(\theta)&=\frac{s}{2\pi\alpha^2}\int_0^{2\pi}\int d\sigma
\\
&=\int
\left(
\frac{\cos^2\theta+3}{\cos^2\theta-1}
\right)^2
\sin\theta\,d\theta,
\quad a\le\theta\le\pi-a
\end{align*}

\noindent
Angular support is limited to an arbitrary $a>0$ because $I(0)$ and $I(\pi)$ are undefined.
Assume that $I(\theta)-I(a)$ is computable given $\theta$ by either symbolic or numerical integration.

\bigskip
\noindent
Let $C$ be the normalization constant
\begin{equation*}
C=I(\pi-a)-I(a)
\end{equation*}

\noindent
Then the cumulative distribution function $F(\theta)$ is
\begin{equation*}
F(\theta)=\frac{I(\theta)-I(a)}{C},\quad a\le\theta\le\pi-a
\end{equation*}

\noindent
The probability of observing scattering events in the interval $\theta_1$ to $\theta_2$
can now be computed.
\begin{equation*}
P(\theta_1\le\theta\le\theta_2)=F(\theta_2)-F(\theta_1)
\end{equation*}

\noindent
Probability density function $f(\theta)$ is the derivative of $F(\theta)$.
\begin{equation*}
f(\theta)
=\frac{dF(\theta)}{d\theta}
=\frac{1}{C}
\left(
\frac{\cos^2\theta+3}{\cos^2\theta-1}
\right)^2
\sin\theta
\end{equation*}

\noindent
This is a graph of $f(\theta)$ for $a=\pi/6=30^\circ$.

\begin{center}
\includegraphics[scale=0.5]{moller-scattering.png}
\end{center}

\noindent
Probability distribution for $30^\circ$ bins ($a=30^\circ$).
\begin{center}
\begin{tabular}{|c|c|c|}
\hline
$\theta_1$ & $\theta_2$ & $P(\theta_1\le\theta\le\theta_2)$\\
\hline
$0^\circ$ & $30^\circ$ & -- \\
$30^\circ$ & $60^\circ$ & 0.40 \\
$60^\circ$ & $90^\circ$ & 0.10 \\
$90^\circ$ & $120^\circ$ & 0.10 \\
$120^\circ$ & $150^\circ$ & 0.40 \\
$150^\circ$ & $180^\circ$ & -- \\
\hline
\end{tabular}
\end{center}

\subsection*{Notes}
In component notation, the trace operators of the Casimir trick become sums over
a repeated index, in this case $\alpha$.
\begin{align*}
f_{11}&=
\left(
(\slashed{p}_3+m)^\alpha{}_\beta
\gamma^{\mu\beta}{}_\rho
(\slashed{p}_1+m)^\rho{}_\sigma
\gamma^{\nu\sigma}{}_\alpha
\right)
\left(
(\slashed{p}_4+m)^\alpha{}_\beta
\gamma_\mu{}^\beta{}_\rho
(\slashed{p}_2+m)^\rho{}_\sigma
\gamma_\nu{}^\sigma{}_\alpha
\right)
\\
f_{12}&=
(\slashed{p}_3+m)^\alpha{}_\beta
\gamma^{\mu\beta}{}_\rho
(\slashed{p}_1+m)^\rho{}_\sigma
\gamma^{\nu\sigma}{}_\tau
(\slashed{p}_4+m)^\tau{}_\delta
\gamma_\mu{}^\delta{}_\eta
(\slashed{p}_2+m)^\eta{}_\xi
\gamma_\nu{}^\xi{}_\alpha
\\
f_{22}&=
\left(
(\slashed{p}_4+m)^\alpha{}_\beta
\gamma^{\mu\beta}{}_\rho
(\slashed{p}_1+m)^\rho{}_\sigma
\gamma^{\nu\sigma}{}_\alpha
\right)
\left(
(\slashed{p}_3+m)^\alpha{}_\beta
\gamma_\mu{}^\beta{}_\rho
(\slashed{p}_2+m)^\rho{}_\sigma
\gamma_\nu{}^\sigma{}_\alpha
\right)
\end{align*}

\noindent
To convert the above formulas to Eigenmath code,
the $\gamma$ tensors need to be transposed
so that repeated indices are adjacent to each other.
Also, multiply $\gamma^\mu$ by the metric tensor to lower the index.
\begin{align*}
\gamma^{\beta\mu}{}_\rho\quad&\rightarrow\quad
\text{\tt gammaT = transpose(gamma)}\\
\gamma^\beta{}_{\mu\rho}\quad&\rightarrow\quad
\text{\tt gammaL = transpose(dot(gmunu,gamma))}
\end{align*}

\noindent
Define the following $4\times4$ matrices.
\begin{align*}
(\slashed{p}_1+m)\quad&\rightarrow\quad\text{\tt X1 = pslash1 + m I}\\
(\slashed{p}_2+m)\quad&\rightarrow\quad\text{\tt X2 = pslash2 + m I}\\
(\slashed{p}_3+m)\quad&\rightarrow\quad\text{\tt X3 = pslash3 + m I}\\
(\slashed{p}_4+m)\quad&\rightarrow\quad\text{\tt X4 = pslash4 + m I}
\end{align*}

\noindent
Then for $f_{11}$ we have the following Eigenmath code.
The contract function sums over $\alpha$.
\begin{align*}
(\slashed{p}_3+m)^\alpha{}_\beta
\gamma^{\mu\beta}{}_\rho
(\slashed{p}_1+m)^\rho{}_\sigma
\gamma^{\nu\sigma}{}_\alpha
\quad&\rightarrow\quad
\text{\tt T1 = contract(dot(X3,gammaT,X1,gammaT),1,4)}
\\
(\slashed{p}_4+m)^\alpha{}_\beta
\gamma_\mu{}^\beta{}_\rho
(\slashed{p}_2+m)^\rho{}_\sigma
\gamma_\nu{}^\sigma{}_\alpha
\quad&\rightarrow\quad
\text{\tt T2 = contract(dot(X4,gammaL,X2,gammaL),1,4)}
\end{align*}

\noindent
Next, multiply then sum over repeated indices.
The dot function sums over $\nu$ then the contract function
sums over $\mu$. The transpose makes the $\nu$ indices adjacent
as required by the dot function.
$$
f_{11}=
\mathop{\rm Tr}(\cdots\gamma^\mu\cdots\gamma^\nu)
\mathop{\rm Tr}(\cdots\gamma_\mu\cdots\gamma_\nu)
\quad\rightarrow\quad
\text{\tt contract(dot(T1,transpose(T2)))}
$$

\noindent
Follow suit for $f_{22}$.
\begin{align*}
(\slashed{p}_4+m)^\alpha{}_\beta
\gamma^{\mu\beta}{}_\rho
(\slashed{p}_1+m)^\rho{}_\sigma
\gamma^{\nu\sigma}{}_\alpha
\quad&\rightarrow\quad
\text{\tt T1 = contract(dot(X4,gammaT,X1,gammaT),1,4)}
\\
(\slashed{p}_3+m)^\alpha{}_\beta
\gamma_\mu{}^\beta{}_\rho
(\slashed{p}_2+m)^\rho{}_\sigma
\gamma_\nu{}^\sigma{}_\alpha
\quad&\rightarrow\quad
\text{\tt T2 = contract(dot(X3,gammaL,X2,gammaL),1,4)}
\end{align*}

\noindent
Then
$$
f_{22}=
\mathop{\rm Tr}(\cdots\gamma^\mu\cdots\gamma^\nu)
\mathop{\rm Tr}(\cdots\gamma_\mu\cdots\gamma_\nu)
\quad\rightarrow\quad
\text{\tt contract(dot(T1,transpose(T2)))}
$$

\noindent
The calculation of $f_{12}$ begins with
\begin{multline*}
(\slashed{p}_3+m)^\alpha{}_\beta
\gamma^{\mu\beta}{}_\rho
(\slashed{p}_1+m)^\rho{}_\sigma
\gamma^{\nu\sigma}{}_\tau
(\slashed{p}_4+m)^\tau{}_\delta
\gamma_\mu{}^\delta{}_\eta
(\slashed{p}_2+m)^\eta{}_\xi
\gamma_\nu{}^\xi{}_\alpha
\\
\rightarrow\quad
\text{\tt T = contract(dot(X3,gammaT,X1,gammaT,X4,gammaL,X2,gammaL),1,6)}
\end{multline*}

\noindent
Then sum over repeated indices $\mu$ and $\nu$.
$$
f_{12}=\mathop{\rm Tr}(\cdots\gamma^\mu\cdots\gamma^\nu\cdots\gamma_\mu\cdots\gamma_\nu)
\quad\rightarrow\quad
\text{\tt contract(contract(T,1,3))}
$$

\end{document}


% !TEX root = ../main.tex
\section{Introduction}\label{sec:rfs-introduction}
\input{ch-rfs/table/example_meals}
Classical recommender system datasets contain a matrix where each row is a user and each column is an item. Each entry in the matrix indicates whether or not a user consumed an item. Modern applications often gather rich side information about items in the form of a set of attributes or tags. Item attributes provide valuable side information for recommender systems. With a large number of items or a sparse user-item matrix, attribute information is necessary for good performance.

We are motivated by a specific dataset with these properties: a dataset of 55k users logging 16M meals using the LoseIt! diet tracking app. \Cref{tab:example-meals} shows the kind of data logged by users, where each row is an item (meal), each left-hand column is an attribute (food), and each right-hand column is a user. The food attributes can clearly inform recommendations: User~1 does not log meat, User~4 is omnivorous and undiscriminating, and User 3 mostly eats salads. In the LoseIt! data, there is a massive number of possible items to recommend: there are 12M unique meals, composed of subsets of 3M foods. Meals containing only a few foods, or those ordered at chain restaurants, may be logged by many users. But these represent a small proportion of the meals people actually eat, so a long tail of meals are logged by single users.
%Models that require parameters to be learned for every item cannot scale to this type of data, and models that do not leverage attributes cannot recommend items from the long tail.

Modeling item attributes in these non-standard recommender systems is not straightforward. Popular ways to use item attributes like multiple matrix factorization~\citep{wang2011collaborative,gopalan2014content-based} struggle when the attribute vocabulary or number of items is large. Conversely, simple models are computationally tractable but risk losing the ability to capture nonlinear patterns of user consumption. For instance, a user may enjoy meals tagged with foods \texttt{A} and \texttt{B}, \texttt{B} and \texttt{C}, or \texttt{A} and \texttt{C}, but not all three. Finding the right balance between scalability and flexibility is therefore a primary goal.

Even when a model can be scaled, it may not be clear how its training procedure
connects to the recommender system evaluation metric.
% A model optimized using a training objective may not yield optimal recommendation performance.
A matrix factorization method might minimize mean squared error when the recommender
system is evaluated on recall. While it is plausible that minimizing mean squared error will
improve recall, the connection between the two is implicitly assumed in many methods. Ideally, a recommender system should have an objective that matches its evaluation metric.

This paper proposes \gls{rfs}, a class of principled, scalable models for recommending items with sets of attributes. \gls{rfs} casts the recommendation problem as binary classification. Given a user and an item, \gls{rfs} treats attributes as features and classifies whether or not the item is likely to be consumed by the user. \gls{rfs} learns embeddings for each user and attribute; each item is represented as the mean of its attribute embeddings. To scale to large datasets, we develop an \gls{rfs} method that is trained using negative sampling of random items that are unlikely to be consumed.

\gls{rfs} enjoys two benefits from framing the recommendation problem as classification. First, the \gls{rfs} classification objective function is directly tied to recommender recall: we show that a classifier with zero worst-case error achieves maximum recall. Second, \gls{rfs} is provably flexible enough to learn any class of recommendation model based on set-valued side information (including multiple matrix factorization). This generality makes \gls{rfs} a natural drop-in replacement for many specialized models in the literature.

We study the performance of the negative sampling \gls{rfs} model on a semi-synthetic benchmark dataset and the LoseIt! dataset. The semi-synthetic paper recommendation dataset consists of 65k users clicking on 636k papers posted to the arXiv; the attributes of each paper are the unique words in its abstract. We then apply the method to the LoseIt! dataset to make out-of-sample meal recommendations. In both cases, the \gls{rfs} method outperforms the state of the art in terms of recall. In addition to good performance, the \gls{rfs} model learns interpretable embeddings that intuitively capture the structure of the underlying data.
\input{ch-rfs/fig/fig_arxiv_tsne}

% \gls{rfs} is extremely scalable and is fit with a loss function tied to an
% evaluation metric. In addition to outperforming competitors on large datasets,
% it is backed by an ability to approximate other models that recommend items with
% attributes. \emph{This work demonstrates that if a practitioner aims to perform
%   recommendation of items with attributes and measures recommendation
%   performance with recall, the best choice of model is a deep classifier such as
%   \gls{rfs}.}
% The rest of this paper is organinized as follows:
% \paragraph{Background}
% \begin{itemize}
%     \item Recommendation with side information
%     \item Negative sampling in recommender systems
%     \item Regression models with set-valued features
% \end{itemize}
% \paragraph{Method}
% \begin{itemize}
%     \item Recommendation as classification
%     \item Embedding users and items
%     \item Learning the parameters through negative sampling
% \end{itemize}

% \paragraph{Results}
% \begin{itemize}
%     \item Metrics (recall@K definition)
%     \item Recommending documents
%     \item Recommending meals
% \end{itemize}
% \paragraph{Discussion}
% \begin{itemize}
%     \item Summarize contribution
%     \item Incorporating additional side information
%     \item Other interesting things?
% \end{itemize}
% % set up the task of recommendation, foreshadow how we will solve it via
% % classification
% Sets of attributes represent many types of items. A user might be associated
% with a photo that has tags, a disease with diagnosis codes, or a playlist of
% songs. Recommendation models for such items use the item attributes to rank
% items for users. Central to building recommendation models is evaluation, and a
% common metric is recall. But existing models such as matrix factorization do not
% have associated theoretical guarantees of improved recall. Currently, models are
% built on a case-by-case basis and adapted to the data at hand, and must be
% painstakingly compared to see which extension leads to improvement of the
% evaluation metric.
% % foreshadow desiderata
% Our goal is to build a recommendation model to rank items from attributes, and
% buttress the model with theoretical guarantees of universal approximation
% (ability to approximate other models) and of improved recommendation performance
% vis-\`a-vis recall.
% % desideratum #1: statistical challenge
% Building models that rank items from sets of attributes must address two
% difficulties arising from the properties of sets. The first difficulty is the
% statistical challenge posed by the large number of possible sets. The number of
% sets of attributes is large; we cannot posit a model with unique parameters for
% every set of attributes. The meal recommendation problem illustrates this
% statistical challenge. \Cref{fig:hist} shows the number of meals in data from a
% food tracking app. Even in this small fraction of the data, there are over ten
% million unique meals. In building a recommendation model to rank meals based on
% their constituent foods, the model should satisfy the criterion of
% parameter-sharing, and share parameters across meals with similar foods. For
% example, matrix factorization does not satisfy this criteria: it requires
% learning parameters for every meal. This is inefficient, as most meals are
% consumed by a single user in this data. The criterion of parameter-sharing is
% necessary for models to scale to large real-world datasets as in
% \Cref{fig:hist}.
% % desideratum #2
% In addition to parameter-sharing across sets, models that rank items based on
% their sets of attributes must be invariant to the order of set elements. This
% criterion is called order-invariance. For example, a meal is a set of foods, and
% remains the same meal if we permute the foods it contains. Recommendation models
% should yield the same output regardless of the order that set elements are fed
% to the model. Matrix factorization is an example of an order-invariant model.
% \input{ch-rfs/fig/hist}
% % hook: why you should read on. world-as-it-could-be if you join us on the ride
% We develop \gls{rfs}, a recommendation model that meets the above
% criteria of parameter-sharing and order-invariance, and guarantees improvement
% in recall and ability to approximate other models. Other order-invariant models
% such as matrix factorization do not have such theoretical backing of improved
% evaluation metrics and ability to approximate other models. The theory we
% develop for \gls{rfs} frees practitioners to focus on building
% efficient architectures for one model, rather than comparing across that may not
% be able to approximate others, or that may not provably improve recall.
% % at a high level, what are the insights needed to solve the problem?
% The key insight that guarantees that \gls{rfs} improves recall is
% the framing of recall as classification. Recall measures the fraction of items a
% user consumed in a ranking returned by a recommendation model. This is
% inherently a binary task: a model does or does not recall an item. It follows
% that a perfect classifier maximizes recall. This framing enables us build
% \gls{rfs} as a classifier and leverage recent innovations from
% deep learning~\citep{Mikolov2013} to fit our model. We define negative samples as
% items users are unlikely to consume. This allows us to fit
% \gls{rfs} to implicit feedback data, where there are only
% user-item interactions, and users do not explicitly indicate dislike of items.
% % universal approximation
% The second goal of building a model that approximates others is achieved by
% parameterizing \gls{rfs} using neural networks. This enables us to
% show that the model can approximate other recommenders that rank from sets. We
% describe several neural network architectures, including one based on residual
% networks~\citep{DBLP:journals/corr/HeZRS15}.
% % describe our model, how it is trained, an how it recommends
% \gls{rfs} is a classifier whose output is the probability of a
% user consuming an item. The model is trained to discriminate items users consume
% from items users are unlikely to consume (negative samples). The probability
% of item consumption output by the model is used to rank items for
% recommendation.
% % deep learning-> universal approximation, and architectures to satisfy
% % order-invariance and parameter-sharing
% We parameterize \gls{rfs} using neural networks, enabling the
% approximation of other models. The architectures of the neural networks are
% defined to meet the criteria of parameter-sharing and order-invariance arising
% from the properties of items represented by sets of attributes.
% % results
% We demonstrate our method by comparing it to several recommendation models on
% two datasets. The first dataset consists of users consuming $16$M meals from a
% food tracking app, and the second consists of users consuming $637$k preprints
% on the arXiv. The model outperforms order-invariant recurrent neural
% networks~\citep{Hochreiter1997}, a word embedding model~\citep{Mikolov2013}, and
% content-based Poisson factorization~\citep{Gopalana}. We also find that
% \gls{rfs} yields interpretable patterns in user behavior as in
% \Cref{fig:arxiv_tsne}.
% \paragraph{Related work.} Regression models such as deep
% sets~\citep{DBLP:journals/corr/ZaheerKRPSS17} have been developed for set-valued
% data. The deep sets model is a regression, not recommendation model, and does
% not use negative sampling in contrast to \gls{rfs}. Several
% recommendation algorithms use negative sampling to improve performance
% \citep{he2017neural,Chen:2017:SSN:3097983.3098202}. There are also deep learning
% models for collaborative filtering~\citep{zhang2017deep}. However, such work is
% centered on recommending items without side information. We focus on items with
% side information comprised of sets of attributes. In this regime the large
% number of unique sets of attributes is an obstacle and requires additional
% modeling choices. \citet{tansey2016diet2vec} also analyze diet data, but do not
% address recommendation. Probabilistic deep learning approaches for
% recommendation exist~\citep{Ranganath:2015} but do not include negative samples
% in the likelihood; we show this improves performance.
% % set up the task of recommendation, foreshadow how we will solve it via
% % classification
% Sets of attributes represent many types of items. A user might be associated
% with a photo that has tags, a disease with diagnosis codes, or a playlist of
% songs. Recommendation models for such items use the item attributes to rank
% items for users. Central to building recommendation models is evaluation, and a
% common metric is recall. But existing models such as matrix factorization do not
% have associated theoretical guarantees of improved recall. Currently, models are
% built on a case-by-case basis and adapted to the data at hand, and must be
% painstakingly compared to see which extension leads to improvement of the
% evaluation metric.
% % foreshadow desiderata
% Our goal is to build a recommendation model to rank items from attributes, and
% buttress the model with theoretical guarantees of universal approximation
% (ability to approximate other models) and of improved recommendation performance
% vis-\`a-vis recall.
% % desideratum #1: statistical challenge
% Building models that rank items from sets of attributes must address two
% difficulties arising from the properties of sets. The first difficulty is the
% statistical challenge posed by the large number of possible sets. The number of
% sets of attributes is large; we cannot posit a model with unique parameters for
% every set of attributes. The meal recommendation problem illustrates this
% statistical challenge. \Cref{fig:hist} shows the number of meals in data from a
% food tracking app. Even in this small fraction of the data, there are over ten
% million unique meals. In building a recommendation model to rank meals based on
% their constituent foods, the model should satisfy the criterion of
% parameter-sharing, and share parameters across meals with similar foods. For
% example, matrix factorization does not satisfy this criteria: it requires
% learning parameters for every meal. This is inefficient, as most meals are
% consumed by a single user in this data. The criterion of parameter-sharing is
% necessary for models to scale to large real-world datasets as in
% \Cref{fig:hist}.
% % desideratum #2
% In addition to parameter-sharing across sets, models that rank items based on
% their sets of attributes must be invariant to the order of set elements. This
% criterion is called order-invariance. For example, a meal is a set of foods, and
% remains the same meal if we permute the foods it contains. Recommendation models
% should yield the same output regardless of the order that set elements are fed
% to the model. Matrix factorization is an example of an order-invariant model.
% \input{ch-rfs/fig/hist}
% % hook: why you should read on. world-as-it-could-be if you join us on the ride
% We develop \gls{rfs}, a recommendation model that meets the above
% criteria of parameter-sharing and order-invariance, and guarantees improvement
% in recall and ability to approximate other models. Other order-invariant models
% such as matrix factorization do not have such theoretical backing of improved
% evaluation metrics and ability to approximate other models. The theory we
% develop for \gls{rfs} frees practitioners to focus on building
% efficient architectures for one model, rather than comparing across models that
% may not provably improve recall (or be able to approximate other models).
% % at a high level, what are the insights needed to solve the problem?
% The key insight that guarantees that \gls{rfs} improves recall is
% the framing of recall as classification. Recall measures the fraction of items a
% user consumed in a ranking returned by a recommendation model. This is
% inherently a binary task: a model does or does not recall an item. It follows
% that a perfect classifier maximizes recall. This framing enables us build
% \gls{rfs} as a classifier and leverage recent innovations from
% deep learning~\citep{Mikolov2013} to fit our model. We define negative samples as
% items users are unlikely to consume. This allows us to fit
% \gls{rfs} to implicit feedback data, where there are only
% user-item interactions, and users do not explicitly indicate dislike of items.
% % universal approximation
% The second goal of building a model that approximates others is achieved by
% parameterizing \gls{rfs} using neural networks. This enables us to
% show that the model can approximate other recommenders that rank from sets. We
% describe several neural network architectures, including one based on residual
% networks~\citep{DBLP:journals/corr/HeZRS15}.
% % describe our model, how it is trained, an how it recommends
% \gls{rfs} is a classifier whose output is the probability of a
% user consuming an item. The model is trained to discriminate items users consume
% from items users are unlikely to consume (negative samples). The probability
% of item consumption output by the model is used to rank items for
% recommendation.
% % deep learning-> universal approximation, and architectures to satisfy
% % order-invariance and parameter-sharing
% We parameterize \gls{rfs} using neural networks, enabling the
% approximation of other models. The architectures of the neural networks are
% defined to meet the criteria of parameter-sharing and order-invariance arising
% from the properties of items represented by sets of attributes.
% % results
% We demonstrate our method by comparing it to several recommendation models on
% two datasets. The first dataset consists of users consuming $16$M meals from a
% food tracking app, and the second consists of users consuming $637$k preprints
% on the arXiv. The model outperforms order-invariant recurrent neural
% networks~\citep{Hochreiter1997}, a word embedding model~\citep{Mikolov2013}, and
% content-based Poisson factorization~\citep{Gopalana}. We also find that
% \gls{rfs} yields interpretable patterns in user behavior as in
% \Cref{fig:arxiv_tsne}.
% \paragraph{Related work.} Regression models such as deep
% sets~\citep{DBLP:journals/corr/ZaheerKRPSS17} have been developed for set-valued
% data. The deep sets model is a regression, not recommendation model, and does
% not use negative sampling in contrast to \gls{rfs}. Several
% recommendation algorithms use negative sampling to improve performance
% \citep{he2017neural,Chen:2017:SSN:3097983.3098202}. There are also deep learning
% models for collaborative filtering~\citep{zhang2017deep}. However, such work is
% centered on recommending items without side information. We focus on items with
% side information comprised of sets of attributes. In this regime the large
% number of unique sets of attributes is an obstacle and requires additional
% modeling choices. \citet{tansey2016diet2vec} also analyze diet data, but do not
% address recommendation. Probabilistic deep learning approaches for
% recommendation exist~\citep{Ranganath:2015} but do not include negative samples
% in the likelihood; we show this improves performance.


\documentclass[a4paper]{article}

\input{temp}

\setcounter{section}{-1}

\begin{document}

\title{Mathematical Biology}

\maketitle

\newpage

\tableofcontents

\newpage

\section{Miscellaneous}

Course notes online: Julia Gog(www.damtp.cam.ac.uk/research/dd/teaeching, 2013-2017), Peter Haynes(www.damtp.cam.ac.uk/user/phh/mathbio.html)

Moodle page: Handwritten notes by lecture; Matlab/Python programming examples; solved exercises.

This course involves 3 models: Deterministic temporal models (11 lectures), Stochastic temporal models (5 lectures), Deterministic spatio-temporal models (8 lectures).

The focus of this course is biochemical reactions and population processes.

(some introductory speech)

\begin{eg} (1, Transient population)
If we use $n(t)$ to denote the size of a population, we may want to model $\frac{dn}{dt} = f(n)$ by an ODE, or maybe if we have several components $\mathbf{n}(t)$ then we may want to model $\frac{d\mathbf{n}}{dt} = \mathbf{f}(\mathbf{n})$ which is a system of ODEs.

Note that although $n$ should be an integer (discrete), when $n >> 1$ we may model it with continuous equations.
\end{eg}

\begin{eg} (2)
$n \to \partial_t P(n,t) = W \cdot P(n,t)$, Markov processes. Here $P(n,t)$ is a probablity(?), $n$ being a state, and $W$ being the transition matrix.
\end{eg}

\begin{eg} (3)\\
If we include spatial aspect, we may have $n(t)$ becoming $n(x,t)$. Now there might be 'diffusion': $\partial_t n(x,t) = f(n(x,t)) + D \nabla^2 (x,t)$ where $\nabla^2 = \frac{\partial^2}{\partial x^2}$; this is the reaction-diffusion equation.
\end{eg}

\newpage

\section{Birth-death models}
The general idea is that we have a population of size $n(t)$; per capita per unit time, we have births of rate $b$ and deaths of rate $d$. Then we can write $$n(t+\Delta t) = n(t) + bn\Delta t - dn \Delta t$$ So we have an ODE $$\frac{dn}{dt} = (b-d)n = rn$$ where $r = b-d$. This has an easy solution $n(t) = n_0 e^{rt}$, assuming $r$ is a constant. We see that if $r$ is positive then the population grows exponentially, and if $r$ is negative then the population decreases to 0 asymptotically.

Now probably $b$ and $d$ are related to $n$ by $b(n) = bn$ and $d(n) = dn^2$ due to competition. Then we have $$\frac{dn}{dt} = bn-dn^2$$ which we can definitely rewrite as $$\frac{dn}{dt}=\alpha n(1-n)$$ by some change of variable on $n$. Now

\begin{equation*}
\begin{aligned}
\frac{dn}{n(1-n)}&=\alpha dt\\
\implies \frac{dn}{n} + \frac{dn}{1-n} &= \alpha dt\\
\implies \ln n - \ln(1-n) &= \alpha t + c\\
\implies n &= \frac{n_0 e^{\alpha t}}{(1-n_0) + n_0 e^{\alpha t}}
\end{aligned}
\end{equation*}
where we are given that $t=0$, $n=n_0$. If $t \gg \frac{1}{\alpha}$, when $t \to \infty$ we have $n(t) \to 1$. Now we can investigate if the population size is stable, and if it has any fixed points.

Let's now define $\mathbf{n} = (n_1,...,n_p)$, i.e. $p$ populations, and $\frac{d\mathbf{n}}{dt} = \mathbf{f}(\mathbf{n})$. If $\mathbf{n}=\mathbf{n}^*$ is a fixed point, then $\frac{d\mathbf{n}}{dt} = 0$, i.e. $\mathbf{f}(\mathbf{n}) = 0$. Now if we apply a small perturbation $\mathbf{n} = \delta\mathbf{n}^* + \delta \mathbf{n}$, i.e.

\begin{equation*}
\begin{aligned}
\frac{d}{dt} \delta \mathbf{n} &= \mathbf{f} (\mathbf{n}^* + \delta \mathbf{n})\\
a&= \mathbf{f} (\mathbf{n}^*) + \frac{\partial f_i}{\partial n_j} \delta_{nj} + \frac{1}{2} \frac{\partial^2 f_i} {\partial n_j \partial n_k} \delta_{n_j} \delta_{n_k}
\end{aligned}
\end{equation*}
So $\frac{d}{dt} \delta \mathbf{n} = J \cdot \partial \mathbf{n}$, so $\delta n(t) = e^{J t} \cdot \delta n(0)$. If $\lambda_i$'s are the eigenvalues of $J$, we consider the real part of $\lambda_i$: if $Re(\lambda_i)<0$, then  if $p\geq 5$ we only have numerical solutions, if $3 \leq p \leq 5$ we have analytic solutions, and $p=2$ is an easy case (recall $p$ is the number of populations):

$\bullet$ If $p=2$, $\mathbf{n} = (n_1,n_2)$, then
\begin{equation*}
\begin{aligned}
\frac{d}{dt} \begin{pmatrix} \delta_{n_1} \\
\delta_{n_2}
\end{pmatrix} = \begin{pmatrix}
\frac{\partial f_1}{\partial n_1} & \frac{\partial f_1}{\partial n_2}\\
\frac{\partial f_2}{\partial n_1} & \frac{\partial f_2}{\partial n_2}
\end{pmatrix} \cdot \begin{pmatrix}
\delta_{n_1}\\
\delta_{n_2}
\end{pmatrix}
\end{aligned}
\end{equation*}
Where the matrix is $J$. Now we have $\lambda_1\lambda_2 =\det J$ and $\lambda_1 + \lambda_2 = \tr J$. Determined by the signs of those two, we have different possible behaviours:

\includegraphics[scale=0.5]{image/Bio_01.png}

Now let's consider the spread of Dengue. There are several processes going on at the same time:

(1) Mosquitos carry dengue;\\
(2) Wolbachia infect mosquitos;\\
(3) Infected mosquitos do not transmit dengue;\\
(4) Wolbachia transmission only across generations.

Question: will an intially infected population of mosquitos eventually spread over the entire population as $t \to \infty$?

\includegraphics[scale=0.7]{image/Bio_02.png}

\includegraphics[scale=0.5]{image/Bio_03.png}

We always assume that there are enough males to fertilise the female eggs.

Now consider $\frac{d}{dt}$ of $n_U$ and $n_I$ (uninfected and infected females). From the above tables we should be able to get (hopefully)

\begin{equation*}
\begin{aligned}
\frac{d}{dt} n_U &= r n_U \frac{n_U}{n_U + n_I} - dn_U - \varepsilon (n_U+n_I) n_U\\
\frac{d}{dt} n_I &= \lambda r n_I \frac{n_U}{n_U + n_I} + \lambda r n_I \frac{n_I}{n_U + n_I} - \mu d n_I - \varepsilon (n_U+n_I) n_I \ (*)
\end{aligned}
\end{equation*}
This is our model when $p=2$. The term with $\varepsilon$ is the death rate associated with competition.

We'll try to simplify these equations. By rescaling the time as $t \to rt$, and rescaling the population as $n \to \frac{\varepsilon}{r} n$, we get (?)
\begin{equation*}
\begin{aligned}
\frac{d}{dt} n_U &= n_U \frac{n_U}{n_U + n_I} - \frac{d}{r} n_U - (n_U+n_I) n_U\\
&= n_U\left[\frac{n_U}{n_U+n_I} - \frac{d}{r} - (n_U+n_I)\right] \ (1)
\end{aligned}
\end{equation*}
and the second equation becomes (???)
\begin{equation*}
\begin{aligned}
\frac{d}{dt} n_I = n_I \left[\lambda - \mu \frac{d}{r} - (n_U+n_I)\right] \ (2)
\end{aligned}
\end{equation*}

We'd like to see that the model has at least the fixed points $\mathbf{n}^* = (n^*_U,0)$ and $(0,n^*_I)$. The lecture then somehow defines
\begin{equation*}
\begin{aligned}
n^*_I &= \lambda - \mu \frac{d}{r}\\
n^*_U &= 1-\frac{d}{r}
\end{aligned}
\end{equation*}
so that our differential equations become
\begin{equation*}
\begin{aligned}
\frac{d}{dt} n_U &= n_U \left[n^*_U - \frac{n_I}{n_U+n_I} - (n_U+n_I)\right]\\
\frac{d}{dt} n_I &= n_I \left[n^*_ - (n_U+n_I)\right]
\end{aligned}
\end{equation*}
which has fixed points $(0,0),(n^*_U,0),(0,n^*_I),(n^*_I(1-n^*_I-n^*_U),n^*_I(n^*_U-n^*_I))$. The first is unstable, the second two are stable and the last fixed point is a saddle. This is disappointing because we want a small infection to be spread out to the whole population, but in that case the second fixed point needs to be unstable.

Global analysis:

We can plot the flow of the ode system
\begin{equation*}
\begin{aligned}
\frac{d}{dt} {n_U \choose n_I} = {{f_U(n_U,n_I)} \choose {f_I(n_U,n_I)}}
\end{aligned}
\end{equation*}
This is usually done by programming. We'll try to sketch the flow of this model:

\includegraphics[scale=0.5]{image/Bio_04.png}

Qualitative behaviour: we need a finite (large) $n_I(0)$ (in order to converge to $(n^*_I,0)$).

For quantitative part we can only do numerical integrations.

Now we consider an epidemic model, where each individual may pass through three phases: susceptibles, infectives, recovered (compartment models -- same individual for different phases). We use $S(t),I(t),R(t)$ to denote the population of each of them.

\includegraphics[scale=0.5]{image/Bio_05.png}

Now we want to know what is the rate of their change. We use biological datum, from which we know there is a per capita infection rate $\beta$, a recovery rate $\nu$, so in conclusion we have
\begin{equation*}
\begin{aligned}
\frac{d}{dt} S &= -\beta SI\\
\frac{d}{dt} I &= \beta SI - \nu I\\
\frac{d}{dt} R &= \nu
\end{aligned}
\end{equation*}
Also we expect the population to be closed, i.e. the total population should not change over time (unlike the previous model), so
\begin{equation*}
\begin{aligned}
\frac{d}{dt}(S+I+R) = 0
\end{aligned}
\end{equation*}
Which is true. So it's sufficient to look at just two equations,
\begin{equation*}
\begin{aligned}
\frac{dS}{dt} &= -\beta SI\\
\frac{dI}{dt} &= \beta SI - \nu I
\end{aligned}
\end{equation*}
What are the questions we want to ask? We may want to know:\\
$\bullet$ When can you have an \emph{outbreak}, i.e. $\frac{dI}{dt}>0$;\\
$\bullet$ What is the final size of the outbreak?\\
$\bullet$ What vaccination strategy would work best?\\
$\bullet$ Endemic $\implies I^*>0$, finite number of $I$ in steady state.

For obvious reason we call this the "SIR model".

(Q1)\\
at $t=0$, $\frac{d}{dt}I = [\beta S(0) - \nu] \cdot I(0)$, so $\frac{\beta}{\mu}S(0) > 1 \implies \frac{\beta N}{\nu}>1 = \mathcal{R}_0$, the reproduction ratio, or the mean number of susceptibles infected per infective.

(Q2)\\
\includegraphics[scale=0.5]{image/Bio_06.png}
\includegraphics[scale=0.5]{image/Bio_07.png}
We had $dS = -\beta SI dt$, $dI = (\beta SI - \nu I) dt$, so
\begin{equation*}
\begin{aligned}
\frac{dI}{dS} &= \frac{(\beta SI - \nu I)}{-\beta SI} = -1 + \frac{\nu}{\beta} \cdot \frac{1}{S}\\
&= \frac{N}{\mathcal{R}_0} \cdot \frac{1}{S} - 1
\end{aligned}
\end{equation*}
So
\begin{equation*}
\begin{aligned}
I=\frac{N}{\mathcal{R}_0} \ln S - S + \text{ const}
\end{aligned}
\end{equation*}
Now $I(t)-I(0) = \frac{N}{\mathcal{R}_0} \ln \frac{S(t)}{S(0)} - (S(t)-S(0))$. As $t \to \infty$, $S(t) = \sigma N$ ($\sigma < 1$, $I(t) \to 0$. So
\begin{equation*}
\begin{aligned}
0 &= \frac{N}{\mathcal{R}_0} \ln \sigma - (\sigma N-N)\\
\sigma - \frac{1}{\mathcal{R}_0} \ln \sigma &= 1
\end{aligned}
\end{equation*}
We can rewrite the second equation as $\mathcal{R}_0 (\sigma-1) = \ln \sigma$. Clear $\sigma = 1$ is a solution, but we are not interested in that. For $\mathcal{R}_0 \gg 1$, $\sigma \approx e^{-\mathcal{R}_0}$.(by sketching curves below and analyze intersections?)
\includegraphics[scale=0.5]{image/Bio_08.png}

Insight: in any epidemic, only a fraction of the population is infected. Size of the epidemic = $(1-\sigma)N$.

(Q3)\\
Vaccination? We can use pre-vaccination, i.e. vaccinate in anticipation of an outbreak. Let $p$ be the fraction of the population being vaccinated. At $t=0$ we have
\begin{equation*}
\begin{aligned}
S(0) \approx (1-p)N\\
\frac{\beta}{\nu} S(0) > 1 \implies \frac{\beta}{\nu} (1-p)N = (1-p)\mathcal{R_0} > 1
\end{aligned}
\end{equation*}
so $p>1-\frac{1}{\mathcal{R}_0}$.
\includegraphics[scale=0.5]{image/Bio_09.png}

(Q4)\\
Endemic: $I(t) \to I^* > 0$ as $t \to \infty$.\\
Biological datum: suppose we have a finite rate of birth of $S$, and of death of $S,I,R$. Now
\begin{equation*}
\begin{aligned}
\frac{d}{dt} S = -\beta SI - \mu S + \mu N\\
\frac{d}{dt} I = \beta SI - \nu I - \mu I\\
\frac{d}{dt} R = \nu I - \mu R
\end{aligned}
\end{equation*}
at $t=0$, $\mathcal{R} = \frac{\beta}{\nu+\mu}N$(??). So
\begin{equation*}
\begin{aligned}
S^* &= \frac{\mu+\nu}{\beta} = \frac{N}{\mathcal{R}_0}\\
I^* &= \frac{\mu(N-S^*)}{\beta S^*} = \frac{\mu}{\beta}(\mathcal{R}_0-1)
\end{aligned}
\end{equation*}
We had a Jacobian (?)
\begin{equation*}
\begin{aligned}
J=\begin{pmatrix}
-\beta I - \mu & -\beta S\\
\beta I & \beta S - \nu - \mu
\end{pmatrix}
\end{aligned}
\end{equation*}
so
\begin{equation*}
\begin{aligned}
J^*=\begin{pmatrix}
-\mu \mathcal{R}_0 & -(\mu+\nu)\\
\beta(\mathcal{R}_0-1) & 0
\end{pmatrix}
\end{aligned}
\end{equation*}
$\lambda = -\frac{1}{2} \mu \mathcal{R}_0 \pm i\sqrt{\mu\nu(\mathcal{R}_0 - 1}$ (?). If we assume $\nu \gg \mu$, then rate of recovery $\gg$ rate of death, so we get a short lived disease.

\includegraphics[scale=0.5]{image/Bio_10.png}
\includegraphics[scale=0.5]{image/Bio_11.png}

Time period is $T = \frac{2\pi}{\omega} = \frac{2\pi}{\sqrt{\mu\nu(R_0-1)}}$

If $\mu \gg \nu$, for example, for Measles we have $\mu \sim \frac{1}{70}$ years, $\nu \sim \frac{1}{10}$ days, $\mathcal{R}_0 \sim 20$, so the period of oscillation $T \approx 2.18$ years. Then we have the following pattern.

\includegraphics[scale=0.5]{image/Bio_12.png}

\newpage

\section{Enzyme Kinetics}

Enzyme is biological catalyst, which speeds up the process of reaction (substrate turning to product) without being consumed in the process.

\includegraphics[scale=0.5]{image/Bio_13.png}

Suppose we have the model
\begin{equation*}
\begin{aligned}
\frac{dS}{dt} = -\bar{k}S & \text{ no enzyme}\\
\frac{dS}{dt} = -kS & \text{ enzyme present}
\end{aligned}
\end{equation*}
where $k \gg \bar{k}$.

Hypothesis: (Michaelis-Menten, $\sim$1915)
\begin{equation*}
\begin{aligned}
S + E \xrightarrow{k_1} C \text{ (complex)}\\
C \xrightarrow{k_2} S+E\\
C \xrightarrow{k_3} E+P
\end{aligned}
\end{equation*}
Under this model, we have
\begin{equation*}
\begin{aligned}
\frac{d}{dt} S &= -k_1 ES + k_2C\\
\frac{d}{dt} E &= -k_1 ES + k_2C + k_3 C\\
\frac{d}{dt} C &= k_1 ES - k_2C - k_3 C\\
\frac{d}{dt} P &= k_3 C
\end{aligned}
\end{equation*}

We see that $\frac{d}{dt} (E+C)=0$, and $\frac{d}{dt} (S+C+P)=0$. Therefore, $E+C=e_0$ is constant and $S+C+P=s_0$ is constant. There are 4 equations and 2 constraints, so we can reduce the dimension of the equation. We will choose
\begin{equation*}
\begin{aligned}
\frac{d}{dt} S = -k_1(e_0-C) S + k_2 C = -k_1e_0 S + (k_1S+k_2) C\\
\frac{d}{dt} C = k_1(e_0-C)S - k_2C - k_3C = k_1 e_0 S - (k_1S+k_2+k_3) C
\end{aligned}
\end{equation*}
We use our old trick (?) of rescaling variables by $n_S = \frac{S}{s_0}$, $n_C = \frac{C}{e_0}$, then $n_S=1$ and $n_C=0$ at $t=0$. The equations become
\begin{equation*}
\begin{aligned}
\frac{d}{dt} n_S = -n_S + (n_S + \mu-\lambda) n_C\\
\varepsilon \frac{d}{dt} n_C = n_S - (n_S+\mu) n_C
\end{aligned}
\end{equation*}
where $\mu = \frac{k_3}{k_1s_0}, \lambda = \frac{k_2+k_3}{k_1s_0}, \varepsilon = \frac{e_0}{s_0} \ll 1$.

Steady state value of $n_C$ assuming $n_S$ is fixed:\\
$n_C = \frac{n_S}{n_S+\mu}$ as $t \to \infty$. Plug them back into $n_S$ equation, get
\begin{equation*}
\begin{aligned}
\frac{d}{dt} n_S = -n_S + (n_S+\mu-\lambda) \frac{n_S}{n_S+\mu}\\
\frac{d}{dt} n_S = -\frac{\lambda n_S}{n_S + \mu} \ (*)
\end{aligned}
\end{equation*}
This is called the Michaelis-Menten equation.

\section{Prey-predator system}
Suppose we have rabbits with number $n_R$, and foxes with number $n_F$. Our biological datum is that if there is no predation then rabbits grow unboundedly, and foxes die (as they have nothing to eat). With predation, rabbits die at a rate $b$ per capita, and foxes reproduce at a rate $c$ per capita. We have
\begin{equation*}
\begin{aligned}
\frac{d}{dt} n_R = a \cdot n_R - b n_R n_F\\
\frac{d}{dt} n_F = c n_R n_F - dn_F
\end{aligned}
\end{equation*}
we write as
\begin{equation*}
\begin{aligned}
\frac{d}{dt} n_R = n_R (1-n_F)\\
\frac{d}{dt} n_F = -\alpha n_F (1-n_R)
\end{aligned}
\end{equation*}
This has fixed points $(0,0)$ and $(1,1)$, and has Jacobian
\begin{equation*}
\begin{aligned}
\begin{pmatrix}
1-n_F & -n_R\\
\alpha n_F & -\alpha(1-n_R)
\end{pmatrix}
\end{aligned}
\end{equation*}
evaluate at the two fixed points, we see that $(0,0)$ is unstable (actually a saddle), and the $(1,1)$ fixed point has eigenvalue (of Jacobian) $\pm i\sqrt{\alpha}$. Since the real part is 0 we don't know (yet) whether it is stable or not. We have to solve the equations of motion:
\begin{equation*}
\begin{aligned}
d n_R = n_R (1-n_F) dt\\
d n_F = -\alpha n_F (1-n_R) dt
\end{aligned}
\end{equation*}
so $\frac{d n_R}{dn_F} = \frac{n_R (1-n_F)}{-\alpha n_F(1-n_R)}$, i.e. $\alpha \frac{1-n_R}{n_R} dn_R = -\frac{1-n_F}{n_F} dn_F$ so $\alpha(\log n_R - n_R) = -(\log n_F - n_F) + c$. We get $H(n_R,n_F) = \alpha(n_R - n_R) + \log n_F - n_F = $constant, where $H(n_R,n_F)$ is the integral of motion. So we should observe the number $n_R$ and $n_F$ show a pattern of oscillation with some period $T$ which we wish to find.

\includegraphics[scale=0.5]{image/Bio_14.png}

We'll get $T=1$ after some interesting contour integration (no idea) $\oint d(\ln n_R ) = \int_0^\pi (1-n_F)dt$.

What if both are hunted upon (say by a disease)? Let the death rate of rabbits and foxes be $\lambda_R$ and $\lambda_F$ respectively. Then $\frac{d}{dt} n_R = an_R - bn_Rn_F - \lambda_R n_R$, $\frac{d}{dt} n_F = cn_Rn_F - dn_R-\lambda_F n_F$. We introduce a shift parameter $a \to a-\lambda_R$, $d \to d+\lambda_F$, then we find that there is a shift on the fixed points: the fixed point in original variables is $(n^*_R,n^*_F) = (d/c,a/b)$. Now the new fixed point becomes $(n^*_R$, $n^*_F) =((d+\lambda_F)/c,(a-\lambda_R)/b)$.

Fragility of ecosystems: if we add competition:

\begin{equation*}
\begin{aligned}
\frac{d}{dt} n_R &= n_R(1-n_F) - \varepsilon_R n_R^2\\
\frac{d}{dt} n_F &= -\alpha n_F(1-n_R) - \alpha \varepsilon_F n_F^2
\end{aligned}
\end{equation*}
After doing the same calculation we get
\begin{equation*}
\begin{aligned}
n_R^* &= \frac{1+\varepsilon_F}{1+\varepsilon_R\varepsilon_F}\\
n_F^* &= \frac{1-\varepsilon_F}{1+\varepsilon_R\varepsilon_F}\\
J^* &= \begin{pmatrix}
-\varepsilon_R n_R^* & -n_R^*\\
\alpha n_F^* & -\alpha\varepsilon_F n_F^*
\end{pmatrix}
\end{aligned}
\end{equation*}
and only the (2,1) entry is positive, so $\tr J <0$, $\det J >0$. So this fixed point now becomes stable.

Let's consider another model, the Fitzhugh-Nagumo model:
\begin{equation*}
\begin{aligned}
\frac{d}{dt} n_1 = c(n_2+n_1 - \frac{1}{3} n_1^3 + \mathcal{L}(t))\\
\frac{d}{dt} n_2 = -\frac{1}{c} (n_1 - a+bn_2)
\end{aligned}
\end{equation*}
where $\mathcal{L}(t)$ is an external signal, which can depend on time.

Nullclines(maybe something in dynamical systems?):\\
\begin{equation*}
\begin{aligned}
\frac{d}{dt} n_1 = 0 \implies n_2 = -n_1 + \frac{1}{3} n_1^3\\
\frac{d}{dt} n_2 = 0 \implies n_2 = \frac{a-n_1}{b}
\end{aligned}
\end{equation*}
where $\mathcal{L}(t) = 0$. The parameter bounds are $0<b\leq 1, 1-\frac{2}{3} b < a < 1, c \gg 1$. If we plot the two graphs we get fixed point at $n_1>0,n_2<0$, a stable focus.

\includegraphics[scale=0.5]{image/Bio_15.png}

If we now add $\mathcal{L}(t)$, we are essentially moveing the cubic curve upwards. There are three cases in terms of the magnitude added:\\
(1) small: nothing interesting happens, the fixed point just moves by a bit;\\
(2) medium: $n_2$ spikes up first, then falls back to the fixed points;
(3) large: fixed points lose stability; $n_2$ oscillate like the above diagram, with spikes after certain periods.

\iffalse

\begin{equation*}
\begin{aligned}

\end{aligned}
\end{equation*}
\fi

\end{document}


\vsssub
\subsubsection{~$S_{in} + S_{ds}$:  Tolman and Chalikov 1996} \label{sec:ST2}
\vsssub

\opthead{ST2}{\ws}{H. L. Tolman}

\noindent
The source term package of \cite{tol:JPO96} consists of the input source term
of \cite{art:CB93} and \cite{art:Cha95}, and two dissipation constituents. The
input source term is given as

%----------------------------%
% Chalikov an Belevich input %
%----------------------------%
% eq:CB93_gen

\begin{equation}
\cS_{in}(k,\theta) = \sigma \, \beta \, N(k,\theta)
\: , \label{eq:CB93_gen} \end{equation}

\noindent
where $\beta$ is a nondimensional wind-wave interaction parameter, which is
approximated as

% eq:CB93_beta

\begin{equation}
10^4 \beta = \left \{
\begin{array}{ccrcl}
-a_1\toa^2 -a_2          &,&             & \toa & < -1     \\
a_3\toa(a_4\toa-a_5)-a_6 &,&         -1 \leq & \toa & <\Omega_1/2 \\
(a_4\toa-a_5)\toa        &,& \Omega_1/2 \leq & \toa & <\Omega_1   \\
a_7\toa-a_8              &,&   \Omega_1 \leq & \toa & <\Omega_2   \\
a_9(\toa-1)^2+a_{10}     &,&   \Omega_2 \leq & \toa &
\end{array} \right . \label{eq:CB93_beta}
\end{equation}

\noindent
where

% eq:CB93_oma

\begin{equation}
\toa= \frac{\sigma \; u_{\lambda}}{g} \cos(\theta-\theta_w)
\label{eq:CB93_oma} \end{equation}

\noindent
is the non-dimensional frequency of a spectral component, $\theta_w$ is the
wind direction and $u_{\lambda}$ is the wind velocity at a height equal to the
`apparent' wave length

% eq:CB93_lam

\begin{equation}
\lambda_a = \frac{ 2 \pi }{ k | \cos(\theta-\theta_w) | }
\: . \label{eq:CB93_lam} \end{equation}

\noindent
The parameters $a_1-a_{10}$ and $\Om_1,\Om_2$ in Eq.~(\ref{eq:CB93_beta})
depend on the drag coefficient $\CL$ at the height $z=\lambda_a$:

% eq:omapar        Approximation parameters

\begin{equation} \begin{array}{lcl}
\Om_1=1.075+75\CL  &\Om_2=& 1.2+300\CL                     \\
a_1=0.25+395\CL,    &a_3 =& (a_0-a_2-a_1)/(a_0+a_4+a_5)    \\
a_2=0.35+150\CL,    &a_5 =& a_4\Om_1                       \\
a_4=0.30+300\CL,    &a_6 =& a_0(1-a_3)                     \\
a_9=0.35+240\CL,    &a_7 =&
                     (a_9(\Om_2-1)^2+a_{10})/(\Om_2-\Om_1) \\
a_{10}=-0.05+470\CL,&a_8 =& a_7\Om_1                       \\
                    &a_0 =& 0.25 a_5^2/a_4
\end{array} \label{eq:omapar} \end{equation}

\noindent
The wave model takes the wind $u_r$ at a given reference height $z_r$ as its
input, so that $u_\lambda$ and $\CL$ need to be derived as part of the
parameterization. Excluding a thin surface layer adjusting to the water
surface, the mean wind profile is close to logarithmic

% eq:u_z

\begin{equation}
u_z = \frac{v_\ast}{\kappa} \ln \left ( \frac{z}{z_0} \right )
\: , \label{eq:u_z}
\end{equation}

\noindent
where $\kappa = 0.4 $ is the Von K\`{a}rm\`{a}n constant, and $z_0$ is the
roughness parameter. This equation can be rewritten in terms of the drag
coefficient $C_r$ at the reference height $z_r$ as \citep{art:Cha95}

% eq:C95C
% eq:C95R
% eq:C95Ca

\begin{equation}
C_r = \kappa^2 \left [ R - \ln(C) \right ] ^2
\: , \label{eq:C95C} \end{equation} where \begin{equation}
R = \ln \left ( \frac{z_r g}{\chi \sqrt{\alpha} u_r^2} \right )
\: , \label{eq:C95R} \end{equation}

\noindent
where $\chi = 0.2$ is a constant, and where $\alpha$ is the conventional
nondimensional energy level at high frequencies. An accurate explicit
approximation to these implicit relations is given as

\begin{equation}
C_r = 10^{-3} \left ( 0.021 + \frac{10.4}{R^{1.23}+1.85} \right )
\: . \label{eq:C95Ca} \end{equation}

The estimation of the drag coefficient thus requires an estimate of the
high-frequency energy level $\alpha$, which could be estimated directly from
the wave model. However, the corresponding part of the spectrum is generally
not well resolved, tends to be noisy, and is tainted by errors in several
source terms. Therefore, $\alpha$ is estimated parametrically as
\citep{art:Jan89}

% eq:alpha_J89

\begin{equation}
\alpha = 0.57 \left ( \frac{u_\ast}{c_p} \right )^{3/2}
\: . \label{eq:alpha_J89} \end{equation}

\noindent
As the latter equation depends on the drag coefficient, Eqs.~(\ref{eq:C95R})
through (\ref{eq:alpha_J89}) formally need to be solved iteratively. Such
iterations are performed during the model initialization, but are not
necessary during the actual model run, as $u_\ast$ generally changes
slowly. Note that Eq.~(\ref{eq:alpha_J89}) can be considered as an internal
relation to the parameterization of $C_r$, and can therefore deviate from
actual model behavior without loss of generality. In \cite{tol:JPO96}, $C_r$
is therefore expressed directly in terms of $c_p$.

Using the definition of the drag coefficient and Eq.~(\ref{eq:u_z}) the
roughness parameter $z_0$ becomes

% eq:z0

\begin{equation}
z_0 = z_r \; \exp \left ( - \kappa C_r^{-1/2} \right )
\; , \label{eq:z0} \end{equation}

\noindent
and the wind velocity and drag coefficient at height $\lambda$ become

% eq:ul
% eq:Cl

\begin{equation}
u_{\lambda} = u_r \frac{ln(\lambda_a/z_0)}{ln(z_r/z_0)},
\label{eq:ul} \end{equation} \begin{equation}
C_{\lambda} = C_r \left ( \frac{u_a}{u_\lambda}
\right ) ^2 ,\label{eq:Cl}
\end{equation}

\noindent
Finally, Eq.~(\ref{eq:alpha_J89}) requires an estimate for the peak frequency
$f_p$. To obtain a consistent estimate of the peak frequency of actively
generated waves, even in complex multimodal spectra, this frequency is
estimated from the equivalent peak frequency of the positive part of the input
source term \citep[see][]{tol:JPO96}

% eq:fp_ir

\begin{equation}
f_{p,i} =
\frac { \int \int \: f^{-2} \: c_g^{-1} \:
\max \: [ \: 0 \:,\: \cS_{wind}(k,\theta) \: ] \: d f \: d\theta }
{ \int \int \: f^{-3} \: c_g^{-1} \:
\max \: [ \: 0 \:,\: \cS_{wind}(k,\theta) \: ] \: d f \: d\theta }
\: , \label{eq:fp_ir}
\end{equation}

\noindent
from which the actual peak frequency is estimated as (the tilde identifies
nondimensional parameter based on $u_\ast$ and $g$)

% eq:fp_fpi

\begin{equation}
\tilde{f}_p \: = \: 3.6 \: 10^{-4} \: + \: 0.92 \tilde{f}_{p,i}
\: - \: 6.3 \: 10^{-10} \: \tilde{f}_{p,i}^{-3}
\:\: . \label{eq:fp_fpi} \end{equation}

\noindent
All constants in the above equations are defined within the model. The user
only defines the reference wind height $z_r$.

During testing of a global implementation of \ws\ including this source term
\citep{tol:OMB02a}, it was found that its swell dissipation due to opposing or
weak winds was severely overestimated. To correct this deficiency, a filtered
input source term is defined as

% eq:swellf         Input source term (modified)

\begin{equation}
\cS_{i,m} = \left \{ \begin{array}{ccccc}
    \cS_i         & \mbox{for} & \beta \geq 0 & \mbox{or}  & f > 0.8 f_p \\
  X_s \cS_i       & \mbox{for} & \beta < 0    & \mbox{and} & f < 0.6 f_p \\
{\cal{X}}_s \cS_i & \mbox{for} & \beta < 0    & \mbox{and} & 0.6 f_p < f < 0.8 f_p
\end{array} \right . \: , \label{eq:swellf} \end{equation}

\noindent
where $f$ is the frequency, $f_p$ is the peak frequency of the wind sea as
computed from the input source term, $\cS_i$ is the input source term
(\ref{eq:CB93_gen}), and $0 < X_s < 1$ is a reduction factor for $\cS_i$,
which is applied to swell with negative $\beta$ only (defined by the
user). ${\cal{X}}_s$ represents a linear reduction of $X_s$ with $f_p$
providing a smooth transition between the original and reduced input.

The drag coefficient that follows from Eq.~(\ref{eq:alpha_J89}) becomes
unrealistically high for hurricane strength wind speeds, leading to
unrealistically high wave growth rates. To alleviate this, the drag
coefficient at the reference height $C_r$ can be capped with a maximum allowed
drag coefficient $C_{r,max}$, either as a simple hard limit

\begin{equation}
C_r = \min ( C_r , C_{r,max}) \:\:\: , \label{eq:Cd_cap_1}
\end{equation}

\noindent
or with a smooth transition

\begin{equation}
C_r = C_{r,max} \tanh ( C_r / C_{r,max} ) \:\:\: . \label{eq:Cd_cap_2}
\end{equation}

\noindent
Selection of the capped drag coefficient occurs at the compile stage of the
code. The cap level and cap type can be set by the user. Defaults settings are
$C_{r,max} = 2.5 \:10^{-3}$ and Eq.~(\ref{eq:Cd_cap_1}).

The corresponding dissipation source term consists of two constituents.  The
(dominant) low-frequency constituent is based on an analogy with energy
dissipation due to turbulence,

%-------------------------------%
% TC, low frequency dissipation %
%-------------------------------%
% eq:TCdl
% eq:h
% eq:phi

\begin{equation}
\cS_{ds,l}(k,\theta) = -2 \: u_{\ast} \: h \: k^2 \phi
\: N(k,\theta) \: , \label{eq:TCdl}
\end{equation} \begin{equation}
h = 4\left(\int_{0}^{2\pi} \int_{f_h}^{\infty} \: F(f,\theta) \:
d f \: d\theta \right)^{1/2} \: . \label{eq:h} \end{equation} \begin{equation}
\phi = b_0 + b_1 \tilde{f}_{p,i}  + b_2 \tilde{f}_{p,i} ^{- b_3}
\: . \label{eq:phi} \end{equation}

\noindent
where $h$ is a mixing scale determined from the high-frequency energy content
of the wave field and where $\phi$ is an empirical function accounting for the
development stage of the wave field. The linear part of Eq.~(\ref{eq:phi})
describes dissipation for growing waves. The nonlinear term has been added to
allow for some control over fully grown conditions by defining a minimum value
for $\phi$ ($\phi_{\min}$) for a minimum value of $f_{p,i}$
($f_{p,i,\min}$). If $\phi_{\min}$ is below the linear curve, $b_2$ and $b_3$
are given as

% eq:b_21
% eq:b_31

\begin{equation}
b_2 = \tilde{f}_{p,i,\min}^{b_3} \: \left ( \phi_{\min} - b_0
- b_1 \tilde{f}_{p,i,\min} \right ) \: , \label{eq:b_21}
\end{equation} \begin{equation}
b_3 = 8 \: . \label{eq:b_31}
\end{equation}

\noindent
If $\phi_{\min}$ is above the linear curve, $b_2$ and $b_3$ are given as

% eq:f_a           Auxiliary frequency
% eq:b_22          Equation b_2 above
% eq:b_32          Equation b_3 above

\begin{equation}
\tilde{f}_a = \frac{\phi_{\min} - b_0}{b_1} \:\:\: , \:\:\:
\tilde{f}_b = \max \: \left \{ \: \tilde{f}_a - 0.0025 \: , \:
\tilde{f}_{p,i,\min} \: \right \} \:\:\: , \label{eq:f_a}
\end{equation} \begin{equation}
b_2 = \tilde{f}_b^{b_3} \left [ \phi_{\min} - b_0 -
b_1 \tilde{f}_b \right ] \: , \label{eq:b_22}
\end{equation} \begin{equation}
b_3 = \frac{b_1 \tilde{f}_b}{\phi_{\min} -b_0 -b_1 \tilde{f}_b}
\: . \label{eq:b_32}
\end{equation}

\noindent
The above estimate of $b_3$ results in $\partial \phi / \partial
\tilde{f}_{p,i} = 0$ for $\tilde{f}_{p,i} = \tilde{f}_b$. For $\tilde{f}_{p,i}
< \tilde{f}_b$, $\phi$ is kept constant ($\phi = \phi_{\min}$).

The empirical high-frequency dissipation is defined as

%--------------------------------%
% TC, high frequency dissipation %
%--------------------------------%
% eq:TCdh

\begin{equation}
\cS_{ds,h}(k,\theta) = - a_0 \left ( \frac{u_\ast}{g} \right ) ^2  f^3 \:
\alpha_n^B \: N(k,\theta) \:\:\: , \label{eq:TCdh}
\end{equation} \begin{displaymath}
B = a_1 \left( \frac{ f u_\ast}{g} \right ) ^{-a_2}
\:\:\: , \end{displaymath} \begin{equation}
\alpha_n = \frac{\sigma^6}{c_g \: g^2 \alpha_r} \int_0^{2\pi} N(k,\theta) \: d\theta
\:\:\: , \label{eq:alpha_n} \end{equation}

\noindent
where $\alpha_n$ is Phillips' nondimensional high-frequency energy level
normalized with $\alpha_r$, and where $a_0$ through $a_2$ and $\alpha_r$ are
empirical constants. This parameterization implies that $m = 5$ in the
parametric tail, which has been preset in the model. Note that in the model
Eq.~(\ref{eq:alpha_n}) is solved assuming a deep water dispersion relation, in
which case $\alpha_n$ is evaluated as

\begin{equation}
\alpha_n = \frac{2 \: k^3}{\alpha_r}  F(k)
\:\:\: . \label{eq:alpha_n_mod} \end{equation}

\noindent
The two constituents of the dissipation source term are combined using a
simple linear combination, defined by the frequencies $f_1$ and $f_2$.

%-----------------------%
% TC, total dissipation %
%-----------------------%
% eq:TCdtot
% eq:filt_A        Dissipation filter function

\begin{equation}
\cS_{ds}(k,\theta) = {\cal{A}} \cS_{ds,l} +
\left ( 1 - {\cal{A}} \right ) \cS_{ds,h}
\: , \label{eq:TCdtot} \end{equation} \begin{equation}
{\cal A} = \left \{ \begin{array}{ccrclc}
  1  & \;{\rm for}\; &          &\!\!\!f& \!\!\! < f_l & ,\\
\frac{ f-f_2}{f_1-f_2}
     & \;{\rm for}\; & f_1 \leq &\!\!\!f& \!\!\! < f_2 & ,\\
  0  & \;{\rm for}\; & f_2 \leq &\!\!\!f&              & .
\end{array} \right . \label{eq:filt_A} \end{equation}

\noindent
To enhance the smoothness of the model behavior for frequencies near the
parametric cut-off $f_{hf}$, a similar transition zone is used between the
prognostic spectrum and the parametric high-frequency tail as in
Eq.~(\ref{eq:tail_N_k})

% eq:smtail

\begin{equation}
N(k_i,\theta) = \left ( 1 - {\cal{B}} \right ) N(k_{i},\theta) +
{\cal{B}} N(k_{i-1},\theta) \left ( \frac{f_i}{f_{i-1}}\right ) ^{-m-2}
\: , \label{eq:smtail}
\end{equation}

\noindent
where $i$ is a discrete wavenumber counter, and $\cal{B}$ is defined
similarly to $\cal{A}$, ranging from 0 to 1 between $f_2$ and $f_{hf}$.

The frequencies defining the transitions and the length scale $h$ are
predefined in the model as

% eq:TC_f

\begin{equation} \left . \begin{array}{lll}
  f_{hf} & = & 3.00 \: f_{p,i}  \\
  f_1 & = & 1.75 \: f_{p,i}  \\
  f_2 & = & 2.50 \: f_{p,i}  \\
  f_h & = & 2.00 \: f_{p,i}
\end{array} \:\:\: \right \rbrace \:\:\: . \label{eq:TC_f} \end{equation}

\noindent
Furthermore, $f_{p,i,\min} = 0.009$ and $\alpha_r = 0.002$ are preset in the
model. All other tunable parameters have to be provided by the user. Suggested
and default values are given in Table~\ref{tab:TC_par}.

% tab:TC_par

\begin{table} \begin{center}
\begin{tabular}{|l|c|c|c|c|c|c|} \hline \hline
Tuned to :  & $a_0$ &      $a_1$       & $a_2$ &
            $b_0$           & $b_1$  & $\phi_{\min} $\\ \hline
KC stable   &  4.8  & $1.7 \: 10^{-4}$ &  2.0  &
 $ \:\:\:\: 0.3 \: 10^{-3}$ &  0.47  &  0.003  \\
KC unstable &  4.5  & $2.3 \: 10^{-3}$ &  1.5  &
 $     -5.8 \: 10^{-3}$     &  0.60  &  0.003  \\ \hline \hline
\end{tabular} \end{center}
\caption{Suggested constants in the source term package of Tolman and
         Chalikov. KC denotes \cite{art:KC92,ibk:KC94}. First line represents
         default model settings.}
\label{tab:TC_par} \botline \end{table}

Test results of these source terms in a global model implementation
\citep{tol:OMB02a} suggested that (i) the model tuned in the classical way to
fetch-limited growth for stable conditions underestimates deep-ocean wave
growth (a deficiency apparently shared by the WAM model) and that (ii) effects
of stability on the growth rate of waves \citep{art:KC92,ibk:KC94} should be
included explicitly in the parameterization of the source terms.  Ideally,
both problems would be dealt with by theoretical investigation of the source
terms. Alternatively, the wind speed $u$ can be replaced by an effective wind
speed $u_e$. In \cite{tol:OMB02a} the following effective wind speed is used :

% eq:scor         Stability correction
% eq:c1
% eq:c2
% eq:stab         Stability parameter

\begin{equation}
\frac{u_e}{u} = \left ( \frac{c_o}{1 + C_1 + C_2} \right )^{1/2}
\: , \label{eq:scor} \end{equation} \begin{equation}
C_1 = c_1 \tanh \left [ \max ( 0 , f_1 \{ \ST - \ST_o \} ) \right ]
\: , \label{eq:c1} \end{equation} \begin{equation}
C_2 = c_2 \tanh \left [ \max ( 0 , f_2 \{ \ST - \ST_o \} ) \right ]
\: , \label{eq:c2} \end{equation} \begin{equation}
\ST = \frac{h g}{u_h^2} \: \frac{T_a - T_s}{T_0}
\: , \label{eq:stab} \end{equation}

\noindent
where $\ST$ is a bulk stability parameter, and $T_a$, $T_s$ and $T_0$ are the
air, sea and reference temperature, respectively. Furthermore, $f_1 \leq 0$,
$c_1$ and $c_2$ have opposite signs and $f_2 = f_1 c_1 / c_2$. Following
\cite{tol:OMB02a}, default settings of $c_0 = 1.4$, $c_1 = -0.1$, $c_2 = 0.1$,
$f_1 = -150$ and $\ST_o = -0.01$ in combination with the tuning to stable
stratification wave growth data (`KC stable' parameter values in
Table~\ref{tab:TC_par}) are used. Note that this effective wind speed was
derived for winds at 10~m height. The wind correction can be switched off by
the user during compilation of the model, and default parameter settings can
be redefined by the user in the program input files. This stability correction
is activated with the {\code STAB2} switch. The air-sea temperature differences
need to be provided by the user, e.g. using {\file ww3\_prep}.


% !TEX root = ../../main.tex
% !TEX spellcheck = en_GB

\section{Test}
\label{sec:test}
\subsection{Frequency determination}
\Cref{tab:test} shows the output of the Matlab model and the Blackfin implementation when determining the frequency of a \num{512} samples long input signal.
The Matlab model was run four times with four different inputs and applied a Hamming window, which the Blackfin implementation did not.
As can be seen the Matlab model is very precise in determining the frequency whereas the Blackfin implementation is slightly of.
The Blackfin being not as precise as the Matlab model can be attributed mostly to the lacking window and to quantization errors.

\begin{table}
	\centering
	\begin{tabular}{c | c c c c c | c}
		\toprule
		Test freq (Hz) & \multicolumn{4}{l}{Matlab freq (Hz)} & & Blackfin freq (Hz) \\
		\midrule
		\num{245} & \num{245.13} & \num{244.93} & \num{244.85} & \num{245.03} && \num{237}\\
		\num{350} & \num{349.90} & \num{349.94} & \num{349.88} & \num{349.96} && \num{349}\\
		\num{470} & \num{470.00} & \num{470.00} & \num{470.00} & \num{470.00} && \num{470} \\
		\num{521} & \num{521.22} & \num{521.18} & \num{521.10} & \num{521.04} && \num{525} \\
		\bottomrule
	\end{tabular}
	\caption{Tested frequencies and the found results using blocks of length \num{512}. Matlab results are the average of 4 blocks of \num{512} on a signal of length \num{2048}, each block windowed with a hamming window. It has been investigated if the \SI{470}{\hertz} results are due to an error, but it does not seem so.}
	\label{tab:test}
\end{table}

\subsection{Clock cycle usage}
A question to be asked is, "Can the processing of the signal occur before the next set of 512 samples?".
To find the answer for this, the clock cycles used of the FFT an the hilbert transform has been measured, and the amount of time at disposal has been calculated.

Time between sample blocks:
$td = \frac{samples}{fs} = \frac{512}{\SI{48}{\kilo\hertz}} = \SI{10.7}{\milli\second}$

Measurement of the clock cycles usage:
$\frac{1898733 cycles}{512 samples} = 3708 \frac{cyles}{sample}$.
Which is less then specified in the requirements.

The Blackfin has a maximum speed at \SI{600}{\mega\hertz}.
Which means it will take $\frac{\num{1898733}}{\SI{600}{\mega\hertz}} = {\SI{3.16}{\milli\second}}$ so the Hilbert transformation uses less time than the time it takes to sample 512 samples since $\SI{3.16}{\milli\second} < \SI{10.7}{\milli\second}$ and it uses less cycles pr. sample then specified in the requirements.
Concluding the Hilbert transform takes less time than it has at its disposal.

To generate 183 samples, with the sine generator it takes: $\frac{\num{26225} cycles}{183 samples} = \num{143.3}\frac{cycles}{sample}$.
This brings the total time of finding the frequency and generating one period of it up to \SI{3.21}{\milli\second}, still way below the threshold of \SI{10.7}{\milli\second}.

\subsubsection{Optimized clock cycle usage}
In the cross core environment it is possible to optimize the code with regards to size or speed.
This was done with three different settings for the optimization.
Firstly where the size was the main focus of the optimization.
Secondly the size and speed had same prioritization in the optimization settings.
And lastly where the speed was the focus. The result can be seen on
\begin{table}
	\centering
	\begin{tabularx}{0.95\textwidth}{l c c c c}
		\toprule
		{\textbf{Optimized for:}} & \textbf{None} & \textbf{Size} & \textbf{50\% Size 50\% Speed} & \textbf{Speed} \\
		\midrule
		\textbf{Hilbert transform} & \num{3708} & \num{3582} & \num{3577} & \num{3554} \\
		\textbf{Sine generator} & \num{143} & \num{115} & \num{115} & \num{115} \\
		\textbf{Total} & \num{3851} & \num{3697} & \num{3692} & \num{3669} \\
		\bottomrule
	\end{tabularx}
	\caption{The cycle usage with different settings for the optimization function in the cross core environment. Every value is shown in $\frac{\text{cycles}}{\text{sample}}$.}
	\label{OptimizedCycleUsage}
\end{table}

So if the code is optimized with regards to speed, the amount of cycles used becomes less, but a neglect able amount.

\FloatBarrier


\documentclass[a4paper,11pt]{article}
\usepackage{a4wide}
\usepackage{amsmath}
\usepackage{amssymb}
\begin{document}
\begin{center}
  {\LARGE\bf Supplemental note for Week 5 Part 1}
  \end{center}
\begin{flushright}
  {\large\bf ver. 20170417-01}\\
 \ \\
{\large\bf Ryoichi Yamamoto}\\
\end{flushright}

\section{Langevin Eq. $\rightarrow$ Fokker-Planck Eq.}

Let us start with the Langevin equation for a Brownian particle
\begin{equation}
m\frac{d\mathbf{V}(t)}{dt}=-\zeta\mathbf{V}(t)+\mathbf{F}(t),\tag{F2}
\end{equation}
where the random force satisfies
\begin{equation}
\langle\mathbf{F}(t)\rangle=\mathbf{0}\tag{F3}
\end{equation}
\begin{equation}
\langle\mathbf{F}(t)\mathbf{F}(0)\rangle=2k_BT\zeta\mathbf{I}\delta(t).\tag{F4}
\end{equation}
To derive a useful partial differential equation for the probability
distribution functions, we redefine the
Langevin equation in the following 1-dimensional form, assuming that the particle is subject to a conservative force $F_p(R(t),t)=-\frac{\partial U}{\partial R}$ due to a potential $U(R(t),t)$,
\begin{eqnarray}
m\frac{dV(t)}{dt}&=&-\zeta V(t)+F(t)+F_{p}(R(t),t),
\end{eqnarray}
where $R(t)$ represents the position of the Brownian particle at time $t$.
\\
Hereafter, we neglect the inertial term $m\frac{dV}{dt}\simeq 0$, since
we are mainly interested in the long-time behavior
$t\gg\frac{\zeta}{m}$ of the Brownian particle.
We thus obtain the overdamped Langevin equation,
\begin{eqnarray}
0&=&-\zeta V(t)+F(t)+F_{p}(R(t),t)\\
V(t)=\frac{dR(t)}{dt}&=&\frac{F_p(R(t),t)}{\zeta}+\frac{F(t)}{\zeta}.
\end{eqnarray}
Let us now rewrite this equation (3) in the following more general
form (making the substitution $R(t)\longrightarrow r(t)$)
\begin{equation}
\frac{dr(t)}{dt}=f(r(t),t)+g\eta(t),
\end{equation}
where $f$ is an arbitrary function of $r(t)$ and $t$, $g$ is a
constant, and $\eta(t)$ is a Gaussian white noise random variable with
\begin{eqnarray}
\langle\eta(t)\rangle&=&0\\
\langle\eta(t)\eta(t')\rangle&=&\delta(t-t').
\end{eqnarray}
Integration of Eq.(4) from $t=t_i$ to $t_{i+1}=t_i+\Delta t$, yields
\begin{eqnarray}
r(t_{i+1})-r(t_i)&=& \int_{t_i}^{t_{i+1}}f(r(t),t)dt + g\int_{t_i}^{t_{i+1}}\eta(t)dt\\
&\simeq& f(r(t_i),t_i)\Delta t + g\sqrt{\Delta t}\tilde{\eta}(t_i),
\end{eqnarray}
with
\begin{eqnarray}
\langle\tilde{\eta}(t)\rangle&=&0\\
\langle\tilde{\eta}(t_i)\tilde{\eta}(t_j)\rangle&=&\delta_{ij}
\end{eqnarray}
(see Eq.(F11) and the supplemental note for Week 4 Part 1).
\\
We now consider a general function $p\left[r(t)\right]$ of $r(t)$ and
make a Taylor expansion of it in terms of $\Delta t$, keeping only the
terms equal to and lower than the first-order in $\Delta t$
\begin{eqnarray}
p\left[r(t_{i+1})\right]&=&p\left[r(t_i)+f(r(t_i),t_i)\Delta t + g\sqrt{\Delta t}\tilde{\eta}(t_i)\right]\\
&\simeq&
p\left[r(t_{i})\right]+\dot{p}\left[r(t_{i})\right]
\left(f(r(t_i),t_i)\Delta t+g\sqrt{\Delta t}\tilde{\eta}(t_i)\right)\nonumber\\
&&+\frac{\ddot{p}\left[r(t_{i})\right]}{2}\left(f(r(t_i),t_i)\Delta t+g\sqrt{\Delta t}\tilde{\eta}(t_i)\right)^2+\cdots\\
&\simeq&
p\left[r(t_{i})\right]
+\dot{p}\left[r(t_{i})\right]g\tilde{\eta}(t_i)\Delta t^{0.5}
+\dot{p}\left[r(t_{i})\right]f(r(t_i),t_i)\Delta t\nonumber\\
&&+\frac{\ddot{p}\left[r(t_{i})\right]}{2}g^2\tilde{\eta}^2(t_i)\Delta t+{\cal O}(\Delta t^{1.5}),
\end{eqnarray}
where $\dot{p}\left[r(t_{i})\right]\equiv\left.\frac{dp}{dr}\right|_{r=r(t_{i})}$ and
$\ddot{p}\left[r(t_{i})\right]\equiv\left.\frac{d^2p}{dr^2}\right|_{r=r(t_{i})}$.
\\
Moving $p\left[r(t_{i})\right]$ to the left-hand-side, dividing by
$\Delta t$, and taking a statistical average, we obtain
\begin{eqnarray}
\left\langle\frac{p\left[r(t_{i+1})\right]-p\left[r(t_i)\right]}{\Delta t}\right\rangle
&=&
\left\langle \dot{p}\left[r(t_{i})\right]g\tilde{\eta}(t_i)\Delta t^{-0.5}\right\rangle
+\left\langle \dot{p}\left[r(t_{i})\right]f(r(t_i),t_i)\right\rangle\nonumber\\
&&+\left\langle\frac{\ddot{p}\left[r(t_{i})\right]}{2}g^2\tilde{\eta}^2(t_i)\right\rangle\\
&=&
\left\langle \dot{p}\left[r(t_{i})\right]\right\rangle g\left\langle\tilde{\eta}(t_i)\right\rangle\Delta t^{-0.5}
+\left\langle \dot{p}\left[r(t_{i})\right]f(r(t_i),t_i)\right\rangle\nonumber\\
&&+\left\langle\frac{\ddot{p}\left[r(t_{i})\right]}{2}g^2\right\rangle\left\langle\tilde{\eta}^2(t_i)\right\rangle
\end{eqnarray}
Substituting $\langle\tilde{\eta}(t_i)\rangle=0$ and $\langle\tilde{\eta}^2(t_i)\rangle=1$, and then taking the limit of $\Delta t\rightarrow 0$, one finally obtains
\begin{equation}
  \left\langle\frac{dp(r(t))}{dt}\right\rangle
  =\left\langle \dot{p}(r(t)f(r(t),t)\right\rangle+\left\langle\frac{\ddot{p}(r(t))}{2}g^2\right\rangle
\end{equation}
\\
Using the definition of a statistical average in terms of the
probability distribution function $P(r,t)$, we have
\begin{equation}
\left\langle p(r(t))\right\rangle=\int P(r,t)p(r)dr.
\end{equation}
The corresponding expressions for each of the terms appearing in
Eq.(16) are
\begin{eqnarray}
\left\langle \frac{dp(r(t))}{dt}\right\rangle&=&\frac{\partial}{\partial t}\int P(r,t)p(r)dr\\
\left\langle \dot{p}(r(t)f(r(t),t)\right\rangle&=&\int P(r,t)\dot{p}(r)f(r,t)dr\\
\left\langle \frac{\ddot{p}(r(t))}{2}g^2\right\rangle&=&\int P(r,t)\frac{\ddot{p}(r)}{2}g^2dr.
\end{eqnarray}
In the case that
$p(r(t))=\delta(r(t)-R)$, the above averages can be calculated as follows,
\begin{eqnarray}
\left\langle \frac{dp(r(t))}{dt}\right\rangle&=&\frac{\partial}{\partial t}\int P(r,t)\delta(r-R)dr=\frac{\partial}{\partial t}P(R,t)\\
\left\langle \dot{p}(r(t)f(r(t),t)\right\rangle&=&\int P(r,t)\frac{d}{dr}\delta(r-R)f(r,t)dr\\
&=&-\int \frac{d}{dr}\left(P(r,t)f(r,t)\right)\delta(r-R)dr\\
&=&-\frac{\partial}{\partial  R}\left(P(R,t)f(R,t)\right)\\
\left\langle \frac{\ddot{p}(r(t))}{2}g^2\right\rangle&=&\int P(r,t)\frac{g^2}{2}\frac{d^2}{dr^2}\delta(r-R)dr\\
&=&\int \delta(r-R)\frac{d^2}{dr^2}P(r,t)\frac{g^2}{2}dr\\
&=&\frac{g^2}{2}\frac{\partial}{\partial R^2}P(R,t).
\end{eqnarray}
Finally, substituting the above expression into Eq.(16) yields the Fokker-Planck equation shown below
\begin{equation}
\frac{\partial}{\partial t}P(R,t)=-\frac{\partial}{\partial  R}\left(P(R,t)f(R,t)\right)
+\frac{g^2}{2}\frac{\partial}{\partial R^2}P(R,t).
\end{equation}
\\
We can recover the original Langevin equation by changing variables as follows
\begin{eqnarray}
R&=&R_\alpha\\
f(R,t)&=&0\\
g^2&=&\frac{2k_BT}{\zeta}=2D,
\end{eqnarray}
then, the Fokker-Planck equation takes the usual form of a diffusion equation
\begin{equation}
\frac{\partial}{\partial t}P(R_\alpha,t)=
D\frac{\partial}{\partial R_\alpha^2}P(R_\alpha,t).
\end{equation}
Solving this with an initial condition $P(R_\alpha,t)=\delta(R_\alpha)$, yields
\begin{eqnarray}
  P(R_\alpha,t)&=&\frac{1}{\sqrt{4\pi Dt}}\exp\left[-\frac{R_\alpha^2}{4Dt}\right]\\
  &=&\frac{1}{\sqrt{2\pi \sigma^2}}\exp\left[-\frac{R_\alpha^2}{2\sigma^2}\right]
\end{eqnarray}
with $\sigma^2=\frac{2k_BT t}{\zeta}=2Dt$.
This is equivalent to Eq.(G1)-(G3).
\end{document}