\par
\section{Driver programs found in the {\tt Misc} directory}
\label{section:Misc:drivers}
\par
This section contains brief descriptions of the driver programs.
\par
%=======================================================================
\begin{enumerate}
%-----------------------------------------------------------------------
\item
\begin{verbatim}
testNDperm msglvl msgFile n1 n2 n3 outPermFile
\end{verbatim}
This driver program generates a {\tt Perm} object that contains a
nested dissection ordering for a {\tt n1 x n2 x n3} regular grid.
\par
\begin{itemize}
\item
The {\tt msglvl} parameter determines the amount of output ---
taking {\tt msglvl >= 3} means the {\tt Perm} object is written
to the output file.
\item
The {\tt msgFile} parameter determines the message file --- if {\tt
msgFile} is {\tt stdout}, then the message file is {\it stdout},
otherwise a file is opened with {\it append} status to receive any
output data.
\item
{\tt n1} is the number of points in the first direction.
\item
{\tt n2} is the number of points in the second direction.
\item
{\tt n3} is the number of points in the third direction.
\item
The {\tt outPermFile} parameter is the output file for the {\tt Perm}
object.
If {\tt outPermFile} is {\tt none} then the {\tt Perm} object is not
written to a file.
Otherwise, the {\tt Perm\_writeToFile()} method is called to write
the object to
a formatted file (if {\tt outPermFile} is of the form {\tt *.permf}),
or
a binary file (if {\tt outPermFile} is of the form {\tt *.permb}).
\end{itemize}
%-----------------------------------------------------------------------
\item
\begin{verbatim}
testOrderViaMMD msglvl msgFile GraphFile seed ETreeFile
\end{verbatim}
This program reads in a {\tt Graph} object from a file and computes
a multiple minimum degree ordering of the graph.
\par
\begin{itemize}
\item
The {\tt msglvl} parameter determines the amount of output ---
taking {\tt msglvl >= 3} means the {\tt Perm} object is written
to the output file.
\item
The {\tt msgFile} parameter determines the message file --- if {\tt
msgFile} is {\tt stdout}, then the message file is {\it stdout},
otherwise a file is opened with {\it append} status to receive any
output data.
\item
The {\tt inGraphFile} parameter is the input file for the {\tt Graph}
object. It must be of the form {\tt *.graphf} or {\tt *.graphb}.
The {\tt Graph} object is read from the file via the
{\tt Graph\_readFromFile()} method.
\item
The {\tt seed} parameter is a random number seed.
\item
The {\tt ETreeFile} parameter is the output file for the {\tt ETree}
object.
If {\tt ETreeFile} is {\tt none} then the {\tt ETree} object is not
written to a file.
Otherwise, the {\tt ETree\_writeToFile()} method is called to write
the object to
a formatted file (if {\tt ETreeFile} is of the form {\tt *.etreef}),
or
a binary file (if {\tt ETreeFile} is of the form {\tt *.etreeb}).
\end{itemize}
%-----------------------------------------------------------------------
\item
\begin{verbatim}
testOrderViaND msglvl msgFile GraphFile maxdomainsize seed ETreeFile
\end{verbatim}
This program reads in a {\tt Graph} object from a file and computes
a generalized nested dissection ordering of the graph.
\par
\begin{itemize}
\item
The {\tt msglvl} parameter determines the amount of output ---
taking {\tt msglvl >= 3} means the {\tt Perm} object is written
to the output file.
\item
The {\tt msgFile} parameter determines the message file --- if {\tt
msgFile} is {\tt stdout}, then the message file is {\it stdout},
otherwise a file is opened with {\it append} status to receive any
output data.
\item
The {\tt inGraphFile} parameter is the input file for the {\tt Graph}
object. It must be of the form {\tt *.graphf} or {\tt *.graphb}.
The {\tt Graph} object is read from the file via the
{\tt Graph\_readFromFile()} method.
\item
The {\tt maxdomainsize} parameter governs the partition of a graph.
If a subgraph has more than {\tt maxdomainsize} vertices, it is
split.
\item
The {\tt seed} parameter is a random number seed.
\item
The {\tt ETreeFile} parameter is the output file for the {\tt ETree}
object.
If {\tt ETreeFile} is {\tt none} then the {\tt ETree} object is not
written to a file.
Otherwise, the {\tt ETree\_writeToFile()} method is called to write
the object to
a formatted file (if {\tt ETreeFile} is of the form {\tt *.etreef}),
or
a binary file (if {\tt ETreeFile} is of the form {\tt *.etreeb}).
\end{itemize}
%-----------------------------------------------------------------------
\item
\begin{verbatim}
testOrderViaMS msglvl msgFile GraphFile maxdomainsize seed ETreeFile
\end{verbatim}
This program reads in a {\tt Graph} object from a file and computes
a multisection ordering of the graph.
\par
\begin{itemize}
\item
The {\tt msglvl} parameter determines the amount of output ---
taking {\tt msglvl >= 3} means the {\tt Perm} object is written
to the output file.
\item
The {\tt msgFile} parameter determines the message file --- if {\tt
msgFile} is {\tt stdout}, then the message file is {\it stdout},
otherwise a file is opened with {\it append} status to receive any
output data.
\item
The {\tt inGraphFile} parameter is the input file for the {\tt Graph}
object. It must be of the form {\tt *.graphf} or {\tt *.graphb}.
The {\tt Graph} object is read from the file via the
{\tt Graph\_readFromFile()} method.
\item
The {\tt maxdomainsize} parameter governs the partition of a graph.
If a subgraph has more than {\tt maxdomainsize} vertices, it is
split.
\item
The {\tt seed} parameter is a random number seed.
\item
The {\tt ETreeFile} parameter is the output file for the {\tt ETree}
object.
If {\tt ETreeFile} is {\tt none} then the {\tt ETree} object is not
written to a file.
Otherwise, the {\tt ETree\_writeToFile()} method is called to write
the object to
a formatted file (if {\tt ETreeFile} is of the form {\tt *.etreef}),
or
a binary file (if {\tt ETreeFile} is of the form {\tt *.etreeb}).
\end{itemize}
%-----------------------------------------------------------------------
\item
\begin{verbatim}
drawGraph msglvl msgFile inGraphFile inCoordsFile inTagsIVfile
          outEPSfile linewidth1 linewidth2 bbox[4] rect[4] radius
\end{verbatim}
This driver program generates a Encapsulated Postscript file
{\tt outEPSfile} of a 2-D graph using a {\tt Graph} object,
a {\tt Coords} object and a tags {\tt IV} object that contains the
component ids of the vertices.
\par
See the {\tt doDraw} script file in this directory for an example
calling sequence.
\begin{itemize}
\item
The {\tt msglvl} parameter determines the amount of output ---
taking {\tt msglvl >= 3} means that all objects are written
to the output file.
\item
The {\tt msgFile} parameter determines the message file --- if {\tt
msgFile} is {\tt stdout}, then the message file is {\it stdout},
otherwise a file is opened with {\it append} status to receive any
output data.
\item
The {\tt inGraphFile} parameter is the input file for the {\tt Graph}
object. It must be of the form {\tt *.graphf} or {\tt *.graphb}.
The {\tt Graph} object is read from the file via the
{\tt Graph\_readFromFile()} method.
\item
The {\tt inCoordsFile} parameter is the input file for the {\tt Coords}
object. It must be of the form {\tt *.coordsf} or {\tt *.coordsb}.
The {\tt Coords} object is read from the file via the
{\tt Coords\_readFromFile()} method.
\item
The {\tt inTagsIVfile} parameter is the input file for the tags
{\tt IV} object.
It must be of the form {\tt 'none'}, {\tt *.ivf} or {\tt *.ivb}.
The {\tt IV} object is read from the file via the
{\tt IV\_readFromFile()} method.
\item
The {\tt outEPSfile} parameter is the output file for the Encapsulated
Postscript file.
\item
The {\tt linewidth1} parameter governs the linewidth of edges
between vertices in the same component.
\item
The {\tt linewidth2} parameter governs the linewidth of edges
between vertices in different components.
\item
The {\tt bbox[4]} array is the bounding box for the plot.
In Postscript the coordinates are in {\it points}, where there are
72 points per inch.
For example, a bounding box of {\tt 0 0 200 300} will create a plot
whose size is 2.78 inches by 4.17 inches.
\item
The {\tt rect[4]} array is the enclosing rectangle for the plot.
To put a 20 point margin around the plot, set
{\tt rect[0] = bbox[0] + 20},
{\tt rect[1] = bbox[1] + 20},
{\tt rect[2] = bbox[2] - 20} and
{\tt rect[3] = bbox[3] - 20}.
\item
The {\tt radius} parameter governs the size of the filled circle
that is centered on each vertex.
The dimension is in points.
\end{itemize}
See Figure~\ref{fig-R2D100} for a plot of the graph of {\tt R2D100},
a randomly triangulated grid with 100 vertices with {\tt linewidth1
= 3}.
Figure~\ref{fig-R2D100-fishnet} illustrates a domain decomposition
obtained from the fishnet algorithm
of Chapter~\ref{chapter:GPart:intro}
with {\tt linewidth1 = 3} and {\tt linewidth2 = 0.1}.
\par
\begin{figure}[htbp]
\caption{{\sc R2D100}}
\label{fig-R2D100}
\begin{center}
\mbox{
% \psfig{file=R2D100notags.eps,height=4.00in,width=4.00in}
\psfig{file=../../misc/doc/R2D100notags.eps,height=4.00in,width=4.00in}
}
\end{center}
\end{figure}
\par
\begin{figure}[htbp]
\caption{{\sc R2D100: fishnet domain decomposition}}
\label{fig-R2D100-fishnet}
\begin{center}
\mbox{
% \psfig{file=R2D100fishnet.eps,height=4.00in,width=4.00in}
\psfig{file=../../misc/doc/R2D100fishnet.eps,height=4.00in,width=4.00in}
}
\end{center}
\end{figure}

%-----------------------------------------------------------------------
\item
\begin{verbatim}
testSemi msglvl msgFile GraphFile ETreeFile mapFile
\end{verbatim}
This program is used to compute the effect of using a semi-implicit
factorization to solve
$$
AX =
\left \lbrack \begin{array}{cc}
A_{0,0} & A_{0,1} \cr
A_{1,0} & A_{1,1}
\end{array} \right \rbrack
\left \lbrack \begin{array}{c}
X_0 \cr
X_1
\end{array} \right \rbrack
=
\left \lbrack \begin{array}{c}
B_0 \cr
B_1
\end{array} \right \rbrack
= B.
$$
$A$ is factored as
$$
\left \lbrack \begin{array}{cc}
A_{0,0} & A_{0,1} \cr
A_{1,0} & A_{1,1}
\end{array} \right \rbrack
=
\left \lbrack \begin{array}{cc}
L_{0,0} & 0 \cr
L_{1,0} & L_{1,1}
\end{array} \right \rbrack
\left \lbrack \begin{array}{cc}
U_{0,0} & U_{0,1} \cr
 0 & U_{1,1}
\end{array} \right \rbrack,
$$
and to solve $AX = B$, we do the following steps.
\begin{itemize}
\item solve $L_{0,0} Y_0 = B_0$
\item solve $L_{1,1} U_{1,1} X_1 = B_1 - L_{1,0} Y_0$
\item solve $U_{0,0} X_0 = Y_0 - U_{0,1} X_1$
\end{itemize}
An alternative factorization is
$$
A =
\left \lbrack \begin{array}{cc}
L_{0,0} & 0 \cr
A_{1,0}U_{0,0}^{-1} & L_{1,1}
\end{array} \right \rbrack
\left \lbrack \begin{array}{cc}
U_{0,0} & L_{0,0}^{-1}U_{0,1} \cr
 0 & U_{1,1}
\end{array} \right \rbrack.
$$
To solve $AX = B$, we do the following {\it semi-implicit solve}.
\begin{itemize}
\item solve $L_{0,0} U_{0,0} Z_0 = B_0$
\item solve $L_{1,1} U_{1,1} X_1 = B_1 - A_{1,0} Z_0$
\item solve $L_{0,0} U_{0,0} X_0 = B_0 - A_{0,1} X_1$
\end{itemize}
When we compare the semi-implicit solve against the explicit solve,
we see that the former needs
$A_{0,1}$ and $A_{1,0}$ but not $L_{1,0}$ or $A_{0,1}$.
and executes two solves with $L_{0,0}$ and $U_{0,0}$ (instead of one)
and performs a matrix-matrix multiply with $A_{0,1}$ and $A_{1,0}$
instead of $L_{1,0}$ and $U_{0,1}$.
In situations where the numbers of entries in $L_{1,0}$ and
$U_{0,1}$ are much larger than those in $A_{1,0}$ and $A_{0,1}$,
and the numbers of entries in $L_{0,0}$ and $U_{0,0}$ are not too
large, the semi-implicit factorization can be more efficient.
\par
This program reads in three objects:
a {\tt Graph} object,
an {\tt ETree} object to specify the ordering,
and an {\tt IV} map object that tells which vertices are in the
which blocks of the matrix.
The map from vertices to blocks follows the same convention as the
{\it component map} from the {\tt GPart} object.
If {\tt map[v] = 0}, then vertex {\tt v} belongs to the Schur
complement $(1,1)$ block.
Otherwise, {\tt v} belongs to a domain (the domain number is {\tt
map[v]}) and so belongs to the $(0,0)$ block.
The output of the program gives statistics for storage and
operation count for the two types of solves.
For example,
\begin{verbatim}
 storage: explicit = 1404, semi-implicit = 1063, ratio = 1.321
 opcount: explicit = 2808, semi-implicit = 2742, ratio = 1.024
\end{verbatim}
is the output using the {\tt do\_testSemi} driver program for
the {\tt R2D100} matrix.
\par
\begin{itemize}
\item
The {\tt msglvl} parameter determines the amount of output.
\item
The {\tt msgFile} parameter determines the message file --- if {\tt
msgFile} is {\tt stdout}, then the message file is {\it stdout},
otherwise a file is opened with {\it append} status to receive any
output data.
\item
The {\tt GraphFile} parameter is the input file for the {\tt Graph}
object. It must be of the form {\tt *.graphf} or {\tt *.graphb}.
The {\tt Graph} object is read from the file via the
{\tt Graph\_readFromFile()} method.
\item
The {\tt ETreeFile} parameter is the input file for the {\tt ETree}
object. It must be of the form {\tt *.etreef} or {\tt *.etreeb}.
The {\tt ETree} object is read from the file via the
{\tt ETree\_readFromFile()} method.
\item
The {\tt mapFile} parameter is the input file for the map {\tt IV}
object. It must be of the form {\tt *.ivf} or {\tt *.ivb}.
The {\tt IV} object is read from the file via the
{\tt IV\_readFromFile()} method.
\end{itemize}
%-----------------------------------------------------------------------
\item
\begin{verbatim}
allInOne msglvl msgFile type symmetryflag pivotingflag
         matrixFileName rhsFileName seed
\end{verbatim}
This {\it all-in-one} driver program is an example that tests the
serial $U^TDU$, $U^HDU$ or $LU$ factorization and solve.
Matrix entries are read in from a file, and then the matrix
is assembled and factored.
The right hand side entries are read in from a file, and the system
is solved.
Three input parameters specify the type of system (real or
complex),
the type of factorization (symmetric, Hermitian or nonsymmetric)
and whether pivoting is to be used for numerical stability.
\par
\begin{itemize}
\item
The {\tt msglvl} parameter determines the amount of output ---
taking {\tt msglvl >= 3} means the {\tt Perm} object is written
to the output file.
\item
The {\tt msgFile} parameter determines the message file --- if {\tt
msgFile} is {\tt stdout}, then the message file is {\it stdout},
otherwise a file is opened with {\it append} status to receive any
output data.
\item
{\tt type} is the type of entries
\begin{itemize}
\item {\tt 1} --- ({\tt SPOOLES\_REAL}) for real entries
\item {\tt 2} --- ({\tt SPOOLES\_COMPLEX}) for complex entries
\end{itemize}
\item
{\tt symmetryflag} defines the factorization
\begin{itemize}
\item {\tt 0} --- ({\tt SPOOLES\_SYMMETRIC})
for a real or complex $U^TDU$ factorization
\item {\tt 1} --- ({\tt SPOOLES\_SYMMETRIC})
for a complex $U^HDU$ factorization
\item {\tt 2} --- ({\tt SPOOLES\_SYMMETRIC})
for a real or complex $LU$ factorization
\end{itemize}
\item
{\tt pivotingflag} defines pivoting or not for numerical stability
\begin{itemize}
\item {\tt 0} --- ({\tt SPOOLES\_NO\_PIVOTING}) for no pivoting
\item {\tt 1} --- ({\tt SPOOLES\_PIVOTING}) for pivoting
\end{itemize}
Note, the code has a pivoting threshold {\tt tau = 100} hardwired
into the code.
\item
The {\tt matrixFileName} parameter is the name of the input file
for the matrix entries.
For a real matrix, this file must have the following form.
\begin{verbatim}
nrow ncol nent
...
irow jcol value
...
\end{verbatim}
where the first line has the number of rows, columns and entries.
(Note, for this driver program {\tt nrow} must be equal to {\tt ncol}
since we are factoring a square matrix.)
Each of the {\tt nent} following lines contain one nonzero entry.
For a complex matrix, the file has this structure.
\begin{verbatim}
nrow ncol nent
...
irow jcol real_value imag_value
...
\end{verbatim}
For both real and complex entries, the entries need not be
disjoint,
i.e., entries with the same {\tt irow} and {\tt jcol} values are
{\it summed}.
\item
The {\tt rhsFileName} parameter is the name of the input file for
the right hand side matrix.
It has the following structure
\begin{verbatim}
nrow nrhs
...
irow value_0 value_1 ... value_\{nrhs-1\}
...
\end{verbatim}
Note, {\tt nrow} need not be the number of equations, here it is
the number of nonzero right hand side entries.
This allows us to input sparse right hand sides without specifying
the zeroes.
In contrast to the input for the matrix entries, the nonzero rows
{\it must} be unique.
The right hand side entries are not assembled into a dense matrix
object, but placed into the object.
\item
{\tt seed} is a random number seed used for the ordering process.
\end{itemize}
%-----------------------------------------------------------------------
\item
\begin{verbatim}
patchAndGo msglvl msgFile type symmetryflag patchAndGoFlag fudge toosmall

           storeids storevalues matrixFileName rhsFileName seed
\end{verbatim}
This driver program is used to test the ``patch-and-go''
functionality for a factorization without pivoting.
When small diagonal pivot elements are found,
one of three actions are taken.
See the {\tt PatchAndGoInfo} object for more information.
\par
The program reads in a matrix $A$ and right hand side $B$,
generates the graph for $A$ and orders the matrix,
factors $A$ and solves the linear system $AX = B$ for $X$
using multithreaded factors and solves.
Use the script file {\tt do\_patchAndGo} for testing.
\par
\begin{itemize}
\item
The {\tt msglvl} parameter determines the amount of output.
Use {\tt msglvl = 1} for just timing output.
\item
The {\tt msgFile} parameter determines the message file --- if {\tt
msgFile} is {\tt stdout}, then the message file is {\it stdout},
otherwise a file is opened with {\it append} status to receive any
output data.
\item
The {\tt type} parameter specifies a real or complex linear system.
\begin{itemize}
\item
{\tt type = 1 (SPOOLES\_REAL)} for real,
\item
{\tt type = 2 (SPOOLES\_COMPLEX)} for complex.
\end{itemize}
\item
The {\tt symmetryflag} parameter specifies the symmetry of the matrix.
\begin{itemize}
\item
{\tt type = 0 (SPOOLES\_SYMMETRIC)} for $A$ real or complex symmetric,
\item
{\tt type = 1 (SPOOLES\_HERMITIAN)} for $A$ complex Hermitian,
\item
{\tt type = 2 (SPOOLES\_NONSYMMETRIC)}
\end{itemize}
for $A$ real or complex nonsymmetric.
\item
The {\tt patchAndGoFlag} specifies the ``patch-and-go'' strategy.
\begin{itemize}
\item
{\tt patchAndGoFlag = 0} --- if a zero pivot is detected, stop
computing the factorization, set the error flag and return.
\item
{\tt patchAndGoFlag = 1} --- if a small or zero pivot is detected,
set the diagonal entry to 1 and the offdiagonal entries to zero.
\item
{\tt patchAndGoFlag = 2} --- if a small or zero pivot is detected,
perturb the diagonal entry.
\end{itemize}
\item
The {\tt fudge} parameter is used to perturb a diagonal entry.
\item
The {\tt toosmall} parameter is judge when a diagonal entry is small.
\item
If {\tt storeids = 1}, then the locations where action was taken is
stored in an {\tt IV} object.
\item
If {\tt storevalues = 1}, then the perturbations are
stored in an {\tt DV} object.
\item
The {\tt matrixFileName} parameter is the name of the files where
the matrix entries are read from.
The file has the following structure.
\begin{verbatim}
neqns neqns nent
irow jcol entry
...  ...  ...
\end{verbatim}
where {\tt neqns} is the global number of equations and {\tt nent}
is the number of entries in this file.
There follows {\tt nent} lines, each containing a row index, a
column index and one or two floating point numbers, one if real,
two if complex.
\item
The {\tt rhsFileName} parameter is the name of the files where
the right hand side entries are read from.
The file has the following structure.
\begin{verbatim}
nrow nrhs
irow entry ... entry
...  ...   ... ...
\end{verbatim}
where {\tt nrow} is the number of rows in this file
and {\tt nrhs} is the number of rigght and sides.
There follows {\tt nrow} lines, each containing a row index
and either {\tt nrhs} or {\tt 2*nrhs} floating point numbers,
the first if real, the second if complex.
\item
The {\tt seed} parameter is a random number seed.
\end{itemize}
%-----------------------------------------------------------------------
\item
\begin{verbatim}
QRallInOne msglvl msgFile type matrixFileName rhsFileName seed
\end{verbatim}
This {\it all-in-one} driver program is an example that tests the
serial $QR$ factorization and solve.
Matrix entries are read in from a file, and then the matrix
is assembled and factored.
The right hand side entries are read in from a file, and the system
is solved.
One input parameter specifies the type of system (real or
complex).
\par
\begin{itemize}
\item
The {\tt msglvl} parameter determines the amount of output ---
taking {\tt msglvl >= 3} means the {\tt Perm} object is written
to the output file.
\item
The {\tt msgFile} parameter determines the message file --- if {\tt
msgFile} is {\tt stdout}, then the message file is {\it stdout},
otherwise a file is opened with {\it append} status to receive any
output data.
\item
{\tt type} is the type of entries
\begin{itemize}
\item {\tt 1} --- ({\tt SPOOLES\_REAL}) for real entries
\item {\tt 2} --- ({\tt SPOOLES\_COMPLEX}) for complex entries
\end{itemize}
\item
The {\tt matrixFileName} parameter is the name of the input file
for the matrix entries.
For a real matrix, this file must have the following form.
\begin{verbatim}
nrow ncol nent
...
irow jcol value
...
\end{verbatim}
where the first line has the number of rows, columns and entries.
Each of the {\tt nent} following lines contain one nonzero entry.
For a complex matrix, the file has this structure.
\begin{verbatim}
nrow nrhs nent
...
irow jcol real_value imag_value
...
\end{verbatim}
For both real and complex entries, the entries need not be
disjoint,
i.e., entries with the same {\tt irow} and {\tt jcol} values are
{\it summed}.
\item
The {\tt rhsFileName} parameter is the name of the input file for
the right hand side matrix.
It has the following structure
\begin{verbatim}
nrow nrhs
...
irow value_0 value_1 ... value_\{nrhs-1\}
...
\end{verbatim}
Note, {\tt nrow} need not be the number of equations, here it is
the number of nonzero right hand side entries.
This allows us to input sparse right hand sides without specifying
the zeroes.
In contrast to the input for the matrix entries, the nonzero rows
{\it must} be unique.
The right hand side entries are not assembled into a dense matrix
object, but placed into the object.
\item
{\tt seed} is a random number seed used for the ordering process.
\end{itemize}
%-----------------------------------------------------------------------
\end{enumerate}


\documentclass{article} % This command is used to set the type of document you are working on such as an article, book, or presenation
\usepackage{amsmath}  % This package allows the use of a large range of mathematical formula, commands, and symbols=]
\usepackage[linguistics]{forest}
\usepackage{tikz}

\begin{document}

\title{multiFaAcceleration: A program for the measurement of mutation velocity and acceleration from a four-species multiple alignment}
\author{Riley J. Mangan}
\maketitle

\section{Usage}
multiFaAcceleration - Performs velocity and acceleration on a four way multiple alignment in multiFa format.\par
A four way multiple alignment must contain four species (index 0 to 3) in the topology that species 1 to 3 are successive outgroups of species 0.\par
While this program accepts an alignment of any four species in this configuration, this program was initially written for a multiple alignment of Human, Chimpanzee, Gorilla, and Orangutan. Variable names in this documentation and in the code itself are named according to these species names.\par
Three bed files are returned. The first produces the normalized velocity score, the second returns the normalized acceleration score, and the third returns the normalized initial velocity score for each window of the genome for aln[0] (Human). This program can also produce the raw Velocity and Initial Velocity branch lengths as optional returns.\par
multiFaAcceleration chromName in.fa velocity.bed acceleration.bed initialVelocity.bed\par

\section{Distance-based phylogenetic inference with the Fitch-Margoliash method}

Consider a phylogenetic tree with four extant species (Human, Chimpanzee, Gorilla, Orangutan), two extinct ancestors (Human-Chimp Ancestor (HCA) and Human-Gorilla Ancestor (HGA)), and branch lengths (BhumHca, BchimpHca, HCA-HGA, BhgaGor, BhgaOrang) with the following topology.\par

\begin{center}
\begin{tikzpicture}
\node[above] at (-2,0) {$\textbf{HCA}$};
\draw (-2,0) -- node[above] {$BhcaHga$} (2,0) node[above] {$\textbf{HGA}$};
\draw (-2,0) -- node[above] {$BhumHcaA$}(-3.5,1.5) node[above] {$\textbf{Hum}$};
\draw (-2,0) -- node[above] {$BchimpHca$}(-3.5,-1.5) node[below] {$\textbf{Chimp}$};
\draw (2,0) -- node[above] {$BhgaGor$}(3.5,1.5) node[above] {$\textbf{Gor}$};
\draw (2,0) -- node[above] {$BhgaOrang$}(3.5,-1.5) node[below] {$\textbf{Orang}$};\
\end{tikzpicture}
\end{center}

Consider that we can measure the pairwise mutation distance between any two extant species on this tree, represented by $D_{ij}$. The distance defined by the sum of branch lengths, also known as the patristic distance, is represented as $d_{ij}$. It follows that the pairwise distance between two extant species is equal to the sum of branch lengths separating those species on the phylogenetic tree shown above. Thus, we are able to produce the following system of linear equations.

\begin{equation}
\begin{split}
&D_{hum-chimp} \approx d_{hum-chimp} =  BhumHca + BchimpHca\\
&D_{hum-gor} \approx d_{hum-gor} = BhumHca + BhcaHga + BhgaGor\\
&D_{chimp-gor} \approx d_{chimp-gor} = BchimpHca + BhcaHga + BhgaGor\\
&D_{hum-orang} \approx d_{hum-orang} = BhumHca + BhcaHga + BhgaOrang\\
&D_{chimp-orang} \approx d_{chimp-orang} = BchimpHca + BhcaHga + BhgaOrang\\
&D_{gor-orang} \approx d_{gor-orang} = BhgaGor + BhgaOrang
\end{split}
\end{equation}

If our interest is to study Human genome evolution, we can define the mutation distance as $BhumHca$, the distance between the human sequence and the sequence of its most recent ancestor with chimpanzees. We can then define the initial mutation distance as $BhcaHga$, the distance along the previous branch the inferred Human-Chimp ancestor and the common ancestor between humans and gorillas (HGA).\par
We can compute branch lengths using the method of Fitch and Margoliash \cite{pmid5334057} with an alternating least squares optimization algorithm developed by Felsenstein \cite{pmid11975348}. While the full details and derivations for these methods can be found in these two papers, I will briefly explain the method below.\par
Due to such phenomenon as back mutation and discrepancies in INDEL-sensitive distance metrics, it is not always possible to find a set of branch lengths for the above system of equations such that $D_{ij} = d_{ij} \: \forall \: i,j \in S$, where $S$ is the set of all extant species. Thus, in the Fitch-Margoliash method, we aim to find a set of branch lengths $B$ that minimizes the squared difference between the pairwise and patristic distances. In symbolic terms:
\begin{equation*}
	Q = \sum_{i \in S}\sum_{j \in S}w_{ij}(D_{ij} - d_{ij})^2
\end{equation*}
In the above expression, $w_{ij}$ represents a weight for error terms, and serves to place more of the overall error in the estimated branch lengths on longer branches. This expression is of the form:
\begin{equation*}
\begin{split}
	w_{ij} = \frac{1}{D_{ij}^2} \mid D_{ij} \ne 0\\
\end{split}
\end{equation*}

When $D_{ij} = 0$, the weight term $w_{ij}$ approaches positive infinity. In this program, we approximate this limit by assigning an arbitrarily large number to $w_{ij}$. This value is $1000$ by default, but can be controlled by the user with the option $zeroDistanceWeightConstant$.

\section{Tree reduction and subtree optimization}
In the alternating least squares approach top optimize Q described by Felsenstein, we must first reduce the above tree, which contains two internal nodes $HCA$ and $HGA$, to subtrees containing only one internal node. These subtrees, which we refer to as the left and right subtrees, are shown below.

Left subtree:
\begin{center}
\begin{tikzpicture}
\node[above] at (-2,0) {$\textbf{HCA}$};
\draw (-2,0) -- node[above] {$BhcaHga$} (2,0) node[above] {$\textbf{HGA}$};
\draw (-2,0) -- node[above] {$BhumHca$}(-3.5,1.5) node[above] {$\textbf{Hum}$};
\draw (-2,0) -- node[above] {$BchimpHca$}(-3.5,-1.5) node[below] {$\textbf{Chimp}$};
\end{tikzpicture}
\end{center}

Right subtree:
\begin{center}
\begin{tikzpicture}
\node[above] at (-2,0) {$\textbf{HCA}$};
\draw (-2,0) -- node[above] {$BhcaHga$} (2,0) node[above] {$\textbf{HGA}$};
\draw (2,0) -- node[above] {$BhgaGor$}(3.5,1.5) node[above] {$\textbf{Gor}$};
\draw (2,0) -- node[above] {$BhgaOrang$}(3.5,-1.5) node[below] {$\textbf{Orang}$};\
\end{tikzpicture}
\end{center}

In the $multiFaAcceleration$ program, these subtrees are produced with the $pruneLeft$ and $pruneRight$ helper functions, respectively. To find the optimal branch lengths for these subtrees, we must find the pairwise distances between the extant species nodes and the ancestral node which is now a leaf in the subtree. For the left subtree, Felsenstein demonstrates that we can calculate these distances as:
\begin{equation*}
	D_{HumHga} = \frac{w_{HumGor}(D_{HumGor} - BhgaGor) + w_{Humorang}(D_{HumOrang} - BhgaOrang)}{w_{HumGor} + w_{HumOrang}}
\end{equation*}
\begin{equation*}
	D_{ChimpHga} = \frac{w_{ChimpGor}(D_{ChimpGor} - BhgaGor) + w_{ChimpOrang}(D_{ChimpOrang} - BhgaOrang)}{w_{ChimpGor} + w_{ChimpOrang}}
\end{equation*}
Similarly, for the right subtree:
\begin{equation*}
	D_{HcaGor} = \frac{w_{HumGor}(D_{HumGor} - BhgaGor) + w_{ChimpGor}(D_{ChimpGor} - BhgaOrang)}{w_{HumGor} + w_{ChimpGor}}
\end{equation*}
\begin{equation*}
	D_{HcaOrang} = \frac{w_{HumOrang}(D_{HumOrang} - BhgaGor) + w_{ChimpOrang}(D_{ChimpOrang} - BhgaOrang)}{w_{HumOrang} + w_{ChimpOrang}}
\end{equation*}
As distance is necessarily a non-negative quantity, and the weight constant is set to an arbitrarily large number when $D_{ij} = 0$, the denominator in the above equations can never be zero, and does not need to be otherwise constrained.\par
The three-species left subtree with branch lengths $v$ has the following optimal branch lengths:
\begin{equation*}
\begin{split}
v_a = \frac{(D_{ab} + D_{ac} - D_{bc})}{2}\\
v_b = \frac{(D_{ab} + D_{bc} - D_{ac})}{2}\\
v_c = \frac{(D_{ac} + D_{bc} - D_{ab})}{2}
\end{split}
\end{equation*}

\section{Constraint for non-negative branch lengths}
In some cases, the optimal set of branch lengths for the minimization of Q will include negative branch lengths. While this can be allowed by the user with the option $allowNegative$, this program constrains branch lengths to non-negative values by default. Briefly, when one or more branches from the 3-species subtrees are evaluated as negative values, they are set to 0. From Felsenstein 1997, if branch lengths $v_b$ or $v_c$ are set to zero in this fashion, the new optimal branch length for $v_a$, given that either of these terms are set to zero, can be approximated as:
\begin{equation*}
	\hat v_a = \frac{w_{ab}(D_{ab} - v_b) + w_{ac}(D_{ac} - v_c)}{w_{ab} + w_{ac}}
\end{equation*}

\section{Algorithm for branch length calculations}
With these equations in hand, we can now describe the algorithm for computing optimal branch lengths for the four-species tree, which is performed by the helper function $alternatingLeastSquares$ in $multiFaAcceleration$. First, the set of output branch lengths are initialized such that each branch length is equal to 1. In each iteration, the tree is first pruned to the left subtree, and the branch lengths $BhumHca, BchimpHca, BhcaHga$ are then set to the optimal branch lengths for this subtree. Next, the tree is pruned into the right subtree, and the branches $BhcaHga, BhgaGor, BhgaOrang$ are then set to the optimal values for this subtree. Once both optimizations have occurred, the value of Q is calculated for the current branch lengths and compared to the value of Q observed in the previous iteration. If the difference between the estimates of Q falls below a user-specified level of error $\epsilon$, the answer is returned. Otherwise, a new iteration is initiated. This heuristic will converge on a local minimum for Q and achieve stationarity in finite iterations. Due to the approximation used for non-negative branch lengths, it is possible stationarity will be achieved as the oscillation between two sets of branch lengths. In this case, we take the set of branch lengths associated with the lowest value of Q.
\section{Genome-wide acceleration calculation}
For a given four-way alignment in multiFa format, $gonomics:multiFaAcceleration$ calculates $BhumHca$ and $BhcaHga$ using pairwise mutation distance (defined as the number of SNPs and INDELs, where each INDEL counts as one mutation regardless of length) for each window of a user-specified window size. Windows may be every possible window of the genome, or may be restricted to a particular subset of the genome using the option $-searchSpaceBed$, which enables the input of a bed file which specifies the regions that should be considered. The option $-searchSpaceProportion$ enables the user to consider all windows in which at least a user-specified proportion of bases are within the searchSpace.

We define $\textbf{v}$ as the normalized mutation velocity, or the normalized rate of mutation over the branch $BhumHca$. To calculate $\textbf{v}$, we calculate the average $BhumHca$ length $E(BhumHca)$ across all windows. For each window:
\begin{equation*}
	\textbf{v} = \frac{BhumHca}{E(BhumHca)}
\end{equation*}

Similarly, the normalized initial rate of mutation, or the normalized rate of mutation over the branch $BhcaHga$, can be calculated as:
\begin{equation*}
	\textbf{v}_0 = \frac{BhcaHga}{E(BhcaHga)}
\end{equation*}
Where $e(BhcaHga)$ is the average value of $BhcaHga$ over all windows.\par
$\textbf{v}$ and $\textbf{v}_0$ have intuitive numerical interpretations. If $\textbf{v} = 1$ for a particular window, the mutation rate in the branch $BhumHca$ is equal to the chromosome-wide average mutation rate. $\textbf{v} = 2$ would be found in a region evolving twice as quickly, and $\textbf{v} = 0.5$ in a region evolving at half the average rate. The same interpretations apply for $\textbf{v}_0$, the rate of evolution along the branch $BhcaHga$.\par
Finally, we define the quantity $\textbf{a}$, for acceleration, as the normalized change in mutation rate between branches branches $BhumHca$ and $BhcaHga$:
\begin{equation*}
\textbf{a} = \textbf{v} - \textbf{v}_0
\end{equation*}

The quantity $\textbf{a}$ is equal to zero when the mutation rate along $BhumHca$ is equal to the mutation rate along $BhcaHga$. As both $\textbf{v}$ and $\textbf{v}_0$ are normalized, this holds true even if $BhumHca$ and $BhcaHga$ are not equal in absolute length, which will be the case when the extant species are not separated by equal amounts of evolutionary time (in the example here, the distance between humans and chimpanzees, about six million years, is nearly triple the 2.5 million years separating the Human-Chimp Ancestor from the Human-Gorilla Ancestor). Positive values for $\textbf{a}$ indicate accelerated regions, and negative values suggest regions under negative acceleration, in which a region evolved at a slower rate along $BhumHca$ than $BhcaHga$.

\bibliographystyle{genres}
\bibliography{multiFaRefs}

\end{document}


\chapter{Interactive Assumptions}

This chapter covers the implementation of our approach for
analyzing interactive assumptions.
%
We get an input of the following form:
\begin{verbatim}
emaps G1 * G2 -> GT.
isom G1 -> G2.

input [ X, Y ] in G1.

oracle O(m : Fq) = sample A:G1, (A, A*Y, A*X + m*A*X*Y).

win(U:G1, V:G1, W:G1, mm) = U <> 0 /\ mm <> m_i /\ V = UX /\ W = U*X + m*U*X*Y.
\end{verbatim}
%
For now, we make the following assumptions:
\begin{enumerate}
\item Either the group setting is a generic group or the input, oracle
  arguments and return values, and winning condition input
  are all in one group. In the last case, we exploit that the
  problem is computational.
\item All oracle inputs are of type \verb!Fq!. Allowing for group
  elements complicates the definition.
\end{enumerate}
%
We first compute a formal sum for each \verb!win! input of type $\group$
  as follows:
\begin{enumerate}
\item Assume that the adversary is given inputs
  $\vec{f}$ where $f_j$ defines an element in
  $\group$ over random variables~$\vec{X}$.
\item That there is one oracle taking field elements
  $\vec{m}$ and returning $\vec{g}$
  where $g_j$ defines an element in $\group$
  over the variables $\vec{X}$ and the variables
  $\vec{A}$ sampled in the oracle call.
\item We assume there are $q$ oracle queries.
\item As a first step, we introduce indexed parameters
  $m_{1,j},\ldots,m_{l,j}$ ($j \in [q]$) and
  indexed random variables
  $A_{1,j},\ldots,A_{r,j}$ ($j \in [q]$).
\item Then all computable elements can
  be expressed as linear combinations as follows:
  \[
    \alpha_1 f_1 + \ldots + \alpha_k f_k
    + \Sigma_{i=1}^q \beta_{1,i}\, g_1(\vec{m_i},\vec{A_i},\vec{X})
    \ldots
    + \Sigma_{i=1}^q \beta_{n,i}\, g_n(\vec{m_i},\vec{A_i},\vec{X})
  \]
\item We assume the winning condition takes
  elements $\vec{U}$ in $\group$.
  Then we use $\alpha_i^{(j)}$ and $\beta_i^{(j)}$ (this is a vector) for
  the coefficients of $U_j$.
\end{enumerate}

We represent such linear combinations as formal sums.


\documentclass{memoir}
\usepackage{notestemplate}

%\logo{~/School-Work/Auxiliary-Files/resources/png/logo.png}
%\institute{Rice University}
%\faculty{Faculty of Whatever Sciences}
%\department{Department of Mathematics}
%\title{Class Notes}
%\subtitle{Based on MATH xxx}
%\author{\textit{Author}\\Gabriel \textsc{Gress}}
%\supervisor{Linus \textsc{Torvalds}}
%\context{Well, I was bored...}
%\date{\today}

\begin{document}

% \maketitle

% Notes taken on 05/18/21

Now let us consider the Euler-Lagrange equations of a graph:
\begin{align*}
	&\inf_{u} \left\{ \int_\Omega f(\nabla u) \mid \int_\Omega g(u) = M \right\} \quad &(P_1)\\
	&\inf_{u} \left\{ \int_\Omega f(\nabla u) \mid \int_{\Omega }g(u) = M; \; u = u_0 \; \partial \Omega  \right\}  \quad &(P_2)
\end{align*}

\begin{exmp}
	Consider \(f(z) = \sqrt{1+\left| z \right|^2} \) and \(g(s) = \left| s \right| \), \(u_0 = 0\). We are looking for minimizers that satisfy \(\int_\Omega \left| u \right| = M\). If \(u\geq 0\), then this integral is exactly the area below the graph of \(u\).\\

	Problems of this sort are referred to as being of \textbf{isoperimetric type}. We have a fixed perimeter, and we want to minimize a function which is constrained along it. It does not always admit a solution, however.\\

	To see this, consider \(\Omega = B_R(0)\). The minimizer will be a spherical cap described by \(u(x) = \sqrt{S^2-\left| x \right|^2} - \sqrt{S^2 - R^2} \) for some \(S\geq R\). If \(M > \dfrac{\left| B_R \right| }{2}\) then there is no graph which can attain \(M\) within the constraints!
\end{exmp}
\begin{figure}[ht]
    \centering
     \def\svgwidth{1\linewidth}
     \input{./figures/example-space-for-p_1-and-p_2.pdf_tex}
     \caption{Area graph with \(f(z) = \sqrt{1+\left| z \right|^2} \) and \(g(s) = \left| s \right| \)}
    \label{fig:example-space}
\end{figure}

\begin{exmp}
	Consider \(f(\nabla u) = \dfrac{\left| \nabla u \right|^2}{2}\), \(g(u) = \dfrac{u^2}{2}\) and \(u_0 = 0\).\\

	In this case, minimizers \textit{always} exist, and are eigenfunctions of \(-\Delta \) that satisfy the zero Dirichlet condition.
\end{exmp}

\section{Linear Transformations by Smooth Functions}
\label{sec:linear_transformations_by_smooth_functions}

We can learn more about minimizers on the graph family of Euler-Lagrange equations by combining them with nicely behaved functions. Consider
\begin{align*}
	\int_\Omega g(u+t\varphi ) = M
\end{align*}
for all non-negative real \(t\). What constraints must \(\varphi \) have to satisfy this? We can see that
\begin{align*}
	g(u+t\varphi ) = g(u) + tg'(u)\varphi + \dfrac{t^2}{2}g''(u)\varphi^2 + o(t^3)\implies\\
	M = M+t \int_\Omega g'(u) \varphi  + \dfrac{t^2}{2}\int_\Omega g''(u)\varphi^2 + o(t^3)
\end{align*}
for all \(t\). We can actually infer from this that \(\int_\Omega g'(u) \varphi  = 0\) by the first-order conservation of \(\int g(u)\)!\footnote{To check this, apply integration by parts and see what you get.} Then the sum \(u+t\varphi \) only differs from \(u\) by \(o(t^2)\), and so for small \(t\) is relatively close.\\

% Diagram

In the context of differential geometry, we can interpret this new family as the functions in
\begin{align*}
	T_u\mathcal{M} = \left\{\varphi  \mid \int g'(u)\varphi  = 0 \right\} .
\end{align*}
This is because if \(\varphi :\int_{\Omega }g'(u)\varphi  = 0\), then there should be an \(O(t^2)\) correction such that
\begin{align*}
	u+t\varphi +O(t^2) \in \mathcal{M}.
\end{align*}

Let us discuss these families more formally. Let \(\varphi, \xi  \in C^{\infty}(\overline{\Omega })\) such that
\begin{align*}
	\int_\Omega g'(u)\varphi =0 \quad \int_\Omega  g'(u) \xi   = 1
\end{align*}
Consider \(u+t\varphi +s \xi  \in C^{\infty}(\Omega )\) with two parameters \((t,s)\). The implicit function theorem tells us that there exists \(\varepsilon>0\) and \(s(t):(-\varepsilon,\varepsilon)\to \R\) such that, if \(u(t) = u + t\varphi  + s(t) \xi  \), then
\begin{align*}
	\int_\Omega g(u(t)) = M \quad \forall \left| t \right| <\varepsilon\\
	s(0) = 0
\end{align*}
This \(s(t)\) is in essence our \(O(t^2)\) correction that allows the families \(\varphi \) to still satisfy our condition. Let us look in more detail how \(s(t)\) interacts with our current formulations:

\begin{align*}
	\int_\Omega g(u) &= \int_\Omega g(u+t\varphi +s(t) \xi ) \\
	&= \int_\Omega g(u) + t \int _\Omega g'(u) \left[ \varphi +s'(0) \xi  \right] + \dfrac{t^2}{2}\int_\Omega  g''(u)\left[ \varphi +s'(0)\xi  \right]^2 + g'(u) \xi  s''(0) + o(t^2) \\
	&\implies 0 = \int _\Omega g'(u) \left[ \varphi +s'(0) \xi  \right] = s'(0) \int_\Omega g'(u) \xi  = s'(0)\\
	&\implies 0 = \int_\Omega g''(u)\varphi^2 + s''(0) \int_\Omega g'(u) \xi
\end{align*}
But notice that \(\int_\Omega g'(u) \xi  = 1\), so that
\begin{align*}
	s''(0) = - \int_\Omega g''(u) \varphi^2
\end{align*}
This classifies our correction factor up to low orders, so we have that
\begin{align*}
	s \approx - \left[ \int_\Omega g''(u) \varphi^2 \right] \cdot \dfrac{t^2}{2}
\end{align*}

Now we can plug this back into the Euler-Lagrange equations of the problem
\begin{align*}
	\inf_{u} \left\{ \int_\Omega f(\nabla u) \mid \int_\Omega g(u) = M \right\} .
\end{align*}
to get
\begin{align*}
	\mathcal{F}(u+t\varphi +s(t) \xi ) \geq \mathcal{F}(u) \quad \forall \left| t \right| < \varepsilon\\
\end{align*}
and our variations on
\begin{align*}
	f(\nabla u + t \nabla \varphi + s(t) \nabla \xi )
\end{align*}
are given by
\begin{align*}
	&\frac{d}{dt} f(\nabla u + t\nabla \varphi + s(t) \nabla \xi ) = \nabla f(\nabla u+\ldots) \cdot (\nabla \varphi +s'(t) \nabla \xi )\\
	&= \nabla f(\nabla u)\cdot \nabla \varphi \\
	&\frac{d^2}{dt^2}f(\nabla u+t \nabla \varphi + s(t) \nabla \xi) = (\nabla \varphi +s'(t) \nabla \xi ) \cdot \nabla^2 f(\nabla u + \ldots)(\nabla \varphi + s'(t) \nabla \xi ) + \nabla f(\nabla u + \ldots)\cdot \nabla \xi s''(t) \\
	&= \nabla \varphi \cdot (\nabla^2f(\nabla u)\nabla \varphi ) + \nabla f(\nabla u)\cdot \nabla \xi s''(0)
\end{align*}

\hrulefill

Now let \(\psi \in C^{\infty}(\overline{\Omega })\) and choose
\begin{align*}
	\varphi = \psi - \left[ \frac{\int g '(u) \psi }{\int  g '(u)^2} \right] g'(u) = \int_\Omega g'(u)\varphi =0
\end{align*}
Or in other words, we are choosing \(\varphi \) to be \(\psi \) subtracted by its projection along \(g'(u)\). We are choosing \(\varphi \) this way so that \(\langle g'(u), \varphi  \rangle = 0\). Note that there is an implicit assumption here that \(g\) satisfies \(\int g '(u)^2 > 0\). Lastly, choose \(\xi = \dfrac{g'(u)}{\int_\Omega g'(u)^2}\) so that \(\langle g'(u),\xi  \rangle= 1\).

Now let's reconsider the Euler-Lagrange equations, but with the choices of \(\varphi \) and \(\xi \) as above. That is, for all \(\varphi \) and \(\xi \) of the form above:
\begin{align*}
	\int_\Omega \nabla f(\nabla u)\cdot \nabla \varphi = 0\\
	\int_\Omega \nabla \varphi \cdot (\nabla^2f(\nabla u)\nabla \varphi ) + s''(0) \nabla f(\nabla u)\cdot \nabla \xi \geq 0
\end{align*}
Now we substitute in the projection form for \(\varphi \) :
\begin{align*}
	\int_\Omega \nabla f ( \nabla u) \cdot \left[ \nabla \psi - \left[ \frac{\int g'(u) \psi }{\int g'(u)^2} \right] g''(u) \nabla u \right]= 0 \\
\implies \int_\Omega \nabla f(\nabla u)\cdot \nabla \psi - \lambda (u) \int_\Omega g'(u) \psi = 0
\end{align*}
and so
\begin{align*}
	\lambda (u) = \frac{\int_\Omega g''(u) \left[ \nabla u \cdot \nabla f(\nabla u) \right] }{\int_\Omega g'(u)^2}
\end{align*}
This \(\lambda(u)\) is what we refer to by a \textbf{Lagrange multiplier}.\\

Now denote \(X \cong \nabla f(\nabla u)\) and observe:
\begin{align*}
	\int_\Omega X \cdot \nabla \psi = \int_\Omega dw(\psi X) - \int_\Omega \psi \textrm{div}X\\
	= \int_{\partial\Omega }\psi (X\cdot \nu_\Omega ) - \int_\Omega \psi \textrm{div}X.
\end{align*}

\begin{align*}
	0 = \int_{\partial\Omega }\psi \nu_\Omega \cdot \nabla f(\nabla u) + \int_\Omega \psi \left[ -dw(\nabla f(\nabla u)) - \lambda g'(u) \psi  \right] \quad \forall \psi \in C^{\infty}(\overline{\Omega })
\end{align*}
Testing on \(\psi =0\) on \(\partial\Omega \), but arbitrary otherwise, we get on \(\Omega \) :
\begin{align*}
	-dw(\nabla f(\nabla u)) = \lambda g'(u)
\end{align*}
Once we know this we get

\begin{align*}
	\begin{cases}
	-dw(\nabla f(\nabla u)) = \lambda g'(u) & \Omega \\
	\nu_\Omega \cdot \nabla f(\nabla u) = 0 & \partial\Omega
	\end{cases}
\end{align*}

\begin{exmp}
	Choosing \(f(z) = \dfrac{\left| z \right|^2 }{2}\) and \(g(u) = \dfrac{u^2}{2}\), the above becomes
	\begin{align*}
		- \Delta u = \lambda u \quad \Omega \\
		\frac{\partial u}{\partial \nu_\Omega } = \nabla u\cdot \nu_\Omega  = 0 \quad \partial\Omega
	\end{align*}
	This is the Neumann eigenfunctions of the Laplacian \(\Omega \).
\end{exmp}

\begin{exmp}
	Consider the space \(\Omega  = (0,\pi )\), and let \(u_k(x) = \cos(kx)\) for \(k \in \N\). These are all solutions to
	\begin{align*}
		-u_k'' = \lambda u_k \quad (0,\pi )\\
		u'_k\mid_{0,\pi }=0
	\end{align*}
	\(\lambda =k^2\) and \((u_k) \cong k^2\). This is an example of a variational problem with many critical points.
\end{exmp}

Notice that if \(f(z) = \sqrt{1+\left| z \right|^2} \) then \(\nabla f(\nabla u) \cdot \nu_\Omega = \frac{\nabla u \cdot \nu_{\Omega }}{\sqrt{1+ \left| \nabla u \right|^2} }=0\).

\end{document}

Topics in Partial Differential Equations/Calculus of Variations/Notes/source/Lecture2.tex


\documentclass[12pt]{article} \input{physics1}
\begin{document}

\noindent
Name: \rule[-1ex]{0.55\textwidth}{0.1pt}
NetID: \rule[-1ex]{0.2\textwidth}{0.1pt}

\section*{NYU Physics I---Term Exam 6}

\paragraph{\problemname~\theproblem:}\refstepcounter{problem}%
What is the speed of a package orbiting on a circular orbit right near
the surface of the Earth? Give your answer in $\mps$.
(from Problem Set 11)

\vfill

\paragraph{\problemname~\theproblem:}\refstepcounter{problem}%
Sketch an orbit of roughly eccentricity 0.9. Most importantly: Show the
point about which the object is orbiting, and make sure your pericenter
and apocenter distances make sense. Don't worry about getting it all right,
just roughly!
(from Problem Set 12)

\vfill

\paragraph{\problemname~\theproblem:}\refstepcounter{problem}%
Draw a space-time diagram that shows a stationary base E (in the rest
frame of E) and a ship S moving at speed $0.5\,c$ in the $x$
direction with respect to E. At some time (your choice!) when the base and ship are far
apart, base E sends a light signal to the ship S. Draw that light
signal on your diagram too.
(from Problem Set 13)

\vfill
~
\clearpage

\paragraph{\problemname~\theproblem:}\refstepcounter{problem}%
Earth orbits on a nearly circular orbit at 1\,AU; Jupiter orbits
on a nearly circular orbit at 5.2\,AU. What is the semi-major axis
of the transfer orbit that just kisses both of these orbits?
(from lecture on 2018-11-27)

\vfill

\paragraph{\problemname~\theproblem:}\refstepcounter{problem}%
If you want to observe a time-dilated celebration (or, say, lifetime
of some unstable particles), time dilated by a factor of 10, how fast
does the party (or do the particles) have to move with respect to you?
Give your answer in terms of the speed of light $c$.
(from lecture on 2018-12-04)

\vfill

\paragraph{\problemname~\theproblem:}\refstepcounter{problem}%
What is the spacetime interval $(\Delta s)^2$ between the two events $A$ and $B$?
$$A = (c\,t_A, x_A) = (2\,\m, 6\,\m) $$
$$B = (c\,t_B, x_B) = (7\,\m, 3\,\m) $$
Don't forget your units. (from the recitation on the interval)

\vfill
~
\end{document}


\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[margin=1in]{geometry}
\usepackage{enumitem}
\usepackage{amsmath}
\usepackage{listings}
\usepackage{color}
\usepackage{booktabs}
\usepackage[font=small, labelfont=bf]{caption}
\usepackage[T1]{fontenc}

% macro to select a scaled-down version of Bera Mono (for instance)
\makeatletter
\newcommand\BeraMonottfamily{%
  \def\fvm@Scale{0.85}% scales the font down
  \fontfamily{fvm}\selectfont% selects the Bera Mono font
}
\makeatother

\definecolor{codegreen}{rgb}{0,0.6,0}
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
\definecolor{codepurple}{rgb}{0.58,0,0.82}
\definecolor{backcolour}{rgb}{0.95,0.95,0.92}

\lstdefinestyle{mystyle}{
    backgroundcolor=\color{backcolour},
    commentstyle=\color{codegreen},
    keywordstyle=\color{magenta},
    numberstyle=\tiny\color{codegray},
    stringstyle=\color{codepurple},
    basicstyle=\BeraMonottfamily\footnotesize,
    breakatwhitespace=false,
    breaklines=true,
    captionpos=b,
    keepspaces=true,
    numbers=left,
    numbersep=5pt,
    showspaces=false,
    showstringspaces=false,
    showtabs=false,
    tabsize=2
}
\lstset{style=mystyle,
        otherkeywords={True,False}
}

\title{CS249 Fall 2020\\
       Problem Set 2: Statistical Inference II}
\author{Christopher Munoz Cortes}
\date{\today}

\usepackage{natbib}
\usepackage{graphicx}

\begin{document}

\maketitle

\section{Hypothesis Testing}
Assume a friend of yours currently has a salary of \$70k per year. She is
considering a switch in her career, and has narrowed down her choices to
three different options. She has been able to find the following data points
for entry-level salaries (in thousand dollars) for these three choices:
\begin{enumerate}
\item 143 102 119 157 146 61 119 85 87 102
\item 77 143 108 76 92 87 145 60 86 27
\item 19 83 87 55 115 41 71 66 101 99
\end{enumerate}
Assume that these data points are IID observations, and the difference between
them can only be attributed to noise. Additionally, assume that after
a career change your friend’s salary will be a sample from the same distribution
as the one behind your observed data points.
\begin{enumerate}[label={(\alph*)}]
    \item Can your friend expect an increase in her salary on average if she
    chooses \#1?

    An appropriate null hypothesis to answer this question would be the following
    one-tail test: $H_0: \mu_0 \leq 70$. If we can reject $H_0$, then we can assert
    that the population mean is higher than \$70k, and conclude that our friend
    should expect, on average, an increase in her salary.
    Since $\frac{p}{2} = 0.0009 < \alpha = 0.05$
    and $t>0$ we reject $H_0$. As a consequence, our friend should expect an
    increase in her salary on average if she chooses \#1.

    \item Is there any difference between the average salary of the three
    choices?

    Here we define $H_0: \mu_1 = \mu_2 = \mu_3$ as our null hypothesis and use an
    ANOVA test to verify it. The result of the test shows that we have enough evidence
    to reject the null hypothesis, since $p = 0.04 < \alpha = 0.05$. As a
    consequence, we assert that there is a difference between the average salary of
    the three choices.

    \item Is there any difference between the average salary of \#1 and \#3?

    We can answer this question testing the following null hypothesis: $H_0: \mu_1
    = \mu_3$ and verifying its validity. Since $p = 0.01 < \alpha = 0.05$ we reject
    $H_0$ and assert that the mean salary for choice 1 and choice 2 are different.
\end{enumerate}

\begin{lstlisting}[language=Python, caption=Code for Question 1 \emph{Hypothesis
Testing}]
import numpy as np
from scipy import stats

y_1 = np.array([143, 102, 119, 157, 146, 61, 119, 85, 87, 102])
y_2 = np.array([77, 143, 108, 76, 92, 87, 145, 60, 86, 27])
y_3 = np.array([19, 83, 87, 55, 115, 41, 71, 66, 101, 99])

# Part (a): H_0: mean >= 70k
mu_0 = 70
t_stat, p_val = stats.ttest_1samp(y_1, mu_0)
print(f"t-stat: {t_stat}")
print(f"p-value: {p_val/2}")

# Part (b): H_0: mu_1 = mu_2 = mu_3
f_stat, p_val = stats.f_oneway(y_1, y_2, y_3)
print(f"f-stat: {f_stat}")
print(f"p-value: {p_val}")

# Part (c): H_0: mu_1 = mu_3
t_stat, p_val = stats.ttest_ind(y_1, y_3, equal_var=True)
print(f"t-stat: {t_stat}")
print(f"p-value: {p_val}")
\end{lstlisting}

\pagebreak

\section{Regression to the Mean}
\begin{enumerate}[label={(\alph*)}]
    \item Assume $x$ represents the height of the father and $y$
    represents the height of the son. Standardize the two
    covariates. You can use the following code:

    \lstinline{x = (x - np.mean(x)) / np.std(x)}

    \lstinline{y = (y - np.mean(y)) / np.std(y)}

    Plot \lstinline{y} vs. \lstinline{x} in a scatter plot in Python.
    \begin{figure}[h]
        \centering
        \includegraphics[scale=0.7]{scatter_father_son_height.png}
        \caption{\lstinline{y} vs. \lstinline{x}}
        \label{fig:father_son}
    \end{figure}

    \item Based on your intuition and without fitting a model, draw the line corresponding to the linear regression for this data.

    See Figure \ref{fig:father_son}.

    \item Fit a linear regression in Python where the response variable is
    \lstinline{y}. Draw the line corresponding to the fitted linear regression in the
    scatter plot. Does this line match your intuition from the previous part?

    The line corresponding to the fitter linear regression does not match the line I
    plotted based on my intuition. See Figure \ref{fig:father_son} above.
    %TODO: add equation for the line of best fit

    \item Based on the fitted regression line, if a father is 10 inches taller than
    the average, how much greater is the expected height of the son compared to the
    average? And if a father is 10 inches shorter than the average, how much smaller
    is the expected height of the son compared to the average?

    If a father is 10 inches taller than the average, the expected height of the son
    is 5.14 inches taller than the average. Conversely, if a father is 10 inches
    shorter than average, the expected height of the son is 5.14 inches shorter
    than average.

    \item Based on the answer to the previous part, do you think it is fair to say
    that heights become more and more ``average'' over time? Read about ``regression
    to the mean'' and revisit your answer.

    If we didn't take the regression error into consideration, the results from the
    previous part would lead us to believe that the heights do become more ``average''
    over generations. However, this is a naive interpretation that ignores the fact
    that the actual $y_i$ values will not be exactly where the model predicts them to
    be. Some of them will be closer to the mean, while other will be further from it.
    In other words, we when take the error in the regression predicting $y$ from $x$,
    this interpretation is incorrect.

    \begin{lstlisting}[language=Python, caption=Standard Error and Confidence
    Interval for $T$]
import pandas as pd
from google.colab import drive
import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression

# Mount drive
drive.mount('/content/drive')
df = pd.read_csv('/content/drive/My Drive/father_son.txt', delim_whitespace=True)

# Standardize the two covariates
def standardize_feature(feature):
  return (feature - np.mean(feature)) / np.std(feature)

x = standardize_feature(df['Father'])
y = standardize_feature(df['Son'])

# Part (a): plot y vs. x
fig, ax = plt.subplots()
ax.scatter(x, y)

# Part (b): plot intuition line of best fit (y=x)
x_int = np.linspace(-3,3)
y_int = x_int
ax.plot(x_int, y_int, linestyle='dashed', color='C1')

# Part (c): fit a linear regression
x = x.values.reshape(-1, 1)
y = y.values.reshape(-1,1)
model = LinearRegression()
model.fit(x,y)
y_hat = model.predict(x)
ax.plot(x, y_hat, linestyle='dashed', color='C2')
ax.legend(['Intuition line of best fit', 'Line of best fit'])

# Part (d)
# Father 10 in taller than the average
x_father = df['Father'].mean() + 10

# Transform the value to match the scale of the model fit
x_father = (x_father - df['Father'].mean()) / df['Father'].std()
x_father = np.array([x_father])

# Son height for x_father
y_hat_son = model.predict(x_father.reshape(-1,1))
y_hat_son = y_hat_son[0][0] * df['Son'].std() + df['Son'].mean()
print(f"The son is {y_hat_son - df['Son'].mean()} inches taller than the average")

# Part (e)
# What if the father is 10 in shorter than the average?
x_father_2 = df['Father'].mean() - 10
x_father_2 = (x_father_2 - df['Father'].mean()) / df['Father'].std()
x_father_2 = np.array([x_father_2]).reshape(-1,1)

y_hat_son_2 = model.predict(x_father_2)
y_hat_son_2 = y_hat_son_2[0][0] * df['Son'].std() + df['Son'].mean()
print(f"The son is {np.abs(y_hat_son_2 - df['Son'].mean())} inches shorter than the average")
\end{lstlisting}
\end{enumerate}
\pagebreak

\section{Linear Regression}
In this problem, we are going to see what happens if we use a linear regression to
model the relationship between two independent random variables.
\begin{enumerate}[label={(\alph*)}]
    \item Simulate 1000 data points from a normal distribution with mean 0 and standard
    deviation 1. Assign it to a variable named $x$. Simulate another 1000 data points
    from a similar normal distribution and assign them to variable $y$. Run a linear
    regression of $y$ vs. $x$. Use \texttt{statsmodels} to view the statistical
    properties of the model. What is the slope of the model? Report your observations.

    I generated $y$ drawing samples from a normal distribution $N(0,1)$. The linear regression results from fitting $y$ vs. $x$ with \texttt{statsmodels} are shown below:
    \begin{figure}[h]
        \centering
        \includegraphics[scale=0.5]{ols_res.png}
        \caption{OLS Regression Results with \texttt{statsmodels}.}
        \label{fig:ols_res}
    \end{figure}

    As shown in Figure \ref{fig:ols_res}, the slope of the fitted line is -0.0309.

    \item Repeat the simulation in the previous part 100 times and gather the
    slopes in a list. Draw the distribution, and report your conclusions based
    on the result.
    \begin{figure}[h]
        \centering
        \includegraphics[scale=0.5]{slopes_dist.png}
        \caption{Distribution of slope values}
        \label{fig:slopes}
    \end{figure}

    The distribution for the slope values is centered around ~0 and has a standard
    deviation of 0.03. The slope reported by the linear regression model is roughly
    within one standard deviation of the distribution of the slope values found by
    running several simulations.
\begin{lstlisting}[language=Python, caption=Standard Error and Confidence]
import numpy as np
import statsmodels.api as sm
import numpy as np
import matplotlib.pyplot as plt

np.random.seed(0)

# Simulate 1000 data points from a normal distribution with a mean 0 and std 1
x = np.random.normal(0,1,1000)
y = np.random.normal(0,1,1000)

# Fit the model
x_with_intercept = sm.add_constant(x)
model = sm.OLS(y, x_with_intercept).fit()
y_hat = model.predict(x_with_intercept)

# Print the results
print(model.summary())

# Repeat the simulation 100 times
slopes = []
for i in range(100):
  x = np.random.normal(0,1,1000)
  y = np.random.normal(0,1,1000)
  x_with_intercept = sm.add_constant(x)
  model = sm.OLS(y, x_with_intercept).fit()
  slopes.append(model.params[1])

# Get the mean and std dev of the distribution
slope_std = np.std(slopes)
slope_mean = np.mean(slopes)
print(f"Slope std: {slope_std}")
print(f"Slope mean: {slope_mean}")

# Plot the distribution
plt.hist(slopes, ec='azure')
plt.title('Distribution of slope values')
plt.xlabel('OLS regression slope')
plt.ylabel('Count')
plt.savefig('/content/drive/My Drive/slopes_dist.png', dpi=300)
\end{lstlisting}

\end{enumerate}
\pagebreak

\section{Linear Regression Properties}
\begin{enumerate}[label={(\alph*)}]
    \item Assume we have fitted a linear regression model with an intercept to our
    data. Prove that the sum of residuals in the fitted model is equal to zero:
    \[
        \sum_{i=0}^n \hat{\varepsilon_i} = 0
    \]
    Proof:
    \begin{align*}
        \sum_{i=0}^n \hat{\varepsilon_i} &=
        \sum_{i=0}^n (Y_i - \widehat{Y_i}) \\
        &= Y - X(X^TX)^{-1}X^TY \\
        &= Y - X X^{-1} (X^T)^{-1}  X^T Y \\
        &= Y - I I Y \\
        &= Y - Y = 0
    \end{align*}

    \item We can write the equation for a linear regression model fitted to a dataset
    with $p$ features and $n$ data points as
    \[
        Y_i = \hat{\beta}_0 + \sum_{j=1}^p \hat{\beta}_j X_{i,j} + \hat{\varepsilon_i}
    \]
    where $X_{i,j}$ is the value of $j$-th feature for $i$-th data point and $Y_i$ is
    the response variable for the $i$-th data point. Assume we have
    \emph{centered features} in our data, meaning
    \[
        \dfrac{1}{n} \sum_{i=1}^n X_{i,j} = 0
    \]
    prove that the value of the intercept in the fitted model is equal to the
    average of the response variable in our data:
    \[
        \hat{\beta_0} = \dfrac{1}{n} \sum_{i=1}^n Y_i
    \]
    Proof:
    \begin{align*}
        \hat{\beta_0} &= \dfrac{1}{n} \sum_{i=1}^n Y_i \\
        &= \dfrac{1}{n} \sum_{i=1}^n (\hat{\beta_0} + \sum_{j=1}^p \hat{\beta_j}
        X_{i,j} + \hat{\varepsilon_i}) \\
        &= \dfrac{1}{n} \left(n\hat{\beta_0} + \sum_{i=1}^n \sum_{j=1}^p \hat{\beta_j}
        X_{i,j} + \sum_{i=1}^n\hat{\varepsilon_i} \right) \\
        &= \hat{\beta_0} + \sum_{j=1}^p \hat{\beta_j} \left(\dfrac{1}{n}
        \sum_{i=1}^n X_{i,j}\right) \\
        &= \hat{\beta_0}
    \end{align*}
\end{enumerate}

%\bibliographystyle{plain}
%\bibliography{references}
\end{document}


%
\section{Introduction}%
%
\begin{frame}[t]%
\frametitle{Optimization Algorithms}%
\begin{itemize}%
\item Many questions in the real world are actually optimization problems\only<2->{, e.g.,
\begin{itemize}%
%
\item \only<-6>{Find the \emph{shortest} tour for a salesman to visit certain set of cities\only<-2>{ in China and return to Hefei!}}\only<7->{\alert<7>{Traveling Salesman Problem}\scitep{ABCC2006TTSPACS,LLKS1985TTSPAGTOCO,GP2004TTSPAIV,L2011SGEFTSPIMSS}}%
%
\item<3-> \only<-6>{I need to transport $n$ items from here to Feixi\only<-3>{ but they are too big to transport them all at once. How can I load them best into my car so that I have to travel back and forth the least times?}}\only<7->{\alert<7>{Bin Packing Problem}\scitep{KSH1995EHFTBPP}}%
%
\item<4-> \only<-6>{Which setting of $x_1$, $x_2$, $x_3$, and $x_4$ can make $(x_1\lor\lnot x_2 \lor x_3)\land(\lnot x_2\lor\lnot x_3 \lor x_4) \land (\lnot x_1\lor\lnot x_3 \lor \lnot x_4)$ become true\only<-4>{ (or, at least, as \emph{many} of its terms as possible)?}}\only<7->{\alert<7>{Maximum (3-)Satisfiability Problem}\scitep{HS2000SAORFROS,TH2004UAIAEEFSAFSAMS,S1978TCOSP,RMK2000EASP}}%
%
\item<5-> \only<-6>{I want to build a large factory with $n$ workshops.\only<-5>{ I know the flow of material between each two workshops and now need to choose the locations of the workshops such that the overall running cost incurred by material transportation is \emph{minimized}.}}\only<7->{\alert<7>{Quadratic Assignment Problem}\scitep{MF1999ACOMATSAACFTQAP,GTD1999ACOQAP}}%
\end{itemize}%
}%
%
\item<6-> Many optimization problems are \alert<7>{\NPHard}, meaning that finding the best possible solution will usually not be possible in feasible time.%
%
\item<8-> We use metaheuristic optimization algorithms to give us good approximate solutions within acceptable runtime.%
%
\item<9-> Examples of such algorithms are\only<-19>{ %
Evolutionary Algorithms\scitep{BFM1997EA,CWM2011VOEAFRWA,BFM2000EC1BAAO,BFM2000EC2BAAO,DLJD2000EC,EM1999EC,CDGDMPP1999NIIO,GT2002AIECTAA,WGOEB}\uncover<10->{, %
Ant Colony Optimization\scitep{DMC1996ACO,DS2004ACO,GM2002APBATDOP,ZBMD2004MBSFCOACS,WGOEB}\uncover<11->{, %
Evolution Strategies\scitep{R1965ES,R1973ES,R1994ES,S1965KYASDEFIDS,S1968EOEZDT1,S1975EUNO,WGOEB}\uncover<12->{, %
Differential Evolution\scitep{WGOEB}\uncover<13->{, %
Particle Swarm Optimization\scitep{WGOEB}\uncover<14->{, %
Estimation of Distribution Algorithms\scitep{PSL2005DE,F2006DE,MMVRCC2006DE,BZSM2006DE,LZ2000DE,MM2005DE,BVPK2006DE,S2010DEFCFOAABKPARS}\uncover<15->{, %
CMA-ES\scitep{HOG1995ESAD,HO1996AANMDIESTCMA,HO2001ESCMA,HMK2003RTTCOTDESWCMACE,HK2004ETCESOMTF,H2006TCESACR,AH2005ARCESWIPS,AH2005PEOAALSEA}\uncover<16->{, and %
Local Search methods\scitep{HS2005SLSFAA,AL1997LSICO,DBSD2001DOILSA}\uncover<17->{ such as %
Simulated Annealing\scitep{SSF2002FCAIFSA,LA1987SATAA,B1987GAASA,JCS2003HC,KGV1983SA,VC1985SA,DPSW1982MCTICO,DPSW1982MCTICO2,P1970AMCMFTASOCTOCOP,WGOEB}\uncover<18->{ or %
Tabu Search\scitep{G1989TSPI,G1990TSPII,GL1993TABU,DWH1989TSTATAAATNN,BT1994TABU}\uncover<19->{, %
as well as hybrids of local and global search, such as Memetic Algorithms\scitep{M1989MA,M2002MA,MC2003AGITMA,ES2003HWOTMA,HKS2005RAIMA,DM2004MA,RS1994FMA}%
}}}}}}}}}}}\only<20->{\dots\ many}%
%
\item<20-> \alert<20>{Which of them is best (for my problem)?}%
\item<21-> \alert<21>{How can I make a good algorithm better (for my problem)?}%
%
\end{itemize}%
%
\locate{2}{\includegraphics[width=0.6\paperwidth]{\sharedPath/graphics/optimization/tsp/tsp_example/tsp_example}}{0.2}{0.29}%
\locate{3}{\includegraphics[width=0.875\paperwidth]{\sharedPath/graphics/optimization/bin_packing/bin_packing_example/bin_packing_example}}{0.0625}{0.495}%
\locate{4}{\includegraphics[width=0.55\paperwidth]{\sharedPath/graphics/optimization/sat/sat_example/sat_example}}{0.225}{0.5}%
\locate{5}{\includegraphics[width=0.85\paperwidth]{\sharedPath/graphics/optimization/qap/qap_example/qap_example}}{0.075}{0.625}%
\locate{6-7}{\includegraphics[width=0.78\paperwidth]{\sharedPath/graphics/complexity/exponential_functions/exponential_functions}}{0.09}{0.55}%
%
\end{frame}%
%
\begin{frame}[t]%
\frametitle{Algorithm Analysis and Comparison}%
\begin{itemize}%
\item \alert{Which of the algorithms is best (for my problem)?}%
\item<2-> Traditional Approach {\`{a}} la \emph{\inQuotes{QuickSort is better than Bubble Sort because it needs \bigOOf{n \log n} while Bubble Sort needs \bigOOf{n^2} steps to sort $n$ elements in the average case.}}%
%
\item<3-> Complexity Analysis, Theoretical Bounds of Runtime and Solution Quality%
\item<4-> \alert<-9>{Usually not feasible}\uncover<5->{%
\begin{itemize}%
\item analysis extremely complicated\uncover<6->{ since%
\item<6-> algorithms are usually randomized\uncover<7->{ and%
\item<7-> have many parameters (e.g., crossover rate, population size)\uncover<8->{ and%
\item<8-> \inQuotes{sub-algorithms} (e.g., crossover operator, mutation operator, selection algorithm)%
\item<9-> optimization problems also differ in many aspects%
\item<10-> theoretical results only available for toy problems and extremely simplified algorithms.%
\item<11-> \alert<10>{Currently, not mature enough to be an easy-to-use tool for practitioners}%
}}}%
\end{itemize}%
}%
%
\item<12-> \alert{Experimental analysis and comparison only practical alternative.}%
%
\end{itemize}%
\end{frame}%
%
%
%
\begin{frame}%
\frametitle{Performance and Anytime Algorithms}%
%
\emph{\inQuotes{We use metaheuristic optimization algorithms to give us \alert<3->{good approximate solutions} within \alert<4->{acceptable runtime}.}}%
%
\uncover<2->{%
\begin{itemize}%
\item Algorithm performance has two dimensions\scitep{NAFR2010RPBBOB2ES,WCTLTCMY2014BOAAOSFFTTSP}:\uncover<3->{ solution quality\uncover<4->{ and required runtime}}%
\item<5-> Anytime Algorithms\scitep{BD1989STDPP2} are optimization methods which maintain an approximate solution at \emph{any time} during their run and iteratively improve this guess.%
\item<6-> All metaheuristics are Anytime Algorithms.%
\item<7-> Several exact methods like Branch-and-Bound\scitep{LMSK1963AAFTTSP,Z1993TBABACSOTATSP,Z1999TAADFBABACSOTATSP} are Anytime Algorithms.%
\item<8-> Consequence: Most optimization algorithms produce approximate solutions of different qualities at different points during their process.%
\item<9-> Experiments must capture solution quality and runtime data.%
\end{itemize}%
}%
%
\locate{3}{\includegraphics[width=0.55\paperwidth]{\sharedPath/graphics/optimization/performance/performance_dimensions/performance_dimensions_1}}{0.225}{0.542}%
\locate{4}{\includegraphics[width=0.55\paperwidth]{\sharedPath/graphics/optimization/performance/performance_dimensions/performance_dimensions_2}}{0.225}{0.542}%
\locate{5}{\includegraphics[width=0.55\paperwidth]{\sharedPath/graphics/optimization/performance/performance_dimensions/performance_dimensions}}{0.225}{0.542}%
%
\end{frame}%
%
\begin{frame}[t]%
\frametitle{Experimental Procedure}%
\begin{itemize}%
\item In optimization or Machine Learning, the following experimental procedure is often used\uncover<2->{%
\begin{enumerate}%
\item Select a \only<3->{\alert<3>{set of }}benchmark instance\only<3->{\alert<3>{s}}\only<3-7>{:%
\begin{itemize}%
\item multiple instances%
\item<4-> which cover some different problem features%
\item<5-> should be well-known to make results comparable%
\only<-6>{%
\item<6-> e.g., \tspLib\expandafter\scitep{\tspLibReferences} for the TSP has instances with different numbers of cities and geometries%
}%
\only<-7>{%
\item<7-> e.g., \bbob\expandafter\scitep{\bbobReferences} offers different benchmark functions for numerical optimization problems%
}%
\end{itemize}%
}%
\item<8-> Do experiment\only<12->{\alert<12-13>{s}}\only<9-13>{:%
\begin{itemize}%
\item conduct several independent runs of algorithm for each benchmark instance%
\item<10-> collect algorithm progress informatio, e.g., as \emph{\inQuotes{runtime bestObjectiveValue}} tuples%
\item<11-> one log file per run, each log file has several such tuples%
\item<12-> repeat for different algorithm parameter settings (e.g., different population sizes of an EA)%
\item<13-> repeat with other algorithms for comparison purposes%
\end{itemize}%
}%
\item<14-> Evaluate the gathered data\only<15->{:\alert<22>{%
\begin{itemize}%
\item draw diagrams of progress of solution quality over time%
\item<16-> draw diagrams of advanced statistical parameters such as ECDF\scitep{HAFR2012RPBBOBES,HS1998ELVAPAR,TH2004UAIAEEFSAFSAMS,WCTLTCMY2014BOAAOSFFTTSP}\only<17->{ and ERT\scitep{HAFR2012RPBBOBES,WCTLTCMY2014BOAAOSFFTTSP}} (over time)%
\item<18-> use statistical tests to compare results (at different points during the runs)%
\item<19-> analyze the impact of benchmark features and algorithm parameters on the above%
\end{itemize}%
}}%
%
\item<20-> Draw conclusions about algorithm performance and parameter settings%
\item<21-> But this is all \emph{very} cumbersome, involves much work and much data\dots
\end{enumerate}%
}%
\item<22-> The \optimizationBenchmarking\ Evaluator can automatize much of this work%
\end{itemize}%
%
\locateWithCaption{6}{%
\includegraphics[width=0.925\paperwidth]{\sharedPath/graphics/optimization/tsp/tspLib_features/tspLib_features_symmetric}%
}{%
The relative amounts of the instances of the 110 symmetric instances of \tspLib\ according to their features (the 10 asymmetric instances are not plotted).%
}{0.0375}{0.51}{0.925}%
%
\locateWithCaption{7}{%
\pgfuseimage{bbob_features}%
}{%
The relative amounts of \bbob\ benchmark functions according to their features.%
}{0.0375}{0.51}{0.925}%
%
\locateWithCaption{10}{%
\includegraphics[width=0.8\paperwidth]{\sharedPath/graphics/optimization/tsp/tspSuite_logfile_example/tspSuite_logfile_example}%
}{%
Example for data collected in a log file by \tspSuite\scitep{\tspSuiteReferences}.%
}{0.0375}{0.53}{0.925}%
%
\locateWithCaption{15-17}{
\strut%
\includegraphics[width=0.28\paperwidth]{\sharedPath/graphics/optimization/performance/progress_example/progress_example}%
\uncover<16->{%
\strut\hfill\strut%
\includegraphics[width=0.28\paperwidth]{\sharedPath/graphics/optimization/performance/ecdf_example/ecdf_example}%
\uncover<17->{%
\strut\hfill\strut%
\includegraphics[width=0.28\paperwidth]{\sharedPath/graphics/optimization/performance/ert_example/ert_example}%
}}\strut%
}{%
Examples for progress\only<16>{ and ERT}\only<17->{, ERT, and ECDF} diagrams for different algorithms (signified by different colors) over different sub-sets of the \tspLib\ data.%
}{0.0375}{0.525}{0.925}%
%
\end{frame}%
%
%


\section*{vEB - Peter Christensen}

\begin{enumerate}
	\item Define the goal: To get algorithm with $O(\log\log u)$ runtime for universe of size U
	\item A recursion tree that where the input shrinks $\sqrt{u}$ and constant work in the leafs would give that.
	\item Show an example of a bit vector tree, where the leafs are spint into cluster and the parent are the summart vector.
	\item Define the structure vEb with a $u$, summary, cluster, min, max.
	\item Go through an example of how the structure works, such as Figure~20.6.
	\item go through insert and predecessor algorithm and explain how it works.
\end{enumerate}


\documentclass[../psets.tex]{subfiles}

\pagestyle{main}
\renewcommand{\leftmark}{Problem Set \thesection}

\begin{document}

\section{Mechanical Waves}
\begin{enumerate}[label={\arabic*)}]
    \item \marginnote{8/9:}\textcite{bib:YoungFreedman}: Problem 15.9.\par
    Which of the following wave functions satisfies the wave equation?
    \begin{enumerate}
        \item $y(x,t)=A\cos(kx+\omega t)$.
        \item $y(x,t)=A\sin(kx+\omega t)$.
        \item $y(x,t)=A(\cos kx+\cos\omega t)$.
        \item For the wave of part (b), write the equations for the transverse velocity and transverse acceleration of a particle at point $x$.
    \end{enumerate}
    \item \textcite{bib:YoungFreedman}: Problem 15.26.\par
    A fellow student with a mathematical bent tells you that the wave function of a traveling wave on a thin rope is $y(x,t)=(\SI{2.30}{\milli\meter})\cos[(\SI{6.98}{\radian\per\meter})x+(\SI{742}{\radian\per\second})t]$. Being more practical, you measure the rope to have a length of $\SI{1.35}{\meter}$ and a mass of $\SI{0.00338}{\kilo\gram}$. You are then asked to determine:
    \begin{enumerate}
        \item Amplitude.
        \item Frequency.
        \item Wavelength.
        \item Wave speed.
        \item Direction the wave is traveling.
        \item Tension in the rope.
        \item Average power transmitted by the wave.
    \end{enumerate}
    \item \textcite{bib:YoungFreedman}: Problem 15.30.\par
    \textbf{Interference of Triangular Pulses.} Two triangular wave pulses are traveling toward each other on a stretched string as shown below. Each pulse is identical to the other and travels at $\SI{2.00}{\centi\meter\per\second}$. The leading edges of the pulses are $\SI{1.00}{\centi\meter}$ apart at $t=0$. Sketch the shape of the string at $t=\SI{0.250}{\second}$, $t=\SI{0.500}{\second}$, $t=\SI{0.750}{\second}$, $t=\SI{1.000}{\second}$, and $t=\SI{1.250}{\second}$.
    \begin{center}
        \begin{tikzpicture}[scale=1.2]
            \footnotesize
            \draw [orx,very thick] (0,0)
                -- (1,0)
                -- (2,1)
                -- (3,0)
                -- (4,0)
                -- (5,1)
                -- (6,0)
                -- (7,0)
            ;

            \draw [very thin,|-|] (0.85,0.05) -- node[left]{$\SI{1.00}{\centi\meter}$} ++(0,0.95);
            \draw [very thin,|-|] (1,-0.15) -- node[below]{$\SI{1.00}{\centi\meter}$} ++(1,0);
            \draw [very thin,|-|] (2,-0.15) -- node[below]{$\SI{1.00}{\centi\meter}$} ++(1,0);
            \draw [very thin,|-|] (3,0.3) -- node[above]{$\SI{1.00}{\centi\meter}$} ++(1,0);
            \draw [very thin,|-|] (4,-0.15) -- node[below]{$\SI{1.00}{\centi\meter}$} ++(1,0);
            \draw [very thin,|-|] (5,-0.15) -- node[below]{$\SI{1.00}{\centi\meter}$} ++(1,0);
            \draw [very thin,|-|] (6.15,0.05) -- node[right]{$\SI{1.00}{\centi\meter}$} ++(0,0.95);

            \draw [grx,ultra thick,-latex] (2,1.1) -- node[above=1mm,black]{$v=\SI{2.00}{\centi\meter\per\second}$} ++(1,0);
            \draw [grx,ultra thick,-latex] (5,1.1) -- node[above=1mm,black]{$v=\SI{2.00}{\centi\meter\per\second}$} ++(-1,0);
        \end{tikzpicture}
    \end{center}
    \item \textcite{bib:YoungFreedman}: Problem 15.32.\par
    \textbf{Interference of Rectangular Pulses.} The below figure shows two rectangular wave pulses on a stretched string traveling toward each other. Each pulse is traveling with a speed of $\SI{1.00}{\milli\meter\per\second}$ and has the height and width shown in the figure. If the leading edges of the pulses are $\SI{8.00}{\milli\meter}$ apart at $t=0$, sketch the shape of the string at $t=\SI{4.00}{\second}$, $t=\SI{6.00}{\second}$, and $t=\SI{10.0}{\second}$.
    \begin{center}
        \begin{tikzpicture}[scale=1.2]
            \footnotesize
            \draw [orx!60!black,line join=round,double=orx,double distance=1.2pt] (0,0)
                -- (1,0)
                -- (1,0.75)
                -- (2,0.75)
                -- (2,0)
                -- (4,0)
                -- (4,-1)
                -- (5,-1)
                -- (5,0)
                -- (6,0)
            ;

            \draw [very thin,|-|] (0.5,0.05) -- node[xshift=-0.05cm,fill=white,inner sep=2pt]{$\SI{3.00}{\milli\meter}$} ++(0,0.7);
            \draw [very thin,|-|] (1,0.9) -- node[above]{$\SI{4.00}{\milli\meter}$} ++(1,0);
            \draw [very thin,|-|] (2,-0.15) -- node[below]{$\SI{8.00}{\milli\meter}$} ++(1.95,0);
            \draw [very thin,|-|] (4,-1.15) -- node[below]{$\SI{4.00}{\milli\meter}$} ++(1,0);
            \draw [very thin,|-|] (5.5,-0.05) -- node[xshift=0.05cm,fill=white,inner sep=2pt]{$\SI{4.00}{\milli\meter}$} ++(0,-0.95);

            \draw [grx,ultra thick,-latex] (2.1,0.4) -- ++(0.5,0) node[right,black]{$v=\SI{1.00}{\milli\meter\per\second}$};
            \draw [grx,ultra thick,-latex] (3.9,-0.75) -- ++(-0.5,0) node[left,black]{$v=\SI{1.00}{\milli\meter\per\second}$};
        \end{tikzpicture}
    \end{center}
    \item \textcite{bib:YoungFreedman}: Problem 15.34.\par
    Adjacent antinodes of a standing wave on a string are $\SI{15.0}{\centi\meter}$ apart. A particle at an antinode oscillates in simple harmonic motion with amplitude $\SI{0.850}{\centi\meter}$ and period $\SI{0.0750}{\second}$. The string lies along the $+x$-axis and is fixed at $x=0$.
    \begin{enumerate}
        \item How far apart are the adjacent nodes?
        \item What are the wavelength, amplitude, and speed of the two traveling waves that form this pattern?
        \item Find the maximum and minimum transverse speeds of a point at an antinode.
        \item What is the shortest distance along the string between a node and an antinode?
    \end{enumerate}
    \item \textcite{bib:YoungFreedman}: Problem 15.64.\par
    A strong string of mass $\SI{3.00}{\gram}$ and length $\SI{2.20}{\meter}$ is tied to supports at each end and is vibrating in its fundamental mode. The maximum transverse speed of a point at the middle of the string is $\SI{9.00}{\meter\per\second}$. The tension in the string is $\SI{330}{\newton}$.
    \begin{enumerate}
        \item What is the amplitude of the standing wave at its antinode?
        \item What is the magnitude of the maximum transverse acceleration of a point at the antinode?
    \end{enumerate}
    \item A harmonic wave travels down a string in the $+x$ direction. At position $x=0$ and time $t=0$, the following is observed: the displacement of the string is $+\SI{1.0}{\centi\meter}$, the transverse velocity is $-\SI{2.0}{\centi\meter\per\second}$, and the transverse acceleration is $-\SI{4.0}{\centi\meter\per\square\second}$.
    \begin{enumerate}
        \item What is the frequency of the wave?
        \item What is the amplitude of the wave?
    \end{enumerate}
    \item A long, uniform rope of length $L$ hangs vertically. The only tension in the rope is that produced by its own weight.
    \begin{enumerate}
        \item Show that, as a function of the distance $y$ from the lower end of the rope, the speed of a transverse wave pulse on the rope is $\sqrt{gy}$.
        \item How much time does it take for a wave pulse to travel from one end of the rope to the other?
    \end{enumerate}
    \item Using continuity conditions on a string, we derived the relative amplitudes for transmitted and reflected waves at a boundary. Show that the average power of the \emph{transmitted} wave plus the average power of the \emph{reflected} wave is equal to the average power of the \emph{incident} wave. (Otherwise, energy would not be conserved.)
\end{enumerate}

\end{document}


\chapter{Seamless modeling of retarded vdW interactions}\label{chap:casimir}

{\sffamily\mathversion{sans} This chapter briefly discusses the extension of the MBD method to distances at which the finite speed of light cannot be neglected, resulting in the so-called retarded vdW (Casimir) interactions.
Previously, microscopic models of vdW interactions such as MBD were restricted to the non-retarded regime, whereas the macroscopic continuous models used for description of Casimir interactions could not be used at short distances and must have been parametrized from experimental data.
Here, we show that these two descriptions can be unified within a single framework, which then enables seamless calculation of vdW energies both at the non-retarded and retarded (Casimir) regimes.
This unification also extends the applicability of the new developments in Chapter~\ref{chap:polarizability}, because any improvements in a model of material response can be directly used in the study of Casimir physics.
The results discussed in this chapter have been published in \citep*{VenkataramPRL17}.
The Maxwell-equation scattering calculations were done by Prashanth Venkataram, the DFT and polarizability screening calculations by myself, and the unified theoretical framework is a result of joint work.
}\vspace{1em}

The ACFD formula and hence the MBD correlation energy in~\eqref{eq:mbd-rpa} originate from the nonrelativistic quantum mechanics, which assumes that the electromagnetic forces in the form of the Coulomb law acts instantly over any distance.
This limits the applicability of MBD to systems that are separated by less than hundreds of angstroms, at which point the time it takes for light to travel between the interacting objects becomes comparable to the frequency of the electronic oscillations that drive the vdW interactions.
(The speed of light, $c$, in atomic units is approximately 137, the inverse of the fine-structure constant.)
The well-known effect of this retardation of the electromagnetic force is the asymptotic $1/R^7$ attraction that replaces the nonrelativistic $1/R^6$ power law.

The extension of MBD to account for this retardation consists of two steps.
First, the instantaneous dipole operator (eq.~\ref{eq:dipole-op}) is replaced with its frequency-dependent retarded version, which is proportional to the Green's function, $\boldsymbol G_0$, of the electric field,
\begin{equation}
  \tilde{\mathbf T}(\mathbf R,u)=\frac{4\pi u^2}{c^2}\boldsymbol G_0=\big(\boldsymbol\nabla\otimes\boldsymbol\nabla'-\tfrac{u^2}{c^2}\mathbf I\big)\mathrm e^{-|\mathbf r-\mathbf r'|u/c}v(|\mathbf r-\mathbf r'|)\Big|_{\substack{\mathbf r=\mathbf R\\\mathbf r'=\mathbf 0}}
  \label{eq:green-maxwell}
\end{equation}
This substitution prevents one to perform the analytic integration over frequencies analytically (see eq.~\ref{eq:mbd-rpa}), but otherwise it is a straightforward modification of the MBD method.

The second step is necessary only because of the kind of systems that we want to study.
The prototypical systems studied in the context of Casimir interactions consist of small microscopic bodies such as molecules, and macroscopic objects with nontrivial shapes or surface gratings~\cite{RodriguezNP11,WoodsRMP16}.
The latter are typically large enough that microscopic description of individual atoms in them is unnecessary and, furthermore, such large atomic calculations would be unfeasible.
As an alternative, efficient approaches solve directly the continuous Maxwell equations either with scattering or finite-differencing methods~\cite{RodriguezPRA07,RahiPRD09}.
This raises the issue of connecting the continuous and microscopic descriptions.
It turns out that such a connection is naturally enabled by the form of the MBD expression for the interaction energy.
Consider the MBD interaction energy of two bodies, $A$ and $B$,
\begin{equation}
\begin{aligned}
E_\text{int}&=E_{AB}-E_{A}-E_{B} \\
&=\frac1{2\pi}\int_0^\infty\mathrm du\operatorname{Tr}\big(\ln(1+(\boldsymbol\alpha_A+\boldsymbol\alpha_B)\tilde{\mathbf T})-\ln(1+\boldsymbol\alpha_A\tilde{\mathbf T})-\ln(1+\boldsymbol\alpha_B\tilde{\mathbf T})\big) \\
&=\frac1{2\pi}\int_0^\infty\mathrm du\operatorname{Tr}\big(\ln((1+\boldsymbol\alpha_A\tilde{\mathbf T}+\boldsymbol\alpha_B\tilde{\mathbf T})(1+\boldsymbol\alpha_A\tilde{\mathbf T})^{-1}(1+\boldsymbol\alpha_B\tilde{\mathbf T})^{-1})\big) \\
&=\frac1{2\pi}\int_0^\infty\mathrm du\operatorname{Tr}\big(\ln((1+\boldsymbol\alpha_B\tilde{\mathbf T}(1+\boldsymbol\alpha_A\tilde{\mathbf T})^{-1})(1+\boldsymbol\alpha_B\tilde{\mathbf T})^{-1})\big) \\
&\equiv\frac1{2\pi}\int_0^\infty\mathrm du\operatorname{Tr}\big(\ln((1+\boldsymbol\alpha_B\tilde{\mathbf T}_A)(1+\boldsymbol\alpha_B\tilde{\mathbf T})^{-1})\big) \\
&=\frac1{2\pi}\int_0^\infty\mathrm du\operatorname{Tr}\big(\ln(1+\boldsymbol\alpha_B\tilde{\mathbf T}_A)-\ln(1+\boldsymbol\alpha_B\tilde{\mathbf T})\big) \\
&=E_B(\tilde{\mathbf T}_A)-E_B(\tilde{\mathbf T})
\end{aligned}
\label{eq:casimir-mbd}
\end{equation}
Here, we defined $\tilde{\mathbf T}_A=\tilde{\mathbf T}(1+\boldsymbol\alpha_A\tilde{\mathbf T})^{-1}$, which is the retarded dipole operator screened by the electromagnetic response of the body $A$, and the interaction energy between $A$ and $B$ was recast as the difference in the total energy of $B$ calculated with the bare and screened dipole operators.
The definition of $\tilde{\mathbf T}_A$ has the form of a Dyson-like equation analogous to that for the interacting nonlocal polarizability, which points to two equivalent points of view on the ground-state system of bodies of matter interacting via the electromagnetic force---one as fluctuating polarizations of the electronic density propagated (in the Green's function sense) by the electromagnetic field, the other as fluctuations in the electromagnetic field propagated by the electronic response of the matter.

\begin{figure}[t]
\centering
\includegraphics[width=10cm]{media/casimir.pdf}
\caption{\textbf{Retardation effects in vdW interactions.}
Interaction energies of a perpendicular (black) and parallel (red) carbyne wire, fullerene C$_{500}$, and a protein with a golden surface calculated with different models are plotted relative to the prediction of a pairwise approximation as a function of the vertical distance, $z$.
$\mathcal{E}$ is the full retarded MBD method (eq.~\ref{eq:casimir-mbd}), $\mathcal{E}_0$ is the nonrelativistic approximation ($c\rightarrow\infty$ in~\eqref{eq:green-maxwell}), and $\mathcal E_\text{CP}$ is the so-called ``Casimir--Polder approximation'' which approximates the whole microscopic object with a single point.
The inset shows the local power-law asymptote for the plate--fullerene system.
}\label{fig:casimir}
\end{figure}

Using the formulation in~\eqref{eq:casimir-mbd}, the MBD interaction energy of a macroscopic body (which can be also a collection of macroscopic bodies) and a set of microscopic objects can be calculated in the following way.
First, one obtains the Green's function of the electric field in the presence of the macroscopic body by an efficient continuous macroscopic method.
Second, the screened retarded dipole operator is calculated from the Green's function using~\eqref{eq:green-maxwell}.
Third, the vdW interaction energy is calculated using the regular MBD method with the screened and bare dipole operators according to~\eqref{eq:casimir-mbd}.
Figure~\ref{fig:casimir} illustrates the effects of the retardation on the interactions of several prototypical systems with a golden plate.
The full retarded MBD interaction energy calculated with~\ref{eq:casimir-mbd} transitions between the nonrelativistic approximation (the regular MBD), which becomes exact at short distances, and the relativistic Casimir--Polder approximation, which models the microscopic objects as point objects, and becomes exact at large separations.
In this regard, this unified framework represents a new seamless approach to multi-scale modeling that enables accurate description of intermolecular interactions at a range spanning several orders of magnitude.


\documentclass{article}
\usepackage{fullpage}
\usepackage{nopageno}
\usepackage{amsmath}
\allowdisplaybreaks

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

\begin{document}
\title{Notes}
\date{December 4, 2013}
\maketitle
\section*{8.7}
application of laplace transform is what the section is about. we are only doing one application. L-R-C circuit
\begin{align*}
  Q(t)&=\text{charge}\\
  Q'(t)&=\frac{\mathrm{d}Q(t)}{\mathrm{d}t}=\text{current}\\
  L\frac{\mathrm{d}^2Q}{\mathrm{d}t^2}+R\frac{\mathrm{d}Q}{\mathrm{d}t}+\frac{Q}{C}&=E(t)\\
  Q(o)&=Q_0\\
  \frac{\mathrm{d}Q}{\mathrm{d}t}(0)&=I_0\\
  C&=\text{capacitor Faradey F}\\
  L&=\text{inductor Henry H}\\
  R&=\text{resistance Ohm \omega}\\
  E&=\text{voltage Volts V}
\end{align*}
\subsection*{exercise 1}
suppose that we consider a circuit ith a capacitor C a resistor R and a voltage supply $E(t)=\left\{\begin{aligned}100&,\quad0\leq t\leq1\\0&,\quad t\geq 1\end{aligned}\right.$. If  $L=0$ find $Q(t)$ and $I(t)$ if $Q(0)=0$, $C=\frac{1}{50}F$ and $R=50\omega$
\begin{align*}
  E(t)&=100-100U(t-1)\\
  50\frac{\mathrm{d}Q}{\mathrm{d}t}+50Q&=100-100U(t-1)\\
  Q'+Q=2-2U(t-1) \intertext{take laplace transform}\\
  \mathcal{L}\{Q'\}&=s\mathcal{L}\{Q\}-Q(0)\\
  s\mathcal{L}\{Q\}-Q(0)+\mathcal{L}\{Q\}&=\frac{2}{s}-2\frac{e^{-s}}{s}\\
  \mathcal{L}\{Q\}(s+1)&=2\left(\frac{1}{s}-\frac{e^-s}{s}\right)\\
  \mathcal{L}\{Q\}&=\frac{2}{s(s+1)}-\frac{2e^{-s}}{s(s+1)}\\
  \frac{2}{s(s+1)}&=\frac{A}{s}+\frac{B}{s+1}\\
  2&=A(s+1)+Bs\\
  A&=2,\quad A+B=0\\
  B&=-2\\
  \mathcal{L}\{Q\}&=(\frac{2}{s}-\frac{2}{s+1})-e^{-s}(\frac{2}{s}-\frac{2}{s+1})\\
  Q(t)&=2-2e^{-t}-(2-2e^{1-t})U(t-1)\intertext{case 1, $0<t<1$}\\
  \frac{\mathrm{d}U}{\mathrm{d}t}&=0\\
  \frac{\mathrm{d}Q}{\mathrm{d}t}&=2e^{-t}\intertext{case 2, $t>1$}\\
\end{align*}

\section*{6.3 linear system}
\begin{align*}
  2x+3y&=5\\
  3x+9y&=6\\
  Ax=b\\
  A&=\left(\begin{array}{cc}2&3\\3&9\end{array}\right),X=\left(\begin{array}{c}x\\y\end{array}\right),b=\left(\begin{array}{c}5\\6\end{array}\right)\\
  X&=A^{-1}b
\end{align*}
consider $y''+5y'+2y=\cos t$ can you write this in system?
\begin{align*}
  y'&=x\\
  y''&=x'\\
  y''&=-5y'-2y+\cos t\\
  &=-5x-2y+\cos t\\
  x'&=\\
  y'&=
\end{align*}
\end{document}


% \chapter{Reproduction of GCN}

\section{Graph Convolution Layer and GCN model}

A neutral network based on graph convolution consists of layers of graph convolution and non-linear activation function. To reproduct the work of Kipf et al.\cite{DBLP:journals/corr/KipfW16}, a neutral network is modeled by the forward function in Equation \ref{forward-function-in-gcn}.

\begin{equation}
    Z = f(X, A) = \text{softmax} \left(\hat{A}\cdot \text{ReLU}\left(\hat{A}XW^{(0)}\right)W(1)\right)
    \label{forward-function-in-gcn}
\end{equation}

\section{Model Implement and Experiment}

The reproduced model is based on PyTorch package, which contains built-in neutral network model frameworks. The codes are attached in Appendix.

To regain the training result in the work of Kipf et al\cite{DBLP:journals/corr/KipfW16}, the model implements the same hyperparameters, as shown in Table \ref{hyperparam-gcn}.

\medskip

\begin{table}[H]
    \centering
    \small
    \begin{tabular}{cccccc}
        \hline
        random seed & hidden units & dropout rate & learning rate & weight decay for L2 loss & epochs \\
        24 & 16 & 0.5 & 0.01 & 5e-4 & 200 \\
        \hline
    \end{tabular}
    \caption{Hyperparameters in GCN Reproduction}
    \label{hyperparam-gcn}
\end{table}

\section{Comparison and Result}

The training is carried out on \textbf{Cora} dataset\cite{Sen_Namata_Bilgic_Getoor_Galligher_Eliassi-Rad_2008} in both reproducable random split measures. The result performance is calculated on the basis on 20 trainings, which

The original paper performance and comparison is shown in Table \ref{result-comparison}.

\begin{table}[H]
    \centering
    \small
    \begin{tabular}{lll}
        \hline
        model & Cora & Citeseer \\
        \hline
        ManiReg\cite{ManiReg} & 59.5 & 60.1 \\
        SemiEmb\cite{SemiEmb} & 59.0 & 59.6 \\
        LP\cite{LP} & 68.0 & 45.3 \\
        DeepWalk\cite{DeepWalk} & 67.2 & 43.2 \\
        ICA\cite{ICA} & 75.1 & 69.1 \\
        Planetoid*\cite{DBLP:journals/corr/YangCS16} & 75.7 & 64.7 \\
        GCN (paper) & 81.5 & 70.3 \\
        GCN (paper, rand splits) & 80.1$\pm$0.5 & 67.9$\pm$0.5 \\
        \hline
        GCN (reproduced) & 82.5 & 73.1 \\
        \hline
    \end{tabular}
    \caption{Comparison of GCN and Other Model Performance}
    \label{result-comparison}
\end{table}

The results of reproduction generally matches the original performance. The reproduction appears to have slightly higher accuracy rate, which can be caused by sample shuffling and difference in train-valid-test ratio. The reproduction is in all satisfactory.