\subsection{Model optimization}
\label{sec:optimization}

Our objective is to find the best clustering, or equivalently, the indicator vectors $\{\bm{z}_r\}_{r=1}^k$ that
minimizes the penalty function $\mathcal{J}()$.
Note that $\mathcal{J}()$ is a function of $\bml$ and $\bmo$ (which are the weights of meta-paths and object
attributes), whose values need to be learned as well.
\schain\ learns these parameters using an iterative mutual update approach.
Each iteration consists of two steps. First, given $\bml$ and $\bmo$, we find the optimal clustering
$\{\bm{z}_r\}_{r=1}^k$. Second, given $\{\bm{z}_r\}_{r=1}^k$, we
find the optimal $\bml$ and $\bmo$.
\schain\ iterates until the change in the penalty is smaller than a threshold $\epsilon$ or
a fixed number of iterations have been executed.
Next, we show how the two update steps are performed.

\subsubsection{Finding the optimal $\{${\boldmath $z$}$_r\}_{r=1}^k$ given {\boldmath $\lambda$} and \boldmath $\omega$}

For fixed values of $\bml$ and $\bmo$, $\mathcal{J}()$ is a function of $\bmz$.
We define a matrix $\tilde{Z}$, where its $r$-th column
$\tilde{Z}_{\cdot r}$
equals $D^{\frac{1}{2}}\bm{z}_r/(\bm{z}_r^TD\bm{z}_r)^{\frac{1}{2}}$.
Note that since $\tilde{Z}^T\tilde{Z} = I_k$, where $I_k$ is the $k \times k$ identity matrix,
$\tilde{Z}$ is an orthonormal matrix.
For fixed values of $\bml$ and $\bmo$, minimizing $\mathcal{J}()$ is equivalent to minimizing:
%\begin{small}
\begin{equation}
\label{eq:obj:trans2}
\begin{split}
\mathcal{J}'(\tilde{Z}) & = \mathit{trace}(\tilde{Z}^TD^{-\frac{1}{2}}(D-S-W\circ S)D^{-\frac{1}{2}}\tilde{Z}), \\
%& = \mathit{trace}(\tilde{Z}^TD^{-\frac{1}{2}}DD^{-\frac{1}{2}}\tilde{Z}-\tilde{Z}^TD^{-\frac{1}{2}}(S+ W\circ S)D^{-\frac{1}{2}}\tilde{Z}) \\
& = \mathit{trace}(I_k-\tilde{Z}^TD^{-\frac{1}{2}}(S+W\circ S)D^{-\frac{1}{2}}\tilde{Z}).
\end{split}
\end{equation}
%\end{small}
Since $trace(I_k)$ is a constant, the above is equivalent to solving the following trace maximization problem:
\begin{equation}
\begin{split}
\label{eq:max}
& \max_{\tilde{Z}^T\tilde{Z} = I_k}\mathit{trace}(\tilde{Z}^TD^{-\frac{1}{2}}(S+W\circ S)D^{-\frac{1}{2}}\tilde{Z}).  \\
\end{split}
\end{equation}
Since $\tilde{Z}$ is a rigorous cluster indicator matrix, the optimization problem is NP-hard~\cite{DBLP:dblp_conf/icml/LongZWY06}.
To address this issue, we allow real relaxation to $\tilde{Z}$ so that its entries can assume real values. Then,
according to the Ky-Fan theorem~\cite{bhatia1997matrix},
the maximization problem (\ref{eq:max}) has a closed-form solution that corresponds to the subspace spanned
by the top $k$ eigenvectors of $K = D^{-\frac{1}{2}}(S+W\circ S)D^{-\frac{1}{2}}$.
Since $\tilde{Z}_{\cdot r} = D^{\frac{1}{2}}\bm{z}_r/(\bm{z}_r^TD\bm{z}_r)^{\frac{1}{2}}$,
we need to transform each $\tilde{Z}_{\cdot r}$ back to a real-relaxed $\bm z_r$.
We first calculate
$U = D^{-\frac{1}{2}}\tilde{Z}$ and then
normalize it by column.
Each column in $U$ is a real-relaxed $\bm z_r$.
Finally, with the real relaxation, entries in $U$ take on fractional values, so the clustering is not
definite. To derive a hard clustering,
we treat each row in $U$ as a feature vector of an object.
After row normalization on $U$, we adopt $k$-means to cluster objects.
%a postprocessing step is required and we adopt $k$-means to convert $\tilde{Z}$ to $\{\bm {z}_r\}_{r=1}^k$.
%we take the cluster membership values of each object (derivable from $\bmz$)
%as features of objects and cluster the objects using $k$-means based on these cluster membership features.

\subsubsection{Finding the optimal {\boldmath $\lambda$} and {\boldmath $\omega$} given $\{${\boldmath $z$}$_r\}_{r=1}^k$}
%After clusters are derived, they can be used to supervise the weight learning of meta paths and attributes,
%because different meta paths and attributes play different roles in determining the formation of these clusters.
%Therefore, we can optimize $\bm \lambda$ and $\bm \omega$ based on the results of $\{\bm z_i\}_{i=1}^k$.

For fixed $\{\bm z_r\}_{r=1}^k$, $\mathcal{J}()$ is a function of $\bml$ and $\bmo$.
We rewrite Eq.~\ref{eq:obj:trans:reg} as:
\begin{small}
\begin{equation}
\label{eq:obj:trans3}
\begin{split}
\mathcal{J}(\bm \lambda, \bm \omega) & =
%\sum_{i=1}^k\frac{\bm{z}_i^T(D-S- \mathcal{W} \circ S)\bm{z}_i}{\bm{z}_i^TD\bm{z}_i} + \gamma(||\bm\lambda||^2+||\bm \omega||^2) \\
%& =
\sum_{r=1}^k\frac{\bm{z}_r^TD\bm{z}_r-\bm{z}_r^T(S+ \mathcal{W} \circ S)\bm{z}_r}{\bm{z}_r^TD\bm{z}_r} + \gamma(||\bm\lambda||^2+||\bm \omega||^2), \\
& = k - \sum_{r=1}^k\frac{\bm{z}_r^T(S+ \mathcal{W} \circ S)\bm{z}_r}{\bm{z}_r^TD\bm{z}_r} + \gamma(||\bm\lambda||^2+||\bm \omega||^2). \\
%& + \gamma(\|\bm \lambda\|^2 + \sum_{c=1}^k \|A_c\|_F^2),
\end{split}
\end{equation}
\end{small}
Since $k$ is a constant, minimizing $\mathcal{J}(\bml, \bmo)$ is equivalent to maximizing:
\begin{equation}
\label{eq:obj:trans4}
%\mathcal{J}''(\bml, \bmo) =
\max_{\bm \lambda, \bm \omega} \sum_{r=1}^k\frac{\bm{z}_r^T(S+ \mathcal{W} \circ S)\bm{z}_r}{\bm{z}_r^TD\bm{z}_r}
- \gamma(||\bm \lambda||^2+||\bm \omega||^2).
\end{equation}
Note that the entries of matrices $S$ and $D$ are linear functions of $\bml$ and $\bmo$.
Therefore, the numerator and the denominator of each term in the summation are both linear functions of $\bml$ and $\bmo$.
Hence, (\ref{eq:obj:trans4})
can be rewritten as:
%can be reformulated to a nonlinear polynomial fractional programming (NPFP) problem~\cite{dinkelbach1967nonlinear}.

%\textbf{Nonlinear polynomial fractional programming problem (NPFPP)}.
%$f(\bm \lambda, \{A_i\}_{i=1}^k) = \sum_{u=1}^p a_u\prod_{j = 1}^{|\mathcal{PS}|}(\lambda_j)^{b_u}\prod_{i=1}^k\prod_{j=1}^{|\mathcal{A}|}((A_i)_{jj})^{c_{uij}}$,
%$g(\bm \lambda, \{A_i\}_{i=1}^k) = \sum_{u=1}^q r_u \prod_{j = 1}^{|\mathcal{PS}|}(\lambda_j)^{s_u}\prod_{i=1}^k\prod_{j=1}^{|\mathcal{A}|}((A_i)_{jj})^{t_{uij}}$.
%Then Eq.~\ref{eq:obj:trans4} can be revised as
\begin{equation}
\label{eq:obj:trans5}
\mathcal{H}(\bml, \bmo) = \max_{\bm \lambda, \bm \omega} \frac{f(\bm \lambda, \bm \omega)}{g(\bm \lambda, \bm \omega)},
\end{equation}
where
$f(\bm \lambda, \bm \omega)$ and $g(\bm \lambda, \bm \omega)$ are two nonlinear multivariate polynomial functions.

It is shown in~\cite{dinkelbach1967nonlinear} that the maximization problem with the form shown in Eq.~\ref{eq:obj:trans5} can be solved by solving the following
related {\it non-linear parametric programming} problem:
%It is difficult to directly perform analysis on a NPFP problem to determine the existence of solution, so it is necessary to
%convert this kind of problem into an easy-to-solve one.
%
%\begin{theorem}
%\label{theo:NPFP}~\cite{DBLP:dblp_journals/jgo/TuyTK04}
%The above NPFP problem is equivalent to the following polynomial programming (PP) problem
%\begin{equation}
%\label{eq:obj:trans6}
%\max_{\bm \lambda, \bm \omega, \eta} \eta f(\bm \lambda, \bm\omega)
%\end{equation}
%subject to $\sum_{i=1}^{|\mathcal{PS}|}\lambda_i = 1$,$\lambda_i \geq 0$, $i = 1,2,...|\mathcal{PS}|$,
%$\sum_{j=1}^{|A|}\omega_j = 1$, $\omega_j \geq 0$, $j = 1,2,...|A|$
%and $0 \leq \eta \leq 1/g(\bm \lambda, \bm \omega)$.
%\comment{
%Proof: Suppose $(\hat{\bm \lambda}, \{\hat A_i\}_{i=1}^k, \hat \eta)$ is an optimal solution for Eq.~\ref{eq:obj:trans6},
%obviously, $\hat \eta = 1/g(\hat{\bm \lambda}, \{\hat A_i\}_{i=1}^k)$ and $\hat \eta f(\hat{\bm \lambda}, \{\hat A_i\}_{i=1}^k) =
%f(\hat{\bm \lambda}, \{\hat A_i\}_{i=1}^k)/g(\hat{\bm \lambda}, \{\hat A_i\}_{i=1}^k)$. Then for any solution $(\bm \lambda, \{A_i\}_{i=1}^k)$ for NFPP,
%setting $\eta = 1/g(\bm \lambda, \{A_i\}_{i=1}^k)$ satisfies the constraints for PPPPC. Since $(\hat{\bm \lambda}, \{\hat A_i\}_{i=1}^k, \hat \eta)$
%corresponds to the maximum value of Eq.~\ref{eq:obj:trans6}, we have $\eta f(\bm \lambda, \{A_i\}_{i=1}^k) \leq \hat \eta f(\hat{\bm \lambda}, \{\hat A_i\}_{i=1}^k)$
%, i.e.,
%$f(\bm \lambda, \{A_i\}_{i=1}^k)/g(\bm \lambda, \{A_i\}_{i=1}^k) \leq$ $f(\hat{\bm \lambda},$ $\{\hat A_i\}_{i=1}^k)$$/g(\hat{\bm \lambda}, \{\hat A_i\}_{i=1}^k)$.
%Therefore, $(\hat{\bm \lambda}, \{\hat A_i\}_{i=1}^k)$ solves NFPP.
%
%Conversely, suppose $(\hat{\bm \lambda}, \{\hat A_i\}_{i=1}^k)$ solves NFPP. Then for any solution $(\bm \lambda, \{A_i\}_{i=1}^k, \eta)$ for PPPPC,
%we have $\eta f(\bm \lambda, \{A_i\}_{i=1}^k)$ $\leq f(\bm \lambda, \{A_i\}_{i=1}^k)/g(\bm \lambda, \{A_i\}_{i=1}^k) \leq f(\hat{\bm \lambda}, \{\hat A_i\}_{i=1}^k)/g(\hat{\bm \lambda}, \{\hat A_i\}_{i=1}^k)$. By setting $\hat \eta = 1/g(\hat{\bm \lambda}, \{\hat A_i\}_{i=1}^k)$, obviously, $(\hat{\bm \lambda}, \{\hat A_i\}_{i=1}^k, \hat \eta)$ solves PPPPC.
%}
%\hfill$\Box$
%\end{theorem}
%
%According to Theorem~\ref{theo:NPFP}, the NPFP problem can be solved by
%solving an equivalent PP problem at the cost of adding one more parameter.
%Obviously, the added parameter brings in new burden and is not preferred.
%Moreover, it is well known that the key to solving a global optimization problem is to transcend an incumbent value of the objective function,
%so we can reformulate the NPFP problem into a nonlinear parametric programming (NPP) problem and further simplify it.
%Using the same symbols in Eq.~\ref{eq:obj:trans5}, we define
\begin{definition}
\label{def:npp}
\textbf{[Non-linear parametric programming (NPP)]}
Let $f(\bml,\bmo)$ and $g(\bml,\bmo)$ be two multivariate polynomial functions. For a given $\mu$, find
\begin{equation}
\label{eq:obj:trans7}
F(\mu) = \max_{\bm \lambda, \bm \omega} \left( f(\bm \lambda, \bm \omega) - \mu g(\bm \lambda, \bm \omega) \right).
\end{equation}
In our context, the parameters $\bml$ and $\bmo$ are subject to the constraints listed at the end of Section~\ref{sec:penalty}.
%subject to $\sum_{i=1}^{|\mathcal{PS}|}\lambda_i = 1$,$\lambda_i \geq 0$, $i = 1,2,...|\mathcal{PS}|$ and
%$\sum_{j=1}^{|A|}\omega_j \newline= 1$, $\omega_j \geq 0$, $j = 1,2,...|A|$.
\hfill$\Box$
\end{definition}
In~\cite{dinkelbach1967nonlinear}, the following theorem is proved.
\begin{theorem}
\label{theorem2}
Given a fixed $\mu$, let $({\bm \lambda^*}, {\bm \omega^*})$ be the optimal solution to $F(\mu)$ (Eq.~\ref{eq:obj:trans7}).
$(\bm \lambda^*, \bm \omega^*)$ is also an optimal solution to $\mathcal{H}(\bml, \bmo)$ (Eq.~\ref{eq:obj:trans5}) if and only if $F(\mu) = 0$.
%$f(\bm \lambda, \{A_i\}_{i=1}^k) = \sum_{u=1}^p a_u \prod_{j = 1}^{|\mathcal{PS}|}(\lambda_j)^{b_u}\prod_{i=1}^k$ $\prod_{j=1}^{|\mathcal{A}|}((A_i)_{jj})^{c_{uij}}$,
%$g(\bm \lambda, \{A_i\}_{i=1}^k) = \sum_{u=1}^q r_u \prod_{j = 1}^{|\mathcal{PS}|}(\lambda_j)^{s_u}\prod_{i=1}^k$ $\prod_{j=1}^{|\mathcal{A}|}((A_i)_{jj})^{t_{uij}}$.
\hfill$\Box$
\end{theorem}

Besides Theorem~\ref{theorem2}, a few lemmas are also proved in~\cite{dinkelbach1967nonlinear}:
%Theorem~\ref{theorem2} reduces the NPFP problem to a NPP problem \emph{in the same parameter space},
%which is much simpler compared with PP problem. Also it is much easier to solve a NPP problem than a NPFP problem.
%Besides, we have some lemmas to help with the optimization.

\begin{lemma}
\label{lemma1}
$F(\mu)$ is convex.
\comment{
Proof: Suppose $(\bm \lambda, \{A_i\}_{i=1}^k)$ is the solution corresponding to $\mu = t\mu_1 + (1-t)\mu_2$,
where $\mu_1 \neq \mu_2, 0 \leq t \leq 1$. Then we have $F(\mu) = f(\bm \lambda, \{A_i\}_{i=1}^k) - \mu g(\bm \lambda, \{A_i\}_{i=1}^k)
= f(\bm \lambda, \{A_i\}_{i=1}^k) - (t\mu_1 + (1-t)\mu_2)g(\bm \lambda, \{A_i\}_{i=1}^k) = t(f(\bm \lambda, \{A_i\}_{i=1}^k) - \mu_1g(\bm \lambda, \{A_i\}_{i=1}^k))
+ (1-t)(f(\bm \lambda, \{A_i\}_{i=1}^k) - \mu_2g(\bm \lambda, \{A_i\}_{i=1}^k))$.
Obviously, $f(\bm \lambda, \{A_i\}_{i=1}^k) - \mu_1g(\bm \lambda, \{A_i\}_{i=1}^k) \leq F(\mu_1)$ and
$f(\bm \lambda, \{A_i\}_{i=1}^k) - \mu_2g(\bm \lambda, \{A_i\}_{i=1}^k) \leq F(\mu_2)$,
which induces $F(t\mu_1 + (1-t)\mu_2) \leq tF(\mu_1)+(1-t)F(\mu_2)$.
}
\hfill$\Box$
\end{lemma}
\begin{lemma}
\label{lemma2}
$F(\mu)$ is continuous.
\hfill$\Box$
\end{lemma}
\begin{lemma}
\label{lemma3}
$F(\mu)$ is strictly monotonically decreasing, i.e., if $\mu_1 < \mu_2$, $F(\mu_1) > F(\mu_2)$.
\comment{
Proof: Suppose $(\hat{\bm \lambda}, \{\hat{A}_i\}_{i=1}^k)$ is the solution corresponding to $\mu_2$.
Then we have $F(\mu_2) = f(\hat{\bm \lambda}, \{\hat{A}_i\}_{i=1}^k) - \mu_2g(\hat{\bm \lambda}, \{\hat{A}_i\}_{i=1}^k)
< f(\hat{\bm \lambda}, \{\hat{A}_i\}_{i=1}^k) - \mu_1g(\hat{\bm \lambda}, \{\hat{A}_i\}_{i=1}^k) \leq
\max_{\bm \lambda, \{A_i\}_{i=1}^k} f(\bm \lambda, \{A_i\}_{i=1}^k) - \mu_1 g(\bm \lambda, \{A_i\}_{i=1}^k) = F(\mu_1)$
}
\hfill$\Box$
\end{lemma}
\begin{lemma}
\label{lemma4}
$F(\mu) = 0$ has a unique solution.
\hfill$\Box$
\end{lemma}
Due to space limit,
readers are referred to~\cite{dinkelbach1967nonlinear, stancu2012fractional} for the proofs of the theorem and lemmas.

From Theorem~\ref{theorem2}, we need to find
a $\mu^*$ and its corresponding $({\bm \lambda^*}, {\bm \omega^*})$ such that $F(\mu^*) = 0$.
\schain\ does so by an iterative numerical method.
In each iteration, \schain\ computes a $\mu$ and $(\bml, \bmo)$.
Let $\mu_i$, $(\bml_i, \bmo_i)$ be those computed in the $i$-th iteration.
\schain\ first sets $\mu_1 = 0$ and in each iteration, performs two steps:
(Step 1:) Solve the NPP problem (Eq.~\ref{eq:obj:trans7}) for $\mu = \mu_i$ and set $(\bml_i, \bmo_i)$ to be the solution found.
(Step 2:) Set $\mu_{i+1} = f(\bml_i, \bmo_i)/g(\bml_i, \bmo_i)$.
Next, we show theoretical properties of this update process.

\noindent{\bf Property 1:}
$\bm{F(\mu_1) > 0}$.
Without loss of generality, we assume $f(\bml, \bmo) > 0$ and $g(\bml, \bmo) > 0$.\footnote{One can show that the quantity (\ref{eq:obj:trans4})
is bounded below by $-2\gamma$. We can add an arbitrary large constant to (\ref{eq:obj:trans4}) to make it, and thus
$f(\bml, \bmo)$ and $g(\bml, \bmo)$, positive.}
Now, $F(\mu_1)$ = $F(0)$ = $\max_{\bml, \bmo} f(\bm \lambda, \bm \omega) > 0$.

\noindent{\bf Property 2: if} $\bm{F(\mu_i) > 0}$ {\bf then}
$\bm {0 \leq F(\mu_{i+1}) < F(\mu_i)}$.
Since $(\bml_i, \bmo_i)$ is the solution of the NPP problem for $\mu = \mu_i$ (Eq. \ref{eq:obj:trans7}),
we have $f(\bml_i, \bmo_i) - \mu_i g(\bml_i, \bmo_i) = F(\mu_i) > 0$.
Hence, $\mu_{i+1} = f(\bml_i, \bmo_i)/g(\bml_i, \bmo_i) > \mu_i$.
By Lemma~\ref{lemma3}, $F(\mu_{i+1}) < F(\mu_i)$.
Also, we have
$F(\mu_{i+1})$ = $\max_{\bm \lambda, \bm \omega} ( f(\bm \lambda, \bm \omega) -\mu_{i+1}g(\bm \lambda, \bm \omega))
\geq f(\bm \lambda_i, \bm \omega_i) - \mu_{i+1} g(\bm \lambda_i, \bm \omega_i) = 0$.

From the properties, we see that \schain\ starts with a positive $F(\mu)$, whose value
stays positive and decreases across iterations until it reaches 0.
The update procedure thus converges to the optimal values.
%The process is repeated until a certain maximum number of iterations have been executed, or until $F(\mu_i)$ becomes
%negative for some iteration $i$.
%In the latter case, due to Lemma~\ref{lemma3}, we know that $\mu^* \in [\mu_{i-1}, \mu_i]$.
%\schain\ then switches to the bisection method:
%It computes $\mu_{i+1} = (\mu_{i-1} + \mu_i)/2$, and repeats either with the interval $[\mu_{i-1}, \mu_{i+1}]$ or $[\mu_{i+1}, \mu_i]$,
%depending on which interval contains $\mu^*$.
The \schain\ algorithm is summarized in Algorithm~\ref{alg}.
\begin{algorithm}
\begin{small}
\caption{SCHAIN}
\label{alg}
\begin{algorithmic}[1]
%\Require $G=(V, E)$, $A$, meta-paths $\mathcal{P}$'s, $\mathcal{X}_i$, $\mathcal{L}$, $D$, $B$, $N_s$.
\Require $G$, $\mathcal{M}$, $\mathcal{C}$, $T_i$, $k$, $\mathcal{PS}$.
\Ensure $\mathfrak{C} = \{C_1, ..., C_k\}$
\State Compute similarity matrices $S_A$, $S_L$, and $S$
\State $t=0$, $\Delta \mathcal{J} = \infty$
%\State Derive $S$ by Eq.~\ref{eq:S}
\State $\bm \lambda = (\frac{1}{|\mathcal{PS}|}, ..., \frac{1}{|\mathcal{PS}|})$;
$\bm \omega = (\frac{1}{|A_i|}, ..., \frac{1}{|A_i|})$
%\State Calculate $\mathit{QS}(D)$
\While{$\Delta \mathcal{J} > \epsilon$ or $t$ < max\_iter}
%\State Construct $\mathcal{M}$ and $\mathcal{C}$
\LeftComment Step 1: Optimize $\{\bm z_r\}_{r=1}^k$ given {$\bm \lambda$} and $\bm \omega$
\State Solve Eq.~\ref{eq:max} to obtain real-relaxed $\tilde{Z}$
\State Calculate $U=D^{-1/2}\tilde{Z}$ and normalize it
\State Derive $\{{\bm z}_r\}_{r=1}^k$ from $U$ by k-means
\LeftComment Step 2: Optimize {$\bm \lambda$} and $\bm \omega$ given $\{${$\bm z$}$_r\}_{r=1}^k$
\State $j=1$; $\mu_j = 0$
%\For{$j = 0$ to $F(\mu)$ converges to 0}
\Repeat
\State Solve Eq.~\ref{eq:obj:trans7} with $\mu = \mu_j$ to obtain ${\bm \lambda}_{j}$, ${\bm \omega}_{j}$
\State $\mu_{j+1} = f({\bm \lambda}_{j}, {\bm \omega}_{j}) / g({\bm \lambda}_{j}, {\bm \omega}_{j})$; $j$++
\Until  $F(\mu_{j+1})$ converges to 0%($j$ > max\_iter2) %or ($F(\mu_j) < 0$)
%\If{($F(\mu_j) < 0$)}
%\State use bisection method to determine $\bml$, $\bmo$
%\Else
%\State $\bml = \bml_j$; $\bmo = \bmo_j$
%\EndIf
\State $\Delta \mathcal{J}$ = change in $\mathcal{J}$ with the updated $\{{\bm z_r}\}_{r=1}^k$, $\bml$, $\bmo$
\State $t$++
%\State $\bm \lambda^{t+1} = \hat{\bm \lambda}^{j+1}$; $\bm \omega^{t+1} = \hat{\bm \omega}^{j+1}$
\EndWhile
\State Decode $\{C_r\}_{r=1}^k$ from $\{{\bm z_r}\}_{r=1}^k$
\State \Return $\mathfrak{C} = \{C_1, ..., C_k\}$
\end{algorithmic}
\end{small}
\end{algorithm}

\comment{

In conclusion, to solve a NPFP problem, we need to first convert it into a NPP problem.
To solve the NPP problem, it involves in two steps. The first step is to select a $\mu$ value and the second one is to solve the maximization problem in
Eq.~\ref{eq:obj:trans7} to get $(\bm \lambda, \bm \omega)$ and $F(\mu)$.
Since the final aim is to find the $\mu$ which makes $F(\mu) = 0$,
we adopt an iterative two-step update strategy to perform optimization.
Step 1: given a $\mu$, solve the maximization problem in Eq.~\ref{eq:obj:trans7} to get $(\bm \lambda, \bm \omega)$ and the $F(\mu)$ value.
Step 2: given $(\bm \lambda, \bm \omega)$, calculate a new $\mu$ value.
Due to the monotonically decreasing property of $F(\mu)$,
we can start from a $\mu$ which makes $F(\mu) > 0$.
%and $F(0) = \max_{\bm \lambda, \bm \omega} f(\bm \lambda, \bm \omega) > 0$,
%we can start from $\mu = 0$.
After $(\bm \lambda, \bm \omega)$ is calculated, according to Proposition~\ref{prop1}, we assign $\mu = f(\bm \lambda, \bm \omega)/g(\bm \lambda, \bm \omega)$.
The iteration repeats until $F(\mu) = 0$.

Since $||\bm \lambda||^2 \leq 1$ and $||\bm \omega||^2 \leq 1$,
we usually add a term $2\gamma$ to the end of Eq.~\ref{eq:obj:trans4}
to ensure $-\gamma(||\bm \lambda|| ^ 2 + ||\bm \omega||^2) + 2\gamma \geq 0$.
On the one hand, the added term is irrelevant to $\bm \lambda$ and $\bm \omega$,
so it will not influence the optimization result.
On the other hand, it can ensure the derived $f(\bm \lambda, \bm \omega) > 0$ in Eq.~\ref{eq:obj:trans5}.
Since $F(0) = \max f(\bm \lambda, \bm \omega) > 0$,
we can safely start from $\mu = 0$.

\begin{proposition}
\label{prop1}
Suppose $F(\hat \mu) > 0$ and $(\hat{\bm \lambda}, \hat{\bm \omega})$ solves Eq.~\ref{eq:obj:trans7} corresponding to $\hat \mu$,
then $f(\hat{\bm \lambda}, \hat{\bm \omega})/g(\hat{\bm \lambda}, \hat{\bm \omega}) > \hat \mu$.

Proof: $F(\hat \mu) = \max_{\bm \lambda, \bm \omega} f(\bm \lambda, \bm \omega) - \hat \mu g(\bm \lambda, \bm \omega) =
f(\hat{\bm \lambda}, \hat{\bm \omega}) - \hat \mu g(\hat{\bm \lambda}, \hat{\bm \omega}) > 0$.
$g$ derives from Eq.~\ref{eq:obj:trans4}, as the denominator,
$g(\hat{\bm \lambda}, \hat{\bm \omega}) > 0$,
so we have $f(\hat{\bm \lambda}, \hat{\bm \omega})/g(\hat{\bm \lambda}, \hat{\bm \omega}) > \hat \mu$.
\hfill$\Box$
\end{proposition}

Based on the above iterative optimization method, the model will finally converge.
Proofs are listed as follows.
\begin{theorem}
\label{theorem3}
The proposed model finally converges.

Proof: The objective is to minimize Eq.~\ref{eq:obj:trans:reg}, which includes three parts.
First, $0 \leq \bm{z}_i^T(D-S)\bm{z}_i / \bm{z}_i^TD\bm{z}_i \leq 1$.
Second, for $-(\bm{z}_i^TW\circ S\bm{z}_i / \bm{z}_i^TD\bm{z}_i)$, we consider two extreme cases:
if all the object pairs in cluster $i$ are in the must-link set $\mathcal{M}$, then $0 \leq \bm{z}_i^TW\circ S\bm{z}_i / \bm{z}_i^TD\bm{z}_i \leq 1$;
if all the object pairs in cluster $i$ are in the cannot-link set $\mathcal{C}$, then $-1 \leq \bm{z}_i^TW\circ S\bm{z}_i / \bm{z}_i^TD\bm{z}_i \leq 0$,
so $-1 \leq \bm{z}_i^TW\circ S\bm{z}_i / \bm{z}_i^TD\bm{z}_i \leq 1$, i.e., $-1 \leq -(\bm{z}_i^TW\circ S\bm{z}_i / \bm{z}_i^TD\bm{z}_i) \leq 1$.
Third, since $\gamma \geq 0$, $\gamma (||\bm \lambda||^2 + ||\bm \omega||^2)$ is convex, the constraints on $\bm \lambda$ and $\bm \omega$ are
also convex, so
%$\sum_{i=1}^{|\mathcal{PS}|}\lambda_i = 1$, $\sum_{i=1}^{|\mathcal{PS}|}\lambda_i = 1$,$\lambda_i \geq 0$ and $\lambda_j \geq 0$,
it must have a minimum value.
In conclusion, Eq.~\ref{eq:obj:trans:reg} has a lower bound.

Furthermore, the iterative optimization method, either optimizing $\{${\boldmath $z$}$_i\}_{i=1}^k$ or
updating $\bm \lambda$ and $\bm \omega$, always decreases the objective function, so the convergence is guaranteed.
\hfill$\Box$
\end{theorem}

}


\section{Numerical Results}
\label{sec:numerical_results}

\begin{frame}[c]{Synthetic Asset}
	\begin{block}{Goal}
		Evaluate different RL algorithms in a controlled environment, i.e.  on a synthetic asset with profitably tradable features
	\end{block}
	The synthetic asset price is given by
	\begin{equation*}
		Z_t = \exp\left(\frac{z_t}{\max_t z_t - \min_t z_t}\right)
	\end{equation*}
	where $\{z_t\}$ is a random walk with autoregressive trend $\{\beta_t\}$
		\begin{equation*}
			\begin{split}
				z_t &= z_{t-1} + \beta_{t-1} + \kappa \epsilon_t\\
				\beta_t &= \alpha \beta_{t-1} + \nu_t\\
			\end{split}
		\end{equation*}
\end{frame}

\begin{frame}[c]{Convergence of RL algorithms}
\begin{figure}[t!]
	\centering
	\includegraphics[height=5cm,width=1.0\textwidth]{Images/6_0_single_synthetic_neutral_convergence}
\end{figure}
\end{frame}

\begin{frame}[c]{Backtest Performance of the Trading Strategies Learned}
\begin{figure}[t]
	\centering
	\includegraphics[height=6cm,width=1.0\textwidth]{Images/6_1_single_synthetic_neutral_performance}
\end{figure}
\end{frame}

\begin{frame}[c]{Impact of Transaction Costs}
\begin{figure}[t!]
	\centering
	\includegraphics[height=3cm,width=1.0\textwidth]{Images/6_2_impact_transaction_costs}
\end{figure}
\begin{figure}[t!]
	\centering
	\includegraphics[height=3cm,width=1.0\textwidth]{Images/6_3_impact_short_selling_fees}
\end{figure}
\end{frame}


\section{Construction of icosahedral grid}
The icosahedral geodesic grid is constructed as follows:
\begin{enumerate}
  \item Each side of the icosahedron whose vertices are on a unit sphere are
    projected onto the sphere. This grid is called 'glevel 0' gri. (Fig. \ref{fig:scale-gm_grid}(a)).
  \item By connecting the mid-points of the geodesic arcs, four
      sub-trianbles are generated from each of the 'glevel 0' triangles. This
      grid is called 'glevel 1' grid (Fig. \ref{fig:scale-gm_grid}(b)).
  \item By iterating this process $l$-th times, a grid structure of 'glevel l'
    is obtained.
\end{enumerate}
The total number $N_p$ of triangle verrtices with the glevel $l$ grid can be
described as
\begin{equation}
  N_p(l) = 10 \times 4^l + 2 \nonumber
\end{equation}

\begin{figure}[H]
  \begin{center}
    \includegraphics[width=10cm]{../../figure/grid_structures}
%    \begin{tabular}{cc}
%    \includegraphics[width=5cm]{../../figure/grid0} &
%    \includegraphics[width=5cm]{../../figure/grid1} \\
%    \includegraphics[width=5cm]{../../figure/grid2} &
%    \includegraphics[width=5cm]{../../figure/grid3}
%    \end{tabular}
    \caption{Grid structure (grid division levels 0-3).}
    \label{fig:scale-gm_grid}
  \end{center}
\end{figure}

\section{Control volume}
All the  variables are defined at the vertices of triangles. This arrangement
is so-called 'Arakawa-A' type grid. Since the descritization of equations is
based on the finite volume method, it is necessary for the control volume to
be defined. The schematic figure of control volume is shown in Fig. \ref{fig:scale-gm_control_volume}. The
red points of $P_0$ up to $P_6$ are the vertices of triangles, Green points
remained are defined as gravitational center of the corresponding
triangles. The control volume for the point $P_0$ is defined as the polygon
constructed by connecting the gravitational centers of the neighbouring
triangles. The shape of control volume in the almost region is hexagon, while
it is pentagon at only 12 points inherited from glevel 0.

\begin{figure}[H]
  \begin{center}
    \includegraphics[width=5cm]{../../figure/control_volume}
    \caption{Schematic figure of the control volume}
    \label{fig:scale-gm_control_volume}
  \end{center}
\end{figure}

\section{Modification of icosahedral grid}
The construction method of control volume as described in the previous
subsection has one problem as regards to accuracy. From the viewpoints of
accuracy, any variable-defined point should be the gravitational center of
control volume. However, it is not so in the above construction. So, we
develop a new grid by modifying the default grid as follows.
\begin{enumerate}
  \item After the construction of first control volume by the previous method,
    variable-defined points are moved to the gravitaitonal center of control
    volume. This process is shown in Fig. \ref{fig:scale-gm_modified_control_volume}. The blue points are new
    locations of variable-defined points.
  \item By using the new location of variable-defined points, next
    variable-defined points are obtained in the same manner.
  \item This iteration is reported until the variable-defined points is
    converged.
\end{enumerate}
Whether grid is converged or not has not been yet mathematically proved, but
practically, it can be converged up to glevel 8. Those grids are called glevel
$l$M.

\begin{figure}[H]
  \begin{center}
    \includegraphics[width=5cm]{../../figure/modified_control_volume}
    \caption{Schematic figure of modified grid and control volume}
    \label{fig:scale-gm_modified_control_volume}
  \end{center}
\end{figure}

Figure \ref{fig:scale-gm_control_volume_comparison} gives the default grid and modified one for the grid division level
3. As shown in this figure, the grid interval around vertices of icosahedron
slightly decreases by the modification. This lead to the increase of
maximum/minimum ratio of grid interval.
%The maximum/minimum ratio of grid
%interval against grid division level is shown in Fgi. XX, where grid interval
%$d$ is defined as the root of control volume area. It can be guessed from this
%figure that even in the glevel 11M grid the value of $d_max/d_min$ will be
%about 3, so it is enough acceptable.

\begin{figure}[H]
  \begin{center}
    \includegraphics[width=5cm]{../../figure/control_volume_comparison}
    \caption{Comparison of default and modiified grids. The perspective
      center of the figures is located at the north pole.}
    \label{fig:scale-gm_control_volume_comparison}
  \end{center}
\end{figure}

\section{Parallelization}
\subsection{Region division}
The concept of region division level is introduced as follows.
\begin{enumerate}
  \item By connecting two neighboring triangles of spherical icosahedron, ten
    rectangles are constructed as Fig. \ref{fig:scale-gm_region_structure}(a). This construction is called 'rlevel
    0.'
  \item For each rectangle, four sub-rectangles are generated by connecting
    the diagonal mid-grid-points (Fig. \ref{fig:scale-gm_region_structure}(b)). This construction is called
    'rlevel 1.'
  \item This process is repeated until the desirable regions are obtained.
\end{enumerate}
This example of grid structure in a region is shown in Fig. \ref{fig:scale-gm_grid_structure}. Although the
grid is not based on rectangles but triangles, it is like a
structured-grid. On the other words, all variables can be described by
Fortran's 2 dimensional array. This is an advantage for vector super-computing.

\begin{figure}[H]
  \begin{center}
    \includegraphics[width=10cm]{../../figure/region_structure}
    \caption{Region structure (region division levels 0-3)}
    \label{fig:scale-gm_region_structure}
  \end{center}
\end{figure}

\begin{figure}[H]
  \begin{center}
    \includegraphics[width=5cm]{../../figure/grid_structure}
    \caption{Grid structure of one region.}
    \label{fig:scale-gm_grid_structure}
  \end{center}
\end{figure}

\subsection{Parallelization}
In the parallel computing, the regions made by the above method are managed by
some processes. One of the simples solutions of parallilization is that one
process manages one region. However, it is lacking of flexibility. We design
the management of region as follows.
\begin{enumerate}
  \item Any process can manage any nubmer and any location of regions.
  \item Number of managed process is not necessary to be constant.
\end{enumerate}
This design concept makes the load of each CPU be uniform.

When two neigouring regions are not managed by the same process, the excahnge
of boundary conditions is done using MPI communication. When two neighboring
regions are managed by the same process, it is done by copying the memory of
boundary.

Figure \ref{fig:scale-gm_parallel} shows the schematic figure of region management. This figure is an
expansion for rlevel 1. Total amount of region is forty and ten processes
manage those regions. Each of the processes manages the region marked by same
color. For example, regions A, B, C, and D are managed by the same process. It
is configured for each fo processes to manage the regions from pole and
equatorial regions. By this configuration, locad imbalance due to the
atmospheric physical process would be avoided.

\begin{figure}[H]
  \begin{center}
    \includegraphics[width=5cm]{../../figure/parallel}
    \caption{Schematic figure of parallelization.}
    \label{fig:scale-gm_parallel}
  \end{center}
\end{figure}

\subsection{Note}
 \begin{itemize}
   \item g-level (grid level): number of subdivision times of the grid from the original icosahedron.
         the number starts from 1, we recommend to use the number larger than 4.
   \item r-level (region level): number of subdivision times of the region(tile)
         from the original icosahedron. When r-level = 0, we have ten regions(tiles).
         At that time, the number of available maximum MPI processes is ten.
 \end{itemize}

\textcolor{red}{[さらにHALOを説明する図もある方が良い]}


\input{6DL/DoubleFourier}
%\section{Asymptotic convergence estimates for $L^2$ norm}
%\subsection

\iffalse
Then we propose the next assumption on $\sigma$
\begin{assumption}\label{assump:sigma}[Siegle \& Xu 2020]
	Let $\sigma \in L^{\infty}(\Omega)$ and there exists $p> 1$  such that
	\begin{equation}\label{key}
	|\sigma(t)| \le (1+|t|)^{-p}.
	\end{equation}
\end{assumption}

Then we have the next important lemma about the estimate of $\rho(\theta)$.
\fi

\begin{theorem}\label{approximation_rate_theoreml2}
 Let $\Omega\subset \mathbb{R}^d$ be a bounded domain. If the activation function $\sigma $ is non-zero and satisfies the polynomial decay condition
$$
\sigma(t) \le (1+|t|)^{-p}
$$
for some $p>1$, then for any $n \ge 1$, there exist
	$\theta_i = (\omega_i, b_i) \in \mathbb{R}^{d+1}$ such that
	\begin{equation}\label{key}
	\|u-u_n\|_{L^{2}(\Omega)} \lesssim n^{-\frac{1}{2}}\|u\|_{\mathcal B^1(\Omega)},
	\end{equation}
	where
	\begin{equation}\label{key}
	u_n(x) = \frac{\|\rho\|_{L^1}}{n} \sum_{i=1}^n \beta_i {\sigma}(a^{-1}\omega_i\cdot x + b_i) %{\rm Re} \left( \hat f(\omega_i)e^{iab}\right)
	\in \dnn(\sigma, n).
	\end{equation}
\end{theorem}

\begin{theorem}\label{approximation_rate_theorem}
 Let $\Omega\subset \mathbb{R}^d$ be a bounded domain. If the activation function $\sigma\in W^{m,\infty}(\mathbb{R})$ is non-zero and satisfies the polynomial decay condition
 \begin{equation}\label{growth_condition}
  |\sigma^{(k)}(t)| \leq C_p(1 + |t|)^{-p}
 \end{equation}
 for $0\leq k\leq m$ and some $p > 1$, we have
 \begin{equation}
  \inf_{u_n\in \dnn(\sigma,n)}\|u-u_n\|_{H^m(\Omega)} \leq |\Omega|^{\frac{1}{2}}C(p,m,\text{\normalfont diam}(\Omega),\sigma)n^{-\frac{1}{2}}\|u\|_{\mathcal{B}^{m+1}(\Omega)},
 \end{equation}
 for any $u\in \mathcal{B}^{m+1}$.
\end{theorem}
Before we proceed to the proof, we discuss how this bound depends on
the dimension $d$. We first note that $|\Omega|$ may in a sense depend
on the dimension, as the measure may be exponentially large in high
dimensions. However, bounding the $H^m$ error over a larger set is
also proportionally stronger. This can be seen by noting that dividing
by the $|\Omega|^\frac{1}{2}$ factor transforms the left hand side
from the total squared error to the average squared error.

The dimension dependence of this result is a consequence of how the
Barron norm behaves in high dimensions. This issue is discussed in
\cite{barron1993universal}, where the norm $\|\cdot\|_{\mathcal{B}^1}$
is analyzed for a number of different function classes. A particularly
representative result found there is that $H^{\frac{d}{2}+2}\subset
\mathcal{B}^1$. This shows that sufficiently smooth functions have
bounded Barron norm, where the required number of derivatives depends
upon the dimension. It is known that approximating functions with such
a dimension dependent level of smoothness can be done efficiently
\cite{petrushev1998approximation, kainen2007sobolev}. However, the
Barron space $\mathcal{B}^1$ is significantly larger that
$H^{\frac{d}{2}+2}$, in fact we only have $\mathcal{B}^1 \subset H^1$
by lemma \ref{smoothness-lemma}. The precise properties of the Barron
norm in high dimensions are an interesting research direction which
would help explain exactly how shallow neural networks help alleviate
the curse of dimensionality.

Next we consider the proof for Theorem \ref{approximation_rate_theoreml2}. Recall
 \begin{equation}
u(x) =  \int_{\mathbb{R}^d}\int_\mathbb{R} k(x,\theta) dbd\omega,\quad
  k(x,\theta)= \frac{1}{ \hat{\sigma}(a)}
  \sigma\left(a^{-1}{\omega}\cdot
    x+b\right)\hat{u}(\omega)e^{-2\pi iab}.
 \end{equation}
where $\theta=(\omega, b)$.
 Define
\begin{equation}\label{key}
h(\omega, b) = \max_{x\in \Omega}|\sigma(a^{-1}\omega\cdot x+b)|, \quad \mbox{ and }\quad \rho(\theta) = h(\omega, b)  |\hat u(\omega)|.
\end{equation}
If $ \rho(\theta) \in L^1(\mathbb{R}^{d+1})$, then $f(x)=\mathbb{E}(k(x,\theta))$. By the Monte Carlo method in Theorem \ref{MC}, it is sufficient to prove $ \rho(\theta) \in L^1(\mathbb{R}^{d+1})$.
\begin{lemma}
Let $\sigma \in L^{\infty}(\Omega)$ and there exists $p> 1$  such that
	\begin{equation}\label{key}
	|\sigma(t)| \le (1+|t|)^{-p},
	\end{equation}
then we have
$$
\rho(\theta) \in L^1(\mathbb{R}^{d+1}).
$$
\end{lemma}
\begin{proof}
Note that
\begin{equation}
\label{eq:4}
\begin{aligned}
|k(x,\theta)| &\le \frac{1}{ |\hat \sigma(a)|} \max_{x\in \Omega} |\sigma\left(a^{-1}{\omega}\cdot
x+b\right) | |\hat u(\omega)|  \\
&\le  \frac{1}{ |\hat \sigma(a)|}  h(\omega, b)|\hat u(\omega)|   =  \frac{1}{  |\hat \sigma(a)|} \rho(\theta)
\end{aligned},
\end{equation}
and
	\begin{equation}\label{key}
	\|\rho\|_{L^1(\mathbb{R}^{d+1})} = \int_{\mathbb{R}^{d+1}} |\rho(\theta)|d\theta = \int_{\mathbb{R}^d} \left( \int_{\mathbb{R}} h(\omega, b)db\right) |\hat u(\omega)| d\omega.
	\end{equation}
Note that
\begin{equation}\label{key}
|a^{-1}\omega \cdot x + b| \ge |b| - |a^{-1}\omega \cdot x | \ge  |b| - |a^{-1}||\omega| | x|  \ge |b| - |a^{-1}| |\omega | R,
\end{equation}
where
\begin{equation}\label{key}
R = \max_{x\in \bar \Omega} |x|,
\end{equation}
as $\Omega$ is bounded.
Thus
\begin{equation}\label{key}
|a^{-1}\omega \cdot x + b| \ge \max(0, |b| - \frac{R}{|a|} |\omega |).
\end{equation}
That is to say
\begin{equation}\label{key}
h(\omega, b) \le (1+  \max(0, |b| - \frac{R}{|a|}|\omega|))^{-p},
\end{equation}
	Then we calculate
	\begin{equation}\label{eq_775}
	\begin{split}
	\int_\mathbb{R} h(\omega,b)db& \le \int_{|b|\leq \frac{R|\omega|}{|a|}} db + 2\int_{b > \frac{R\|\omega\|}{|a|}} \left(1 + b - \frac{R|\omega|}{|a|}\right)^{-p}db \\
	& =~2R|a|^{-1}|\omega| + 2\left[(1-p)^{-1}\left(1 + b - \frac{R|\omega|}{|a|}\right)^{1-p}\right]_{\frac{R|\omega|}{|a|}}^\infty \\
	&=~2R|a|^{-1}|\omega| + \frac{2}{p-1}\leq C_1(p,\text{\normalfont diam}(\Omega),\sigma) (1 + |\omega|).
	\end{split}
	\end{equation}
	Thus, we have
	\begin{equation}\label{key}
		\|\rho\|_{L^1(\mathbb{R}^{d+1})} \le C_1\int_{\mathbb{R}^d} (1+|\omega|)|\hat u(\omega)| d\omega.
	\end{equation}
\end{proof}
Here we denote
\begin{equation}\label{key}
\|u\|_{\mathcal B^1(\Omega)} = \int_{\mathbb{R}^d} (1+\|\omega\|)|\hat u(\omega)| d\omega,
\end{equation}
namely
\begin{equation}\label{key}
\|\rho\|_{L^1(\mathbb{R}^{d+1})} \lesssim \|u\|_{\mathcal B^1(\Omega)}.
\end{equation}

These two theorems include many popular activation functions, such as the rectified linear units \cite{nair2010rectified} and logistic sigmoid activation functions. Below we provide a table listing some well-known activation functions to which this theorem applies.
\begin{center}
\begin{tabular}{ |c|c|c|c|c| }
 \hline
 Activation Function & $\sigma(x)$ & Maximal $m$ & $n_0$ & $\nu(x)$ \\
 \hline
 Sigmoidal (Logistic) & $(1 + e^{-x})^{-1}$ & $\infty$ & $2$ & $\sigma(x+1) - \sigma(x)$ \\
 \hline

 Arctan & $\arctan(x)$ & $\infty$ & $2$ & $\sigma(x+1) - \sigma(x)$ \\
 \hline
 Hyperbolic Tangent & $\tanh(x)$ & $\infty$ & $2$ & $\sigma(x+1) - \sigma(x)$ \\
 \hline
 SoftPlus \cite{glorot2011deep} & $\log(1 + e^x)$ & $\infty$ & $4$ & $\sigma(x+1) + \sigma(x - 1) - 2\sigma(x)$ \\
 \hline
 ReLU\cite{nair2010rectified} & $\max(0,x)$ & $1$ & $4$ & $\sigma(x+1) + \sigma(x - 1) - 2\sigma(x)$ \\
 \hline
  Leaky ReLU\cite{maas2013rectifier} & $\epsilon x + (1-\epsilon)\max(0,x)$ & $1$ & $4$ & $\sigma(x+1) + \sigma(x - 1) - 2\sigma(x)$ \\
 \hline
 $k$-th power of ReLU & $[\max(0,x)]^k$ & $k$ & $k+1$ & $\sum_{i=0}^k(-1)^i\binom{k}{i} \sigma(x - \lfloor k/2 \rfloor + i)$\\
 \hline
\end{tabular}
\end{center}

The bound depends on
the dimension $d$. We first note that $|\Omega|$ may in a sense depend
on the dimension, as the measure may be exponentially large in high
dimensions. However, bounding the $H^m$ error over a larger set is
also proportionally stronger. This can be seen by noting that dividing
by the $|\Omega|^\frac{1}{2}$ factor transforms the left hand side
from the total squared error to the average squared error.

\iffalse
\newpage

\subsection{Comparison with linear finite element method}
We can briefly have the next two asymptotic approximation results for deep neural networks and adaptive
linear finite element methods:
\begin{description}
	\item[Neural Network (NN)]
	\begin{equation}\label{key}
	\inf_{f_n \in \dnn(\sigma,n)} \|f-f_n\|_{L^{2}(\Omega)} \lesssim  n^{-\frac{1}{2}}\|f\|_{\mathcal B^1(\Omega)},
	\end{equation}
	where $nd$ is the number of parameters.
	\item[Finite Element (FE)]
	\begin{equation}\label{key}
	\inf_{f_n \in V_n} \|f-f_n\|_{L^{2}(\Omega)} \lesssim  n^{-\frac{2}{d}}\|f\|_{\ast},
	\end{equation}
	where
	\begin{equation}\label{key}
	V_n: \text{linear finite element space of}~ n-\text{elements},
	\end{equation}
	and $\|f\|_{\ast}$ is some Besov norm.
\end{description}
A direct observation for the asymptotic approximation error is that :
\begin{equation}\label{key}
(\frac{n}{d})^{-\frac{1}{2}} << n^{-\frac{2}{d}},
\end{equation}
if $d >> 1$ with respect to the umber of parameters. However, in the future  we will show that
\begin{equation}\label{key}
{\rm DNN}({\rm ReLU}) = \text{Linear FE},
\end{equation}
or we can say that DNN with ReLU activation function is a different way to parametrize linear
finite element space.
\fi


\documentclass{article}
\usepackage{graphicx}
\usepackage{amsmath}
%\usepackage[scientific-notation=true]{siunitx}
\usepackage{tabularx}
\newcommand{\D}{\displaystyle}
\begin{document}
\section{Method 1}
Suppose we take time series data points, N (indexed by a) from each of S species.
$$
X_i^a\rightarrow X^1=
\begin{bmatrix}
           x_{1}^1 \\
           x_{2}^1 \\
           \vdots \\
           x_{S}^1
 \end{bmatrix}
 ,X^2=
 \begin{bmatrix}
           x_{1}^2 \\
           x_{2}^2 \\
           \vdots \\
           x_{S}^2
 \end{bmatrix}
 ....
 ,X^N=
 \begin{bmatrix}
           x_{1}^N \\
           x_{2}^N \\
           \vdots \\
           x_{S}^N
 \end{bmatrix}
$$

Goal: Maximizing$ P(X|\mu,\sigma^2,d) $
\hfill\break
\hfill\break
Assumptions:
\hfill\break
\hfill\break
1). A is a symmetric S by S matrix \hfill\break
2). $A_{ij}=\dfrac{\mu}{S}+B_{ij}$, where $B_{ij}~N(0,\dfrac{\sigma^2}{S}), i.e. A_{ij}~N(\dfrac{\mu}{S}, \dfrac{\sigma^2}{S})$
3). $A_{ii}= -d+\dfrac{\mu}{S}$
4). For A sufficiently large, the determinants of A for different random entries are similar so we use the average determinat of A in place of A. $<detA>=D(\mu,\sigma^2,d)$
\hfill\break
Since, $x_i$ are independent, the average probability of observing $x_i$ given $\mu,\sigma,d$:
$$
P(x|\mu, \sigma^2,d)=\int dA \prod(P(x^a|A)P(A|\mu,\sigma^2,d)
$$
we can pull the product out and distribute it to each term
$$
=\int (\prod_{i<j}(dA_{ij})\dfrac{(detA)^{N/2}}{(2\pi)^{NS/2}} exp(\dfrac{1}{2}\sum_{a=1}^{N}\sum_{ij}^S x_i^a A_{ij} x_j^a) P(A|\mu,\sigma^2,d)
$$
Given our assumptions:
$$
=\dfrac{<detA>^{N/2}}{(2\pi)^{NS/2}} \int (\prod_{i<j}dB_{ij}) exp(\dfrac{1}{2}\sum_{a=1}^N(-d \sum(x_i^a)^2 +\dfrac{\mu}{S} \sum_{ij} x_i^a x_j^a + \sum_{i<j}x_i B_{ij} x_j)  P(B|\sigma^2))
$$
pulling out the terms seperate from $B_{ij} $
$$
=\dfrac{<detA>^{N/2}}{(2\pi)^{NS/2}}exp(\dfrac{-d}{2}\sum_{a=1}^N\sum_{i=1}^S(x_i^a)^2 + \dfrac{\mu}{2S}\sum_{a=1}^N(\sum_{i=1}^S x_i^a)^2 \times \int((\prod_{ij}dB_{ij})exp(\sum_{a=1}^N\sum_{i<j} x_i^a B_{ij}x_j^a)exp(- \sum_{i<j} \dfrac{B_{ij}^2}{2\sigma ^2/S})
$$
$$
\times(\sqrt{\dfrac{S}{2\pi}}\dfrac{1}{\sigma}))
$$
The firt part of the integral becomes\hfill\break
$$\prod_{i<j}dB_{ij}\rightarrow \prod_{i<j}exp(\dfrac{\sigma^2}{2S}(\sum_{a=1}^N x_i^a x_j^a)^2)=exp(\dfrac{\sigma^2}{4S} \sum_{ij}\sum_a x_i^a x_j^a \sum_b x_i^b x_j^b)$$\hfill\break
Then we can condense the summations and obtain:
$$ exp(\dfrac{\sigma^2}{4S}\sum_{ab}(\sum_i x_i^a x_i^b )^2)$$
The portion in the exponent becomes\hfill\break

$$\prod_{i<j} exp(-\dfrac{B_{ij}^2}{2\sigma^2/S}+\sum_{a=1}^N x_i^a B_{ij} x_j^a)\sqrt{\dfrac{S}{2\pi}}\dfrac{1}{\sigma}$$
\hfill\break
After rearranging the terms we get \hfill\break
$$\prod_{i<j} dB_{ij} \sqrt{\dfrac{S}{2\pi}}\dfrac{1}{\sigma}exp(-\dfrac{B_{ij}^2}{2\sigma^2/S}+\sum_{a=1}^N x_i^a B_{ij} x_j^a)$$
Let $y=B_{ij}, \tau=\dfrac{\sigma}{\sqrt{S}}, z=\sum_{a=1} x_i^a x_j^a$
\hfill\break\hfill\break
Then our integral becomes :
$$
\int dy \sqrt{\dfrac{1}{2\pi}}\dfrac{1}{\tau}exp(\dfrac{-y^2}{2\tau ^2}+yz)
$$
Which when solved, simplifies to:
$$
exp(\dfrac{\tau ^2 z^2}{2})
$$
Now let us denote $P(x|\mu,\sigma,d)$ as P:
$$
P=D\times exp(\dfrac{-d}{2}\sum_{a=1}^N\sum_{i=1}^S(x_i^a)^2 + \dfrac{\mu}{2S} \sum_{a=1}^N (\sum_{i=1}^S x_i^a)^2+\dfrac{\sigma^2}{4S}\sum_{ab}(\sum_i x_i^a x_i ^b)^2)
$$
$$
\dfrac{2}{N}logP=logD-\dfrac{d}{N}\sum_{a=1}^N\sum_{i=1}^S(x_i^a)^2 - \dfrac{\mu}{SN} \sum_{a=1}^N (\sum_{i=1}^S x_i^a)^2+\dfrac{\sigma^2}{2SN}\sum_{ab}(\sum_i x_i^a x_i ^b)^2
$$

\subsection{Optimization}
To optimize P we take the partial derivatives wrt $\mu, \sigma$, and d and set them all equal to 0

1). $\dfrac{2}{N}\dfrac{\partial logP}{\partial d}=\dfrac{1}{D}\dfrac{\partial D}{\partial d}-\dfrac{1}{N}\sum_{a=1}^N\sum_{i=1}^S(x_i^a)^2 =0$
\hfill\break\hfill\break
2). $\dfrac{2}{N}\dfrac{\partial logP}{\partial \sigma^2}=\dfrac{1}{D}\dfrac{\partial D}{\partial \sigma^2}+\dfrac{1}{2SN}\sum_{ab}(\sum_i x_i^a x_i ^b)^2 =0$
\hfill\break\hfill\break
3). $\dfrac{2}{N}\dfrac{\partial logP}{\partial \mu}=\dfrac{1}{D}\dfrac{\partial D}{\partial \mu}-\dfrac{1}{SN} \sum_{a=1}^N (\sum_{i=1}^S x_i^a)^2 =0$
\hfill\break\hfill\break
\subsection{Determinant of A}
The average determinant as given to us by the semicircular law in Random Matrix Theory-Robert Wiegner
$$
<log D>=\sum_i log(\lambda_i)=log(d+\mu)+(S-1)\int d\lambda \dfrac{\sqrt{4\sigma^2-(\lambda+d)^2}}{2\pi\sigma}log(\lambda)
$$
We evaluate this integral from $-d-2\sigma : -d+2\sigma$ as that is the radius in which all of our eigenvalues lie according to the semicircular law. Let $z=\dfrac{\lambda -d}{2\sigma}, b=\dfrac{2d}{\sigma}$ so $\lambda \rightarrow 2\sigma z+d, d\lambda \rightarrow 2\sigma dz$. Now we divide everything by $2\sigma$ and the integral:
$$
\int_{-d/2\sigma -1}^{-d/2\sigma +1} d\lambda \dfrac{\sqrt{1-(\dfrac{\lambda -d}{2\sigma})^2}}{2\pi\sigma}log(\dfrac{\lambda}{2\sigma})+log(2\sigma)
$$
becomes:
$$
I=\dfrac{2\sigma}{\pi}[log(2\sigma)\int_{-b-1}^{-b+1}dz\sqrt{1-z^2}+\int_{-b-1}^{-b+1} dz log(z+b)\sqrt{1-z^2}]
$$
By using mathematica we solve the integral, where $F_{3,1}$ is the Hypergeometric function $HypegeometricPFQ[(1,1,\dfrac{3}{2}),(2,3),\dfrac{1}{b^2}]$:
$$
I=log(d)-\dfrac{\sigma^2}{2d^2}[F_{3,11}(\dfrac{4\sigma^2}{d^2})]
$$
Now we can rewrite the average log determinant as:
$$
\dfrac{1}{S}<logD>=\dfrac{1}{S}log(d+\mu)+(1-\dfrac{1}{S})I
$$

\subsection{Solving the Optimization Equations}
Now that we have the $<logD>$ we can solve optimization equations 1)., 2). and 3).
\hfill\break
So first let $g(x)=\dfrac{1}{2}xF_{3,1}(4x)$, Then $g'(x)=\dfrac{1}{1+\sqrt{1-4x}-2x}$
\hfill\break
\hfill\break
\textbf{Optimization equation 3).} becomes
$$
\dfrac{2}{N}\dfrac{\partial logP}{\partial \mu}=\dfrac{1}{d+\mu}-\dfrac{1}{SN} \sum_{a=1}^N (\sum_{i=1}^S x_i^a)^2=0
$$
If we solve optimization equation 3). for $d+\mu$ we get $d+\mu=\dfrac{SN}{ \sum_{a=1}^N (\sum_{i=1}^S x_i^a)^2}$. We replace $d+\mu$ in optimization equation 1). with this.
\hfill\break\hfill\break
\textbf{Optimization equation 1).} becomes:
$$
\dfrac{2}{N}\dfrac{\partial logP}{\partial d}=\dfrac{1}{d}+\dfrac{2\sigma^2}{d^3}g'(\dfrac{\sigma^2}{d^2})-\dfrac{1}{SN}\sum_{a=1}^N\sum_{i=1}^S(x_i^a)^2 +\dfrac{1}{S^2N} \sum_{a=1}^N (\sum_{i=1}^S x_i^a)^2=0
$$
$$
\rightarrow \dfrac{1}{d}+\dfrac{2\sigma^2}{d^3}g'(\dfrac{\sigma^2}{d^2})=\dfrac{1}{SN}\sum_{a=1}^N\sum_{i=1}^S(x_i^a)^2 - \dfrac{1}{S^2N} \sum_{a=1}^N (\sum_{i=1}^S x_i^a)^2
$$
\textbf{Optimization equation 2).} becomes:
$$
\dfrac{2}{N}\dfrac{\partial logP}{\partial \mu}=-\dfrac{1}{d^2}g'(\dfrac{\sigma^2}{d^2})+\dfrac{1}{2SN}\sum_{ab}(\sum_i x_i^a x_i ^b)^2 =0
$$
$$
\rightarrow \dfrac{1}{S}\dfrac{1}{2SN}\sum_{ab}(\sum_i x_i^a x_i ^b)^2=\dfrac{1}{d^2}g'(\dfrac{\sigma^2}{d^2})
$$

\hfill\break\hfill\break
To solve for $\mu, \sigma$ and d we use rootsolvers in R...
\end{document}


\chapter{Methods}

\section{System of Equations}
The system of study was modelled using coupled Ordinary Differential Equations (ODEs). The model is based on a logistic framework modified with a dynamic carrying capacity that depends on the environmental conditions. The ``environment" consists of the resources, oxygen and testosterone which have their own equations for production and consumption. We make the simplifying assumption that every other resource required by cells are present in non-limiting concentrations. Additionally, the cell types were assumed to not mutate and hence cannot change their types. No spatial structure is considered and the system is assumed to be well mixed and the resource available in bulk for all the cells.

The ODEs for population size of a cell type is given in \autoref{cell_eq}. The equation is such that the population increases by a maximum growth rate $r_{i,max}$ and reduces by a maximum death rate $\delta_i$. The effective growth rate decreases as the total population approaches a maximum limit while the effective death rate stays the same. This maximum limit for the total population varies between 1 to $K_{i,max}$ and varies depending on the resource availability as a function of the form as given in \autoref{fres_eq} and visualised in \autoref{fig_fres}.\\
For $i \in \{T^+,T^p,T^-\}$
\begin{equation}
  \frac{dy_i}{dt} = r_{i,max}(dtx) y_i (1 - \frac{\sum_j y_j}{1 + K_{i,max} f_i(O_2) f_i(test)} )- \delta_i y_i
  \label{cell_eq}
\end{equation}

The functional dependence on resource $f_i(res) \in [0,1]$. Below the lower limit, $ll_{res,i}$ the function is 0, representative of no growth, and increases linearly above it upto the upper limit, $ul_{res,i}$ and the function saturates to 1, representative of the maximum growth, for any resource levels above that.\\
For $res \in \{O_2,test\}$
\begin{equation}
  f_i(res) = \begin{cases}
  1 &\text{if } ul_{res,i} \leq res \\
  \frac{res-ll_{res,i}}{ul_{res,i}-ll_{res,i}} &\text{if } ll_{res,i} < res < ul_{res,i} \\
  0 &\text{if } res \leq ll_{res,i} \\
  \end{cases}
  \label{fres_eq}
\end{equation}
\begin{figure}[h]
  \centering
  \includegraphics[width=0.5\textwidth]{f_res}
  \caption{$f_i(res)$}
  \label{fig_fres}
\end{figure}

The ODE for oxygen is given in \autoref{o2_eq}. This involves a term for external production that increase oxygen levels constantly at a rate $p_{O_2}$, a term for uptake by all cells where they decrease oxygen levels at a rate $\mu_{O_2,i}$ and a term for decay where oxygen level decreases at a rate $\lambda_{O_2}$.
\begin{equation}
  \frac{dO_2}{dt} = p_{O_2} - \sum_i \mu_{O_2,i} y_i - \lambda_{O_2} O_2
  \label{o2_eq}
\end{equation}

The ODE for testosterone is given in \autoref{test_eq}. The form is similar to that of oxygen, with the difference being production being done by $T^p$ cells at a rate $p_{test}$ here.
\begin{equation}
  \frac{dtest}{dt} = p_{test}(abi) y_{T^p} - \sum_i \mu_{test,i} y_i - \lambda_{test} test
  \label{test_eq}
\end{equation}

Note that these equations are defined only for positive values of cell count and resource level to be biologically relevant. To mitigate the problem of having a continuous variable for  cell count, $y_i < 1$ is defined as extinction of the cell type $i$ and $y_i = \frac{dy_i}{dt} = 0$ in such a case.

\section{Therapy}
For implementation of therapy, production rate of testosterone and growth rate of the cells are governed by the dose of abiraterone $abi$ and docetaxel $dtx$ respectively as given in \autoref{p_test_dose_eq} and \autoref{r_dose_eq}. Therapy is modelled as a boolean value, where $1$ represents dose at MTD and $0$ represents no dose.
\begin{equation}
  p_{test}(abi) = \begin{cases}
  p_{test,max} &\text{if } abi = 0 \\
  p_{test,min} &\text{if } abi = 1 \\
  \end{cases}
  \label{p_test_dose_eq}
\end{equation}
\begin{equation}
  r_i(dtx) = \begin{cases}
  r_{i,max} &\text{if } dtx = 0 \\
  r_{i,min} &\text{if } dtx = 1 \\
  \end{cases}
  \label{r_dose_eq}
\end{equation}
The dosing scheme for standard-of-care is given in \autoref{dose_soc_eq}. Here, the dose is applied at MTD at all times from the start of the simulation regardless of the population size.\\
For $dose \in \{abi,dtx\}$
\begin{equation}
  dose(x,t) = 1 \quad \forall\ t, x
  \label{dose_soc_eq}
\end{equation}

The dosing scheme for adaptive therapy is given in \autoref{dose_at_eq}. A binary mode of adaptive therapy is considered here, where dose is applied at MTD when the population size exceeds the On threshold and stays on until the population size falls below the Off threshold, after which it is turned off.
\begin{equation}
  dose(x,t) = \begin{cases}
  0 &\text{if } dose(x,t-\Delta t) = 0 \text{ and } x < \text{On} \\
  1 &\text{if } dose(x,t-\Delta t) = 0 \text{ and } x \geq \text{On} \\
  1 &\text{if } dose(x,t-\Delta t) = 1 \text{ and } x > \text{Off} \\
  0 &\text{if } dose(x,t-\Delta t) = 1 \text{ and } x \leq \text{Off} \\
  \end{cases}
  \label{dose_at_eq}
\end{equation}

\section{Constraint equations and parameters from literature}
\autoref{parmtable} gives a brief description of the parameters from the above equations, the values used, and the sources for these values where applicable. Note that all the resource parameters are normalised to ``Tissue levels of that resource" as obtained from the literature sources cited. The cell lines of LNCaP, 22Rv1 and PC3 were considered to correspond to the $T^+$, $T^p$ and $T^-$ cells respectively when obtaining literature values.

Constraint equations given below were used to determine the values of some parameters for which direct sources were not available.\\
\autoref{r_eq} is obtained from solving \autoref{cell_eq} from $N_0$ to $2N_0$ under the assumption that resources are not limiting and $y_i$ is small. This constraint along with doubling time and death rates obtained from literature can be used to get the growth rate.
\begin{equation}
  r_{i,max} = \frac{ln(2)}{\tau_{d,i}} + \delta_i
  \label{r_eq}
\end{equation}
\autoref{K_eq} is obtained from setting \autoref{cell_eq} = 0 under the assumption that equilibrium is reached with only one cell type present and resources are not limited. This constraint along with an assumed equilibrium value of 10000 for the cells, growth and death rate obtained from above can be used to get the maximum carrying capacity for that cell type.
\begin{equation}
  K_{i,max}=\frac{r_{i,max}}{r_{i,max}-\delta_i} y_i^*
  \label{K_eq}
\end{equation}
\autoref{p_o2_eq} is obtained from setting \autoref{o2_eq} = 0 under the assumption that equilibrium is reached with only $T^-$ cell type present. This constraint along with an assumed equilibrium value of 1 for oxygen and 10000 for the cells, and uptake and decay rates from literature can be used to get the production rate of oxygen.
\begin{equation}
  p_{O_2} = \lambda_{O_2} O_2^* + y_i^* \mu_i
  \label{p_o2_eq}
\end{equation}
\autoref{p_test_eq} is obtained from setting \autoref{test_eq} = 0 under the assumption that equilibrium is reached with only $T^p$ cell type present. This constraint along with an assumed equilibrium value of 1 for oxygen and 10000 for the cells, decay rates from literature can be used to get the production rate of testosterone.
\begin{equation}
  p_{test,max} - \mu_{test,T^p} = \frac{test^* \lambda_{test}}{y_{T^p}^*} = 4 \times 10^{-4}
  \label{p_test_eq}
\end{equation}
\autoref{p_test_doseparm_eq} is the same as \autoref{p_test_eq} with a lower equilibrium value of testosterone with abiraterone therapy.
\begin{equation}
  p_{test,min} = \frac{test_{abi}^* \lambda_{test}}{y_{T^p}^*} + \mu_{test,T^p}
  \label{p_test_doseparm_eq}
\end{equation}
\autoref{r_doseparm_eq} is the rearranged version of \autoref{K_eq} with a lower equilibrium value for the cells with docetaxel therapy.
\begin{equation}
  r_{i,min}=\frac{K_{i,max}}{K_{i,max} - y_{i,dtx}^*} \delta_i
  \label{r_doseparm_eq}
\end{equation}

\section{Code Implementation}
The code is written in Python 3 and with dependencies of numpy, scipy, pandas, matplotlib and seaborn libraries. The system of equations were solved numerically by the LSODA algorithm provided by the \texttt{scipy.integrate.ode} function. The code is designed to iterate over the different parameters of a set parallely over multiple threads, however, the actual solver is sequential and single threaded.

The code, at each time step checks if the values are non-negative and sets them to 0 if it is the case. This is since the equations are not defined in these range of values and numerical errors can give rise to negative values. A similar implementation is done for $y_i < 1$.

The source code along with the data is available at the following Github repository: \url{https://www.github.com/harshavardhan-bv/cancer-compe-strat}.
\begin{figure}[h]
  \centering
  \includegraphics[width=0.15\textwidth]{github}
  \caption{QR code for the Github repository}
  \label{github}
\end{figure}

\newpage
\begin{longtable}[c]{|l|p{4.3cm}|c|p{2.3cm}|}

  \hline \multicolumn{1}{|c|}{\textbf{Parameter}} & \multicolumn{1}{c|}{\textbf{Description}} & \multicolumn{1}{c|}{\textbf{Value(s)}} & \multicolumn{1}{c|}{\textbf{Source(s)}}\\ \hline
  \endhead

  \hline \multicolumn{4}{|r|}{{Continued on next page}} \\ \hline
  \endfoot

  \endlastfoot

  $y_i$ & No. of cells of cell type $i$ & N/A & N/A  \\ \hline
  $r_{i,max}$ & Population growth rate of cell type $i$  &
  \begin{tabular}{l|l}
    $T^+$ & $2.84 \times 10^{-3}$ \tiny{min$^{-1}$}\\
    $T^p$ & $2.79 \times 10^{-3}$ \tiny{min$^{-1}$}\\
    $T^-$ & $6.23 \times 10^{-4}$ \tiny{min$^{-1}$}\\
  \end{tabular}
  & \autoref{r_eq} \\ \hline
  $r_{i,min}$ & Population growth rate of cell type $i$ under $dtx$ therapy &
  \begin{tabular}{l|l}
    $T^+$ & $2.55 \times 10^{-3}$ \tiny{min$^{-1}$}\\
    $T^p$ & $2.54 \times 10^{-3}$ \tiny{min$^{-1}$}\\
    $T^-$ & $2.06 \times 10^{-4}$ \tiny{min$^{-1}$}\\
  \end{tabular}
  & \autoref{r_doseparm_eq} \\ \hline
  $\delta_i$  & Population death rate of cell type $i$ &
  \begin{tabular}{l|l}
    $T^+$ & $2.5 \times 10^{-3}$ \tiny{min$^{-1}$}\\
    $T^p$ & $2.5 \times 10^{-3}$ \tiny{min$^{-1}$}\\
    $T^-$ & $1.6 \times 10^{-4}$ \tiny{min$^{-1}$}\\
  \end{tabular}
  & \cite{Jain}  \\ \hline
  $K_{i,max}$ & Maximum Carrying capacity, coming up through the environment/resources &
  \begin{tabular}{l|l}
    $T^+$ & $8.35 \times 10^4$ \\
    $T^p$ & $9.62 \times 10^4$ \\
    $T^-$ & $1.34 \times 10^4$ \\
  \end{tabular}
  & \autoref{K_eq} \\ \hline
  $f_{i,res}$ & Functional dependence of cell type $i$ on resource $res$, normalised to 1 & $f_{T^-,test}=1$ & N/A \\ \hline
  $p_{res}$ & Production rate of resource, either as bulk or by cells &
  \begin{tabular}{l|l}
    $O_2$ & 0.11 \tiny{min$^{-1}$}\\
    $test,max$ & $5 \times 10^{-7}$ \tiny{min$^{-1}$cell$^{-1}$}\\
  \end{tabular}
  & \autoref{p_o2_eq}, \autoref{p_test_eq}\\ \hline
  $p_{test,min}$ & Production rate of $test$ under $abi$ therapy & $1 \times 10^{-7}$ \tiny{min$^{-1}$cell$^{-1}$} & \autoref{p_test_doseparm_eq}\\ \hline
  $\mu_{res,i}$ & Uptake of resource $res$ by cell type $i$ &
  \begin{tabular}{l|l|l}
    $O_2$ & $T^+$ & $1.63 \times 10^{-6}$ \tiny{min$^{-1}$cell$^{-1}$}\\
    & $T^p$ & $1.63 \times 10^{-6}$ \tiny{min$^{-1}$cell$^{-1}$}\\
    & $T^-$ & $1.04 \times 10^{-6}$ \tiny{min$^{-1}$cell$^{-1}$}\\ \hline
    $test$ & $T^+$ & $2.34 \times 10^{-8}$ \tiny{min$^{-1}$cell$^{-1}$}\\
    & $T^p$ & $6.00 \times 10^{-8}$ \tiny{min$^{-1}$cell$^{-1}$}\\
    & $T^-$ & 0 \tiny{min$^{-1}$cell$^{-1}$}\\
  \end{tabular}
  & \cite{HailJr}, \autoref{p_test_eq}\\ \hline
  $\lambda_{res}$ & Decay rate of resource $res$ &
  \begin{tabular}{l|l}
    $O_2$ & 0.100 \tiny{min$^{-1}$}\\
    $test$ & 0.004 \tiny{min$^{-1}$}\\
  \end{tabular}
  & \cite{Jain}\\ \hline
  $ll_{res,i}$ & Lower limit/threshold level of resource $res$ for carrying capacity of cell type $i$ & $\in [0,1]$ & N/A \\ \hline
  $ul_{res,i}$ & Upper limit/saturation level of resource $res$ for carrying capacity of cell type $i$ & $\in [0,1]$ & N/A \\ \hline
  \multicolumn{4}{|c|}{Supplementary Parameters}\\ \hline
  $\tau_d$  & Doubling time of cell type $i$ &
  \begin{tabular}{l|l}
    $T^+$ & $34$ \tiny{hr} \\
    $T^p$ & $40$ \tiny{hr} \\
    $T^-$ & $25$ \tiny{hr} \\
  \end{tabular}
  & \cite{atcc} \\ \hline
  $y_i^*$ & Equilibrium value of cell number in absence of competition & 10000 & assumed \\ \hline
  $y_{i,dtx}^*$ & Equilibrium value of cell number in absence of competition under $dtx$ therapy &
  \begin{tabular}{l|l}
    $T^+$ & $0.30 \times y_i^*$ \\
    $T^p$ & $0.30 \times y_i^*$ \\
    $T^-$ & $0.15 \times y_i^*$ \\
  \end{tabular}
  & \cite{Morikawa} \\ \hline
  $res^*$ & Equilibrium/Tissue levels of resource with one cell type present &
  \begin{tabular}{l|l}
    $O_2$    & 2.5 \tiny{mmHg}          \\
    $test$   & 3.74 \tiny{pmol/g tissue}\\
  \end{tabular}
  & \cite{Steward},\cite{Titus} \\ \hline
  $test_{abi}^*$ & Equilibrium/Tissue levels of testosterone with only $T^p$ cell type present under $abi$ therapy & $0.1 \times test^*$ & \cite{Acharya} \\ \hline

  \caption{Table of all parameters}
  \label{parmtable}\\
\end{longtable}


\section{Appendix\label{sec:appendix}}
\subsection{Notations}
We follow the ZOGY paper symbol notations. Frequency space quantities are
marked with \(\hat{\ }\), complex conjugation is marked by
\(\overline{x}\). Pixels of images are referred as functions
(\Cref{eq:img_func}). Expectation value of random variables are marked by
\(\langle\ \rangle\).
%
\par We use the terms \emph{image space} and \emph{Fourier- or frequency
  space} to refer to the discrete Fourier transform of images. \emph{Pixels}
may refer to either space depending on the context.
\begin{align}
x &= \{x(0), x(1), ... , x(n) \},\ x(n) \in \mathbb{R}\\
\hat{x} &= \{\hat{x}(0), \hat{x}(1), ... , \hat{x}(k) \},\ \hat{x}(k) \in
\mathbb{C}\\
\label{eq:img_func}
\end{align}
%
\subsection{Parseval theorem\label{sec:parseval}}
The Parseval theorem states that the integral (sum) of absolute
squares in image and frequency space are equal. In DFT form:
\begin{equation}
  \sum_i \abs{x_i}^2 = \frac{1}{N} \sum_k \abs{\hat{x}_k}^2\label{eq:Parseval}
\end{equation}
%
\subsection{Floating point values\label{sec:floating_point}}
The machine \emph{epsilon} is the smallest positive floating point value
where \(1 + \varepsilon \neq 1\). This is \(\approx 1e-16\) for double
precision.
%
\par The machine \emph{tiny} is the smallest positive floating point value
where the significand does not start with leading zeroes but the exponent is
the smallest representable. Going below this value the floating point number
looses significant digits and eventually rounds to exact zero. About
\(\mathrm{epsilon}\cdot\mathrm{tiny} = 0\).
%
\par Underflow to zero occurs around the order of the floating-point
\emph{tiny} value, we found, however, that this never practically
happens. In all our practical PSF transformation cases FFT values
cannot go a few orders below the floating-point \emph{epsilon} that is
several orders higher than the \emph{tiny} limit. This is
understandable if we consider that every pixel is a result of addition
operations, where the number of terms roughly equals to the number of
pixels in the image. As the PSFs are normalized, the zero frequency
value is always 1, which approximately sets the exponent of these
floating point values.
%
\par Furthermore, we usually zero pad a small PSF image to a larger image
size that creates a window function effect in the padded image. The
transformed image, therefore, have long oscillating tails in frequency space
and we found that all pixel (absolute) values remain a few orders even above
the epsilon threshold.
%
\subsection{Complex random variables}
%
\begin{equation}
\langle Z\rangle = \langle\Re(Z)\rangle + i\langle\Im(Z)\rangle
\end{equation}
%
\begin{equation}
\langle \bar{Z}\rangle = \overline{\langle Z\rangle}
\end{equation}
%
\newcommand{\Var}{\mathrm{Var}}
%
The variance and covariance of a complex random variable are defined as:
\begin{equation}
\operatorname{Var}(Z) \in \mathbb{R} \equiv \langle\abs{Z-\langle Z \rangle}^2 \rangle =
\langle\abs{Z}^2\rangle - \abs{\langle Z \rangle}^2
\end{equation}
%
\begin{align}
\operatorname{Cov}(X, Y) &\equiv \left\langle\left(X - \langle X \rangle\right)
\overline{\left(Y - \langle Y \rangle\right)} \right\rangle
= \langle X\bar{Y} \rangle - \langle X \rangle \overline{\langle Y \rangle} \\
\operatorname{Cov}(X, X) &= \operatorname{Var}(X)
\end{align}
%
\subsection{Discrete Fourier transformation normalization convention}
\par There is a freedom how normalization factors are placed in the
forward and inverse Fourier transforms.  This scales the individual
values of frequency components compared to corresponding pixel space
values. Usually, we do not need to worry about these scalings as the
forward and inverse operation factors cancel out. However, certain
frequency space relations change in their form if the normalization
convention changes, most importantly for us, the expression of the
convolution theorem changes.
%
The definition of DFT usually has the following normalization convention:
\begin{equation}
\hat{X}(k) = \mathcal{F}[x](k) \equiv \sum_n x(n) e^{-i\frac{2\pi}{N}k\cdot n}
\end{equation}
%
\begin{equation}
x(n) = \mathcal{F}^{-1}[\hat{x}](n) \equiv \frac{1}{N}\sum_k \hat{x}(k)
  e^{i\frac{2\pi}{N}n\cdot k}
\end{equation}
In this convention, the convolution theorem (and its dual) looks like:
\begin{equation}
\mathcal{F}[x \otimes y] =  \hat{x} \cdot \hat{y}
\end{equation}
\begin{equation}
\mathcal{F}[x\cdot y] = \frac{1}{N} \hat{x} \otimes \hat{y}
\end{equation}
Also:
\begin{equation}
\mathcal{F}[x](0) = \sum_n x(n)
\label{eq:X0sum}
\end{equation}
These relations change with factors of $\sqrt{N}$ if the transform
normalization changes. We must be sure that the correct convention is used
by numpy. This is the default as of v1.18.
%
\subsection{Noise variance properties in frequency space\label{sec:noise_freq_space}}
%
\par Let's take a look at the covariance of the Fourier transform of zero
expectation value pixels The complex covariance can be written as:
\begin{equation}
\begin{split}
\left\langle \hat{x}(k) \overline{\hat{x}(j)} \right\rangle =
\left\langle \sum_{n=0}^{N-1} x(n) e^{-i\frac{2\pi}{N}kn}
 \sum_{l=0}^{N-1} \overline{x(l)} e^{i\frac{2\pi}{N}jl} \right\rangle = \\
\sum_{n,l=0}^{N-1} \left\langle x(n)\overline{x(l)}\right\rangle e^{-i\frac{2\pi}{N}(kn - jl)} =
\sum_{n=0}^{N-1} \sigma(n)^2 e^{-i\frac{2\pi}{N}(k-j)}
\label{eq:freq_cov}
\end{split}
\end{equation}
%
\par If \(k=j\), we get the variance at each frequency. From the last
expression in \Cref{eq:freq_cov}, we can see that the variance is the same
at all frequency and it is the sum of the individual pixel
variances. Considering the normalization in the forward and inverse Fourier
transformation, we can think of this as the average of the individual pixel
variances, too.
%
\par This implies that using the average value of the variance plane as the
variance in frequency space is actually not an approximation but the exact
value.
%
\par If \(k\neq j\), but the individual pixel variances are equal, then the
phase factors in \Cref{eq:freq_cov} average out and we get that the
covariance in frequency space is zero between different frequencies. As a
similar expression and argument can be written for the pseudo-covariance, we
receive that any two different frequencies are uncorrelated. This is the
well-known relation that the Fourier transform of white noise is white noise. If
\(\sigma_n\)-s are not equal however, the phase factors won't average to
zero. Spatial variations of pixel noise introduce correlation in frequency
space noise. The correlation in frequency space encodes the spatial
distribution of \(\sigma_n\) values in image space.
%
\par We note that this is the case if we add zero padding to the
image, because the zero padding can be seen as pixels with zero sigma
noise. Also, if we change the correlation between frequencies by
multiplying with frequency-dependent factors, this implies a spatial
change of noise in image space, following the convolution
theorem.
%
\par Finally, let's consider a white noise image that got convolved by a kernel
image. From the convolution theorem, we get that in frequency space the
variance becomes frequency-dependent, but different frequencies remain still
uncorrelated.
%
\par We summarize these noise transformation properties in
\Cref{tab:freq_noise}, noting the duality of variances values and
correlation between pixels in image and frequency spaces. Our understanding
is that correlated noise in image space can be decorrelated by scaling in
frequency space so that all components have the same variance. This is one
of the key ideas in the ZOGY difference image construction, that one square
root of the likelihood variance weight can be assigned to the proper
difference image, so that its noise gets whitened (decorrelated). (The other
square root is part of the difference image PSF.)
%
\par The change of the spatial distribution of pixel sigmas follows the overall
convolution (like \(c_n, c_r\)) of the original uncorrelated images. If
furthermore, per pixel variances are uniform across the image, then the
whitening restores uncorrelated white noise across the image.
%
\begin{table}[h]
\begin{center}
\begin{tabular}{c|c}
  image space & frequency space \\
  \hline
  white noise & white noise \\
  \parbox{3in}{different variance values in uncorrelated pixels} &
  \parbox{3in}{same average variance at all frequencies
    but correlation in noise between different
    frequencies}
  \\
  \parbox{3in}{same variance but correlated pixel noise due to
  convolution operation} & \parbox{3in}{different variances at frequencies but
                 noise between frequencies are still uncorrelated} \\
\end{tabular}
\end{center}
\caption{\label{tab:freq_noise}Summary of image space and frequency space
  noise properties.}
\end{table}
%
\subsection{The resolution of DFT space\label{sec:dft}}
\par Finite DFT transforms N pixel into N pixel in frequency space. The
covered frequency range always goes from -1/2 through zero to \(\frac{1}{2}
\frac{1}{\mathrm{px}}\) frequencies but the resolution depends on the number
of input pixels (\Cref{fig:dft_sampling}). As conservation of information,
the N resulting frequencies can distinguish exactly N spatial positions. The
same concept is described by the interpretation that finite DFT always sees
the input as if it were periodic, giving the same result as if the input
were repeating in every N pixels. This also means that when we make a
frequency space manipulation we must see not only the input image or kernel
but the results as well to be periodic back in image
space.\footnote{\Cref{fig:dft_sampling} source:
  \texttt{https://en.wikipedia.org/wiki/File:Fourier\_transform,\_Fourier\_series,\_DTFT,\_DFT.svg}}
\begin{figure}[h]
\begin{center}
\includegraphics[width=5.5in]{fig/dft_sampling.pdf}
\end{center}
\caption{\label{fig:dft_sampling}Overview of sampling and periodicity
  effects in frequency space. Given the Fourier transform of a
  function (top left), sampling it every T time may cause a change in
  the frequency space values according to the sampling theorem (bottom
  left). This is called aliasing, in the bottom left panel, the
  minimum value shown is different from the top left panel. If the
  function is periodic, the frequency space values reduced to discrete
  values as well (top right). DFT/FFT combines the two concepts
  (bottom right). Considering unit pixel size, the FFT space always
  goes to 1/2 frequency with a resolution of 1/N. Figure source:
  Wikipedia:Discrete Fourier transform}
\end{figure}
%
\subsection{Zero padding in FFT frequency space\label{sec:zeropadS}}
%
\par While in image space convolution operations can have their own
way of handling edges, in Fourier space, multiplication always
corresponds to the circular boundary conditions in image space.  If we
want to implement a convolution without circular boundary
conditions that we want to calculate in frequency space,
we need to pad the images by extra edge pixels to avoid the
reappearance of values from the opposite side.
As we saw in \Cref{sec:patterns}, numerical artifacts in the matching
kernels cannot be bounded well in image space, they fill the full area
independently of the padding size. Therefore we cannot practically perform
the kernel matching convolutions in image space.
%
\par In the previous section, we also saw that a zero-padding violates one
of the ZOGY assumptions: that frequencies are independent and log
likelihoods can be calculated from them by simple addition. Is this a
significant inaccuracy in the score image?
%
\par Let's assume for a moment that the image background is extended in a
sourceless way with white noise. In this case, all the assumptions of the
detection statistics derivation hold thus we get \Cref{eq:Shat}. This is a
usual convolution expression in image space and at any pixel its value
depends only from the half \(P_d\) size neighboring area. If \(P_d\)
significant values are located in about the same square size as the original
PSF size then the affected edge area also remains the same. If the PSF
contains edges, however, \(P_d\) can be significantly bigger in size. Zero
padding adds pixels to an image that, from a noise model perspective, all
have a noise variance of zero. By padding the input images with zeroes, the
pixel variance of the difference image and, in a smaller edge region, the
score image variance will decrease. It is unclear whether scaling the score
image \(S\) with its variance plane satisfactorily corrects for this
effect. Nevertheless, this correction term is listed as a suggested
rescaling of the score image in the ZOGY paper Section 3.3. Beside this
correctional approach, we propose the implementation of padding with the
model white noise instead of constant zeroes in the future.
%
\subsection{Sampling}
\par It can be shown that Gaussians with \(0.95 < \sigma\), are well
sampled in the sense that \(3\sigma\) of their Fourier
transform Gaussian fit up to the 1/2 frequency limit. For
\(5\sigma\) fit, this is \(1.59 < \sigma\).


\documentclass{homework}
\course{Math 5522H}
\author{Alex Li}
\input{preamble}

\DeclareMathOperator{\polylog}{Li}
\newcommand{\dilog}{\polylog_2}

\begin{document}
\maketitle

\begin{inspiration}
    Music is nothing but ratios and harmonic math, anyways.
    \byline{Andrew Sega}
    \end{inspiration}

    With this being a ``short'' week because of the instructional break,
    this problem set is concomitantly shorter.

    \section{Terminology}

    \begin{problem}
      What is a harmonic function?
      \end{problem}
      \begin{solution}
      Let $U$ be an open subset of $\C$. A function $f:U \to \R$ is real harmonic if $f\in C^2$ and $\Delta f = 0$.
      \end{solution}
      \begin{problem}
        Define the term \textbf{harmonic conjugate}.  (Recall \ref{harmonic-conjugate}.)
        \end{problem}
        \begin{solution}
        A harmonic conjugate of a harmonic funcion $f$ is a function $g$ such that $f+ig$ is holomorphic.
        \end{solution}

        \section{Numericals}

        \begin{problem}\label{relate-fourier-and-taylor-series}Let $S^1 := \{(x,y) \in \R^2 : x^2 + y^2 = 1 \}$ and $D_1(0) := \{ (x,y) \in \R^2 : x^2 + y^2 \leq 1 \}$.  Find a continuous function $F : D_1(0) \to \R$ that is harmonic on the interior of $D_1(0)$ and that extends
          $f : S^1 \to \R$ given by
           \[
              f(\cos \theta,\sin \theta) = \sum_{k=0}^N \left(c_k \, \cos \left( k\theta \right) + s_k \, \sin \left( k \theta \right) \right).
               \]
                (This problem encourages you to relate Fourier series and Taylor series.)
                \end{problem}
                \begin{solution}
                Extend $f$ to the disk by the following equation:
                \[
                F(r, \theta) = f(\theta)r^{k}
                \]
                On the open disk, $r=1$ and so the additional term we multiply by is $r^1=1$, and thus this function agrees with $f$ on the edges of the disk. As a sum and product of infinitely differentiable functions, it is $C^2$.

                Checking that the laplacian $F_{xx} + F_{yy} = 0$ is equivalent to checking the following in polar coordinates:
                \begin{align*}
                F_{rr} +  \frac{F_r}{r} + \frac{F_{\theta\theta}}{r^2} &= 0\\
                f(\theta)k(k-1)r^{k-2} +  \frac{f(\theta)kr^{k-1}}{r} + \frac{(-f(\theta))r^k}{r^2} &= 0\\
                r^{k-2}(k(k-1) +  k - k^2) &= 0\\
                r^{k-2}\cdot 0 &= 0
                \end{align*}
                Thus this function is harmonic on the interior of $D$.
                \end{solution}
                \section{Exploration}

                \begin{problem}
                  Recall \ref{where-converge-one-over-n}.  Consider the power series for the \textbf{dilogarithm} function,
                    \[
                        \dilog(z) = \sum_{n=1}^\infty \frac{z^n}{n^2}.
                          \]
                            What is its radius $r$ of convergence?  Where on the boundary of
                              $B_r(0)$ does this series converge?  (Note that there is no pole on
                                the boundary; not every singularity is a pole!)
                                \end{problem}
                                \begin{solution}
                                The radius of convergence is 1: if $r > 1$, then
                                \[\abs{Li_2(r)} = \sum_1^\infty \frac{r^n}{n^2}\]
                                But as $n\to\infty$,
                                \[
                                \lim_{n\to \infty} \frac{r^n}{n^2} = \lim_{n\to \infty} \frac{nr^{n-1}}{2n} =  \lim_{n\to \infty} n(n-1)r^{n-2} = \infty,
                                \]
                                so the terms grow arbitrarily large, and thus the sum diverges.

                                On the other hand, if $r\leq 1$, then
                                \[\abs{Li_2(z)} \leq \sum_{n=1}^\infty \frac{1}{n^2} = \frac{\pi^2}{6},\]
                                so the sum converges absolutely and thus the sum converges everywhere on the closed unit ball of radius 1, and nowhere outside of it.
                                %TODO This seems too easy?
                                \end{solution}
                                \begin{problem}\label{laplacian-via-wirtinger}Consider an open set
                                  $U \subset \C$ and a holomorphic function $f : U \to \C$.  Write
                                    the \textbf{Laplacian}
                                      \[
                                          \Delta := \frac{\partial^2}{\partial x^2} + \frac{\partial^2}{\partial y^2}
                                            \]
                                              in terms of the mixed Wirtinger derivative
                                                $\displaystyle\frac{\partial^2}{\partial z \partial \conj{z}}$.
                                                \end{problem}
                                                \begin{solution}
                                                \begin{align*}
                                                \pfrac{}{z}\pfrac{}{\conj{z}} &= \frac{1}{2}(\pfrac{}{x} - i\pfrac{}{y})\frac{1}{2}(\pfrac{}{x} + i\pfrac{}{y})\\
                                                &= \frac{1}{4}(\ppfrac{}{x} + \ppfrac{}{y}) = \frac{\Delta}{4}
                                                \end{align*}
                                                \end{solution}

                                                \begin{problem}\label{composition-holomorphic-harmonic}Consider open
                                                  sets $U, V \subset \C$ and a holomorphic function $f : U \to V$ and
                                                    a harmonic function $g : V \to \R$.  Is the composition $g \circ f$
                                                      a harmonic function on $V$?
                                                      \end{problem}
                                                      \begin{solution}
                                                      Choose real valued functions $u, v:U \to \R$ such that $f(z) = u(z) + iv(z)$. Let $g_x$ be the derivative of $g$ in the first coordinate and $g_y$ the second.
                                                      \begin{align*}
                                                      \ppfrac{g(u, v)}{x} &= \pfrac{}{x}\left( g_x(u, v)(u_x + v_x) \right)\\
                                                      &=  g_{xx}(u, v)(u_x + v_x)^2 + g_x(u, v)(u_{xx} + v_{xx})\\
                                                      &=  g_{xx}(u, v)(u_x - u_y)^2 \color{purple} \qquad \text{Cauchy Riemann Equations}
                                                      \end{align*}
                                                      Let's do the same for the y derivative
                                                      \begin{align*}
                                                      \ppfrac{g(u, v)}{y} &= \pfrac{}{y}\left( g_y(u, v)(u_y + v_y) \right)\\
                                                      &=  g_{yy}(u, v)(u_y + v_y)^2 + g_x(u, v)(u_{yy} + v_{yy})\\
                                                      &=  g_{yy}(u, v)(u_y - u_x)^2 \color{purple} \qquad \text{Cauchy Riemann Equations}
                                                      \end{align*}
                                                      Then $g\circ f$ is harmonic since,
                                                      \begin{align*}
                                                          (\ppfrac{}{y}+\ppfrac{}{x})g\circ f = (g_{xx} + g_{yy})(u, v)(u_x - u_y)**2 = 0
                                                          \end{align*}
                                                          (using the fact that $g$ is harmonic).
                                                          \end{solution}
                                                          \section{Prove or Disprove and Salvage if Possible}
                                                          \begin{problem} % wrong sign
                                                            If $f : U \to \R$ is a harmonic function on an open set $U \subset \R^2$, then
                                                              \[
                                                                  F(x+iy) := f_x(x,y) + i f_y(x,y)
                                                                    \]
                                                                      defines a holomorphic function $F : U \to \C$, regarding $U$ as an
                                                                        open subset of $\C$.
                                                                        \end{problem}
                                                                        \begin{solution}
                                                                        % Let $f = \frac{1}{z}$ on $U=\C/\{0\}$. Since $f$ is holomorphic, it's twice differentiable with $f_{xx}(z) = f''(x+iy) = -f_{yy}(z)$, so $f_{xx} + f_{yy} = 0$ and $f$ is harmonic.
                                                                        No, take $f=\Re(z^2) = x^2 - y^2$. This is harmonic as it is the real part of a holomorphic function. Then $F = 2x - 2yi = 2\conj{z}$, and this is not holomorphic.

                                                                        Instead define
                                                                          \[
                                                                              F_2(x+iy) := f_x(x,y) - i f_y(x,y)
                                                                                \]
                                                                                We can see that $F_2$ satisfies the Cauchy-Riemann equations: Let $u=f_x(x,y)$ and $v=f_y(x,y)$ so that $F=u-iv$. Then
                                                                                \begin{gather*}
                                                                                u_x = f_{xx}(x, y) = -f_{yy}(x, y) = v_y\\
                                                                                u_y = f_{xy}(x, y) = f_{yx}(x, y) = -v_x
                                                                                \end{gather*}
                                                                                Since $f$ is a harmonic function, $F_2$ is twice differentiable and this is more than enough to conclude that it is in fact holomorphic.
                                                                                \end{solution}
                                                                                \begin{problem}\label{maximum-principle}For an open set
                                                                                $U \subset \R^2$ and a harmonic function $f : U \to \R$, the
                                                                                function $f$ does not achieve a maximum. % nonconstant missing
                                                                                \end{problem}
                                                                                \begin{solution}
                                                                                False, take $f=0$. It's true if $f$ is not constant and $U$ is connected.

                                                                                Let $g$ be a holomorphic function with real part $f$.
                                                                                Suppose that $f$ achieves a maximum at the point $z$.
                                                                                Then consider a curve $\gamma(t) = re^{it} + z$ from 0 to $2\pi$ and apply Cauchy's integral formula:
                                                                                \begin{align*}
                                                                                f(z) &= \Re\left(\frac{1}{2\pi i}\int_\gamma \frac{g(w)}{w-z}dw\right)\\
                                                                                &= \Re\left(\frac{1}{2\pi i}\int_0^{2\pi} \frac{g(z + re^{i\theta})ire^{i\theta}}{re^{i\theta}}d\theta\right)\\
                                                                                &= \frac{1}{2\pi }\int_0^{2\pi} f(z + re^{i\theta})d\theta
                                                                                \end{align*}
                                                                                Subtracting $f(z)$, we see that
                                                                                \begin{align*}
                                                                                0 = \frac{1}{2\pi }\int_0^{2\pi} f(w) - f(z) d\theta
                                                                                \end{align*}
                                                                                Since $f(z)$ is the maximum value, the integrand is never positive and by continuity of $f$ it must always be 0. Since this is true for all circles centered at $z$, the set of points which achieve the maximum value of $f$ is open, and the complement of this set is the preimage of the open set $\R/\{f(z)\}$, so it is open. Since $U$ is connected, $f$ is constna
                                                                                \end{solution}
                                                                                \begin{problem}\label{universal-taylor-series}Suppose
                                                                                $\displaystyle\sum_{n=0}^\infty a_n z^n$ is a power series with
                                                                                radius of convergence 1.  We say that series is \textbf{universal}
                                                                                if, for every $\epsilon > 0$ and $\delta > 0$, for every closed disk
                                                                                $D_r(a)$ with $\abs{a-1} > r$, for every holomorphic function
                                                                                $f : B_{r + \delta}(a) \to \C$, there exists $N$ so that
                                                                                \[
                                                                                \sup_{z \in D_r(a)} \abs{ f(z) - \sum_{n=0}^N a_n z^n } < \epsilon.
                                                                                \]

                                                                                There is a universal power series.
                                                                                \end{problem}
                                                                                \begin{solution}
                                                                                This is super false, since the power series isn't neccessarily the power series of $f$. For example, take $a_n=1$ and $f=0$, and consider the disk of radius .2 around the point $0$. Then $\sum_{n=0}^N a_nz^n = 1 + \sum_{n=1}^N 0^n = 1$ for any $N$ but $f(0) = 0$.

                                                                                Let's choose $f$ first, and let the power series be the taylor series of $f$ at the point $0$. We can write it out using Cauchy's integral formula and a positively oriented curve $\gamma$ around the circle of radius $r+\delta$.

                                                                                \begin{align}\label{Taylor_Series_0_for_f}
                                                                                f(z) = \sum_{n=0}^N \int_\gamma \frac{f(w) dw}{w^{n+1}}z^n
                                                                                \end{align}

                                                                                Now we just really need to show that this function approaches $f(z)$. We can apply Cauchy's integral formula to $f$ in a small circle $\gamma_2$ centered at $z$ and contained in the circle $\gamma$ .
                                                                                \begin{align}\label{Cauchys_Integral_Formula_for_f}
                                                                                f(z) &= \int_{\gamma_2} \frac{f(w) dw}{w - z}
                                                                                \end{align}
                                                                                In fact, we can replace $\gamma_2$ with $\gamma$ since the two curves are homotopic on the set $\C\setminus z$ where the function $\frac{f(w)}{w-z}$ is holomorphic. Thus we need to show that difference of the RHS of equations \ref{Taylor_Series_0_for_f} and \ref{Cauchys_Integral_Formula_for_f} is 0.

                                                                                \begin{align*}
                                                                                \int_{\gamma} \frac{f(w) dw}{w - z} - \sum_{n=0}^N \int_\gamma \frac{f(w) dw}{w^{n+1}}z^n &= \int_\gamma f(w)\left( \frac{1}{w-z} - \sum_{n=0}^n \frac{z^n}{w^{n+1}}\right) dw\\
                                                                                &= \int_\gamma f(w)\left( \frac{1}{w-z} - \frac{1/w}{1-\frac{z}{w}}\right) dw\\
                                                                                &= \int_\gamma 0 dw = 0
                                                                                \end{align*}
                                                                                \end{solution}
                                                                                \end{document}


\section*{Summary of Section 1}
\begin{itemize}
  \item Addition in $\bbz/100$ is defined by the formula
  \begin{equation*}
    \tens{a_1}\units{b_1} + \tens{a_2}\units{b_2}
    =
    \tens{a_1 + a_2 + c(b_1, b_2)}\units{b_1 + b_2}
  \end{equation*}
  where $c: \bbz/10 \times \bbz/10 \rightarrow \bbz/10$ is the ``carry'' function.
  Unravelling the axioms of abelian groups we see that $c$ satisfies the following three identities:
  \begin{enumerate}
    \item $c(b_1, 0) = 0 = c(0,b_1)$,
    \item $c(b_1, b_2) = c(b_2, b_1)$,
    \item $c(b_1, b_2) + c(b_1 + b_2, b_3) = c(b_1 , b_2 + b_3) + c(b_2, b_3)$.
  \end{enumerate}
  Such a function $c$ is called a \emph{normalized, symmetric, 2-cocycle}.

  \item We now flip the tables and ``define'' an addition on the set of 2-digit numbers by the formula $\tens{a_1}\units{b_1} + \tens{a_2}\units{b_2}
  =
  \tens{a_1 + a_2 + c(b_1, b_2)}\units{b_1 + b_2}$ where $c$ is any normalized, symmetric, 2-cocycle.

  \item Examples:
    \begin{enumerate}
      \item $c(b_1, b_2) = \left \lfloor \dfrac{b_1 + b_2}{10}  \right \rfloor $ defines the standard addition on $\bbz/100$.
      \item $c(b_1, b_2) = 0$ defines the addition in which the set of 2-digit numbers becomes $\bbz/10 \times \bbz/10$.
      \item $c(b_1, b_2) = k\left \lfloor \dfrac{b_1 + b_2}{10}  \right \rfloor$ for any integer $k$ defines an addition on the set of 2-digit numbers, the isomorphism class of the resulting abelian group depends on $k \mod 10$.
      \item $c(b_1, b_2) = b_1 b_2$ defines an addition on the set of 2-digit numbers, and resulting group is $\bbz/20 \times \bbz/5$.
    \end{enumerate}
\end{itemize}

There are exactly 4 isomorphism classes of abelian groups of order 100:
  \begin{equation*}
    \bbz/100,\quad \bbz/50 \times \bbz/2, \quad \bbz/20 \times \bbz/5, \quad \bbz/10 \times \bbz/10.
  \end{equation*}
\begin{q*}
  How do we know which abelian group is being created by using a particular addition?
\end{q*}
\begin{proof}[Answer]
  The four groups $\bbz/100$, $\bbz/50 \times \bbz/2$, $\bbz/20 \times \bbz/5$, $\bbz/10$ can be differentiated in the following way:
  $\bbz/100$ contains an element of order 100,
  $\bbz/50 \times \bbz/2$ contains an element of order 50 but not of order 100,
  $\bbz/20 \times \bbz/5$ contains an element of order 20 but not of order 100,
  the order of every element of $\bbz/10 \times \bbz/10$ is at most 10.
\end{proof}


\subsection{Performance Measures} \label{performance_measures}

Since our proposed sliding window filter is tested on time series streams that contain various different gestures, we need to treat the described online gesture recognition challenge as multi-class problem.
Common performance measures for multi-class problems are $Precision_{\mu}$, $Recall_{\mu}$ and $F_{\beta}score_{\mu}$ \cite{sokolova2009systematic}:

\begin{equation*}
    Precision_{\mu} = {\sum \limits_{i=1}^{l} tp_i}  \bigg/  {\sum \limits_{i=1}^{l} (tp_i + fp_i)}
\end{equation*}
\begin{equation*}
    Recall_{\mu} = {\sum \limits_{i=1}^{l} tp_i} \bigg/{\sum \limits_{i=1}^{l} (tp_i + fn_i)}
\end{equation*}
\begin{equation*}
    F_{\beta}score_{\mu} = {(\beta^2 + 1)Precision_{\mu} Recall_{\mu}} \bigg/ {\beta^2 Precision_{\mu} + Recall_{\mu}}
\end{equation*}

where $\beta$ is usually set to one and $l$ denotes the number of classes that require separate computation of true positives ($tp$), false positives ($fp$), and false negatives ($fn$).
These multi-class performance measures allow us to compare and rank the results for different parameter settings.
For our evaluation we employ the $F_{1}score_{\mu}$, which weights $Precision_{\mu}$ and $Recall_{\mu}$ equally.


\documentclass{article}

\usepackage{inconsolata}
\usepackage{microtype}

\usepackage{flix}

\lstset{language=flix}

\begin{document}

\section{Algebraic Data Types and Pattern Matching}

\begin{lstlisting}
/// An algebraic data type for shapes.
enum Shape {
    case Circle(Int32),          // circle radius
    case Square(Int32),          // side length
    case Rectangle(Int32, Int32) // height and width
}

/// Computes the area of the given shape using
/// pattern matching and basic arithmetic.
def area(s: Shape): Int32 = match s {
    case Circle(r)       => 3 * (r * r)
    case Square(w)       => w * w
    case Rectangle(h, w) => h * w
}

// Computes the area of a 2 by 4.
def main(): Int = area(Rectangle(2, 4))
\end{lstlisting}

\section{Lists and List Processing}

\begin{lstlisting}
/// In Flix, as in many functional programming languages,
/// lists are the bread and butter.

/// We can easily construct a list:
def aList(): List[Int32] = 1 :: 2 :: 3 :: Nil

/// We can easily append two lists:
def bList(): List[Int32] = aList() ::: aList()

/// We can use pattern matching to take a list apart:
def length[a](l: List[a]): Int = match l {
    case Nil     => 0
    case x :: xs => 1 + length(xs)
}

/// The Flix library has extensive support for lists:
def main(): Bool =
    let l1 = List.range(0, 10);
    let l2 = List.intersperse(42, l1);
    let l3 = List.map(x -> x :: x :: Nil, l2);
    let l4 = List.flatten(l3);
    List.exists(x -> x == 0, l4)
\end{lstlisting}

\end{document}