We carry around three different 1D radial quantities: $\etarhoec$
(edge-centered), $\etarhocc$ (cell-centered), and $\divetarho$
(cell-centered).  These notes discuss when each of these is used, and
how they are computed, in both plane-parallel and spherical.

\section{The Mixing Term, $\etarho$}

The base state evolves in response to heating and mixing in the star.
The density evolution is governed by
\begin{eqnarray}
\frac{\partial \rho_0}{\partial t} &=& -
 \nablab \cdotb \left( \rho_0 w_0 \er \right)
- \nablab \cdotb \left( \etarho \er \right) \enskip ,
\label{eq:rho0upd_new}
\end{eqnarray}
with
\begin{equation}
\etarho(r) = \overline{\left(\rhop \Ubt \cdot \er \right)} = \frac{1}{A(\Omega_H)}
 \int_{\Omega_H}  (\rhop \Ubt \cdot \er ) \; dA \enskip , \label{eq:eta}
\end{equation}
designed to keep the average value of the full density, $\rho$, over a
layer of constant radius in the star equal to $\rho_0$.  To complete
the update of the base state, we need evolution equations for the
pressure, $p_0$, and velocity, $w_0$.  For spherical geometry, the
derivation of $w_0$ constraint equation is shown in
the multilevel paper, resulting in the following system
\begin{eqnarray}
w_0 &=& \ow + \delta w_0 \\
\frac{1}{r^2} \frac{\partial}{\partial r} \left (r^2 \ow \right ) &=& \Sbar \\
\frac{\partial}{\partial r} \left[ \frac{\gammabar p_0}{r^2} \frac{\partial}{\partial r} (r^2 \dw) \right] &=& - \frac{g}{r^2} \frac{\partial (r^2 \etarho)}{\partial r} - \frac{4 (\ow + \dw) \rho_0 g}{r}
- 4 \pi G \rho_0 \etarho \label{eq:dw0constraint}
\end{eqnarray}

In paper~III, we introduced a mixing term, $\etarho$, to the density
evolution equation (eq.~[\ref{eq:rho0upd_new}]), with the objective of
keeping the base state density equal to the average of the density
over a layer.  For a spherical base state, it is best to define the
average in terms of spherical coordinates,
\begin{equation}
\overline{q} = \frac{1}{4\pi} \int_{\Omega_H} q(r,\theta,\phi) \; d\Omega
\end{equation}
where $\int_{\Omega_H} d\Omega = 4\pi$ represents the integral over
the spherical $\theta$ and $\phi$ angles at constant radius.

Recall from Paper III that if initially $\overline{\rho'} = 0$,
there is no guarantee that $\overline{\rho'} = 0$ will hold at later
time.  To see this, recall equation (\ref{eq:Perturbational Density}),
written in a slightly different form:
\begin{equation}
\frac{\partial\rho'}{\partial t} + \nabla\cdot\left(\rho'\Ub\right) = -\nabla\cdot\left(\rho_0\Ubt\right).
\end{equation}
We integrate this over a spherical shell of thickness $2h$ at radius $r_0$, i.e.,
$\Omega_H \times (r_0-h, r_0+h)$, and normalize by the integration
volume, which is $\sim 4\pi r_0^2  2h$ for small $h$, to obtain:
\begin{eqnarray}
\frac{1}{4\pi r_0^2 2h}\int_{r_0-h}^{r_0+h}r^2 dr\int_{\Omega_H}\left[\frac{\partial\rho'}{\partial t} + \nabla\cdot\left(\rho'\Ub\right)\right]d\Omega
&=& - \frac{1}{4\pi r_0^2 2h}\int_{r_0-h}^{r_0+h}r^2 dr\int_{\Omega_H}\nabla\cdot\left(\rho_0\Ubt\right)d\Omega \nonumber \\
&=& \left. -\frac{1}{4\pi r_0^2 2h}\int_{\Omega_H}\left[\rho_0\left(\Ubt\cdot\eb_r\right)\right]r^2 d\Omega\right|_{r_0-h}^{r_0+h} \nonumber \\
&=& 0,
\end{eqnarray}
where we have used the divergence theorem in spherical coordinates to transform
the volume integral on the right hand side into an area integral over $\Omega_H$.
We see that the right hand side disappears since
$\int_{\Omega_H}\rho_0(\Ubt\cdot\eb_r)d\Omega=0$,  which follows from the definition
of $\Ubt$.  Now, expanding the remaining terms and taking the limit as
$h\rightarrow 0,$ we can write
\begin{eqnarray}
0 &=& \lim_{h\rightarrow 0} \frac{1}{4\pi r_0^2 2h} \int_{r_0-h}^{r_0+h} r^2  dr \int_{\Omega_H} \left[\frac{\partial \rho'}{\partial t} + \nabla\cdot(\rho'\Ub)\right] d\Omega \nonumber \\
&=& \frac{\partial}{\partial t} \left( \lim_{h\rightarrow 0} \frac{1}{4\pi r_0^2} \frac{1}{2h} \int_{r_0-h}^{r_0+h} r^2  dr \int_{\Omega_H}  \rho' d\Omega \right) + \lim_{h\rightarrow 0} \left[\frac{1}{4\pi r_0^2  2h} \int_{r_0-h}^{r_0+h} r^2  dr \int_{\Omega_H}  \nabla \cdot ( \rho' \Ub )  d\Omega\right] \nonumber \\
&=& \frac{\partial}{\partial t} \left(\frac{1}{4\pi} \int_{\Omega_H}  \rho'  d\Omega \right) + \lim_{h\rightarrow 0} \left\{\left.\frac{1}{r_0^2 2h}\left[\frac{1}{4\pi}\int_{\Omega_H} \rho' (\Ub \cdot \eb_r)  d\Omega  \right]  r^2 \right |_{r_0-h}^{r_0+h} \right\} \nonumber  \\
&=&  \frac{\partial}{\partial t} \overline{\rho'} + \lim_{h\rightarrow 0} \left\{ \left .  \frac{1}{r_0^2  2h} \left[ \overline{\rho' (\Ub \cdot \eb_r)} \right]  r^2  \right |_{r_0-h}^{r_0+h} \right\} \nonumber  \\
&=&  \frac{\partial}{\partial t} \overline{\rho'} + \lim_{h\rightarrow 0} \frac{1}{r_0^2 2h} \int_{r_0-h}^{r_0+h} \nabla \cdot \left[\overline{\rho' (\Ub \cdot \eb_r)} \eb_r \right]  r^2  dr \nonumber \\
&=&  \frac{\partial}{\partial t} \overline{\rho'} + \nabla \cdot \left[ \overline{\rho' (\Ub \cdot \eb_r)} \eb_r \right]
\end{eqnarray}
again using the divergence theorem, extracting the time derivative from the spatial integral,
and switching the order of operations as appropriate.

In short,
\begin{equation}
\frac{\partial}{\partial t} \overline{\rho'} = - \nabla\cdot\left[\overline{\rho'\left(\Ub\cdot\eb_r\right)}\eb_r\right] = -\nabla\cdot\left(\etarho\eb_r\right), \label{eq:rhopbar}
\end{equation}
and thus, $\etarho = \overline{\left(\rho'\Ub\cdot\eb_r\right)}$.

We need both $\etarho$ alone and its divergence for the
various terms in the construction of $w_0$ and the correction to
$\rho_0$.  The quantity $\etarho$ is edge-centered on our grid, and
for Cartesian geometries, we constructed it by averaging the
appropriate fluxes through the grid boundaries.  For a spherical base
state, this does not work, since the spherical shells do not line up
with the Cartesian grid boundaries.

Therefore, we take a different approach.  We compute $\etarho$ by
constructing the quantity $\rhop \Ubt \cdot \er$ in each cell, and then
use our average routine to construct a 1-d, cell-centered
$\eta_{\rho,r}$ (this is essentially numerically solving the integral
in Eq.~[\ref{eq:eta}]).  The edge-centered values of $\etarho$,
$\eta_{\rho,r+1/2}$ are then constructed by simple
averaging: \MarginPar{should we be doing a volume-weighted average?}
\begin{equation}
\eta_{\rho,r+1/2} = \frac{\eta_{\rho,r} + \eta_{\rho,r+1}}{2} \enskip .
\end{equation}

Instead of differencing $\eta_{\rho,r+1/2}$ to construct the
divergence, we instead use equation~(\ref{eq:rhopbar}) directly, by writing:
\begin{equation}
\left [ \nabla \cdot (\etarho \er ) \right ]^{n+1/2}
= - \frac{\overline{\rhop^{n+1}} - \overline{\rhop^n}}{\Delta t}
= - \frac{\overline{\rhop^{n+1}}}{\Delta t} \enskip ,
\end{equation}
where we have made use of the fact that $\overline{\rhop^n} = 0$ by construction.

%-----------------------------------------------------------------------------
% flow chart
%-----------------------------------------------------------------------------
\section{$\eta$ Flow Chart}
\begin{enumerate}
\item Enter {\tt advance\_timestep} with $[\etarhoec, \etarhocc]^{n-\myhalf}$.
\item Call {\tt make\_w0}.  The spherical version uses uses $\etarho^{{\rm ec},n-\myhalf}$ and $\etarho^{{\rm cc},n-\myhalf}$.
\item Call {\tt density\_advance}.  The plane-parallel version computes $\etarho^{{\rm flux},n+\myhalf,*}$.
\item Call {\tt make\_etarho} to compute $[\etarhoec, \etarhocc]^{n+\myhalf,*}$.  The plane-parallel version uses $\etarho^{{\rm flux},n+\myhalf,*}$.
\item Call {\tt make\_psi}.  The plane-parallel version uses $\etarho^{{\rm cc},n+\myhalf,*}$.
\item Call {\tt make\_w0}.  The spherical version uses uses $\etarho^{{\rm ec},n+\myhalf,*}$ and $\etarho^{{\rm cc},n+\myhalf,*}$.
\item Call {\tt density\_advance}.  The plane-parallel version computes $\etarho^{{\rm flux},n+\myhalf}$.
\item Call {\tt make\_etarho} to compute $[\etarhoec, \etarhocc]^{n+\myhalf}$.  The plane-parallel version uses $\etarho^{{\rm flux},n+\myhalf}$.
\item Call {\tt make\_psi}.  The plane-parallel version uses $\etarho^{{\rm cc},n+\myhalf}$.
\end{enumerate}

%-----------------------------------------------------------------------------
% computing
%-----------------------------------------------------------------------------
\section{Computing $\etarhoec$ and $\etarhocc$}
This is done in {\tt make\_eta.f90}.

\subsection{Plane-Parallel}
We first compute a radial edge-centered multifab, $\etarho^{\rm flux}$, using
\begin{equation}
\eta_{\rho,\ib+\myhalf\eb_r}^{\rm flux} = \left[\left(\Ubt_{\ib+\myhalf\eb_r}^{n+\myhalf}\cdot\eb_r\right) + w_{0,r+\myhalf}^{n+\myhalf}\right] \rho_{\ib+\myhalf\eb_r}^{n+\myhalf} - w_{0,r+\myhalf}^{n+\myhalf}\rho_{0,r+\myhalf}^{n+\myhalf, {\rm pred}}
\end{equation}
$\etarhoec$ is the edge-centered ``average'' value of $\eta_{\rho}^{\rm flux}$,
\begin{equation}
\eta_{\rho,r+\myhalf}^{\rm ec} = \overline{\eta_{\rho,\ib+\myhalf\eb_r}^{\rm flux}}
\end{equation}
$\etarhocc$ is a cell-centered average of $\etarhoec$,
\begin{equation}
\eta_{\rho,r}^{\rm cc} = \frac{\eta_{\rho,r+\myhalf}^{\rm ec} + \eta_{\rho,r-\myhalf}^{\rm ec}}{2}.
\end{equation}

\subsection{Spherical}\label{Sec:eta Spherical}
First, construct $\eta_{\rho}^{\rm cart} =
[\rho'(\Ubt\cdot\eb_r)]^{n+\myhalf}$ using:
\begin{equation}
\left[\frac{\rho^n+\rho^{n+1}}{2}-\left(\frac{\rho_0^n+\rho_0^{n+1}}{2}\right)^{\rm cart}\right] \sum_d\left(\frac{\Ubt_{\ib+\myhalf\eb_d}^{n+\myhalf}\cdot\eb_d+\Ubt_{\ib-\myhalf\eb_d}^{n+\myhalf}\cdot\eb_d}{2}\right)n_d.
\end{equation}
Then, $\etarhocc$ is the cell-centered average of $\eta_{\rho}^{\rm cart}$,
\begin{equation}
\etarhocc = \overline{\eta_{\rho}^{\rm cart}}.
\end{equation}
On interior faces, $\etarhoec$ is the average of $\etarhocc$,
\begin{equation}
\eta_{\rho,r-\myhalf}^{\rm ec} = \frac{\eta_{\rho,r-1}^{\rm cc} + \eta_{\rho,r}^{\rm cc}}{2}.
\end{equation}
At the upper and lower boundaries, we use
\begin{eqnarray}
\eta_{\rho,-\myhalf}^{\rm ec} &=& 0, \\
\eta_{\rho,{\rm nr}-\myhalf}^{\rm ec} &=& \eta_{\rho,{\rm nr}-1}^{\rm cc}.
\end{eqnarray}

%-----------------------------------------------------------------------------
% etarho_ec
%-----------------------------------------------------------------------------
\section{Using $\etarhoec$}
\subsection{Plane-Parallel}
NOT USED.

\subsection{Spherical}
In {\tt make\_w0}, $\etarhoec$ is used in the construction of the RHS
for the $\delta w_0$ equation.

%-----------------------------------------------------------------------------
% etarho_cc
%-----------------------------------------------------------------------------
\section{Using $\etarhocc$}
\subsection{Plane-Parallel}
In {\tt make\_psi}, $\psi = \etarhocc g$.

\subsection{Spherical}
In {\tt make\_w0}, $\etarhocc$ is used in the construction of the RHS
for the $\delta w_0$ equation.


\chapter{Derivation of spreading coefficient limit of declining infection}\label{chap:principles}

In this document I try to develop a model that would help me to understand the
essential figures and numbers that we should be monitored and measured in order to
distinguish the effective and ineffective measures in limiting the spread of
the COVID19 virus.

I start the derivation from the measured reproduction number $R0$. We know that
the nature of the growth of the infection is exponential which inherently
means the disease is spread by infected persons infecting the uninfected ones
over certain period of time. Later on in Chapter \ref{sect:discrete_time} I add a more detailed discrete time
system model to reveal the effects of the feedback delays. That model is still
under construction, and I need to fit the system parameter presented in the
following to that model.
With COVID19 there is lots of statistics about number of
infected persons, daily new cases, deaths and recoveries. Based on these
statistics we may derive the estimate of the contamination time during which
the infected patient spreads the disease in such a manner that the daily
proportional growth equals the monitored reproduction number.

Under assumption that infected persons spread the disease with constant
fraction of cases per day, the newly infected persons tomorrow can be
expressed as
\begin{align}
    y\left(n\right)&=K y\left(n-1\right)\\
    K&= \frac{y\left(n\right)}{y\left(n-1\right)}=
    \frac{y\left(n\right)-y\left(n-1\right)}{y\left(n-1\right)}+1
\end{align}
where $y\left(n\right)$ is the number of infected persons on day $n$. Without
limiting measures $K$ is assumed here to be relatively constant.

We may express $K$ as
\begin{align}
    K&= 1+S\\
    S &= \frac{y\left(n\right)-y\left(n-1\right)}{y\left(n-1\right)},
\end{align}
where $S$ is spreading coefficient, the \emph{ ratio of of daily increase of
    cases  to
active cases }. It should be noted that any estimation error that is in fixed
proportion to actually confirmed cases is canceled in calculation of $S$. Thus
we can state that any measure that gives us proportionally relatively stable
information will provide us accurate information about $S$.

As shown before, $K_l$ and $S$ can be measured. So can be the reproduction
number $R_0$, which for the COVID19 have been estimated to be $R_0=2.06 \ldots
2.52$~\cite{Zhang_S2020}.
These two expansion mechanisms are related, ans they should match at least in early phases of
epidemic, when deaths, recoveries, countermeasures, and developing immunity do not hinder the
spreading. The relation can be expressed as
\begin{align}
    K^{T_c}&= 1+R_0\\
    T_c&=\frac{\ln\left(1+R_0\right)}{\ln\left(K\right)},
\end{align}
where $T_c$ is the contamination time, i.e.\ the effective time during which the patients
spread the disease. It can be thought as a time before patient get's so
visibly sick that he will be isolated/quarantined from the community and thus
does not spread the disease. This time is specific to disease and we may
assume here it is relatively constant.

We may now denote the spreading coefficient, measured as the ratio of increase
to the active cases, in the beginning of the epidemic as $S_0$. Thus
\begin{align}
    T_c&=\frac{\ln\left(1+R_0\right)}{\ln\left(1+S_0\right)}
\end{align}
For present COVID19, $S_0$ seems to be, with reasonable number of cases,
between 0.3 and 0.2, thus we may use $S_0=0.25$ in our example
calculations. We may now preform an example calculation for contamination
period
\begin{align}
    S_0&=0.25\\
    R_0&=2.5\\
    T_c&=\frac{\ln\left(1+R_0\right)}{\ln\left(1+S_0\right)}=5.6.
\end{align}
Thus the estimate of the contamination time is 5.6 days, and we assume that to
remain constant.

Under ongoing epidemic, public authorities and private persons perform
measures to reduce $S$ in order to hinder the spread of the disease. However,
as $S$ and $R_0$ are connected, we may try to calculate \emph{how low we should
reduce $S$ in order to stop the epidemic under assumption that $T_T$ does not
change}. Stopping the epidemic means $R_0< 1$. We may now calculate the limit
$S_l$ that should result in declining numbers of active patients.
\begin{align}
    {\left(1+S_l\right)}^{T_c}&<2\\
    S_l&<2^{\frac{\ln\left(1+S_0\right)}{\ln\left(1+R_0\right)}}-1.
\end{align}
With the given values for current COVID19 outbreak $S_l<0.13$.

In Table~\ref{tab:variants} the obtained values under various assumptions are
presented.
\begin{table}[h!]
  \begin{center}
      \caption{Spreading coefficient limit value under various assumptions on
      reproduction number $R_0$ and initial spreading coefficient $S_0$}\label{tab:variants}
   \begin{tabular}{c|c|c|c} % <-- Alignments: 1st column left, 2nd middle and 3rd right, with vertical lines in between
        \textbf{$R_0$} & \textbf{$S_0$} & \textbf{$T_c$} & \textbf{$S_l$}\\
      \hline
      2 &0.25&4.9&0.15 \\
      2 &0.3&4.2&0.18\\
      2 &0.4&3.7&0.21\\
      2.5&0.25&5.6&0.13\\
      2.5&0.3&4.8&0.16\\
      2.5&0.4&4.2&0.18\\
      3 &0.25&6.2&0.11\\
      3 &0.3&5.3&0.14\\
      3 &0.4&4.6&0.18\\
    \end{tabular}
  \end{center}
\end{table}
These values reveal that with given parameter spread there is no
\emph{practical} difference in contamination time, it lies between 3.7 to 6.2
days. This means practically two days difference, easily masked by individual
variation and real life uncertainties.
Furthermore we may quite
certainly say there is no chance of epidemic to stop with spreading factors
larger than 0.2. Assuming 0.15 might be wishful thinking but may work, and 0.1 should be
quite safe.

As the global data for the cases have been collected and made generally
available it is possible to evaluate the theory by comparing it to
existing data. That comparison well be presented in Chapter~\ref{chap:observations}.

\section{Parameter estimation with measured data}
On March 23 friend of mine,  Teemu Lehtimäki suggested that the measured
relative growth e.g.\ in Sweden and the trend of measured cases do not support
the $R_0$ parameter value 2.x, but that the correct number could be higher. The
arising is, what is the most reliable way to estimate $T_t$ in the beginning
of the epidemic, when the behaviour of the individuals is not affected by the
counter measures, but when the cases are relatively scarce. I think one
possible
method is LMS curve fitting based on measured relative growth and difference
of cases $y\left(n\right)-y\left(n-x\right)$.

\chapter{Discrete time infection system model}\label{sect:discrete_time}
In order to gain more insight on input-output relation (i.e the
transfer function),,stability and critical parameters to be identified, I
developed s simple discrete-time system model.

Fig \ref{fig:infection_system} depicts a discrete time infection system model
in Z-domain. $X(Z)$ are
    the infectious patients entering the community with spreading factor $S$.
$X_q(Z)$ are the infectious patients entering the system through
quarantine. They are known to be infectious, but they are isolated.
\begin{figure}
    \centering
    \includegraphics[width=\textwidth]{Figures/Infection_system.eps}
    \caption{Discrete time Infection system in Z-domain.}\label{fig:infection_system}
\end{figure}

Fig \ref{fig:infection_feedback_system} presents the infection feedback
eventually causing the exponential growth. Every infectious patient $X$ will
initiate an infection chain over $T_c$ days, adding $S$ new infections.
\begin{figure}
    \centering
    \includegraphics[width=\textwidth]{Figures/Contamination_feedback_system.eps}
    \caption{Infection feedback system $W(Z)$}\label{fig:infection_feedback_system}
\end{figure}

Due to the feedback through $W(Z)$, the system will eventually have positive
feedback causing exponential type of growth. The parameters characterizing the
system behaviour are listed in Table~\ref{table:system parameters}.
\begin{table}
    \centering
    \caption{Infection system parameters}\label{table:system parameters}
    \begin{tabular}{l|p{10cm}}
        \textbf{Parameter} & \textbf{Description} \\
        \hline
        $S$ & Spreading factor.\\
        $T_i$ & Incubation period. It is assumed that the patient is not
        infectious during this time. \\
        $T_c$ & Contamination period. Patient spreads the disease during this
        time until is isolated from the population because of sickness or
        treatment.\\
        $T_m$ & Monitoring delay. The time from the patient becoming
        infectious to registration of the case.\\
        $r_d$ & Death rate. The share of the registered patients dying.\\
        $T_d$ & Delay of death. Time from registration to death.\\
        $T_r$ & Recovery time.
    \end{tabular}
    \label{tab:system_parameters}
\end{table}

\subsection{Considerations on the feedback model}
In the beginning of the  April I had already several bothersome days of
thinking the accuracy of the  feedback model. There seemed to be a
discrepancy between the exponential growth model I describe in the beginning
of this chapter, and the $R_0$-based exponential model. As per now, (April 2), I
think I have developed an explanation that helps to get the modeling forward.

The parameters $s_k$ define define the feedback system $W(Z)$ In simplest case,
$s_0=R_0$, and the other feedback coefficients are zero. This will provide
the growth due to feedback on a single day with the delay of $T_i$. To use
relative growth as a measure in this kind of a system, we should estimate the
$T_i$ accurately, and use the past values $y\left(n-T_i\right)$ in calculation
of relative growth. Currently I use $y\left(n-1\right)$ in calculation of the
relative growth, and it does not take into account the incubation period at
all. Adding the delay would increase the relative growth values on by the
average gain of over incubation period, (which should be $R$).

So, the
question remains why my model seems to work, even though it is timing wise
incorrect. My current thoughts are the following and subject to change. The
way I originally thought the exponential growth process is, that \emph{a
    patient infects persons as geometric series so that total number of persons over the
contamination person is increased by reproduction number $R$}. This is technically incorrect.
However, it can be modeled as $s_k$  values in Fig.~\ref{fig:infection_feedback_system}
\begin{align}
    s_k&=s\left(1+s\right)^k, \quad k=\left[0,T_c-1\right].
\end{align}
This is the  sum of the growth after $T_c$, which compensates the lack of $T_i$.
Actually, as
\begin{align}
    s_{T_c}&=\left(1+s\right)^{T_c}-1=R,
\end{align}
the model works exactly as the incubation period were $T_c$. So the timing
error in the relative growth estimate is the difference of the contamination
period $T_c$, and incubation period $T_i$. Most likely this is not zero, but
the question is, is that difference typically smaller than the estimation
error of the incubation period? If it is, it is, using this model provides
better estimate than the discrete time model with estimated
incubation period. One can also think, that the incubation period \emph{is}
the period over which the patient is infectious but not sick enough to isolate
himself. At the end of the incubation period, the patient has infected $R$
patients. This effectively means $T_c=T_i$, which would mean that the model is
accurate, and measuring the relative growth would reflect quite accurately the
characteristics of the system. It also distributes the exponential growth
over the $T_c$ with exponential emphasis on the last days. More considerations
are required to determine if this is accurate enough.

The remaining delay is the measurement delay
$T_m$, which is not related to the disease, but the system measuring it. This
does not affect the relative growth number, only delays the result by $T_m$-
It should also be noted, that we may measure the contamination period by
monitoring the relative growth at the point where the increase of the number
of active cases stops.

Therefore following observations about the nature of the
system can be made.
\begin{itemize}
    \item System is not linear time invariant, but can be considered piecewise
        linear over
        the coherence time on $S$, i.e. during the periods $S$ is not altered,
        and linear time invariant, if $S$ is considered constant.
    \item As the fraction of recovered and dead patiences increases, the $S$
        is decreased. This phenomenon is not included in this model,
        indicating infinite population.
    \item Timing relation of the signal and $S$ in the feedback path indicates
        that the effect of changes in policies affecting $S$ are immediate to
        the spreading of the disease, and visible in the statistics after the
        measurement delay $T_m$.
\end{itemize}


\documentclass[10pt, letterpapr]{article}
\usepackage[utf8]{inputenc} % document encoding
\usepackage{graphicx}
\usepackage{comment} % allow comment blocks to be added
\usepackage{amsmath}

\begin{document}

\subsection*{Multiphase flow through porous media}

\subsubsection*{Liquid phase}

Flux through a porous medium is defined as:

\[
	f_l=-K\frac{d\psi}{dz}
\]

\noindent where $f_l$ is liquid flux density [kg\,m$^{-2}$\,s$^{-1}$], $\psi$ is the matric potential [J\,kg$^{-1}$] $\left(\text{note: }\psi=gh\right)$, and $K$ is the hydraulic conductivity [kg\,s\,m$^{-3}$].\footnote{note: $K_{kg\cdot\,s\cdot\,m^{-3}}=\frac{\rho_l}{g}K_{m\cdot\,s^{-1}}$}

When combined with the mass conservation equation, the result yields the transient vertical (1D) Richards (1931) equation:

% pg.166 Bittelli etal (2015); potential is being represented in the energy per unit mass form (J/kg) rather than the per unit volume form (J/m3=Pa) to avoid temperature dependence on liquid volume (see pg.98).

\[
	\rho_l\frac{\partial\theta}{\partial t}=\frac{\partial}{\partial z}\left[K(\psi)\left(\frac{\partial\psi}{\partial z}+g\right)\right],
\]

\noindent which is often expressed in its so-called $\psi$--based form:

\[
	\rho_lC(\psi)\frac{\partial\psi}{\partial t}=\frac{\partial}{\partial z}\left[K(\psi)\left(\frac{\partial\psi}{\partial z}+g\right)\right],
\]

\noindent where $\rho_l$ is the density of the liquid [kg\,m$^{-3}$], $g$ is the acceleration to to gravity ($\approx9.80665$\,m\,s$^{-2}$ or J\,kg$^{-1}$\,m$^{-1}$). The capacity [kg\,J] term is solved using the Campbell (1974) model: % pg121

\[
	C(\psi)=\frac{d\theta}{d\psi}=\frac{-\theta}{b\psi}
\]

\noindent and conductivity:

\[
	K(\psi)=
	\begin{cases}
		K_s\left(\frac{\psi_e}{\psi}\right)^{2+3/b}  \qquad &\text{if $\psi_m\leq\psi_e$} \\
		K_s  &\text{otherwise}
	\end{cases}
\]

\noindent where $K_s$ is the saturated conductivity [kg\,s\,m$^{-3}$], $b$ is a shape parameter and $\psi_e$ is the air-entry potential [J kg$^{-1}$]. Furthermore, water content ($\theta$) [m$^3$ m$^{-3}$] and $\psi$ are assumed related by the power-law relationship:

\[
	\theta(\psi)=
	\begin{cases}
		\theta_s\left(\frac{\psi}{\psi_e}\right)^{-1/b}  \qquad &\text{if $\psi_m\leq\psi_e$} \\
		\theta_s  &\text{otherwise}
	\end{cases}
\]

\noindent or conversely,

\[
	\psi(\theta)=
	\begin{cases}
		\psi_e\left(\frac{\theta}{\theta_s}\right)^{-b}  \qquad &\text{if $\theta\leq\theta_s$} \\
		\psi_e  &\text{otherwise}
	\end{cases}
\]

\noindent where $\theta_s$ is the water content at saturation. The water balance for cell $i$ can be solved using the its finite-difference form: % linear method
\[
	\frac{\rho_l\left(\theta_i^{j+1}-\theta_i^j\right)\left(z_{i+1}-z_{i-1}\right)}{2\Delta t}=\frac{\overline{K}_i\left(\psi_{i+1}-\psi_i\right)}{z_{i+1}-z_i}-\frac{\overline{K}_{i-1}\left(\psi_i-\psi_{i-1}\right)}{z_i-z_{i-1}}+u_i
\]

\noindent or in its $\psi$-based form:
\[
	\frac{\rho_lC_i\left(\psi_i^{j+1}-\psi_i^j\right)\left(z_{i+1}-z_{i-1}\right)}{2\Delta t}=\frac{\overline{K}_i\left(\psi_{i+1}-\psi_i\right)}{z_{i+1}-z_i}-\frac{\overline{K}_{i-1}\left(\psi_i-\psi_{i-1}\right)}{z_i-z_{i-1}}+u_i
\]

The source term $u_i$ could include extraction by roots, evaporation, etc. In most cases, for vertical simulations, the source term represents gravitational flux, where:
\[
	u_i=g\left(\overline{K}_{i-1}-\overline{K}_i\right).
\]

% The solution to the above equation is done implicitly, by solving a system equations. Transforming the above to:
% \begin{align*}
	% \varrho(i) &=\rho_lC_i\frac{\left(z_{i+1}-z_{i-1}\right)}{2\Delta t} \\
	% k(i) &=\frac{K_i}{z_{i+1}-z_i} \\
	% c(i) &= a(i+1) = k(i) \\
	% b(i) &= k(i-1)+k(i)+\varrho(i) \\
	% d(i) &= \varrho(i)\psi_i^j+u(i)
% \end{align*}

% \noindent the finite-difference scheme for $4$ layers is put in matrix form:
% \[
	% \begin{bmatrix}
		% b(1) & c(1) & 0 & 0 \\
		% a(2) & b(2) & c(2) & 0 \\
		% 0 & a(3) & b(3) & c(3) \\
		% 0 & 0 & a(4) & b(4)
	% \end{bmatrix}
	% \begin{bmatrix}
		% \psi^{j+1}(1) \\
		% \psi^{j+1}(2) \\
		% \psi^{j+1}(3) \\
		% \psi^{j+1}(4)
	% \end{bmatrix}
	% =
	% \begin{bmatrix}
		% d(1) \\
		% d(2) \\
		% d(3) \\
		% d(4)
	% \end{bmatrix}
% \]

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection*{Vapour phase within the soil matrix}

Vapour flux density [kg\,m$^{-2}$\,s$^{-1}$] (i.e., molecular diffusion flux of water vapour in the air) is defined using Fick's Law: %pg.70 Novak
\[
	f_v=-\rho_a D(\theta) \frac{dq}{dz},
\]

\noindent where $\rho_a$ is the density of air, [kg m$^{-3}$], $D(\theta)$ is the effective coefficient of turbulent diffusion of water vapour in pore-space air [m$^2$\,s$^{-1}$], often given the form attributed to Penman (1940):
\[
	D(\theta)=D_a\eta\left(\theta_s-\theta\right),
\]

\noindent where $D_a$ is coefficient of molecular diffusion of water vapour in air $\approx2.12\times10^{-5}$ m$^2$\,s$^{-1}$, and $\eta$ is a dimensionless coefficient characterizing the turbulent diffusion in porous media, $\eta\approx0.66$ (Penman, 1940). Note that the term $\left(\theta_s-\theta\right)$ is included correct for the volume of gas-filled porosity, where vapour flux is occurring. $q$ is the specific humidity (moisture content) of air [kg\,kg$^{-1}$]:
\[
	q=\frac{\varepsilon e}{P}=wq^*(T,P),
\]

\noindent where $e$ and $P$ are the vapour and total pressures, respectively [kg\,m$^{-1}$\,s$^{-2}$], $\varepsilon$ is the ratio of the molecular weight of water to the molecular weight of air ($\approx 0.622$), $w$ is the relative humidity [--], and $q^*$ is the saturated specific humidity determined using the August-Roche-Magnus-Tetens relationship:
\[
	q^*(T,P)=\frac{0.38}{P}\exp\left(\frac{17.625T}{T+243.04}\right),
\]

\noindent where $P$ is in [kPa] and $T$ is in [$^\circ$C].

Within a porous medium, assuming isobaric (i.e., $P_\text{pores}\approx P_a$) and isothermal (constant temperature) conditions, the specific humidity gradient can be related to pore-space relative humidity ($w_p$) and soil temperature ($T_s$) by:
\[
	\frac{dq}{dz}=q^*(T_s,P)\frac{dw_p}{dz}.
\]

By further assuming that the liquid and vapour phases are in equilibrium (i.e., have equal potential and the partial pressure of water has reached its vapour pressure, $e$), according to the ideal gas law, pore-space relative humidity can be determined from liquid potential by (Philip, 1957):
\[ %eq:wp
	w_p=\frac{e}{e^*(T_s)}=\frac{q}{q^*(T_s,P)}=\exp{\frac{\omega_w\psi}{RT_s}},
\]

\noindent where the gas constant $R=8.3143$ J mol$^{-1}$ K$^{-1}$, the molecular mass of water $\omega_w=0.01802$ kg mol$^{-1}$, and $e^*$ is the saturated vapour pressure at the temperature of the soil surface $T_s$ [K]. Next, using the chain rule,
\[
	\frac{dw_p}{dz}=\frac{dw_p}{d\psi}\frac{d\psi}{dz}=w_p\frac{\omega_w}{RT_s}\frac{d\psi}{dz},
\]

\noindent Combining the above equations, results in:
\[
	f_v=-K_v\frac{d\psi}{dz},
\]

\noindent where
\[
	K_v=\frac{\omega_w\eta\rho_aD_aq}{RT_s}\left(\theta_s-\theta\right),
\]

By combining the flux of water vapour, the Richards equation can be re-stated as (Nov\'ak, 2012): % pg.71
\[
	\rho_l\frac{\partial\theta}{\partial t}=\frac{\partial}{\partial z}\left[K(\psi)\left(\frac{\partial\psi}{\partial z}+g\right)+\rho_a D(\theta)\frac{\partial q}{\partial z}\right],
\]

\noindent and further:

\[
	\rho_l\frac{\partial\theta}{\partial t}=\frac{\partial}{\partial z}\left[\left[K(\psi)+K_v(\theta,q)\right]\frac{\partial\psi}{\partial z}+gK(\psi)\right].
\]

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection*{Atmospheric exchange}

At the soil surface--atmosphere interface, the flux density to the atmosphere remains (Nov\'ak, 2012):
\[
	f_v=\rho_a D \frac{dq}{dz}
\]

Assuming that vertical fluxes do not change in the vicinity of the evaporating soil surface, integrating the above equation from the soil surface ($z_s$) and some effective height above the surface ($z_a$) yields: %pg.45 in Novak

\[
	-\int\limits_{q_s}^{q_a}dq = \frac{f_v}{\rho_a}\int\limits_{z_s}^{z_a}\frac{dz}{D(z)},
\]

\noindent re-arranging:

\[
	f_v=\frac{1}{\int_{z_s}^{z_a}\frac{dz}{D(z)}}\rho_a(q_s-q_a).
\]

\noindent Next, by defining a water vapour turbulent transport coefficient ($k_v$) [m\,s$^{-1}$]:

\[
	k_v=\frac{1}{\int_{z_s}^{z_a}\frac{dz}{D(z)}},
\]

\noindent vapour flux density to the atmosphere from the gas-filled pores can be written as:
\begin{align*}
	f_{v,g} &=\rho_ak_v(q_s-q_a) \\
	&=\rho_ak_v\left[q_s-w_aq^*(T_a,P_a)\right],
\end{align*}

\noindent and
\[
	f_{v,l}=\rho_ak_v(q^*(T_s,P_a)-q_a),
\]

\noindent where $w_a$ is the atmospheric relative humidity, $T_a$ is air temperature [K], and $P_a$ is air pressure [Pa\,=\,kg\,m$^{-1}$\,s$^{-2}$]. (Note that for water, the units for flux density [kg\,m$^{-2}$\,s$^{-1}$] is equivalent to [mm\,s$^{-1}$].) The water vapour turbulent transport coefficient can be related to wind speed ($u(z)$) [m\,s$^{-1}$] using boundary-layer theory: % simplified from pg.49 Novak
\[
	k_v\approx\frac{\kappa^2u(z)}{\left[\ln\left(\frac{z}{z_0}\right)+\frac{\beta}{L_*}z\right]^2} \approx\frac{\kappa^2u(z)}{\ln\left(\frac{z-d_e}{z_0}\right)^2},
\]

\noindent where $\kappa$ is the von-K\'arm\'an constant ($\approx0.4$), $z_0$ is the roughness length [m], $\beta$ and $L_*$ are the Monin-Obukhov (1954) coefficient of atmospheric stability and characteristic length, respectively, and $d_e$ is the so-called zero-plane displacement height [m]. Alternatively, the Penman (1948)/Penman-Monteith (1965) relationship to aerodynamic resistance ($r_a$), soil surface resistance ($r_s$) and canopy resistance ($r_c$) [s\,m$^{-1}$] can be used, where:
\[
	k_v=\frac{1}{r_a+r_s+r_c}.
\]

Lastly, the effective mass flux evaporating from the soil surface must account for the portion of the soil surface area exposed to gas-filled pores and the area of direct liquid exposure:
\begin{align*}
	f_e &=\left(\theta_s-\theta\right)f_{v,g}+\theta f_{v,l}. \\
		&=\rho_ak_v\left[\theta_s(q_s-q_a)+\theta(q^*_s-q_s)\right]
\end{align*}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection*{Numerical solution to the Richards equation}

One solution to the 1D Richards equation is the cell-centered finite volume solution scheme following Bittelli et.al.\,(2015). The cell-centered finite-volume form to the above equations gives the mass-balance at node $i$ as:
\[
	\rho_lV_i\frac{\partial\theta_i}{\partial t}=\sum_{j=1}^{n}F_{ij}+u_i \qquad\forall i\neq j,
\]

\noindent where $V_i$ is the finite volume of cell/node $i$, and the inter-nodal mass flux [kg\,s$^{-1}$]:
\[
	F_{ij}=-A_{ij}\overline{K}_i\frac{h_i-h_j}{L_{ij}},
\]

\noindent and $h_i=\psi_i+gz$ is the total hydrostatic potential [J\,kg$^{-1}$]. In the 1D vertical, The water balance in cell $i$ (i.e., implicit Euler method---evaluating at the end of the time step) is: %pg.63
\[
	\frac{\rho_lV_i\overline{C}_i}{\Delta t}\left(h_i^{k+1}-h_i^k\right)=F_i\left(h_i^{k+1}-h_{i+i}^{k+1}\right)-F_{i-1}\left(h_{i-1}^{k+1}-h_i^{k+1}\right)+u_i,
\]

\noindent where
\[
	F_i=-A_i\frac{\overline{K}_i}{z_{i+1}-z_i}.
\]
\noindent and
\[
	\overline{C}_i=\frac{d\theta}{dh}\approx\frac{\theta_i^{k+1}-\theta_i^k}{h_i^{k+1}-h_i^k}.
\]

The solution to the above equation is done implicitly, by solving a system equations, expanding the above and letting:
\begin{align*}
	\varrho(i) &=\frac{\rho_l V_i\overline{C}_i}{\Delta t} \\
	f(i) &=\frac{A_i\overline{K}_i}{z_{i+1}-z_i} \\
	c(i) &= a(i+1) = -f(i) \\
	b(i) &= f(i-1)+f(i)+\varrho(i) \\
	d(i) &= \varrho(i)h_i^k+u_i
\end{align*}

\noindent the finite-volume scheme for $4$ layers is put in matrix form:
\[
	\begin{bmatrix}
		b(1) & c(1) & 0 & 0 \\
		a(2) & b(2) & c(2) & 0 \\
		0 & a(3) & b(3) & c(3) \\
		0 & 0 & a(4) & b(4)
	\end{bmatrix}
	\begin{bmatrix}
		h^{k+1}(1) \\
		h^{k+1}(2) \\
		h^{k+1}(3) \\
		h^{k+1}(4)
	\end{bmatrix}
	=
	\begin{bmatrix}
		d(1) \\
		d(2) \\
		d(3) \\
		d(4)
	\end{bmatrix}
\]

\noindent which is a tri-diagonal matrix that is solved using the Thomas algorithm.

\subsubsection*{Newton-Raphson transformation}

A finite-difference solution to the 1D Richards equation is solved using the Newton-Raphson solution scheme following Bittelli et.al.\,(2015). The water balance in cell $i$ is:

\begin{multline*}
	F_i=\frac{\overline{K}_i\left(\psi_{i+1}-\psi_i\right)}{z_{i+1}-z_i}-\frac{\overline{K}_{i-1}\left(\psi_i-\psi_{i-1}\right)}{z_i-z_{i-1}} \\
		-g\left(\overline{K}_i-\overline{K}_{i-1}\right)-\frac{\rho_l}{2\Delta t}\left(\theta_i^{k+1}-\theta_i^k\right)\left(z_{i+1}-z_{i-1}\right),
\end{multline*}

\noindent where $F$ is the mass balance residual and $\overline{K}$ is the mean elemental hydraulic conductivity. Applying integral transform methods (Bittelli et.al., 2015), $\overline{K}$ is defined by: %eq.8.53 pg.178
\[
	\overline{K}_i=\frac{K_{i+1}\psi_{i+1}-K_i\psi_i}{\left(1+3/b\right)\left(\psi_{i+1}-\psi_i\right)}.
\]

\noindent The solution to the above equation is then considered a minimization problem, whereby Newton-Raphson:

\[
	\frac{\partial F}{\partial\psi}\cdot \left(\psi^{k+1}-\psi^k\right)=-F\rightarrow 0 \\
\]

\noindent or in a matrix-form for a $3$--layer profile is:

\[
	\begin{bmatrix}
		\frac{\partial F_1}{\partial\psi_1} & \frac{\partial F_1}{\partial\psi_2} & \frac{\partial F_1}{\partial\psi_3} \\
		\frac{\partial F_2}{\partial\psi_1} & \frac{\partial F_2}{\partial\psi_2} & \frac{\partial F_2}{\partial\psi_3} \\
		\frac{\partial F_3}{\partial\psi_1} & \frac{\partial F_3}{\partial\psi_2} & \frac{\partial F_3}{\partial\psi_3}
	\end{bmatrix}
	\begin{bmatrix}
		\psi_1^{k+1}-\psi_1^k \\
		\psi_2^{k+1}-\psi_2^k \\
		\psi_3^{k+1}-\psi_3^k
	\end{bmatrix}
	=
	\begin{bmatrix}
		-F_1 \\
		-F_2 \\
		-F_3 \\
	\end{bmatrix}
\]

\noindent where $k$ indicates the $k^{th}$ iteration of the minimization attempt. The mass-balance function $F$ is solved by:

\[
	F_i=f_i-f_{i-1}+u_i-u_{i-1}-\frac{\rho_l}{2\Delta t}\left(\theta_i^{k+1}-\theta_i^k\right)\left(z_{i+1}-z_{i-1}\right),
\]

\noindent where
\[
	f_i=-\frac{\overline{K}_i\left(\psi_{i+1}-\psi_i\right)}{z_{i+1}-z_i} = -\frac{K_{i+1}\psi_{i+1}-K_i\psi_i}{\left(1+3/b\right)\left(z_{i+1}-z_i\right)}
\]

\noindent and letting
\begin{align*}
	u_i &=-gK_i \\
	\varrho_i &=-\rho_l\theta_i\frac{z_{i+1}-z_{i-1}}{2\Delta t},
\end{align*}

\noindent then substituting yields:
\begin{multline*}
	F_i=\frac{K_i\psi_i-K_{i-1}\psi_{i-1}}{\left(1+3/b\right)\left(z_i-z_{i-1}\right)}
	-\frac{K_{i+1}\psi_{i+1}-K_i\psi_i}{\left(1+3/b\right)\left(z_{i+1}-z_i\right)} \\
	-g\left(K_i-K_{i-1}\right)-
	\frac{\rho_l}{2\Delta t}\left(\theta_i^{k+1}-\theta_i^k\right)\left(z_{i+1}-z_{i-1}\right).
\end{multline*}

\noindent Differentiating $F_i$ with respect to $\psi_i$, $\psi_{i-1}$ and $\psi_{i+1}$ yields:

\begin{align*}
	f'_i &=\frac{\partial f_i}{\partial\psi_i}=\frac{K_i}{z_{i+1}-z_i} \\
	u'_i &=\frac{\partial u_i}{\partial\psi_i}=\frac{gK_i}{\psi_i}(2+3/b) \\
	\varrho'_i &=\frac{\partial \varrho_i}{\partial\psi_i}=\rho_l\frac{\theta_i}{b\psi_i}\frac{z_{i+1}-z_{i-1}}{2\Delta t}
\end{align*}

\noindent and thus % pg.180-181
\begin{align*}
	\frac{\partial F_i}{\partial\psi_i} &=\frac{K_i}{z_{i+1}-z_i}+\frac{K_{i-1}}{z_i-z_{i-1}}+u'_i+\varrho'_i \\
	\frac{\partial F_i}{\partial\psi_{i-1}} &=\frac{-K_{i-1}}{z_i-z_{i-1}}-u'_{i-1} \\
	\frac{\partial F_i}{\partial\psi_{i+1}} &=\frac{-K_i}{z_{i+1}-z_i}
\end{align*}

\noindent Solving the Newton-Raphson system of equations is then accomplished like the linear methods described above.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection*{Boundary conditions}

Boundary conditions for the top of the vertical profile can either be a constant flux (e.g., evaporation) or constant potential:

\begin{itemize}
	\item For constant flux, the source is added to $F_1$;
	\item For a constant potential, $\psi_1^{j+1}$ is known and is set at the start of the time step (since the Newton-Raphson method computes changes in $\psi$ to bring $F$ to zero, $F_1$ and $\frac{\partial F_1}{\partial\psi_i}$ are set to zero before solving; therefore the value of $\psi_1$ will remain constant throughout the time step. For infiltration, set $\psi_1=\psi_e$.
\end{itemize}

At the bottom of the profile, either a constant potential (i.e., water table) or a free drainage condition can be specified using a ghost below the profile that never becomes part of the solution. Free drainage is set by:
\begin{align*}
	\psi_{n+1} &=\psi_n \\
	\theta_{n+1} &=\theta_n \\
	K_{n+1} &=K_n
\end{align*}

\noindent after each outer iteration, where $n$ is the number of finite difference cells being solved.

\newpage
\subsection*{References}

Bittelli, M., Campbell, G.S., and Tomei, F., 2015. Soil Physics with Python. Oxford University Press.

Campbell, G.S., 1974. A simple method for determining unsaturated conductivity from moisture retention data. Soil Science, 117: 311--387.

Monteith, J.L.,1965. Evaporation and environment. Symposia of the Society for Experimental Biology 19: 205–-224.

Nov\'ak, V., 2012. Evapotranspiration in the Soil-Plant-Atmosphere System. Springer. 253pp.

Penman, H.L., 1940. Gas and vapour movements in the soil: I. The diffusion of vapours through porous solids. Journal of Agricultural Science 30(3): 437--462.

Penman, H.L., 1948. Natural evaporation from open water, bare soil and grass. Proceedings of the Royal Society of London. Series A, Mathematical and Physical Sciences 193(1032): 120--145.

Philip, J.R., 1957. Evaporation, and moisture and heat fields in the soil. Journal of Meteorology 14: 354--366.

Richards, L.A., 1931. Capillary conduction of liquids through porous media. Physics 1: 318--333.

\end{document}


\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage{tensor}
\author{Andreas Forster}
\numberwithin{equation}{section}
\renewcommand{\vec}[1]{\ensuremath{\mathbf{#1}}}
\newcommand{\vecs}[1]{\ensuremath{\boldsymbol{#1}}}
\renewcommand{\deg}{\ensuremath{^\circ}}
\newcommand{\norm}[1]{\ensuremath{\left|\left|#1\right|\right|}}
\newcommand{\Exp}{\mathrm{Exp}}

\renewcommand{\arraystretch}{1.5}
%\setcounter{secnumdepth}{0}

\begin{document}
\section{Free Line Parametrization}
A coordinate frame $L_i$ is defined with origin $\tensor[_W]{\vec{p}}{_L}$ on the line and with minimum distance $d_{L}$ to the frame origin. The $x$ axis is aligned with the line and the $z$ axis points away from the origin. The parametrization is as follows:
\begin{equation}
\vec{l} = \left[q_{WL}^T \quad d_L\right].
\end{equation}
The line anchor $\tensor[_W]{\vec{p}}{_L}$ can be calculated in the following way:
\begin{equation}
\tensor[_W]{\vec{p}}{_L} = q_{WL}\times\begin{bmatrix}
0\\0\\d_L\end{bmatrix}
\end{equation}
And the line direction $\tensor[_W]{\vec{x}}{_L}$:
\begin{equation}
\tensor[_W]{\vec{x}}{_L} = q_{WL}\times\begin{bmatrix}1\\0\\0 \end{bmatrix}
\end{equation}
%
\section{Measurement}
Let $\vec{f}_1$ and $\vec{f}_2$ be the bearing vectors through the two endpoints of the detected line segment. $\tilde{\vec{n}} = \frac{\vec{f}_1\times\vec{f}_2}{\norm{\vec{f}_1\times\vec{f}_2}}$ is the normalized normal vector of the plane spanned by the two bearing vectors and defines our measurement.
%
\section{Error formulation}
Given: Measurement $\tilde{\vec{n}}$ and line $\vec{l} = [q_{WL}^T\quad d_L]$.
\subsection{Parallel constraint}
The direction of the line is parallel to the plane defined with $\tilde{\vec{n}}$:
\begin{equation}
\varepsilon_1 = \tensor[_C]{\tilde{\vec{n}}}{^T}C_{CB}\hat{C}_{BW}\tensor[_W]{\vec{x}}{_L}.
\end{equation}
$\varepsilon_1$ is related to the angle $\delta\phi$ between plane and the line $\vec{l}$ in the following way:
\begin{equation}
\varepsilon_1 = \sin \delta\phi.
\end{equation}
\subsection{Distance constraint}
The anchor point should be part of the measured plane. We define the second error term $\varepsilon_2$ as the sine of the angle between the bearing vectors through the anchor point and the projection of that point on the measured plane.
\begin{align}
\varepsilon_2 &= \frac{\tensor[_C]{\tilde{\vec{n}}}{^T} C_{CB} \hat{C}_{BW} \left(\tensor[_W]{\hat{\vec{p}}}{_C} - \tensor[_W]{\vec{p}}{_L}\right)}{\norm{\tensor[_W]{\hat{\vec{p}}}{_C} - \tensor[_W]{\vec{p}}{_L}}}\\
\tensor[_W]{\hat{\vec{p}}}{_C} &= -\left(\tensor[_W]{\hat{\vec{t}}}{_{CB}}+\tensor[_W]{\hat{\vec{t}}}{_{BW}}\right)\\
&=-\left(\hat{C}_{WB} C_{BC} \tensor[_C]{\vec{t}}{_{CB}} +
\hat{C}_{WB} \tensor[_B]{\hat{\vec{t}}}{_{BW}}\right)\\
&=-\hat{C}_{WB} \left(C_{BC} \tensor[_C]{\vec{t}}{_{CB}} +
\tensor[_B]{\hat{\vec{t}}}{_{BW}}\right)
\end{align}
\section{Jacobian w.r.t to $T_{BW}$}
\begin{align}
C_{BW} &\leftarrow C_{BW}\Exp(\vecs{\delta\phi})\\
\tensor[_B]{\vec{t}}{_{BW}} &\leftarrow \tensor[_B]{\vec{t}}{_{BW}} + C_{BW}\vecs{\delta t}
\end{align}
\subsection{$\vecs{\varepsilon_1}$}
\begin{align}
\varepsilon_1 &= \tensor[_C]{\tilde{\vec{n}}}{^T}C_{CB} C_{BW}\Exp(\vecs{\delta\phi}) \tensor[_W]{\vec{x}}{_L}\\
&\approx \tensor[_C]{\tilde{\vec{n}}}{^T}C_{CB} C_{BW}\tensor[_W]{\vec{x}}{_L} - \tensor[_C]{\tilde{\vec{n}}}{^T}C_{CB} C_{BW} \tensor[_W]{\vec{x}}{_L^\wedge}\vecs{\delta\phi}
\end{align}
\begin{align}
\frac{\partial \varepsilon_1}{\partial\vecs{\delta\phi}} &= -\tensor[_C]{\tilde{\vec{n}}}{^T}C_{CB} C_{BW}\tensor[_W]{\vec{x}}{_L^\wedge}\\
\frac{\partial \varepsilon_1}{\partial\vecs{\delta t}} &= \begin{bmatrix} 0&0&0 \end{bmatrix}
\end{align}
\subsection{$\vecs{\varepsilon_2}$}
%
%
Let:
\begin{equation}
\vec{v} = \frac{\tensor[_W]{\hat{\vec{p}}}{_C} - \tensor[_W]{\vec{p}}{_L}}{\norm{\tensor[_W]{\hat{\vec{p}}}{_C} - \tensor[_W]{\vec{p}}{_L}}}
\end{equation}
Then:
\begin{align}
\varepsilon_2 &= \tensor[_C]{\tilde{\vec{n}}}{^T} C_{CB} C_{BW} \Exp(\vecs{\delta\phi}) \vec{v}\\
&\approx \tensor[_C]{\tilde{\vec{n}}}{^T} C_{CB} C_{BW} \vec{v} - \tensor[_C]{\tilde{\vec{n}}}{^T} C_{CB} C_{BW} \vec{v}^\wedge \vecs{\delta\phi}
\end{align}
\begin{align}
\frac{\partial\varepsilon_2}{\partial\vecs{\delta\phi}} &= \tensor[_C]{\tilde{\vec{n}}}{^T} C_{CB} C_{BW}\frac{\partial \vec{v}}{\partial\vecs{\delta\phi}} - \tensor[_C]{\tilde{\vec{n}}}{^T} C_{CB} C_{BW}\vec{v}^\wedge\\
\frac{\partial\varepsilon_2}{\partial\vecs{\delta t}} &= \tensor[_C]{\tilde{\vec{n}}}{^T} C_{CB} C_{BW}\frac{\partial\vec{v}}{\partial \vecs{\delta t}}
\end{align}
\begin{align}
\frac{\partial\vec{v}}{\partial\vecs{\delta\phi}} &= \frac{\partial \vec{v}}{\partial\tensor[_W]{\vec{p}}{_C}} \frac{\partial \tensor[_W]{\vec{p}}{_{C}}}{\partial \vecs{\delta\phi}}\\
\frac{\partial\vec{v}}{\partial\vecs{\delta t}} &= \frac{\partial \vec{v}}{\partial\tensor[_W]{\vec{p}}{_C}} \frac{\partial \tensor[_W]{\vec{p}}{_C}}{\partial \vecs{\delta t}}
\end{align}
Some derivatives:
\begin{align}
\frac{d\norm{\vec{w}}}{d\vec{w}} &= \frac{1}{\norm{\vec{w}}}\vec{w}^T\\
\frac{d\frac{1}{\norm{\vec{w}}}}{d\vec{w}} &= -\frac{1}{\norm{\vec{w}}^3}\vec{w}^T\\
\frac{d\frac{\vec{w}}{\norm{\vec{w}}}}{d\vec{w}} &= \frac{1}{\norm{\vec{w}}}I - \frac{1}{\norm{\vec{w}}^3}\vec{w}\vec{w}^T\notag\\
&= \frac{1}{\norm{\vec{w}}}\left(I - \frac{\vec{w}}{\norm{\vec{w}}}\left(\frac{\vec{w}}{\norm{\vec{w}}}\right)^T\right)
\end{align}
It follows:
\begin{align}
\frac{\partial \vec{v}}{\partial\tensor[_W]{\vec{p}}{_C}} &=
%\frac{1}{\norm{\tensor[_W]{\vec{p}}{_C} - \tensor[_W]{\vec{p}}{_L}}}I
%-\frac{1}{\norm{\tensor[_W]{\vec{p}}{_C} - \tensor[_W]{\vec{p}}{_L}}^3} (\tensor[_W]{\vec{p}}{_C} - \tensor[_W]{\vec{p}}{_L})(\tensor[_W]{\vec{p}}{_C} - \tensor[_W]{\vec{p}}{_L})^T\notag\\
%&=\frac{1}{\norm{\tensor[_W]{\vec{p}}{_C} - \tensor[_W]{\vec{p}}{_L}}}
%\left(
%I - \frac{(\tensor[_W]{\vec{p}}{_C} - \tensor[_W]{\vec{p}}{_L})(\tensor[_W]{\vec{p}}{_C} - \tensor[_W]{\vec{p}}{_L})^T}{\norm{\tensor[_W]{\vec{p}}{_C} - \tensor[_W]{\vec{p}}{_L}}^2}
%\right)\\
%&=
\frac{1}{\norm{\tensor[_W]{\vec{p}}{_C} - \tensor[_W]{\vec{p}}{_L}}}
\left(
I - \vec{v}\vec{v}^T
\right)
\end{align}
\subsubsection{Derivative of camera position w.r.t to $T_{BW}$}
\begin{align}
\tensor[_W]{\vec{p}}{_C} &= -\Exp(-\vecs{\delta\phi}) C_{WB} \left( C_{BC} \tensor[_C]{\vec{t}}{_{CB}} + \left(\tensor[_B]{\vec{t}}{_{BW}} + C_{BW} \vecs{\delta t}\right)\right)\\
&\approx -\left[C_{WB} \left( C_{BC} \tensor[_C]{\vec{t}}{_{CB}} + \left(\tensor[_B]{\vec{t}}{_{BW}} + C_{BW} \vecs{\delta t}\right)\right)\right.\\
&\left.\qquad-\vecs{\delta\phi}^\wedge C_{WB} \left( C_{BC} \tensor[_C]{\vec{t}}{_{CB}} + \left(\tensor[_B]{\vec{t}}{_{BW}} + C_{BW} \vecs{\delta t}\right)\right)\right]\\
&\approx -C_{WB} \left( C_{BC} \tensor[_C]{\vec{t}}{_{CB}} + \left(\tensor[_B]{\vec{t}}{_{BW}} + C_{BW} \vecs{\delta t}\right)\right)\\
&\qquad+\vecs{\delta\phi}^\wedge C_{WB} \left( C_{BC} \tensor[_C]{\vec{t}}{_{CB}} + \left(\tensor[_B]{\vec{t}}{_{BW}} + C_{BW} \vecs{\delta t}\right)\right)\\
%
&\approx -(\tensor[_W]{\vec{t}}{_{CB}} + \tensor[_W]{\vec{t}}{_{BW}} + \vecs{\delta t})
+ \vecs{\delta\phi}^\wedge\left(\tensor[_W]{\vec{t}}{_{CB}} + \tensor[_W]{\vec{t}}{_{BW}} + \vecs{\delta t}\right)\\
&\approx -(\tensor[_W]{\vec{t}}{_{CB}} + \tensor[_W]{\vec{t}}{_{BW}} + \vecs{\delta t})
- \left(\tensor[_W]{\vec{t}}{_{CB}} + \tensor[_W]{\vec{t}}{_{BW}} + \vecs{\delta t}\right)^\wedge\vecs{\delta\phi}\\
%
%&\approx-\left(\tensor[_W]{\vec{t}}{_{CB}}+\tensor[_W]{\vec{t}}{_{CB}^\wedge}\vecs{\delta\phi}\right) - \left(\tensor[_W]{\vec{t}}{_{BW}} + \vecs{\delta t} + \tensor[_W]{\vec{t}}{_{BW}^\wedge}\vecs{\delta\phi} +\vecs{\delta t}^\wedge\vecs{\delta\phi}\right)
\end{align}
\begin{align}
\frac{\partial\tensor[_W]{\vec{p}}{_C}}{\partial\vecs{\delta\phi}} &= -(\tensor[_W]{\vec{t}}{_{CB}} + \tensor[_W]{\vec{t}}{_{BW}})^\wedge\\
\frac{\partial\tensor[_W]{\vec{p}}{_C}}{\partial\vecs{\delta t}} &= -I
\end{align}
\subsubsection{Full jacobian}
\begin{align}
\frac{\partial\varepsilon_2}{\partial\vecs{\delta\phi}} &= \tensor[_C]{\tilde{\vec{n}}}{^T} C_{CB} C_{BW}\frac{\partial \vec{v}}{\partial\vecs{\delta\phi}} - \tensor[_C]{\tilde{\vec{n}}}{^T} C_{CB} C_{BW}\vec{v}^\wedge\\
&= \tensor[_C]{\tilde{\vec{n}}}{^T} C_{CB} C_{BW}\frac{\partial \vec{v}}{\partial\tensor[_W]{\vec{p}}{_C}}
\frac{\partial \tensor[_W]{\vec{p}}{_{C}}}{\partial \vecs{\delta\phi}}
 - \tensor[_C]{\tilde{\vec{n}}}{^T} C_{CB} C_{BW}\vec{v}^\wedge\\
&= \tensor[_W]{\tilde{\vec{n}}}{^T}
\frac{1}{\norm{\tensor[_W]{\vec{p}}{_C} - \tensor[_W]{\vec{p}}{_L}}}
\left(
I - \vec{v}\vec{v}^T
\right)
\frac{\partial \tensor[_W]{\vec{p}}{_{C}}}{\partial \vecs{\delta\phi}}
 - \tensor[_W]{\tilde{\vec{n}}}{^T} \vec{v}^\wedge\\
 &= \frac{1}{\norm{\tensor[_W]{\vec{p}}{_C} - \tensor[_W]{\vec{p}}{_L}}}\tensor[_W]{\tilde{\vec{n}}}{^T}
\left(
I - \vec{v}\vec{v}^T
\right)
\left(-(\tensor[_W]{\vec{t}}{_{CB}} + \tensor[_W]{\vec{t}}{_{BW}})^\wedge\right)
 - \tensor[_W]{\tilde{\vec{n}}}{^T} \vec{v}^\wedge\\
 &=\frac{-1}{\norm{\tensor[_W]{\vec{p}}{_C} - \tensor[_W]{\vec{p}}{_L}}}\tensor[_W]{\tilde{\vec{n}}}{^T}
\left(
I - \vec{v}\vec{v}^T
\right)
\left(\tensor[_W]{\vec{t}}{_{CB}} + \tensor[_W]{\vec{t}}{_{BW}}\right)^\wedge
 - \tensor[_W]{\tilde{\vec{n}}}{^T} \vec{v}^\wedge\\
&=-\tensor[_W]{\tilde{\vec{n}}}{^T}\left(\frac{1}{\norm{\tensor[_W]{\vec{p}}{_C} - \tensor[_W]{\vec{p}}{_L}}}
\left(
I - \vec{v}\vec{v}^T
\right)
\left(\tensor[_W]{\vec{t}}{_{CB}} + \tensor[_W]{\vec{t}}{_{BW}}\right)^\wedge + \vec{v}^\wedge\right)
\end{align}
\begin{align}
\frac{\partial\varepsilon_2}{\partial\vecs{\delta t}} &=
\tensor[_C]{\tilde{\vec{n}}}{^T} C_{CB} C_{BW}\frac{\partial\vec{v}}{\partial \vecs{\delta t}}\\
&=
\tensor[_W]{\tilde{\vec{n}}}{^T}
\frac{\partial \vec{v}}{\partial\tensor[_W]{\vec{p}}{_C}}
\frac{\partial \tensor[_W]{\vec{p}}{_C}}{\partial \vecs{\delta t}}\\
&=
\tensor[_W]{\tilde{\vec{n}}}{^T}
\frac{1}{\norm{\tensor[_W]{\vec{p}}{_C} - \tensor[_W]{\vec{p}}{_L}}}
\left(
I - \vec{v}\vec{v}^T
\right)
\frac{\partial \tensor[_W]{\vec{p}}{_C}}{\partial \vecs{\delta t}}\\
&=
\frac{1}{\norm{\tensor[_W]{\vec{p}}{_C} - \tensor[_W]{\vec{p}}{_L}}}
\tensor[_W]{\tilde{\vec{n}}}{^T}
\left(
I - \vec{v}\vec{v}^T
\right)
(-I)\\
&=\frac{-1}{\norm{\tensor[_W]{\vec{p}}{_C} - \tensor[_W]{\vec{p}}{_L}}}
\tensor[_W]{\tilde{\vec{n}}}{^T}
\left(
I - \vec{v}\vec{v}^T
\right)
\end{align}

\nocite{*}
\bibliographystyle{IEEEtran}
\bibliography{bibliography_lines}

\end{document}


% !TEX root = ./main.tex
\section{General diffusion equation}

Our introduction to diffusion theory begins with the derivation of the partial
differential equation that defines the time evolution of the allele frequency
probability distribution $P(x, t)$. The approach we will consider here is a
discretization of the otherwise continuous probability density function.
Figure~\ref{fig01:diffusion_basics}(B) depicts the idea behind this
discretization where we divide the distributions into bins of some width $\Delta
x$. Since $P(x, t)$ is a \textit{probability density function}, i.e., a
probability function for continuous random variables, evaluating this density
for any particular value of the allele frequency returns zero. Only intervals of
the form $P(x - \delta x \leq x \leq x + \delta x)$ have meaningful
probabilities. This is because $P(x, t)$ has units of inverse $x$ (in our case,
inverse allele frequency), but probability has no dimensions. So by computing
the interval via an integration of the form
\begin{equation}
    P(x - \delta x \leq x \leq x + \delta x) =
    \int_{x - \delta x}^{x + \delta x} dx \; P(x, t),
\end{equation}
we multiply the density $P(x, t)$ (units of inverse allele frequency) with the
infinitesimal width $dx$ (units of allele frequency), recovering a dimensionless
quantity. Our discretization of this distribution then takes the form
\begin{equation}
    p(x, t) \equiv P(x - \frac{\Delta x}{2} \leq x \leq x + \frac{\Delta x}{2})
    \approx \overbrace{P(x, t)}^{\text{height}}
    \overbrace{\Delta x}^{\text{width}},
\label{eq:mass_vs_density}
\end{equation}
where we define $p(x, t)$ to be a \textit{probability mass function}, i.e., a
probability function for discrete random variables. What we are doing is
approximating the integral as a rectangle of height $P(x, t)$ and a width $dx$.
The smaller $dx$ the more accurate our approximation gets.

Before jumping into the modeling of each of the individual evolutionary forces,
we will begin our analysis with an abstract transition probability that captures
the effect of all forces all together. This will allow us to gain intuition on
how to implement each of the particular forces in the following section. Let us
define a probability transition rate $\phi(x \mid x')$. The way to think about
this function is that, by taking into account all evolutionary forces involved,
$\phi(x \mid x')$ tells us what is the probability of transition from an allele
frequency $x'$ to a frequency $x$ per unit time. Given that $\phi(x \mid x')$ is
a rate (units of inverse time), we need to multiply is by a small window of time
$\Delta t$ in order to obtain a transition probability. For example, if we want
to compute what is the probability of transitioning from an allele frequency $x$
to an allele frequency $x + \Delta x$ in a small time window $\Delta t$, we must
compute
\begin{equation}
    P_{\text{transition}}(x \rightarrow x + \Delta x; \Delta t) =
    \phi(x + \Delta x \mid x) \Delta t.
\end{equation}
With this in hand let's focus our attention to a particular frequency value $x$.
Figure~\ref{fig01:diffusion_basics}(C) shows the checks and balances we need to
consider for this allele frequency. What the schematic shows is that in a small
time window $\Delta t$ the ``amount of probability'' at $x$ can change due to
the outflow of probability mass from $x$ to the two contiguous bins $x + \Delta
x$ and $x - \Delta x$, and due to the inflow from those same two bins. We are
assuming that $\Delta t$ is sufficiently small such that we only need to
consider transitions from the nearest neighbors. Writing down this check and
balance equation we obtain
\begin{equation}
\begin{split}
    p(x, t + \Delta t) &= p(x, t)
    + \overbrace{p(x - \Delta x, t) \phi(x \mid x - \Delta x)\Delta t}
    ^{\text{inflow from the left}}
    + \overbrace{p(x + \Delta x, t) \phi(x \mid x + \Delta x)\Delta t}
    ^{\text{inflow from the right}}\\
    &- \overbrace{p(x, t) \phi(x - \Delta x \mid x) \Delta t}
    ^{\text{outflow to the left}}
    - \overbrace{p(x, t) \phi(x + \Delta x \mid x) \Delta t}
    ^{\text{outflow to the right}}.
\end{split}
\label{eq:inflow_outflow_diffusion}
\end{equation}
To make further progress, we need to rewrite the transition probability in terms
of the jump size $r \equiv x - x'$. In other words, instead of defining the
funciton with the initial and final position, we define the function with the
initial position and the size of the displacement. This is
\begin{equation}
    \phi(x \mid x') = \phi(x'; r).
\end{equation}
Using this allows us to rewrite \ref{eq:inflow_outflow_diffusion} as
\begin{equation}
\begin{split}
    p(x, t + \Delta t) = &p(x, t)
    + p(x - \Delta x, t) \phi(x - \Delta x; \Delta x)\Delta t
    + p(x + \Delta x, t) \phi(x + \Delta x; -\Delta x)\Delta t\\
    &- p(x, t) \phi(x; -\Delta x) \Delta t
    - p(x, t) \phi(x; \Delta x) \Delta t.
\end{split}
\label{eq:jump_diffusion}
\end{equation}
This equation needs a few rearrangements. First we send the first term on the
right hand side to the left, and divide both sides by $\Delta t$. This results
in
\begin{equation}
\begin{split}
    \frac{p(x, t + \Delta t) - p(x, t)}{\Delta t} &=
    p(x - \Delta x, t) \phi(x - \Delta x; -\Delta x)
    + p(x + \Delta x, t) \phi(x + \Delta x; \Delta x)\\
    &- p(x, t) \phi(x; -\Delta x)
    - p(x, t) \phi(x; \Delta x).
\end{split}
\end{equation}
Taking the limit $\Delta t \rightarrow 0$ allows us to rewrite
\begin{equation}
\begin{split}
    \frac{d p(x, t)}{dt} &=
    p(x - \Delta x, t) \phi(x - \Delta x; -\Delta x)
    + p(x + \Delta x, t) \phi(x + \Delta x; \Delta x)\\
    &- p(x, t) \phi(x; -\Delta x)
    - p(x, t) \phi(x; \Delta x).
\end{split}
\label{eq:master_eq_jump}
\end{equation}
This equation that describes the time evolution of the probability mass function
is usually called a master equation. As written right now,
Eq.~\ref{eq:master_eq_jump} depends on the unknown function $\phi(x; r)$ that
involves the influence of all evolutionary forces. The next manipulation of the
equation involves a Taylor expansion of the terms in Eq.~\ref{eq:master_eq_jump}
involving $x \pm \Delta x$ around $x$. As written right now we cannot Taylor
expand $p(x, t)$ since a probability mass function can only evaluated for the
\textit{discrete} values the random variable can take. It is at this point that
we use Eq.~\ref{eq:mass_vs_density} to convert back to the probability density
function. Substituting this in Eq.~\ref{eq:master_eq_jump} doesn't have any
effect given that the extra $\Delta x$ term that comes along with converting
from a mass to a density cancels from both sides, resulting in
\begin{equation}
\begin{split}
    \frac{d P(x, t)}{dt} &=
    P(x - \Delta x, t) \phi(x - \Delta x; -\Delta x)
    + P(x + \Delta x, t) \phi(x + \Delta x; \Delta x)\\
    &- P(x, t) \phi(x; -\Delta x)
    - P(x, t) \phi(x; \Delta x).
\end{split}
\label{eq:master_eq_density}
\end{equation}
Now we can properly Taylor expand the terms involving $x \pm \Delta x$. This
expansion takes the form
\begin{equation}
\begin{split}
    P(x \pm \Delta x, t) \phi(x \pm \Delta x; \mp \Delta x) &\approx
    P(x, t)\phi(x; \mp \Delta x)\\
    &+ \frac{d}{dx}
    \left[ P(x, t) \phi(x; \mp \Delta x)  \right] (\pm \Delta x)\\
    &+ \frac{1}{2} \frac{d^2}{d x^2}
    \left[ P(x, t) \phi(x; \mp \Delta x)  \right] (\pm \Delta x)^2.\\
\end{split}
\label{eq:taylor_expand_jump}
\end{equation}
Substituting Eq.~\ref{eq:taylor_expand_jump} into Eq.~\ref{eq:master_eq_density}
results in
\begin{equation}
\begin{split}
    \frac{\partial P(x, t)}{\partial t} &=
    P(x, t)\phi(x; - \Delta x)\\
    &+ \frac{\partial}{\partial x}
    \left[ P(x, t) \phi(x; - \Delta x)  \right] (\Delta x)\\
    &+ \frac{1}{2} \frac{\partial^2}{\partial x^2}
    \left[ P(x, t) \phi(x; - \Delta x) \right]   (\Delta x)^2\\
    &+ P(x, t) \phi(x; \Delta x)\\
    &+ \frac{\partial}{\partial x}
    \left[ P(x, t) \phi(x; \Delta x)  \right] (- \Delta x)\\
    &+ \frac{1}{2} \frac{\partial ^2}{\partial x^2}
    \left[ P(x, t) \phi(x; \Delta x)  \right] (- \Delta x)^2\\
    &- P(x, t) \phi(x; -\Delta x)
    - P(x, t) \phi(x; \Delta x).
\end{split}
\end{equation}
This equation might look quite messy, but it can be enormously simplified by
cancelling terms and using the fact that derivatives are linear operators. Doing
so results in
\begin{equation}
    \frac{\partial P(x, t)}{\partial t} =
    \frac{\partial}{\partial x}
    \left[ P(x, t)
    \left(\phi(x; - \Delta x) - \phi(x; \Delta x) \right) (\Delta x)
    \right]
    + \frac{1}{2} \frac{\partial^2}{\partial x^2}
    \left[ P(x, t)
    \left(\phi(x; - \Delta x) - \phi(x; \Delta x)\right) (\Delta x)^2 \right].
\label{eq:PDE_diffusion}
\end{equation}

Let's look at the terms involving the transition probability. The first term on
the right hand side of the equation involves a term $\left(\phi(x; - \Delta x) -
\phi(x; \Delta x) \right) (\Delta x)$. This is nothing else than the mean
displacement. The way to see this is as follows: recall that in our discrete
approach for sufficiently small $\Delta t$ we only really have to consider the
three contiguous bins $x$ and $x \pm \Delta x$. To be consistent with the
notation in the population genetics literature, let us define $M(x)\Delta t$ as
the mean change in allele frequency during a small time window $\Delta t$. This
is analogous to the definition of $\phi(x \mid x')$ in which only the product of
$\phi(x \mid x')\Delta t$ satisfies the dimensionless nature of probabilities.
In other words, we can think of $M(x)$ as the mean rate with which the allele
frequency changes. The mean change in allele frequency is then computed as
\begin{equation}
M(x)\Delta t = \left\langle \Delta x \mid x \right\rangle_{\Delta x}\Delta t,
\end{equation}
where $\langle \cdot \rangle_{\Delta x}$ means to take the average over possible
jumps in allele frequency. What this equation says is that $M(x)\Delta t$
represents the expected shift in allele frequency on a small time window $\Delta
t$ given that the current allele frequency is $x$. Computing this average
displacement for our discrete case has only three options: a jump of size
$\Delta x$, a jump of size $- \Delta x$ and no jump. The average jump is then
given by.
\begin{equation}
    M(x)\Delta t =
    \overbrace{(-\Delta x) \phi(x, - \Delta x)\Delta t}
    ^{\text{jump from $x$ to $x - \Delta x$}}
    + \overbrace{(\Delta x) \phi(x, + \Delta x)\Delta t}
    ^{\text{jump from $x$ to $x _ \Delta x$}}
    + \overbrace{(0) (1 - \phi(x, + \Delta x) - \phi(x, - \Delta x)\Delta t}
    ^{\text{no jump}}
\label{eq:Mx}
\end{equation}
From this we can easily see that
\begin{equation}
    M(x) = \left(\phi(x; + \Delta x) - \phi(x; - \Delta x) \right) (\Delta x).
\end{equation}
Notice this the change in the order in the terms compared with the first term in
Eq.~\ref{eq:PDE_diffusion}. This change of order will be carried as a minus sign
in our final result. In the same way let us define $V(x)\Delta t$ as the
variance in displacement during a small time window. This is written as
\begin{equation}
    V(x)\Delta t = \left[\langle (\Delta x)^2 \mid x \rangle_{\Delta x}
    - \left(\langle \Delta x \mid x \rangle_{\Delta x}\right)^2\right]\Delta t.
\end{equation}
As we showed in Eq.~\ref{eq:Mx}, the mean displacement scales with $\Delta x$.
This means that the second term on the right hand side of
Eq.~\ref{eq:variance_displacement} scales with $(\Delta x)^2$, which for very
small $\Delta x$ we will consider as negligible. With this simplification, the
variance in displacement during a small time window $\Delta t$ is then simply
given by
\begin{equation}
    V(x)\Delta t = \langle (\Delta x)^2 \mid x \rangle_{\Delta x} \Delta t.
\label{eq:variance_displacement}
\end{equation}
This can be computed again considering the three possible jumps as
\begin{equation}
    V(x)\Delta t =
    \overbrace{(\Delta x)^2 \phi(x; \Delta x)\Delta t}
    ^{\text{jump from $x$ to $x + \Delta x$}}
    + \overbrace{(-\Delta x)^2 \phi(x; \Delta x)\Delta t}
    ^{\text{jump from $x$ to $x - \Delta x$}}
    + \overbrace{(0)^2 (1 - \phi(x, + \Delta x) - \phi(x, - \Delta x)\Delta t)
    \Delta t}
    ^{\text{no jump}}.
\end{equation}
From this we can see that
\begin{equation}
    V(x) = \left(\phi(x; + \Delta x) - \phi(x; - \Delta x)\right) (\Delta x)^2.
\label{eq:Vx}
\end{equation}
Substituting Eqs.~\ref{eq:Mx}~and~\ref{eq:Vx} into Eq.~\ref{eq:PDE_diffusion}
results in the diffusion-advection equation for allele frequency we were after
\begin{equation}
    \frac{\partial P(x, t)}{\partial t} =
    - \frac{\partial}{\partial x}\left[ P(x, t) M(x) \right]
    + \frac{1}{2}\frac{\partial^2}{\partial x^2}\left[ P(x, t) V(x) \right].
\end{equation}
The reason for writing this general Fokker-Planck equation in terms of the mean
displacement rate $M(x)$ and the variance in the displacement rate $V(x)$ is
that the evolutionary are assigned to each of these functions. As we will see in
the next section, selection and mutation, being deterministic evolutionary
forces belong to the advection term, and therefore they define $M(x)$, while
genetic drift, a stochastic force, defines the term $V(x)$.


\section*{Exercise 26.2-9}
We are given two flows, $f$ and $f'$ and compute the augmented flow $f\uparrow f'$.

\textbf{Does the augmented flow satisfy the flow conservation property?}
\\
Yes!
\\
\\
For any vertice $u\in V - \left\{s,t\right\}$, one of the following cases apply:
\\
\textit{Neither $f$ nor $f'$ includes $u$.}
\\
There is no flow, so $f(u,v)=f(v,u)$, where $v\in V$.
\\
\\
\textit{$f$ and/or $f'$ includes $u$.}
\\
It is given, that $f$ and $f'$ are ordinary flows, so the flow conservation property must hold for each of these; all flow into a vertice will also flow out. Regardless of whether $u$ is included in one or two flows, all flow into $u$ will also come out.
\\
\\
\textbf{Does the augmented flow satisfy the capacity constraint?}
\\
No!
\\
\\
Consider the following case:
\\
The edge $(u,v)$ has capacity $c(u,v)=2$. The edge $(u,v)$ is part of both flows $f$ and $f'$, where $f(u,v)=2$ and $f'(u,v)=2$.
\\
Hence, $f(u,v)+f'(u,v)=2+2=4>c(u,v)$.


\documentclass[letterpaper]{article}

\usepackage{fullpage}
\usepackage{nopageno}
\usepackage{amsmath}
\usepackage{amssymb}
\allowdisplaybreaks

\newcommand{\abs}[1]{\left\lvert #1 \right\rvert}

\begin{document}
\title{Notes}
\date{November 5, 2014}
\maketitle
\section*{4.2 2a,8,9}
\subsection*{9}
show that the remainder when $f(x)$ is divided by $(x-a)^2$ is $f'(a)(x-a)+f(a)$

$f(x)=(x-a)^2q(x)+r(x)$ and $\deg r<2$ $r(x)=\alpha x+\beta$.
$f(a)=r(a)=\alpha a+\beta$.
$f'(x)=2(x-a)q(x)+(x-a)^2q'(x)+\alpha$
$f'(a)=\alpha$

$f(a)=f'(a)a+\beta\to\beta=f(a)-af'(a)$.o

$r(x)=f'(a)x+f(a)-af'(a)=f'(a)(x-a)+f(a)$
\section*{proposition}
let$I\subseteq K[x]$ such that
\begin{enumerate}
\item
$I$ contains a non-zero polynomial
\item
$f(x),g(x)\in I\Rightarrow f(x)+g(x)\in I$
\item
$f(x)\in I, g(x)\in K[x]\Rightarrow f(x)g(x)\in I$
\end{enumerate}
this is the ideal of $K[x]$
let $d(x)\in I$ of minimal degree. then $I=\{a(x)f(x):f(x)\in K[x]\}$

\subsubsection*{proof}
let $h(x)\in I$ write $h(x)=d(x)q(x)+r(x)$ with $r(x)=0$ or $\deg r>\deg d$

then $r(x)=h(x)+d(x)[-q(x)]\in I$ by 2 above. by choice of $d(x)$ we have $r(x)=0$ and so $h(x)\in I$

\section*{def}
$f(x),g(x)\in K[x]$ where $K$ is a field. a monic polynomial $a(x)\in K[x]$ is called gcd of $f(x),g(x)$ if
\begin{enumerate}
\item
$a(x)|f(x)$ and $a(x)|g(x)$
\item
if $t(x)|f(x)$ and $t(x)|g(x)$ then $t(x)|a(x)$
\end{enumerate}

monic means that the leading coefficient is 1

\section*{thm}
if we have $f(x),g(x)$ non-zero, then $\exists\gcd(f(x),g(x))$ and $\gcd(f(x),g(x))$ can be expressed in the form $\alpha(x)f(x)+\beta(x)g(x)$.
\subsubsection*{proof}

let ideal $I=\{\alpha(x)f(x)+\beta(x)g(x)\}$. Check that $I$ satisfies all conditions of earlier proposition.

let $d(x)\in I$ of minimal degree and without loss of generality assume $d(x)$ is monic. we can do this because multiplying by a constant is multiplying by a polynomial, so it's still in $I$.

claim $d(x)$ is a $\gcd$ of $f(x),g(x)$

$I=\{d(x)h(x):h(x)\in K[x]\}$ in particular $d(x)f(x)$ and $d(x)g(x)$ are both in $I$. now if $t(x)|f(x)$ and $t(x)|g(x)$. $\exists\alpha(x),\beta(x)$ such that $d(x)=\alpha(x)f(x)+\beta(x)g(x)$. then $t(x)|d(x)$.

\section*{thm}
the gcd is unique. lets assume that $d_1(x)$ and $d_2(x)$ are gcd of $f(x)$ and $g(x)$. $d_2(x)|f(x)$ and $d_2(x)|g(x)$. $d_1$ is gcd so $d_1|d_2$ and $d_1(x)|f(x)$ and $d_1(x)|g(x)$ so because $d_2$ is gcd then $d_2|d_1$. we said our gcd was monic.

$d_1(x)=d_2(x)\alpha_1(x)$ and $d_2(x)=d_1(x)\alpha_2(x)$. now $d_1(x)\alpha_1(x)\alpha_2(x)\to d_2=d_1(x)\alpha_1(x)\alpha_2(x)$

\section*{thm}
if $p(x)|f(x)g(x)$ and $\gcd(p(x),f(x))=1$ then $p(x)|g(x)$.

\section*{def}
$f(x)\in K[x]$. we say that $f(x)$ is irreducible over the field $K$ if $f(x)$ cannot be factored into a product of two polynomials of degree lower than $\deg f(x)$.
\subsection*{example}
$x^2+1$ is irreducible over $\mathbb{R}$
\subsection*{example}
$x^2+1\in \mathbb{C}[x]$ is reducible (not irreducible) over $\mathbb{C}$

\section*{prop}
$f(x)\in K[x]$, $\deg f(x)$ is $2$ or $3$ and $f(x)$ has no roots in $K$. then $f(x)$ is irreducible.

\subsubsection*{proof}
we choose $\deg 2,3$ because at least one of the factors is $\deg 1$

we assume the factors exist. then $f(x)=(\alpha x+\beta)h(x)$ and $f(-\beta\alpha^{-1})=0$ and it has a root.

\section*{thm}
every non-zero polynomial in  $K[x]$ can be written uniquely as a product of irreducible polynomials.

proof is inductive argument

\section*{def}
$f(x)\in K[x], c\in K$ we say that $c$ is a root of multiplicity $m$ of $f(x)$ if $(x-c)^m$ divides $f(x)$ and $(x-c)^{m+1}\not| f(x)$

\section*{prop}
$f(x)\in \mathbb{R}[x]$, $\deg f(x)\ge 1$ then $f(x)$ has no repeatable factors iff the $gcd$ of $f(x)$ and $f'(x)$ is one
\end{document}


\section{Updates 12/16/2019}%
\label{sec:updates2019_12_16}
All of the following results were trained using Horovod on COOLEY for
$1\times10^5$ training steps ($2\times$  previous training length).
%

As a measure of how well the trained sampler performs, we can introduce the
\emph{tunneling rate} ($\gamma$), as
%
\begin{equation}
  \gamma = \frac{1}{M}\sum_{m=1}^{M} |\mathcal{Q}^{(m+1)} - \mathcal{Q}^{(m)}|
\end{equation}
%
where $\mathcal{Q} \in \mathbb{Z}$ is the topological charge, and $M$ denotes
the number of accept/reject steps the sampler was ran for.
%
This tells us the amount by which we can expect the topological charge to
change per step, and is a useful metric for measuring how well the sampler is
able to explore different topological sectors.
%


\section{A plethora of products}
\begin{remark}
Please note that these notes might be absolute bullshit, because I came back today from my flight at 8 am.
\end{remark}
Recall that we have the Kronecker pairing $\langle ,\rangle: H^p(X)\otimes H_p(X)\to R$, which obviously isn't natural because $ H^p$ is contravariant while homology isn't.

Consider the following. Given $f:X\to Y$, and $b\in H^p(Y)$ and $x\in H_p(X)$, how does $\langle f^\ast b,x\rangle$ relate to $\langle b,f_\ast x\rangle$?
\begin{claim}
$$\langle f^\ast b,x\rangle=\langle b,f_\ast x\rangle$$
\end{claim}
\begin{proof}
Easy! I find it useful to write out diagrams of where things are. We're gonna work on the chain model.
\begin{equation*}
	\xymatrix{
	\Hom(S_p(X),R)\otimes S_p(X)\ar[r]^{\langle,\rangle} & R\\
	\Hom(S_p(Y),R)\otimes S_p(X)\ar[r]^{1\otimes f_\ast}\ar[u]^{f^\ast\otimes 1} & \Hom(S_p(Y),R)\otimes S_p(Y)\ar[u]^{\langle,\rangle}
	}
\end{equation*}
The top line is what gives the Kronecker pairing. Note that $f^\ast$ means contravariant and $f_\ast$ means covariant. This diagram commuting \emph{is} the statement we want to prove. Let's see. Suppose $[\beta]=b$ and $[\xi]=x$. Then from the bottom left, going to the right and then the top is $\beta\otimes\xi\mapsto\beta\otimes f_\ast(\xi)\mapsto\beta(f_\ast\xi)$. The other way is $\beta\otimes\xi\mapsto f^\ast(\beta)\otimes\xi=(\beta\circ f)\otimes\xi\mapsto(\beta\circ f)(\xi)$. This is exactly $\beta(f_\ast\xi)$, because, oh, that's just how composition works.
\end{proof}
There's another product around. We called this $\mu$ I think, where $\mu:H(C_\bullet)\otimes H(D_\bullet)\to H(C_\bullet\otimes D_\bullet)$ given by $[c]\otimes [d]\mapsto[c\otimes d]$. I'm secretly using this in the above proof.

We also have the cross product(s!) $\times: H_p(X)\otimes H_q(Y)\to H_{p+q}(X\times Y)$ and $\times: H^p(X)\otimes H^q(Y)\to H^{p+q}(X\times Y)$. You should think of this as fishy because both maps are in the same direction -- but this is OK because we're using different things to make these constructions. Still, they're related:
\begin{theorem}
Let $a\in H^p(X),b\in H^p(Y),x\in H_p(X), y\in H_q(Y)$. Then:
\begin{equation*}
\langle a\times b,x\times y\rangle=(-1)^{|x|\cdot |b|}\langle a,x\rangle\langle b,y\rangle
\end{equation*}
\end{theorem}
This isn't just idle -- although idle things are a great thing to do!
\begin{proof}
Say $[\alpha]=a,[\beta]=b,[\xi]=x,[\eta]=y$. Then recall that $\langle a\times b,x\times y\rangle$ comes from $(\alpha\times\beta)(\sigma)=(-1)^{pq}\alpha(\sigma_1\circ\alpha_p)\beta(\sigma_2\circ\omega_q)$ where $\sigma:\Delta^{p+q}\to X\times Y$. There's two uses of the symbol $\alpha$, and there'll be a third one in a minute, but they'll all have subscripts, so I hope you'll forgive me.

Recall also the ($(p,q)$th component of the) Alexander-Whitney map $\alpha_{X,Y}:S_{p+q}(X\times Y)\to S_p(X)\otimes S_q(Y)$. We have a big diagram:
\begin{equation*}
\xymatrix{
	S_p(X)\otimes S_q(Y)\ar[r]^{\times}\ar[dr]^{1\sim} & S_{p+q}(X\times Y)\ar[d]^{\alpha_{X,Y}}\ar[dr]^{\alpha\times\beta} & \\
	& S_p(X)\otimes S_p(Y)\ar[r]_{\alpha\cdot\beta} & R
}
\end{equation*}
Where $\alpha\cdot\beta:(\xi\otimes\eta)\mapsto(-1)^{pq}\alpha(\xi)\cdot\beta(\xi)$. Now, the diagonal arrow $S_p(X)\otimes S_q(Y)\to S_p(X)\otimes S_p(Y)$ is unique up to chain homotopy, and is homotopic to the identity -- this is what the method of acyclic models tells me. (See the statement of the Eilenberg-Zilber theorem above.)

Thus we find that $\alpha_{X,Y}(\xi\times\eta)=\xi\otimes\eta+(dh+hd)(\xi\otimes\eta)$ for some chain homotopy $h$. I think we're really down now, because $\xi$ and $\eta$ are both cycles, and hence $d$ will kill them (wait it seems like it only kills $\eta$???). So $\alpha_{X,Y}(\xi\times\eta)=\xi\otimes\eta$. Now, $\alpha\cdot\beta$ is a cocycle (check!). When I apply $\alpha$ it kills the $dh$ factor (what???), therefore $(\alpha\cdot\beta)\alpha_{X,Y}(\xi\times \eta)=(\alpha\cdot\beta)(\xi\otimes\eta)$.
\end{proof}
All because of the magic of acyclic models.

Let's now try to prove a K\"unneth theorem for $ H^\ast$. Let $R=k$ be a field (eg $\FF_p,\QQ$) that's our coefficient. Then we have $ H_\ast(X)\otimes_k H_\ast(Y)\cong H_\ast(X\times Y)$. Also, this map $ H^p(X)\otimes H_p(X)\to k$ has an adjoint $ H^p(X)\to \Hom_k( H_p(X),k)=: H_p(X)^\vee$, which is an isomorphism because $\Ext$ vanishes over a field.
\begin{theorem}
Let $k$ be a field. Assume that $ H_p(X)$ is finite-dimensional for all $p$. Then $ H^\ast(X)\otimes H^\ast(Y)\cong H^\ast(X\times Y)$.
\end{theorem}
\begin{proof}
We have:
\begin{equation*}
\xymatrix{
	 H^\ast(X)\otimes H^\ast(Y)\ar[r]^{\times}\ar[d]^\cong & H^\ast(X\times Y)\ar[d]^\cong\\
	 H_\ast(X)\otimes H_\ast(Y)^\vee\ar[d]^{\zeta} & H_\ast(X\times Y)^\vee\ar[dl]^\cong\\
	\left( H_\ast(X)\otimes H_\ast(Y)\right)^\vee
}
\end{equation*}
Where $\zeta:\alpha\otimes\beta\mapsto(x\otimes y\mapsto \pm\alpha(x)\beta(y))$. The theorem we proved above implies that this diagram commutes.

In general, I might have two (graded) vector spaces $U,V$, and consider $U^\vee\otimes V^\vee\to(U\otimes V)^\vee$ by the above formula. Well, $(U\otimes V)^\vee=\Hom_k(U\otimes V,k)=\Hom_k(U,V^\vee)$. Thus I get a map $U^\vee\otimes V^\vee\to\Hom_k(U,V^\vee)$. This map is an isomorphism when $U$ or $V$ is finite dimensional. I also have $\widehat{\alpha}:U^\vee\otimes W\to \Hom(U,W)$ via $\alpha\otimes w\mapsto(w\mapsto\alpha(u)w)$. And that's the map we have in mind. The image of $\widehat{\alpha}$ consists of finite rank homomorphisms because a general tensor is a finite sum. This is therefore an isomorphism if $U$ or $W$ is finite dimensional.

This shows that the map $\zeta$ above is an isomorphism if $ H_\ast(X)$ or $ H_\ast(Y)$ is finite-dimensional. We're done by commutativity.
\end{proof}
We saw before that $\times$ is an algebra map! So this is an isomorphism of algebras.

There are more products around. There is a map $ H^p(Y)\otimes H^q(X,A)\to H^{p+q}(Y\times X,Y\times A)$. Constructing this is on your homework. You can see how this comes about. This comes from the map on the chain level, and it comes from looking at the cochains, and you're going to get a map (???). Anyway. Suppose $Y=X$. Then I get $\cup: H^\ast(X)\otimes H^\ast(X,A)\to H^\ast(X\times X,X\times A)\xrightarrow{\Delta^\ast} H^\ast(X,A)$ where $\Delta:(X,A)\to (X\times X,X\times A)$. This ``relative cup product'' makes $ H^\ast(X,A)$ into a graded module over $ H^\ast(X)$. This is \emph{not} a ring -- it doesn't have a unit, for example -- but it is a module. Also the lexseq is a sequence of $ H^\ast(X)$-modules. I'm just making statements here.

I want to introduce you to \emph{one more} product, which we'll talk more about, and forms the foundation of Poincar\'{e} duality. This is the cap product. What can I do with $S^p(X)\otimes S^n(X)$? Well, I get big map:
\begin{equation*}
S^p(X)\otimes S_n(X)\xrightarrow{1\times (\alpha_{X,X}\circ \Delta_\ast)} S^p(X)\otimes S_p(X)\otimes S_{n-p}(X)\xrightarrow{\langle -,-\rangle\otimes 1}S_{n-p}(X)
\end{equation*}
This composite participates in a chain map. This induces a map in homology $\cap: H^p(X)\otimes H_n(X)\to H_{n-p}(X)$ that comes from $\mu$. This is a pretty interesting map.
\begin{lemma}
$(\alpha\cup\beta)\cap x=\alpha\cap(\beta\cap x)$ and $1\cap x=x$.
\end{lemma}
\begin{proof}
Easy to check from the definition.
\end{proof}
This makes $ H_\ast(X)$ into a module over $ H^\ast(X)$. These are not hard things to check. There's a lot of structure, and the fact that $ H^\ast(X)$ forms an algebra is a good thing. Notice how the dimensions work. People made a mistake before, and they should have indexed cohomology with negative numbers, so that $\cap: H^p(X)\otimes H_n(X)\to H_{n-p}(X)$ makes sense. A cochain complex with positive grading is the same as a chain complex with negative grading.

There's also slant products (two of them!). Maybe we won't talk about them. We will check a few things about cap products, and then we'll go into Poincar\'{e} duality. We can prove nice theorems then.