\documentclass{article}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage[section]{placeins}

\hypersetup{
  colorlinks, linkcolor=red
}

\begin{document}

\title{CS838 Lab 3}
\author{Sek Cheong}
\maketitle

%\begin{abstract}
%The abstract text goes here.
%\end{abstract}

\section{Introduction}
The purpose of this project is to build a convolutional neural network (CNN) that is capable to classify images into six categories. The categories are airplane, butterfly, flower, grand  piano, starfish, and  watch. In this project we will create an CNN in Java and train it with the given training set and tuning set, and the we use the trained model to predict the images in a given test set. We will first plot the learning curve against the percentage of the train set being used, and we will the plot the learning curve against the number of epochs.

\section{The Model}
We use the model as shown in the following illustration. The model consists of an input layer, three convolution, LuRe, Max Pool layers, and followed by a fully connected layer and a Softmax output layer with six classes. The width and height of the input layer correspond to the image width and height. The allowable image sizes are 8x8, 16x16, 32x32, 64x64, and 128x128.

\begin{figure}[!ht]
  \centering
  \includegraphics[width=4.5in]{layers.png}
  \label{networkmodel}
  \caption{The network model}
\end{figure}

\section{The Experiment}
The first experiment is to create a learning curve that shows the accuracy verses the percentage of training sample being used. To ensure repeatability, we set the epoch to $50$ and no early stop. We start with $10\%$ of the training sample and in increment of $10\%$ in each iteration until it reaches $100\%$ of the training samples. The tuning and testing set are the full set and remain unchanged in the entire test.

\begin{figure}[!ht]
 \centering
  \includegraphics[width=4.8in]{size.eps}
 \label{trainsize}
 \caption{Learning curve: Accuracy vs Training set size}
\end{figure}

In the second experiment we create a learning curve that shows the accuracy verses the number of epoch the network has been trained. In this experiment we observed that the network reached its best accuracy at around $46$ epochs. The best accuracy is around $80\%$. As epoch increases the accuracy fluctuates between $70\%$ to $80\%$ then it steadily decreases to around $60\%$.

\begin{table}[ht]
  \caption{The Confusion table}
  \centering
  \begin{tabular}{ | l | r | r | r| r | r | r |}
    \hline
                & airplane & butterfly  & flower    &   piano  &  starfish &   watch\\ \hline
    airplane    &    38    &     0      &     1     &     0    &      0    &     2 \\
   butterfly    &    0     &    15      &     2     &     2    &      3    &     2 \\
      flower    &    1     &     2      &    27     &     0    &      2    &     0 \\
       piano    &    0     &     0      &     2     &    16    &      2    &     0 \\
    starfish    &    1     &     1      &     4     &     0    &      9    &     3 \\
       watch    &    1     &     0      &     1     &     1    &      1    &    39 \\
    \hline
  \end{tabular}
\end{table}

\begin{figure}[!ht]
 \centering
  \includegraphics[width=4.8in]{epoch.eps}
 \label{trainepoch}
 \caption{Learning curve: Accuracy vs Epoch}
\end{figure}

\begin{figure}[!ht]
 \centering
  \includegraphics[width=3.0in]{epoch_46_l1_filters.png}
 \label{L1filters}
 \caption{Visualization of the first convolution filters layer filters}
\end{figure}

\begin{figure}[!ht]
 \centering
  \includegraphics[width=3.0in]{epoch_46_l2_activation.png}
 \label{L1Act}
 \caption{Visualization of the first convolution layer activation}
\end{figure}

\begin{figure}[!ht]
 \centering
  \includegraphics[width=3.0in]{epoch_46_l5_filters.png}
 \label{L1filters}
 \caption{Visualization of the second convolution layer filters}
\end{figure}

\begin{figure}[!ht]
 \centering
  \includegraphics[width=3.0in]{epoch_46_l5_activation.png}
 \label{L1Act}
 \caption{Visualization of the second convolution layer activation}
\end{figure}

\section{Discussion}
From the confusion table it appears that the most hard to predict picture is star fish. The is probably due to the fact that some star fish look resemble either butterfly or flower. We tried picture of various sizes and were able to get the similar results on 16x16 images but the 8x8 images give poor results.

\end{document}


\chapter{Evaluation}
Experiments of the performance of our system is evaluated here.
We evaluate our event detection and scene recognition system respectively.
For both event and scene evaluation, we have a evaluation on self model tuning, and another evaluation for system comparison.

\section{Event Detection Evaluation}
\subsection{Evaluation Data and Metric}
The evaluation for event detection uses data from IEEE AASP Challenge for event detection\footnote{http://c4dm.eecs.qmul.ac.uk/sceneseventschallenge}.
In this challenge, a training dataset are given containing instantiations of individual events for 16 different classes.
Moreover, there is also a developement dataset, which consist of 1 minute recordings of every-day audio events in a number of office environments.
This developement dataset is annotated by human and can be used for model evaluation. \\

The evaluation begins by first segmenting clips using the a segmenter.
We assume that only one event happens during a segment.
Then use the trained GMM to calculate the posterior probability.
The detected event is chosen when its corresponding GMM has the highest posterior probability.\\

Three types of assessment of the various systems will take place, i.e., a frame-based, event-based, and class-wise event-based evaluation \cite{giannoulis2013database}.  These three metrics differ mainly in the way they interpret a sequence result of detected events.
Suppose $r$, $e$ and $c$ denotes number of ground truth, estimated and correct events, the Precision, Recall, and F-measure are defined as:
\begin{equation}
	P = \frac{c}{e}, R = \frac{c}{r}, F = \frac{2PR}{P+R}.
\end{equation}
For the frame-based metric, $r$, $e$, and $c$ are calculated in a 10ms window and are averaged over the entire duration.
The event-based metric takes a different perspective of how a event unit is calculated.
Unlike frame-based metric, which undiscriminately count event for every 10ms, this metric focuses on the true onset and offset time of ground truth events.
Onset-only evaluation set restriction on onset time tolerance.
Onset-offset evaluation further add a offset time restriction.
The onset-only and onset-offset evaluation are averaged as event-based metric.
Class-wise event-based calculate $r$, $e$, and $c$ for each class separately. And then it is averaged over classes.
Finally, the F-measure for these three metric are averaged as the final metric of a system, and we will compare this metric with other systems.

\subsection{Evaluation Result}

\subsubsection{Self Tuning}
Audio events are detected using the previous proposed GMM method, but there are still some parameters or configuration to be tuned for the best performance of our model.
Most importantly, the number of component number in GMM are ser by human, we run a evaluation for different component numbers from 4 to 45 to see how the number affects the F-measure.
Figure \ref{fig:component} is the result of average F-measure with regard to different component numbers in GMM.
% component.eps
\begin{figure}[htb!]
\centering
\input{figure/evaluation/component}
\caption{F-measure for different component number}
\label{fig:component}
\end{figure}

As we can see in Figure \ref{fig:component}, the F-measure gradually rise when component number are increasing.
But after component number reaching 18 or so, the F-measure roughly stays the same.

% running time eps
\begin{figure}[htb!]
\centering
\input{figure/evaluation/componentTime}
\caption{Running time for different componet number}
\label{fig:componentTime}
\end{figure}
Moreover, Figure \ref{fig:componentTime} is the running time of our system with regard to the number of components.
There is basically a linear relationship between the number of components and the total running time.
Hence, we choose to use 18 as the component number for our system, since this component number has a good F-measure, and the speed for training models are also fast.

\subsubsection{System Comparison}
In system comparison, we use other models from the aforementioned IEEE AASP Challenge\footnote{http://c4dm.eecs.qmul.ac.uk/sceneseventschallenge/resultsOL.html}.
In the submitted papers, contestents also carried out the same evaluation on the developement dataset, so the comparison are done on the same dataset.
\begin{table}[htb]
\centering
\caption{Event Detetion Evaluation}
\begin{tabular}{lllll}
\hline
         & EB    & CWEB  & FB    & Average \\
\hline
baseline & 0.154  & 0.135  & 0.206  & 0.1650   \\
NR2      & 0.1106 & 0.209  & 0.3249 & 0.2148   \\
NVM      & 0.4753 & 0.4128 & 0.5441 & 0.4774   \\
Our      & 0.5344 & 0.4007 & 0.5241 & 0.4864   \\
VVK      & 0.5113 & 0.3977 & 0.5628 & 0.4906   \\
GVV      & 0.468  & 0.367  & 0.652  & 0.4957   \\
DHV      & 0.5105 & 0.3805 & 0.616  & 0.5023   \\
\hline
\end{tabular}
\end{table}
There are seven systems in the online challenge, but the system "SCS" does not list their class-wise event based result, so it is excluded for comparison.
\begin{figure}[htb!]
\centering
\input{figure/evaluation/eventdetectF1}
\caption{Event Detection F-Measure}
\label{fig:eventdetectF1}
\end{figure}
As we could see visually in Figure \ref{fig:eventdetectF1}, our event detection system have a accuracy close to the highest-performing system.

\section{Scene Recognition Evaluation}

\subsection{Evaluation Data}
After we have done event detection, we use the previous proposed scene inference method to do scene recognition.
In this section, a 10-scenes evaluation experiment are carried out for evaluating our system's performance.

The 10 scenes we used in this evaluation is \textit{bathroom, beach, concert, forest, kitchen, office, park, restaurant, street, subway station}.
These scenes are chosen both covering indoor and outdoor, quiet and noisy environments.
The testing clips we used are downloaded mainly from previously mentioned sound search engines, and there is 10 clips for each scene, i.e., 100 in total.

\subsection{Baseline systems}
In this evaluation, we need to compare our systems with other systems.
And this requires getting existing audio scene recognition system with source code, since we are going to train on different scenes.
Luckily, IEEE AASP Challenge has a scene classification part\footnote{\url{http://c4dm.eecs.qmul.ac.uk/sceneseventschallenge/}}, and source code for sume of the submitted systems\footnote{\url{https://code.soundsoftware.ac.uk/projects/dcase2013submissions}} are available for downloading.
On the website, there are 4 scene classification systems and one baseline scene classifier.
Because of some programming issues, we choose 2 classification systems, together with the baseline scene classifier for comparison.
Table \ref{table:systems} shows a summary of the systems used for comparison and our systems.

\begin{table}[htb!]
\caption{Summary of systems}
\begin{tabular}{ll}
\toprule
 Code & Method \\
\bottomrule
 Baseline & MFCCs, classified with a bag-of-frames approach \\
 RNH & Recurrence Quantification Analysis to MFCC time-series, classified by SVM \\
 GSR & 6669 features, classifed using SVM within 4-second window, then majority voting \\
 Our & MFCCs, dynamic segmentation, classified with GMM \\
\bottomrule
\end{tabular}
\label{table:systems}
\end{table}

\subsection{Evaluation Result}

\subsubsection{Self Tuning}
In the self tuning part of our scene recognition system.
We conducted a evaluation on how noise reduction can affect the scene recognition accuracy.
In the training process, the clips could be denoised before training GMMs, and the same reason applies to the testing process.
So here are two factors that affect the event detection result: whether training data are denoised, and whether testing data are denoised.
We denote the model name for these different condition in the format of \textit{out\_trainDenoise\_testDenoise}.
The last two variable would be represented by $0$ and $1$.
For example, \textit{our\_1\_1} represent the model which has the training data and testing data denoised.

\begin{table}[htb!]
\centering
\resizebox{\textwidth}{!}{
\begin{tabular}{lccccccccccc}
\toprule
     & bathroom & beach & concert & forest & kitchen & office & park & restaurant & street & subway station & Average \\
\bottomrule
our\_0\_0 & $70\%$ & $20\%$ & $30\%$ & $60\%$ & $50\%$ & $70\%$ & $10\%$ & $0\%$  & $90\%$ & $0\%$  & $40\%$\\
our\_0\_1 & $60\%$ & $60\%$ & $50\%$ & $50\%$ & $50\%$ & $70\%$ & $50\%$ & $0\%$  & $60\%$ & $0\%$  & $45\%$\\
our\_1\_0 & $60\%$ & $0\%$  & $40\%$ & $20\%$ & $40\%$ & $80\%$ & $10\%$ & $0\%$  & $90\%$ & $0\%$  & $34\%$\\
our\_1\_1 & $80\%$ & $60\%$ & $60\%$ & $50\%$ & $60\%$ & $80\%$ & $40\%$ & $10\%$ & $100\%$& $30\%$ & $57\%$\\
\bottomrule
\end{tabular}
}
\caption{Recognition accuracy for our different models}
\label{table:ourTuning}
\end{table}

Table \ref{table:ourTuning} shows the detailed result of this experiment.
As expected, for different training process, denoising the testing data always bring an improvement in accuracy.
Moreover, denoising the training further boost the result.

\begin{figure}[htb!]
\centering
\input{figure/evaluation/ourTuning}
\caption{Recognition accuracy for our different models}
\label{fig:ourTuning}
\end{figure}

Figure \ref{fig:ourTuning} is a graphical present of the data in Table \ref{table:ourTuning}.
In the x-axis label, ``Train on denoised'' means that we are training on denoised data, and the other are trained on undenoised data.
For one group, there is two bar representing given that training condition, two testing experiments are done.
The blue bar is the result of testing on undenoised data, and the brown bar is the result of testing on denoised data.
It is clearly shown in the figure that denoising testing data always improves the accuracy.
Our highest performance is achieved at $57\%$ when we train our model on denoised data and also test on denoised data.

\subsubsection{System Comparison}
Table \ref{table:ac} show the recognition accuracy for each audio scenes.
As we could see in this table, GSR has a highest average accuracy of $61\%$, while our model comes second with accuracy of $54\%$.
However, the variation in our recognition result is very large.
Our model have 5 scenes which get the highest accuracy, but at the same time, perform bad in \textit{restaurant} and \textit{subway station}.
This is reasonable for our approach.
Because our system work by detecting distinct audible events.
Thus favoring scenes where many distinct events exist, like in office, \textit{phone, printer, paper} could be a distinct event.
But in scene like \textit{restaurant}, it is generally filled with noise atmosphere, thus hard for our system to detect something useful.

\begin{table}[htb!]
\centering
\resizebox{\textwidth}{!}{
\begin{tabular}{lccccccccccc}
\toprule
     & bathroom & beach & concert & forest & kitchen & office & park & restaurant & street & subway station & Average \\
\bottomrule
Baseline & $60\%$ & $40\%$ & $60\%$ & $40\%$ & $10\%$ & $40\%$ & \textbf{$60\%$} & $30\%$ & $60\%$ & $70\%$ & $47\%$\\
RNH1 & $30\%$ & $40\%$ & $70\%$ & $40\%$ & $20\%$ & $30\%$ & $50\%$ & $50\%$ & $70\%$ & $50\%$ & $45\%$ \\
RNH2 & $20\%$ & $40\%$ & $70\%$ & $40\%$ & $40\%$ & $30\%$ & $50\%$ & $40\%$ & $70\%$ & $60\%$ & $46\%$ \\
GSR & $60\%$ & $50\%$ & \textbf{$90\%$} & \textbf{$50\%$} & $30\%$ & $60\%$ & \textbf{$60\%$} & \textbf{$60\%$} & $70\%$ &\textbf{ $80\%$} & \textbf{$61\%$} \\
Our & \textbf{$80\%$} & \textbf{$60\%$} & $60\%$ & \textbf{$50\%$} & \textbf{$60\%$} & \textbf{$80\%$} & $40\%$ & $10\%$ & \textbf{$100\%$} & $30\%$ & $57\%$ \\
\bottomrule
\end{tabular}
}
\caption{Recognition accuracy for 10 audio scenes}
\label{table:ac}
\end{table}

\begin{figure}[htb!]
\centering
\input{figure/evaluation/sceneeval}
\caption{Recognition accuracy for 10 audio scenes}
\label{fig:sceneeval}
\end{figure}

In the table \ref{table:ac}, we could see that GSR has the highest average accuracy which reaches to $61\%$.
And our system ranked the second with $57\%$.
Yet, our system has the highest accuracy in 6 different scenes, and even reaches a perfect accuracy in scene \textit{street}.

\begin{figure}[htb!]
\centering
\input{figure/evaluation/ourgsr}
\caption{Comparison of Our's with GSR}
\label{fig:ourgsr}
\end{figure}

Looking closely at the Figure \ref{fig:ourgsr}, we could find that our system performs bad in \textit{restaurant} and \textit{subway station}, only $10\%$ and $30\%$ respectively.
We think that this is because the testing data of these two scenes are generally noisy.
Our system work in a way to detect audible events our an audio clip.
But when the clip is noisy, it is hard for our system to detect any audible events embedded in it, which is the case in \textit{restaurant} and \textit{subway station}.

\cleardoublepage{}
\section{Summary}
In this chapter, we introduced the evaluation of our systems.
It include two parts: first the event detection evaluation and then the scene recognition evaluation.

In the first evaluation, we compare our model with submitted systems to the IEEE AASP Challenge for event detection.
This evaluation uses 16 audible events, and each event has 20 clips for training.
The testing datas are three long audio, where each may contain 10 to 20 events.
The task is to build a model trained on training data and detect out the events in the testing data, where the onset and offset time are also required.
Our system build GMMs on MFCC features, and segment the testing clips with a dynamic segmentor.
In the evaluation, we has a average F-measure of 0.4864, which come close to the highest one: 0.5023.

In the scene recognition evaluation, we first conduct an experiment on how noise reduction affects the performance of our system.
The result is that noise reduction would boost the performance, and we have the highest accuracy when both training data and testing data are denoised.
So, we use this mechanism in the following evaluation.
In the system comparison part, we compare the performance of our system with other 4 algorithms in a 10 scene classification problem.
The 10 scene are chosen to be the common audio scene seen in everyday life.
The result is that we achieved second in the average accuracy.
But it is notable that we have six scenes with accuracies ranked the first.


\documentclass{article}
	\title{Cardano's Formula for Cubic Equations}
\author{Matthew Osamor}
\date{November 20, 2021}
\usepackage{amsmath}
\begin{document}
	\maketitle
	\begin{center}

\begin{center}
		Abstract
		\end{center}
	\begin{center}

	  Gerolamo Cardano was born in Pavia in 1501 as the illegitimate child of a jurist. He attended the University of Padua and became a physician in the town of Sacco, after being rejected by his home town of Milan. He became one of the most famous doctors in all of Europe, having treated the Pope. He was also an astrologer and an avid gambler, to which he wrote the Book of Chance, which was the first serious treatise on the mathematics of probability [1].
	\end{center}
	\end{center}
\section{Introduction to Cardano's Formula}
Cardano's formula for solution of cubic equations for an equation like;\\
$x^3$ + $a_{1}x^2$ + $a_{2}x$ + $a_{3}$ = 0\\
the parameters Q, R, S and T can be computed thus,\\
\\
Q=$\dfrac{3a_{2}-a_{1}^2}{a}$\\
 \\
R=$\dfrac{{9a_1a_2-27a_3-2a^3_1}}{54}$\\
\\
S=$3\sqrt{R+\sqrt{-Q^3+R^2}}$\\
\\
T=$\sqrt{R-\sqrt{Q^3+R^2}}$\\
\\
to give the roots;\\
$x_{1}=S+T-\dfrac{1}{3}a_{1}$\\
\\
$x_{2}=\dfrac{-(S+T)}{2}-\dfrac{a_1}{3}+i\dfrac{\sqrt{3}(s-T)}{2}$\\
\\
$x_{2}=\dfrac{-(S+T)}{2}-\dfrac{a_1}{3}-i\dfrac{\sqrt{3}(s-T)}{2}$\\
\\
Note:$x^3$ must not have a coefficient.\\
\subsection{Some Examples}
\begin{itemize}
 \item $x^3-3x^2+4=0$
 \item $2x^3+6x^2+1=0$
 \end{itemize}\\
\section{References}
[1] P. Scarani, "Out of control: vita di gerolamo cardano (1501-1576),"\\
Pathologica, vol. 93, pp. 565-574, 2001.
\end{document}

CLASS PARTICIPATION/WEEK6 PRACTICE/CLASS PROJECT 2.tex


\chapter{How to benefit from this book}

\epigraph{Young man, in mathematics you don't understand things. You just get used to them.}{John von Neumann (1903--1957) \cite{zukav1979dancing} (p. 208)}

This book is optimized for slow thoughtful focused sequential reading.
The author tries to make the book as short as possible.

\section{Notation}

A \emph{mathematical notation}, like the Latin alphabet,
is a way of writing \emph{English} or any other natural language.
When you read ``math'',
you are really reading the same language
that you speak everyday.

When you encounter symbols in a sentence,
think about how they should read in English
to make the whole sentence grammatically correct.

Beware that mathematical notations also have slangs and inconsistencies.

A large part of mathematics is about defining and naming things.
``\(A\) is \(B\) with some additional properties. \(B\) is \(C\) with some other properties.''

The reader is assumed to know the Greek alphabet.

\section{Some motivation}

Math seems hard because learning a new language is hard.

\emph{Math is fun.}
Indeed you can brainwash yourself into thinking anything is fun,
including physical exercise and healthy eating,
just by repeatedly shouting in your mind that it is fun.

\emph{Every time} you think you suck at math,
shout in your head, ``I love math!''
Even if you feel you can't,
no matter however phony you feel,
just shout it.
Repeat it until it becomes a reflex.
Remember that you \emph{just} want to love math;
you don't want to be a math expert.
You can love math without being a math expert.
It's perfectly logical.

In mathematics, right is right, and wrong is wrong,
regardless of age, skin color, gender, weight, wealth,
nationality, religion, or political affiliation.
In mathematics, we don't have to worry about offending anyone.

John von Neumann:
``If people do not believe that mathematics is simple, it is only because they do not realize how complicated life is.''


\section{Program gto\char`_filter}
The \texttt{gto\char`_filter} filters numerical sequences using a low-pass filter.\\
For help type:
\begin{lstlisting}
./gto_filter -h
\end{lstlisting}
In the following subsections, we explain the input and output paramters.

\subsection*{Input parameters}

The \texttt{gto\char`_filter} program needs two streams for the computation, namely the input and output standard. The input stream is a numeric file.\\
The attribution is given according to:
\begin{lstlisting}
Usage: ./gto_filter [options] [[--] args]
   or: ./gto_filter [options]

It filters numerical sequences using a low-pass filter.

    -h, --help                show this help message and exit

Basic options
    < input.num               Input numeric file (stdin)
    > output.num              Output numeric file (stdout)

Optional
    -w, --windowsize=<int>    Window size (defaut 0)
    -d, --drop=<int>          Discard elements (default 0.0)
    -t, --windowtype=<int>    Window type (0=Hamm, 1=Hann, 2=Black, 3=rec) (default 0 (Hamm))
    -c, --onecolumn           Read from one column
    -p, --printone            Print one column
    -r, --reverse             Reverse mode

Example: ./gto_filter -w <windowsize> -d <drop> -t <windowtype> -c -p -r < input.num > output.num
\end{lstlisting}
An example on such an input file is:
\begin{lstlisting}
1   1.77
5   2.18
10  2.32
15  3.15
20  2.52
25  4.43
30  1.23
\end{lstlisting}

\subsection*{Output}
The output of the \texttt{gto\char`_filter} program is a numeric file, identical of the input.\\
Using the input above with the window size of 3, an output example for this is the following:
\begin{lstlisting}
Got 7 entries from file
1   2.085
5   2.256
10  2.507
15  2.757
20  2.905
25  2.860
30  2.674
\end{lstlisting}


\documentclass[a4paper]{article}

\input{temp}

\setcounter{section}{-1}

\begin{document}

\title{Numerical Analysis II}

\maketitle

\newpage

\tableofcontents

\newpage

\section{The Poisson equation}

\begin{prob}
Solve
\begin{equation*}
\begin{aligned}
\nabla^2 u = f & x \in \Omega\\
u = \phi & x \in \partial\Omega
\end{aligned}
\end{equation*}
here
\begin{equation*}
\begin{aligned}
\nabla^2 u = \left(\frac{\partial^2}{\partial x^2} + \frac{\partial^2}{\partial y^2} \right)u
\end{aligned}
\end{equation*}
is the Laplace operator. The method is to impose on $\Omega$ a rectangular grid $\Omega_h$ with the spacing $h$, and replace $\grad^2 u$ by a difference scheme. We'll look for approximate $u|_{\Omega_h}$.
\end{prob}

\end{document}


\documentclass{article}

\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{amssymb}

\title{Assignment 1}
\date{}
\author{Steven Porretta \\ 100756494}

\begin{document}
\section{Introduction}
	The army ant raiding problem is essentially a gathering problem where many mobile-agents, called ants, venture forth from a unique starting location referred to as a nest. The value of this model has potential to improve working conditions in dangerous real-world environments like the clean-up of hazardous waste. In the exploration of the army ant raiding problem some key features of the model will be discussed heurisitically.

\section{Background}
	In the army ant raiding model, each ant moves away from the nest by walking from site to site by moving either, diagonally to the left, or diagonally to the right, much like the movement of a bishop in a game of chess in a diagonal grid pattern as in Figure~\ref{fig:move}, where each black square is a location where $Ant_i$ is capable of moving to. The ant moves with probability $\mathbb{P}_m$ and if it moves, then it moves at most to one site to the left with probability $\mathbb{P}_l$ or one site to the right with $\mathbb{P}_r$ as in Equations~\eqref{eq:move,eq:left,eq:right}, respectively. When the ant makes a movement it also leaves a breadcrumb behind referred to as a pheromone trail.

	The goal of the ants is to collect as much information, called food, for which the distribution throughout the environment is not a priori. Once an ant has found food, it picks it up, either reducing it's quantity from the environment or removing it all together, and turns to face the opposite heading. Returning back to the nest for the ant is not a simple task, since this ant should carry the food back to the nest by using pheromone trails alone.

	To improve the probability that an ant returns to the nest with a high success rate, the pheromone trail is said to evaporate over time. This may seem counter-intuitive, but it will be discussed further in Section~\ref{sec:suc}

\section{Foraging Patterns}\labe{sec:pats}
\section{Effect of Food on Foraging} \label{sec:food}
\section{Effect of n and k}\label{sec:nandk}
\section{successful foraging}\label{sec:suc}

\end{document}


\section{More types}
\begin{frame}[fragile]
\frametitle{Pointers}

\begin{lstlisting}
package main

import "fmt"

func main() {
    i, j := 42, 2701

    p := &i         // point to i
    fmt.Println(*p) // read i through the pointer
    *p = 21         // set i through the pointer
    fmt.Println(i)  // see the new value of i

    p = &j         // point to j
    *p = *p / 37   // divide j through the pointer
    fmt.Println(j) // see the new value of j
}
\end{lstlisting}

\end{frame}

\begin{frame}[fragile]
\frametitle{Structs}

\begin{lstlisting}
package main

import "fmt"

type Vertex struct {
    X, Y int
}

var (
    v1 = Vertex{1, 2}  // has type Vertex
    v2 = Vertex{X: 1}  // Y:0 is implicit (X literal)
    v3 = Vertex{}      // X:0 and Y:0
    p  = &Vertex{1, 2} // has type *Vertex
)

func main() {
    fmt.Println(v1, p, v2, v3)
}
\end{lstlisting}

\end{frame}

\begin{frame}[fragile]
\frametitle{Arrays}

\begin{lstlisting}
package main

import "fmt"

func main() {
    var a [2]string
    a[0] = "Hello"
    a[1] = "World"
    fmt.Println(a[0], a[1])
    fmt.Println(a)

    primes := [6]int{2, 3, 5, 7, 11, 13}
    fmt.Println(primes)
}
\end{lstlisting}

\end{frame}

\begin{frame}[fragile]
\frametitle{Slices}

\begin{lstlisting}
package main

import "fmt"

func main() {
    names := [4]string{
        "John",
        "Paul",
        "George",
        "Ringo",
    }
    fmt.Println(names)

    a := names[0:2]
    b := names[1:3]
    fmt.Println(a, b)

    b[0] = "XXX" // as being a reference to array, modifies its value
    fmt.Println(a, b)
    fmt.Println(names)
}
\end{lstlisting}

\end{frame}

\begin{frame}[fragile]
\frametitle{Slices}

\begin{lstlisting}
package main

import "fmt"

func main() {
    s := []int{2, 3, 5, 7, 11, 13} // slice literal
    // can use s := make([]int, 0, 5) => [] (len 0, cap 5)

    s = s[1:] // slice default
    fmt.Println(s)

    s = s[:0]  // Extend its length.
    printSlice(s)

    s = s[:3] // Drop its first two values.
    printSlice(s) // can append s = append(s, 2, 3, 4)
}

func printSlice(s []int) {
     fmt.Printf("len=%d cap=%d %v\n", len(s), cap(s), s)
}
\end{lstlisting}
\end{frame}

\begin{frame}[fragile]
\frametitle{Range}

\begin{lstlisting}
package main

import "fmt"

func main() {
    pow := make([]int, 10)
    for i := range pow {
        pow[i] = 1 << uint(i) // == 2**i
    }
    for _, value := range pow {
        fmt.Printf("%d\n", value)
    }
}
\end{lstlisting}
\end{frame}

\begin{frame}[fragile]
\frametitle{Maps}

\begin{lstlisting}
package main

import "fmt"

type Vertex struct {
    Lat, Long float64
}

var m = map[string]Vertex{
    "Bell Labs": Vertex{40.68433, -74.39967}, // type can be omitted
    "Google": Vertex{37.42202, -122.08408},
}

func main() {
    fmt.Println(m)

    m = make(map[string]Vertex) // another way
    m["Bell Labs"] = Vertex{40.68433, -74.39967}

    v, ok := m["Bell Labs"] // also can delete(m, "Bell Labs")
    fmt.Println("The value:", v, "Present?", ok)
}
\end{lstlisting}
\end{frame}

\begin{frame}[fragile]
\frametitle{Function values}

\begin{lstlisting}
package main

import (
    "fmt"
    "math"
)

func compute(fn func(float64, float64) float64) float64 {
    return fn(3, 4)
}

func main() {
    hypot := func(x, y float64) float64 {
        return math.Sqrt(x*x + y*y)
    }
    fmt.Println(hypot(5, 12))

   fmt.Println(compute(hypot))
   fmt.Println(compute(math.Pow))
}
\end{lstlisting}
\end{frame}

\begin{frame}[fragile]
\frametitle{Function closures}

\begin{lstlisting}
package main

import "fmt"

func adder() func(int) int {
    sum := 0
    return func(x int) int {
        sum += x
        return sum
    }
}

func main() {
    pos, neg := adder(), adder()
    for i := 0; i < 10; i++ {
        fmt.Println(
            pos(i),
            neg(-2*i),
        )
    }
}
\end{lstlisting}
\end{frame}


\subsection{Bladed Weapons}

\begin{longtable}{|C{2cm} L{2cm} L{2cm} L{8cm}|}
\hline
\large{\textbf{Name}} &
\large{\textbf{Cost}} &
\large{\textbf{Handedness}} &
\large{\textbf{Damage}}
\\ \hline
\WeaponRow{Dagger}{65 m}{One}{
\textbf{When slashing:} \hfill \break
\textit{Slashing:} $\frac{2d6 \pm modifiers}{5}*Dexterity$ \hfill \break
\textit{Crushing:} $\frac{1d4 \pm modifiers}{5}*Dexterity$ \hfill \break
\textbf{When stabbing:} \hfill \break
\textit{Piercing:} $\frac{2d8 \pm modifiers}{5}*Dexterity$ \hfill \break
\textit{Crushing:} $\frac{1d4 \pm modifiers}{5}*Dexterity$
}{Daggers have short, typically straight blades - easily concealed, they are perfect weapons for assassins and thieves, and also have plenty of utility outside of combat as well.}
\WeaponRow{Straight Short Sword}{85 m}{One}{
\textbf{When slashing:} \hfill \break
\textit{Slashing:} $\frac{2d8 \pm modifiers}{5}*Dexterity$ \hfill \break
\textit{Crushing:} $\frac{1d6 \pm modifiers}{5}*Dexterity$ \hfill \break
\textbf{When stabbing:} \hfill \break
\textit{Piercing:} $\frac{2d8 \pm modifiers}{5}*Dexterity$ \hfill \break
\textit{Crushing:} $\frac{1d6 \pm modifiers}{5}*Dexterity$
}{Straight-bladed short swords have a blade length between 30 and 60 cm \Parentheses{1 and 2 ft}. They pack a bigger punch than daggers, but also have reduced utility outside of combat. A straight-bladed short sword may also be called a \textbf{Long Seax}, a \textbf{Gladius}, a \textbf{Xiphos} or just a \textbf{Shortsword}.}
\WeaponRow{Curved Short Sword}{90 m}{One}{
\textbf{When slashing:} \hfill \break
\textit{Slashing:} $\frac{2d10 \pm modifiers}{5}*Dexterity$ \hfill \break
\textit{Crushing:} $\frac{1d8 \pm modifiers}{5}*Dexterity$ \hfill \break
\textbf{When stabbing:} \hfill \break
\textit{Piercing:} $\frac{2d4 \pm modifiers}{5}*Dexterity$ \hfill \break
\textit{Crushing:} $\frac{1d4 \pm modifiers}{5}*Dexterity$
}{Curved-bladed short swords have a blade length between 30 and 60 cm \Parentheses{1 and 2 ft}. Weapons dedicated purely for combat, their curved blades are perfect for slashing, but are rather poor for stabbing. A curved-bladed short sword may also be known as a \textbf{Khopesh}, a \textbf{Sica}, a \textbf{Shamshir}, a \textbf{Nimcha}, a \textbf{Dao}, a \textbf{Kodachi} or a \textbf{Wakizashi}.}
\WeaponRow{Straight Medium Sword}{110 m}{One / Two}{
\textbf{When slashing:} \hfill \break
\textit{Slashing:} $\frac{2d10 \pm modifiers}{5}*Dexterity$ \hfill \break
\textit{Crushing:} $\frac{1d8 \pm modifiers}{5}*Dexterity$ \hfill \break
\textbf{When stabbing:} \hfill \break
\textit{Piercing:} $\frac{2d10 \pm modifiers}{5}*Dexterity$ \hfill \break
\textit{Crushing:} $\frac{1d8 \pm modifiers}{5}*Dexterity$
}{Straight-bladed medium swords have a blade length between 70 and 80 cm \Parentheses{2.2 and 2.6 ft}. A weapon dedicated purely for combat, a straight-bladed medium sword was typically called a \textbf{Jian}, an \textbf{Arming Sword} or just a \textbf{Sword}.}
\WeaponRow{Curved Medium Sword}{110 m}{One / Two}{
\textbf{When slashing:} \hfill \break
\textit{Slashing:} $\frac{2d12 \pm modifiers}{5}*Dexterity$ \hfill \break
\textit{Crushing:} $\frac{1d10 \pm modifiers}{5}*Dexterity$ \hfill \break
\textbf{When stabbing:} \hfill \break
\textit{Piercing:} $\frac{2d6 \pm modifiers}{5}*Dexterity$ \hfill \break
\textit{Crushing:} $\frac{1d4 \pm modifiers}{5}*Dexterity$
}{Curved-bladed medium swords have a blade length between 70 and 80 cm \Parentheses{2.2 and 2.6 ft}. A weapon dedicated purely for combat, a curved-bladed medium sword was typically called a \textbf{Scimitar}, a \textbf{Sabre}, a \textbf{Falchion}, a \textbf{Cutlass}, a \textbf{Yatagan} or a \textbf{Katana}.}
\WeaponRow{Straight Long Sword}{130 m}{Two}{
\textbf{When slashing:} \hfill \break
\textit{Slashing:} $\frac{2d12 \pm modifiers}{5}*Dexterity$ \hfill \break
\textit{Crushing:} $\frac{1d10 \pm modifiers}{5}*Dexterity$ \hfill \break
\textbf{When stabbing:} \hfill \break
\textit{Piercing:} $\frac{2d12 \pm modifiers}{5}*Dexterity$ \hfill \break
\textit{Crushing:} $\frac{1d10 \pm modifiers}{5}*Dexterity$
}{Straight-bladed long swords have a blade length longer than 90 \Parentheses{2.9 ft}, but seldom longer than 120 cm \Parentheses{3.9 ft}. A weapon dedicated purely for combat, a straight-bladed long sword was typically called a \textbf{Longsword}, a \textbf{Claymore} or a \textbf{Zweihänder}.}
\WeaponRow{Curved Long Sword}{135 m}{Two}{
\textbf{When slashing:} \hfill \break
\textit{Slashing:} $\frac{3d10 \pm modifiers}{5}*Dexterity$ \hfill \break
\textit{Crushing:} $\frac{1d12 \pm modifiers}{5}*Dexterity$ \hfill \break
\textbf{When stabbing:} \hfill \break
\textit{Piercing:} $\frac{2d8 \pm modifiers}{5}*Dexterity$ \hfill \break
\textit{Crushing:} $\frac{1d6 \pm modifiers}{5}*Dexterity$
}{Curved-bladed long swords have a blade length longer than 90 \Parentheses{2.9 ft}, but seldom longer than 120 cm \Parentheses{3.9 ft}. A weapon dedicated purely for combat, a curved-bladed long sword was typically called a \textbf{Falx}, \textbf{Changdao}, an \textbf{Oudachi} or a \textbf{Nodachi}.}
\end{longtable}


\documentclass[a4paper]{article}
\usepackage[english]{babel}
\usepackage{graphicx}
\usepackage{multicol}
\usepackage{amsmath}
\usepackage{hyperref}
\usepackage{amsthm}
\usepackage{geometry}
\geometry{a4paper}
\usepackage{fancyhdr}
\usepackage{xcolor}
\usepackage{amssymb}
\usepackage{multicol}
\theoremstyle{definition}
\newtheorem{exmp}{Example}[section]
\newtheorem{theorem}{Theorem}
\newtheorem{problem}{Problem}

\begin{document}
\author{ \textbf{Fractals}}
\title{\textbf{Basic Equation Solving}}
\maketitle
\tableofcontents
\noindent
\section{Basic Equation Solving}
\subsection{Algebraic Manipulation}
To introduce the topic of \textbf{algebraic manipulation},
let us start with a little known example: \textbf{egyptian fractions}

\begin{theorem}[\textbf{Egyptian Fractions}]
    For all \(a, b \) where \(ab \ne 1 \)
    \[
        \dfrac{a}{ab - 1 } = \dfrac{1}{b( ab - 1)} + \dfrac{1}{b}.
    \]
    From here, we can see that putting things together (factoring) is just as important as taking them
    apart (distributing). Now, let us turn the power of products:
\end{theorem}
\begin{exmp}
    For positive real numbers \(a, b \),
    \[
        a + \dfrac{1}{b} = 4,
    \]
    \[
        b + \dfrac{1}{a} = 5,
    \]
    Find \(ab + \dfrac{1}{ab} \). \\

    \noindent
    \(Solution\). It is very easy to get lost in the problem if we directly try to solve for a and b. Instead,
    let us multiply the equations:
    \[
        (a+\dfrac{1}{b})(b+\dfrac{1}{a}) = 4(5) = 20.
    \]
    \[
        ab + \dfrac{a}{a} + \dfrac{b}{b} + \dfrac{1}{ab} = ab + \dfrac{1}{ab} + 2 = 20,
    \]
    \begin{center}
        \framebox[1\width]{ \( ab + \dfrac{1}{ab} = 18\). }
    \end{center}
\end{exmp}
\begin{theorem}
    Let \(x, y \) be nonzero real numbers such that \(x + y = a\) and \(xy = b\) Then,
    \[
        x^2 + y^2 = a^2 -2b,
    \]
    \[
        (x+1)(y+1) = a + b + 1,
    \]
    \[
        x^2 + xy^2 = ab,
    \]
    \[
        | x - y | = \sqrt{a^2 - 4b},
    \]
    \[
        x^3 + y^3 = a^3 - 3ab,
    \]
    \[
        \dfrac{1}{x} + \dfrac{1}{y} = \dfrac{a}{b},
    \]
\end{theorem}
\subsection{Quadratic Equations}
A polynomial is an equation of the following form:
\[
    a_n x^n + a_{n-1} x^{n-1} + \cdots + a_1 x + a_0 ,
\]
where
\[
    a_0, a_1, \dots, a_n
\]
are constants. A quadratic equation is a polynoimal with \(n = 2\):
\[
    ax^2 + bx + c = 0,
\]
A common way to solve a quadratic equation is to use the quadratic formula:
\begin{theorem}[\textbf{Quadratic Formula}]
    For the equation \(ax^2 + bx + c = 0\), the roots \(x_1, x_2 \) must be equal to
    \[
        x_1 = \dfrac{-b + \sqrt{b^2 - 4ac}}{2a},
    \]
    \[
        x_2 = \dfrac{-b - \sqrt{b^2 - 4ac}}{2a},
    \]
\end{theorem}
\begin{theorem}
    For the equation \(ax^2 + bx + c = 0\), we have the following cases:
    \begin{itemize}
        \item If \(b^2 - 4ac > 0\), we have \textbf{two real roots.}
        \item If \(b^2 - 4ac = 0\), we have \textbf{one real root.}
        \item If \(b^2 - 4ac < 0\), we have \textbf{no real roots.}
    \end{itemize}
    Using the Quadratic Formula, we can calculate the sum of roots and product of roots:
\end{theorem}
\begin{theorem}
    For the equation \(ax^2 + bx + c = 0\), the sum of roots is:
    \begin{displaymath}
        x_1 + x_2 = \dfrac{-b + \sqrt{b^2 - 4ac}}{2a} + \dfrac{-b + \sqrt{b^2 - 4ac}}{2a}
        = \dfrac{-2b}{2a} = - \dfrac{b}{a}
    \end{displaymath}
    \begin{displaymath}
        x_1x_2 = \dfrac{-b^2 + 4ac}{2a} \times \dfrac{-b^2 + 4ac}{2a} =
        \dfrac{-(-b)^2 - (b^2 - 4ac)}{4a^2} = \dfrac{c}{a}
    \end{displaymath}
\end{theorem}
\begin{theorem}
    For any polynoimal
    \[
        a_n x^n + a_{n-1} x^{n-1} + \cdots + a_1 x + a_0 ,
    \]

    \textbf{The sum of roots is}: \( - \dfrac{\text{seconed coeffeicent}}{\text{first coeffeicent}}
    = - \dfrac{a_{n-1}}{a_n}\)
    and \textbf{the product of roots is:} \(\dfrac{\text{last coeffeicent}}{\text{first coeffeicent}}
    = \dfrac{a_0}{a_n} \) \\

    \noindent
    For those who are looking for a more advanced and more powerful theorem, we can generalize
    this formula:
\end{theorem}

\begin{theorem}[\textbf{Vieta’s Formulas}]
    for any polynoimal
    \[
        a_n x^n + a_{n-1} x^{n-1} + \cdots + a_1 x + a_0 ,
    \]
    let \(r_1, r_2, \dots r_n\) (an \(n\)-degree equation has n different roots).
    Vieta’s formulas state that
    \[
        a_n = a_n
    \]
    \[
        a_{n-1} = -a_n(r_1 + r_2 + \cdots + r_n)
    \]
    \[
        a_{n-2} = a_n(r_1r_2+r_1r_3+\cdots + r_{n-1}r_n)
    \]
    \[
        \vdots
    \]
    \[
        a_0 = (-1)^n a_n(r_1r_2\cdots r_n)
    \]
\end{theorem}

\section{Problems}

\begin{problem}
Let \(x\) be a real number such that \(x+\dfrac{1}{x} = \sqrt{2020}\).
What is \(x^2 + \dfrac{1}{x^2}\)?
\end{problem}

\begin{problem}
Two non-zero real numbers, a and b, satisfy \(ab = a - b\).
Which of the following is a possible value of \(\dfrac{a}{b}
+ \dfrac{b}{a} -ab \)?
\end{problem}

\begin{problem}
Let \(x, y\) be nonnegative real numbers such that \(x + y = 5\) and \(xy = 7\). Find
\(\dfrac{x}{y-1} +\dfrac{y}{p-1}\)
\end{problem}

\begin{problem}
Let \(a, b\) are real numbers such that
\[
    \dfrac{1}{a(b+1)} + \dfrac{1}{b(a+1)} = \dfrac{1}{(a+1)(b+1)}.
\]
\end{problem}

\begin{problem}
Find the sum of roots to the equation \(x^{2020} = 2020x^{2019} + 1\)
\end{problem}

\begin{problem}
Find the product of the roots of the equation \(x^3 = 9\pi x + x^2 + 1. \)
\end{problem}

\begin{problem}
What is the average value of the three roots of the equation \(x^3 -12x^2 - 4x + 48 = 0\)?
\end{problem}

\end{document}


\section{Introduction}
\label{sec:introduction}

  The multigroup neutron diffusion equation has proven to be a useful tool for
  modeling the neutron distribution in a typical nuclear reactor. With the
  development of the \gls{nem}, the model was made more accurate and
  computational time was significantly decreased. The typical quantity of
  interest in these reactor simulations is the fundamental mode of the
  eigenvalue problem; that is, the largest eigenvalue and associated eigenvector
  which represent the effective neutron multiplication factor and scalar neutron
  flux distribution respectively.

  Traditionally, the multigroup neutron diffusion equation and \gls{nem}
  equations have been solved using the \gls{pi} method. The \gls{pi} method is a
  fixed-point method useful for solving eigenvalue problems. It is a linear
  iteration method and converges to the fundamental eigenmode at a linear rate.
  Recently, the use of \gls{jfnk} methods has been investigated in an attempt to
  reduce the computing time required to solve the \gls{nem} equations.
  \gls{jfnk} methods are attractive because when the iteration terminates, the
  method converges $q$-quadratically. However, \gls{jfnk} methods require the
  computation of quantities not required by the \gls{pi} method including the
  finite difference Jacobian-vector product. Due to the challenges of computing
  these quantities, the implementation of \gls{jfnk} methods for computing the
  fundamental mode to the multigroup neutron diffusion equation and \gls{nem}
  equations remains an active area of research.

  In \citetitle{qe2paper}, \citeauthor{qe2paper} explore an implementation of
  the \gls{jfnk} method that seeks to efficiently solve the \gls{nem} equations
  for the fundamental eigenmode. \sref{sec:summary} briefly summarizes this work
  and a few considerations for solving the \gls{nem} equations using the
  \gls{jfnk} method are provided. Then, \sref{sec:critique} critiques the
  authors' implementation with a focus on the applicability of the proposed
  method to realistic nuclear reactor simulations. Finally,
  \sref{sec:conclusion} provides a few conclusions based on the work by
  \citeauthor{qe2paper} and some considerations for future implementations of
  the \gls{jfnk} method to solve the \gls{nem} equations in nuclear reactor
  simulations.


%===================================Used packages======================%
%----------------------------------------------------------------------%
\documentclass[12pt]{report}
\usepackage{sagetex}
\pagenumbering{gobble}
\oddsidemargin=0pt

%----------------------------------------------------------------------%
%=======================Title page=====================================%
%----------------------------------------------------------------------%
\title{Dynamic of Structure: Mode and Time Period}
\author{Amarjeet Singh }
\begin{document}
\setcounter{chapter}{1}
\thispagestyle{plain}
	\begin{titlepage}
\maketitle
	\end{titlepage}

\begin{sagesilent}
	load('main.sage.py')

\end{sagesilent}

Number Of Storeys
\begin{equation}
	N = \sage{Number_of_storeys}
\end{equation}

\begin{sagesilent}
latex.matrix_delimiters("\{","\}")
\end{sagesilent}

Mass
\begin{equation}
	 [M]=\sage{mass}
\end{equation}

Time Period
\begin{equation}
	[T]=\sage{Time_period}
\end{equation}

Omega Square
\begin{equation}
	[\omega^2] =\sage{Omega_square.transpose()}
\end{equation}

Frequency
\begin{equation}
	[\omega]=\sage{Omega}
\end{equation}

\newpage
\begin{figure}
	\sageplot[scale=0.75]{Graph}
	\caption{Mass Model}
\end{figure}

\begin{equation}Number of modes considered=\sage{Modes_considered}
\end{equation}
\newpage

Level Floor
\begin{equation}
	[L]=\sage{Level_floor}
\end{equation}

Modal Participation Factor
\begin{equation}
	 [p]=\sage{Modal_participation_factor}
\end{equation}

Modal Mass
\begin{equation}
	 [M_{{m}}]=\sage{Modal_mass}
\end{equation}

Modal Contribution
\begin{equation}
	[M_{{c}}]=\sage{Modal_contribution}
\end{equation}

Sa By G
\begin{equation}
	 [S_{{a}}]=\sage{Sa_by_g}
\end{equation}

A H
\begin{equation}
	[A_{{H}}]=\sage{A_h[:,1]}
\end{equation}

\begin{sagesilent}
latex.matrix_delimiters("[","]")

\end{sagesilent}
Design Lateral Force
\begin{equation}
	[F]=\sage{Design_lateral_force}
\end{equation}

Peak Shear Force
\begin{equation}
	[V]=\sage{Peak_shear_force}
\end{equation}

\begin{sagesilent}
latex.matrix_delimiters("\{","\}")
\end{sagesilent}

\section{Storey Shear Force}
ABS-:
\begin{equation}
	\sage{storey_shear_force3}
\end{equation}
SRSS -:
\begin{equation}
	\sage{Storey_shear_force2}
\end{equation}
Complete Quadratic combination -:
\begin{equation}
	\sage{Lateral_force}
\end{equation}
Maximum Absolute Response -:
\begin{equation}
	\sage{Force}
\end{equation}
\end{document}


%! Author = tstreule

\section{Action Potential \& Hodgkin-Huxley Model}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{minipage}[t]{.5\columnwidth-.5\columnsep}
    \subsection{Current Clamp}
    %
    \textbf{Fix current} $I_m$ and\\
    measure membrane potential
    \begin{itemize}
        \item[$\to\!\!$] Good for observing AP\\
        (since voltage can change)
    \end{itemize}
\end{minipage}%
\hspace{\columnsep}%
\begin{minipage}[t]{.5\columnwidth-.5\columnsep}
    \subsection{Voltage Clamp}
    %
    \textbf{Fix voltage} $V_m$ and\\
    measure the current
    \begin{itemize}
        \item[$\to\!\!$] Good for studying membrane channel proteins (ion transp.)
    \end{itemize}
\end{minipage}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{2-state ion channel model}
%
\formula{two states}{\ce{close <=>[\alpha][\beta] open}}
\quad with gate charge $Q$
\formula{\#open states}{\deriv{n(t)}{t} = \alpha (\mathcal{N} - n(t)) - \beta n(t)}
\formbox{Prob. being open}{x(t) \simeq \frac{n(t)}{\mathcal{N}} = x_\infty\! + (x_0-x_\infty\!) \;\eu^{-t/\tau_x}}
\formbox{~}{x_\infty\! = \frac{\alpha}{\alpha+\beta}, \quad \tau_x = \frac{1}{\alpha+\beta}}

\begin{minipage}{\linewidth}
    \begin{minipage}{\linewidth}
        \formula{Boltzmann law}{\alpha = A\;\eu^{(E_c-E_B)/kT}}
        \formula{~}{\beta = A\;\eu^{(E_o-E_B)/kT}}
        \formula{~}{x_\infty\! = \frac{1}{1+\beta/\alpha} = \frac{1}{1+\eu^{-QV_m/kT}}}
        \formula{~}{\tau_x = \frac{1}{A\;\eu^{-\frac{1}{2}QV_B/kT}} \cdots}
        \formula{~}{\phantom{\tau_x =} \cdots \frac{1}{\eu^{\frac{1}{2}QV_m/kT} + \eu^{-\frac{1}{2}QV_m/kT}}}
    \end{minipage}
    \begin{minipage}{\linewidth}
        \vspace{-30mm}\hfill
        \includegraphics[width=.35\columnwidth]{AP_Boltzmann}
    \end{minipage}
\end{minipage}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Circuit Model \textnormal{(Conductance) \hfill\small$V\ped{K} \simeq \unit[-75]{mV}, \quad V\ped{Na} \simeq \unit[+55]{mV}$}}
%
\formtex{~}{\scalebox{.9}{%
    \highlight{$J\ped{C} = C_m \deriv{V_m(t)}{t}$} \enskip \fbox{$J_m = C_m \deriv{V_m}{t} + G_m(V_m-V_m\ap{rest})$}}}
\formtex{~}{\scalebox{.9}{%
    \highlight{$J\ped{K} = G\ped{K}\;(V_m-V\ped{K})$} \scriptsize always $>0$, we don't fall below ($V_m>V\ped{K}$)}}
\formtex{~}{\scalebox{.9}{%
    \highlight{$J\ped{Na} = G\ped{Na}\;(V_m-V\ped{Na})$} \scriptsize $\begin{cases}>0 & \text{if } V_m-V\ped{Na}>0 \\ <0 & \text{otw.} \end{cases}$}}

\vspace{-18mm}%
\begin{minipage}{\linewidth}
    \includegraphics[width=.3\columnwidth]{AP_Conductance_Model}
\end{minipage}

\begin{minipage}{.25\columnwidth}
    \includegraphics[width=.8\columnwidth]{AP_Conductance}
\end{minipage}
\begin{minipage}{.75\columnwidth}
    \begin{itemize}
        \item slow onset; decays slow
        \item \ce{K+} inactivates \ce{Na+} channels
    \end{itemize}
    $\to$ \textbf{Refractoriness} {\scriptsize(kurzzeitige AP Resistenz)}\\
    \phantom{$\to$} (\ce{Na+} channels are still inactivate, $h\sim0$)
\end{minipage}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Multiple states gate}
%
\formtex{open $n_Q(V_m,t)$}{big/small $Q$ $\to$ fast/slow dynamics}

\formtex{Let's write}{%
    \fbox{$h$} $= n_{-Q}$ ``slow''\!, \;\;
    \fbox{$m$} $= n_{2Q}$ ``fast''\!, \;\;
    \fbox{$n$} $= n_Q$ %``normal''
}
\formtex{~}{The \textit{lower} $T$, the \textit{bigger} the diff. between them.}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Hodkin-Huxley \textnormal{(HH)} model}
%
Experimentally you may fit the \ce{K+} and \ce{Na+} current into
\formula{Conductance}{G\ped{K}(V_m,t) = \overline{G}\ped{K} \; n^4}
\formula{~}{{G\ped{Na}(V_m,t) = \overline{G}\ped{Na} \; m^3 h}}

\begin{minipage}{.35\columnwidth}
    \includegraphics[width=.9\columnwidth]{AP_Actionpotential}
\end{minipage}%
\hspace{\boxmargin}%
\begin{minipage}{.65\columnwidth}
    \textbf{Four regimes during AP}:
    \begin{enumerate}
        \item[II] \textit{De}polarization:
        \ce{Na+} gate opens $\to$ \ce{Na+} in
        \item[III] \textit{Re}polarization:
        \ce{K+} gate opens $\to$ \ce{K+} out
        \item[IV] \textit{Hyper}polarization:\\
        Active \ce{Na+-K+-ion} pump (\ce{Na+}$\leftrightarrow$ \ce{K+})
    \end{enumerate}
\end{minipage}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Decrement-free conduction}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Core -- Conductor Model}
%
\begin{minipage}{.3\columnwidth}
    \vspace{6mm}$V_m \big\downarrow$
    \begin{minipage}{.5\columnwidth}
        \vspace{-6mm}\includegraphics[width=\columnwidth]{AP_Core_Conductor_Model}
    \end{minipage}
\end{minipage}%
\hspace{1.5\boxmargin}%
\begin{minipage}{.6\columnwidth}
    $R_i = r_i \diff z$\quad $\leftarrow$ $\diff z$: per unit length\\
    $R_o = r_o \diff z$\\
    $I_m = k_m \diff z$\quad $\leftarrow$ may use HH-model
\end{minipage}%

\vspace{-3mm}
\formula{Core--Conductor eq.}{\pderiv[2]{V_m(z,t)}{z} = (r_o+r_i)K_m(z,t) - \overbrace{r_oK_e(z,t)}^{\overset{\textrm{if}}{=}\; 0 \;\to\; I_o = -I_i}}
\formula{\hfill wave eq.}{\phantom{\pderiv[2]{V_m(z,t)}{z}} = \frac{1}{v^2} \pderiv[2]{V_m(z,t)}{t} }
\enskip with $v = \frac{W}{\Delta t}$
\formbox{\hfill$\overset{K_e=0}{\implies}$}{v \simeq \frac{K_ma}{2\rho_i}}
\enskip for $r_i \gg r_o$
\enskip i.e. $v\propto\sqrt{a}$
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Cable model \textnormal{-- Core--Conductor with HH-model inside}}
%
\formtex{Linearize \small(1st order)}{\small timescale for membrane voltage changes {$\tau_m {=} \frac{C_m}{G_m}$}}
\formtex{Cable equation}{Let $v_m = V_m + V_m\ap{rest}$}
~\qquad $v_m {+} \hspace{-1mm}\underbrace{\tau_m\pderiv{v_m}{t}\vspace{-1mm}}_{\vspace{-2mm} = 0 \text{ time indep.}}\hspace{-1mm} - \lambda_C^2 \pderiv[2]{v_m}{z} {=} r_o\lambda_C^2K_e$
\enskip \highlight{$\lambda_C {=} \frac{1}{\sqrt{g_m(r_o+r_i)}}$}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsubsection{Saltatory Conduction Hypothesis}
%
$\to$ explain discrete manner in steps

\formula{velocity $\sim$ axon}{\textrm{total delay} \sim N (\#\textrm{nodes}) \sim (\textrm{axon length})/L}
\formula{diameter $D$}{\ce{->[$L\sim D$]} \textrm{velocity} \sim \frac{\textrm{total delay}}{\textrm{axon length}} \sim D}

\begin{minipage}{\columnwidth/3}
    \includegraphics[width=.85\columnwidth]{AP_Saltatory}
\end{minipage}%
\begin{minipage}{\columnwidth/3}
    \centering
    \includegraphics[width=.8\columnwidth]{AP_Saltatory_2}
\end{minipage}%
\begin{minipage}{\columnwidth/3}
    \hfill
    \includegraphics[width=.75\columnwidth]{AP_Ranvier_Node}
\end{minipage}


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

\begin{document}

This section covers selection and replacement techniques in the context of a crossover-based evolutionary algorithms. Their purpose is to introduce selection after reproduction in a way that checks whether or not crossover and mutation were able to produce a new solution candidate that outperforms its parents.

\begin{itemize}
    \item \textbf{OS:} A certain ratio of the next generation has to consist of children that can outperform their parents.
    \item \textbf{RAPGA:} new child solutions are added to the population as long as it is possible to generate unique and successful offspring from the gene pool of the last generation.
\end{itemize}

An upper limit for the selection pressure provides a good termination criterion.

\section{Offspring Selection (OS)}
\sectionmark{OS}

The progression of genetic search is the assured by means of successful offspring. The goal of OS is to create a sufficient number of children that surpass their parents' fitness.

\subsection{Success Ratio}
The success ration is defined as the relation between the next population members that need to be generated by successful mating, in relation to the total population.

\begin{equation}
    \text{SuccRation} \in [0,1]
\end{equation}

Having filled up the the claimed ratio, the rest of the generation is filled with randomly generated individuals that were also created by crossover but did not reach the criteria.

\subsection{Comparison Factor}
In oder to classify a child as \emph{better} than it's parent, the comparison factor is introduced. A comparison factor of 0 means that the child is considered better when it outperforms its weakest parent while it has to outperform its best parent for a comparison factor of 1.

\begin{equation}
    \text{CompFactor} \in [0,1]
\end{equation}

The comparison factor is scaled from 0 to 1 during the run of the algorithm. This causes a broader search at the beginning and a more directed search in the end.

\subsection{Actual Selection Pressure}
The actual selection pressure is the quotient of individuals that had to be considered until the success ration was reached, and the number of individuals in the population in the following way:

\begin{equation}
    \text{ActSelPress} = \frac{ | \text{POP}_{i+1} | + | \text{POOL} | }{ | \text{POP}_i | }
\end{equation}

An upper limit defines the maximum numbers of offspring considered. When this limit is sufficiently high, the model can be used for detecting premature convergence.

\textit{If it is no longer possible to find a sufficient number $(\text{SuccRatio} \dot | \text{POP} |)$ of offspring, outperforming their own parents even if $(\text{MaxSelPress} \dot | \text{POP} |)$ candidates have been generated, premature convergence has occurred.}

Higher success ratios cause higher selection pressure. This does not necessary cause premature convergence because the new selection step does not accepts clones. The latter are a major reason for premature convergence in regular GAs.

\section{Relevant Alleles Preserving GA (RAPGA)}
\sectionmark{RAPGA}

The goal of this enhanced algorithm variant is trying to bring out as much progress from the actual generation as possible and losing as little genetic diversity as possible at the same time. This is achieved by adjusting the population size. Potential offspring are accepted as members of the next generation $\Leftrightarrow $ they are able to outperform the fitness of their parents and they are new in the sense that their chromosome consists of a concrete allele alignment that is not represented yet in the  an individual of the current generation.

\subsection{Considerations}

The following practical aspects of the RAPGA need to be considered:

\begin{itemize}
    \item The algorithm should offer different parent selection mechanisms, even for different parents (male and female) or allow for it to be disabled completely (random).
    \item It is reasonable to have more than one crossover and mutation operator. This works even for operators only generating a good result sporadically, because only successful chromosomes are considered in the evolutionary progress.
    \item The population size requires a lower and upper bound. The upper limit is required to prevent snowballing in the first rounds. The lower limit is needed to have a sufficient amount of chromosomes present to outperform parents. Additionally, it can act as a detector for convergence.
    \item Checking genotipical identity prevents structurally identical individuals to be included in the next generation.
    \item The maximum effort per generation is the maximum number of newly generated chromosomes per generation, no matter whether they are accepted or not. This can be used to terminate generation rounds.
\end{itemize}

\end{document}


\documentclass[./Thesis.tex]{subfiles}
\begin{document}

\chapter*{Conclusion}
\addcontentsline{toc}{chapter}{Conclusion}
\chaptermark{Conclusion}
\markboth{Conclusion}{Conclusion}

This thesis described a selection of number theoretic concepts required for the
formalization and implementation of the AKS primality decision algorithm in the
\Agda{} proof assistant. We began with a high level overview of the AKS
algorithm. This overview outlined the necessary mathematical concepts that would
be required to implement AKS in a proof assistant. Since the \Agda{} proof
assistant does not have the mathematical lexicon of the average human number
theorist this list of theorems was quite large. As this is an undergraduate time
limited thesis, we choose to explicate a select few from this list. \\

In Chapter \ref{chap:exponentiation} we iteratively developed an exponentiation
algorithm that runs in logarithmic time relative to the exponent. This algorithm
can exponentiate any base as long as the base forms a commutative monoid under
its multiplication operation. Following this we proved that our exponentiation
algorithm was equal to the standard grade school method of computing
exponentials. This algorithm appears in the AKS algorithm multiple times and
importantly the type of the base changes in each location necessitating the
ability to exponentiate arbitrary commutative monoids. \\

Next in Chapter \ref{chap:termination} we investigated how \Agda{} is able to
ensure non-looping behavior, or in other words reject circular definitions. We
remarked on the strength of Agda's termination checker, the code that rejects
potentially looping programs. We discovered that \Agda{} can tell if a program
is soundly defined if it can infer a well-founded relation for its inputs. As
\Agda{} does not always succeed in this inference we then built machinery to
provide \Agda{} with our own well-founded relation. This allows us to express
complex recursive algorithms without the fear of non-termination. \\

Lastly, in Chapter \ref{chap:primality} we codified the correct representation of a
decision procedure in a proof relevant setting. As AKS is a decision procedure
getting this correct is paramount. We then developed a decision procedure for
the divisibility relation common in number theory. The ability to test if one
number divides another was immediately useful. As we ended the chapter with a
brute force primality decision procedure. This is a critical sub-component of the
AKS algorithm as AKS requires a list of ``small'' primes to test the input
against. \\

We were not able to develop every required component to prove the
correctness of AKS but we estimate at least 75\% of the required components are
completed. Some of the developed, but not described components are as follows; a
GCD function that works over an arbitrary Euclidean Domain, a polynomial
datatype that forms a Euclidean Domain, a modular ring datatype, and many more.
All of these formulations are available publicly in the github repo
\url{https://github.com/mckeankylej/thesis}. With more work we believe the
correctness of AKS can be fully formalized.

\end{document}


\section{\module{operator} ---
         Standard operators as functions.}
\declaremodule{builtin}{operator}
\sectionauthor{Skip Montanaro}{skip@automatrix.com}

\modulesynopsis{All Python's standard operators as built-in functions.}

The \module{operator} module exports a set of functions implemented in C
corresponding to the intrinsic operators of Python.  For example,
\code{operator.add(x, y)} is equivalent to the expression \code{x+y}.  The
function names are those used for special class methods; variants without
leading and trailing \samp{__} are also provided for convenience.

The functions fall into categories that perform object comparisons,
logical operations, mathematical operations, sequence operations, and
abstract type tests.

The object comparison functions are useful for all objects, and are
named after the rich comparison operators they support:

\begin{funcdesc}{lt}{a, b}
\funcline{le}{a, b}
\funcline{eq}{a, b}
\funcline{ne}{a, b}
\funcline{ge}{a, b}
\funcline{gt}{a, b}
\funcline{__lt__}{a, b}
\funcline{__le__}{a, b}
\funcline{__eq__}{a, b}
\funcline{__ne__}{a, b}
\funcline{__ge__}{a, b}
\funcline{__gt__}{a, b}
Perform ``rich comparisons'' between \var{a} and \var{b}. Specifically,
\code{lt(\var{a}, \var{b})} is equivalent to \code{\var{a} < \var{b}},
\code{le(\var{a}, \var{b})} is equivalent to \code{\var{a} <= \var{b}},
\code{eq(\var{a}, \var{b})} is equivalent to \code{\var{a} == \var{b}},
\code{ne(\var{a}, \var{b})} is equivalent to \code{\var{a} != \var{b}},
\code{gt(\var{a}, \var{b})} is equivalent to \code{\var{a} > \var{b}}
and
\code{ge(\var{a}, \var{b})} is equivalent to \code{\var{a} >= \var{b}}.
Note that unlike the built-in \function{cmp()}, these functions can
return any value, which may or may not be interpretable as a Boolean
value.  See the \citetitle[../ref/ref.html]{Python Reference Manual}
for more informations about rich comparisons.
\versionadded{2.2}
\end{funcdesc}

The logical operations are also generally applicable to all objects,
and support truth tests, identity tests, and boolean operations:

\begin{funcdesc}{not_}{o}
\funcline{__not__}{o}
Return the outcome of \keyword{not} \var{o}.  (Note that there is no
\method{__not__()} method for object instances; only the interpreter
core defines this operation.  The result is affected by the
\method{__nonzero__()} and \method{__len__()} methods.)
\end{funcdesc}

\begin{funcdesc}{truth}{o}
Return \constant{True} if \var{o} is true, and \constant{False}
otherwise.  This is equivalent to using the \class{bool}
constructor.
\end{funcdesc}

\begin{funcdesc}{is_}{a, b}
Return \code{\var{a} is \var{b}}.  Tests object identity.
\versionadded{2.3}
\end{funcdesc}

\begin{funcdesc}{is_not}{a, b}
Return \code{\var{a} is not \var{b}}.  Tests object identity.
\versionadded{2.3}
\end{funcdesc}

The mathematical and bitwise operations are the most numerous:

\begin{funcdesc}{abs}{o}
\funcline{__abs__}{o}
Return the absolute value of \var{o}.
\end{funcdesc}

\begin{funcdesc}{add}{a, b}
\funcline{__add__}{a, b}
Return \var{a} \code{+} \var{b}, for \var{a} and \var{b} numbers.
\end{funcdesc}

\begin{funcdesc}{and_}{a, b}
\funcline{__and__}{a, b}
Return the bitwise and of \var{a} and \var{b}.
\end{funcdesc}

\begin{funcdesc}{div}{a, b}
\funcline{__div__}{a, b}
Return \var{a} \code{/} \var{b} when \code{__future__.division} is not
in effect.  This is also known as ``classic'' division.
\end{funcdesc}

\begin{funcdesc}{floordiv}{a, b}
\funcline{__floordiv__}{a, b}
Return \var{a} \code{//} \var{b}.
\versionadded{2.2}
\end{funcdesc}

\begin{funcdesc}{inv}{o}
\funcline{invert}{o}
\funcline{__inv__}{o}
\funcline{__invert__}{o}
Return the bitwise inverse of the number \var{o}.  This is equivalent
to \code{\textasciitilde}\var{o}.  The names \function{invert()} and
\function{__invert__()} were added in Python 2.0.
\end{funcdesc}

\begin{funcdesc}{lshift}{a, b}
\funcline{__lshift__}{a, b}
Return \var{a} shifted left by \var{b}.
\end{funcdesc}

\begin{funcdesc}{mod}{a, b}
\funcline{__mod__}{a, b}
Return \var{a} \code{\%} \var{b}.
\end{funcdesc}

\begin{funcdesc}{mul}{a, b}
\funcline{__mul__}{a, b}
Return \var{a} \code{*} \var{b}, for \var{a} and \var{b} numbers.
\end{funcdesc}

\begin{funcdesc}{neg}{o}
\funcline{__neg__}{o}
Return \var{o} negated.
\end{funcdesc}

\begin{funcdesc}{or_}{a, b}
\funcline{__or__}{a, b}
Return the bitwise or of \var{a} and \var{b}.
\end{funcdesc}

\begin{funcdesc}{pos}{o}
\funcline{__pos__}{o}
Return \var{o} positive.
\end{funcdesc}

\begin{funcdesc}{pow}{a, b}
\funcline{__pow__}{a, b}
Return \var{a} \code{**} \var{b}, for \var{a} and \var{b} numbers.
\versionadded{2.3}
\end{funcdesc}

\begin{funcdesc}{rshift}{a, b}
\funcline{__rshift__}{a, b}
Return \var{a} shifted right by \var{b}.
\end{funcdesc}

\begin{funcdesc}{sub}{a, b}
\funcline{__sub__}{a, b}
Return \var{a} \code{-} \var{b}.
\end{funcdesc}

\begin{funcdesc}{truediv}{a, b}
\funcline{__truediv__}{a, b}
Return \var{a} \code{/} \var{b} when \code{__future__.division} is in
effect.  This is also known as division.
\versionadded{2.2}
\end{funcdesc}

\begin{funcdesc}{xor}{a, b}
\funcline{__xor__}{a, b}
Return the bitwise exclusive or of \var{a} and \var{b}.
\end{funcdesc}

Operations which work with sequences include:

\begin{funcdesc}{concat}{a, b}
\funcline{__concat__}{a, b}
Return \var{a} \code{+} \var{b} for \var{a} and \var{b} sequences.
\end{funcdesc}

\begin{funcdesc}{contains}{a, b}
\funcline{__contains__}{a, b}
Return the outcome of the test \var{b} \code{in} \var{a}.
Note the reversed operands.  The name \function{__contains__()} was
added in Python 2.0.
\end{funcdesc}

\begin{funcdesc}{countOf}{a, b}
Return the number of occurrences of \var{b} in \var{a}.
\end{funcdesc}

\begin{funcdesc}{delitem}{a, b}
\funcline{__delitem__}{a, b}
Remove the value of \var{a} at index \var{b}.
\end{funcdesc}

\begin{funcdesc}{delslice}{a, b, c}
\funcline{__delslice__}{a, b, c}
Delete the slice of \var{a} from index \var{b} to index \var{c}\code{-1}.
\end{funcdesc}

\begin{funcdesc}{getitem}{a, b}
\funcline{__getitem__}{a, b}
Return the value of \var{a} at index \var{b}.
\end{funcdesc}

\begin{funcdesc}{getslice}{a, b, c}
\funcline{__getslice__}{a, b, c}
Return the slice of \var{a} from index \var{b} to index \var{c}\code{-1}.
\end{funcdesc}

\begin{funcdesc}{indexOf}{a, b}
Return the index of the first of occurrence of \var{b} in \var{a}.
\end{funcdesc}

\begin{funcdesc}{repeat}{a, b}
\funcline{__repeat__}{a, b}
Return \var{a} \code{*} \var{b} where \var{a} is a sequence and
\var{b} is an integer.
\end{funcdesc}

\begin{funcdesc}{sequenceIncludes}{\unspecified}
\deprecated{2.0}{Use \function{contains()} instead.}
Alias for \function{contains()}.
\end{funcdesc}

\begin{funcdesc}{setitem}{a, b, c}
\funcline{__setitem__}{a, b, c}
Set the value of \var{a} at index \var{b} to \var{c}.
\end{funcdesc}

\begin{funcdesc}{setslice}{a, b, c, v}
\funcline{__setslice__}{a, b, c, v}
Set the slice of \var{a} from index \var{b} to index \var{c}\code{-1} to the
sequence \var{v}.
\end{funcdesc}

The \module{operator} module also defines a few predicates to test the
type of objects.  \note{Be careful not to misinterpret the
results of these functions; only \function{isCallable()} has any
measure of reliability with instance objects.  For example:}

\begin{verbatim}
>>> class C:
...     pass
...
>>> import operator
>>> o = C()
>>> operator.isMappingType(o)
True
\end{verbatim}

\begin{funcdesc}{isCallable}{o}
\deprecated{2.0}{Use the \function{callable()} built-in function instead.}
Returns true if the object \var{o} can be called like a function,
otherwise it returns false.  True is returned for functions, bound and
unbound methods, class objects, and instance objects which support the
\method{__call__()} method.
\end{funcdesc}

\begin{funcdesc}{isMappingType}{o}
Returns true if the object \var{o} supports the mapping interface.
This is true for dictionaries and all instance objects.
\warning{There is no reliable way to test if an instance
supports the complete mapping protocol since the interface itself is
ill-defined.  This makes this test less useful than it otherwise might
be.}
\end{funcdesc}

\begin{funcdesc}{isNumberType}{o}
Returns true if the object \var{o} represents a number.  This is true
for all numeric types implemented in C, and for all instance objects.
\warning{There is no reliable way to test if an instance
supports the complete numeric interface since the interface itself is
ill-defined.  This makes this test less useful than it otherwise might
be.}
\end{funcdesc}

\begin{funcdesc}{isSequenceType}{o}
Returns true if the object \var{o} supports the sequence protocol.
This returns true for all objects which define sequence methods in C,
and for all instance objects.  \warning{There is no reliable
way to test if an instance supports the complete sequence interface
since the interface itself is ill-defined.  This makes this test less
useful than it otherwise might be.}
\end{funcdesc}

Example: Build a dictionary that maps the ordinals from \code{0} to
\code{256} to their character equivalents.

\begin{verbatim}
>>> import operator
>>> d = {}
>>> keys = range(256)
>>> vals = map(chr, keys)
>>> map(operator.setitem, [d]*len(keys), keys, vals)
\end{verbatim}

\subsection{Mapping Operators to Functions \label{operator-map}}

This table shows how abstract operations correspond to operator
symbols in the Python syntax and the functions in the
\refmodule{operator} module.

\begin{tableiii}{l|c|l}{textrm}{Operation}{Syntax}{Function}
  \lineiii{Addition}{\code{\var{a} + \var{b}}}
          {\code{add(\var{a}, \var{b})}}
  \lineiii{Concatenation}{\code{\var{seq1} + \var{seq2}}}
          {\code{concat(\var{seq1}, \var{seq2})}}
  \lineiii{Containment Test}{\code{\var{o} in \var{seq}}}
          {\code{contains(\var{seq}, \var{o})}}
  \lineiii{Division}{\code{\var{a} / \var{b}}}
          {\code{div(\var{a}, \var{b}) \#} without \code{__future__.division}}
  \lineiii{Division}{\code{\var{a} / \var{b}}}
          {\code{truediv(\var{a}, \var{b}) \#} with \code{__future__.division}}
  \lineiii{Division}{\code{\var{a} // \var{b}}}
          {\code{floordiv(\var{a}, \var{b})}}
  \lineiii{Bitwise And}{\code{\var{a} \&\ \var{b}}}
          {\code{and_(\var{a}, \var{b})}}
  \lineiii{Bitwise Exclusive Or}{\code{\var{a} \^\ \var{b}}}
          {\code{xor(\var{a}, \var{b})}}
  \lineiii{Bitwise Inversion}{\code{\~{} \var{a}}}
          {\code{invert(\var{a})}}
  \lineiii{Bitwise Or}{\code{\var{a} | \var{b}}}
          {\code{or_(\var{a}, \var{b})}}
  \lineiii{Exponentiation}{\code{\var{a} ** \var{b}}}
          {\code{pow(\var{a}, \var{b})}}
  \lineiii{Identity}{\code{\var{a} is \var{b}}}
          {\code{is_(\var{a}, \var{b})}}
  \lineiii{Identity}{\code{\var{a} is not \var{b}}}
          {\code{is_not(\var{a}, \var{b})}}
  \lineiii{Indexed Assignment}{\code{\var{o}[\var{k}] = \var{v}}}
          {\code{setitem(\var{o}, \var{k}, \var{v})}}
  \lineiii{Indexed Deletion}{\code{del \var{o}[\var{k}]}}
          {\code{delitem(\var{o}, \var{k})}}
  \lineiii{Indexing}{\code{\var{o}[\var{k}]}}
          {\code{getitem(\var{o}, \var{k})}}
  \lineiii{Left Shift}{\code{\var{a} <\code{<} \var{b}}}
          {\code{lshift(\var{a}, \var{b})}}
  \lineiii{Modulo}{\code{\var{a} \%\ \var{b}}}
          {\code{mod(\var{a}, \var{b})}}
  \lineiii{Multiplication}{\code{\var{a} * \var{b}}}
          {\code{mul(\var{a}, \var{b})}}
  \lineiii{Negation (Arithmetic)}{\code{- \var{a}}}
          {\code{neg(\var{a})}}
  \lineiii{Negation (Logical)}{\code{not \var{a}}}
          {\code{not_(\var{a})}}
  \lineiii{Right Shift}{\code{\var{a} >\code{>} \var{b}}}
          {\code{rshift(\var{a}, \var{b})}}
  \lineiii{Sequence Repitition}{\code{\var{seq} * \var{i}}}
          {\code{repeat(\var{seq}, \var{i})}}
  \lineiii{Slice Assignment}{\code{\var{seq}[\var{i}:\var{j}]} = \var{values}}
          {\code{setslice(\var{seq}, \var{i}, \var{j}, \var{values})}}
  \lineiii{Slice Deletion}{\code{del \var{seq}[\var{i}:\var{j}]}}
          {\code{delslice(\var{seq}, \var{i}, \var{j})}}
  \lineiii{Slicing}{\code{\var{seq}[\var{i}:\var{j}]}}
          {\code{getslice(\var{seq}, \var{i}, \var{j})}}
  \lineiii{String Formatting}{\code{\var{s} \%\ \var{o}}}
          {\code{mod(\var{s}, \var{o})}}
  \lineiii{Subtraction}{\code{\var{a} - \var{b}}}
          {\code{sub(\var{a}, \var{b})}}
  \lineiii{Truth Test}{\code{\var{o}}}
          {\code{truth(\var{o})}}
  \lineiii{Ordering}{\code{\var{a} < \var{b}}}
          {\code{lt(\var{a}, \var{b})}}
  \lineiii{Ordering}{\code{\var{a} <= \var{b}}}
          {\code{le(\var{a}, \var{b})}}
  \lineiii{Equality}{\code{\var{a} == \var{b}}}
          {\code{eq(\var{a}, \var{b})}}
  \lineiii{Difference}{\code{\var{a} != \var{b}}}
          {\code{ne(\var{a}, \var{b})}}
  \lineiii{Ordering}{\code{\var{a} >= \var{b}}}
          {\code{ge(\var{a}, \var{b})}}
  \lineiii{Ordering}{\code{\var{a} > \var{b}}}
          {\code{gt(\var{a}, \var{b})}}
\end{tableiii}


\chapter{Normal forms}\setcounter{ProbPart}{0}

\problempart
\label{pr.DNF}
Consider the following sentences:
	\begin{earg}
		\item $(A \eif \enot B)$
		\item $\enot (A \eiff B)$
		\item $(\enot A \eor \enot (A \eand B))$
		\item $(\enot (A \eif B ) \eand (A \eif C))$
		\item $(\enot (A \eor B) \eiff ((\enot C \eand \enot A) \eif \enot B))$
		\item $((\enot (A \eand \enot B) \eif C) \eand \enot (A \eand D))$
	\end{earg}
        For each sentence, find a tautologically equivalent sentence in DNF and one in CNF.

\stepcounter{chapter} % Functional completeness
\stepcounter{chapter} % Soundness


\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[utf8, left=2.5cm, right=2.5cm, top=2.5cm, bottom=2.5cm]{geometry}
\usepackage[english]{babel}
\setlength{\parindent}{2em}
\setlength{\parskip}{1em}
\renewcommand{\baselinestretch}{1}
\usepackage{graphicx}
\usepackage{gensymb}
\usepackage{natbib}
\usepackage{amssymb}
\usepackage{xcolor}
\usepackage{wasysym}

\title{Tidal Evolution of the Earth-Moon System}
\author{Patricia Golaszewska}
\date{May $14^{th}$ 2021}
\begin{document}

\maketitle

\newpage

\begin{center}
    \section*{Introduction}
\end{center}

This project sets out to model the tidal evolution of the Earth-Moon system. The evolution of this system can be modelled using a set of ordinary differential equations:

\begin{equation}
   \frac{dL_{\oplus}}{dt} = T_{\odot}
\end{equation}

\begin{equation}
   \frac{dS_{\oplus}}{dt} = -T_{\odot} - T_{\leftmoon}
\end{equation}

\begin{equation}
   \frac{dL_{\leftmoon}}{dt} = T_{\leftmoon}
\end{equation}

The ultimate goal is to integrate these ODEs numerically using python. This allows us to model the tidal evolution of the Earth-Moon system; from initial impact to the present day. As discussed in the project outline, tidal forces have an effect on the tides. Our understanding of this phenomenon is a combination of the effects of the spin angular momentum of Earth, and the orbital angular momentum of the Sun and the moon. This then motivates the choice of the set of ODEs used in this project.

\begin{center}
    \section*{Methods}
\end{center}

We are first tasked with establishing various quantities which are used throughout the project. Due to the majority of quantities being provided in cgs units, this was the chosen unit system. Other values were converted in order to conform to this unit system.

Calculations could then be made by using the mathematical abilities of python. This allowed us to then calculate the values we'll need to feed into our integrator later on. Thus, we could calculate the numerical values of timescales associated with our three ODEs, their initial conditions, and their RHS.

Using the scipy.integrate package and the dopri5 integrator, we could then combine our initial conditions with our ODEs following the format discussed in CTA200H lectures. Because we need to integrate into the past, a negative set of time values was chosen, ranging from the present day (0) to billions of years in the past. According to the model, the moon formed roughly 1.5 billion years ago, however, there is scientific evidence that the moon is much older than that.

Using the result of this integration, we could then analyze the evolution of the moons formation. The giant impact hypothesis is generally regarded as the leading theory in the formation of our moon. Our model allows for us to integrate into the past when the Earth and the object that would become our moon collided. At this point, their separation distance was 0 and grew over time to its present value. Thus, indexing our arrays allows us to find the time which the model predicts that the moon formed. As time moved forward, the semimajor axis expanded, and that expansion is depicted visually in Figure 1.

\begin{figure}[htp]
    \centering
    \includegraphics[width=12cm]{Q6.pdf}
    \caption{Change in the semimajor axis of the moon over time.}
    \label{fig:Q6}
\end{figure}

If the moon formed at the Roche radius (at approximatley 9496 km), then the length of day would be approximately 4 hours long. As the system stabilized over time, the length of day became longer. This is depicted visually in Figure 2.

\begin{figure}[htp]
    \centering
    \includegraphics[width=12cm]{Q7.pdf}
    \caption{Change in the length of day on Earth over time.}
    \label{fig:Q7}
\end{figure}

Issues surrounding this model arise from the incorrect age we get for our system. I suspect that there may be issues with how our model predicts the evolution of this system, and possibly doesn't account for the conditions at impact.

Firstly, I do not believe that this model allows for the moon to go through the process of mass accretion. This process would change the dynamics of the system over time as the gravitational effects change.

Second, I believe that this model assumes that the Earth-Moon system has been tidally locked from impact. This is an extension of the point made above; the dynamics of this system age the Earth-Moon system based on the tidal evolution. However, if the moon spent a period of time in asynchronous rotation, this model doesn't capture this.

I believe that this model interprets the collision as formation, which isn't necessarily true. The moon would have began it's formation at some distance away (i.e possibly the Roche radius) versus at impact.

Additional inconsistencies may be caused by changes in the eccentricity and alignment of the moons orbit, as well as external gravitational influences. Stabilization and tidal-locking may also result in changes in the energy in this system, which could have influenced the evolution of our system.

These reasons are listed in the order of what I assume to be the most reasonable assumption. My primary concern is that the initial dynamics of the system differ than those observed today, and they are not accounted for in the scope of this project.

\end{document}


\documentclass[12pt]{article}
\usepackage[english]{babel}
\usepackage{graphicx, amsmath, mathtools, listings, color, caption, rotating, subfigure, fullpage, textcomp, enumerate, float, alltt, hyperref}

\lstset{
	language=R,
	keywordstyle=\bfseries\ttfamily\color[rgb]{0,0,1},
	identifierstyle=\ttfamily,
	commentstyle=\color[rgb]{0.133,0.545,0.133},
	stringstyle=\ttfamily\color[rgb]{0.627,0.126,0.941},
	showstringspaces=false,
	numberstyle=\tiny,
	numbers=left,
	stepnumber=1,
	numbersep=10pt,
	tabsize=2,
	breaklines=true,
	breakatwhitespace=false,
	aboveskip={1.5\baselineskip},
  columns=fixed,
  upquote=true,
  extendedchars=true,
}

\begin{document}
\begin{center}
\bf{A Primer on Calculating the Mann-Whitney Statistic}
\end{center}
Hello everyone,
The Mann-Whitney test is pretty useful. I told my discussion section it's one of the “bread-and-butter techniques” in nonparametric statistics, because if the data is actually normal, it's almost as efficient (i.e.: almost the same power) as the t-test (which relies on normality), and if the data isn't normal, it's often far more efficient. I wrote this walkthrough a few years ago to explain to a biostatistics class how to calculate the MW U-Statistic the way you discussed in lecture. I hope this helps some of you understand how to compute the statistic.

I will use the dataset from page 284 (example 7.10.2) of “Statistics for the Life Sciences”, Fourth Edition, by Samuels, Witmer, and Schaffner, and test the hypothesis that the distribution of population 1 is equal to population 2,
%%%%
against the alternative that between the two at $\alpha = 0.05$:
%%%%
\begin{table}[H] \center
\begin{tabular}{|c|c|c|c|c|c|c|c|c|} \hline
$X$ & 64 & 315 & 17 & 170 & 20 & 22 & 190 & \\ \hline
$Y$ & 13 & 14 & 15 & 6 & 29 & 16 & 18 & 22 \\ \hline
\end{tabular}
\end{table}

\section{Order the Data}
Order the data so that the smallest values are first and the largest values are last. This makes it easier to do the later steps. Reproduced below are the two, ordered, samples.
\begin{table}[H] \center
\begin{tabular}{|c|c|c|c|c|c|c|c|c|} \hline
$X$ & 17 & 20 & 22 & 64 & 170 & 190 & 315 & \\ \hline
$Y$ & 6 & 13 & 14 & 15 & 16 & 18 & 22 & 29 \\ \hline
\end{tabular}
\end{table}

\section{Count Number of X Smaller Than Y}
Starting with the first sample, $X$, count how many values in $Y$ are smaller than each value of $X$. For example, the first value of $X$ is 17. The $Y$ values 6, 13, 14, 15, and 16 are all smaller than 17, so the first number of observations in $Y$ smaller than the first observation of $X$ is 5. The second value of $X$ is 20, and in $Y$, values 6, 13, 14, 15, 16, and 18 are smaller. This means the number of observations smaller than the second observation is 6.

For the third number, 22, you'll notice there are ties with $Y$. Instead of giving the usual point value of 1 to a greater number, if you encounter a tie, add .5. Thus, the third observation of $X$ (22) is bigger than 6, 13, 14, 15, 16, 18, and ties with 22, for a score of 6.5. Repeat this process for all remaining values of $X$. You will get the following numbers of $X$'s greater than $Y$'s: 5, 6, 6.5, 8, 8, 8, 8. Note that the last four observations of $X$ (64, 170, 190, 315) are all greater than the largest number in $Y$, so the number of observations of $Y$ that are smaller than $X$ will be the same for the last four observations. The $K_1$ statistic is the sum of all those numbers. $5 + 6 + 6.5 + 8 + 8 + 8 + 8 = 49.5$.

Now, there's a nifty property that shows that if you repeated the procedure but with $X$ and $Y$ flipped, their sum would be the product of the two sample sizes. We will leverage this fact to avoid having to do this procedure again. If $U_{lower} + U_{upper} = nm$, then $U_{lower} = nm - U_{upper}$. So the lower statistic will be $(7 \cdot 8) - 49.5 = 6.5$.

\section{Look Up the Statistic in the Book}
The book is going to give you a range of probable lower and upper statistics for a few levels of significance. $X$ has 7 observations and $Y$ has 8, so $n=7$ and $m=8$ (if you confuse $n$ and $m$, it's okay, because it's symmetric--the table gives the same values as $n=8$ and $m=7$). The region to we need to hit is $(13,43)$. If our lower statistic is less than $13$ or our upper statistic is bigger than $43$, we would have evidence to reject our null hypothesis.

As a note, you only need to check either the upper \emph{or} the lower value, because once you know the sample sizes and just one of the statistics (lower or upper), you can calculate the other one.

Our statistic is 49.5. Since we said we would reject if the upper statistic was bigger than 46, we reject $H_0$, and conclude that there are differences in the distributions of $X$ and $Y$.
\section{How to do This in R}
Get the data into R. Then use the function \verb+wilcox.test+.
\begin{center}
\begin{lstlisting}
X = c(64, 315, 17, 170, 20, 22, 190)
Y = c(13, 14, 15, 6, 29, 16, 18, 22)
wilcox.test(X, Y)
\end{lstlisting}

\begin{alltt}
Wilcoxon rank sum test with continuity correction
data:  X and Y
W = 49.5, p-value = 0.015
alternative hypothesis: true location shift is not equal to 0

Warning message:
In wilcox.test.default(X, Y) : cannot compute exact p-value with ties
\end{alltt}
\end{center}
For more information about the Wilcoxon-Mann-Whitney function in R, check out the help page: \\\ \url{http://stat.ethz.ch/R-manual/R-patched/library/stats/html/wilcox.test.html}. \\
The page also gives you information about how to specify alternative hypotheses, and whether to use a normal approximation.
\end{document}

Primers and Walkthroughs/A Primer on Mann-Whitney.tex