\section{Transmission Selection}

As part of your design, you will need to select the type of transmission and subsequent specification of your chosen transmission. You will need to do some research on the types of transmission to be able to present a reasoned argument for your selection. This will be followed by the steps taken to select an initial specification of transmission. In this document, we will take your through the selection of a chain transmission. For other transmission types, you will have to look up the relevant guides and processes. Do not let this put you off though as the steps are fairly similar.

\subsection{Transmission Types}

\begin{framed}
    \vspace{1cm}
    \begin{center}
        \Large
        -- Own Research \& Lectures --
    \end{center}
    \vspace{1cm}
\end{framed}

\subsection{Selecting a Chain Drive}

The following selection of a chain drive uses Renold's Chain Guide\footnote{Acknowledgements to the Renold Chain Guide}. Other chain companies will have similar processes and it is important to follow the appropriate companies' process when selecting your transmission.

\subsubsection{Features \& Considerations}

An\marginnote{Centre Distance}  incorrect centre distance leads to a higher wear rate and slack chain, which introduces further inefficiencies into the system. % Centre distances that are smaller than nominal can be attained through the use of a chain tensioner.

When\marginnote{polygonal action} the driving sprocket of a chain drive runs at constant speed, the speed of the chain itself is not constant but is subject to periodic fluctuations. This fluctuation, which is caused by the fact that the chain when wrapped on a sprocket forms a polygon rather than a circle, is known as polygonal action~\cite{mahalingam1958}.

One effect of polygonal action is to produce a periodic variation in the velocity ratio of the drive, and if the frequency of this variation coincides with a resonant frequency of the system, large stresses may occur. At high chain speeds the effects of impact are very complex; each impact sets up a train of travelling waves which, after reflection at the sprockets, combine with the next train and so on.

\cref{fig-cyclic-speed-variation} highlights that polygonal actions' effect increases considerably as one decreases the no.\ of sprocket teeth below 19. Hence, Renold recommends that sprockets should have a minimum of 19 teeth to avoid the effect of polygonal action. If lower teeth are required, then an additional factor is applied when selecting a chain, which reduces the maximum rated speed of the chain.

\begin{marginfigure}
    \centering
    \includegraphics[width=\textwidth]{07_transmission_selection/polygonal-action.png}
    \caption[Cyclic speed variation due to polygonal action]{Cyclic speed variation due to polygonal action~\citep[p.24]{renoldchain}}
    \label{fig-cyclic-speed-variation}
\end{marginfigure}

It\marginnote{cranked link} is always best practice and desirable to have a chain with an even number of links. However, when there is a case that requires an odd linked chain, cranked links are used to form the chain loop. \cref{fig-cranked-link} shows an example of a cranked link within a chain. The link has a natural kink in the profile to allow it to connect to the next link in the chain. This inherently places additional stress concentrations within the component and thus, is not recommended for high load and/or speed chain drives.

\begin{marginfigure}
    \centering
    \includegraphics[width=\textwidth]{07_transmission_selection/cranked-link.png}
    \caption[Cranked link]{Cranked link~\citep[p.11]{renoldchain}}
    \label{fig-cranked-link}
\end{marginfigure}

\subsubsection{Selection Process}

The selection process for a Renold chain is as follows. The prerequisites for the process is that you know the torque and sprocket speeds that you wish to run at.

The\marginnote{Selection Power (\(P_s\))} selection power is calculated by multiplying the power you wish to transmit (\(P_s\)) by two safety factors \(f_1\) and \(f_2\).

\begin{equation}
  P_s = f_1f_2P_t
\end{equation}

\noindent Where:

\begin{description}
  \item[\(f_1\)] Safety factor depending on your operation and can be found using chart 2 on p.28 of the Renold catalogue
  \item[\(f_2\)] Adjustment factor is your are using the non-recommended number of driving sprocket teeth. \(f_2=\frac{19}{\text{No. of teeth on driving}}\)
\end{description}

With\marginnote{Selecting a Suitable Chain Pitch} the selection power determined and the driver sprocket speed known, one can determine the chain pitch using \cref{fig-chain-pitch}. These rating charts have been created from years of empirical testing and theoretical modelling by the chain companies, and dictate the safe operating windows for their selection of chains.

\begin{figure}[h!]
    \centering
    \includegraphics[width=0.9\textwidth]{07_transmission_selection/chain-pitch.png}
    \caption[Chain pitch selection chart]{Chain pitch selection chart~\citep[p.31]{renoldchain}}
    \label{fig-chain-pitch}
\end{figure}

After\marginnote{Select Chain and Sprockets} selecting the chain pitch, you can go through the catalogue to find the drive and driven sprockets that will give you the required (or as near as possible) ratio for your design.

Having\marginnote{Chain Links and Centre Distance} the chain pitch and sprockets selected, the centre distance

\begin{equation}
    L = \frac{Z_1+Z_2}{2}+\frac{2C_1}{P}+\frac{P{\left(\frac{Z_2-Z_1}{2\pi}\right)}^2}{C_1}
\end{equation}

\noindent{} Where:

\begin{description}
    \item[\(Z_1\)] Number of driving teeth
    \item[\(Z_2\)] Number of driven teeth
    \item[\(C_1\)] Approximate desired centre distance
    \item[\(P\)] Chain pitch
    \item[\(L\)] Number of chain links
\end{description}

Once calculated, you then round to the nearest even integer and use this to calculate your centre distance \(C\).

\begin{equation}
    C=\frac{P}{8}
    \left[
    2L-Z_2-Z_1
    +
    \sqrt{
    {\left(2L-Z_2-z_1\right)}^2 - \left(\frac{\pi}{3.88}\left(Z_2-Z_1\right)^2\right)
    }
    \right]
\end{equation}

\subsubsection{Chain Example}

Select a chain and sprocket to transmit \SI{2}{\kilo\watt} of power at \SI{20}{rpm}. A ratio of 1:2 is required, driven by an electric motor with moderate shocks expected from the load. Space is highly limited.

Using\marginnote{determining \(f_1\) and \(f_2\)} Chart 2 on p.28 of the Renold catalogue, we identify that \(f_1=1.4\) for our context and we will also use the recommended number of teeth on the driving sprocket (19), which makes \(f_2=1\). Therefore, the selection power \(P_s\) becomes:

\begin{equation}
    P_s = f_1f_2P_t = 2\si{\kilo\watt}\times1.4\times1=2.8\si{\kilo\watt}
\end{equation}

Using\marginnote{chain pitch} \cref{fig-chain-pitch}, we can find the chain pitches that are suitable for our application. The potential pitches are:

\begin{itemize}
    \item \SI{38.10}{\milli\metre} simplex
    \item \SI{31.75}{\milli\metre} duplex
    \item \SI{25.40}{\milli\metre} triplex
\end{itemize}

For\marginnote{chain and sprocket selection} this example, we will select the triplex as our requirement is to have a compact solution. Now it is just a case of looking in the tables to find a sprocket set (Renolds, p.75) that will provide us with a ratio that provides us with the closest match in terms of our desired ratio, and a triplex chain (Renolds, p.25).

\begin{description}
    \item[Chain] 12B-3
    \item[Driving Sprocket] 16B1/19T
    \item[Driven Sprocket] 16B1/38T
\end{description}

Now\marginnote{chain links} we have the sprockets and chain selected, it is then a simple case of using their specifications to determine the number of links:

\begin{equation}
    L =
    \frac{19+38}{2}
    +
    \frac{2\times571.5}{19.05}+\frac{19.05{\left(\frac{38-19}{2\pi}\right)}^2}{571.5} = 88.6
\end{equation}

Rounding this up to the nearest even integer gives us \(L=90\).

The\marginnote{centre distance} final calculation is to determine the centre distance:

% https://www.sharelatex.com/learn/Aligning_equations_with_amsmath
\begin{equation}
\begin{split}
    C & = \frac{19.05}{8}
    \left[
    2(90)-38-19
    +
    \sqrt{
    {\left(2(90)-38-19\right)}^2 - \left(\frac{\pi}{3.88}\left(38-19\right)^2\right)
    }
    \right]
    \\ & = \SI{583}{\milli\metre}
\end{split}
\end{equation}

\subsection{Selecting a vee-belt or tooth belt}

\begin{framed}
    \vspace{1cm}
    \begin{center}
        \Large
        -- Own Research \& Lectures --
    \end{center}
    \vspace{1cm}
\end{framed}


\documentclass[12pt]{amsart}

\usepackage[margin=.7in]{geometry}

\usepackage{amsmath}

\usepackage{enumerate}
\usepackage{todonotes}
\usepackage{hyperref}
\newtheorem{thm}{Theorem}
\newtheorem{cor}{Corollary}
%\newtheorem{rmk}[thm]{Remark}
\newenvironment{sol}{\paragraph{{\bf Solution:}}}{\hfill$\square$}
\newenvironment{act}{\paragraph{{\bf Activity:}}}{\hfill$\square$}
\usepackage{bm}

\theoremstyle{definition}
\newtheorem*{defn}{Definition}
\newtheorem*{ex}{Example}
\newtheorem*{nonex}{Non-example}
\newtheorem*{rmk}{Remark}

\usepackage{mathtools}

\usepackage{tikz}

\newcommand{\Q}{\mathbb{Q}}
\newcommand{\N}{\mathbb{N}}

\title{What to Expect for Exam 2
}

\begin{document}
MTH 210 - Winter 2020 \hfill Dr. Keough\\

\maketitle

\vspace{-.3in}

\section{Structure }
Please read the following carefully:
\begin{itemize}
\item The exam will be posted on Blackboard on Tuesday, April 7 at 1PM. You should upload a single PDF of your answers by Thursday, April 9 at 5PM. \emph{Please start each section on a new page and make sure you are uploading just one document.}
\item The exam is open book and notes. On the first attempt, you should not use Blackboard, and no collaboration is allowed (but see the revisions section for how this policy changes on the second attempt). No technology is allowed
\item There is no time limit on the exam, but my intention is that it will not take you more time than if we took the exam in class.
\item  There is no regular class on Wednesday, April 8, but I will be in our online classroom during class time in case you have questions about the exam at that time. \item The exam covers Sections 3.3-6.3 (up through the material covered on Wednesday, April 2).
\end{itemize}
\vspace{-.2in}
\section{Grading}

The exam will be organized into 4 sections (see the information Section 3 of this document). Each section will be graded as E(xemplary), S(atisfactory), P(rogressing), I(ncomplete). Here is a description of what each grade means:

\begin{center}
\begin{tabular}{|c|c|p{4in}|}
\hline
Letter &Meaning &Description\\
\hline
E &Exemplary &There are no mistakes or errors in the work, including errors in logic and notation, apart from a small number of trivial errors. All solutions are backed up by work that is well written, clearly shown, and easy to read.\\
\hline
S &Satisfactory &Understanding of the concepts is evident, although there may be a small number of mistakes in the work that do not significantly affect the overall reasoning. All solutions are backed up by work that is clearly shown and easy to read.\\
\hline
P &Progressing &Partial understanding of concepts is evident, and all parts of the solution have a good-faith attempt. But there are significant errors in computation, logic, or writing that affect the overall reasoning. The solution should be revised.\\
\hline
I &Incomplete &There are significant omissions in the work, such as parts of the solution left blank intentionally or essential parts of the reasoning behind the answers that are missing or unreadable. Not enough information to determine if the concepts are fully understood. \\
\hline
\end{tabular}
\end{center}
\hspace{.5in}

The grade on the exam will be either E, S, or P+, or P according to the following table

\begin{center}
\begin{tabular}{|c|c|c|}
\hline
Letter &Meaning &Description\\
\hline
E &Exemplary &All sections earned an S or a E including at least one E. \\
\hline
S &Satisfactory &All sections earned an S.\\
\hline
P+ &Progressing Plus &Earned at least 2 S's or E's, but not all sections earned S's or E's.\\
\hline
P &Progressing &Did not earn at least 2 S's or E's.\\
\hline
\end{tabular}
\end{center}

\newpage

\section{Sections}

The sections are listed below. Each section will have multiple questions, the letter grade will be based on your answers to all questions.
\vfill

\begin{enumerate}
\item {\bf Sets}  Properly use the notation $\subset$, $\subseteq$, $\in$, $=$, $\not\subset$, $\not\subseteq$, $\notin$, $=$. Be able to read and write in both roster and set builder notation. Given sets $A$ and $B$ and a universal set $U$ be able to find $A\cap B$, $A\cup B$, $A-B$, $A^c$, $\mathcal{P}(A)$ (the power set of $A$), $A\times B$, $|A|$ (the cardinality of $A$, and combinations of these things. For sets $A$ and $B$, know how to prove $A\subseteq B$, $A\subset B$, $A=B$, $A\neq B$, and $A\cap B = \emptyset$ ($A$ and $B$ disjoint).
\vfill

\item {\bf Functions} Know the formal definition of function and some examples/non-examples. Know the terms domain, codomain, range, image, and preimage, and be able to use them in sentences about a given function. Be able to create functions with given properties about their domains, codomains, range, images, and or preimages. Articulate what it means for two functions to be equal. Demonstrate using functions that are more general than $f(x) = (rule)$, like functions involving congruence, derivatives, determinants, and functions of two variables. Know the definitions of injection, surjection, and bijection, know how to determine if a function is any of these, and be able to construct examples of each (or combinations of them). Know how to prove that a function is an injection, surjection, or bijection.

\vfill
\item {\bf Which Proof Technique When?}   For this section you will be given 4 theorem statements with which you will need to do 3 things:
	\begin{itemize}
	\item State which proof technique you would use.
	\item Explain your choice of proof technique.
	\item Outline the steps in a proof using the proof technique (but you should not actually attempt to prove the statement). You should say what you would assume and what you would try to prove.

	\end{itemize}

	For the first bullet your options for proof techniques are the following:  direct, contrapositive, contradiction, cases, induction.

	For the second bullet you should be able to state something like ``both the hypothesis and conclusion are stated negatively so I would use proof by contrapositive to make them positive statements".

	In the third bullet you need to be detailed - for a proof by cases, what cases would you use? For a proof by induction, what steps would you use (and what's $P(k)$?)? In each case you need to be as specific as possible - do not say ``I would assume the negation", say what the negation actually is.

	\vfill

\item {\bf Proof Section} \emph{ There will be 2 proofs on the exam.} One of them will be from the following list:
\begin{enumerate}
\item For each integer $a$, if $3\mid a^2$ then $3\mid a$.
\item For each $n\in\N$, $5\mid n^5 + 4n$. (You may use the following lemma without proof:
	\[ (k+1)^5 = k^5+5k^4+10k^3+10k^2+5k+1.\]
\item For all real numbers $x$ and $y$, if $x$ is rational and $y$ is irrational then $x+y$ is irrational.
\end{enumerate}
You may collaborate on these proofs \emph{before} the exam is posted, but no collaboration is allowed once the exam is posted. You can also ask me about them, again \emph{before} the exam is posted. Recall, you should not copy answers, share any electronic files, or just tell someone how to do the proof.\\

\noindent The other theorem you'll be asked to prove will be given to you on the exam.\\

\noindent \emph{ For both proofs you will need to write according to our writing guidelines.}
\vfill
\end{enumerate}

\newpage

\section{Revisions}

The exams will be graded by the end of the day Friday, April 10, with feedback and grades posted on Blackboard.
\noindent To revise your exam you should, on separate paper,
\begin{itemize}
\item Redo each question from each section you would like to revise.
\item Write 1-2 sentences explaining the mistake that was made on the exam.
\item Sign up for an appointment for the week of April 13 (I will post the sign up on Blackboard after the exams are graded).
\item Send me (at keoulaur@gvsu.edu) a PDF of your revised answers at least 24 hours before your appointment.
\end{itemize}
The following are the policies for the revisions, some of which are \textbf{different than last time} so read carefully:
\begin{itemize}
\item You may collaborate on your revisions with anyone you wish to in addition to using your your notes, text, and Blackboard (no other internet sources though).
\item While you are allowed to collaborate, do this in a way that improves your understanding. I will ask additional questions about your answers as well as related, but different problems to test your understanding.
\item Your grades on the revised portion replace the original exam score.
\end{itemize}

\vfill

\section{How to Study}

While you are allowed to use your book and your notes on the exam, it's still a good idea to prepare for the exam. Here are some recommendations for how to study:
\begin{itemize}
\item Work on the given proofs for Section 4 before the exam - take advantage of being able to talk through those proofs with a classmate.
\item Organize your notes! Make a summary sheet and focus on connections between topics using class worksheets, preview activities, synthesis activities, and mastery quizzes
\item Make a list of important definitions and notation. See the lists in each of the sections for what you should know. Though math is not about memorization, it certainly helps to know and understand your definitions when trying to do proofs.
\item Go through the self quiz questions on Blackboard. Look through your notes for ones you can not answer.
\item Practice!  Look at the extra practice questions on Blackboard, try synthesis activities again (without looking at your solutions), and do exercises on worksheets.  Use the book to find extra exercises on things you are struggling with.
\item Complete your table of proof techniques.
\item Write the test! Write yourself a practice exam that you think I would write.  Then take the practice exam.  Feel free to share this with me and I will tell you if you are forgetting big ideas.
\end{itemize}

\vfill
\end{document}


%=========================================================================

%\chapter{User's Guide for \PLAUT} \label{app:userGuide}

``\PLAUT'' is a graphic tool for AUTO data visualization. Here we
explain how to
view AUTO data sets with \PLAUT. An AUTO data set contains a solution file, ``s.foo'',
a bifurcation file, ``b.foo'', and a diagnostic file, ``d.foo''. Here ``foo'' denotes a user-chosen data set name.
This user's guide includes the following information:
\begin{enumerate}
    \item A description of the \PLAUT~ window system.
    \item A list of \PLAUT~ configuration options.
    \item An example of using \PLAUT.
\end{enumerate}

\section{Quick start}

\subsection{Starting and stopping \PLAUT }

\subsubsection{Starting}

The starting command for \PLAUT~ is: ``plaut04''. A short Unix command
is also provided as ``@pl''. In the Python CLUI, one can start \PLAUT
~by typing ``plot3()'', ``p3()'', or ``commandPlotter3D()''.

This command can have no argument, one argument, or two arguments.

If no argument is provided, then the system uses the AUTO default data files,
fort.7, fort.8, and fort.9, as inputs.

If one argument is given, it must be the name of the data set which we want
to view. This data set should be in the current directory.

When two arguments are given,
the first is always the path to the data set, and the second is the data set name.

Note that the AUTO data set name does not mean the full name of an AUTO file. It refers to
the postfix of AUTO data files. For example, if we have the AUTO
data files: ``s.H1'', ``b.H1'', and ``d.H1'', the AUTO data file name is ``H1''.

\subsubsection{Stopping}

One can exit the system by
clicking the cross at the top-right corner of the window or from the ``File'' menu of the system.
\begin{comment}
\begin{figure}[!htmb]
	\captionstyle{center}
\centering
\scalebox{.50}{\includegraphics {./include/exit.pdf}}
%\makebox[\textwidth]{\framebox[5cm]{\rule{0pt}{5cm}}}
\caption{Exit the System} \label{fig:exitSys}
\end{figure}
\end{comment}

\subsection{Changing the ``Type''}

Often one will frequently change between the solution diagram and the bifurcation diagram.
The ``Type'' menu helps to complete this change. This menu includes two
items, ``Solution'', and ``Bifurcation''. There is a marker beside the current
diagram. For example, if the current diagram is the solution diagram,
but we want to change to the bifurcation diagram,
we can do so by clicking ``Type $\to$ Bifurcation'' to switch to the
bifurcation diagram.

\begin{figure}[!htmb]
    \begin{minipage}[b]{0.5\textwidth}
        \begin{center}
        \includegraphics {./include/typeMenu.pdf}
        \caption{The Type Menu} \label{fig:tpyeMenu}
	\end{center}
    \end{minipage}%
    %\hspace{0.0\textwidth}%
    \begin{minipage}[b]{0.5\textwidth}
        \begin{center}
        \includegraphics {./include/styleMenuNew.pdf}
        \caption{The Style Menu} \label{fig:styleMenu}
	\end{center}
    \end{minipage}
\end{figure}

\subsection{Changing the ``Style''}

\PLAUT~ provides four ways to draw the graphics, \textit{i.e.}, using
curves, tubes, points, or as a surface. One can select the style from
the ``Style'' menu. The ``Style'' menu is shown in Figure \ref{fig:styleMenu}.

\subsection{Coordinate axes}

Figure \ref{fig:coordMenu} shows the selections of the ``Coord'' menu.
One may use this menu to select to show or not to show
coordinate axes, and the type of coordinate axes, in the graphics.

\subsection{Options}

The ``Options'' Menu provides functions to add or remove widgets from the graphics.
It also allows to start/stop solution or orbit animation.
The ``normalize data'' normalizes the raw data to [0,1].
``Preference'' lets  us set preferences for the GUI (see Figure \ref{fig:optionMenu}).
\begin{figure}[!htmb]
	\centering
    \begin{minipage}[b]{0.5\textwidth}
        \centering
        \includegraphics {./include/drawCoordMenu.pdf}
        \caption{The Draw-Coordinate-Axes Menu} \label{fig:coordMenu}
    \end{minipage}%
    %\hspace{0.2\textwidth}%
    \begin{minipage}[b]{0.5\textwidth}
        \centering
        \includegraphics {./include/optionMenu.pdf}
    	\caption{The Options Menu} \label{fig:optionMenu}
    \end{minipage}
\end{figure}

\subsection{CR3BP animation}

The ``Center'' Menu allows to animate the motion of the three bodies in different
coordinate systems. We can animate the motion in a large-primary-centered inertial
coordinate system, or in a small-primary-centered inertial system, or in the bary-centered
inertial system. Figure \ref{fig:centerMenu} displays the layout of the ``Center'' menu.

\begin{figure}[!htmb]
\centering
    \begin{minipage}[b]{0.5\textwidth}
        \centering
        \includegraphics {./include/centerMenu.pdf}
        \caption{The Center Menu} \label{fig:centerMenu}
    \end{minipage}%
    %\hspace{0.2\textwidth}%
    \begin{minipage}[b]{0.5\textwidth}
        \centering
        \includegraphics {./include/helpMenu.pdf}
        \caption{The Help Menu} \label{fig:helpMenu}
    \end{minipage}
\end{figure}

\subsection{Help}

The ``Help'' menu provides an on-line help on how to use \PLAUT.

\subsection{Picking a point in the diagram}

The picking operation is useful when we want to know data corresponding to a certain
point in the diagram. In order to execute a picking operation, we should follow these steps.
\begin{itemize}
	\item Click the arrow icon to change the mouse to picking state.
    \item Move the mouse to the point of interest.
	\item Click the left button of the mouse to pick the point.
\end{itemize}

Once a point has been picked, a new window is popped up. In this new window, the Floquet
multipliers of the point are shown in an x-y plane.
Black crosses in the diagram indicate the Floquet Multipliers.
The solution, and the values of the corresponding Floquet Multipliers, are given in the lower part of the
window. A unit circle is drawn in the diagram.
Figure \ref{fig:flq} is an example of the picking operation.
From this diagram, we can see that two Floquet Multipliers
are outside the unit circle, two are on the unit circle, and the other two are inside the unit circle.

\begin{figure}[!htmb]
\centering
\scalebox{.60}{\includegraphics {./include/floquet.pdf}}
%\makebox[\textwidth]{\framebox[5cm]{\rule{0pt}{5cm}}}
\caption{Picking a point }
\label{fig:flq}
\end{figure}

\subsection{Choosing the variables}

\begin{figure}[!htmb]
\centering
\scalebox{.60}{\includegraphics {./include/menubar.pdf}}
%\makebox[\textwidth]{\framebox[5cm]{\rule{0pt}{5cm}}}
\caption{Menu-bar layout}
\label{fig:mnbar}
\end{figure}

AUTO can generate large amounts of data. The CR3BP, for example, has 6 variables, \textit{i.e.}, $x,y,
z, x', y', z'$, and time. One can choose to draw any combination of these variables in 2
or 3 dimensions using \PLAUT. On the list bar,
we can see three {dropdown lists} with label ``X'', ``Y'', and ``Z'' (See Figure~\ref{fig:mnbar}).
Each of these three lists has the exact number of choices, namely, the number of variables of the system plus one.
In our case, these lists have 7 choices, which are represented by the integers 0 to 6.
0 represents time. 1 to 6 stand for $x, y, z, x', y'$, and $z'$, respectively.
``1'' is selected for ``X'', which indicates that $x$ is drawn on the X-axis.
``2'' is selected for ``Y'',  which indicates that $y$ is represented on the Y-axis.
``3'' is selected for ``Z'',  which indicates that $z$ is represented on the Z-axis.

\begin{figure}[!htmb]
\centering
\scalebox{.50}{\includegraphics {./include/2component.pdf}}
%\makebox[\textwidth]{\framebox[5cm]{\rule{0pt}{5cm}}}
\caption{Displaying multiple components}
\label{fig:twoPairs}
\end{figure}

We can also show multiple combinations at the same time. For example, if we want
to show x-y-z and x'-y'-z' in the same diagram, we can input $1,4$ in the ``X'' \textrm{dropdown list} to
select $x$ and $x'$ being drawn on the X-axis, input $2,5$ in the ``Y'' list to show $y$ and $y'$ on the Y-axis,
and input $3,6$ in the ``Z'' \textrm{dropdown list} to draw $z$ and $z'$ on the Z-Axis. Note that after finishing
the input in the \textrm{dropdown list} box, we must type ``ENTER'' for
the input to be accepted by the system. Figure \ref{fig:twoPairs} shows the results of the above
choices. The combination is flexible. For example, if X is $1$, Y is $3, 5$, and Z is $4, 5, 6$,
the system will automatically reorganize them to $1-3-4$, $1-5-5$, $1-3-6$ and show the results.
If X is $1, 5$,  Y is $2$, and Z is $3, 4$, the system reorganizes them to $1-2-3$, $5-2-4$.

Different components are drawn with different colors from blue to red.

The default values can be set in the resource file. If no resource file exists, then the system
will use ``1'' for X-axis, ``2'' for Y-axis, and ``3''for Z-axis for both the solution and the bifurcation
diagrams.

\subsection{Choosing labels}

From the Label list, we can choose the label of the solution to be drawn. If ``ALL'' is chosen, all
solutions are shown in the diagram. If ``NONE'' is chosen, none of the solutions is shown.
``HALF'' shows the solutions with odd labels and special solutions only. ``SPEC'' lets the system
show the special solutions only.
We can also show selected solutions by inputting their labels in the list
box separated by commas.
For example, typing 1, 10, 15, 20 will lead the system to show only the solutions with label 1, 10, 15 and 20.

We can set the default value for this list in the \PLAUT~resource file.

\subsection{Coloring}

Many coloring methods are provided. They can be classified into three groups. The first group
is coloring by variables.
This group provides as many choices as the number of variables of a problem plus
1 for the time.
The second group is coloring by parameters. These parameters are defined by the AUTO user.
in the AUTO constants file.
There are as many choices as the number of parameters defined in the AUTO constants file.
The third group includes ``TYPE'', type of solution,
``PONT'', point number,
``BRAN'', the branch to which the solution belongs,
and ``LABL'', label of the solution.
Different coloring methods cannot be used at the same time.
Figure \ref{fig:clrMethod} shows the difference between coloring by type and coloring by label.
From Figure \ref{fig:clrMethod}(a), we can see that there is only one
branching orbit in this family, which is shown in cyan.
In Figure~\ref{fig:clrMethod}(b), the start solution is colored in blue, and the last solution is colored in red.
When using time to color the diagram, 0 is set to blue, while 1 is set to red.
\begin{figure}[!htmb]
    \subfigure[Coloring by ``Type'']{
    \label{fig:clrType}
    \begin{minipage}[b]{0.32\textwidth}
        \centering
        \includegraphics[width=5.0cm, height=5.0cm] {./include/clrTyMu0.pdf}
    \end{minipage}}%
    \subfigure[Coloring by ``Label'']{
    \label{fig:clrLabel}
    \begin{minipage}[b]{0.32\textwidth}
        \centering
        \includegraphics[width=5.0cm, height=5.0cm]{./include/clrLBMu0.pdf}
    \end{minipage}}%
    \subfigure[Coloring by ``Time'']{
    \label{fig:clrTime}
    \begin{minipage}[b]{0.32\textwidth}
        \centering
        \includegraphics[width=5.0cm, height=5.0cm]{./include/clrTimeMu0.pdf}
    \end{minipage}}
    \caption{Coloring} \label{fig:clrMethod}
\end{figure}

We can set the default value in the \PLAUT~resource file.

\subsection{Number of periods to be animated}

Generally only one period is animated when we animate the solution in the inertial frame.
However, the SpinBox allows us to change the default value.
 This is a specially designed function for the CR3BP.
It is useful when  we animate the motion in the three bodies in the inertial frame.

\subsection{Changing the line/tube thickness}

The ``Line Thickness'' spinbox allows us to increase or decrease the line/tube thickness
in the diagram.  The \PLAUT~ resource file also provides a way to change the default values of the
line/tube thickness.

\subsection{Changing the animation speed}

The ``Sat'' and ``Orbit'' scale bar allow us to change the animation speed.
Their Maximum and Minimum value can be set in the resource file.

\subsection{Changing the background picture}

A user can set the background with his favorite picture.
To do this, a user should copy the picture to the directory ``\$AUTO\_DIR/plaut04/widgets'',
and then change the name of the file to ``background.rgb''.

\section{Setting up the resource file}

The \PLAUT~resource file sets default values for
almost all controls of \PLAUT.
%Generally when we solve a problem, we want
%to put the solutions in the same directory.
%For the same problem, what a user is interested in is almost the same.
\PLAUT~allows us to write our own resources files and put them in the same directory as the AUTO data files.
\PLAUT~first looks for the resource file in the current directory.
If it cannot find a resource file there, then it will try to use the one installed
in the AUTO root directory. If both these searches fail, then the internal
default values will be used.

In order to write a usable resource file, one should follow the following rules:
\begin{enumerate}
\item Comment lines start with ``\#''. Comments may take as many lines as desired.
\item Between the ``variable name'' and the default value, we must use
``='' to tell the system that the left side is the ``variable name'', and
the right side is its corresponding default value.
\item If a ``variable'' has aggregate values, a comma ``,'' must be used between
two values.
\item The line type is set using 4-digit hexadecimals, starting with ``0x''. Its values can
range from $0$ (invisible) to ``0xffff'' (solid). The system default is ``0xffff'' for stable
solutions, and ``0x3333'' for unstable ones.
The line pattern is determined by the number of $1$s and $0$s when the hexadecimal
is converted to a $16$-bit binary. A ``$1$'' indicates that the drawing occurs, and ``$0$'' that
it does not, on a pixel by pixel basis. For example, the pattern ``0xAAAA'',
in binary is $0000100010001000$, and \PLAUT~interprets this as drawing
3 bits off, 1 bit on, 3 bits off, 1 bit on, 3 bits off, 1 bit on and finally 4 bits off.
The pattern is read backward because the low order bits are used first.
\item Some variables can only be set to ``Yes'' or ``No''. They cannot be assigned other values.
\item No ``variable name'' should be  modified.
\end{enumerate}

It is strongly recommended that the default resource file is used as a template
when writing a custom resource file.

Below is a copy of the default resource file.
{\footnotesize
\begin{verbatim}
#version 0.0

# Line colors are represented by RGB values from 0 to 1.0.
# DEFAULT color is also used when animationLabel == 0, i.e.,
# when showing all solutions and animating the solution change.
# Point Type    RED  GREEN  BLUE PATTERN
DEFAULT       = 1.0,  1.0,  1.0, 0xffff
BP ALG        = 1.0,  0.0,  0.0, 0xffff
LP ALG        = 0.0,  1.0,  0.0, 0xffff
HB            = 0.0,  0.0,  1.0, 0xffff
UZ4           = 1.0,  1.0,  0.0, 0xffff
UZ-4          = 0.5,  0.5,  0.0, 0xffff
LP DIF        = 0.0,  0.0,  0.5, 0xffff
BP DIF        = 0.0,  0.5,  0.5, 0xffff
PD            = 1.0,  0.0,  1.0, 0xffff
TR            = 0.0,  1.0,  1.0, 0xffff
EP            = 0.3,  0.0,  0.3, 0xffff
MX            = 0.6,  0.0,  0.6, 0xffff
OTHERS        = 1.0,  1.0,  1.0, 0xffff

# Initialize the line pattern for showing stability:
UNSTABLE LINE PATTERN = 0xffff
STABLE LINE PATTERN   = 0xffff

# Initialize the default options:
Draw Reference Plane  = No
Draw Reference Sphere = No
Orbit Animation       = No
Satellite Animation   = No
Draw Primaries        = No
Draw Libration Points = No
Normalize Data        = No
Draw Labels           = No
Show Label Numbers    = No
Draw Background       = No
Draw Legend           = No

# Initialize the default coordinate axes:
#  0 --- None,
#  1 --- at origin
#  2 --- at left and behind
#  3 --- at left and ahead
#  4 --- always at origin
Coordinate Type = 3

# Draw Scale on the Aexs
Draw Scale = Yes

#  Initialize the default graph type:
#  0 --- Solution (fort.8)
#  1 --- Bifurcation (fort.7)
Graph Type    = 0

# Initialize the default graph style:
#  0 --- LINES,
#  1 --- TUBES,
#  2 --- SURFACE
Graph Style  =  0

# Set the window width and height:
Window Width        = 1000
Window Height       = 1000

# Set X, Y, Z axes for the solution diagram:
# 0 is Time for X,Y,Z.
X Axis Solution             = 1
Y Axis Solution             = 2
Z Axis Solution             = 3

# Set X, Y, Z axes for the bifurcation diagram:
X Axis Bifurcation          = 4
Y Axis Bifurcation          = 5
Z Axis Bifurcation          = 6

#Labeled solutions:
Labels              = 0

# Set coloring method:
# -6 --- STABILITY
# -5 --- POINT
# -4 --- BRANCH
# -3 --- TYPE
# -2 --- LABEL
# -1 --- COMPONENT
# Otherwise, according to the data in the ith column of the solution file.
# It can only be set to an integer value.
#Coloring Method           = -3
# For the solution diagram:
Coloring Method Solution  = -3
# For the bifurcation diagram:
Coloring Method Bifurcation = -3
Number of Period Animated = 1

# Line Width Scaler adjusts the thickness of curves:
Line Width Scaler         = 1.0

# The AniLine Thickness Scaler sets the thickness of animated solution curves:
AniLine Thickness Scaler  = 3.0

# Background color:
Background Color  = 0.0,  0.0,   0.0

# Background transparency:
Background Transparency = 0.0

# Set the radius of the spheres used for labels:
# The normal size is 1.0.
# For smaller radius, use 0.xxx
# For bigger radius, use  X.XXX
Label Sphere Radius       =  1.0

# Disk Rotation
Disk Rotation = 1.0, 0.0, 0.0, 1.570796

# Disk Position
Disk Position = 0.0, 0.0, 0.0

# Disk Radius
Disk Radius = 1.0

# Disk Height
Disk Height = 0.001

# Disk Transparency [0, 1]
Disk Transparency = 0.7

# Read Disk From File
Disk From File = No

# Sphere Position
Sphere Position = 0.0, 0.0, 0.0

# Sphere Radius
Sphere Radius = 1.0

# Sphere Transparency [0, 1]
Sphere Transparency = 0.7

# Read Sphere From File
Sphere From File = No

# Axes color:
X Axis Color    = 1.0,  0.0,   0.0
Y Axis Color    = 0.0,  1.0,   0.0
Z Axis Color    = 0.0,  0.0,   1.0

# Color of the satellite, large primary, and small primary in animation:
satellite Color             = 1.0,  0.0,   0.0
large primary Color         = 0.0,  1.0,   0.0
large primary tail Color    = 0.0,  1.0,   1.0
small primary Color         = 0.0,  0.0,   1.0
small primary tail Color    = 0.5,  0.5,   0.0

# Surface color:
Surface Color         =  0.0,  1.0,  0.0

# Stable solution color:
Stable Solution Color = 0.0, 0.0, 1.0

# Stable solution color:
Unstable Solution Color = 1.0, 0.0, 0.0

# Set the radius of the satellite, large primary, and small primary:
# The normal size is 1.0.
# For smaller radius, use 0.xxx
# For bigger radius, use  X.XXX
Satellite Radius        = 1.0
Large Primary Radius    = 1.0
Small Primary Radius    = 1.0
Libration Point Size    = 1.0

# Set the initial, maximum and minimum satellite animation speed:
Sat Animation Speed = 100
Sat Max Animation Speed = 100
Sat Min Animation Speed = 0

# Set the initial, maximum and minimum orbit-change animation speed:
Orbit Animation Speed = 50
Orbit Max Animation Speed = 100
Orbit Min Animation Speed = 0

# Set the active AUTO parameter indices:
parameter ID = 10

# Choose 3D or 2D graph:
#3D  = Yes

# Choose 3D or 2D graph for the bifurcation diagram:
3DBif = Yes

# Choose 3D or 2D graph for the solution diagram:
3DSol = Yes

\end{verbatim}
}

\section{Example}

In this example, we want to view a CR3BP data set.
We want the diagram to show the ``$x$'' component on the X-axis, ``$y$'' component on the Y-axis, and ``$z$'' component on the Z-axis
for the solution diagram.
%and column 4 of the AUTO b file as the X-axis, column 5
%on the Y-axis, and column 6 on the Z-axis, for the bifurcation diagram.
In the CR3BP, we use the parameters ``1 2 3 10 21 22 23'' in the AUTO
calculations, and we also want to be able to use these to color the diagram, so we set the ``parameter indices''.

Other preferences include
\begin{itemize}
\item The diagram is drawn using Tubes.
\item Coordinate axes are not drawn.
\item No animation.
\item Reference plane, libration points, and primaries are drawn.
\item All labels are shown.
\item Data is not normalized.
\end{itemize}

The settings are the settings in the resource file are then as follows:
{\footnotesize
\begin{verbatim}
#  Initialize the default options
Draw Reference Plane  = Yes
Orbit Animation       = No
Satellite Animation   = No
Draw Primaries        = Yes
Draw Libration Points = Yes
Normalize Data        = No
Draw Background       = No

#  Initialize the default graph type
#  0 --- Solution(fort.8)  1 --- Bifurcation(fort.7)
Graph Type    = 0

# initialize the default graph style
#  0 --- LINES,  1 --- TUBES, 2 ---- SURFACE  3--- nurbs curve
graph Style  =  1

# set X, Y, Z, and Label
# 0 is Time for X,Y,Z. 0 is "All" for Label

Solution X Axis              = 1
Solution Y Axis              = 2
Solution Z Axis              = 3

Labels                       = 0

#set the parameter indices
parameter ID = 1,  2,  3, 10,  15, 21, 22,  23
\end{verbatim}
}

Based on the above settings,
the solution diagram for the CR3BP family \L{1} for $\mu=0.01215$ appears in Figure \ref{fig:AppEx1}.

\begin{comment}
\begin{figure}[!htmb]
	\centering
	%\includegraphics[width=10cm] {./include/ex1Mu0.01215V1.pdf}
	%\includegraphics[width=10cm] {./include/emV4Surface.pdf}
	\includegraphics[width=10cm] {./include/emL1Sol.pdf}
%\makebox[\textwidth]{\framebox[5cm]{\rule{0pt}{5cm}}}
	\caption{Example}
\label{fig:AppEx1}
\end{figure}
\end{comment}

\begin{figure}[!htmb]
        \centering
		\includegraphics[width=10cm, height=10cm] {./include/emL1Sol.pdf}
        \caption{Example} \label{fig:AppEx1}
\end{figure}


\documentclass[paper=a4, fontsize=11pt]{scrartcl}
\usepackage{amsmath, amsfonts, amssymb}

\title{Paraphrase of  a paragraph in "PREMIX: A Program for Modeling Steady, Laminar, One-Dimensional Premixed Flames"}
\author{Yu Cang \ \ 018370210001}
\date{2019-03-08}

\begin{document}

\maketitle

\section{Original paragraph}
	The numerical solution procedure begins by making finite difference approximations to reducethe boundary value problem to a system of algebraic equations. The initial approximations are usually ona very coarse mesh that may have as few as five or six points. After obtaining a solution on the coarsemesh, new mesh points are added in regions where the solution or its gradients change rapidly.  Weobtain an initial guess for the solution on the finer mesh by interpolating the coarse mesh solution. Thisprocedure continues until no new mesh points are needed to resolve the solution to the degree specifiedby the user.  This continuation from coarse to fine meshes has several important benefits that areexplained later in this section.  We attempt to solve the system of algebraic equations by the dampedmodified Newton algorithm. However, if the Newton algorithm fails to converge, the solution estimate isconditioned by a time integration. This provides a new starting point for the Newton algorithm that iscloser to the solution, and thus more likely to be in the domain of convergence for Newton’s method. As the mesh becomes finer we normally find that the estimate interpolated from the previous mesh is withinthe domain of convergence of Newton’s method. This point is key to the solution strategy.

\section{My paraphrase}
	To solve the Boundary Value Problem(BVP), the governing equations are approximated by Finite Difference Method(FDM) and the a system of algebraic equations are to be solved.\newline
	The numerical procedure starts from a coarse mesh so that the converged solution is more likely to be achieved. Then it seeks better solution on a finer mesh and the corresponding initial values are calculated from interpolation of previous results.\newline
	A hybrid scheme is adopted to solve these algebraic equations. First, the solver tries the damped Newton method, which has faster convergence speed, but unstable. Once the damped Newton method fails, it switches to the time-stepping method which is stable but  slow to converge. As the mesh becomes finer and finer, it's normally expected that the converged solution will be achived.

\end{document}


\documentclass{article}

\usepackage[main=english,vietnamese]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[sexy]{evan}
\usepackage{matchsticks}
\usepackage{wrapfig}
\usepackage{listings}

\title{The Power of Mathematical Reasoning - Part One}
\author{Nghia Doan \& Catherine Doan}
\date{\today}

\begin{document}

\maketitle

In this article, we discuss mathematical reasoning by a number of examples.

\section*{It is so obvious, $\ldots$ or is it?}

Let's start with a few classic examples.
These problems are simple, but don't let them fool you.

\begin{example*}[Who lied?]
    \label{example:pi-2022-4-p1}
    Two American Indians were sitting on a log - a big Indian and a little Indian.
    The big Indian was smoking and the little Indian played with a toy.
    The little Indian was the son of the big Indian,
    but the big Indian was not the father of the little Indian.

    How is it possible?
\end{example*}

\begin{soln}[\nameref{example:pi-2022-4-p1}]
    The fact that the big Indian was smoking does not mean that the big Indian was a man.
    Now, the little Indian was the son of the big Indian, and if the big Indian was not his father
    then the big Indian was \framebox{his mother}.
\end{soln}

\begin{example*}[Whose picture I am looking at?]
    \label{example:pi-2022-4-p2}
    A man was looking at a portrait. Someone asked him "Whose picture are you looking at?"
    He replied: "Brothers and sisters have I none, but this man's father is my father's son."
    (\textit{This man's father means, of course, the father of the man in the picture.})

    Whose picture was the man looking at?
\end{example*}

\begin{soln}[\nameref{example:pi-2022-4-p2}]
    The man made a statement that contains two parts, each a seperate statement.
    The first one means that he had neither brothers nor sisters.
    The second one means that the father in his sentence is a son of his father, meaning one of his brothers or himself.
    Because he has no brother, therefore the father is himself.
    Thus, he is the father of the man in the paintng and the man in the painting is \framebox{his son.}
\end{soln}

\begin{example*}[How could she set the clock?]
    \label{example:pi-2022-4-p3}
    The clock in Lilian's house has stopped. Lilian wanted to set the correct time,
    but she was unable to do that, since there is the only one clock in the house.
    That evening, she went to visit her friend, Bianca,
    who has an excellent wall clock that always shows correct time.
    When Lilian came home after the visit, she was able to set the correct time on her clock.

    How did she do it?
\end{example*}

\begin{soln} \nameref{example:pi-2022-4-p3}
    Lilian checked the time displayed on her clock twice: \textit{when she left the house} and \textit{when she came back.}
    The difference of these two will be equal to the total time when she was away,
    which is \textit{twice the length of the trip in time} between the two houses.
    By dividing by two, she had \textit{the time needed for a trip}.

    Now, lets assume that she walked to Bianca house, took a look at the clock and promptly left.
    This way, Lilian knew \textit{what time it was she left Bianca's house}.
    By adding the time needed for a trip to that she knew what time it was and then set the clock.
\end{soln}

\begin{example*}[Defeat King Haggard]
    \label{example:pi-2022-4-p4}
    There are ten wells in the far, far away Dark Forest.
    The wells are marked by signs with number from 1 to 10.
    The water from these wells look and taste like normal water;
    however, they were all poisoned.
    The only known antidote is water from a higher-numbered well.
    (\textit{For example, if you had a sip of water from the well number 6,
    you could save yourself by drinking from the well 7, 8, 9, or 10.})

    Unfortunately, there is no antidote for the water from the $10^{\text{th}}$ well.
    While the first nine wells can be easily visited,
    the $10^{\text{th}}$ well is inside the castle of King Haggard, the ruler of the Dark Forest.

    Prince Martin challenged the King to a duel:
    \textit{Each participant should drink a cup of water offered by the opponent.}
    Of course, King Haggard agreed. His plan was to use his $10^{\text{th}}$ well;
    because the water from this well help him survive any drink offered by Prince Martin,
    and it will definitely kill the prince.

    The duel took place as planned. Each participant drank the cup of water offered by the opponent.
    Everybody surprised and delighted to see that Prince Martin lived and King Haggard died.

    How did this happen?
\end{example*}

\begin{soln} \nameref{example:pi-2022-4-p4}
    Prince Martin \textit{gave King Haggard a drink of clear water.}
    Thus instead of curing him, the water from the $10^{\text{th}}$ well he drank then poisoned him.
    Prince Martin, before the duel, drank some water from any of the wells with a number smaller than $10.$
    Therefore \textit{Haggard's cup of water from the $10^{\text{th}}$ well actually cured Prince Martin.}
\end{soln}

\section*{If this is true then $\ldots$, if this is false then $\ldots$}

\begin{example*}[Who is younger?]
    \label{example:pi-2022-4-p7}
    A brother and a sister were once asked who was younger. "I am older," said the brother.
    "I am younger," said the sister.

    Now, if you knew that \textit{at least one of them lied,}
    then who was younger?
\end{example*}

There are two different approaches to this problem.

\begin{soln}[\nameref{example:pi-2022-4-p7}]
    The first one is to \textit{evaluate all possible truths} and see which one matches the given conditions.
    There are two cases: the brother was younger, or the sister was younger.

    If the brother was younger, then the brother lied, and so did the sister.
    If the sister was younger, then both of them told the truth, which would not be possible.

    Thus, \framebox{the brother was younger, and they both lied.}
\end{soln}

\begin{soln}[\nameref{example:pi-2022-4-p7}]
    Now, the second approach is to \textit{evaluate all possible assumptions},
    in this case whether the brother (and then the sister) told the truth.

    If the brother told the truth, then the sister did too, then
    this contradicts the condition that at least one of them lied.
    If the brother lied, then the sister lied too, so
    this satisfies the condition, and therefore it is the correct one.

    Thus, \framebox{the brother was younger, and they both lied.}
\end{soln}

\section*{Exercises}

\begin{exercise*}[Which one is correct?]
    \label{exercise:pi-2022-4-p5}
    Which phrase is correct: "the yolk \textit{is} white" or "the yolk \textit{are} white."?
\end{exercise*}

\begin{soln} \nameref{exercise:pi-2022-4-p5}
    Actually, the yolk is \textit{yellow.}
\end{soln}

\begin{exercise*}[How can they see each other?]
    \label{exercise:pi-2022-4-p6}
    Two camels were facing in the opposite direction.
    One was facing due east and the other one was facing due west.
    How can they manage to see each other, without walking, turning around, or even moving their heads?
\end{exercise*}

\begin{soln} \nameref{exercise:pi-2022-4-p6}
    The two camels were \textit{facing each other} the whole time, hence facing in opposite directions.
\end{soln}

\end{document}


%
% body.tex
%
% Copyright © 2020 Libao Jin <jinlibao@outlook.com>
% Distributed under terms of the MIT license.
%
The deadline will be strictly enforced. If you do not submit in time there will be a $20\%$ penalty for each day you're late. If you do not submit in time there will be a $20\%$ pennalty upfront plus another $20\%$ for  each day you're late. Remember that you are allowed to work in teams of two on this assignment. You are encouraged to prepare your work in \LaTeX{}; a template will be provided to help you put it all together. If you choose  to submit a hard copy, you may submit only one copy for a team, indicating the names of both contributors. Online submission is encouraged, however, in that case both members of a team should submit the PDF file containing  their work and showing both their names.

\emph{All plots generated in this homework should have a title, legend, and labeled $x$ and $y$-axes.} \\[15pt]

\textbf{Instruction}

\begin{enumerate}[label={\arabic*.}]
  \item Go to \url{https://www.overleaf.com} and sign in (required).
  \item Click \emph{Menu} (up left corner), then \emph{Copy Project}.
  \item Go to \verb|LaTeX/meta.tex| (the file \verb|meta.tex| under the folder \verb|LaTeX|) to change the section and your name, e.g.,
    \begin{itemize}
      % \item change title to \verb|\title{MATH 3340-01 Scientific Computing Homework 6}|
      \item change author to \verb|\author{Albert Einstein \& Carl F. Gauss}|
    \end{itemize}
  \item For Problem 1 and 4, you are encouraged to type solutions in \LaTeX{}. But if you want to write it on the printout, make sure your scanned work is \emph{clear} enough, and compile all solutions \emph{in order}, i.e., 1, 2, 3, 4, in a single PDF (failure to do so will lead to points deduction).
  \item For Problem 2 and 3, you need to write function/script files, store results to output files, and save graphs to figure files. Here are suggested names for function files, script files, output files, and figure files:
    \begin{table}[!hbtp]
      \centering
      % \caption{caption}
      % \label{tab:label}
      \begin{tabular}{cllll}
        \toprule
        Problem & Function File         & Script File     & Output File & Figure File                                 \\
        \midrule
        2(a)    &                       & \verb|hw6_p2.m| &             &                                             \\
        2(b)    & \verb|cubic_spline.m| &                 &             &                                             \\
        2(c)    & \verb|lagrange.m|     &                 &             & \verb|hw6_p2.pdf|                           \\
        3       &                       & \verb|hw6_p3.m| &             & \verb|hw6_p3_1.pdf| \& \verb|hw6_p3_2.pdf|  \\
        \bottomrule
      \end{tabular}
    \end{table}

    Once finished, you need to upload these files to the folder \verb|src| on Overleaf. If you have different filenames, please update the filenames in \verb|\lstinputlisting{../src/your_script_name.m}| accordingly. You can code in the provided files in \href{https://libaoj.in/courses/2020s/MATH3340/Homework/6/hw6.zip}{hw6.zip}, and use the MATLAB script \verb|save_results.m| to generate the output files and store the graphs to \verb|.pdf| files automatically (the script filenames should be exactly same as listed above).
  \item Recompile, download and upload the generated PDF to WyoCourses.
  \item You may find \href{https://libaoj.in/files/LaTeX.Mathematical.Symbols.pdf}{\LaTeX{}.Mathematical.Symbols.pdf} and the second part of \href{https://libaoj.in/courses/2020s/MATH3341/slides/Math.3341.Lab.01.Slides.pdf}{Lab 01 Slides} and \href{https://libaoj.in/courses/2020s/MATH3341/slides/Math.3341.Lab.02.Slides.pdf}{Lab 02 Slides} helpful.
\end{enumerate}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Problem 1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Problem 1}%
\label{sec:problem_1}
This problem must be done by hand. Consider the following data set (Table \ref{tab:1data}).
\begin{table}[!hbtp]
  \centering
  \caption{Problem 1 Data Set}
  \label{tab:1data}
  \begin{tabular}{ccccc}
    \toprule
    $k$ & $0$ & $1$ & $2$ & $3$             \\
    \midrule
    $x_{k}$ & $1.0$ & $1.5$ & $1.9$ & $2.4$ \\
    $y_{k}$ & $1.1$ & $1.7$ & $2.1$ & $1.8$ \\
    \bottomrule
  \end{tabular}
\end{table}

Using these data points, compute the cubic spline interpolant for the function $y = f(x)$. That is,  computer the coefficients $\{a_{j}, b_{j}, c_{j}, d_{j}\}$ for $j = 0, 1, 2$. To do so, you will need to set up the system of four equations in four unknowns for  the coefficients $c_{j}, j = 0, 1, 2, 3$. Use natural boundary conditions to reduce this system to only two equations for $c_{1}$ and $c_{2}$. Then determine the other coefficients using the relations for $b_{j}$ and $d_{j}$. Finally, once you have all the coefficients, evaluate  the interpolant $S(x)$ at the two points $x = 1.3$ and $x = 1.7$. Perform all computations rounding to three digits after the decimal point.
\begin{solution}
  Results:
  \lstinputlisting[style=Plain]{../src/hw6_p1.txt}
  \lstinputlisting[style=MATLAB]{../src/hw6_p1.m}
\end{solution}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Problem 2
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Problem 2}%
\label{sec:problem_2}
Consider the test function
\begin{equation*}
  f(x) = \frac{1}{1 + 14 x^{2}}.
\end{equation*}
The task here is to approximate this function using the cubic spline piecewise interpolant with natural boundary conditions, and compare this interpolant with a polynomial with natural boundary conditions, and compare this interpolant with a polynomial interpolant using the same data set. This problem builds on top of the interpolation problem on the last homework. Aside from reusing the code you have developed in the last homework, you \emph{must} create a \emph{minimum} of three code files for this problem: two function files and one script file, described below.
\begin{enumerate}[label=(\alph*)]
  \item \label{enum:2a} Create a script file which defines the function $f(x)$, a set \verb|xplot| of $100$ equispaced points in $[-1, 1]$ that will be used for plotting, together with the values that the test function $f$ produces at these points. Also generate a data set \verb|xdata|, i.e., the nodes $x_{k}$ in our math notation, to be used for interpolating this function by computing the values $y_{k} = f(x_{k})$  where  $\{x_{k}\}$ is an equispaced set in $[-1, 1]$ with $-1 = x_{0} < x_{1} < \cdots < x_{n} = 1$. Use again $n = 9$ (i.e., $10$ nodes) like in the previous homework.
  \item \label{enum:2b} Write your own spline interpolation routine. At a minimum, this should involve a function which calculates the coefficients of the piecewise cubic spline polynomial and a function which evaluates the piecewise spline interpolant. Some of you may want to break the computation of the spline coefficients in several separate functions instead of having only one function perform the whole task. Note that the spline interpolant is a piecewise function and there may be several ways in which to evaluate and plot this function. Some very efficient methods can be devised, or blunt force may be used to locate the evaluation point in a particular patch.
  \item In your script file, you should call the functions you wrote for part \ref{enum:2b} together with those you created for polynomial interpolation in the  previous homework, then plot the spline interpolant $S(x)$ together with the original function $f(x)$ and the polynomial interpolant $p_{n}(x)$ based on the same set of data points. On the same plot, show the data set with a marker. For the global polynomial interpolant, just reuse the functions you created for homework 5 on this new test function. To plot, compute the values of all three functions (that is, the original test function, the cubic spline and the global polynomial) on the set of points \verb|xplot| you created in part \ref{enum:2a}. Your plot must have a title, legend, and labeled $x$ and $y$ axes.
\end{enumerate}
\emph{Note}: Results using the built-in MATLAB functions for spline interpolation will receive no credit. Nevertheless, you may find these functions helpful for verifying your results.
\begin{solution}
  \quad
  \begin{itemize}
    \item
      Function file \verb|lagrange.m|
      \lstinputlisting[style=MATLAB]{../src/lagrange.m}
      Function file \verb|cubic_spline.m|
      \lstinputlisting[style=MATLAB]{../src/cubic_spline.m}
    \item
      Script file \verb|hw6_p2.m|
      \lstinputlisting[style=MATLAB]{../src/hw6_p2.m}
      \newpage
    \item
      Figure files: \verb|hw6_p2.pdf| (Figure \ref{fig:p2}).
      \begin{figure}[!hbtp]
        \centering
        \includegraphics[width=0.75\linewidth]{../src/hw6_p2.pdf}
        \caption{Data Points, Cubic Spline Interpolant, and Polynomial Interpolant}%
        \label{fig:p2}
      \end{figure}
  \end{itemize}
\end{solution}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Problem 3
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Problem 3}%
\label{sec:problem_3}
Consider the function
\begin{equation*}
  f(x) = \frac{e^{x}}{1 + x^{2}}.
\end{equation*}
Evaluate the error in its first derivative $f'(0)$, computed using the central first derivative formula, for a step ranging from $\Delta x = 0.1$ to $\Delta x = 10^{-7}$; decrease the value of the step $\Delta x$ by  a factor of 10 (one order of magnitude) for each successive evaluation. Plot the error versus the step $\Delta x$ using a logarithmic scale on both axes. Repeat the same calculations for the second derivative $f''(0)$, also computed with the centered formula. You may find that for some values of $\Delta x$ the error is zero; when using a logarithmic scale, this may lead to trouble when plotting, since the logarithm of zero is not defined (MATLAB does not complain, but Octave may produce an error message). To avoid this problem, you can just set the error to the machine accuracy \verb|eps| whenever it is lower than \verb|eps|.
\begin{solution}
  \quad
  \begin{itemize}
    \item
      Function file \verb|central_difference.m|
      \lstinputlisting[style=MATLAB]{../src/central_difference.m}
    \item
      Script file \verb|hw6_p3.m|
      \lstinputlisting[style=MATLAB]{../src/hw6_p3.m}
      \newpage
    \item
      Figure files: \verb|hw6_p3_1.pdf| (Figure \ref{fig:p31}) and \verb|hw6_p3_2.pdf| (Figure \ref{fig:p32}).
      \begin{figure}[!hbtp]
        \centering
        \includegraphics[width=0.75\linewidth]{../src/hw6_p3_1.pdf}
        \includegraphics[width=0.75\linewidth]{../src/hw6_p3_3.pdf}
        \caption{Error vs. Step $\Delta x$ for First Derivative $f'(0)$}%
        \label{fig:p31}
      \end{figure}
      \begin{figure}[!hbtp]
        \centering
        \includegraphics[width=0.75\linewidth]{../src/hw6_p3_2.pdf}
        \includegraphics[width=0.75\linewidth]{../src/hw6_p3_4.pdf}
        \caption{Error vs. Step $\Delta x$ for Second Derivative $f''(0)$}%
        \label{fig:p32}
      \end{figure}
  \end{itemize}
\end{solution}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Problem 4
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Problem 4}%
\label{sec:problem_4}
Using the Taylor series method set up in class (see section 7.2, page 117 in the typed notes) find a formula that approximates the values for $f'(x)$ and $f''(x)$ with the highest accuracy possible using a linear combination (weighted sum) of the values:
\begin{equation*}
  f(x - 2h), \quad f(x - h), \quad f(x + 2h), \quad f(x + 3h),
\end{equation*}
where $h = \Delta x$ is the step size. Do this calculation by hand.
\begin{solution}
  Results:
  \lstinputlisting[style=Plain]{../src/hw6_p4.txt}
  \lstinputlisting[style=MATLAB]{../src/hw6_p4.m}
\end{solution}


\subsection{Methods}
\label{sec:methods}

\mysubsubsection{Quantitative data}
A set of standard statistical methods have been used in this work to share some light into our analysis, however as our sample size is extremely small ($n=24$), extra care is needed to confirm our analysis results.

\begin{description}
\item[Descriptive statistics], such as means or distributions of values, are one of the most often used tools in this work.
\item[Cross-tabulation ($\chi^2$)] is a method used to confirm if cross-tabulated data is distributed evenly or unevenly. Due to sample size, we have not used the standart $\chi^2$ test, rather we applied \textit{Fisher's exact test}, which unlike the $\chi^2$ test does not assume large enough pool of data. We however report this test as $\chi^2$ and related values in $\chi^2$ format for compatibility.
\item[Correlation] is used to explore detailed relationship between variables. When necessarily, such as in cases of Likert-scales, rank-correlation was used in the calculations
\item[Linear regression] was used to explore the relation of a set of (dependable) variables to one (in-dependant) variable. To counter problems of small sample size, we report only adjusted R$^2$, however we have not engaged in detailed residual analysis.
\end{description}

\noindent For the more analytic statistics, present a $p$-value, which indicates our trust in the examined phenomena. We have accepted values below the 10 \%-cut point as indicators of some level of trust\footnote{This level is usually accepted in social sciences.}, and indicate the exact value in detail, or just non-significance (n.s.) of the result. This said, results should be considered as indicators and are all worth further study with larger sample and refined hypotheses and questions.

\mysubsubsection{Qualitative data}
Even while there is several forms of qualitative methods and theories how to interepret that kind of data, our work applies the most often used \textit{content classification} approach, where content is read and re-read by the researchers and classified by their relevance to the research question. In our work certain quotes from the data are used to provide examples of the conclusions made from the qualitative data.


\documentclass[a4paper,12pt]{article}
%\documentclass[a4paper,12pt]{scrartcl}

\usepackage{xltxtra}

\input{../preamble.tex}

\usepackage{tikz}
\usetikzlibrary{shapes,backgrounds}

% \setromanfont[Mapping=tex-text]{Linux Libertine O}
% \setsansfont[Mapping=tex-text]{DejaVu Sans}
% \setmonofont[Mapping=tex-text]{DejaVu Sans Mono}

\title{Homework \#02: Compound probability}
\author{Isaac Ayala Lozano}
\date{2020-01-15}

\begin{document}
\maketitle

\def\firstcircle{(0,0) circle (1.5cm)}
\def\secondcircle{(0:2cm) circle (1.5cm)}
\def\thirdcircle{(45:2cm) circle (1.5cm)}

Let \emph A and \emph B be two events for a sample space \emph{S}. Proofs are presented for the compund probability of $A \cup B$ employing Venn diagrams for the general case and the particular case where A and B are mutually exclusive.

\section{General case}

The probability of $A \cup B$ is given by  $P(A \cup B) = P(A) + P(B) - P(A \cap B)$.
The probability of $A \cap B$ is subtracted because that subset is contained in both A and B ($A \cap B \subset A,  A \cap B \subset B$), hence added twice.
Thus the compound probability is obtained by adding the probability of A and B subtracted by the probability of $A \cap B$, as shown in figure 1.

\section{Particular case}

For the particular case where $A \cap B = \emptyset$, the probability of $A \cup B$ is equivalent to the sum of probabilities of A and B, subtracted by the probability of $A \cap B$ which is zero in this case:
$P(A \cup B) = P(A) + P(B) - P(A \cap B) = P(A) + P(B) - 0 = P (A) + P (B)$.

% \begin{figure}
% \centering
% \begin{tikzpicture}
%      \begin{scope}[shift={(3cm,-5cm)}, fill opacity=0.5]
%         \fill[red] \firstcircle;
%         \fill[green] \secondcircle;
%         \draw \firstcircle node[center] {$A$};
%         \draw \secondcircle node [center] {$B$};
%     \end{scope}
% \end{tikzpicture}
% \caption{Events A and B in the sample space S.}
% \label{fig: events}
% \end{figure}

 \begin{figure}[ht]
    \centering
    \import{./img/}{hw02-venn-diagrams.pdf_tex}
    \caption{Compound probability.}
    \label{fig: compound probability}
\end{figure}

\end{document}


\chapter{Processing the Captured Data}
This chapter is dedicated to the process of extracting critical data from the video files and the smartphone csv file. This process will take the raw captured data and transform it to values that we can feed into the Extended Kalman Filter. It is referred to in this work as preprocessing since the data is being processed before the filter.

\section{Processing the IMU Data}
The following flowcharts depicts the procedural processing of smartphone sensor and GPS data gathered from the chest mounted smartphone running the AndroSensor application. The following flow diagram shows the different steps in preprocessing.

\begin{figure}[!ht]
\captionsetup{width=0.8\linewidth, font=small}
\includegraphics[width=\linewidth]{figures/imuflow.png}
\caption{Diagram showing the progression and dependence of the major stages of sensor data processing in this project}
\label{fig:imuflow}
\end{figure}

From the diagram our raw input log file is a large unprocessed dataset captured by the smartphone with a logging rate of 100Hz. From this the critical data must be extracted and synchronized with the rest of the system. The data must also be manipulated to keep units constant and unify various frames of reference. By correctly preprocessing the data, the implementation of the EKF is simplified.

\subsection{Obtaining IMU Data}
Obtaining the raw sensor data was discussed in the previous chapter. The AndroSensor application was configured by specifying the units that all sensors must be logged in. The units of each sensor was selected as per the table below.

\begin{table}[!ht]
\centering
\captionsetup{width=0.8\linewidth, font=small}
\caption{Table showing the different units of the output AndroSensor file}
\label{Smartphone Data Units}
\begin{tabular}{ll}
Heading               & Units  \\
ACCELEROMETER       & $ m/s^2 $  \\
GRAVITY              & $ m/s^2 $ \\
LINEAR ACCELERATION  & $ m/s^2 $\\
GYROSCOPE            & $ rad/s $ \\
MAGNETIC FIELD       &  $  microTesla$\\
ATMOSPHERIC PRESSURE  &     $ Pascal$ \\
LOCATION Latitude     &    $ degrees $   \\
LOCATION Longitude    &    $ degrees $   \\
LOCATION Speed        &     $ m/s $  \\
LOCATION ORIENTATION  &     $ degrees $  \\
VOLUME				&		$ dB $
\end{tabular}
\end{table}

The importance of having uniform units is discussed later in this chapter. The above units have been chosen since they are SI units or the most relevant next possibility.

\subsection{Synchronizing IMU Data}
Previously the application used by \cite{bradstocks} created a beep tone when the logging process was started. This beep tone was recorded by the cameras and was used as a common point of synchronization. Some drawbacks were identified by using this method. The smartphone would start logging only after the beep had completed. this meant that the smartphone data had to be resynchronized to the camera data by further testing. Another shortcoming was that the beep tone was not loud enough to comfortably be detected by the rear cameras, causing difficulty in noisy environments.

The AndroSensor application can record the the magnitude of sound that the microphone is experiencing at a given time. Using this magnitude we can see at what time instance a spike in volume (caused by a simple clap of the hands) was logged. This sample can be a common point between the IMU and the cameras and can thus be used to synchronize the different hardware elements.

Upon further consideration a point of synchronization should be created before and after the testing period to ensure that the different data streams stay in sync. This meant that volume spike had to be made before and after each run.

\subsection{Preprocessing IMU Data}
All these variables have been recorded with respect the smartphone frame of reference. Since the smartphone was rigidly mounted to the body, a simple axis transformation could be completed to move the data onto the body frame of reference. This is further discussed in a following section.

Before we can input the sensor data directly to the EKF, we need to make some minor modifications to the data. This includes zeroing the positional data given by the GPS, since we assume our subject to start at position $ (0,0) $ in the inertial frame. To zero the the following formulae was applied.

$$  gps lat = ( gps lat -  gps lat_i)\times 110922 $$
$$  gps long = ( gps long -  gps long_i)\times 92423 $$

These algorithms subtracts the initial value of the GPS latitude and longitude from every value in the data vector and multiplies the difference by scalars to move the points to a NED frame of reference. These scalar values where obtained from \cite{gps}.

$$  gps vel x =  gps speed \times \cos( gps head) $$
$$  gps vel y =  gps speed \times \sin( gps head) $$

The above algorithms compute the x and y components from the GPS velocity vector by using the magnitude and heading logged from the sensor.

The accelerometer and gyroscope also contained some bias. This can be quantified by logging a large dataset while the smartphone is absolutely stationary and finding the average non-zero value of the individual sensors. Calculating the bias vectors we find them to be. For the accelerometer these values have been calculated as:

$$accelerometer X = -2.74252 \times 10^-5	m/s^2 $$
$$accelerometer Y = -2.61902 \times 10^-5	m/s^2 $$
$$accelerometer Z = 2.04709  \times 10^-5	m/s^2 $$

The values for the gyroscope has been calculated as:

$$gyroscope X = 5.46604 \times 10^-5	r/s $$
$$gyroscope Y = 1.29292 \times 10^-5	r/s $$
$$gyroscope Z = 2.87219 \times 10^-5	r/s $$

The logged data was modified to subtract these bias values.

\subsection{Exporting IMU Data}
The IMU data was finally exported as a final csv file and imported into MATLAB as a set of vectors. Each vector containing the samples of a specific data field. This allows for faster processing and access to the data.

The final step was to compute availability vectors for all the different data fields. This was done by creating a vector that contains a 1 if the sensor value has changed and a 0 if the value has not updated. Since many of the sensors on the smartphone do not update at 100Hz this was necessary to only input the values to the EKF if there was an update. When analysing these availability vectors we can see that the barometer only updates at a rate of 5Hz and the GPS at a rate of 1Hz.

\newpage
\section{Processing the Video Data}
To further simplify the design and implementation of the EKF it is important to pre-process the video data to a less data heavy format than MP4. The following digram shows the process of converting a large video file to a more lightweight csv file without losing any critical information.

\begin{figure}[!ht]
\captionsetup{width=0.8\linewidth, font=small}
\includegraphics[width=\linewidth]{figures/videoProcess.png}
\caption{Diagram showing the progression and dependence of the major stages of video processing in the project}
\label{fig:videoProcess}
\end{figure}

All raw video data streams must be synchronized and the important sections of the streams extracted. Correcting the various distortions introduced by the lens properties of the GoPro and decompressing the video files are necessary before image processing is attempted. Finally each marker position in every frame of all the individual cameras must be quantified. These pixel coordinates will serve as inputs to the EKF.

\subsection{Obtaining Video Data}
The cameras were housed in the custom designed dual camera housing shown in the previous chapter. Two cameras at the front capturing the motion of the lower limbs when they have a positive hip angle and two cameras mounted to the back to capture negative hip angles.

The GoPro cameras were all connected to a single GoPro remote and configured to record video when the remote was activated. After the harness had been properly secured the cameras were started. The remote starts the cameras at similar times, but not accurately enough to use as a method of synchronization. Below is a picture of the GoPro remote used.

\begin{figure}[!ht]
\captionsetup{width=0.8\linewidth, font=small}
\includegraphics[width=0.1\linewidth]{figures/remote.jpg}
\caption{GoPro camera remote control}
\label{fig:remote}
\end{figure}

\subsection{Synchronizing Video Sources}
I typical problem faced when working with different sources of data is that of synchronization. Since this project ases 4 different cameras, synchronizing the video sources are critical to generate accurate stereo vision and lower limb data.

The problem of synchronization was overcome by using a audio cue to align the video data post capturing. With all systems recording, a simple hand clap can serve as a spiking audio input easily identified in the audio track of the video streams. The frame associated with this audio spike can be identified using SVP (Sony Vegas Pro) video editing software as shown in the figure below.

\begin{figure}[!ht]
\captionsetup{width=0.8\linewidth, font=small}
\includegraphics[width=0.5\linewidth]{figures/svpframe.png}
\caption{Figure showing the user interface of SVP video editing software}
\label{fig:svpframe}
\end{figure}

The red track in the above figure shows the recorded audio stream while the corresponding frames are displayed in the blue track above that. The cursor is aligned with the audio spike caused by the clap with the corresponding frame number displayed below the playback controls. This method was repeated for every video stream such that a common starting point was generated.

\subsection{Cutting Critical Video Data}
With the video data synchronized the next step was to generate a subset of video demonstrating a transient period and steady state period of running. By inspecting the videos we can identify the different phases of the run and we can extract their frame numbers by once again using SVP.

A single video was used to determine the different points of the run. From synchronization to the end of the run was 18 seconds. This quantifies as 1800 frames as the cameras are recording at 100 frames per second.

A MATLAB script was created to cut the 1800 critical frames from the raw video file. This script also uncompressed the video files to a more data intensive .AVI file that contains a RGB vector for each individual pixel. The decompression of the video files makes them easier to manipulate as objects in MATLAB, but does however not restore any of the data lost in the process of compression. This MATLAB script can be found on the accompanying CD.

\subsection{Undistorting the Video Data}
Due to the intrinsic lens properties of the GoPro cameras the edges of each frame had been severely distorted. To gain further understanding of undistorting video files \cite{Hartley2004} served as a reference. By using The built in camera calibration toolbox in MATLAB we can generate the various camera matrices needed to undistorted the video files.

A custom MATLAB script was created to undistort the critical video segments. This script used the camera matrix in conjunction with build in functions to correct the lens distortion frame by frame of each video stream. The script can be found on the accompanying CD. The following image shows the difference before and after the frames were corrected.

\begin{figure}[!ht]
\captionsetup{width=0.8\linewidth, font=small}
\includegraphics[width=\linewidth]{figures/fixed.jpg}
\caption{Images demonstrating the effects of lens distortion.}
\label{fig:fixed}
\end{figure}

\subsection{Tracking and Exporting Marker Positions}
This section discusses the different methods of image processing subdividing them into two main methodologies: automated and semi-automated. Each of these approaches offer advantages and disadvantages. To understand the approaches considered for this work it is important to visualize the input image data to the system. The following picture shows the various frames from all the cameras.

\begin{figure}[!ht]
\captionsetup{width=0.8\linewidth, font=small}
\includegraphics[width=\linewidth]{figures/pat_run_quad.png}
\caption{4 Frames from the different cameras combined}
\label{fig:pat_run_quad}
\end{figure}

The top row of images have been generated by the front mounted cameras and the bottom row by the rear mounted cameras. The left images were produced by the left cameras and the right images by the right cameras. From this image we can get a visual idea of the data our image processing system needs to manipulate.

Feature detection is a methodology in image processing that allows critical points of an image to be detected. This extracts an XY coordinate of the point of interest that can then be used to track the movement and position of an object in the image. This methodology can be applied to frames with more than one point of interest as shown in this work. Multiple points of interest in multiple video sources does however increase the complexity of feature detection.

An initial approach of using automated detection was chosen and three possible system were considered. Using a trained \textit{neural network}, using an \textit{edge detection} algorithm with a panning search algorithm and finally using a \textit{colour identifying} algorithm paired with a local search algorithm. These approaches all require a considerable amount of software to implement and therefore the viability of each has to be considered.

In theory a well trained \textit{neural network} will provide the most robust and accurate system to identify features in varying lighting condition. It would also be the most accurate methodology for a system without the markers. This is due to the "understanding" developed by the neural network after sufficient training data is processed. Strong choices for neural network types would be a Hopfield network or a feed-forward network.

Training a network presents a key difficulty in setting up a neural network. The most important element of a neural network is the training data used to teach the network the correct node weightings. Training data consist of annotated images with descriptive metadata. Such a dataset needs to be created either automatically using image processing algorithm or can be created by computer assisted image processing. A neural network therefore cannot generate its own training data and can therefore only be used as a semi automated identification system.

The second approach considered was that of \textit{edge detection}. This method identifies various edges in the image using discontinuities in brightness. Such a system can easily detect the edges of a marker, but cannon differentiate or classify edges. Pairing edge detection with a panning search algorithm allows us to search for marker shaped objects post edge detection. This algorithm needs to correctly identify the marker shapes and correctly differentiate and uniquely annotate the different markers as their respective points.

Although the implementation of edge detection is rather trivial, creating a search algorithm that can correctly identify changing marker shapes and assign them their correct point classification seems beyond the scope of this project. The following image shows edge detection as applied to a camera frame.

\begin{figure}[!ht]
\captionsetup{width=0.8\linewidth, font=small}
\includegraphics[width=0.6\linewidth]{figures/ed.jpg}
\caption{4 Frames from the different cameras combined}
\label{fig:ed}
\end{figure}

From this example we can see that the marker edges are correctly identified, but the colours do not correlate. As assumed the difficulty in this approach is not creating the image processing algorithm but rather in creating a panning search algorithm to extract marker information.

Another approach considered was that of a \textit{colour identifying} algorithm. By using such methods the markers with their bright colours are easy to identify and differentiating between pink and green markers also seem trivial. The local search algorithm is also easy to implement and will start searching for marker in the next frame at the coordinates of the same marker identified in the previous frame.

Such an approach was partially implemented, but did not provide consistent enough results to use. These inconsistencies arise from the GoPro camera automatically adjusting its light level to best suit the environment. Changing the recorded light levels changes the perceived RGB values of the markers. This forces us to increase the colour rage of our markers, introducing more uncertainty and increasing the possibility false positives.

Another major drawback to using such a system is that it is not a generalized solution. This implies that the same markers must be used at the same positions every time the experiment is run. It also depends heavily on the markers, stunting the idea of transitioning to a markerless system.

By comparing the proposed automatic methods above and considering ease of implementation and accuracy no single method seems viable. This is either due to the lack of example data (in the case of the neural network), or the limitations of computer algorithms (too complex in the case of edge detection and not general purpose or accurate enough in the case of the colour identifier).

\newpage
The final approach considered and used was to \textit{semi automatically} label critical point in the image using a toolbox created by Hedrick et al. \cite{hedrick2008software}. This software allows for a semi automatic tracking of points of interest in the video frames by using user input in conjunction with computer algorithms. While this method is labour intensive it is arguably more accurate than the previously investigated methodologies and more generalized. The following figure shows the functionality of the toolbox within MATLAB.

\begin{figure}[!ht]
\captionsetup{width=0.8\linewidth, font=small}
\includegraphics[width=0.5\linewidth]{figures/toolbox.png}
\caption{Using the dltdv toolbox in MATLAB to export marker coordinates}
\label{fig:toolbox}
\end{figure}

By using this toolbox we can generate a dataset of $ (x,y) $ pixel coordinates by identifying the different markers on each frame and assigning their corresponding points to them. The following tables shows the markers and their corresponding point.

\begin{table}[!ht]
\centering
\caption{Table showing the relation between points and markers}
\label{my-label}
\begin{tabular}{lll}
Point & Identifier           & Marker Colour\\
Front Cameras &            &\\
Point 1       & Right Knee &PINK \\
Point 2       & Left Knee  &PINK\\
Point 3       & Right Foot &GREEN\\
Point 4       & Left Foot  &GREEN\\
Rear Cameras  &            &\\
Point 1       & Right Calf&GREEN \\
Point 2       & Left Calf &GREEN \\
Point 3       & Right Heel&PINK \\
Point 4       & Left Heel &PINK \\
\end{tabular}
\end{table}

Each video stream was processed and a total of 16 different coordinate sets was generated, 8 from the front cameras and 8 from the rear cameras. These coordinates were output as csv files that could easily be imported into MATLAB.

Finally availability vectors were created for each of the 16 points.
From these vectors we can also calculate the percentages of each camera seeing each marker. This can give us an idea as to how often the cameras are contributing data and how much of the total gait is captured. These percentages are discussed in a following chapter.

\section{On units}
In order to assure consistency between the different sources of data considering a general set of units is of critical importance. It was decided to implement the system using SI units such that all lengths was given in meters and all angles in radians.

\section{On Frames of Reference}
we need to developed some commonalities among the various sensors and their individual frames of reference. This thesis considers 4 different frames of reference, namely: the body frame, the smartphone frame, the camera frame and the inertial frame.

The body frame has been defined as shown in the image below.

\begin{figure}[!ht]
\captionsetup{width=0.8\linewidth, font=small}
\includegraphics[width=0.5\linewidth]{figures/patbf.jpg}
\caption{Figure demonstrating the body frame of reference}
\label{fig:patbf}
\end{figure}

The smartphone frame is shown in this image below.
\begin{figure}[!ht]
\captionsetup{width=0.8\linewidth, font=small}
\includegraphics[width=0.5\linewidth]{figures/phone.jpg}
\caption{Figure demonstrating the frame of reference of the smartphone}
\label{fig:phone}
\end{figure}

Since the smartphone is rigidly mounted to the body a simple axis transformation is required to transform the sensor data to the body frame. The following equations show the transformation.

$$ bodyX = smartphoneZ  $$
$$ bodyY = -smartphoneY  $$
$$ bodyZ = -smartphoneX  $$

There is however another frame of reference that is important to understand, that of the camera frame.

\begin{figure}[!ht]
\captionsetup{width=0.8\linewidth, font=small}
\includegraphics[width=0.5\linewidth]{figures/cf.png}
\caption{Figure demonstrating the camera frame of reference, image adapted from \cite{matlab}}
\label{fig:cf}
\end{figure}

Since the cameras are pointing down when the subject is standing still the Z axis of the camera aligns with the Z axis of the body.

The following video shows the orientation of the various cameras with repects to the runner.

\begin{figure}[!ht]
\captionsetup{width=0.8\linewidth, font=small}
\includegraphics[width=0.5\linewidth]{figures/forrr.jpg}
\caption{Figure demonstrating the body frame of reference}
\label{fig:forrr}
\end{figure}

from this .....


%
% @author   Shmish  "shmish90@gmail.com"
% @legal    MIT     "(c) Christopher Schmitt"
%

\documentclass{article}

%
% Document Imports
%

\usepackage{fancyhdr}
\usepackage{extramarks}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage{color}
\usepackage{tikz}

%
% Document Configuation
%

\newcommand{\hwAuthor}{Christopher Schmitt}
\newcommand{\hwSubject}{Math 218}
\newcommand{\hwSection}{Section 81}
\newcommand{\hwSemester}{Summer 2019}
\newcommand{\hwAssignment}{Assignment 7}

%
% Document Enviornments
%

\setlength{\headheight}{65pt}
\pagestyle{fancy}
\lhead{\hwAuthor}
\rhead{
  \hwSubject \\
  \hwSection \\
  \hwSemester \\
  \hwAssignment
}

\newenvironment{problem}[1]{
  \nobreak\section*{Problem #1}
}{}

%
% Document Start
%

\begin{document}
  \begin{problem}{1}
    Let $S_n = 1(5) + 2(6) + \dots + n(n + 4)$. Make a table that shows the values $S_1$ through $S_10$.
    \begin{enumerate}
      \item[] $S_1 = 5$
      \item[] $S_2 = 17$
      \item[] $S_3 = 38$
      \item[] $S_4 = 70$
      \item[] $S_5 = 115$
      \item[] $S_6 = 175$
      \item[] $S_7 = 252$
      \item[] $S_8 = 348$
      \item[] $S_9 = 465$
      \item[] $S_{10} = 605$
    \end{enumerate}
    Try finding a pattern in the table.
    \begin{enumerate}
      \item[] $S_1 * 3 = 15 = 1 * 15$
      \item[] $S_2 * 3 = 51 = 3 * 17$
      \item[] $S_3 * 3 = 114 = 6 * 19$
      \item[] $S_4 * 3 = 210 = 10 * 21$
      \item[] $S_5 * 3 = 345 = 15 * 23$
      \item[] $S_6 * 3 = 525 = 21 * 25$
      \item[] $S_7 * 3 = 756 = 28 * 27$
      \item[] $S_8 * 3 = 1044 = 36 * 29$
      \item[] $S_9 * 3 = 1395 = 45 * 31$
      \item[] $S_{10} * 3 = 1815 = 55 * 33$
    \end{enumerate}
    Devise a formula for $S_i$
    \begin{center}
      $S_i = \frac{i(i + 1)(2i + 13)}{6}$
    \end{center}
    Prove the formula.
    \begin{proof}
      Basis Step
      \begin{equation*}
        \begin{split}
          LHS & = 1(5) = 5\\
          RHS & = \frac{1(1 + 1)(2(1) + 13)}{6} = 5
        \end{split}
      \end{equation*}
      Inductive Step:\\
      Suppose that the expression works for $i = n$.
      \begin{equation*}
        \begin{split}
          LHS & = 1(5) + 2(6) + \dots + n(n + 4)\\
          RHS & = \frac{n(n + 1)(2n + 13)}{6}
        \end{split}
      \end{equation*}
      Now consider $i = n + 1$
      \begin{equation*}
        \begin{split}
          LHS & = 1(5) + 2(6) + \dots + n(n + 4) + (n + 1)(n + 5)\\
          LHS & = \frac{n(n + 1)(2n + 13)}{6} + (n + 1)(n + 5)\\
          LHS & = \frac{2n^3 + 21n^2 + 45n + 30}{6}\\
          RHS & = \frac{(n + 1)(n + 2)(2(n + 1) + 13)}{6}\\
          RHS & = \frac{2n^3 + 21n^2 + 45n + 30}{6}
        \end{split}
      \end{equation*}
    \end{proof}
  \end{problem}

  \begin{problem}{2}
    Determine the value of $x$ so that $04393x8078$ is a valid ISBN.
    \begin{center}
      $10(0) + 9(4) + 8(3) + 7(9) + 6(3) + 5(x) + 4(8) + 3(0) + 2(7) + 1(8)$\\
      $0 + 36 + 24 + 63 + 18 + 5x + 32 + 0 + 14 + 8$\\
      $195 + 5(x) = 11(y)$, where $x, y \in \mathbf{Z}$\\
      $195 + 5(5) = 11(20)$\\
      $x = 5$
    \end{center}
  \end{problem}

  \begin{problem}{3}
    Use the Chinese Remainder Theorem to solve the following system of congruences:
    \begin{center}
      $x \equiv 10 \pmod{13}$\\
      $x \equiv 5 \pmod{17}$
    \end{center}
    \begin{enumerate}
      \item [] $M = m_1m_2 = 13 * 17 = 221$
      \item [] $M_1 = \frac{M}{m_1} = 17$
      \item [] $M_2 = \frac{M}{m_2} = 13$
      \item [] $y_1 = 17(k) \equiv \pmod{13} = 10$
      \item [] $y_2 = 13(k) \equiv \pmod{17} = 4$
      \item [] $x = a_1 * M_1 * y_1 + a_2 * M_2 * y_2$
      \item [] $x = 10 * 17 * 4 + 5 * 5 * 4 = 780$
    \end{enumerate}
  \end{problem}

  \begin{problem}{4}
    Jim wants to use the RSA Algorithm, as described on page $141$ of our textbook, to send a message. However, Jim does not understand that, in order for the algorithm to be secure, the two primes $p$ and $q$ that he selects must be large. Consequently, he selected two small primes, and made the values of $r = 341$ and $s = 17$ public.
    \begin{enumerate}
      \item [] If the message that Jim wants to send is M = 19, what will the encrypted message E be?
      \item [] $n = rs = 341(17) = 5797$
      \item [] $e = 7$
      \item [] $7(4663) \equiv 1 \pmod{5440}$
      \item [] $d = 4663$
      \item [] $E = M^e \mod n = 19^7 \mod 5797 = 984$
      \item [] Since Jim picked two small primes, you will be able to determine his supposedly secret p and q. Do so, and by using the procedure from the text, determine the original message M if the encrypted message is E = 197.
      \item [] $C^d \mod n = p$
      \item [] $197^{4663} \mod 5797 = 362$
    \end{enumerate}
  \end{problem}

  \begin{problem}{5}
    Use the characteristic equation to solve the recurrence relation
    \begin{center}
      $a_n = 6a_{n-1} - 8a_{n-2}, n \le 2$, given $a_0 = 4, a_1 = 14$
    \end{center}
    \begin{equation*}
      \begin{split}
        r^2 - 6r + 8 & = 0\\
        (r - 2)(r - 4) & = 0\\
        2, 4 & = r
      \end{split}
    \end{equation*}
    \begin{equation*}
      \begin{split}
        a_n & = k_1 * 2^n + k_2 * 4^n\\
        4 & = k_1 * 2^0 + k_2 * 4^0\\
        14 & = k_1 * 2^1 + k_2 * 4^1\\
        k_1 & = 1\\
        k_2 & = 3\\
        a_n & = 1(2^n) + 3(4^n)
      \end{split}
    \end{equation*}
  \end{problem}

  \begin{problem}{6}
    How many integers between 1 and 100,000 (inclusive) are relatively prime to 1595?
    \begin{center}
      $1595 = 5 * 11 * 29$
      \begin{equation*}
        \begin{split}
          + &\ 100000\\
          - & \text{ multiples of } 5\ (20000)\\
          - & \text{ multiples of } 11\ (9090)\\
          - & \text{ multiples of } 29\ (3448)\\
          + & \text{ multiples of } 5 * 11\ (1818)\\
          + & \text{ multiples of } 5 * 29\ (689)\\
          + & \text{ multiples of } 11 * 29\ (313)\\
          - & \text{ multiples of } 5 * 11 * 29\ (62)\\
          = &\ 70220
        \end{split}
      \end{equation*}
    \end{center}

    How many license plates can be made if each license plate contains six characters, the first four characters are letters and the last two characters are digits, and the letters must all be distinct (but the digits need not be distinct)?
    \begin{center}
      $26 * 25 * 24 * 23 * 10 * 10 = 35880000$
    \end{center}

    In a group of 93 people, how many must have been born on the same day of the week (i.e., Sunday, Monday, Tuesday, etc.)
    \begin{center}
      $\left \lceil{93/7}\right \rceil = 14$
    \end{center}

    I have thirteen different toys (only one copy of each), and I want to give one toy to each of five children. In how many ways can this be done?
    \begin{equation*}
      \begin{split}
        x & = \frac{n!}{r! * (n - r)!} * r!\\
        x & = \frac{13!}{5! * (13 - 5)!} * 5!\\
        x & = 1554440
      \end{split}
    \end{equation*}
  \end{problem}
\end{document}