\subsubsection{Transfer cost use case \label{sec:xfercost}}
If we take the final number from the key numbers page \footnote{\url{https://www.lsst.org/scientists/keynumbers}} we could consider \gls{DR1} as about 6 \gls{PB} (10\% of the final size).

We would have at least  two ways to transfer this : via the network, via physical devices.

A network transfer at 10Gbps of 6 \gls{PB} would take $8 * 6 \times 10^{12} \ 10^7 = 4.8 \times 10^{6}~seconds $ or about 55 days\footnote{ day = 86400s}.
Many institutes have 100 Gbps connections so this should be an upper limit and a transfer should be order one week. If we had a peer to peer network this may go down somewhat and we may be able to support it from the \gls{USDF}.

Alternatively we could host the data on Amazon or Google and let people download it from there - they would have more capacity.
Storage on the cloud  for public data would be theoretically free - download (egress)  would  cost.
Transfer to another cloud \footnote{\url{https://cloud.google.com/storage/pricingi\#network-pricing}}  or
 a Content Delivery Network (\gls{CDN})\footnote{\url{https://cloud.google.com/cdn/pricing}}
 end up costing  about a cent a \gls{GB} which for an open science project and at our volume  should  be negotiable.  At one cent a transfer would cost
  $\sim \$0.01 * 6 \times 10^{12} \ 10^6 = \$60K$.

For physical devices, today apparently we could get a device like Petarack \url{https://www.aberdeeninc.com/petarack/} for \$300K.
Theoretically we could get this cheaper though this is close to the drive price,
Tape may also be a possibility especially if Sony/IBM commercialize high density tape with >300TB per cartridge\footnote{\url{https://newatlas.com/sony-ibm-magnetic-tape-density-record/50743/}}. A current 6TB cartridge is about \$30, so enough tapes for 6PB would cost about  30K. If the density increased this could come down significantly.
This could be be a partner data center cost as well as shipping it. Transfer of data on to this would be about the same as the network rate above so 7 days. SneakerNet \cite{2002cs........8011G} may still be  cost effective in the \gls{LSST} era, which is predicted in the  paper.


\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[top=1cm, bottom=2.0cm, left=1.0cm, right=1.5cm]{geometry}
\usepackage{graphicx}
\usepackage{array}
\usepackage{bbold}
\usepackage{amsmath,amssymb}
\usepackage{caption}
\usepackage{hyperref}
\usepackage{cite}
\usepackage{here}
\usepackage{algpseudocode,algorithm,algorithmicx}
\usepackage{empheq}
\usepackage{lscape}
\usepackage{color}
\newcommand*\widefbox[1]{\fbox{\hspace{2em}#1\hspace{2em}}}
\newcommand{\vv}[1]{\mathbf{#1}}
\newcommand{\todo}[1]{\textcolor{red}{#1}}
\newcommand{\uni}[1]{\,\mathrm{#1}}
\newcommand{\ii}[0]{\mathrm{i}}
\newcommand{\dd}[0]{\mathrm{d}}
\newcommand{\kB}[0]{k_\mathrm{B}}
\DeclareMathOperator\arctanh{arctanh}
% define citation style
\bibliographystyle{unsrt}
\title{Test Results in the Context of Quantum/Casimir Friction}
\author{Marty Oelschläger}
\begin{document}
\maketitle
%\tableofcontents
\section{Introduction and Definitions}
Here, we like to sum up several important equations in the context of noncontact friction. For a detailed explanation see \cite{oelschlager2019a}. We describe a charge neutral microscopic object without an intrinsic magnetic dipole moving above a macroscopic surface, which is flat at least in the direction of motion of the object. Since we consider solely fluctuating fields, we assume that the coupling between the electromagnetic field with the macroscopic material as well as with the microscopic object is described sufficiently in linear coupling. This means that the equation of motion of the microscopic object's relative motion --- described by the electric dipole moment --- can be expressed as
\begin{align}
  \hat{\vv{d}}(\omega) = \underline{\alpha}(\omega) \hat{\vv{E}}(\vv r_\mathrm{cm}(t),\omega)\,,
\end{align}
where $\hat{\vv{d}}(\omega)$ is the dipole moment operator in frequency domain, $\hat{\vv{E}}(\vv r_\mathrm{cm}(t),\omega)$ is the electric field operator evaluated at the time-dependent center of mass of the microscopic object, and $\underline{\alpha}(\omega)$ is the corresponding polarizability of the dipole. In the case of a harmonic oscillator driven by the electric field and with an internal heat bath the polarizability can be written as
\begin{equation}
\underline{\alpha}(\omega)=
\alpha_0\omega_a^2 \left(
  \left[
  \omega_a^2 - \omega^2 -\ii\omega\mu(\omega)\right]\mathbb{1}
- \alpha_0\omega_a^2\int\frac{\mathrm{d}^2\mathbf{k}}{(2\pi)^2} \underline{G}(\mathbf{k},z_a,\mathbf{k}^\intercal \mathbf{v} + \omega)
\right)^{-1}\,,
\end{equation}
where $\underline{G}$ is the electric Green's tensor and $\vv k$ the reciprocal domain corresponding to the two dimensional spatial vector $\vv R=(x,\, y)^\intercal$, and $\mu_R(\omega)$ is the real part of the memory kernel $\mu(\omega)$, which encodes the internal bath dynamics of the microscopic object.
The electric field itself already includes a free field as well as an induced field of the dipole moment, which reads
\begin{align}
  \hat{\vv{E}}(\vv r,\omega) = \hat{\vv{E}}(\vv r,\omega) + \int\frac{\dd^2\vv k}{(2\pi)^2} \underline{G}(\vv k,z,\omega)\hat{\vv{d}}(\omega)e^{\ii\vv k^\intercal \vv R}
\end{align}
\\
The above introduced quantities cover all necessary ingredients to calculate the noncontact friction. Additionally, we introduce the power spectrum of the dipole moment's autocorrelator, which has the form
%
%
\begin{align}
\underline{S}(\omega)
=&\frac{\hbar}{\pi}\,
\underline{\alpha}(\omega)\Bigg\lbrace\int \frac{\mathrm{d}^2\mathbf{k}}{(2\pi)^2}
\frac{\underline{G}_\Im(\mathbf{k},z_a,\mathbf{k}^\intercal \mathbf{v} + \omega)}{1-e^{-\beta\hbar[\mathbf{k}^\intercal \mathbf{v} + \omega]}}
+\frac{1}{\alpha_0\omega_a^2}
\frac{\omega \mu_R(\omega)}{1-e^{-\beta\hbar\omega}}
\Bigg\rbrace \underline{\alpha}^\dagger(\omega)
%
\label{eq:powerspec}.
\end{align}
where $\beta= (k_\mathrm{B}T)^{-1}$ is the inverse temperature of the system. At this point it is noteworthy, that $\underline{S}$ and $\underline{\alpha}_\Im=(\underline{\alpha}-\underline{\alpha^\dagger})/(2\ii)$ are strongly related since
\begin{align}
\underline{\alpha}_\Im(\omega)
=&\frac{\hbar}{\pi}\,
\underline{\alpha}(\omega)\Bigg\lbrace\int \frac{\mathrm{d}^2\mathbf{k}}{(2\pi)^2}
\underline{G}_\Im(\mathbf{k},z_a,\mathbf{k}^\intercal \mathbf{v} + \omega)
+\frac{1}{\alpha_0\omega_a^2}
\omega \mu_R(\omega)
\Bigg\rbrace \underline{\alpha}^\dagger(\omega)
%
\label{eq:powerspec}.
\end{align}
As last note, we present the two implemented forms of the noncontact friction, which read
\begin{align}
\label{eq:numInt1}
F =&
-2
\int_{0}^{\infty} \mathrm{d}\omega\,
\mathrm{Tr}\left[
\underline{S}(\omega) \int\frac{\mathrm{d}^2\mathbf{k}}{(2\pi)^2} \, k_x\,\underline{G}_\Im(\mathbf{k}, z_a, k_xv+\omega)
\right]
\nonumber\\
&+
2\frac{\hbar}{\pi}
\int_{0}^{\infty} \mathrm{d}\omega\,
\mathrm{Tr}\left[
\underline{\alpha}_\Im(\omega)
\int\frac{\mathrm{d}^2\mathbf{k}}{(2\pi)^2} \, k_x\,
\frac{
\underline{G}_\Im(\mathbf{k}, z_a, k_xv+\omega)}{1-\exp(-\beta\hbar[\omega+k_xv])}
\right].
\end{align}
or
\begin{align}
\label{eq:numInt2}
F =&
-2
\frac{\hbar}{\pi}\int_{0}^{\infty} \mathrm{d}\omega\,
\mathrm{Tr}\left[
\underline{J}(\omega) \int\frac{\mathrm{d}^2\mathbf{k}}{(2\pi)^2} \, k_x\,\underline{G}_\Im(\mathbf{k}, z_a, k_xv+\omega)
\right]
\nonumber\\
&+
2\frac{\hbar}{\pi}
\int_{0}^{\infty} \mathrm{d}\omega\,
\mathrm{Tr}\left[
\underline{\alpha}_\Im(\omega)
\int\frac{\mathrm{d}^2\mathbf{k}}{(2\pi)^2} \, k_x\,
\underline{G}_\Im(\mathbf{k}, z_a, k_xv+\omega)\Theta(\Omega_+,\Omega)
\right],
\end{align}
where $\Omega=\hbar\beta\omega$ and $\Omega_+=\hbar\beta(\omega+k_xv)$, $\Theta(\Omega_+,\Omega)=\frac{1}{1-\exp(-\Omega_+)} - \frac{1}{1-\exp(-\Omega)}$ and
\begin{align}
  \frac{\hbar}{\pi}\underline{J}(\omega) =
  \underline{S}(\omega)-\frac{\hbar}{\pi}\frac{\underline{\alpha}_\Im(\omega)}{1-\exp(-\hbar\beta\omega)}=
\frac{\hbar}{\pi}\,
\underline{\alpha}(\omega)\int \frac{\mathrm{d}^2\mathbf{k}}{(2\pi)^2}
\underline{G}_\Im(\mathbf{k},z_a,\mathbf{k}^\intercal \mathbf{v} + \omega)
\Theta(\Omega_+,\Omega)
\underline{\alpha}^\dagger(\omega)
\end{align}
For a detailed derivation see \cite{oelschlager2019a}.
\section{Tests of Response Functions}
All response functions, for example $\underline{G}$ and $\underline{\alpha}$, have to fulfill a certain set of easily testable relations%
\footnote{This is also true for the permittivity of the macroscopic material $\epsilon(-\omega)=\epsilon^*(\omega)$, or the reflection coefficient of a flat surface $r(-\omega)=r^*(\omega)$}%
. First, they have to fulfill reality in time domain and thus the crossing relation in frequency domain
\begin{align}
  \underline{G}(-\omega,\vv r, \vv r') = \underline{G}^\dagger(\omega,\vv r, \vv r')\quad\text{or}\quad
\underline{\alpha}(-\omega) = \underline{\alpha}^*(\omega) \,,
\end{align}
Furthermore, in most cases one can rely on reciprocity of the Green's tensor
\begin{align}
\underline{G}(\omega,-\vv k,z) &= \underline{G}^\intercal(\omega,\vv k, z)\,.
\end{align}
In order to test the Green's tensor's reality, one can use that
\begin{align}
\underline{G}_\Im(\omega,\vv k, z) =\frac{\underline{G}(\omega,\vv k, z) - \underline{G}^\dagger(\omega,\vv k, z)}{2\ii}=
\frac{\underline{G}^\dagger(-\omega,\vv k, z) - \underline{G}(-\omega,\vv k, z)}{2\ii}= -\underline{G}_\Im(-\omega,\vv k, z)\,,\\
\underline{G}_\Re(\omega,\vv k, z) =\frac{\underline{G}(\omega,\vv k, z) + \underline{G}^\dagger(\omega,\vv k, z)}{2}=
\frac{\underline{G}^\dagger(-\omega,\vv k, z) + \underline{G}(-\omega,\vv k, z)}{2}= \underline{G}_\Re(-\omega,\vv k, z)
\,,
\end{align}
or alternatively
\begin{align}
  \int\frac{\dd^2\vv k}{(2\pi)^2}\underline{G}_\Im(\omega,\vv k, z) =
-  \int\frac{\dd^2\vv k}{(2\pi)^2}\underline{G}_\Im(-\omega,\vv k, z)
\quad\text{and}\quad
  \int\frac{\dd^2\vv k}{(2\pi)^2}\underline{G}_\Re(\omega,\vv k, z) =
  \int\frac{\dd^2\vv k}{(2\pi)^2}\underline{G}_\Re(-\omega,\vv k, z)
\end{align}
\section{Test of the Power Spectrum}
The power spectrum is an hermitian matrix, i.e.
\begin{align}
\underline{S}^\dagger(\omega) &= \underline{S}(\omega)\,.
\end{align}
Moreover, one can test the static case, which reproduces
\begin{align}
  \lim_{v\to0}\underline{S}(\omega) \sim \frac{\hbar}{\pi}\frac{\underline{\alpha}_\Im(\omega)}{1-e^{-\hbar\beta\omega}}\,.
\quad\text{or} \quad
  \lim_{v\to0}\int_0^\infty\dd\omega\,\underline{S}(\omega) \sim \frac{\hbar}{\pi}\int_0^\infty\dd\omega\,\frac{\underline{\alpha}_\Im(\omega)}{1-e^{-\hbar\beta\omega}}\,.
\end{align}
Here, the integral expression might be preferred for very low temperatures, since $\frac{1}{1-e^{-\hbar\beta\omega}}\stackrel{\hbar\omega \gg k_\mathrm{B}T}\sim \theta(\omega)$, which can be problematic in a numerical integration.
%Additionally, one can test the integration of $\underline{\alpha}$ in the first order in $\alpha_0$.
%\begin{align}
%\int_0^{\omega_\mathrm{cut}}\dd\omega\,\underline{\alpha}_\Im(\omega)
%\sim
%\begin{cases}
%\mathbb{1}\frac{\pi}{2}\alpha_0\omega_a
%\quad  & \text{for}\quad \omega_\mathrm{cut}\gg \omega_a
%\\
%\alpha_0^2
%\int_0^{\omega_\mathrm{cut}}\dd\omega\,
%\int\frac{\dd^2\vv k}{(2\pi)^2}
%\underline{G}_\Im(\vv k, z_a,\omega + k_xv)
%\quad  &\text{for}\quad \omega_\mathrm{cut}\ll \omega_a
%\end{cases}
%\end{align}
\section{Tests of specific setups}
\subsection{Test Case: Free Space}\label{sec:vacuum}
As neatly derived in \cite{amorim2017} the free Green tensor can be written as
\footnote{The Green's tensor definition in \cite{amorim2017} differs from the displayed one by the factor $\frac{\omega^2}{\epsilon_0c^2}$. This is due to the different definitions of the Green's tensor.}
\begin{align}
  \underline{G}_0(\vv k, z,z',\omega) &=
  \frac{\omega^2}{\epsilon_0c^2}
  \mathcal{P}\left[
    \mathbb{1}-\frac{c^2}{\omega^2}
    \begin{bmatrix}
      \vv k \\ \pm\ii \kappa
    \end{bmatrix}
    \left[ \vv k^\intercal ,\,\pm\ii\kappa\right]
  \right]
  \frac{e^{-\kappa|z-z'|}}{2\kappa}
  -\frac{\vv e_z\otimes\vv e_z}{\omega^2/c^2}\delta(z-z')
  .
\end{align}
Here the case $\pm$ relates to $z\gtrless z'$ and $\kappa=\sqrt{k^2-\omega^2/c^2}$ with $\mathrm{Re}\{\kappa\}\geq0$ and $\mathrm{Im}\{\kappa\}<0$. Especially, we focus on the case $z=z'$. Despite the real part of this Green's tensor being divergent for this case, we can continue calculating the imaginary part. Here we also eliminated odd orders of $k_y$, since we solely consider symmetric integration over $k_y$
%
\begin{align}
  \mathrm{Im}\left\{\underline{G}_0(\vv k, z\to z',\omega)\right\} &=
  \frac{
  \theta(\frac{\omega^2}{c^2}-k^2)
}{2\epsilon_0\sqrt{\omega^2/c^2-k^2}}
  \left(
    \mathbb{1}\frac{\omega^2}{c^2} -
    \mathrm{diag}\left[
      k_x^2,\,k_y^2,\,\frac{\omega^2}{c^2}-k^2
    \right]
  \right)
  .
\end{align}
The Heaviside function is needed to prohibit the $\omega^2/c^2 -k^2 <0$. Otherwise the term would be purely real and thus would not contribute to the imaginary part of the free Green's tensor. To show, that we can obtain the same result as e.g. given in \cite{buhmann2012b} or \cite{intravaia2016b}, we quickly calculate the integration over polar coordinates (assuming $\omega>0$). First, we perform the integration over $\varphi$ and find
%
\begin{align}
  \int \frac{\dd^2\vv k}{(2\pi)^2}
  \mathrm{Im}\left\{\underline{G}_0(\vv k, z\to z',\omega)\right\} &=
  \frac{1}{4\pi\epsilon_0}
  \int_0^{\omega/c} \dd k \,k
  \frac{1
}{\sqrt{\omega^2/c^2-k^2}}
    \mathrm{diag}\left[
     \frac{\omega^2}{c^2}-  \frac{k^2}{2},\,\frac{\omega^2}{c^2}-\frac{k^2}{2},\,k^2
    \right]
  .
\end{align}
%
In order to perform the $k$ integration, we use the known integrals
\begin{align}
  \int_0^y \dd x \frac{x}{\sqrt{y^2-x^2}}=y,
 \quad \quad
  \int_0^y \dd x \frac{x^3}{\sqrt{y^2-x^2}}=\frac{2y^3}{3},
  \end{align}
  and find
\begin{align}
  \int \frac{\dd^2\vv k}{(2\pi)^2}
  \mathrm{Im}\left\{\underline{G}_0(\vv k, z\to z',\omega)\right\} &=
     \frac{\omega^3}{6\pi\epsilon_0 c^3}
     \mathbb{1}
     .
\end{align}
In general, when considering a constant motion of the source with $\vv r = \vv v t +\vv r_0$, we can shift the motion into the frequency dependence, which manifests as a Doppler shift $\omega\to\omega_+=\omega+k_x v$. Since we need several different integrals concerning the $k_x$ integration, we want restrict us here to the $k_y$ integration. The inequality from the Heaviside function then reads $\omega_+^2/c^2-k_x^2\geq k_y^2$. However, when employing this inequality for the upper $k_y$ bound we still have to fulfil the $\omega_+^2/c^2-k_x^2\geq 0$ bound with respect to the $k_x$ integration. In the following we perform the $k_y$ integration

\begin{align}
  \int\frac{\dd^2\vv k}{(2\pi)^2}  \mathrm{Im}\left\{\underline{G}_0(\vv k, z\to z',\omega_+)\right\} &=
  \int\frac{\dd k_x}{4\pi\epsilon_0}
  \theta(\frac{\omega_+^2}{c^2}-k_x^2)
  \int_0^{\xi} \frac{\dd k_y}{\pi}
  \frac{1
}{\sqrt{\xi^2-k_y^2}}
  \left(
  \mathbb{1}\frac{\omega_+^2}{c^2} -
    \mathrm{diag}\left[
      k_x^2,\,k_y^2,\,\xi^2-k_y^2
    \right]
  \right)
  ,
\end{align}
where we introduced $\xi=\sqrt{\omega_+^2/c^2-k_x^2}$. Again we take advantage from the following known integrations
\begin{align}
  \int_0^y \dd x \frac{1}{\sqrt{y^2-x^2}}=\frac{\pi}{2},
 \quad \quad
  \int_0^y \dd x \frac{x^2}{\sqrt{y^2-x^2}}=\frac{\pi y^2}{4},
  \end{align}
  and find

\begin{align}
  \int\frac{\dd^2\vv k}{(2\pi)^2}  \mathrm{Im}\left\{\underline{G}_0(\vv k, z\to z',\omega_+)\right\}f(\omega_+,k_x) &=
  \int\frac{\dd k_x}{8\pi\epsilon_0}
  \theta(\xi^2)
  \left(
  \mathbb{1}\frac{\omega_+^2}{c^2} -
    \mathrm{diag}\left[
      k_x^2,\,\frac{\xi^2}{2},\,\xi^2-\frac{\xi^2}{2}
    \right]
  \right)f(\omega_+,k_x)
  \\
&=
  \int\frac{\dd k_x}{8\pi\epsilon_0}
  \theta(\xi^2)
    \mathrm{diag}\left[
      \xi^2,\,\frac{\omega_+^2}{c^2}-\frac{\xi^2}{2},\,\frac{\omega_+^2}{c^2}-\frac{\xi^2}{2}    \right]f(\omega_+,k_x)
  \\
&=
\int_{-\frac{\omega}{c+v}}^{\frac{\omega}{c-v}}\frac{\dd k_x}{8\pi\epsilon_0}
    \mathrm{diag}\left[
      \xi^2,\,\frac{\omega_+^2}{c^2}-\frac{\xi^2}{2},\,\frac{\omega_+^2}{c^2}-\frac{\xi^2}{2}    \right]f(\omega_+,k_x)
    \\
&=
\frac{1}{v8\pi\epsilon_0}
\int_{\frac{c\omega}{c+v}}^{\frac{c\omega}{c-v}}\dd \omega_+
    \mathrm{diag}\left[
    \xi^2,\,\frac{\omega_+^2}{c^2}-\frac{\xi^2}{2},\,\frac{\omega_+^2}{c^2}-\frac{\xi^2}{2}    \right]f(\omega_+,\frac{\omega_+-\omega}{v})
      .
\end{align}
Here the $f(\omega_+,k_x)$ indicates potential weight functions. In the context of non-contact friction the weight function can take several forms
\begin{align}
  f(\omega_+,k_x) &=
  \begin{cases}
  1
  \\
  k_x
  \\
  \Theta(\hbar\beta\omega_+,\hbar\beta\omega) = \frac{1}{1-\exp(-\beta\hbar\omega_+)}-\frac{1}{1-\exp(-\beta\hbar\omega)}
  \\
  k_x\Theta(\hbar\beta\omega_+,\hbar\beta\omega)
  \end{cases}
\end{align}
The first to cases can be calculated straight-forward
\begin{align}
  \int\frac{\dd^2\vv k}{(2\pi)^2}  \mathrm{Im}\left\{\underline{G}_0(\vv k, z\to z',\omega_+)\right\}k_x
  &=
\frac{\omega^4}{6\pi\epsilon_0}
 \frac{ v c }{(c^2-v^2)^3}
\mathrm{diag}\left[
    1,\,
  \frac{  2 c^2+v^2}{ c^2-v^2}
  ,\,
  \frac{ 2 c^2+v^2}{ c^2-v^2}
\right]
\\
&\stackrel{c\gg v}=
\frac{v/c }{6\pi\epsilon_0}
 \frac{ \omega^4 }{c^4}
\mathrm{diag}\left[
    1,\,
    2
    ,\,
     2\right]
\\
  \int\frac{\dd^2\vv k}{(2\pi)^2}  \mathrm{Im}\left\{\underline{G}_0(\vv k, z\to z',\omega_+)\right\}
  &=
  \frac{1}{8\pi\epsilon_0}\mathrm{diag}\left[
  \frac{4 c \omega ^3}{3 \left(c^2-v^2\right)^2}
    ,\,
    \frac{4 c \omega ^3 \left(c^2+v^2\right)}{3 \left(c^2-v^2\right)^3}
  ,\,
\frac{4 c \omega ^3 \left(c^2+v^2\right)}{3 \left(c^2-v^2\right)^3}
\right]
  \\
  &\stackrel{c\gg v}=
  \mathbb{1}
\frac{\omega^3}{6\pi \epsilon_0 c^3}
\end{align}
In a next step we solve the integrals with temperature distribution. For conveniece, we introduce the dimensionless variable $\Omega=\hbar\beta\omega$
\begin{align}
  \int\frac{\dd^2\vv k}{(2\pi)^2}  \mathrm{Im}\left\{\underline{G}_0(\vv k, z\to z',\omega_+)\right\} \Theta(\Omega_+,\Omega)
\end{align}
\begin{align}
  &=
  \frac{1}{v8\pi\epsilon_0(\hbar\beta)^3}
\int_{\frac{c\Omega}{c+v}}^{\frac{c\Omega}{c-v}}\dd \Omega_+
   \mathrm{diag}\left[
   \frac{\Omega_+^2}{c^2}-\frac{(\Omega-\Omega_+)^2}{v^2},\,\frac{\Omega_+^2}{2c^2}+\frac{(\Omega-\Omega_+)^2}{2v^2},\,\frac{\Omega_+^2}{2c^2}+\frac{(\Omega-\Omega_+)^2}{2v^2}\right]\Theta(\Omega_+,\Omega)
\\
&\stackrel{v\ll c}\sim
\frac{\mathrm{diag}[1,2,2]}{240 \pi\epsilon_0 }\frac{v^2}{c^2}
\frac{\omega^3}{c^3}\frac{\hbar\omega }{ \kB T}\frac{\Omega  \coth \left(\frac{\Omega }{2}\right)-10}{ \sinh^2\left(\frac{\Omega }{2}\right)}
\stackrel{\Omega\ll 1}\sim -
\frac{2\mathrm{diag}[1,2,2]}{15 \pi\epsilon_0 }\frac{v^2}{c^2}
\frac{\omega^3}{c^3}\frac{ \kB T}{\hbar\omega }
\end{align}
It is noteworthy that the function $ \frac{\Omega  \coth \left(\frac{\Omega }{2}\right)-10}{ \sinh^2\left(\frac{\Omega }{2}\right)}$ has, if $\Omega>0$, a maximum at $\Omega(\cosh(\Omega)+2)=11\sinh(\Omega)$. Assuming $\Omega \gg 1$ the maximum is roughly at $\Omega\approx 11$.
\\
Finally, we solve the integral with the last weighing function $k_x\Theta(\Omega_+,\Omega)$
\begin{align}
  \int\frac{\dd^2\vv k}{(2\pi)^2}  \mathrm{Im}\left\{\underline{G}_0(\vv k, z\to z',\omega_+)\right\}\frac{\Omega_+-\Omega}{\hbar\beta v} \Theta(\Omega_+,\Omega)
\end{align}
\begin{align}
  &=
  \frac{1}{v^2 8\pi\epsilon_0(\hbar\beta)^4}
\int_{\frac{c\Omega}{c+v}}^{\frac{c\Omega}{c-v}}\dd \Omega_+
   \mathrm{diag}\left[
   \frac{\Omega_+^2}{c^2}-\frac{(\Omega-\Omega_+)^2}{v^2},\,\frac{\Omega_+^2}{2c^2}+\frac{(\Omega-\Omega_+)^2}{2v^2},\,\frac{\Omega_+^2}{2c^2}+\frac{(\Omega-\Omega_+)^2}{2v^2}\right](\Omega_+-\Omega)\Theta(\Omega_+,\Omega)
   \\
   &\stackrel{v\ll c}\sim
 -
 \frac{\mathrm{diag}\left[1,2,2\right]}{120\pi\epsilon_0}\frac{v}{c}\frac{\omega^4}{c^4}
 \frac{\hbar\omega}{\kB T}\frac{1}{\sinh^2 (\frac{\Omega}{2})}
 \stackrel{\Omega\ll 1} \sim
 -
 \frac{\mathrm{diag}\left[1,2,2\right]}{30\pi\epsilon_0}\frac{v}{c}\frac{\omega^4}{c^4}
 \frac{\kB T}{\hbar\omega}
 \end{align}
\\
In the following we first assume that the microscopic object has \textbf{no internal bath}. Thus, the polarizability has the form
\begin{align}
\underline{\alpha}(\omega)\stackrel{v\ll c}\sim
\frac{\mathbb{1}\alpha_0\omega_a^2}{\omega_a^2-\omega^2 -\ii\alpha_0\omega_a^2\frac{\omega^3}{6\pi\epsilon_0c^3}}
=
\frac{\mathbb{1}\alpha_0}{1-\frac{\omega^2}{\omega_a^2} -\ii\psi(\omega)}
\end{align}
The new function $\psi(\omega)=\omega^3\frac{\alpha_0}{(\hbar\beta)^36\pi\epsilon_0c^3}$ yields two different regimes. If $\omega\ll c\sqrt[3]{\frac{6\pi\epsilon_0}{\alpha_0}}$ we can treat the polarizability as an sharp delta peak. Else, in the case of $\omega\gg c\sqrt[3]{\frac{6\pi\epsilon_0}{\alpha_0}}$ the polarizability is dominated by the damping.
\todo{\\ Put together \\}In free space for temperatures $k_\mathrm{B}T\gg \hbar\omega_a$ one finds (see \texttt{VacuumGreen.pdf})
\begin{align}
F &= -\frac{v}{c} \frac{k_\mathrm{B}T \alpha_0}{6\pi\epsilon_0} \frac{\omega_a^4}{c^4}
\end{align}
Furthermore, one can test the individual Green's tensor integrations via the relations given in the \texttt{VacuumGreen.pdf}. With respect to the polarizability one finds
\begin{align}
\int_0^{\omega_\mathrm{cut}}\dd\omega\,\underline{\alpha}_\Im(\omega)
\sim
\begin{cases}
\mathbb{1}\frac{\pi}{2}\alpha_0\omega_a
\quad  & \text{for}\quad \omega_\mathrm{cut}\gg \omega_a
\\
\alpha_0^2
  \frac{\omega_\mathrm{cut}^4}{8\pi\epsilon_0}\mathrm{diag}\left[
  \frac{ c }{3 \left(c^2-v^2\right)^2}
    ,\,
    \frac{ c  \left(c^2+v^2\right)}{3 \left(c^2-v^2\right)^3}
  ,\,
\frac{ c  \left(c^2+v^2\right)}{3 \left(c^2-v^2\right)^3}
\right]
\stackrel{v\ll c}\approx
\mathbb{1}\alpha_0^2 \frac{\omega_\mathrm{cut}^4}{24\pi\epsilon_0 c^3}
\quad  &\text{for}\quad \omega_\mathrm{cut}\ll \omega_a
\end{cases}
\end{align}
For a microscopic object with a internal bath another term has to be added in the $\omega_\mathrm{cut} \ll \omega_a$ limit
\begin{align}
\int_0^{\omega_\mathrm{cut}}\dd\omega\,\underline{\alpha}_\Im(\omega)
\stackrel{\omega_\mathrm{cut}\ll\omega_a}\sim
\mathbb{1}\alpha_0^2 \frac{\omega_\mathrm{cut}^4}{24\pi\epsilon_0 c^3}
+ \frac{\alpha_0}{\omega_a^2}\mathbb{1}\int\limits_0^{\omega_\mathrm{cut}} \omega\mu_R(\omega)
\stackrel{\mu_R(\omega)=\gamma}=
\mathbb{1}\alpha_0^2 \frac{\omega_\mathrm{cut}^4}{24\pi\epsilon_0 c^3}
+ \frac{\alpha_0\gamma\omega_\mathrm{cut}^2}{2\omega_a^2}\mathbb{1}
\end{align}
If $\gamma$ is not very small compared to $\omega_a$ then we find
\begin{align}
\int_0^{\omega_\mathrm{cut}}\dd\omega\,\underline{\alpha}_\Im(\omega)
\stackrel{\omega_\mathrm{cut}\gg\omega_a}\sim
\mathbb{1}\frac{\alpha_0\omega_a^2}{2}
\left[
  \frac{\pi}{\sqrt{4 \omega_a^2-\gamma ^2}}-\frac{2 \arctan\left(\frac{\gamma ^2-2 \omega_a^2}{\gamma  \sqrt{4 \omega_a^2-\gamma ^2}}\right)}{\sqrt{4 \omega_a^2-\gamma ^2}}
\right]
\stackrel{\gamma\ll\omega_a}\sim\mathbb{1}\frac{\pi}{2}\alpha_0\omega_a
\end{align}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
\subsection{Test Case: Object above a flat surface}
Here we want to present some test cases for the setup of a microscopic object moving above a flat surface. In general the Green's tensor of such a half-space system is
\begin{align}
\underline{G}(\vv k,\omega) &= \underline{G}_0(\vv k, \omega) + \underline{g}(\vv k, \omega)
\end{align}
where $\underline{G}_0$ is the free space Green's tensor of Sec.~\ref{sec:vacuum}.
\section{Test Case: Object in a cylindrical cavity}
\section{Parameter Values}
In this section we provide estimated values of physical parameters, as well as a brief investigation into the numerical parameters used for the calculation.
\subsection{Physical Parameters}
\begin{table}[H]
\centering
\begin{tabular}{c|c|c|c}
\textbf{Quantity} & \textbf{Lower Value} & \textbf{Upper Value} & \textbf{Comment}
\\\hline
$v/c$  & $0$ & $10^{-3}\cdots 10^{-2} c$  & Nonrelativistic
\\\hline
$T$ & $0\,\mathrm{K}$ & $T_a = \hbar\omega_a/k_\mathrm{B} \approx 10^4\,\mathrm{K}$ & Must not lead to resonant excitation
\\\hline
$z_a$ & $10\,\mathrm{nm}$ & $1\,\mu\mathrm{m}$ & Dependent on experiment (see \cite{oelschlager2019a})
\\\hline
$\omega_a$ & $0.1\,\mathrm{eV}$ & $10\uni{eV}$ & Typical atomic/nanoparticle resonances
\\\hline
$\alpha_0$ & $1\uni{a.u.}$ & $300\uni{a.u.}$ & Typical atomic values \cite{schwerdtfeger2019}. May differs for other objects
\\\hline
$\omega_\mathrm{p}$ & $0.001\uni{eV}$ & $10\uni{eV}$ & we considered doped semi-conductors \cite{pirozhenko2008a} and ``usual'' metals \cite{nozieres1999}
\\\hline
$\gamma$ & $1\uni{meV}$ & $600\uni{meV}$  & See comments of $\omega_\mathrm{p}$ and \href{http://www.wave-scattering.com/drudefit.html}{this link}
\\\hline
\end{tabular}
\end{table}
All values depend on the actual physical situation and should be reinvestigated for the actual calculations. Furthermore, all values are rough estimates and should not be taken too seriously.
\subsection{Numerical Parameters}
General numerical parameters of \texttt{QuaCa} are the error bounds of the numerical integrations. As one sees in Eq.~\eqref{eq:numInt1}, three nested integrations have to be performed. To obtain reasonable results the accuracy of the numerical integration must be higher as deeper the nesting, i.e. the lowest integrate has the highest accuracy. To skirt a full quantitative analysis of the magnitude of each integration result, one might stick to relative error bounds.
\\
Besides the general accuracy of the integration routines, we might introduce further numerical parameters. One example is a cut-off wavevector in the scattered Green's tensor (see \cite{intravaia2016a}. Here, the Green's tensor contains a term with $\exp{-2z_a\kappa}$, which dampens strongly for $\mathrm{Re}\{\kappa\}> 0$. Thus, one can easily introduce a faithful cut-off value $\kappa_\mathrm{cut}=\delta_\mathrm{cut}/(2z_a)$, where for instance a $\delta_\mathrm{cut}=20$ leads to a damping of $\exp(-20)\approx 2\times 10^{-9}$.

\bibliography{lib}
\end{document}


\input{header.tex}
\title{}
\author{}
\begin{document}
\maketitle

\end{document}

Sets font size to 11pt
Includes commonly needed packages
Reduces page margins to 0.75in for more space
Redefines \maketitle to save space
Removes page numbers
Changes enumeration to letters as in physics exercises
\v{ } makes bold vectors (\v is redefined to \vaccent)
\uv{ } makes bold unit vectors with hats
\gv{ } makes bold vectors of greek letters
\abs{ } makes the absolute value symbol
\avg{ } makes the angled average symbol
\d{ }{ } makes derivatives (\d is redefined to \underdot)
\dd{ }{ } makes double derivatives
\pd{ }{ } makes partial derivatives
\pdd{ }{ } makes double partial derivatives
\pdc{ }{ }{ } makes thermodynamics partial derivatives
\ket{ } makes Dirac kets
\bra{ } makes Dirac bras
\braket{ }{ } makes Dirac brackets
\matrixel{ }{ }{ } makes Dirac matrix elements
\grad{ } makes a gradient operator
\div{ } makes a divergence operator (\div is redefined to \divsymb)
\curl{ } makes a curl operator
\={ } makes numbers appear over equal signs (\= is redefined to \baraccent)

General LaTeX tips:

Use "$ ... $" for inline equations
Use "\[ ... \]" for equations on their own line
Use "\begin{center} ... \end{center}" to center something
Use "\includegraphics[width=?cm]{filename.eps}" for images - must compile to dvi then use dvipdfm from a batch file
Use "\begin{multicols}{2} ... \end{multicols}" for two columns
Use "\begin{enumerate} \item ... \end{enumerate}" for parts of physics exercises
Use "\section*{ }" for sections without numbering
Use "\begin{cases} ... \end{cases}" for piecewise functions
Use "\mathcal{ }" for a caligraphic font
Use "\mathbb{ }" for a blackboard bold font


\documentclass{article}
\usepackage[minionint,mathlf,textlf]{MinionPro} % To gussy up a bit
\usepackage[margin=1in]{geometry}
\usepackage{graphicx} % For .eps inclusion
%\usepackage{indentfirst} % Controls indentation
\usepackage[compact]{titlesec} % For regulating spacing before section titles
\usepackage{adjustbox} % For vertically-aligned side-by-side minipages
\usepackage{array, mathrsfs, mathrsfs, mhchem, amsmath} % For centering of tabulars with text-wrapping columns
\usepackage{hyper ref}
\usepackage{subfigure}
\newcommand{\Lapl}{\mathscr{L}}

\pagenumbering{gobble}
\setlength\parindent{0 cm}
\begin{document}
\large
\section*{Bode plots}

\begin{itemize}

\item Last time, we began our investigation of how integral and derivative control can be combined with proportional control to improve a system's response to input of various types.

\item We began describing how Bode plots are used to investigate how a system responds to rapid vs. slow changes by examining the effect of the system on sinusoidal functions of varying frequency.

\item We saw that when a sinusoidal function is input to an LTI system, the output is a sinusoidal function of the same frequency, but potentially with a different amplitude and phase. The amplitude and phase are found by setting from $G(i\omega) = A e^{i \phi}$.

\item If $A \ll 1$, the system is attenuating the input -- a good thing if we are trying to buffer the output against variation in input, e.g. in a negative autoregulation system. Similarly, if $A \gg 1$, the input signal is being amplified.

\item Keeping track of the phase difference is very important in feedback loops. Imagine that we are trying to apply negative feedback to cancel out a signal $\tilde{x}(s)$ before it enters the plant. Ideally the output from the control loop is 0 degrees, 0 dB gain: that way, when we subtract it from the input, we get zero.

\item However, If the phase difference is -180 degrees, then subtracting the negative feedback is effectively the same as adding $\tilde{x}(s)$ to itself: we'd've managed to double the magnitude of the input, instead of cancelling it out!

\item Bode plots include both the magnitude (modulus) and the phase angle (argument) of $G(i\omega)$ against $\omega$ in the manner described below.

\item Both graphs in a Bode diagram have log frequency as the independent variable. The first plots the log magnitude of $G(i\omega)$ on the y-axis: typically, we plot $20 \log_{10} | G(i \omega) |$, with units of decibels (dB).

\item This y-axis unit is not as arbitrary as it sems. The decibel unit was introduced during work on the earliest phone lines (when it was called a ``transmission unit") in order to describe the relationship between the power (``strength") of a signal at the source vs. the power at the destination.

\item The human ear perceives differences in volume on a logarithmic scale, so it was sensible to use a unit that scaled logarithmically with the ratio of the two power levels. A constant multiplier was added so that one decibel would be approximately the smallest difference in volume detectable by human ears (about a 25\% change in power):

\[ \textrm{Difference in ``volume" } = 10 \log_{10} \left( \frac{\textrm{Power at destination}}{\textrm{Power at source}} \right) \textrm{ dB} \]

\item Power is proportional to amplitude squared, so for our LTI systems the equivalent is

\[ \textrm{Signal magnitude difference: } = 20 \log_{10} \left( \frac{\textrm{Output amplitude}}{\textrm{Input amplitude}} \right) \textrm{ dB} \]

\item The second graph in a Bode plot has the phase difference $\phi$ on the y-axis, usually given in degrees from -180$^o$ to 180$^o$. (e.g. if $G(i\omega) = a + ib$, then the phase angle would be $\tan^{-1} b/a$ if $a>0$.)\\

\item Practice with proportional ($K(s) = k$, flat magnitude and phase angle zero), integral ($K(s) = 1/s$, $\propto - \log \omega$, phase angle -90), derivative ($K(s) = s$, $\propto \log \omega$, phase angle 90) of which students work at least one. See figure \ref{fig:eachcomponentalone}.

\begin{figure}
\centering
\subfigure[Proportional control]{
\includegraphics[width=.3\textwidth]{bodep.pdf}
}
\subfigure[Integral control]{
\includegraphics[width=.3\textwidth]{bodei.pdf}
}
\subfigure[Derivative control]{
\includegraphics[width=.3\textwidth]{boded.pdf}
}
\label{fig:eachcomponentalone}
\end{figure}

\item High-pass: magnitude is high for high frequencies. Low-frequency: magnitude is high for low frequencies. Definition of bandwidth as range above -3 dB.

\item P-I controller:

\begin{eqnarray*}
G(s) & = & k +  \frac{1}{\tau_i s} = \frac{k\tau_i s + 1}{\tau_i s}\\
G(i\omega) & = &  \frac{k\tau_i \omega - i}{\tau_i \omega}\\
\left| G(i\omega) \right| & = & \sqrt{k^2 + \frac{1}{\tau_i^2 \omega^2} }\\
\phi &= &  \tan^{-1} \left( - \frac{1}{k \tau_i \omega} \right)
\end{eqnarray*}

Phase goes from -90 degrees to zero degrees; magnitude starts high and falls to around $k$ by $\omega \approx 1/\tau_i$ (the ``corner" or ``break" frequency).

\item P-D controller:

\begin{eqnarray*}
G(s) & = & k +  \tau_d s\\
G(i\omega) & = &  k + i \tau_d \omega\\
\left| G(i\omega) \right| & = & \sqrt{k^2 + \tau_d^2 \omega^2}\\
\phi &= &  \tan^{-1} \left( \frac{\tau_d \omega}{k} \right)
\end{eqnarray*}

Phase goes from zero degrees to ninety degrees; magnitude high and falls to around $k$ by $\omega \approx 1/\tau_i$ (the ``corner" or ``break" frequency).

\item A combination of proportional, integral, and derivative control can create a band stop filter:

\begin{eqnarray*}
G(s) & = & k + \tau_d s + \frac{1}{\tau_i s} = \frac{k\tau_i s + \tau_d \tau_i s^2 + 1}{\tau_i s}\\
G(i\omega) & = &\frac{1}{\tau_i \omega} \left( k \tau_i \omega +  i \left[ \tau_d \tau_i \omega^2 - 1 \right]  \right)\\
\left| G(i\omega) \right| & = & \sqrt{k^2 + \left( \tau_d \omega - \frac{1}{\tau_i \omega} \right)^2}\\
\phi &= & \tan^{-1}  \left( \frac{\tau_d \omega}{k} - \frac{1}{k\tau_i \omega} \right)
\end{eqnarray*}

The phase goes from -90 at small $\omega$ to +90 at high $\omega$.

\begin{figure}
\centering
\subfigure[PI control]{
\includegraphics[width=.3\textwidth]{bodepi.pdf}
}
\subfigure[PD control]{
\includegraphics[width=.3\textwidth]{bodepd.pdf}
}
\subfigure[PID control]{
\includegraphics[width=.3\textwidth]{bodepid.pdf}
}
\label{fig:eachcomponentalone}
\end{figure}

\item Concept of lead-lag compensation -- not aware whether anyone has built or is looking for these in biological systems.

\end{itemize}

\section*{Application: yeast osmolarity regulation}
\begin{itemize}
\item Osmolarity: concentration of all solutes in a mixture.
\item When water is allowed to flow between two solutions (e.g. between cytoplasm and extracellular fluid through aquaporins), it will tend to move toward the region with more solutes.
\item An increased osmolarity outside the cell could draw out water, so in such media, yeast make more intracellular solutes until the osmolarity is sufficiently balanced.
\item Specifically, they make the small molecule glycerol under these hyper-osmotic conditions: we therefore call this response system the HOG pathway.
\item Diagram of the pathway simplifying figure 1 of Hershen et al., 2008.
\item In 2008 the Ramanathan lab constructed the moral equivalent of a Bode plot for the budding yeast HOG pathway.  They placed cells in a flow chamber and varied the osmolarity of the media in a square wave pattern of varying pulse length.
\item The output of the pathway was monitored by looking for nuclear entry of HOG1, a transcription factor mediating the response.
\item (Show frequency response analysis results.) What types of control does this pathway seem to display? What is the bandwidth of the pathway?
\end{itemize}

\section*{Introduction to bacterial chemotaxis}

\begin{itemize}
\item Chemotaxis is movement towards a higher concentration of an attractant (or a lower concentration of a repellent).
\item The bacterium \textit{E. coli} swims forward when its many flagella all turn in the same direction (counter-clockwise).
\item  When one or more of the flagella rotate in the opposite direction,  it ``tumbles," splaying out its flagella and ceasing any relative motion. When the concentration of the attractant is spatially homogeneous, tumbling occurs about once per second.
\item During the tumble, the cell's direction is randomized. Eventually the errant flagellum will return to CCW spinning, and the cell begins to swim again, in a new direction.
\item \textit{E. coli} cannot steer, but they can still move in a particular direction on the net by controlling their tumbling rate. They tumble more often when they sense they're headed the ``wrong way," and vice versa.
\item In chemotaxis, the ``right way" is the direction in which the concentration of an attractant like leucine is increasing. \textit{E. coli} sense concentration using cell surface receptors. The fraction of receptors bound at any given time is a function of the ligand concentration (sketch a binding curve).
\item Suppose an \textit{E. coli} cell could detect the fraction of receptors bound at the front end, and compare it to the fraction of receptors bound at the back. Theoretically the cell would know if it were headed in the right direction. Unfortunately, this strategy does not work for \textit{E. coli} because of the small and finite number of receptors.
\item To grasp the problem, imagine a cell with only two receptors: one in front and one in back. The binding state at any instant would be too noisy to tell where [ligand] was higher, but the longer we wait, the more accurately we can measure the fraction of time that each receptor was occupied by ligand. The problem is that because \textit{E. coli} is so small, the concentration difference between the front and back of the cell must be small, so we would need to wait a very long time. Meanwhile the cell is swimming, changing direction etc.
\item Instead of comparing the concentrations at each end, the cell compares the current fraction of bound receptors to the fraction of bound receptors in the recent past (integrated over about the last four seconds). This timescale is appropriate because it balances the increased accuracy in $f_{\textrm{bound}}$ determination from long integration times with the fact that the cell doesn't tend to be going the same direction for very long. (Even when the cell does not tumble, it does not really swim straight: after four seconds it typically has changed orientation by about sixty degrees.)
\end{itemize}

\section*{Perfect adaptation in chemotaxis}

\begin{itemize}
\item You might expect that an \textit{E. coli} cell at steady-state in 0 nM ligand would tumble much more frequently than one at steady-state in a high ligand concentration.
\item In fact, the tumbling frequency at steady state is always the same: we say that tumbling frequency  \textit{adapts perfectly}.
\item This feature is very useful for ensuring that chemotaxis remains effective as a cell climbs a gradient, so that it can find more and more suitable environments.
\item You may already recognize the benefit of integral control in this system. But how, at a biochemical level, is it implemented?
\end{itemize}

\section*{The biochemical pathway and two models}

\begin{itemize}
\item The central player in the pathway is the receptor complex that binds extracellular attractants and regulates the intracellular response. We will call this receptor complex $E$\footnote{This notation does not match Alon but rather follows the original Barkai and Leibler paper.}.
\item $E$ can be bound or unbound by attractant ($E^b$ or $E^u$), and can be methylated or unmethylated ($E_0$ or $E_m$). All four variants are possible and we will refer to some subgroups of variants using a combination of these super- and subscripts.

\begin{center}\includegraphics[width=.5\textwidth]{receptornotation.pdf}\end{center}

\item $E$ is methylated by an enzyme called CheR, which we will assume converts $E_0$ to $E_m$ at a constant rate independent of whether ligand is bound. This constant rate is realistic if $E_0$ always remains abundant enough that we stay in the right tail of CheR's Michaelis-Menten curve [draw this]. (Another way to phrase the assumption is that CheR is \textrm{operating at saturation}.)
\item Although $E$ can technically be methylated at multiple sites, for simplicity we will just assume that $E$ has one or zero methyl groups.

\begin{center}\includegraphics[width=.5\textwidth]{receptormethylation.pdf}\end{center}

\item The methylated form of $E$ is a kinase that can phosphorylate two downstream proteins, CheY and CheB. The \textit{activity} of the kinase is:

\[ A = \alpha_b E_m^b + \alpha_u E_m^u \]

That is, unmethylated receptors do not have any kinase activity. Unbound kinase is more active than bound kinase $(\alpha_u \gg \alpha_b)$.

\item CheY controls tumbling rate: as [CheY-P] increases, the tumbling frequency increases. (CheY-P is also converted back to CheY at a constitutive rate so it does not accumulate indefinitely.) When more ligand is added, $E$'s kinase activity decreases and CheY-P depletes, so less tumbling occurs, as you'd expect.

\item The other phosphorylation target of $E$ is its own demethylase, CheB. This is the crucial feedback loop that allows the circuit to adapt. Details on how CheB works is the only difference between the two models of perfect adaptation we will discuss today.

\item The steady-state tumbling rate depends on the steady-state concentration of CheY-P, which in turn depends on the steady-state activity of $E$ and CheY-P's dephosphorylation rate. Since the dephosphorylation rate is constant, we will have perfect adaptation (i.e. the steady-state tumbling rate will be the same at all ligand concentrations) if $A$ is independent of ligand concentration. We will try to determine when the latter condition holds.

\end{itemize}
\subsection*{Fine-tuned model}
\begin{itemize}
\item In the first model we will consider, phosphorylated CheB demethylates both $E_m^b$ and $E_m^u$ at the same rate. This means that we can write the total rate of change in $E_m$ as

\[ \frac{dE_m}{dt} = \frac{d \left(E_m^u + E_m^b \right)}{dt} = V_R - \frac{ V_{\textrm{max}} E_m}{K_m + E_m}  \]

where $V_R$ is the rate of CheR-mediated methylation (assumed to be saturated), and $V_{\textrm{max}}$ and $K_m$ are properties of CheB. $V_{\textrm{max}}$ is not really a constant, as it depends on the fraction of CheB that's phosphorylated.

\item The steady-state concentration of $E_m$ is

\[ 0 = \left. \frac{dE_m}{dt} \right|_{E_{\textrm{m, ss}}} \implies E_{\textrm{m,ss}} = \frac{V_R K_m}{V_{\textrm{max}} - V_R} \]

\item When the concentration of attractant is zero, all of the $E_m$ is unbound, so at steady state:

\[ A_{\textrm{ss}} =  \alpha_b E_{\textrm{m,ss}}^b  + \alpha_u E_{\textrm{m,ss}}^u  = \alpha_u E_{\textrm{m,ss}} = \frac{ \alpha_u  V_R K_m}{V_{\textrm{max}}^1 - V_R} \]

The notation $V_{\textrm{max}}^1$ reminds us that the maximum rate of CheB depends on what fraction of it is phosphorylated.

\item On the other hand, when the concentration of attractant is saturating, all of the $E_m$ is bound and at steady-state:

\[ A_{\textrm{ss}} = \alpha_b E_{\textrm{m,ss}}^b + \alpha_u E_{\textrm{m,ss}}^u  = \alpha_b E_{\textrm{m,ss}} = \frac{ \alpha_b  V_R K_m}{V_{\textrm{max}}^2 - V_R} \]

Notice that the maximum rate of demethylation has changed because less of the demethylase [CheB-P] will be present at steady-state.

\item These two activities (and indeed, the activity at every intermediate ligand concentration) must be the same in order for the system to display perfect adaptation.

\item While hypothetically possible, this would require exquisite tuning of these parameters through evolution. A major concern is introduced by the variation in gene expression between cells.

\item It is quite common for protein concentrations to vary by, say, 20\% between cells. Uri Alon provides a numerical answer where a 20\% change in the concentration of one protein (CheR) leads to a three-fold change in activities between the two states -- nowhere close to perfect adaptation. (In fact the error could be much worse, depending on what the values for these parameters actually are.) We say that perfect adaptation is a fine-tuned property of this model.
\end{itemize}

\subsection*{A robust model for perfect adaptation}

\begin{itemize}

\item Barkai and Leibler (1997) provide a model for this system that is much more resilient to variation in gene expression and other parameters of the model. The only essential difference is that CheB-P can only demethylate $E_m^u$, so:

\[ \frac{dE_m}{dt} = \frac{d \left(E_m^u + E_m^b \right)}{dt} = V_R - \frac{ V_{\textrm{max}} E_m^u}{K_m + E_m^u}  \]

\item At steady state:

\[ 0 = \left. \frac{dE_m}{dt} \right|_{E_{m,\textrm{ss}}^u} \implies E_{m,\textrm{ss}}^u = \frac{V_R K_m}{V_{\textrm{max}} - V_R} \]

\item In other words, the receptor's kinase activity

\[ A =  \alpha_b E_m^b + \alpha_u E_m^u \approx \alpha_u E_m^u \]

always approaches the same steady-state value, regardless of ligant concentration. Consequently, [CheY-P] will approach the same steady state value as well. This is perfect adaptation.

\item This model makes essentially no requirements on the parameters (other than that our assumptions that CheR operates at saturation and $\alpha_u \gg \alpha_b$ stay valid). In other words, the construction of the pathway is all that is needed to implement the perfect adaptation.

\item Let's recap what is happening in this system. Suppose the cell has adapted to its media and we suddenly add more attractant.
\begin{itemize}
\item  The activity plummets immediately as $E_m^u$ converts to $E_m^b$.
\item This gives rise to a transient decrease in tumbling frequency.
\item Meanwhile, less CheB is phosphorylated than usual due to the low receptor kinase activity: the level of CheB-P begins to fall.
\item This shifts the balance toward methylation of $E$, creating more $E_m$ until the activity returns to its normal value.
\end{itemize}

\end{itemize}

\section*{Perfect adapation always requires integral control}

\begin{itemize}

\item Recall that proportional control results in \textit{droop} (non-zero error at steady-state) and that integral control provides a means to reduce the operating error to zero at steady-state. In control theory, this is called asymptotic tracking (which means the same thing as perfect adaptation).

\item This system implements integral control: the integration (memory of past ligand concentrations) is effected through accumulation or depletion of methyl groups. If the concentration was high recently, then there will be few methyl groups; if it was low recently, then there will be more methyl groups.

\item Control is then exerted by allowing the number of methyl groups to affect the activity of the receptor complex.

\item Your next discussion paper will be on another example of perfect adaptation: this time, in the yeast hyperosmotic glycerol (HOG) response.

\item We have seen an example of integral control applied in biology; on Monday, we'll look at a biological system effecting derivative control.

\end{itemize}

\end{document}

lectures/Lecture 16 - Perfect Adaptation in Chemotaxis as Integral Control/lecture notes/lecture 16 notes.tex


\vssub
\subsubsection{~Spherical Multiple-Cell (SMC) grid} \label{sub:num_space_SMC}
\opthead{SMC}{\ws (MetOffice)}{J.-G. Li}

\noindent
The Spherical Multiple-Cell (SMC) grid\footnote{~Presently this grid is
activated by a compile switch and can only be used as a stand-alone grid. This
will become a run time option in upcoming model versions.}  \citep{art:Li11}
is an extension of the Cartesian multiple-cell grid \citep{art:Li03} onto the
spherical coordinate system. It is an unstructured grid but retains the
conventional lat-lon grid cells so that all propagation formulations on the
spherical coordinates are still applicable and hence all
the finite difference schemes. The SMC grid relaxes the CFL restriction at
high latitudes in a similar fashion as the reduced grid
\citep{art:RA94}. Polar cells are introduced to remove the polar singularity
of the differential transport equation by switching to an integral
equation. The upstream non-oscillatory 2nd order (UNO) advection schemes
\citep{art:Li08} is implemented on the SMC grid for both spatial and
inter-spectral propagation. This 2nd order scheme can be replaced with a 3rd
order scheme using the {\F PSMC} namelist logical variable {\code UNO3}.  The UNO3 scheme is similar
to the UQ scheme but replacing the flux limiters with the UNO 2nd order scheme.  A simple
rotation scheme is used for wave refraction-induced rotation and the great circle
turning \citep{art:Li12}.  The refraction scheme is unconditionally stable for
any time step but the maximum refraction induced rotation angle is limited by
the maximum possible refraction angle towards the local gradient direction.
Diffusion term similar to the \cite{art:BH87} for alleviation of the garden
sprinkler effect is used but the diffusion coefficient is simplified to a single
homogeneous parameter ($D_{nn}$ as in Eq.~(\ref{eq:Dnn_d})).  An additional
1-2-1 weighted averaging scheme is also available by the {\F PSMC} namelist logic
variable {\code AVERG}.  Reduction of computing time with this SMC grid is significant
in comparison with the conventional grid, thanks to the relaxed time step
restriction at high latitudes and removal of land points from the model.
A remedy for the invalided scalar assumption at high latitude is provided to
extend the global wave model into the entire Arctic Ocean \citep{art:Li16}.  This
Arctic part can be activated by adding the ARC switch along side the SMC switch.

The SMC grid can be used for replacing the regular lat-lon grid so that the
model domain can be extended to high latitudes or even the North Pole without
reducing the time step. This application requires few changes to the
regular grid model except for preparing a few extra input files, including the
cell array and face array files. The cell array can be generated with the
existing regular grid bathymetry by using the sea points only and merging
cells in the longitudinal directions at a few latitude steps \citep{art:Li11}.

Another important use of the SMC grid is for multi-resolution grids.
The base level SMC grid cell can be refined into 4 quarterly cells
by halving both the longitude and latitude grid lengths. Any cell
on this refined level can be further divided into another 4 quarterly
cells. This refinement can go on as required, resulting in multi-resolution
grids in a few refined levels. For consistency, the single resolution
SMC grid is considered to have only one level.  The normal regular grid input
files, such as the water depth, land-sea masks, and sub-grid obstruction,
are no longer required, replaced with sea-point only cell and face arrays
and a sub-grid obstruction file.  The water depth is stored in the cell array
in the last (5-th) column as an integer in meter.  The masks will be defined
inside ww3\_grid with the sea-point cell array.

Wind and ocean current (if any) forcing can be applied using a regular grid at the base
resolution as default input forcing for any SMC grid (single or multi-level).
It will be interpolated on to the refined levels (if any) inside the model.
One option of sea-point only wind and current input for SMC grid can be
switched on by the {\code SEAWND} logical variable in the {\F PSMC} namelist.
This sea-point only option not only removes the need to interpolate the wind
(and current, if any) inside the model but also allows different resolution wind
(and current) forcings to be mixed up and interpolated to multi-resolution cells
directly, making it a truly multi-resolution model.

\begin{figure}
\centerline{\epsfig{file=./num/smcelary.eps,angle=0,width=3.in}}
\caption{Illustration of cell arrays used in the SMC grid.}
\label{fig:SMCells} \botline
\end{figure}

One important feature of the SMC grid is that it is an unstructured grid, that
is, the cells are not required to be listed side by side as in their physical
position. For the convenience of multi-resolution SMC grid, the cells are
sorted by their sizes so that cells on one given level are grouped together in
one sub-loop for a shared sub-time-step.  The base level time step is halved
as the grid length for the refined level sub-step. This effectively avoids the
model to be slowed down by the refined cells due to their CFL restrictions.
Neighboring cells information for propagation schemes are provided with cell
face arrays, which are pre-calculated for the given cell array list. So there
is no need to expand the sea point only SMC grid cells onto a full grid for
propagation. Fig.~\ref{fig:SMCells} illustrates how SMC cell arrays are
defined and Fig.~\ref{fig:SMC_Arctic} shows the Arctic region in a 6-12-25 km
three level SMC grid. The golden and red circles mark the global and Arctic
parts in the SMC6-25 grid. The Arctic part within the golden circle requires a
fixed reference direction to define its wave directional bins. The global part
(up to the golden circle) can be run independently without the Arctic part.
The 4 rows from the red to the golden circles are duplicated in the Arctic part
as boundary cells if the Arctic part is activated with the ARC option.
Separate cell and face arrays are used for the Arctic part and they are merged
into the global ones within the wave model for propagation.

\begin{figure}
\centerline{\epsfig{file=./num/JCP_Fig2_GArc.eps,angle=0,width=4.in}}
\caption{The Arctic region in a 6-12-25km multi-resolution SMC grid.}
\label{fig:SMC_Arctic}
\botline
\end{figure}

Some IDL and F90 programs have been developed for generation of SMC grid cell
and face arrays and visualization of the grid mesh and wave fields but they
have not been formally included in the WW3 package yet. An IDL program
(Glob50SMCels.pro) is provided in smc\_docs/SMCG\_TKs/ to generate a global 50km
SMC grid using a 50km regular grid bathymetry ASCII input file (G50kmBathy.dat).
Face array generation is done with two F90 programs, one for the global part
(G50SGlSide.f90) and one for the Arctic part (G50SAcSide.f90).  Due to the special
treatment of the polar cell \citep{art:Li12}, face arrays for the Arctic polar cell
requires a different approach than other cells. The cell array file has to be
sorted with a simple Linux script (countcells) before it is fed into the face array
generation program.  The face arrays also need to be sorted with a Linux script
(countijsd) to determine the multi-level sub-loop counts.  An independent spectral
propagation test (G50SMCSRGD.f90) can be run to test the cell and face arrays and
its output can be visualized with an IDL script, g50smstrspb.pro, which uses the
saved projection files from the SMC grid visualization program, g50smcgrids.pro.
By modifying the projection parameters in g50smcgrids.pro, users can choose a
projection view point (in lat-lon degree) and save the projection for model
output visualization.  The sub-grid obstruction file can be generated with the
idl script Glob50SMCObstr.pro.

Compilation of the SMC grid option is similar to that for the regular
lat-lon grid except for that the SMC switch is substituted for the
PR2 UNO combination switches. Note that the SMC grid is built inside
the regular lat-lon grid type so regular lat-lon grid parameters,
such as NX, NY, SX, SY, X1, and Y1, are still required for SMC grid
in ww3\_grid.inp file at the base resolution level. The regular lat-lon
grid water depth, land-sea masks, and sub-grid obstruction input files
are no longer required and they are replaced with SMC grid sea point only
files (depth is stored in the cell array and subgrid obstruction in
G50GObstr.dat).  The depth and land-sea mask input lines in ww3\_grid.in
are, however, kept for passing parameters, such as the minimum depth.
Due to the merges at high latitudes and refined resolutions if any,
regular grid mapping arrays are modified slightly for consistency
with the SMC grid cells.
Refer to the regression test \emph{regtests/ww3\_tp2.10}
for an example of a 3-level SMC grid model for the Lake Erie.

Output post processing for SMC grid models has been developed for
ww3\_ounf and ww3\_outf. For ww3\_ounf the user can choose between
retrieving multi-resolution information at native model grid sea-points,
or generating regular grids at any of the resolution levels set in
the model grid definition. The ww3\_outf program processes SMC grid data
as either the fully expanded regular lat-lon grid output at the base
resolution level or as ASCII output at all SMC grid sea-points (type-4).
For regular grid outputs, parameter values are determined
using an area-weighted average of all SMC grid cells overlapping the chosen
output cell boundaries. Sea-point data latitudes and longtitudes
correspond to the native model grid cell centres. For ww3\_ounf
sea-point outputs, variables describing cell sizes are also provided
in the netCDF file.

Visualization tools for sea-point outputs are not provided with this
code release; however some examples are available from the Met Office
on request. For netCDF sea-point outputs a python based GUI tool has
been developed. Visualization of the all cell ASCII output can be done
with the aid of the input cell array file because the output cell
sequence is the same as the input cell array. The IDL script
g50smcswhglb.pro is an example program to plot the global 50km SMC grid
SWH output. It uses the projection files produced by g50smcgrids.pro.
Users are encouraged to develop their own grid-generating and
post-processing programs in other languages.

It is recommended to read the smc\_docs/SMC\_Grid\_Guide.pdf or the
conference paper \citep{tol:LiS17} at conference web page:
http://www.waveworkshop.org/15thWaves/
for more information or to contact \url{Jian-Guo.Li@metoffice.gov.uk}
for any help about the SMC grid.


\documentclass[aspectratio=169]{beamer}
\usetheme{Boadilla}
\usepackage{xcolor}
\usepackage{amsmath}
%\usepackage{parskip}
%%\usecolortheme{seahorse}
\setbeamersize{text margin left=30mm,
			text margin right=30mm}

%----
%Information to be included in the title page:
%%https://www.overleaf.com/learn/latex/Beamer
\title[Dynamic Programming Part I] %optional
{Introduction to Dynamic Programming}
\subtitle{Part I: An Overview}
\author[PPE Phil(e)]
{PPE Phil(e)\inst{1}}
\institute[] % (optional)
{
  \inst{1}%
  material @ https://github.com/PPEphile
}
\date[2021] % (optional)
{September 2021}
%---

\begin{document}
%---------------------------------------------------------
%Title Page
\frame{\titlepage}
%---------------------------------------------------------

%---------------------------------------------------------
%Table of contents
\begin{frame}
\frametitle{Table of Contents}
\tableofcontents
\end{frame}
%---------------------------------------------------------

%---------------------------------------------------------
%Section: 1
\section{Overview of Dynamic Programming}

%Slide 3
\begin{frame}
\frametitle{Dynamic Programming}
Dynamic Programming is a technique for solving (dynamic) \textbf{optimization} problems.

\begin{itemize}
	\item Dynamic: your \textbf{rewards} and \textbf{limits} change, depending on your actions
	\item Programming: you try to identify the best strategies (plans/policies/programs) (i.e. which maximise or minimise a goal function)
\end{itemize}

A dynamic optimization problem often has the form:
\begin{equation}
	\max_{(c_t)^{\infty}_{t=0}} \sum^{\infty}_{t=0} \beta^t U(c_t) \quad s.t. \quad \textrm{constraints fulfilled for} \, \forall t
\end{equation}
where we for now assume that a maximum really exists.
\end{frame}

%Slide 4
\begin{frame}
\frametitle{An Example: Growing corn}
\begin{itemize}
	\item Infinite horizon: t=0,1,2, ...
	\item Each period we decide how much of the harvest to consume: $c_t$
	\item Remainder is planted for next period: $f(k_t)-c_t=k_{t+1}$
	\item We start with a stock of corn of $k_0$
	\item Eating corn gives us utility $U(c_t)$, but we discount future meals at the rate $\beta^t$
\end{itemize}

Substituting $c_t$ for $f(k_t) - k_{t+1}$, we have
\begin{equation}
	\max_{0 \leq k_{t+1} \leq f(k_t)} \sum^{\infty}_{t=0} \beta^t U(f(k_t) - k_{t+1})
\end{equation}

\color{red}\textbf{Hence, we have an infinite number of variables and constraints!}
\end{frame}

\begin{frame}
\frametitle{An indirect attack: Dynamic Programming}
"Direct attacks" (e.g. Kuhn-Tucker \& Lagrange) only sometimes work in such scenarios. Dynamic Programming approaches the problem indirectly via the so-called \textbf{value function}.

\begin{itemize}
\item Translate $U(f(k_t) - k_{t+1}) \rightarrow F(k_t, k_{t+1})$
\end{itemize}

We now call the \textbf{Sequence Problem (SP)}
\begin{equation}
	\max_{0 \leq k_{t+1} \leq f(k_t)} \sum^{\infty}_{t=0} \beta^t F(k_t, k_{t+1}) \tag{SP}
\end{equation}

The \textbf{value function} is defined as the solution to the (SP)
\begin{equation*}
	v^{*}(k_0) = \max_{0 \leq k_{t+1} \leq f(k_t)} \sum^{\infty}_{t=0} \beta^t F(k_t, k_{t+1})
\end{equation*}
\end{frame}

%slide 6
\begin{frame}
\frametitle{From (SP) to Bellman Equation}
But now, something interesting happens:
\begin{align*}
	v^{*}(k_0)&= \max_{0 \leq k_{t+1} \leq f(k_t)} \sum^{\infty}_{t=0} \beta^t F(k_t, k_{t+1}) \\
	&= \max_{0 \leq k_{1} \leq f(k_0)} \left\lbrace F(k_0, k_1) + \max_{0 \leq k_{t+1} \leq f(k_t)} \sum^{\infty}_{t=1} \beta^t F(k_t, k_{t+1}) \right\rbrace \\
	&= \max_{0 \leq k_{1} \leq f(k_0)} \left\lbrace F(k_0, k_1) + \beta \max_{0 \leq k_{t+2} \leq f(k_t)} \sum^{\infty}_{t=0} \beta^t F(k_{t+1}, k_{t+2}) \right\rbrace	\\
	&= \max_{0 \leq k_{1} \leq f(k_0)} \left\lbrace F(k_0, k_1) + \beta v^*(k_1) \right\rbrace
\end{align*}

This is called the Bellman equation, which uses Bellman's \textbf{Principle of Optimality}: For a policy to be optimal, whatever we choose today, the remaining decisions must still be optimal.
\end{frame}

%slide 7
\begin{frame}
In the Bellman equation we just saw that
\begin{equation*}
v^*(k_0) = \max_{0 \leq k_{1} \leq f(k_0)} \left\lbrace F(k_0, k_1) + \beta v^*(k_1) \right\rbrace
\end{equation*}

As a result, we know that for any candidate function $v$ to be the true value function $v^*$, it needs to map onto itself! We call this \color{blue}\textbf{necessary condition} \color{black} the \textbf{Functional Equation (FE)}

\begin{block}{Functional Equation}
\begin{equation}
v(x) = \max_{y \in \Gamma(x)} \left\lbrace F(x, y) + \beta v(y) \right\rbrace \tag{FE}
\end{equation}
where $\Gamma(x)$ is the set of admissible values of $y$ given the current state $x$.
\end{block}
\begin{itemize}
\item This is a "functional" equation because the unknown is a \textit{function}.
\end{itemize}
\end{frame}

%slide 8
\begin{frame}
\frametitle{Wrap-up}
\begin{itemize}
\item We can now start to see what it means that Dynamic Programming approaches the (SP) through the value function.
\begin{itemize}
\item As we will see in the next videos, Dynamic Programming makes use of the fact the we can often learn a lot about the value function, which, in turn, helps us learning about the optimal policy.
\end{itemize}
\end{itemize}
\medskip

\textbf{Outlook on tools:}
\begin{itemize}
\item Functional Equation
\item Euler Equation
\item Value function iteration (numeric)
\end{itemize}
\end{frame}

\begin{frame}
\textbf{Check-points for today:}
\begin{itemize}
\item Understand what a dynamic optimization problem is
\item Understand what a value function is
\item Conceptualize that we are searching for an unknown function
\end{itemize}
\end{frame}

%---------------------------------------------------------
%Section: 2
\section{Additional Material}

\begin{frame}
\frametitle{Additional Material}
In notation and exposition, the series closely orients itself on Stokey and Lucas (1989), which is one of the most popular textbooks on Dynamic Programming. If you don't understand something or wish to dig deeper, please check-out the textbook.
\medskip

\textbf{Helpful references}:
\begin{itemize}
\item Simon, C.P. and Blume, L. (1994) \textit{Mathematics for Economists}. New York, Norton \& Company Inc.
\item Stokey, N.L., Lucas, R.E. and Prescott, E.C. (1989) \textit{Recursive Methods in Economic Dynamics}. Cambridge, Harvard University Press.
\end{itemize}

\end{frame}

\end{document}


\documentclass[12]{scrartcl}
\usepackage{amssymb,amsmath,gensymb,dsfont,calc,multicol,fullpage}
\makeatletter
\newcommand\Aboxed[1]{
   \@Aboxed#1\ENDDNE}
\def\@Aboxed#1&#2\ENDDNE{%
   &
   \settowidth\@tempdima{$\displaystyle#1{}$}
   \setlength\@tempdima{\@tempdima+\fboxsep+\fboxrule}
   \kern-\@tempdima
   \boxed{#1#2}
}
\makeatother

\begin{document}

\title{Homework 30, Section 5.4: 7, 12, 14, 24, 25}
\author{Alex Gordon}
\date{\today}
\maketitle
\section*{Homework}
\subsection*{7.}
Since $T(b_1) = t(1) = 3 + 5t, (T(b_1))_B = \begin{bmatrix}  3 \\5 \\ 0  \end{bmatrix}.$ also, since $T(b_2) = T(t) = -2t + 4t^2, (T(b_2))_B = \begin{bmatrix}  0 \\-2 \\ 4  \end{bmatrix},$ and $T(b_3) = T(t^2) = t^2, (T(b_3))_b = \begin{bmatrix}  0 \\ 0 \\ 1  \end{bmatrix}$. Thus the matrix representation of T relative to the basis b is $\begin{bmatrix}  3 & 0 & 0  \\5 &-2 & 0 \\ 0 & 4 & 1 \end{bmatrix}$
\subsection*{12.}
The eigenvalues of the matrix are 1 and 3. \\
For $\lambda = 1, A - I = \begin{bmatrix}  -1 & 1 \\ -3 & 3 \end{bmatrix}.$ The basis vector for the eigenspace, with $x_2$ being free, is $v_1 = \begin{bmatrix}  1\\1 \end{bmatrix}$\\
For $\lambda = 3, A - I = \begin{bmatrix}  -3 & 1 \\ -3 & 1 \end{bmatrix}.$ The basis vector for the eigenspace, with $x_2$ being free, is $v_1 = \begin{bmatrix}  1\\1 \end{bmatrix}$\\
\subsection*{14.}

\subsection*{24.}
If $A = PBP^{-1}$ then rank $A =$ rank $P(BP^{-1} =$ rank $BP^{-1}$. Also, Rank $BP^{-1} = $ rank $B$, since $p^{-1}$ is invertible. Thus, rank$A = $rank$B$.
\subsection*{25.}
IF $A = PBP^{-1}$ then by the trace property $tr(A) = tr(P^{-1}PB) = tr(IB) = tr(B).$ if B is diagonal, then the diagonal entries of B must be the eigenvalues of A, by the diagonalization theorem. So, tr$a = $ tr $b=$ the sum of the eigenvalues of A.

\end{document}


 \documentclass [12pt]{article}

\usepackage {amsmath}
\usepackage {amsthm}
\usepackage {amssymb}
\usepackage {graphicx}
\usepackage {float}
\usepackage {multirow}
\usepackage {xcolor}
\usepackage [ruled,vlined,commentsnumbered,titlenotnumbered]{algorithm2e} \usepackage {array}
\usepackage {booktabs}
\usepackage {url}
\usepackage {parskip}
\usepackage [margin=1in]{geometry}
\usepackage [T1]{fontenc}
\usepackage {cmbright}
\usepackage [many]{tcolorbox}
\usepackage [colorlinks = true,
            linkcolor = blue,
            urlcolor  = blue,
            citecolor = blue,
            anchorcolor = blue]{hyperref}
\usepackage {enumitem}
\usepackage {xparse}
\usepackage {verbatim}
\usepackage{algpseudocode}
\usepackage{listings}
\usepackage{xcolor}
\lstset { %
    language=C++,
    backgroundcolor=\color{black!5}, % set backgroundcolor
    basicstyle=\footnotesize,% basic font setting
}
\newtheorem{theorem}{Theorem}
\newtheorem{remark}{Remark}
\newtheorem{lemma}[theorem]{Lemma}
\theoremstyle{definition}
\newtheorem{definition}{Definition}[section]
\newtheorem{claim}{Claim}
\newtheorem{proposition}{Proposition}

\DeclareTColorBox {Solution}{}{breakable, title={Solution}} \DeclareTColorBox {Solution*}{}{breakable, title={Solution (provided)}} \DeclareTColorBox {Instruction}{}{boxrule=0pt, boxsep=0pt, left=0.5em, right=0.5em, top=0.5em, bottom=0.5em, arc=0pt, toprule=1pt, bottomrule=1pt} \DeclareDocumentCommand {\Expecting }{+m}{\textbf {[We are expecting:} #1\textbf {]}} \DeclareDocumentCommand {\Points }{m}{\textbf {(#1 pt.)}}

\begin {document}

\vspace {1em}
\begin {Instruction}
Adapted From Virginia Williams'lecture notes.
\end {Instruction}

{\LARGE \textbf {COMP 285 (NC A\&T, Spr `22)}\hfill \textbf {Lecture 30} }

\begin{centering}
\section*{More Greedy: Huffman Coding and MST}
\end{centering}

\section{Activity Selection}

Last lecture, we introduced the activity selection problem and walkted through a few possible candidates for greedy algorithms.

\begin{proposition}
For each $S_{i ,j}$, there is an optimal solution $A_{i ,j}$ containing $a_k \in S_{i ,j}$ of minimum finishing time $f_k$.
\end{proposition}

Note that if the proposition is true, when $f_k$ is minimum, then $A_{i ,k}$ is empty, as no activities can finish before $a_k$ ; thus, our optimal solution only depends on one other subproblem $A_{k ,j}$ (giving us a linear time algorithm).

Here, we prove the proposition.

\begin{proof}

Let $a_k$ be the activity of minimum finishing time in $S_{i ,j}$. Let $A_{i ,j}$ be some maximum set of non-conflicting activities. Consider $A'_{i ,j} = A_{i ,j} \setminus {a_l} \cup {a_k}$ where $a_l$ is the activity of minimum finishing time in $A_{i ,j}$. It's clear that $|A'_{i ,j}| = |A_{i ,j}|$. We need to show that $A'_{i ,j}$ does not have conflicting activities. We know $a_l \in A_{i ,j} \subset S_{i ,j}$. This implies $f_l \geq f_k$ , since $a_k$ has the minimum finishing time in $S_{i ,j}$.

All $a_t \in A_{i ,j} \setminus {a_l}$ don't conflict with $a_l $, which means that $s_t \geq f_l$ , which means that $s_t \geq f_k$ , so this means that no activity in $A_{i ,j} \setminus {a_l}$ can conflict with $a_k$ . Thus, $A'_{i ,j}$ is an optimal solution.
\end{proof}

Due to the above proposition, the expression for $A_{i ,j}$ from before simplifies to the following
expression in terms of $a_k \subseteq S_{i ,j}$, the activity with minimum finishing time $f_k$ .

\begin{align*}
|A_{i,j}| = 1 + |A_{k,j}| \\
A_{i,j} = A_{k,j} \cup \{a_k \}
\end{align*}

Algorithm Greedy-AS assumes that the activities are presorted in nondecreasing order of their finishing time, so that if $i < j$, $f_i \leq f_j$.

\begin{algorithm}
\caption{Greedy-AS(a)}
\label{alg:greed_as}
\begin{algorithmic}
\State $A \gets \{a_1\}$ \texttt{/* activity of min $f_i$}
\State $k \gets 1$
\State \For{$m = 2 \to n$} {
    \State \If{$s_m \geq f_k$} {
        \State \texttt{// $a_m$ starts after last activity in A}
        \State $A \gets A \cup \{a_m\}$
        \State $k \gets m$
    }
}
\State \Return $A$
\end{algorithmic}
\end{algorithm}

By the above claim, this algorithm will produce a legal, optimal solution via a greedy selection of activities. There may be multiple optimal solutions, but there always exists a solution that includes $a_k$ with the minimum finishing time. The algorithm does a single pass over the activities, and thus only requires $O(n)$ time – a dramatic improvement from the trivial dynamic programming solution. If the algorithm also needed to sort the activities by $f_i$ , then its runtime would be $O(n \log n)$ which is still better than the original dynamic programming solution.

\section{Scheduling}

Consider another problem that can be solved greedily. We are given $n$ jobs which all need a common resource. Let $w_j$ be the weight (or importance) and $l_j$ be the length (time required) of job $j$. Our output is an ordering of jobs. We define the completion time $c_j$ of job $j$ to be the sum of the lengths of jobs in the ordering up to and including $l_j$ . Our goal is to output an ordering of jobs that minimizes the weighted sum of completion times $\sum_{j} w_jc_j$.

\subsection{Intuition}
Our intuition tells us that if all jobs have the same length, then we prefer larger weighted jobs to appear earlier in the order. If jobs all have equal weights, then we prefer shorter length jobs in the order.

\begin{figure}[h!]
    \centering
    \includegraphics[scale=0.5]{scheduling_intuition.png}
\end{figure}

In the first case, assuming they all have equal weights of $1$, $\sum^{3}_{i=1} w_ic_i = 1 + 3 + 6 = 10.$ In the second case, $\sum^{3}_{i=1} w_ic_i = 3 + 5 + 6 = 14.$

\subsection{Optimal Substructure}

What do we do in the cases where $l_i < l_j$ and $w_i < w_j$? Consider the optimal ordering of jobs. Suppose we have a job $i$ that is followed by job $j$ in the optimal order. Consider swapping jobs $i$ and $j$. The example below swaps jobs 1 and 2.

Note that swapping jobs $i$ and $j$ does not alter the completion times for every other job and only changes the completion times for $i$ and $j$. $c_i$ increases by $l_j$ and $c_j$ decreases by $l_i$. This means that our objective function $\sum_i w_ic_i$ changes by $w_il_j -w_jl_i$. Since we assumed our order was optimal originally, our objective function cannot decrease after swapping the jobs. This means,
$$
w_il_j - w_jl_i \geq 0
$$
which implies
$$
\frac{l_j}{w_j} \geq \frac{l_i}{w_i}
$$

Therefore, we want to process jobs in increasing order of $\frac{l_i}{w_i}$, the ratio of the length to the weight of each job. The algorithm also does a single pass over jobs, and thus only requires $O(n)$ time, assuming the jobs were ordered by $\frac{l_i}{w_i}$. Like previously, if the algorithm also needed to sort the jobs based on the ratio of length to weight, then its runtime would be $O(n \log n)$.

\section{Optimal Codes}

Our third example comes from the field of information theory. In ASCII, there is a fixed $8$
bit code for each character. Suppose we want to incorporate information about frequencies
of characters to obtain shorter encodings. What if we want to represent characters by codes
of different lengths depending on each character's frequencies? We explore a greedy solution
to find the optimal encoding of characters.

To create optimal codes, we want a way to encode and decode our sequence. To encode the
sequence, we would just have to concatenate the code of each character together. How about
for decoding? Consider the following codes of characters: $a \to 0, b \to 1, c \to 01$. However,
when decoding, when we encounter $01$, this could be decoded as ``ab''or ``c''. Therefore, our
codes need to be prefix free: no codeword is a prefix of another.

\subsection{Tree Representation}
We may think of representing our codes in a tree structure, where the codewords represent the leaves of our tree. An example is shown below:

\begin{figure}[h!]
\centering
\includegraphics{huffman_tree.png}
\end{figure}

Above, in addition to the characters $\{a, b, c, d, e, f \}$, we've included frequency information. That is, $f (a) = 0.45$ means that the probability of a random character in this language being equal to a is $.45$. The code for each character can be found by concatenating the bits of the path from the root to the leaves. By convention, every left branch is given the bit 0 and every right branch is given the bit 1.

As long as the characters are on the leaves of this tree, the corresponding code will be
prefixfree. This is because one string is a prefix of another if and only if the node corresponding to the first is an ancestor of the node corresponding to the second. No leaf is an ancestor of any other leaf, so the code is prefix-free.

\subsection{How good is a code?}
Suppose we have a set of characters $C$ with frequencies$ f (c)$ so that $\sum_{c\in C} f (c) = 1$. That is, $f (c)$ can be thought of as the probability of using a letter $c$ in this language. The cost, in terms of bits, of a character $c \in C$ when using the coding scheme represented by a tree $T$ is just the depth in the tree $T$: $\text{cost}(c) = d_T(c)$. For example, in the tree above, $e$ has depth 4 in the tree, and requires 4 bits to represent. The average cost of the tree is
$$
B(T) = \mathbb{E}_{c \in C}[d_t(C)] = \sum_{c \in C} f(c)d_T(c)
$$

We say that a tree $T$ is optimal if this expected cost $B(T)$ is as small as possible.

\subsection{Huffman Codes}

In 1951, David A. Huffman, in his MIT information theory class, was given the choice of a
term paper or final exam. Huffman chose to do the term paper rather than take the final
exam. He found greedy algorithm to find the most efficient binary code, which we know today
as Huffman codes.

The basic idea is this: build subtrees for subsets of characters and merge them from the
bottom up, combining the two trees with the characters of minimum total frequency.

\begin{algorithm}
\caption{A high-level description of the Huffman Coding algorithm}
\label{alg:huffman_algo}
\begin{algorithmic}
\State \textbf{Input:} Set of characters $C = \{c_1, c_2, \cdots, c_n \}$ of size $n$, and $F = \{f(c_1), f(c_2), \cdots, f(c_n) \}$, a set of frequencies.
\State Create nodes $N_k$ for each character $c_k$ with key $f(c_k)$
\State Let the \texttt{current} denote the set $\{N_1, \cdots, N_n\}$ of nodes.
\State \While {\texttt{current} has \textit{length of more than one}} {
    \State Find the two nodes $N_i$ and $N_j$ in the \texttt{current} with the minimum frequencies and create a new intermediate node $I$ with $N_i$ and $N_j$ as its children, so that $I$.key $= N_i$.key $+ N_j$.key.
    \State Add $I$ to the \texttt{current} and remove $N_i, N_j$
}
\State \Return \textit{the only entry of \texttt{current}, which is the root of the tree}
\end{algorithmic}
\end{algorithm}

The tree shown above results from running this algorithm on the letters with those frequencies; see the slides for an illustration of this process.

\subsection{Proof of Correctness}

This algorithm works, but at first it's not at all obvious why. For a rigorous proof, refer to
Lemmas 16.2 and 16.3 in CLRS. However, we'll sketch the idea below. Formally, the proof
goes by induction. Recall that after iteration t in Algorithm \ref{alg:huffman_algo}, we have a list current, which contains the roots of subtrees that we still need to merge up. We will maintain the following inductive hypothesis:

\begin{itemize}
    \item \textbf{Inductive hypothesis}: Suppose we have completed $t$ iterations of the loop in Algorithm \ref{alg:huffman_algo}. Then there exists a way to merge the subtrees in current that is optimal.
    \item For the \textbf{base case}, we observe that when $t = 0$, current is just the set of all characters, and definitionally there exists an optimal tree made out of these nodes.
    \item For the \textbf{inductive step}, we need to show that if the inductive hypothesis holds at step $t - 1$, then it holds at step $t$. We'll sketch this later.
    \item Finally, to conclude the argument, we see that at the end of the algorithm, there is only one element in current, and in this case the inductive hypothesis reads that there is a way to merge this single subtree to obtain an optimal subtree. That's just a convoluted way of saying that the single tree we return is optimal, and so we are done.
\end{itemize}
All that remains to show is the inductive step. We first observe the following claim:

\begin{proposition}
We are given a set of characters $C$ and a set of its associated frequencies $F$ where $f (c)$ is the frequency of character $c$. Let $x$ and $y$ be the characters with the two smallest frequencies. There exists an optimal coding tree for $C$ such that $x$, $y$ are sibling leaves.
\end{proposition}

\begin{proof}
Let $T$ be the optimal coding tree for $C$. The optimal coding tree must be a full binary
tree, that is, every non-leaf node must have two children. Let a, b be characters that are
sibling leaves of maximum depth. We define the number of bits to encode $c$ as $d_T (c)$ and
the number of bits needed for the coding tree as $B(T) = \sum_c f(c)d_T(c)$.

We can replace $a, b$ by $x, y$ without increasing the total number of bits needed for the coding
tree.\footnote{For simplicity, we ignore the case where $a, b, x, y$ are not distinct. For more details, see Lemma 16.2 in CLRS} If we swap $x$ and $a$, the change in cost becomes $f (x)d_T (a) + f (a)d_T (x) - f (x)d_T (x) - f (a)d_T (a) = (f (x) - f (a))(d_T (a) - d_T (x)) \leq 0$

Therefore, swapping $a, b$ with $x, y$ will not increase our objective function $B(T)$. Hence, there exists an optimal coding tree where x, y are siblings in the tree.
\end{proof}

\begin{proposition}
Let $C$ be a set of characters, and let $T$ be an optimal coding tree for $C$. Imagine creating $C'$ from $C$ by collapsing all the characters in a subtree rooted at a node $N$ with key $k = N$.key into a single character $c'$ with frequency $k$. Then the corresponding tree $T'$ is optimal for $C'$ . Conversely, suppose that a tree $T'$ that is an optimal coding tree for an alphabet $C'$ . Let $c'\in C'$ be a character with frequency $f (c')$. Introduce new characters $c_1'' , \cdots , c_r''$ with total frequency $\sum^{r}_{i=1} f (c''i ) = f (c')$. Let $T'$ be an optimal coding tree on $c''_1 , \cdots , c''_r$ . Then the tree $T$ on the alphabet $C = (C'\setminus \{c'\}) \cup \{c''_1 , \cdots , c''r \}$ that has the leaf $c'$ replaced with the subtree $T'$ is optimal.
\end{proposition}

\begin{proof}
Let T and T' be the two trees described in the lemma, and consider the difference of their costs.

\begin{align*}
B(T) - B(T') &= \sum_{c\in C} f(c) \cdot d_T(c) - \sum_{c \in C'} f(c) d_{T'}(c) \\
&= \left(\sum_{i=1}^r f(c_i'' d_T(c_i'')) - f(c')d_{T'}(c') \right) \\
&= \left(\sum_{i=1}^r f(c_i'')(d_{T''}(c_i'') + d_{T'}(c'))\right) - f(c')d_{T'}(c') \\
&= \sum_{i=1}^{r} f(c_i'')d_{T''}(c_i'') + d_{T'}(c')\sum_{i=1}^r f(c_i'') - f(c')d_{T'}(c') \\
&= \sum_{i=1}^t f(c_i'')d_{T''}(c_i'')
\end{align*}

where the last line used the fact that $\sum^{r}_{i=1} f (c ''_i ) = f (c ' )$, and so the last two terms cancelled. This means that the difference in the cost between these two trees only depends on $T''$, it doesn't depend at all about the structure of $T$. Thus, $T$ is optimal if and only if $T'$ is optimal.
\end{proof}

The two Claims together prove the inductive step, because the second claim implies that the logic of the first claim holds, even for newly created intermediate nodes $I$.

\textbf{Note}: The proof in CLRS has the same basic steps (Lemmas 16.2 and 16.3 instead of the claims above), although phrased slightly differently. The sketch above is pretty sketchy, so if the above is hard to follow, please check out CLRS for a more detailed version.

\end{document}


\chapter{Conclusion}
\label{cha:conclusion}

This thesis started with explaining the new research area of Electronic Health Record Analytics. We explored the possible impact of this area as it allows to find medical patterns on a large scale. Those patterns range from drug discovery, disease progression for individuals, and reducing medical costs. At the moment several research groups are working on utilizing EHRs to find medical patterns using several methods like querying, statistics, data mining, and artificial intelligence approaches. \\
Our research sought to explore the usage of new machine learning approaches to find correlations between different diagnoses. The correlations found can be used in combination with prediction or classification methods. \\

We introduced a new way on how to apply Word2Vec methods by explaining the link between sentences of words and sequence of medical records. We call this approach a generalized Word2Vec approach and it can be applied on medical data to find the correlations between different diagnoses. \\
To make sure the generalized Word2Vec methods can be applied to large-scale medical data, we applied the generalization concept also on DeepWalk. DeepWalk makes it possible to generate a smaller dataset from the original dataset and then apply a Word2Vec approach on this smaller dataset. \\
Besides the exploration on generalizing Word2Vec approaches, we also improved Word2Vec by tackling one of its shortcomings. This shortcoming of Word2Vec is that it is unable to handle unseen instances once it has built his lookup table. We combine a k-nearest neighbors method with Word2Vec and make an estimation of the correlation to other diagnoses for the unseen instance. \\

We explained how we built a model of our proposed methods. We introduced the OSIM2 dataset on which we trained a model using our generalized Word2Vec, knn Word2Vec, and generalized DeepWalk. \\
We explained our categorization approach using fixed intervals and disease code mapping. With this categorization of the data we enabled more general EHR events during training. We also explained the different parameters for each of our approaches and discussed why we chose their corresponding values. \\

After building the model, we executed two different experiments by generating clusters based on our model. The reason behind the clusters is that we could compare those clusters with the clusters found in the Danish paper. In a sense, experiment $2$ looks at how well the relations are for all the diseases in the Danish clusters and not only the diseases which are in the lookup table of the Word2Vec model as done in experiment $1$. We quantify this comparison using a matching percentage.  \\
We checked the influence of a parameter on the matching percentage by inspecting each parameter setting. From all these parameter settings, we deduced general trends. \\
After checking the individual parameters, we took the parameter setting with the highest average matching percentage for each approach and compared the different approaches. \\

The results from both experiments are that each approach has a maximum matching percentage of $60$\%. It is still difficult to quantify how well a match is of around $60$\% but we concluded this is good enough to show the potential of our approaches. \\

We conclude that both our knn Word2Vec and DeepWalk have the same performance as the basic generalized Word2Vec. This means that we can handle unseen EHR events and train our model on $50$\% of the dataset size using DeepWalk without losing accuracy. \\
Within the limitations of our validation method, we conclude that our models do match the Danish results well depending on the experiment. Especially since we use several estimations such as the disease code mapping, different datasets, and categorization. \\

For more information about another possible experiment which also combines the Word2Vec approaches with prediction or classification methods, we refer to the next chapter. In this chapter we also discuss some possible improvements and future directions to explore.

%%% Local Variables:
%%% mode: latex
%%% TeX-master: "thesis"
%%% End: