\documentclass[journal, a4paper]{IEEEtran}

\usepackage{graphicx}
\usepackage{url}
\usepackage{amsmath}

\begin{document}
	\title{Implementation of Random Forests}
	\author{Alejandro Su\'arez Hern\'andez}
	\markboth{Supervised and Experiential Learning}{}
	\maketitle

% Write abstract here
\begin{abstract}
	This report presents our implementation of Random Forests for
	classification and presents
	some exploratory results. Namely, we are interested in the performance
	of our classifier under different settings, varying the number of
	features considered randomly at each decision stump and the size of the
	ensemble. Another interesting aspect of Random Forests that we will
	review in this document is that they perform implicit feature
	selection. We can take advantage of this to rank the input attributes
	according to their relevance predicting the output class.
\end{abstract}

% Each section begins with a \section{title} command
\section{Introduction}
	% \PARstart{}{} creates a tall first letter for this first paragraph
	\PARstart{R}{andom} forests is an ensemble method for both regression
	and classification. It essentially consists in learning several decision
	trees from the data, introducing some source of randomness
	in the learning process so they are not
	equal. When classifying a new instance, the forest aggregates the
	predictions of all the trees into a single answer. In the classification
	case, the aggregation method is typically the mode (i.e. the most
	frequently predicted class). In regression, the average of all the guesses
	is a common choice. In this document, we focus on the classification
	problem.

	These are the most frequent techniques to introduce stochasticity in the
	learning process:
	\begin{itemize}
		\item \textbf{Bootstrap aggregating:} also known as bagging. It is
		a general method that consists
		in training each learner (in our case, each tree) with a
		random sample of the original train data.
		\item \textbf{Feature bagging:} when learning, select the best
		splitting feature from a random sample of features. Each
		selected feature is splitted optimally according to some
		information criterion (entropy, Gini impurity, error...). The number
		of random features to consider is a parameter of the algorithm.
		This technique is explored in this document.
		\item \textbf{Random splits:} take randomization even one step
		further making the local splits random as well. That is, the
		information criterion is used exclusivelly to select the best
		randomly splitted feature. This technique has been adopted by
		the ExtraTrees (Extremely Randomized Trees) algorithm.
	\end{itemize}

	This document revolves around a custom implementation of Random Forests.
	It incorporates feature bagging and accepts several parameters in order
	to tweak its performance for each data set. More specifically:
	\begin{itemize}
		\item \textbf{Number of selected features ($F$):} the number of candidate
		features chosen randomly at each node for evaluation. $F$ is
		clipped if the number of available features is smaller.
		\item \textbf{Number of learners ($M$):} the number of trees in the
		ensemble.
		\item \textbf{Minimum number of instances to split ($N$):} the learner will
		continue splitting the current node if the number of instances that
		have arrived to it is at least $N$.
		\item \textbf{Split quality criterion:} the implementation
		accepts three criterions: (1) information
		gain (or entropy minimization); (2) Gini impurity coefficient; (3)
		classification error or $ 1 - p_{max} $ where $ p_max $ is the probability
		of the most frequent class in the split.
	\end{itemize}

	Our implementation offers other features like the possibility of storing
	the learnt ensembles in a JSON file, and visualizing them via Graphviz.
	We refer the reader to the \texttt{README.md} file in this repository
	in order to know more about the technical details of our application
	\footnote{Github: \url{https://github.com/sprkrd/randomforest}}.

	In the next section we explore the prediction power of our classifier
	with different parametrizations. In addition, we analyze its ability
	to rank features based on their frequence of apparition as criterion
	in the decision stumps.

\section{Experiments}

\begin{table}[tbp]
\centering
\caption{Data sets used for testing our RF implementation}
\resizebox{\columnwidth}{!}{\begin{tabular}{|r|r|r|r|r|r|}
\hline
\textbf{Data set} & \textbf{Records} & \textbf{Nom. Attr.} & \textbf{Num. Attr} & \textbf{Classes} & \textbf{Missing(\%)} \\ \hline
Audiology & 226 & 69 & 0 & 24 & 2 \\ \hline
Credit & 690 & 9 & 6 & 2 & 0.6 \\ \hline
Hepatitits & 155 & 13 & 6 & 2 & 5.7 \\ \hline
Votes & 435 & 16 & 0 & 2 & 5.6 \\ \hline
Iris & 150 & 0 & 4 & 3 & 0 \\ \hline
Chess & 3196 & 36 & 0 & 2 & 0 \\ \hline
Lenses & 24 & 4 & 0 & 3 & 0 \\ \hline
Soybean & 47 & 35 & 0 & 4 & 0 \\ \hline
Splices & 3190 & 60 & 0 & 3 & 0 \\ \hline
Zoo & 101 & 16 & 1 & 7 & 0 \\ \hline
\end{tabular}}
\label{tab:datasets}
\end{table}

The tested data sets are shown in Table~\ref{tab:datasets}. We aim mostly at
studying the accuracy of the ensemble under different selections of $M$ (number
of trees) and $F$ (number of random features). For the sake of simplicity, the
rest of parameters will be fixed: $ N = 4 $; and the quality metric is the
Giny impurity. We invite the reader to experiment further with our application.

\subsection{Accuracy}

We have tested our ensemble model for $ M \in \{50, 100\} $ and for
$ F \in \{1, 3, \lfloor\log_2(N_{attr}+1)\rfloor, \left[\sqrt{N_{attr}}\right]\} $ (discarding
repeated values of $ F $).

The results are as follows:
\begin{itemize}
	\item \textbf{Audiology:} shown in Table~\ref{tab:acc-audiology}. There is a
	slight improvement for increasing $ M $ and $ F $.
	\item \textbf{Credit:} shown in Table~\ref{tab:acc-crx}. The accuracy does not
	seem to be affected.
	\item \textbf{Hepatitis:} shown in Table~\ref{tab:acc-hepatitis}. Surprisingly,
	the accuracy seems to be higher for the smallest value of $ F $.
	\item \textbf{Votes:} shown in Table~\ref{tab:acc-votes}. The best accuracy
	has been obtained with $ F = 4 $ and 100 learners.
	\item \textbf{Chess:} shown in Table~\ref{tab:acc-chess}. The difference between
	the best and the worst configuration is almost a 3\% with a very low
	deviation.
	\item \textbf{Lenses:} shown in Table~\ref{tab:acc-lenses}. Perhaps not a very
	relevant data set because of the low number of examples. The deviation is too
	high to draw conclusions.
	\item \textbf{Soybean:} shown in Table~\ref{tab:acc-soybean}. Perfect
	classification with all the configurations.
	\item \textbf{Splice:} shown in Table~\ref{tab:acc-splice}. One of the data
	sets in which the parameters choice have the most notable effect, jumping
	from a worst case accuracy of 87.81\% ($ M = 50 $ and $ F = 1 $) to
	96.39\% ($ M = 100 $ and $ F = 8 $). The deviation is also greatly
	reduced, suggesting that this is indeed a very stable configuration.
	\item \textbf{Zoo:} shown in Table~\ref{tab:acc-zoo}. The parameters do not
	have a very noticeable effect.
\end{itemize}

\begin{table}[htbp]
\caption{Accuracy results for Audiology data set}
\begin{center}
\begin{tabular}{|r|r|r|r|r|}
\hline
\textbf{M\textbackslash{}F} & \textbf{1} & \textbf{3} & \textbf{7} & \textbf{8} \\ \hline
\textbf{50} & 73.78 $ \pm $ 6.19 & 74.67 $ \pm $ 7.65 & 74.22 $ \pm $ 7.52 & 74.67 $ \pm $ 9.06 \\ \hline
\textbf{100} & 72.44 $ \pm $ 7.77 & 75.11 $ \pm $ 6.50 & 74.67 $ \pm $ 8.15 & 76.00 $ \pm $ 8.93 \\ \hline
\end{tabular}
\end{center}
\label{tab:acc-audiology}
\end{table}

\begin{table}[htbp]
\caption{Accuracy results for Credit Approval data set}
\begin{center}
\begin{tabular}{|r|r|r|r|}
\hline
\textbf{M\textbackslash{}F} & \textbf{1} & \textbf{3} & \textbf{4} \\ \hline
\textbf{50} & 86.52 $ \pm $ 2.36 & 85.65 $ \pm $ 1.86 & 86.38 $ \pm $ 1.68 \\ \hline
\textbf{100} & 86.67 $ \pm $ 2.27 & 86.96 $ \pm $ 1.02 & 86.23 $ \pm $ 2.00 \\ \hline
\end{tabular}
\end{center}
\label{tab:acc-crx}
\end{table}

\begin{table}[htbp]
\caption{Accuracy results for Hepatitis data set}
\begin{center}
\begin{tabular}{|r|r|r|r|r|}
\hline
\textbf{M\textbackslash{}F} & \multicolumn{1}{r|}{\textbf{1}} & \multicolumn{1}{r|}{\textbf{3}} & \multicolumn{1}{r|}{\textbf{4}} & \multicolumn{1}{r|}{\textbf{5}} \\ \hline
\textbf{50} & 82.58 $ \pm $ 3.29 & 81.29 $ \pm $ 3.76 & 82.58 $ \pm $ 1.58 & 82.58 $ \pm $ 4.83 \\ \hline
\textbf{100} & 85.16 $ \pm $ 2.58 & 84.52 $ \pm $ 1.29 & 81.94 $ \pm $ 4.38 & 80.65 $ \pm $ 5.40 \\ \hline
\end{tabular}
\end{center}
\label{tab:acc-hepatitis}
\end{table}

\begin{table}[htbp]
\caption{Accuracy results for Iris data set}
\begin{center}
\begin{tabular}{|r|r|r|r|}
\hline
\textbf{M\textbackslash{}F} & \textbf{1} & \textbf{2} & \textbf{3} \\ \hline
\textbf{50} & 93.33 $ \pm $ 4.71 & 93.33 $ \pm $ 4.71 & 94.67 $ \pm $ 2.67 \\ \hline
\textbf{100} & 94.00 $ \pm $ 4.90 & 94.00 $ \pm $ 4.90 & 94.67 $ \pm $ 2.67 \\ \hline
\end{tabular}
\end{center}
\label{tab:acc-iris}
\end{table}

\begin{table}[htbp]
\caption{Accuracy results for Votes data set}
\begin{center}
\begin{tabular}{|r|r|r|r|r|}
\hline
\textbf{M\textbackslash{}F} & \textbf{1} & \textbf{3} & \textbf{4} & \textbf{5} \\ \hline
\textbf{50} & 94.71 $ \pm $ 2.25 & 96.78 $ \pm $ 1.69 & 96.55 $ \pm $ 1.63 & 96.09 $ \pm $ 1.17 \\ \hline
\textbf{100} & 95.17 $ \pm $ 1.52 & 96.78 $ \pm $ 1.52 & 97.01 $ \pm $ 1.56 & 96.78 $ \pm $ 1.52 \\ \hline
\end{tabular}
\end{center}
\label{tab:acc-votes}
\end{table}

\begin{table}[htbp]
\caption{Accuracy results for Chess data set}
\begin{center}
\begin{tabular}{|r|r|r|r|}
\hline
\textbf{M\textbackslash{}F} & \textbf{1} & \textbf{3} & \textbf{6} \\ \hline
\textbf{50} & 96.87 $ \pm $ 0.75 & 99.03 $ \pm $ 0.35 & 99.56 $ \pm $ 0.15 \\ \hline
\textbf{100} & 97.18 $ \pm $ 0.57 & 99.19 $ \pm $ 0.44 & 99.53 $ \pm $ 0.17 \\ \hline
\end{tabular}
\end{center}
\label{tab:acc-chess}
\end{table}

\begin{table}[htbp]
\caption{Accuracy results for Lenses data set}
\begin{center}
\begin{tabular}{|r|r|r|r|}
\hline
\textbf{M\textbackslash{}F} & \textbf{1} & \textbf{2} & \textbf{3} \\ \hline
\textbf{50} & 75.00 $ \pm $ 15.81 & 85.00 $ \pm $ 12.25 & 85.00 $ \pm $ 12.25 \\ \hline
\textbf{100} & 70.00 $ \pm $ 18.71 & 85.00 $ \pm $ 12.25 & 85.00 $ \pm $ 12.25 \\ \hline
\end{tabular}
\end{center}
\label{tab:acc-lenses}
\end{table}

\begin{table}[htbp]
\caption{Accuracy results for Soybean data set}
\begin{center}
\begin{tabular}{|r|r|r|r|}
\hline
\textbf{M\textbackslash{}F} & \textbf{1} & \textbf{3} & \textbf{6} \\ \hline
\textbf{50} & 100.00 $ \pm $ 0.00 & 100.00 $ \pm $ 0.00 & 100.00 $ \pm $ 0.00 \\ \hline
\textbf{100} & 100.00 $ \pm $ 0.00 & 100.00 $ \pm $ 0.00 & 100.00 $ \pm $ 0.00 \\ \hline
\end{tabular}
\end{center}
\label{tab:acc-soybean}
\end{table}

\begin{table}[htbp]
\caption{Accuracy results for Splice data set}
\begin{center}
\begin{tabular}{|r|r|r|r|r|}
\hline
\textbf{M\textbackslash{}F} & \textbf{1} & \textbf{3} & \textbf{6} & \textbf{8} \\ \hline
\textbf{50} & 87.81 $ \pm $ 2.20 & 95.02 $ \pm $ 0.89 & 96.14 $ \pm $ 0.80 & 96.39 $ \pm $ 0.52 \\ \hline
\textbf{100} & 88.62 $ \pm $ 3.01 & 96.05 $ \pm $ 0.52 & 96.71 $ \pm $ 0.38 & 96.39 $ \pm $ 0.60 \\ \hline
\end{tabular}
\end{center}
\label{tab:acc-splice}
\end{table}

\begin{table}[htbp]
\caption{Accuracy results for Zoo data set}
\begin{center}
\begin{tabular}{|r|r|r|r|r|}
\hline
\textbf{M\textbackslash{}F} & \textbf{1} & \textbf{3} & \textbf{4} & \textbf{5} \\ \hline
\textbf{50} & 95.00 $ \pm $ 4.47 & 93.00 $ \pm $ 4.00 & 94.00 $ \pm $ 3.74 & 95.00 $ \pm $ 4.47 \\ \hline
\textbf{100} & 95.00 $ \pm $ 4.47 & 95.00 $ \pm $ 3.16 & 96.00 $ \pm $ 4.90 & 94.00 $ \pm $ 3.74 \\ \hline
\end{tabular}
\end{center}
\label{tab:acc-zoo}
\end{table}

\subsection{Feature ranking}

As said before, Random Forests are useful to sort the features of a data set according
to their relevance, as long as $ F > 1 $. Otherwise, at each node the chosen feature is
completely random. This is evidenced by the following example.

The ranking and scores for the Iris data set with $ M = 50 $ and $ F = 1 $ is:
\begin{enumerate}
\item sepal-length (0.27821)
\item sepal-width (0.266537)
\item petal-length (0.2393)
\item petal-width (0.215953)
\end{enumerate}

We can see that the scores do not actually differ too much. However, let us see what happens
maintaining the same value of $ M $, but with $ F = 3 $:

\begin{enumerate}
\item petal-length (0.445693)
\item petal-width (0.348315)
\item sepal-length (0.198502)
\item sepal-width (0.00749064)
\end{enumerate}

We can see that now petal-length and petal-width have gained much more relevance than the other
two features. In fact, this has much sense, since the petal-length alone can be used to discriminate
away one of the three classes. Not only this, but it plays a crucial role for discriminating
the remaining two. Fig.~\ref{fig:iris-tree} shows one of the learnt trees.

\begin{figure*}[htbp]
\centering
\includegraphics[width=0.75\textwidth]{iris1.pdf}
\caption{One of the learnt trees of the Iris data set}
\label{fig:iris-tree}
\end{figure*}

The full list of rankings and scores can be found in the \texttt{experiment\_results} folder. We
refer the reader there.

% Your document ends here!
\end{document}


\documentclass[bigger]{beamer}

\input{header-beam} % change to header-handout for handouts

% ====================
\title[Lecture 9]{Logic I F13 Lecture 9}
\date{October 8, 2013}
% ====================

\include{header}

\setlength{\fitchprfwidth}{5em}

\section{Proof Strategies}

\subsec{Strategy for Proving Conjunctions}{

\begin{tabular}{@{}lp{13em}}
\fitchprf{
   \pline[1.]{}
}{
 \ellipsesline \\
 \pline[2.]{} \\
 \ellipsesline \\
 \pline[3.]{} \\
 \pline[4.]{P \land Q}[\hphantom{\landi{2, 3}}]
}
  &
If we want to prove $\sf P \land Q$, we have to use $\land$Intro.
\end{tabular}

}

\subsec{Strategy for Proving Conjunctions}{

\begin{tabular}{@{}lp{13em}}
  \fitchprf{\pline[1.]{}}{
    \ellipsesline \\
    \pline[2.]{P} \\
    \ellipsesline \\
    \pline[3.]{Q} \\
    \pline[4.]{P \land Q}[\landi{2, 3}]
  }
  &
  For $\land$Intro, we need to prove $\sf P$ first, then prove $\sf Q$. For the last line,
  we'll cite the lines where we proved $\sf P$ and  $\sf Q$, and use $\land$Intro.
\end{tabular}
}

\subsec{Strategy for Using Conjunctions}{

\begin{tabular}{@{}lp{13em}}
\fitchprf{
   \pline[1.]{P \land Q}
}{
 \pline{}[\hphantom{\lande{1}}] \\
 \pline{} \\
 \ellipsesline \\
 \pline{R}
}
  &
If we want to use a sentence of the form $\sf P \land Q$ which is one
of our premises, or a sentence we've already proved, use $\land$Elim.
\end{tabular}
}

\subsec{Strategy for Using Conjunctions}{

\begin{tabular}{@{}lp{13em}}
\fitchprf{
   \pline[1.]{P \land Q}
}{
 \pline[2.]{P}[\lande{1}]\\
 \pline[3.]{Q}[\lande{1}]\\
 \ellipsesline \\
 \pline{R}
}
& Use $\land$Elim to ``split up'' $\sf P \land Q$, proving both $\sf
P$ and $\sf Q$.  We'll probably need them further down in the proof.
\end{tabular}
}

\subsec{Strategy for Proving Disjunctions}{

\begin{tabular}{@{}lp{13em}}
\fitchprf{
   \pline[1.]{}
}{
 \ellipsesline \\
 \pline[2.]{} \\
 \pline[3.]{P \lor Q}[\hphantom{\lori{2}}]
}
  &
We want to prove $\sf P \lor Q$. We could do this using  $\lor$Intro.
\end{tabular}
}

\subsec{Strategy for Proving Disjunctions}{

\begin{tabular}{@{}lp{13em}}
\fitchprf{\pline[1.]{}}{
\ellipsesline \\
\pline[2.]{P} \\
\pline[3.]{P \lor Q}[\lori{2}]
}
&
For $\lor$Intro, we need to prove one of the disjuncts.
We'll try $\sf P$ first. For the last line,
we'll cite the line where we proved $\sf P$, and use $\lor$Intro.
\end{tabular}
}

\subsec{Strategy for Proving Disjunctions}{

\begin{tabular}{@{}lp{13em}}
\fitchprf{\pline[1.]{}}{
\ellipsesline \\
\pline[2.]{Q} \\
\pline[3.]{P \lor Q}[\lori{2}]
}
&
If we can't prove $\sf P$, we may have to backtrack and try to prove $\sf Q$
instead.  Again, we'll cite the line where we proved $\sf Q$, and use
$\lor$Intro.
\end{tabular}
}

\subsec{Strategy for Using Disjunctions}{

\begin{tabular}{@{}l@{}p{13em}}
\fitchprf{
   \pline[1.]{P \lor Q}
}{
 \pline{}\\
\pline{} \\
\pline{}\\
\pline{} \\
\pline{} \\
\pline{} \\
\ellipsesline \\[.7em]
  \pline[6.]{R}[\hphantom{\lore{1}{2--3}{4--5}}]
}
  &
Suppose we want to prove R, and we have $\sf P \lor Q$ as a premise,
as the assumption of a subproof, or as something proved before.
We'll try to use it by applying $\lor$Elim.
\end{tabular}

}

\subsec{Strategy for Using Disjunctions}{

\begin{tabular}{@{}l@{}p{13em}}
\fitchprf{
   \pline[1.]{P \lor Q} }{ \subproof{\pline[2.]{P}}{ \ellipsesline \\
\pline[3.]{R}} \subproof{\pline[4.]{Q}}{ \ellipsesline \\
\pline[5.]{R}} \pline[6.]{R}[\lore{1}{2--3}{4--5}] }
& To prove $\sf R$ using $\lor$Elim from $\sf P \lor Q$, we'll have to
look for two subproofs: one in which we prove $\sf R$ from $\sf P$,
another where we prove $\sf R$ from $\sf Q$. Once we have both, we
can justify $\sf R$ by using $\lor$Elim, citing the line with $\sf P
\lor Q$ and the two subproofs.
\end{tabular}
}

\subsec{Strategy for Proving Negations}{

\begin{tabular}{@{}lp{13em}}
\fitchprf{
   \pline[1.]{}
}{
 \pline{}\\
\pline{} \\
\pline{}\\
\ellipsesline \\[.7em]
  \pline[4.]{\neg P}[\hphantom{\lnoti{2}}]
}
  &
If we want to prove $\neg\sf P$, we'll have to use  $\neg$Intro.
\end{tabular}

}

\subsec{Strategy for Proving Negations}{

\begin{tabular}{@{}lp{13em}}
\fitchprf{\pline[1.]{}}{
\subproof{\pline[2.]{P}}{
\ellipsesline \\
\pline[3.]{\bot}}
\pline[4.]{\neg P}[\lnoti{2--3}]
}
& For $\neg$Intro, we have to start a subproof with assumption $\sf
P$; the last line of the subproof has to be $\bot$.  We'll cite the
subproof, and use $\lnot$Intro.
\end{tabular}
}

\subsec{Strategy for Indirect Proof}{

\begin{tabular}{@{}lp{13em}}
\fitchprf{
   \pline[1.]{}
}{
 \pline{}\\
\pline{} \\
\pline{}\\
\ellipsesline \\[.7em]
  \pline[4.]{P}[\hphantom{\lnoti{2}}]
}
& Sometimes, we want to prove a sentence $\sf P$, but our other
strategies didn't get us far. This is often the case, e.g., when we
want to prove disjunctions but don't have any premises (for example:
$\sf A \lor \neg A$).  Then we can also use $\neg$Intro.
\end{tabular}

}

\subsec{Strategy for Indirect Proof}{

\begin{tabular}{@{}lp{13em}}
\fitchprf{\pline[1.]{}}{
\subproof{\pline[2.]{\neg P}}{
\ellipsesline \\
\pline[3.]{\bot}}
\pline[4.]{P}[\lnoti{2--3}]}
&
Here, we have to start a subproof with assumption $\sf \neg P$;
the last line of the subproof has to be $\bot$.
We'll cite the subproof, and use $\lnot$Intro.  In the subproof, we now
have an additional assumption (on line 2) to work with.
\end{tabular}

}

\subsec{How to Find a Contradiction}{

\begin{tabular}{@{}lp{13em}}
\fitchprf{\pline[1.]{}}{
\subproof{\pline[2.]{\neg P}}{
\pline{}\\
\ellipsesline \\
\pline[4.]{\bot}}
\pline[5.]{P}[\lnoti{2--3}]
}
&
Suppose we used the indirect proof strategy, or we're in some other situation
where we're looking for a proof of $\bot$.  What's a good candidate?
\end{tabular}

}

\subsec{How to Find a Contradiction}{

\begin{tabular}{@{}lp{13em}}
\fitchprf{\pline[1.]{}}{
\subproof{\pline[2.]{\neg P}}{
\ellipsesline \\
\pline[3.]{P}\\
\pline[4.]{\bot}[\lfalsei{2}{3}]}
\pline[5.]{P}[\lnoti{2--4}]
}
& One good candidate is $\sf P$ itself!  This may look weird but
remember that inside the subproof, we have an additional assumption
$\sf \lnot P$ to work with.
\end{tabular}

}

\subsec{How to Use a Negated Sentence}{

\begin{tabular}{@{}lp{13em}}
\fitchprf{
   \pline[1.]{\neg P}
}{
 \pline{}\\
\pline{} \\
\pline{}\\
\ellipsesline \\[.7em]
  \pline[4.]{R}[\hphantom{\lnoti{2}}]
}
  &
Suppose $\sf\neg P$ is one of your premises, or something else you've
already proved, and the sentence you're shooting for doesn't contain
$\sf \neg P$. How are you going to make use of  $\sf\neg P$?
\end{tabular}

}

\subsec{How to Use a Negated Sentence}{

\begin{tabular}{@{}lp{13em}}
\fitchprf{\pline[1.]{\neg P}}{
\subproof{\pline[2.]{\neg R}}{
\ellipsesline \\
\pline[3.]{P}\\
\pline[4.]{\bot}[\lfalsei{1}{3}]}
\pline[5.]{R}[\lnoti{2--4}]
}
&
The only way to make use of $\sf\neg P$ in such a situation is as part
of a contradiction. For instance, apply the indirect proof strategy,
and then look for $\sf P$ inside the subproof.
\end{tabular}

}

\subsec{Summary}{

\bits
\item Trying to prove $\sf P \land Q$? Look for a proof of $\sf P$,
  then for a proof of $\sf Q$ ($\land$Intro).
\item Split up conjunctions ($\land$Elim) whenever you can.
\item Next, use the disjunctions you have ($\lor$Elim).
\item Trying to prove $\sf\neg P$? Look for a subproof of $\bot$ from
  $\sf P$ ($\neg$Intro).
\item Trying to prove $\sf P \lor Q$?  Look for a proof of $\sf P$, if
  that doesn't work, look for a proof of $\sf Q$ ($\lor$Intro). If
  that doesn't work either, use indirect proof.  (Note: $\lor$Intro
  rarely works unless you're in a subproof.)
\item Apply the strategies at each step in the construction of your
  proof. You may not be able to prove $\sf P \lor Q$ using $\lor$Intro
  at one point, but then you might find yourself in a subproof where
  it is possible.
\eit
}

\subsec{Summary}{
\bits
\item It's good to know where you're going: So use the strategies
  based on $\land$Intro, $\lor$Elim, $\neg$Intro before those based on
  $\land$Elim and $\lor$Intro.
\item Picking a disjunct to prove for $\lor$Intro or a candidate for a
  contradiction doesn't always work. If it doesn't, you have to
  backtrack and try something else.
\item If you're looking for a proof of $\sf P$ and you're not getting
  anywhere, make sure you're on the right track: is $\sf P$ even a
  tautological consequence of the premises and assumptions? If not,
  you'll have to backtrack.
\end{itemize}

}

\section{Examples}

\setlength{\fitchprfwidth}{1.4in}

\subsec{An Example}{

\begin{tabular}{@{}p{13em}@{}p{13em}}
\fitchprf{
   \pline[1.]{(A \land B) \lor (A \land C)}
}{
 \pline{}\\
\pline{} \\
\pline{}\\
\ellipsesline \\[.7em]
  \pline{A \land (B \lor C)}[\hphantom{\lore{1}{2--5}{6--9}}]
}
  &
First, we use the disjunction on line 1, and set up the subproofs we
need for $\lor$Elim.
\end{tabular}

}
\subsec{An Example}{

\begin{tabular}{@{}p{13em}@{}p{13em}}
\fitchprf{
   \pline[1.]{(A \land B) \lor (A \land C)}
}{
\subproof{\pline[2.]{A \land B}}{
\ellipsesline \\
  \pline[6.]{A \land (B \lor C)}}\\[.5ex]
\subproof{\pline[7.]{A \land C}}{
\ellipsesline \\
  \pline[11.]{A \land (B \lor C)}}
  \pline{A \land (B \lor C)}[\lore{1}{2--6}{7--11}]
}
  &
In the first subproof, we now set up the sub goals for proving line 6
using $\land$Intro.
\end{tabular}

}
\subsec{An Example}{

\begin{tabular}{@{}p{13em}@{}p{13em}}
\fitchprf{
   \pline[1.]{(A \land B) \lor (A \land C)}
}{
\subproof{\pline[2.]{A \land B}}{
\ellipsesline \\
  \pline[4.]{A}\\
  \pline[5.]{B \lor C}\\
  \pline[6.]{A \land (B \lor C)}[\landi{4, 5}]}\\[.5ex]
\subproof{\pline[7.]{A \land C}}{
  \ellipsesline \\
  \pline[11.]{A \land (B \lor C)}}
\pline{A \land (B \lor C)}[\lore{1}{2--6}{7--11}]
}
  &
We immediately see that we get line 4 from 2 by $\land$Elim; let's
apply the strategy for proving disjunctions to line 5: look for a
proof of $\sf B$.
\end{tabular}

}
\subsec{An Example}{

\begin{tabular}{@{}p{13em}@{}p{13em}}
\fitchprf{
   \pline[1.]{(A \land B) \lor (A \land C)}
}{
\subproof{\pline[2.]{A \land B}}{
  \pline[3.]{B}\\
  \pline[4.]{A}[\lande{2}]\\
  \pline[5.]{B \lor C}[\lori{3}]\\
  \pline[6.]{A \land (B \lor C)}[\landi{4, 5}]}\\[.5ex]
\subproof{\pline[7.]{A \land C}}{
\ellipsesline \\
  \pline[11.]{A \land (B \lor C)}}
  \pline[12.]{A \land (B \lor C)}[\lore{1}{2--6}{7--11}]
}
  &
Like line 4 before, we get line 3 from 2 by $\land$Elim. That's it for
the first subproof. The second subproof is exactly the same.
\end{tabular}

}
\subsec{An Example}{

\begin{tabular}{@{}p{13em}@{}p{13em}}
\fitchprf{
   \pline[1.]{(A \land B) \lor (A \land C)}
}{
\subproof{\pline[2.]{A \land B}}{
  \pline[3.]{B}[\lande{2}]\\
  \pline[4.]{A}[\lande{2}]\\
  \pline[5.]{B \lor C}[\lori{3}]\\
  \pline[6.]{A \land (B \lor C)}[\landi{4, 5}]}\\[.5ex]
\subproof{\pline[7.]{A \land C}}{
  \pline[8.]{C}[\lande{7}]\\
  \pline[9.]{A}[\lande{7}]\\
  \pline[10.]{B \lor C}[\lori{8}]\\
  \pline[11.]{A \land (B \lor C)}[\landi{9, 10}]}
  \pline[12.]{A \land (B \lor C)}[\lore{1}{2--6}{7--11}]
}
  &
\end{tabular}

}

\setlength{\fitchprfwidth}{1.2in}

\subsec{Example Indirect Proof}{

\begin{tabular}{@{}p{14em}@{}p{12em}}
\fitchprf{\pline[1.]{}}{
\subproof{\pline[2.]{\neg (P \lor \lnot P)}}{
\ellipsesline\\
\pline[8.]{\bot}[\lfalsei{2}{7}]}
\pline[9.]{P \lor \neg P}[\lnoti{2--8}]
}
&
Suppose we want to prove $\sf P \lor \neg P$.  A little reflection
shows that this can only be done by indirect proof.  So we set up a subproof
for use with $\neg$Intro.
\end{tabular}

}

\subsec{Example Indirect Proof}{

\begin{tabular}{@{}p{14em}p{12em}}
\fitchprf{\pline[1.]{}}{
\subproof{\pline[2.]{\neg (P \lor \lnot P)}}{
\ellipsesline\\
\pline[7.]{P \lor \neg P}[?]\\
\pline[8.]{\bot}[\lfalsei{2}{7}]}
\pline[9.]{P \lor \neg P}[\lnoti{2--8}]
}
&
Our first candidate for a contradiction is the assumption of the
subproof.  How should we get $\sf P \lor \neg P$ inside that
subproof?
\end{tabular}

}
\subsec{Example Indirect Proof}{

\begin{tabular}{@{}p{14em}p{12em}}
\fitchprf{\pline[1.]{}}{
\subproof{\pline[2.]{\neg (P \lor \lnot P)}}{
\subproof{\pline[3.]{P}}{
\ellipsesline\\
\pline[5.]{\bot}[?]
}
\pline[6.]{\neg P}[\lnoti{3--5}]\\
\pline[7.]{P \lor \neg P}[\lori{6}]\\
\pline[8.]{\bot}[\lfalsei{2}{7}]}
\pline[9.]{P \lor \neg P}[\lnoti{2--8}]
}
&
Inside the subproof, we \emph{can} get $\sf P \lor \neg P$ by
$\lor$Intro. So let's try to prove $\sf \neg P$; it's a negated
sentence, so we'll use $\neg$Intro.
\end{tabular}

}
\subsec{Example Indirect Proof}{

\begin{tabular}{@{}p{14em}p{12em}}
\fitchprf{\pline[1.]{}}{
\subproof{\pline[2.]{\neg (P \lor \lnot P)}}{
\subproof{\pline[3.]{P}}{
\pline[4.]{P \lor \neg P}[\lori{3}]\\
\pline[5.]{\bot}[\lfalsei{2}{4}]
}
\pline[6.]{\neg P}[\lnoti{3--5}]\\
\pline[7.]{P \lor \neg P}[\lori{6}]\\
\pline[8.]{\bot}[\lfalsei{2}{7}]}
\pline[9.]{P \lor \neg P}[\lnoti{2--8}]
}
&
Here, the assumption of the subproof, $\sf P$, is not
really a good candidate for a negation. But we can use the negated
sentence on line 2 again, and it's easy to get in this situation.
\end{tabular}

}

\section{A Logic Puzzle}

\subsec{A Logic Puzzle}{

\bit
\item Every card has a letter on one side and a number on the other side
\item You're a card inspector tasked with making sure that cards satisfy this quality standard:
\begin{quote}
If a card has an even number on one side, then it has a vowel on the other.
\end{quote}
\eit

}

\subsec{A Logic Puzzle}{

Which card(s) do you have to turn over to make sure that:
\begin{quote}
If a card has an even number on one side, then it has a vowel on the other.
\end{quote}

\begin{tabular}{cccc}
\begin{beamerboxesrounded}[width=4em]{}
\vskip 2ex
\hfil \Large E\hfil\\
\end{beamerboxesrounded} &
\begin{beamerboxesrounded}[width=4em]{}
\vskip 2ex
\hfil \Large K\hfil\\
\end{beamerboxesrounded} &
\begin{beamerboxesrounded}[width=4em]{}
\vskip 2ex
\hfil \Large 3\hfil\\
\end{beamerboxesrounded} &
\begin{beamerboxesrounded}[width=4em]{}
\vskip 2ex
\hfil \Large 4\hfil\\
\end{beamerboxesrounded} \\
(1) & (2) & (3) & (4)
\end{tabular}

}

\subsec{Another Logic Puzzle}{

\bit
\item At an all-ages event where everyone has a drink
\item You know how old some of the people are, and you can tell what some of them are drinking
\item You're tasked with making sure that the following rule is followed:
\begin{quote}
If a person is drinking alcohol, then they must be at least 18 years old.
\end{quote}
\eit

}
\subsec{Another Logic Puzzle}{

Which of these people do you have to check (age or drink) to ensure that:
\begin{quote}
If a person is drinking alcohol, then they must be at least 18 years old
\end{quote}

\begin{tabular}{cccc}
\begin{beamerboxesrounded}[width=4em]{}
\vskip 2ex
\Large 22 years\\
\end{beamerboxesrounded} &
\begin{beamerboxesrounded}[width=4em]{}
\vskip 2ex
\Large 16 years\\
\end{beamerboxesrounded} &
\begin{beamerboxesrounded}[width=4em]{}
\vskip 2ex
\Large drinks pop\\
\end{beamerboxesrounded} &
\begin{beamerboxesrounded}[width=4em]{}
\vskip 2ex
\Large drinks beer\\
\end{beamerboxesrounded} \\
(1) & (2) & (3) & (4)
\end{tabular}

}

\end{document}


\documentclass[english, 11pt]{article}
\usepackage{notes}

% Uncomment these for a different family of fonts
% \usepackage{cmbright}
% \renewcommand{\sfdefault}{cmss}
% \renewcommand{\familydefault}{\sfdefault}

\newcommand{\thiscoursecode}{[Math 131]}
\newcommand{\thiscoursename}{Topology I}
\newcommand{\thisprof}{Luis Antonio Perez}
\newcommand{\me}{Liam Horne}
\newcommand{\thisterm}{Fall 2015}
\newcommand{\website}{kandluis.github.io/lperez}

% Headers
\chead{\thiscoursename \ Course Notes}
\lhead{\thisterm}

%%%%%% TITLE %%%%%%
\newcommand{\notefront} {
\begin{center}

{\ttfamily \url{\website}} {\small}

\textbf{\Huge{\noun{\thiscoursecode}}}{\Huge \par}

{\large{\noun{\thiscoursename}}}\\ \vspace{0.1in}

  {\noun \thisprof} \ $\bullet$ \ {\noun \thisterm} \ $\bullet$ \ {\noun {Harvard University}} \\

  \end{center}
  }

% Begin Document
\begin{document}

  % Notes front
  \notefront
   % Abstract
  \doabstract{This lecture is intended as an introduction to Baire spaces, and in particular, has as goal an explanation of the Baire category theorem. The lectures notes are to be self-contained and completely explanatory. If you find anything missing and wish to express your concern, please contact \href{mailto:luisperez@college.harvard.edu}{Luis Perez}. However, some basic understanding of metric spaces is assumed. If more is needed, UC Davis has a good online resource \cite{metric_spaces}. Some basic familiarity with elementary topology is also assumed.

  For reference, I now state the main theorem proved in this lecture. I suggest a close reading of the theorem will be helpful, as well as keeping in mind the ultimate goal of the lecture: to prove the theorem.

  Now, our goal will be to understand the following, fundamental theorem in topology.
  \begin{thrm}
  \label{thrm:baire}
  If $X$ is a \textit{compact Hausdorff space} or a \textit{complete metric space}, then $X$ is a \textit{Baire space}.
  \end{thrm}

  In order to do this, the outline is as follows:
  \begin{enumerate}
    \item Review metric spaces and distance functions.
    \item Explore dense sets and nowhere dense sets.
    \item Explore complete metric spaces.
    \item Define a Baire Space.
    \item Bring everything together and proof Theorem \ref{thrm:baire}.
    \item Do a sample problem to test understanding of the theorem.
  \end{enumerate}
  }
  \pagenumbering{roman}
  % Table of Contents and List of Figures
  \tocandfigures

  \pagenumbering{arabic}

  \section{Review of Metric spaces}
  We'll do a little bit of review first to make sure everyone is on the same page. First, let's start broad, with a space $X$. The point of this lecture is to gives properties of this space $X$ that show it is a Baire Space. The important fact to remember, at the end of the day, is that most spaces we've studied thus far are in fact Baire spaces! This will all become clear as the lecture continues.\\

  First, what's a metric space? Well, a metric space is a \textit{topological space} whose open sets are defined by a \textit{distance function} $d: X \times X \to \mathbb{R}$ which takes as input any two elements $x_1,x_1 \in X$ and returns the \textit{distance} between them (as a real-valued number). I present a few examples below. Formally, see Definition \ref{def:distance_metic}. \\

  \begin{exmp}
  \label{exmp:eucledian}
  For some intuition, let $X = \mathbb{R}^2$ and we take $d$ to the standard Euclidean distance defined for $x,y \in \mathbb{R}^2$ as
  $$
  d(x,y) = \sqrt{(y_1 - x_1)^2 + (y_2 - x_2)^2}
  $$
  The above fits comfortably with our standard intuition of \textit{distance}.\\
  \end{exmp}
  \begin{exmp}
  Another possible metric is the bounded metric. Let $d$ be a metric on the space $X$. The goal is to create a new metric $d'$ such that it is bounded. In particular, we will have $d'(x,y) < M$ for all $x,y \in X$.
  $$
  d'(x,y) = \frac{Md(x,y)}{1 + d(x,y)}
  $$
  This metric is important because it allows us to bound a distance! Typically, $M = 1$.
  \end{exmp}
  \begin{exmp}
  Another trivial example that is typically reference is the \textit{discrete} metric. This is defined as:
  \[
  d(x,y) =
  \begin{cases}
    1 & x \neq y \\
    0 & \text{ otherwise}
  \end{cases}
  \]
  \end{exmp}

  As this is review, I hope everyone recalls the properties of a \textit{distance metric}. For review, I restate them below, but this should be something with which you're already familiar. If not, you can take a look at previous lectures, the textbook \cite{topology_book}, or this short paper on metric spaces from UC Davis \cite{metric_spaces}.
  Recall the following definition of \textit{distance metric}.

  \begin{defn}[Distance Metric]
  \label{def:distance_metic}
    The function $d: X \times X \to \mathbb{R}$ is a \textit{distance metric} on the space $X$ if it satisfies the following properties for all pairs of points points $x_1,x_2 \in X$ and point $x_3 \in X$:
    \begin{align*}
      d(x_1,x_2) &\geq 0 \tag{positivity} \\
      d(x_1,x_2) &= 0 \iff x_1 = x_2 \tag{equality of points} \\
      d(x_1,x_2) &= d(x_2,x_1) \tag{symmetry} \\
      d(x_1,x_2) &\leq d(x_1,x_3) + d(x_3, x_2) \tag{triangle inequality}
    \end{align*}
  \end{defn}
  The one most often difficult to prove being the last!

  \section{Dense and Nowhere Dense Sets}
  Now for the new material! Sets are always at the foundation of mathematics, so we'll take a small detour to explain what I mean in lecture when a say a set $A$ is \textit{dense} in $X$ (here, $A$ is a subset of $X$ and $X$ is a space). Formally, Definition \ref{def:dense} is what we'll run with, but note that there are many alternative notions of \textit{denseness}. I suggest a quick perusal of Wikipedia \cite{wikipedia:dense_set} if questions are left unanswered.

  \begin{defn}
  \label{def:dense}
  In topology, we say that a subset $A$ of a space $X$ is \textit{dense} (in $X$) if any point $x \in X$ either belongs to $A$ or is a limit point of $A$.
  \end{defn}
  Recalling the definition of limit point, we can think of it in this way. To start, $A$ is a subset of $X$, so it's a sub-collection of points from the space (it could be the entire space, but generally, we want it to be a proper subset). The interesting property about the space $A$ is that if we take all the limit points (ie, we take a points to which all possible sequences $\{a_n\}$ from points within $A$ converge as $n \to \infty$) and add them to $A$, we will have every point from $X$. Now for a simple example:

  \begin{exmp}
  Is the empty set dense (in any space $X$)? Well, let us assume that the space $X$ is non-empty. Then the empty set is not dense in any such space. If $X$ is non-empty, then $\exists x \in X$, but $x \notin \emptyset$. Furthermore, note that the limit points of the empty set is the empty set.
  \end{exmp}

  The above idea of taking $A$ and adding the limit points should ring a bell. This is, in fact, the definition of the \textit{closure} of $A$. Therefore, we have Definition \ref{def:dense2}.

  \begin{defn}
  \label{def:dense2}
  We can also say that $A \subset X$ is a dense subspace of $X$ if $\bar{A} = X$ where $\bar{A}$ is the \text{closure} of $A$ defined as $A \cup \{x \in X \mid x \text{ is a limit point of } A\}$.
  \end{defn}

  \begin{rem}
  Note that above we discuss only $A$ in terms of sets. However, if we endow $A$ with the inherited topology from the space $X$, then $A$ will become a dense topological space! For more information on the inherited topology from $X$, take a look at Munkres \cite{topology_book}.
  \end{rem}

  What are some more non-trivial examples of dense sets? We cover a few examples now, but for more I suggest Wikipedia \cite{wikipedia:dense_set} or Math Overflow \cite{overflow:dense_sets}.

  \begin{exmp}
  Let us consider $X = \mathbb{R}$ because we have good intuition about real numbers. Then I claim that $\mathbb{Q}$ is dense in $\mathbb{R}$. That is to say, the set of rational numbers is dense in the set of real numbers. This is because, as we learned in previous lectures, $\bar{\mathbb{Q}} = \mathbb{R}$. The real numbers are simply the closure of the rational numbers! For a more thorough explanation of this result, you can take a Dedekind Cuts by Rich Schwartz \cite{dedekind_cuts}.
  \end{exmp}

  \begin{exmp}
  Even more interesting, take the set $\mathbb{R} \setminus \mathbb{Q}$ (the set of irrational numbers)! Note that this set is also dense in $\mathbb{R}$. This is because any real number either is irrational, or can be a approximated by a sequence of irrational numbers which converge to a rational number $q$. What might this sequence look like? Take an $q \in \mathbb{Q}$, and simply create the sequence $x_n = q + \frac{1}{n}\pi$ for $n \in \mathbb{N}$. Note that $\frac{pi}{n}$ is always irrational (see Proposition \ref{prop:pi_n_irrational} for a proof) for all $n > 1$. Furthermore, recall that the sum of a rational and irrational number is irrational (See Proposition \ref{prop:sum_rational_irrational} for a short proof). However, it's clear that as $n \to \infty$, $x_n \to q$. Therefore, $\{x_n\}$ has $q$ as a limit point, and yet $\{x_n\} \subset \mathbb{R} \setminus \mathbb{Q}$ by construction.
  \end{exmp}

  So in general, we have a good understanding of \text{dense} sets. Intuitively, we can image that a set $A$ is dense in $X$ if it is somehow very tightly packed within $X$. In fact, it is so tightly packed that even if you pick a point $x \in X$ where $x \notin A$, no matter how little you wiggle about the point $x$, you'll always bump into a point from $A$!\\

  There's another concept associated with dense sets that we need to consider. The concept is of a set being \textit{nowhere dense}. We now give a formal definition of this concept:

  \begin{defn}
  \label{def:nowhere_dense}
  A set $A$ is set to be nowhere dense if the interior of $\bar{A}$ is the empty set.
  \end{defn}

  Intuitively, nowhere dense is the opposite of dense. What do we mean by this? Well, if a dense set is one that is very, very tightly packed within the space $X$, then a nowhere dense set is a space that is everywhere very ``loosely'' packed within the state. In a sense, it means that the elements of $A$ (where $A$ is nowhere dense) are not very tightly clustered. Let's look at some easy examples to try and get an understanding of how this works.

  \begin{exmp}
   The set of integers $\mathbb{Z}$ is nowhere dense in $\mathbb{R}$. Note that $\mathbb{Z}$ is already closed, and if we look at the interior, it is empty. All points individually form the boundary of our interior. There are no points ``inside'' the set. Every point is close to the complement of the $\mathbb{Z}$. The intuition here is relatively straight forward. The points aren't very tightly ``packed'' despite the fact that there are infinitely many of them. For any two distinct points in $\mathbb{Z}$, the distance between then is at least $1$.
  \end{exmp}

  \begin{exmp}
  \label{exmp:nowhere_close}
  For a more complicated example, consider the set defined as
  $$
    S = \{ \frac{1}{n} \mid n \in \mathbb{N} \}
  $$
  Is this set nowhere dense? The answer is yes. The first question to answer is what is $\bar{S}$. In this case, we have $\bar{S} = S + \{0\}$ since $0$ is the limit point of the sequence $x_n = \frac{1}{n}$. However, again, this set $\bar{S}$ has an empty interior. Therefore, $S$ is nowhere dense.
  \end{exmp}

  To try to get a better understanding of \textit{nowhere dense} sets and their relation to \text{dense sets}, we now discuss a couple of properties.\\

  \begin{enumerate}
    \item Take note that a nowhere dense set does not need to be a closed set. We've already given an example of this in Example \ref{exmp:nowhere_close}. In particular, note that, almost immediately from Definition \ref{def:nowhere_dense}, we know that a set $A$ is nowhere dense if and only if the closure, $\bar{A}$, is nowhere dense.
    \item The complement of a closed nowhere dense set is a dense open set. This also implies that the complement of a nowhere dense set is a set with a dense interior!
    \item The boundary of every open set is closed and nowhere dense.
  \end{enumerate}

  To summarize, an dense set is a tightly packed set, and nowhere dense set is a set where no part of it is tightly packed! Well, that's the intuition you can walk away with, but you need to know the formal definitions above too!

  \begin{rem}
  One really cool example of nowhere dense set is the Cantor Set \cite{cantor_set}. The reason this is cool is because, if you remember from a previous homework assignment, it turns out that the Cantor Set is a set with positive measure (uncountable cardinality!). However, it is no-where dense. Using Definition \ref{def:nowhere_dense}, this is immediately obvious. The Cantor Set is closed, and consists of disjoint points, therefore its interior is the empty set! Look over your homework assignment if this is still unclear.
  \end{rem}

  \section{Complete Metric spaces}
  As we can see from Theorem \ref{thrm:baire}, before we can understand Baire spaces, we must understand complete metric spaces. I assume everyone is already familiar with both definitions of  \textit{compactness} (Heine-Borel) and of a \textit{Hausdorff} space. \\

  Before I can tackle metric spaces, we need to consider something called \textit{Cauchy sequences}. For the visual learners, take a look at Figure \ref{fig:cauchy_sequence} when reading the definition to make sure you understand it!

  \begin{defn}
  \label{def:cauchy_sequence}
  Let $(X,d)$ be a metric space. We consider a sequence $\{x_n\} \subset X$ to be a \textit{Cauchy sequence} if for every $\epsilon > 0$, there is an $n \in \mathbb{N}$ such that $d(x_l, x_m) < \epsilon$ for all $l,m > n$.
  \end{defn}

  \begin{figure}
    \centering
    \includegraphics[scale=0.5]{converge.png}
    \caption{An example of a Cauchy Sequence.}
    \label{fig:cauchy_sequence}
  \end{figure}

  What exactly does the above say? Well, in a sense, it says that a Cauchy sequence consists of elements in a metric space that, as the sequence continue, get closer and closer to each other. The first thing to note is that if we have a sequence in our metric space which converges, then the sequence is Cauchy \cite{complete_metric_spaces}. \\

  However, note that a Cauchy sequence need NOT be a convergent sequence!

  \begin{exmp}
  \label{exmp:not_complete}
  For example, take the metric space $X = (0,1]$ with the standard metric and consider the sequence $\{x_n\} \subset X$ given by $x_n = \frac{1}{n}$. While the sequence is Cauchy, the sequence does \textit{not} converge in the space $X$.
  \end{exmp}

  The above motivates the following question: When does Cauchy convergence imply convergence of the sequence? Well, every metric space $X$ will have some Cauchy sequences. If we can prove that all of those Cauchy sequences converge in the space, then we'll have solved the above. This is the reason we have what is called a \textit{complete metric space}.

  \begin{defn}
  A metric space $(X,d)$ is said to be \textit{complete} if it fulfills the above discussed conditions. That is to say, for any Cauchy sequence $\{x_n\} \subset X$, $x_n$ converges in $X$ (ie, converge to a point in $X$).
  \end{defn}

  Now for some examples of complete metric spaces:
  \begin{exmp}
  \label{exmp:rn_complete_metric_space}
  $\mathbb{R}^n$ with the standard metric is a complete metric space. Professor Cliffe Taubes showed this in Lecture 10. Please see the notes \href{https://canvas.harvard.edu/courses/4012/files/1066212/download?wrap=1}{here}. To refresh your memory, the argument had to do with representing each decimal as a decimal expansion!
  \end{exmp}

  We need one more thing about metric spaces before we can continue. For a metric space, we can define the \textit{diameter} of the metric space as follows.
  \begin{defn}
  \label{defn:diameter}
  Let $(X,d)$ be a metric space. Then the diameter of $X$ (noted as diam $X$), is given by:
  $$
    \text{diam } X = \sup \{d(x,y) : x,y \in X \}
  $$
  \end{defn}
  Definition \ref{defn:diameter} is essentially saying the the diameter of a metric space is the maximum distance any two points can be within that metric space. So, on the bounded metric, for any metric space, we know the diameter can be at most $M$. For $\mathbb{R}$ with the standard metric, the diameter is infinite. For Example \ref{exmp:not_complete}, the diameter is $1$ (here, note that because we take the supremum, we're considering the limit points of $X$ too, in a sense).\\

  In relation to metric spaces, we now present an interesting result which we will need later. Note that this is presented as Lemma 48.3 by Munkres \cite{topology_book}.

  \begin{lem}
    \label{lem:nested_sequence}
    Let $C_1 \supset C_2 \supset \cdots$ be a nested sequence of nonempty closed sets in the complete metric space $X$. If diam $C_n \to 0$, then $\bigcap C_n \neq \emptyset$.
  \end{lem}

  What is this saying, exactly? For reference, take a look at Figure \ref{fig:nested} while we discuss the main ideas behind the Proof (for a formal statement of the proof, see Munkres \cite{topology_book}).\\

  Let's simplify a bit and suppose the sets $C_k$ are actually intervals on the real line. The the image looks something like Figure \ref{fig:nested}, where each subsequence interval is ``nested'' within the previous intervals. We want to show that the intersection of all of these closed intervals is non-empty (ie, $\exists p \in \bigcap_i C_i$).\\

  \begin{figure}
  \centering
  \includegraphics[scale=0.7]{nested.png}
  \caption{Nested Intervals.}
  \label{fig:nested}
  \end{figure}

  What we can do is we can take advantage of the fact that the space is a complete metric space. First, let's try to construct a sequence using the sets that will converge to a specific point contained within all the sets (thereby showing the intersection is non-empty). Well, let's start by picking $x_n \in C_n$ (ie, we pick a point within each nested interval, and these points form our sequence). Notice, immediately, that $d(x_n,x_m) \to 0$ because the intervals are nested, therefore for large enough $N=\max\{n,m\}$, all points are contained within the interval $I_N$, and by assumption, diam $I_N \to 0$! \\

  Therefore, we have a Cauchy sequence. Now using the property that the space $(X,d)$ is a \textit{Complete} \textit{Metric} \textit{Space}, we conclude that this sequence must converge to some point $x_n \to x \in X$. However, note that $x \in \bar{C_k} = C_k$ because the subsequence $x_k \in C_k$ for all $k$. This implies our result!

  \section{Baire spaces}
  Now to the main point of our lecture! We've arrived at Baire spaces. We follow Munkres closely in our presentation, so if anything is confusing, please take some time to reference it \cite{topology_book}.

  \begin{defn}
  \label{defn:baire_space}
  A space $X$ is said to be a \textit{Baire Space} if given any countable collection $\{A_n\}$ of closed sets of $X$ each of which has an empty interior, their union $\bigcup_n A_n$ also has an empty interior in $X$.
  \end{defn}

  Another way to remember Definition \ref{defn:baire_space} is to think about it this way. Baire space ``preserve'' the interior under the operation of union. If all elements have an empty interior, their union has an empty interior. \\

  We can also rephrase the definition a bit to try to get a better understanding. Another way to think of a Baire space is as a space where, if we know that the union of countably subsets has a non-empty interior, then we know that \textit{at least} one of the sets in the union must have a non-empty interior.\\

  Using everything what we learned from Definition \ref{def:dense}, we can reformulate the definition above more succinctly as:
  \begin{defn}
  \label{defn:baire_closed}
  The interior of $\bigcup A_n$ where each $A_n$ is closed nowhere dense is empty.
  \end{defn}

  Even further, thought still equivalent, we can define a Baire space to be a space where:
  \begin{defn}
  \label{defn:baire_open}
  $\bigcap_n A_n$ is dense if all $A_n$ are dense open sets!
  \end{defn}

  Intuitively, Definition \ref{defn:baire_open} is the ``open'' way to define Baire spaces, and Definition \ref{defn:baire_closed} is the ``closed'' way to define Baire spaces. They are equivalent if we recall two facts discussed previously: (1) the complement of an open sets is a closed sets, and (2) the complement of nowhere dense set is a dense set.

  \section{Baire Category Theorem}
  Now that we have a firm grasp of Baire spaces, we can finally prove the Baire Category Theorem (if you would like to know where the term ``category'' comes from, check Munkres \cite{topology_book}).
  For reference, we now restate Theorem \ref{thrm:baire}.
  \begin{thrm}
    \label{thrm:baire2}
  If $X$ is a \textit{compact Hausdorff space} or a \textit{complete metric space}, then $X$ is a \textit{Baire space}.
  \end{thrm}

  \subsection{Compact Spaces}
  Before we can really understand the proof, though, we must first cover another, simpler theorem which has to do with the \textit{finite intersection} property of sets.
  \begin{defn}
  We'll say that a collection $C$ has the finite intersection property if for every finite sub-collection of $C$, the intersection of all of the sets in the sub-collection is non-empty.
  \end{defn}

  How can we think about this? Well, pictures are always worth more than words, so let's try to have a visual for this. We start with a collection of sets C. Imagine these as just a bunch of blobs in some space, for example. Then this collection has the finite intersection property if I can take any finite number of blobs, and they always overlap. Now, this doesn't mean that all of the blobs must overlap! \\

  The following theorem helps us relate the finite intersection property to compact spaces. For reference, recall Definition \ref{defn:compact_spaces}.

  \begin{defn}
  \label{defn:compact_spaces}
  A space $X$ is said to be compact if every open covering $A$ of $X$ contains a finite subcollection that also covers $X$.
  \end{defn}

  \begin{thrm}
  Let X be a topological space. Then X is compact if and only if for every collection C of closed sets in X having the finite-intersection property, the intersection over all elements in the collection is non-empty.
  \end{thrm}

  Instead of an open cover, we have a collection satisfying the finite intersection property. Instead of being able to find a finite sub-cover, we take the intersection and prove it is non-empty. Intuitively, this still measure how tightly packed a space is. Furthermore, we can see that this is similar to our previous understanding of compactness, but instead approaching it from a complementary view point. \\

  What are the steps to proof the above is equivalent to our previous theorem? Well, the two theorems are almost identical, we just have properties of open sets replaced with properties of closed sets. In fact, this gives us an inspiration. Why not just see if we can take complements?\\

  First, let's suppose we're given an arbitrary collection of sets closed sets $\mathcal{C}$ of $X$. Then take the collection consisting of the complements:
  $$
  \mathcal{A} = \{ X - C \mid C \in \mathcal{C}\}
  $$

  So now, we've gone from closed sets to open set! Fantastic. Well, our original theorem also considered open set covers of $X$. Well, you should notice that $\mathcal{A}$ is a covering of $X$ if and only if the intersection of all elements of $\mathcal{C}$ is empty. This follows almost directly from DeMorgan's law

  $$
  X - \bigcup_{\alpha \in J} A_{\alpha} = \bigcap (X - A_{\alpha})
  $$

  If we have a covering of $X$ by $\mathcal{A}$, then the LHS is the empty set. So then the intersection of $\mathcal{C}$ is empty! Intuitively, if you can cover the entire space with the the union of everything that's NOT in the collection $\mathcal{C}$, it must mean there's nothing shared by all the elements of $\mathcal{C}$!\\

  So, the above isn't too bad. However, our original theorem also talks about finite sub-covers. So, let's say there exists a finite sub-collection of $\mathcal{A}$. Then by the similar argument as above, the corresponding complements must share no elements.\\

  Therefore, we now have a way to go from open sets to closed sets, from open covers to empty infinite intersections, and from finite-sub-covers to finite, empty intersections!\\

  Let's revisit our new theorem of compactness. It says that $X$ is compact when ``Given any collection of closed sets, if every finite intersection of elements from this collection is non-empty, then the intersection of all elements is non-empty''. Using the interchangeability of closed and open sets, we can reword this equivalently by saying that ``Given any collection of open sets, if every finite sub-collection of these elements is NOT a cover of X, then the entire collection is NOT a cover''. Notice that we're just replacing the logical equivalents from above, and now we're so close to our original theorem!\\

  What's the last step? Well, the above is in the form $P \implies Q$, which is logically equivalent to $\lnot Q \implies \lnot P$, and this reads: $X$ is compact when ``Given a collection of open sets that covers X, then there is at least one finite sub-collection which also covers X''.\\

  \subsection{The Main Theorem}

  The key aspects of the theorem are the fact the space is either compact Hausdorff or a complete metric space! Why? Well, these types of spaces have very important properties that we can take advantage of to show that the union of sets with an empty interior also has an empty interior (here, we will use the ``open'' definition of a Baire space).
  \begin{enumerate}
    \item Regularity. We've shown before that all metric spaces are regular (see Proposition \ref{prop:metric_spaces_regular}), and the compact Hausdorff spaces are regular \cite{hausdorff_regular}! Regularity is important because we use it to construct a sequence of non-empty, nested sets disjoint from the sets in our union (similar to Urysohns Lemma).
    \item The countable intersection of non-empty, closed, nested sets is non-empty (where diam $C_n \to 0$ if we have a metric space)! We showed this for complete metric spaces in Lemma \ref{lem:nested_sequence}.
    \item We also know this to be the case for compact spaces in general, as discussed previously. Therefore, a sequence of non-empty, nested sets $\{C_n\}$ such that $C_0 \supset C_1, \cdots \supset C_i \cdots$ posses the finite intersection property \cite{finite_intersection}. Then, by compactness of the space $X$, the finite intersection property implies that the intersection must be non-empty. This is of utmost importance because it is what allows us to show the existence of a point in an open set but not in the union of our nowhere dense closed sets.
  \end{enumerate}

  As always, a picture is worth a thousand words, so take note of Figure \ref{fig:baire_category_theorem} while I explain the rest of the theorem.\\

  \begin{figure}
    \centering
    \includegraphics[angle=180,scale=0.2]{baire_theorem_image.jpg}
    \caption{Illustration of the idea behind the proof of Baire's Category Theorem.}
    \label{fig:baire_category_theorem}
  \end{figure}

  The main strategy for showing that the union has an empty interior is to show that the union contains \textbf{no} open sets (other than the empty set)! If the union doesn't contain open sets, then its interior is empty! How can we show an arbitrary open set $U_0$ isn't contained in $\bigcup_n A_n$ for some countable collection? Well, we can just show that there exists a point $p \in U_0$ where $p \notin \bigcup_n A_n$! \\

  We can show this by constructing a sequence of sets from each $A_n$:
  \begin{enumerate}
    \item The set $U_n$ is disjoint from $A_n$ (in fact, its closure is disjoint!). If we look at Figure \ref{fig:baire_category_theorem}, we see that each $U_1$ avoids $A_1$ and so on. We can do this because the space is regular and because the $A_n$ are closed. More formally:
    \begin{align*}
      \bar{U}_n \cap A_n = \emptyset \\
      \bar{U}_n \subset U_{n-1}
    \end{align*}
    Essentially, we can take a look at $U_{n-1}$ and choose a point $y \in U_{n-1}$ (the space is non-empty by induction). Then by regularity of $X$, we can find an open neighborhood of this point $y$ that does not intersect with $A_n$ because $A_n$ is closed (in fact, the closure of this set, call it $U_n$, does not intersect with $A_n$). Additionally, we can have $\bar{U}_n \subset U_{n-1}$ because $U_{n-1}$ is open and $X$ is regular (with additional condition that diam $U_n < \frac{1}{n}$ in the metric space case). These properties of regular spaces are discussed in Lemma 31.1 in Munkres \cite{topology_book}.
  \end{enumerate}

  If we have this sequence, we can then take advantage of the fact the space is compact Hausdorff and/or a complete metric space to claim that there exists a point $p \in \bigcap_n U_n \subset U_0$ which, by construction, is not in \textit{any} of the $A_n$ (thereby proving that the open set $U_0$ cannot be contained in $\bigcup_n A_n$). Figure \ref{fig:baire_category_theorem} makes this clear. As we've shown before, the intersection of all the sets we've created is contained in $U_0$, is non-empty, and does not intersect the union. Therefore, $U_0$ cannot be contained in $\bigcup_n A_n$, implying $\bigcup_n A_n$ has an empty interior.\\

  That's really all there is to it!

  \section{Sample Problem!}
  Now that we understand the theorem, let's try a sample problem. In particular, we'll tackle Problem 2 on page 299 of Munkres.

  \begin{exmp}
  The Baire Category Theorem implies that $\mathbb{R}$ cannot be written as a countable union of closed subsets having empty interiors. Show this fails if the sets are not required to be closed.
  \end{exmp}
  As we discussed in Example \ref{exmp:rn_complete_metric_space}, $\mathbb{R}$ is a complete metric space, therefore it is a Baire space, which implies that it cannot be written as a countable union of closer subsets having empty interiors.

  In the proof, it's obvious that we need the property that the sets are closed in order to create the sets $U_n$. So obviously, the proof we've given won't go through if we drop the closed set assumption.

  However, let's try to give an explicit example to this problem. What we can do, is we can actually consider the set of rational numbers $\mathbb{Q} = \{q_1,q_2, \cdots, q_n, \cdots\}$, and then create the sets that consists of the union of a single rational point with the irrational numbers:
  $$
  A_n = (\mathbb{R} \setminus \mathbb{Q} \cup \{q_n\})
  $$

  We can do this because it is clear that $\mathbb{R} = \bigcup_n A_n$. Furthermore, note that each $A_n$ has an empty interior! (no open interval contains only elements within each $A_n$), or another way to see it, is that $\R \setminus A_n = \Q - \{q_n\}$ is dense in $\R$. However, each $A_n$ is \textit{not} closed. In fact, the set is neither open nor closed, and therefore we can create them only because we've dropped the requirement that each $A_n$ should be closed.\\

  Thanks for coming to lecture! That's all :)

  \section{Appendix}
  In this section, I describe some more technical aspects quickly discussed in the lecture above.
  \begin{prop}
  \label{prop:pi_n_irrational}
  We want to show that $\forall n > 1$, $\frac{\pi}{n}$ is irrational. We do this by contradiction. Suppose it where the case that $\frac{\pi}{n}$ is rational. Then we can express $\frac{\pi}{n} = \frac{p}{q}$ where $p,q \in \mathbb{Z}$. Therefore, we can rearrange the above equation to have $\pi = \frac{np}{q} = \frac{p'}{q}$ where $p' \in \mathbb{Z}$. This is a contradiction on the fact that $\pi$ is irrational.
  \end{prop}

  \begin{prop}
  \label{prop:sum_rational_irrational}
  Let $x \in \mathbb{Q}$ and $y \in \mathbb{R} \setminus \mathbb{Q}$. Then we claim that $x + y \in \mathbb{R}\setminus \mathbb{Q}$. We prove this by contradiction. Suppose that $x + y \in \mathbb{Q}$, then we can express the sum as a fraction $x + y = \frac{p}{q}$ where $p,q \in \mathbb{Z}$ with $q \neq 0$. Then note that $x = \frac{p'}{q'}$ ($q' \neq 0$ because $x \in \mathbb{Q}$. Therefore, we have that:
  $$
  y = \frac{p}{q} - \frac{p'}{q'} = \frac{pq' - p'q}{pq'}
  $$
  Note that $pq' = p'q \in \mathbb{Z}$ and $pq' \in \mathbb{Q}$, therefore this is a contradiction on the fact that $y$ is irrational.
  \end{prop}

  \begin{prop}
  \label{prop:metric_spaces_regular}
  We proof that all metric spaces are normal, and therefore they are regular (as required by the Baire category theorem).\\
  Suppose we have two closed subsets $A,B$ of a metric spaces $(X,d)$. Then create the sets $U = \{x \in X \mid d(x,A) < d(x,B)\}$ and $V = \{x \in X \mid d(x,B) < d(x,A)\}$. Intuitively, the first is the set of points closer to $A$ than to $B$, and the second the set of points closer to $B$ then to $A$. By construction, $U,V$ are disjoint (strict inequality), each contain $A,B$ respectively, and are open.
  \end{prop}

\begin{thebibliography}{9}
\bibitem{topology_book}
\textit{Topology} by James. R Munkres, Second Edition

\bibitem{metric_spaces}
UC Davis: Metric spaces. Link: \href{https://www.math.ucdavis.edu/~hunter/m125a/intro_analysis_ch7.pdf}{https://www.math.ucdavis.edu/\~hunter/m125a/intro\_analysis\_ch7.pdf}

\bibitem{template}
Template used for these lecture notes can readily be found here: \href{https://github.com/snario/notes-template}{https://github.com/snario/notes-template}. Small modifications were made in the interest of clarity.

\bibitem{wikipedia:dense_set}
Dense Sets. Link: \href{https://en.wikipedia.org/wiki/Dense_set}{https://en.wikipedia.org/wiki/Dense\_set}

\bibitem{overflow:dense_sets}
Understanding the Definition of Dense Sets. Link: \href{http://math.stackexchange.com/questions/58709/understanding-the-definition-of-dense-sets}{http://math.stackexchange.com/questions/58709/understanding-the-definition-of-dense-sets}

\bibitem{dedekind_cuts}
Dedekinda Cuts by Rich Schwartz, \textit{Brown University}. Direct link: \href{http://www.math.brown.edu/~res/INF/handout3.pdf}{http://www.math.brown.edu/~res/INF/handout3.pdf}.

\bibitem{cantor_set}
Cantor Set. Link: \href{https://en.wikipedia.org/wiki/Cantor_set}{https://en.wikipedia.org/wiki/Cantor\_set}

\bibitem{complete_metric_spaces}
Complete Metric spaces. Link: \href{http://pioneer.netserv.chula.ac.th/~lwicharn/2301631/Complete.pdf}{http://pioneer.netserv.chula.ac.th/~lwicharn/2301631/Complete.pdf}

\bibitem{hausdorff_regular}
Compact Hausdorff Implies Normal. Link: \href{http://topospaces.subwiki.org/wiki/Compact_Hausdorff_implies_normal}{http://topospaces.subwiki.org/wiki/Compact\_Hausdorff\_implies\_normal}

\bibitem{finite_intersection}
Finite Intersection Property. Link: \href{https://en.wikipedia.org/wiki/Finite_intersection_property}{https://en.wikipedia.org/wiki/Finite\_intersection\_property}

\end{thebibliography}

  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  \end{document}


\documentclass[paper=a4, fontsize=11pt]{scrartcl}

\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{amsmath,amsfonts,amsthm}

\usepackage{lipsum}

\usepackage{graphicx}
\usepackage{float}
  \floatplacement{figure}{H}
  \floatplacement{table}{H}

\usepackage{sectsty}
\allsectionsfont{\centering \normalfont\scshape}

\usepackage{fancyhdr} % Custom headers and footers
\pagestyle{fancyplain} % Makes all pages in the document conform to the custom headers and footers
\fancyhead{} % No page header - if you want one, create it in the same way as the footers below
\fancyfoot[L]{} % Empty left footer
\fancyfoot[C]{} % Empty center footer
\fancyfoot[R]{\thepage} % Page numbering for right footer
\renewcommand{\headrulewidth}{0pt} % Remove header underlines
\renewcommand{\footrulewidth}{0pt} % Remove footer underlines
\setlength{\headheight}{13.6pt} % Customize the height of the header

\numberwithin{equation}{section} % Number equations within sections (i.e. 1.1, 1.2, 2.1, 2.2 instead of 1, 2, 3, 4)
\numberwithin{figure}{section} % Number figures within sections (i.e. 1.1, 1.2, 2.1, 2.2 instead of 1, 2, 3, 4)
\numberwithin{table}{section} % Number tables within sections (i.e. 1.1, 1.2, 2.1, 2.2 instead of 1, 2, 3, 4)

\setlength\parindent{0pt} % Removes all indentation from paragraphs - comment this line for an assignment with lots of text

%----------------------------------------------------------------------------------------
%	TITLE SECTION
%----------------------------------------------------------------------------------------

\newcommand{\horrule}[1]{\rule{\linewidth}{#1}} % Create horizontal rule command with 1 argument of height

\title{
\normalfont \normalsize
\textsc{Computational Science - ITB} \\ [25pt] % Your university, school and/or department name(s)
\horrule{0.5pt} \\[0.4cm] % Thin top horizontal rule
%\huge  Summary - Euler Method\\ % The assignment title
%\horrule{2pt} \\[0.5cm] % Thick bottom horizontal rule
}

\author{\small{Ridlo W. Wibowo || 20912009}} % Your name

\date{\normalsize\today} % Today's date or a custom date

\begin{document}

\maketitle % Print the title

\section{Summary - Euler Method}
Euler method is first order single-point method for solving ordinary differential equations (ODEs) with a given initial value (IV). It is the most bacic explicit method for numerical integration of ODEs and the simplest Runge-Kutta method. Although this method is too inaccurate to be of much practical value, it's useful to illustrate many concepts relevant to the finite difference solution of initial-value ODEs.
\\
Consider the general nonlinear first-order ODE:\\
\begin{equation}
\overline{y}' = f(t, \overline{y})  \hspace{2.0cm} \overline{y}(t_{0}) = \overline{y}_{0}
\end{equation}

From Taylor series:
\begin{equation}
\overline{y}_{n+1} = \overline{y}_{n} + \Delta t \overline{f}_{n} + \dfrac{1}{2} \overline{y}'' (\tau_{n}) \Delta t^{2} = \overline{y}_{n} + \Delta t \overline{f}_{n} + O(\Delta t^{2})
\end{equation}

Truncating the remainder term, which is $ O(\Delta t^{2}) $, and solving for $ y_{n+1} $ yields the \textit{explicit Euler} finite difference equation (FDE):
\begin{equation}
y_{n+1} = y_{n} + \Delta t f_{n}  \hspace{2cm} O(\Delta t^{2})
\end{equation}
where the $ O(\Delta t^{2}) $ term is included as a reminder of the order of the local truncation error.\\
Several features of above equation are summarized below:
\begin{enumerate}
\item The FDE is explicit, since $f_{n}$ does not depend on $y_{n+1}$.
\item The FDE requires only known point. Hence, it is a single point method.
\item The FDE requires only one derivative function evaluation [i.e. $f(t,y)$] per step.
\item The error in calculating $y_{n+1}$ for a single step, the local truncation error, is $O(\Delta t^{2})$.
\item The global (i.e. total) error accumulated after $N$ steps is $O(\Delta t)$.
\end{enumerate}

At the final point $t_{N}$:
\begin{equation}
y_{N} = y_{0} + \sum (y_{n+1} - y{n}) = y_{0} + \sum \Delta y_{n+1}
\end{equation}

and the total truncation error is given by,
\begin{equation}
\label{err}
Error = \sum \frac{1}{2} y'' (\tau_{n}) \Delta t^{2} = N \frac{1}{2} y'' (\tau) \Delta t^{2},
\end{equation}

where $t_{0} \leq \tau \leq t_{N}$, so the number of steps $N$ is related to the step size $\Delta t$ as follows:
\begin{equation}
\label{jum}
N = \frac{t_{N} - t_{0}}{\Delta t}
\end{equation}

Substituting \eqref{jum} to \eqref{err} yields:
\begin{equation}
Error = \frac{1}{2} (t_{N} - t_{0}) y'' (\tau) \Delta t = O \Delta t
\end{equation}
Consequently, the global (i.e. total) error of the \textit{explicit Euler} FDE is $O \Delta t$.
\\
\\
The other first-order single-point method for FDEs is \textit{implicit Euler} method. There are many second-order method from Euler method  which is generally called the modified Euler method. Runge-Kutta is fourth-order single-point method, and there are many higher order by modifying this method.

\begin{figure}
	\centering
	\includegraphics[width=0.8\textwidth]
		{eulerexplicit.png}
	\caption{Repetitive application of the explicit Euler method.}
	\label{fig:keplerian}
\end{figure}

\end{document}


\documentclass[12pt]{article}
\usepackage[usenames]{color} %used for font color
\usepackage{amsmath, amssymb, amsthm}
\usepackage{wasysym}
\usepackage[utf8]{inputenc} %useful to type directly diacritic characters
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{float}
\usepackage{mathtools}
\usepackage [english]{babel}
\usepackage [autostyle, english = american]{csquotes}
\MakeOuterQuote{"}
\graphicspath{ {./} }
\newcommand{\Z}{\mathbb{Z}}
\newcommand{\N}{\mathbb{N}}
\newcommand{\R}{\mathbb{R}}
\newcommand{\Q}{\mathbb{Q}}
\newcommand{\prob}{\mathbb{P}}
\newcommand{\M}{\mathcal{M}}
\newcommand{\degrees}{^{\circ}}
\DeclarePairedDelimiter\ceil{\lceil}{\rceil}
\DeclarePairedDelimiter\floor{\lfloor}{\rfloor}

\author{Tianshuang (Ethan) Qiu}
\begin{document}
\title{Math 74, Week 9}
\maketitle

\section{Mon Lec, 2}

\subsection{a}
Our monovariant is the sum of all the numbers. Consider $a = ka', b = kb', \gcd(a,b) = k, lcm(a,b) = ka'b'$ Then $a+b = k(a'+b'), \gcd(a,b) +lcm(a,b) = k(a'b'+1)$. $a'b' + 1$ will always be greater than or equal to $a' + b'$ for $a', b' > 0$, so it is nondecreasing.

\subsection{b}
The upperbound is the $nL$, where $n$ is the amount of numbers, and $L$ the product of all the numbers. Since $L$ is the largest number that can appear by this process, multiplying it by the amount of numbers gives an upperbound.

\subsection{c}
Our monovariant changes discretely, and it can change by at least 1 per turn. Since it is nondecreasing, it must stabilize at a value in this process.

\subsection{d}
When the monovariant stops changing, we have $a+b = \gcd(a,b) +lcm(a,b)$ therefore $a = \gcd(a,b), b = lcm(a,b)$ or vice versa. Therefore the game also stops.

\section{Mon Lec, 6}
Let our monovariant be the largest of all the numbers. Since we are replacing them with the absolute value of the differences, the sum can only get smaller. Furthermore, since it can only take discrete changes, it must stabilize at some point.
\newline
At this point, all the number must be $\M$ or 0. Otherwise, the game will take the difference and $\M$ will now be smaller. Now we rescale this to only have $1$ and $0$.
\newline
We now describe a new game: instead of taking the absolute value of the difference, we add the two adjacent numbers. Even though this appears to violate our monovariant, we notice that our new circle is, in fact, equivalent to the original game if we take every number modulo 2. This is true because $a+b = a-b \bmod 2$ Therefore we can directly compute the original game's state with our new game.
\newline
Now we notice that the new game has numbers around it according to Pascal's triangle. Since an even number at a position mean that the original game has a $0$ at the same position, we just need to find a row in Pascal's triangle that has 7 even numbers in the middle (the 8th comes from the edge $1$'s summing to 2). We find it at $8, 28,56,70,56,28,8,2$.
\newline
Note that this reasoning will apply to all $2^k$ initial settings, since the $n$th row of Pascal's triangle is $\binom{2^n}{k}$, which is even for $1<k<2^n$, and the ends sum to $2$.
\newpage

\section{Mon Dis, 1c}
We have shown in class that there can be at most 7 moves for each square. Therefore we construct the following square.
$$
\begin{bmatrix}
-2 & -1\\
-3 & -4
\end{bmatrix}
\to
\begin{bmatrix}
2 & 1\\
-3 & -4
\end{bmatrix}
\to
\begin{bmatrix}
-2 & 1\\
3 & -4
\end{bmatrix}
\to
\begin{bmatrix}
2 & -1\\
3 & -4
\end{bmatrix}
$$

$$
\to
\begin{bmatrix}
2 & -1\\
-3 & 4
\end{bmatrix}
\to
\begin{bmatrix}
-2 & -1\\
3 & 4
\end{bmatrix}
\to
\begin{bmatrix}
2 & 1\\
3 & 4
\end{bmatrix}
$$

\section{Mon Dis, 5}
\subsection{a}
Since $\phi>1$, $\lim_{m\to \infty} \phi^m = \infty$, thus the series diverges to $\infty$

\subsection{b}
Since $\phi>1$, we can apply the geometric series sum with r = $1/phi$:
$$\frac{1}{1-1/\phi} = \frac{1}{1-2/(1+\sqrt5)} = \frac{1}{(-1+\sqrt5)/(1+\sqrt5)} = \frac{1+\sqrt5}{\sqrt5-1} = \frac{(1+\sqrt5)(1+\sqrt5)}{(\sqrt5-1)(1+\sqrt5)}$$
$$=\frac{6+2\sqrt5}{4} = \frac{3+\sqrt5}{2}$$
Now consider $\phi^2$:
$$(\frac{1+\sqrt5}{2})^2 = \frac{6+2\sqrt5}{4} = \frac{3+\sqrt5}{2}$$
Thus we can see that they are equal.
\newpage

\section{Wed Lec, 5f}
The first boy has $n$ choices, and the second $n-1$, and so on. The last boy has $1$ choice since there is only one girl left. This gives a total of $n!$ possible configurations.
\newpage

\section{Fri Lec, 4d}
\subsection{$\sin(2\alpha)$}
From $e^{i\theta}=\cos(\theta)+i\sin(\theta)$ and $e^{-i\theta}=\cos(\theta)-i\sin(\theta)$,
we know that
$$\sin(\alpha)=\frac{e^{\alpha i}-e^{-\alpha i}}{2i}$$
$$\cos(\alpha)=\frac{e^{\alpha i}+e^{-\alpha i}}{2}$$
Now we multiply these to get:
$$\sin(\alpha)\cos(\alpha)=\frac{e^{2\alpha i}-e^{-2\alpha i}}{4i}$$
On the other side:
$$\sin(2\alpha)=\frac{e^{2\alpha i}-e^{-2\alpha i}}{2i}$$
Thus we can see that it is equal to $2\sin(\alpha)\cos(\alpha)$

\subsection{$\cos(2\alpha)$}

$$\cos(2\alpha)=\frac{e^{2\alpha i}+e^{-2\alpha i}}{2}$$
$$\cos^2(\alpha)=(\frac{e^{\alpha i}+e^{-\alpha i}}{2})^2 =
\frac{e^{2\alpha i}+e^{-2\alpha i}+2}{4}$$
$$\sin^2(\alpha)=(\frac{e^{\alpha i}-e^{-\alpha i}}{2i})^2=
\frac{e^{2\alpha i}+e^{2-\alpha i}-2}{-4}$$

$\cos^2(\alpha)-\sin^2(\alpha)$ removes the negative in -4, leading to $\frac{2(e^{2\alpha i}+e^{-2\alpha i})}{4}$, which simplifies to $\cos(2\alpha)$

\section{Fri Lec, 6}
\subsection{a}
Since we know that our nonagon is inscribed inside a unit circle, all complex points on our shape has length 1. Now using polar angles we know that each side has angle $\frac{2\pi}{9}$. Now we simply write each point as $\cos(2\pi j/9)+i\sin(2\pi j/9)$, using our equations, we know that it is equal to
$$\frac{e^{(2\pi j/9 )i}+e^{(-2\pi j/9)i}}{2}+\frac{e^{(2\pi j/9) i}-e^{(-2\pi j/9) i}}{2} = e^{(2\pi j/9) i}$$
Thus we have $A_j =  e^{2\pi  j i/9 }$

\subsection{b}
We calculate $z_1 = e^{2\pi i/9 }$, so $z_1^5 = e^{10\pi i/9 }$ Since we know that $e^{2\pi i}$ gets us back to $z_0$, this ends up at the same spot: $z_1$, since we can write $z_1^5 \equiv e^{1\pi i/9 }$ in our system (essentially modding 9).
\newline
Similarly, for $z_1^9$, we know that it is equal to $e^{2\pi i}=0$, so we are at $A_0$.
\end{document}