    \filetitle{acf}{Autocovariance and autocorrelation functions for VAR variables}{VAR/acf}

	\paragraph{Syntax}\label{syntax}

\begin{verbatim}
[C,R] = acf(V,...)
\end{verbatim}

\paragraph{Input arguments}\label{input-arguments}

\begin{itemize}
\itemsep1pt\parskip0pt\parsep0pt
\item
  \texttt{V} {[} VAR {]} - VAR object for which the ACF will be
  computed.
\end{itemize}

\paragraph{Output arguments}\label{output-arguments}

\begin{itemize}
\item
  \texttt{C} {[} namedmat \textbar{} numeric {]} - Auto/cross-covariance
  matrices.
\item
  \texttt{R} {[} namedmat \textbar{} numeric {]} -
  Auto/cross-correlation matrices.
\end{itemize}

\paragraph{Options}\label{options}

\begin{itemize}
\item
  \texttt{'applyTo='} {[} logical \textbar{} \emph{\texttt{Inf}} {]} -
  Logical index of variables to which the \texttt{'filter='} will be
  applied; the default Inf means all variables.
\item
  \texttt{'filter='} {[} char \textbar{} \emph{empty} {]} - Linear
  filter that is applied to variables specified by `applyto'.
\item
  \texttt{'matrixFmt='} {[} \emph{\texttt{'namedmat'}} \textbar{}
  \texttt{'plain'} {]} - Return matrices \texttt{C} and \texttt{R} as
  either \href{namedmat/Contents}{\texttt{namedmat}} objects
  (i.e.~matrices with named rows and columns) or plain numeric arrays.
\item
  \texttt{'nFreq='} {[} numeric \textbar{} \emph{\texttt{256}} {]} -
  Number of equally spaced frequencies over which the \texttt{'filter='}
  is numerically integrated.
\item
  \texttt{'order='} {[} numeric \textbar{} \emph{\texttt{0}} {]} - Order
  up to which ACF will be computed.
\item
  \texttt{'progress='} {[} \texttt{true} \textbar{}
  \emph{\texttt{false}} {]} - Display progress bar in the command
  window.
\end{itemize}

\paragraph{Description}\label{description}

\paragraph{Example}\label{example}


% !TEX root = ../00_thesis.tex

%-------------------------------------------------------------------------------
\section{Backgrounds on Statistics}
\label{sec:stats}
%-------------------------------------------------------------------------------

This section briefly discusses some background on statistics which is relevant to performance evaluation.

\fakepar{Descriptive and predictive statistics}
A statistic is a number computed from a data set using a mathematical formula.
A statistic can always be calculated and provides a factual description of the underlying data.
This is referred to as a \emph{descriptive statistic}.
However, certain statistics have also some \emph{inference} power; that is, based on the collected data, one may infer the shape of the underlying data distribution, which is unknown. These are referred to as \emph{predictive statistics}.

Predictions are always uncertain and often rely on certain hypotheses. If the hypotheses hold for the collected data, then the statistic estimates some property of the underlying distribution (\eg mean, median, \etc) with a quantifiable level of confidence. One can then predict the expected values of data samples that have not been collected.
One common hypothesis for predictive statistics is that the collected data is \emph{independent and identically distributed} (\iid); informally, this means that the underlying distribution of the data does not change and that successive data samples are not correlated.
It is also common to presume the \emph{nature of the data distribution} (\eg a normal or a Poisson distribution), which allows to make ``better'' predictions with less data.
It is paramount to keep in mind the hypotheses underlying a statistical prediction.

\begin{example}
  One can compute the mean $\mu$ and standard deviation $\sigma$ of a data sample.
  {If} the underlying data distribution is normal (the hypothesis), {then} we can infer that about 68\% of all data points (the distribution) will be contained in $\mu \pm \sigma$.
  However, \textbf{if the distribution is not normal, $\mu$ and $\sigma$ are only descriptive statistics};
  \ie they do not predict anything about the underlying data distribution.
\end{example}

\fakepar{Statistical methods}
Many common statistical methods assume Gaussian distributions (\ie normally distributed data).
However, literature reports that experimental data is rarely normal~\cite{maricq2018Taming,schmid2014measuring} and hence recommends using \emph{non-parametric statistics}; \ie statistics that do not make any assumption on the nature of probability distributions.
Furthermore, it is important to consider \emph{robust statistics}, \ie statistics that are not overly skewed by outliers (common in networking data).
There are two main classes of statistical approaches: hypothesis testing and estimation.
%
% \begin{itemize}
    %
    % \item
    \emph{Hypothesis testing} consists in formulating a so-called null hypothesis, that the test aims to reject. Based on the collected data, one computes the probability, called the \mbox{$p$-value}, that the null hypothesis is correct.
    If the \mbox{$p$-value} is sufficiently low, the null hypothesis is rejected and considered proven incorrect.
    %
    % \item
    \emph{Estimation} consists in computing confidence intervals (CIs) for a given parameter (\eg the median of a distribution).
    A CI is always associated a confidence level (\eg a 95\%~CI) which is the probability that the interval includes the true value of the parameter.
    For example, $[a,b]$ is a 95\%~CI for the median if the true median value is between $a$ and $b$ with 95\% probability (or better).
%
% \end{itemize}

CIs are more legible than $p$-values: ``\textit{CIs provide a mechanism for making statistical inferences that give information in units with practical meaning}''~\cite{cumming2001CI}.
Furthermore, the level of confidence of an estimation only depends on the sample size. In other words, estimations can be used to guide the experimental design. By setting the desired level of confidence, one defines the (minimal) number of samples required.
This is a key property that \triscale leverages.

\fakepar{Reproducibility is a predictive statistic}
Informally, reproducibility is the principle that the ``same experiment'' leads to the ``same results''. Thus, assessing reproducibility entails predicting that future data (\ie the results of a newly-performed experiment) will be the same as the known data (\ie the results of previously conducted experiments): this is a prediction.
Thus, assessing reproducibility requires making certain hypotheses on the data.
It is hence crucial to \emph{(i)~}choose statistics with hypotheses compatible with actual networking data, and to \emph{(ii)~}verify that the hypotheses do hold for the data that one collects.
To this end, \triscale makes use of non-parametric statistics and verifies that their hypotheses hold for the collected samples.


\section{Search Verbs}
\label{searchverbs}

In 1971, the author designed and implemented
linear-time or nearly-linear-time algorithms
for {\em indexof} ({\apl x\qiota\0y})
and {\em set membership} ({\apl x\qeps\0y}),
operating on most data types, on
SHARP APL.\cite{RBernecky:iota}

The Boolean cases of these search algorithms used vector search
instructions ({\tt TRT}, and later, {\tt CLCL}) to find the first
byte of interest, then used that byte as an index into a table,
to give the bit offset within that byte.

%%\medskip
%%\begin{tabular}{l}  % I have no idea what I was thinking here...
%%{\apl First0Tab\qlbr\qomega\qrbr}\\
%%{\apl First1Tab\qlbr\qomega\qrbr}\\
%%{\apl LZCNT\qlarrow\qlbr\qlpar\0uint64~\qalpha\qrpar\qiota\qomega\qrbr}\\
%%\end{tabular}
%%\medskip

Contemporary architectures with bit-level vector extensions
might better use a word-at-a-time search, then a left-zero-count
instruction (LZCNT) to count the
number of leading zeros.~\cite{INTEL:avx,AMD:instructions}

Our original algorithm did not support 64-bit floating point
data when comparison tolerance ({\apl \qQuad\0ct}), was non-zero, but
we later extended it to cover this missing case.


\pgfkeys{
	/pgfplots/complex plane/.style={
		axis x line=middle,
		axis y line=middle,
		xlabel=$\Re$,
		ylabel=$\Im$,
		every axis x label/.style={
			at={(ticklabel* cs:1.02)},
			anchor=west,
		},
		every axis y label/.style={
			at={(ticklabel* cs:1.02)},
			anchor=south,
		},
		axis line style={stealth-stealth, thick},
		label style={font=\large},
		tick label style={font=\large},
		samples=100,
		xmin=-3, xmax=3,
		ymin=-3, ymax=3,
		domain=-3:3,
		grid=both,
		major grid style={black!5},
	},
	/pgfplots/complex solution/.style={
		complex plane,
		width=6.5cm, height=6.5cm,
		xmin=-1.5, xmax=1.5,
		ymin=-1.5, ymax=1.5,
		xtick={-1.5,-1,...,1.5},
		xticklabels={},
		ytick={-1.5,-1,...,1.5},
		yticklabels={},
	},
}

\newcommand{\arcc}[3]{
	\draw[#3, fill=#3!20] (0,0) -- (#2,0) arc (0:#1:#2) -- cycle;
}

\newcommand{\cmplxsol}[1]{
	\coordinate (O) at (0,0);
	\draw[black!20] (1,0) arc (0:360:1);
	\pgfmathsetmacro{\dt}{360/#1}
	\pgfmathsetmacro{\n}{int(#1-1)}
	\pgfplotsinvokeforeach{\n,...,0}{
		\pgfmathparse{##1+1}
		\draw[xcol##1, fill=xcol##1!20] (O) -- ({0.1*##1},0) arc (0:{\dt*##1}:{0.1*##1}) -- cycle;
		\draw[very thick, xcol##1] (O) -- ({cos(\dt*##1)},{sin(\dt*##1)}) node[complex]{};
		\node[xcol##1, fill=xcol##1!10, rounded corners]  at ({1.23*cos(\dt*##1)},{1.23*sin(\dt*##1)}) {$z_{\the\numexpr##1+1\relax}$};
	}
}

\section{Complex Numbers}\label{sec:complex numbers}
\subsection{Algebraic approach}
Real numbers, while being extremely useful, are not complete - they can't solve all equations involving numbers. For example, the equation
\begin{equation}
	x^{2} + 1 = 0
	\label{eq:no_real_solutions}
\end{equation}
has no real solutions, since there can be no real number $x$ such that $x^{2}=-1$. However, we can choose to define a new number, $\iu=\sqrt{-1}$ and using it to build a new number system. This system is of course the set of complex numbers, $\mathbb{C}$. It is defined as the set of all $z$ such that
\begin{equation}
	z = a+\iu b,
	\label{eq:complex_number}
\end{equation}
where $a,b\in\mathbb{R}$ and $\iu=\sqrt{-1}$. We call $a$ the \emph{real component} of $z$ or $\Re(z)$, and $b$ its \emph{imaginary component} or $\Im(z)$\footnote{There is nothing more ``real'' about real numbers than imaginary numbers, but unfortunately that's the terminology we're stuck with \shrug}. These numbers appear a lot all throughout the exact sciences (but especially in physics and engineering), so we must at the very least learn their basic properties.

It is not so obvious that we can add two different kinds of numbers together, but it works (the linear algebra chapter sheds more light on this idea). What is important is that we always keep these two parts separated. We see this when we add together two complex numbers $z_{1},z_{2}$:
\begin{equation}
	z = z_{1}+z_{2} = \left( a_{1}+b_{1}\iu \right) + \left( a_{2}+b_{2}\iu \right) = \left( a_{1}+a_{2} \right) + \left( b_{1}+b_{2} \right)\iu.
	\label{eq:complex_addition}
\end{equation}
The real part of $z$ is therefore $a_{1}+b_{1}$, and its imaginary part is $b_{1}+b_{2}$.

What happens when we multiply two complex numbers? Let's check:
\begin{align}
	z = z_{1}z_{2} &= \left( a_{1}+b_{1}\iu \right)\left( a_{2}+b_{2}\iu \right)\nonumber\\
	&= a_{1}a_{2} + \iu a_{1}b_{2} + \iu a_{2}b_{1} + \iu^{2}b_{1}b_{2}\nonumber\\
	&= a_{1}a_{2} + \iu a_{1}b_{2} + \iu a_{2}b_{1} - b_{1}b_{2}\nonumber\\
	&= \left( a_{1}a_{2} - b_{1}b_{2} \right) + \iu\left( a_{1}b_{2} + a_{2}b_{1} \right).
	\label{eq:complex_product}
\end{align}
We see that we can still separate the real part and imaginary part of the result. What happens in the case of two real numbers? For real numbers $b=0$, and thus \autoref{eq:complex_product} devolves to $z=a_{1}a_{2}\in\mathbb{R}$, which is exactly what we expect: multiplying two real numbers yields their product, which is a real number. Notice that this doesn't happen with purely imaginary numbers: multiplying together two imaginary numbers (i.e. numbers for which $a=0$) results in a real number. Will get to understand why this happens very soon.

When discussing real numbers sometimes we like to refer to their \textit{magnitude}, i.e. their absolute value. With complex numbers this is defined as
\begin{equation}
	|z| = \sqrt{a^{2}+b^{2}},
	\label{eq:complex_magnitude}
\end{equation}
i.e. in a sense, to get the magnitude of a complex number we imagine its two components as being perpendicular and calculate the length of the resulting hypotenuse (cf.\ the Pythagorean theorem). In fact, this is one very useful interpretation of complex numbers, which we will explore in depth in the next subsection.

A very important operation that can be applied to complex numbers is \emph{conjugation}. The conjugate of a complex number $z=a+\iu b$ is defined as
\begin{equation}
	\conj{z} = a-\iu b,
	\label{eq:complex_conjugation}
\end{equation}
i.e. conjugating a number is simply negating its imaginary part. When we multiply a complex number by its own complex conjugate we get
\begin{equation}
	z\conj{z} = (a+\iu b)(a-\iu b) = a^{2} + \cancel{ab\iu}  - \cancel{ab\iu}  - b^{2}\iu^{2} = a^{2}+b^{2},
	\label{eq:conjugate_product}
\end{equation}
i.e. $z\conj{z} = |z|^{2}$. The inverse of a complex number can be expressed as
\begin{equation}
	z^{-1} = \frac{\conj{z}}{|z|^{2}}.
	\label{eq:complex_inverse}
\end{equation}

\subsection{Geometric approach}
As alluded to in the previous subsection, we can interpret a complex number $z=a+\iu b$ as two components in a 2-dimensional space (called the \emph{complex plane}), in which the horizontal axis represents real components, and the vertical access represents imaginary components:
\begin{figure}
	\centering
	\begin{tikzpicture}
		\tikzstyle{every node}=[font=\large]
		\pgfmathsetmacro{\a}{2}
		\pgfmathsetmacro{\b}{2.5}
		\pgfmathsetmacro{\t}{atan2(\b,\a)}
		\begin{axis}[
			complex plane,
			width=9cm, height=9cm,
			xtick={-3,-2.5,...,3},
			xticklabels={},
			extra x ticks={\a},
			extra x tick labels={$a$},
			ytick={-3,-2.5,...,3},
			yticklabels={},
			extra y ticks={\b},
			extra y tick labels={$b$},
		]
		\draw[very thick, xred] (0,0) -- node[midway, above, rotate=\t] {$|z|=\sqrt{a^{2}+b^{2}}$} (\a,\b) node[complex](zdot){};
		\node[xred, above of=zdot, yshift=-6mm] {$z=a+\iu b$};
		\end{axis}
	\end{tikzpicture}
	\caption{A complex number $z=a+\iu b$ shown on the complex plane: the horizontal and vertical axes represent the real and imaginary components, respectively.}
	\label{fig:complex number}
\end{figure}

Drawing a line from $z$ to $a$ (on the real axis) creates a right triangle. We can then define $\theta$ to be the angle near the origin and $r$ the length of the hypotenuse:
\begin{figure}
	\centering
	\begin{tikzpicture}
		\tikzstyle{every node}=[font=\large]
		\pgfmathsetmacro{\a}{2}
		\pgfmathsetmacro{\b}{2.5}
		\pgfmathsetmacro{\t}{atan2(\b,\a)}
		\begin{axis}[
			complex plane,
			width=9cm, height=9cm,
			xtick={-3,-2.5,...,3},
			xticklabels={},
			extra x ticks={\a},
			extra x tick labels={$a$},
			ytick={-3,-2.5,...,3},
			yticklabels={},
			extra y ticks={\b},
			extra y tick labels={$b$},
		]
		\draw[thick, dashed] (\a,\b) -- (\a,0);
		\draw[thick] ({\a-0.25},0) -- ({\a-0.25},0.25) -- (\a,0.25);
		\draw[very thick] (0.75,0) arc (0:\t:0.75);
		\node[] at ({cos(\t/2)},{sin(\t/2)}) {$\theta$};
		\draw[very thick, xred] (0,0) -- node[midway, above, rotate=\t] {$r$} (\a,\b) node[complex](zdot){};
		\node[xred, above of=zdot, yshift=-6mm] {$z$};
		\end{axis}
	\end{tikzpicture}
	\caption{The same complex number $z$ from \autoref{fig:complex number} shown with its polar components $r=|z|=\sqrt{a^{2}+b^{2}}$ and $\theta=\arctan\left( \frac{b}{a} \right)$.}
	\label{fig:complex number 2}
\end{figure}
We call $r$ the \emph{magnitude} of $z$, and $\theta$ its \emph{argument}. The ranges for $r$ and $\theta$ are, respectively, $[0,\infty)$ and $[0,2\pi)$.

Using \autoref{eq:xy_P} the real and imaginary components of $z$ are
\begin{align}
	a &= r\cos(\theta),\nonumber\\
	b &= r\sin(\theta),
	\label{eq:complex_components}
\end{align}
and $z$ can be re-written as
\begin{equation}
	z = r\left( \cos(\theta) + \iu\sin(\theta) \right).
	\label{eq:complex_geometric_form}
\end{equation}
Which we call the \emph{polar form} of $z$ (contrasted with $z=a+\iu b$ being the \emph{Cartesian form} of $z$).

Inverting the relations in \autoref{eq:complex_components} yields the relations
\begin{align}
	r &= a^{2}+b^{2},\nonumber\\
	\theta &= \arctan\left(\frac{b}{a}\right).
	\label{eq:complex_components_geometric}
\end{align}

Let's examine the same properties of complex numbers shown in Equations \ref{eq:complex_addition}, \ref{eq:complex_product} and \ref{eq:complex_conjugation}, and verify that they work in the polar form of complex numbers. We start with addition (\autoref{eq:complex_addition}):
\begin{align}
	z_{1}+z_{2} &= r_{1}\left[ \cos\left( \theta_{1} \right) + \iu\sin\left( \theta_{1} \right) \right] + r_{2}\left[ \cos\left( \theta_{2} \right) + \iu\sin\left( \theta_{2} \right) \right]\nonumber\\
	&= \underbrace{r_{1}\cos\left( \theta_{1} \right)}_{a_{1}} + \underbrace{r_{2}\cos\left( \theta_{2} \right)}_{a_{2}} + \iu\underbrace{r_{1}\sin\left( \theta_{1} \right)}_{b_{1}} + \iu\underbrace{r_{2}\sin\left( \theta_{2} \right)}_{b_{2}}\nonumber\\
&= \left( a_{1}+a_{2} \right) + \iu\left( b_{1}+b_{2} \right).
	\label{eq:complex_addition_geometric}
\end{align}
We see that indeed, the polar form of complex numbers adheres to the addition rule in \autoref{eq:complex_addition}. Next is the product rule:
\begin{align}
	z_{1}z_{2} &= r_{1}\left[ \cos\left(\theta_{1}\right) + \iu\sin\left(\theta_{1}\right) \right] \cdot r_{2}\left[ \cos\left(\theta_{2}\right) + \iu\sin\left(\theta_{2}\right) \right]\nonumber\\
	&= r_{1}r_{2}\left[ \cos\left( \theta_{1} \right)\cos\left( \theta_{2} \right) + \iu\cos\left( \theta_{1} \right)\sin\left( \theta_{2} \right) + \iu\sin\left( \theta_{1} \right)\cos\left( \theta_{2} \right) -\sin\left( \theta_{1} \right)\sin\left( \theta_{2} \right)  \right]\nonumber\\
	&= r_{1}\cos\left( \theta_{1} \right)r_{2}\cos\left( \theta_{2} \right) - r_{1}\sin\left( \theta_{1} \right)r_{2}\sin\left( \theta_{2} \right) + \iu\left[ r_{1}\cos\left( \theta_{1} \right)r_{2}\sin\left( \theta_{2} \right) + r_{1}\sin\left( \theta_{1} \right)r_{2}\cos\left( \theta_{2} \right) \right]\nonumber\\
	&= \left( a_{1}a_{2}-b_{1}b_{2} \right) + \iu\left( a_{1}b_{2} + a_{2}b_{1} \right),
	\label{eq:complex_product_geometric}
\end{align}
which is indeed the result seen in \autoref{eq:complex_product}. We can also develop further the second row of \autoref{eq:complex_product_geometric} using some trigonometry (specifically the trigonometric identities in \autoref{eq:trig product to sum}):
\begin{align}
	z_{1}z_{2} &= r_{1}r_{2}\left[ \cos\left( \theta_{1} \right)\cos\left( \theta_{2} \right) + \iu\cos\left( \theta_{1} \right)\sin\left( \theta_{2} \right) + \iu\sin\left( \theta_{1} \right)\cos\left( \theta_{2} \right) -\sin\left( \theta_{1} \right)\sin\left( \theta_{2} \right) \right]\nonumber\\
	&= r_{1}r_{2}\left[ \cos\left( \theta_{1} \right)\cos\left( \theta_{2} \right)-\sin\left( \theta_{1} \right)\sin\left( \theta_{2} \right) + i\left[ \cos\left( \theta_{1} \right)\sin\left( \theta_{2} \right) + \sin\left( \theta_{1} \right)\cos\left( \theta_{2} \right) \right] \right]\nonumber\\
	&= r_{1}r_{2}\left[ \cos\left( \theta_{1}+\theta_{2} \right) + \iu\sin\left( \theta_{1}+\theta_{2} \right)  \right].
	\label{eq:complex_product_geometric_insight}
\end{align}
This is a very important result: it shows that multiplying a complex number $z_{1}$ by another complex number $z_{2}$ gives a complex number with magnitude $r_{1}r_{2}$, i.e. the product of the magnitudes of the two complex numbers, and argument $\theta_{1}+\theta_{2}$, i.e. the argument of $z_{1}$ rotated by the argument of $z_{2}$ (or vice-versa). We will consider this result in more detail soon.

In the polar form the complex conjugate of a number $z=r\left[ \cos\left( \theta \right) + \iu\sin\left( \theta \right) \right]$ can be brought about by substituting $-\theta$ into the arguments of the trigonometric functions:
\begin{align}
	\conj{z} &= r\left[ \cos\left( -\theta \right) + \iu\sin\left( -\theta \right) \right]\nonumber\\
	&= r\left[ \cos\left( \theta \right) - \iu\sin\left( \theta \right) \right]\nonumber\\
	&= r\cos\left( \theta \right) - \iu r\sin\left( \theta \right)\nonumber\\
	&= a-\iu b.
	\label{eq:complex_conjugation_geometric}
\end{align}

Lastly, let's show that \autoref{eq:conjugate_product} can be derived in the polar form:
\begin{align}
	z\conj{z} &= r\left[ \cos\left( \theta \right) + \iu\sin\left( \theta \right) \right] \cdot r\left[ \cos\left( \theta \right) - \iu\sin\left( \theta \right) \right]\nonumber\\
	&= r^{2}\left[ \cos^{2}\left( \theta \right) -\cancel{\iu\cos\left( \theta \right)\sin\left( \theta \right)} +\iu\cancel{\sin\left( \theta \right)\cos(\theta)} + \sin^{2}\left( \theta \right) \right]\nonumber\\
	&= r^{2}\left[ \sin^{2}\left( \theta \right) + \cos^{2}\left( \theta \right) \right]\nonumber\\
	&= r^{2} = a^{2}+b^{2}.
	\label{eq:conjugate_product_geometric}
\end{align}

In 1748 Leonhard Euler published his famous work \textit{Introduction to analysis of the infinite}\footnote{Latin for \textbf{Introduction to the Analysis of the Infinite}.}. In it he introduced the following relation, called \emph{Euler's formula}:
\begin{equation}
	\eu^{\iu x} = \sin(x) + \iu\cos(x).
	\label{eq:Euler's_formula}
\end{equation}
Using Euler's formula a complex number $z$ can be written as
\begin{equation}
	z = r\eu^{\iu\theta}.
	\label{eq:complex number using Eurler's formula}
\end{equation}

In \autoref{tab:complex_exponentials} we can see some useful complex exponentials $\eu^{\iu x}$. Specifically, setting $x=\pi$ yields the famous \emph{Eurler's identity}, considered by many to be one of the most beautiful equations in mathematics, as it binds together five important numbers, namely $0,1,\pi,e$ and $\iu$:
\begin{equation}
	\eu^{\iu\pi} + 1 = 0.
	\label{eq:Euler's identity}
\end{equation}

\begin{table}
	\centering
	\caption{Values of $\eu^{ix}$ for some useful values of $x$ (cf. \autoref{tab:rad_degs} for the values of $\sin(\theta)$ and $\cos(\theta)$).}
	\label{tab:complex_exponentials}
	\begin{tabular}{lccl}
		\toprule
		$x$ & $\cos(x)$ & $\sin(x)$ & $z=\eu^{\iu x}$\\
		\midrule
		$\frac{\pi}{2}$ & $0$ & $1$ & $\iu$\\
		$\pi$ & $-1$ & $0$ & $-1$\\
		$\frac{3\pi}{2}$ & $0$ & $-1$ & $-\iu$\\
		$\frac{\pi}{3}$ & $\frac{1}{2}$ & $\frac{\sqrt{3}}{2}$ & $\frac{1}{2}\left( 1+\iu\sqrt{3} \right)$\\
		$\frac{\pi}{4}$ & $\frac{\sqrt{2}}{2}$ & $\frac{\sqrt{2}}{2}$ & $\frac{\sqrt{2}}{2}\left( 1+\iu \right)$\\
		$\frac{\pi}{6}$ & $\frac{\sqrt{3}}{2}$ & $\frac{1}{2}$ & $\frac{1}{2}\left( \sqrt{3}+\iu \right)$\\
		\bottomrule
	\end{tabular}
\end{table}

\autoref{tab:complex_exponentials} also shows us the integer behaviours of $\iu$:
\begin{equation}
	\iu^{2}=-1,\ \iu^{3}=-\iu, \iu^{4}=1,\ \iu^{5}=\iu,\ \iu^{6}=-1,\ \iu^{7}=-\iu,\ \dots
	\label{eq:powers of i}
\end{equation}

\subsection{Roots of complex numbers}
What is the $n$-th order roots of a complex number $z$, i.e. $\nroot{n}{z}$? An illuminating way to approach this problem is by looking at the polar form of $z$. As an example, we start with the number $z=1$ and find its 3rd order roots, i.e. all number $w$ such that $w^{3}=1$ (spoiler alert: there are three such numbers).

\autoref{eq:complex_product_geometric_insight} taught us that complex numbers not only scale other numbers, but also rotate them: with real numbers the product $x \cdot y$ is equivalent to a scaling of $x$ by $y$. With complex numbers the product has two components: its magnitude is the scale of $x$ by $y$, and its argument is the argument of $x$ rotated by the argument of $y$\footnote{Due to the commutativity of the complex product we can switch the order of $z$ and $w$ and get the same result.}.

\begin{example}{Rotation using complex numbers}{}
	Let $z=2+2\iu$ and $w=3\iu$. Their polar forms are $z=2\sqrt{2}\left[ \cos(\pi/4) +\iu\sin(\pi/4) \right]$ and $w=3\left[ \cos(\pi/2) + \iu\sin(\pi/2) \right]$. Their product is
	\begin{align*}
		z\cdot w &= (2+2\iu)\cdot3\iu = 6\iu + 6\iu^{2} = -6+6\iu,
	\end{align*}
	which in polar form is $6\sqrt{2}\left[ \cos(3\pi/4) + \iu\sin(3\pi/4) \right]$. Note that
	\begin{align*}
		2\sqrt{2}\cdot3 &= 6\sqrt{2},\text{ and}\\
		\frac{\pi}{4} + \frac{\pi}{2} &= \frac{3\pi}{4},
	\end{align*}
	i.e. $z\cdot w$ has magnitude which is the \textbf{product} of the magnitudes of $z$ and $w$, and an argument which is the \textbf{sum} of the arguments of $z$ and $w$.

	\vspace{1em}
	The figure below depict the arguments of the three numbers $z,w,z\cdot w$. Note that $\textcolor{xpurple}{\bm{\theta_{z\cdot w}}} = \textcolor{xred}{\bm{\theta_{z}}}+\textcolor{xblue}{\bm{\theta_{w}}}$.

	\vspace{1em}
		\centering
		\begin{tikzpicture}[node distance=3mm]
			\tikzstyle{every node}=[font=\large]
			\begin{axis}[
				complex plane,
				width=7cm, height=5cm,
				xmin=-1.25, xmax=1.25,
				ymin=-0.25, ymax=1.25,
				xtick={-1,0,1},
				xticklabels={},
				extra x ticks={-0.5,0.5},
				extra x tick labels={},
				ytick={-1,0,1},
				yticklabels={},
				extra y ticks={-0.5,0.5},
				extra y tick labels={},
			]
			\coordinate (O) at (0,0);
			\coordinate (A) at (0.707,0.707);
			\coordinate (B) at (0,1);
			\draw[black!20] (1,0) arc (0:180:1);
			\arcc{135}{0.60}{xpurple}
			\arcc{90}{0.55}{xblue}
			\arcc{45}{0.5}{xred}
			\draw[xred] (0,0) -- (0.707,0.707) node[complex](z){};
			\draw[xblue] (0,0) -- (0,1) node[complex](w){};
			\draw[xpurple] (0,0) -- (-0.707,0.707) node[complex](zw){};
			\node[xred, right of=z] {$z$};
			\node[xblue, left of=w, yshift=2mm] {$w$};
			\node[xpurple, above left of=zw, xshift=-2mm] {$z\cdot w$};
			\node[xred, rotate=22.5] at ({0.35*cos(22.5)},{0.35*sin(22.5)}) {$\theta_{z}$};
			\node[xblue, rotate=67.5] at ({0.35*cos(67.5)},{0.35*sin(67.5)}) {$\theta_{w}$};
			\node[xpurple, rotate=-45] at ({0.35*cos(112.5)},{0.35*sin(112.5)}) {$\theta_{z\cdot w}$};
			\end{axis}
		\end{tikzpicture}
\end{example}

\begin{note}{$\bm{\iu^{2}=-1}$ from a geometric (polar) viewpoint}{}
	In polar coordinates $\iu$ has magnitude $1$ and argument $\frac{\pi}{2}$, i.e. multiplying by $\iu$ is equivalent to rotation by $\frac{\pi}{2}$ ($\ang{90}$) counter clockwise. Therefore, multiplying $\iu$ by itself, i.e. $\iu^{2}$, rotates $\iu$ itself by $\frac{\pi}{2}$ counter clockwise, bringing it to $-1$.

	\centering
	\begin{tikzpicture}[node distance=3mm]
			\tikzstyle{every node}=[font=\large]
			\begin{axis}[
				complex plane,
				width=7cm, height=5cm,
				xmin=-1.25, xmax=1.25,
				ymin=-0.25, ymax=1.25,
				xtick={-1,0,1},
				xticklabels={},
				extra x ticks={-0.5,0.5},
				extra x tick labels={},
				ytick={-1,0,1},
				yticklabels={},
				extra y ticks={-0.5,0.5},
				extra y tick labels={},
			]
			\coordinate (O) at (0,0);
			\coordinate (i) at (0,1);
			\coordinate (-1) at (-1,0);
			\draw[black!20] (1,0) arc (0:180:1);
			\arcc{180}{0.6}{xblue}
			\arcc{90}{0.5}{xdarkgreen}
			\draw[xdarkgreen] (O) -- (i) node[complex](i){};
			\draw[xblue] (O) -- (-1) node[complex](-1){};
			\node[xdarkgreen, above right of=i] {$\iu$};
			\node[xblue, below of=-1] {$-1$};
			\node[xdarkgreen] at ({0.3*cos(45)},{0.3*sin(45)}) {$\frac{\pi}{2}$};
			\node[xblue] at ({0.3*cos(135)},{0.3*sin(135)}) {$\pi$};
			\end{axis}
		\end{tikzpicture}
\end{note}

In polar form $1=\cos(0)+\iu\sin(0)$. Finding the arguments of the cube roots of $1$ is therefore done by answering the following question: what angles $\theta$ will equal $0$ (or its equivalent angles $2\pi,4\pi,6\pi,\dots$) when multiplied by $3$? The answer is very simple: the only possible solutions are
\begin{align}
	\theta_{1} &= 0,\nonumber\\
	\theta_{2} &= \frac{2\pi}{3},\nonumber\\
	\theta_{3} &= \frac{4\pi}{3}.
	\label{eq:arguments for the cube roots of 1}
\end{align}
(any other number in the range $[0,2\pi)$ will give the same angles)

Therefore, the three cube roots of $1$ are \footnote{recall that $\nroot{3}{1}=1$, and therefore all roots have magnitude $1$.} (\autoref{fig:cube roots of 1})
\begin{align}
	z_{1} &= \cos\left( \theta_{1} \right) + \iu\sin\left( \theta_{1} \right) = \cos(0) + \iu\sin(0) = 1,\nonumber\\
	z_{2} &= \cos\left( \theta_{2} \right) + \iu\sin\left( \theta_{2} \right) = \cos\left( \frac{2\pi}{3} \right) + \iu\sin\left( \frac{2\pi}{3} \right) = -0.5+\frac{\sqrt{3}}{2}\iu,\nonumber\\
	z_{3} &= \cos\left( \theta_{3} \right) + \iu\sin\left( \theta_{1} \right) = \cos\left( \frac{4\pi}{3} \right) + \iu\sin\left( \frac{4\pi}{3} \right) = -0.5-\frac{\sqrt{3}}{2}\iu.
	\label{eq:cube roots of 1}
\end{align}

\begin{figure}
	\centering
	\begin{tikzpicture}
		\tikzstyle{every node}=[font=\large]
		\begin{axis}[
			complex plane,
			width=10cm, height=10cm,
			xmin=-1.25, xmax=1.25,
			ymin=-1.25, ymax=1.25,
			xtick={-1,0,1},
			extra x ticks={-0.5,0.5},
			extra x tick labels={},
			ytick={-1,0,1},
			extra y ticks={-0.5,0.5},
			extra y tick labels={},
		]
		% NOTE: this should changed to use \cmplxsol{3}.
		\coordinate (O) at (0,0);
		\coordinate (z1) at (1,0);
		\coordinate (z2) at (-0.5,{sqrt(3)/2});
		\coordinate (z3) at (-0.5,{-sqrt(3)/2});
		\draw[black!20] (z1) arc (0:360:1);
		\draw[xgreen, fill=xgreen!20] (O) -- (0.175,0) arc (0:240:0.175) -- cycle;
		\draw[xblue, fill=xblue!20] (O) -- (0.125,0) arc (0:120:0.125) -- cycle;
		\draw[very thick, xred] (O) -- node[above, right, xshift=-20, yshift=8] {$\theta_{1}=0$} (z1) node[complex, label=above:$z_{1}$]{};
		\draw[very thick, xblue] (O) -- node[below, rotate=-60] {$\theta_{2}=\frac{2\pi}{3}$} (z2) node[complex, label=above left:$z_{2}$]{};
		\draw[very thick, xgreen] (O) -- node[above, rotate=60] {$\theta_{3}=\frac{4\pi}{3}$}(z3) node[complex, label=below left:$z_{3}$]{};
		\end{axis}
	\end{tikzpicture}
	\caption{The three cube roots of $z=1$.}
	\label{fig:cube roots of 1}
\end{figure}

The $n$-th degree roots of $1$ will follow the same pattern for $n\in\mathbb{N}$ (see \autoref{fig:nth roots of 1}): their magnitude is always $1$, and the argument of the $k$-th root is
\begin{equation}
	\theta_{k} = \frac{2\pi}{n}k.
	\label{eq:nth roots of 1}
\end{equation}

Finding the $n$-th degree roots of a general complex number $z=r\left[ \cos(\theta) +\iu\sin(\theta) \right]$ can be done in a similar fashion: all roots will have the magnitude $\nroot{n}{r}$, and their argument $\theta_{k}$ will be such that multiplying it by $n$ gives $\theta+2\pi m$ for some integer value $m$, i.e.
\begin{equation}
	\theta_{k} = \frac{\theta+2\pi m}{n}.
	\label{eq:sofds}
\end{equation}

\begin{figure}
	\captionsetup[subfigure]{labelformat=empty}
	\centering
	\begin{subfigure}[b]{0.475\textwidth}
		\centering
		\begin{tikzpicture}
			\begin{axis}[
					complex solution,
				]
				\cmplxsol{4}
			\end{axis}
		\end{tikzpicture}
		\caption{$n=4,\ \theta_{k}=\frac{\pi}{2}k$}
	\end{subfigure}
	\hfill
	\begin{subfigure}[b]{0.475\textwidth}
		\centering
		\begin{tikzpicture}
			\begin{axis}[
					complex solution,
				]
				\cmplxsol{5}
			\end{axis}
		\end{tikzpicture}
		\caption{$n=5,\ \theta_{k}=\frac{2\pi}{5}k$}
	\end{subfigure}

	\vspace{2em}
	\begin{subfigure}[b]{0.475\textwidth}
		\centering
		\begin{tikzpicture}
			\begin{axis}[
					complex solution,
				]
				\cmplxsol{6}
			\end{axis}
		\end{tikzpicture}
		\caption{$n=6,\ \theta_{k}=\frac{\pi}{3}k$}
	\end{subfigure}
	\hfill
	\begin{subfigure}[b]{0.475\textwidth}
		\centering
		\begin{tikzpicture}
			\begin{axis}[
					complex solution,
				]
				\cmplxsol{7}
			\end{axis}
		\end{tikzpicture}
		\caption{$n=7,\ \theta_{k}=\frac{7\pi}{2}k$}
	\end{subfigure}
	\caption{Complex $n$-th roots of $z=1$ for $n=4,5,6,7$. Note that for all circles $r=1$.}
	\label{fig:nth roots of 1}
\end{figure}


\outline{3}{Exercise 16.1}
\subsubsection*{Exercise 16.1}

\textit{Revise the majority rule dynamical network model developed above so
that each node stochastically flips its state with some probability. Then
simulate the model and see how its behavior is affected.}


\documentclass[Physics.tex]{subfiles}
\begin{document}
\chapter{Kinematics}
\sldef{Distance} \(x\) is the total length covered by a moving object irrespective of the direction of motion.

\sldef{Displacement} or position \(\mathbf{x}\) is the shortest linear distance of a moving object from a given reference point.

\sldef{Speed} is the rate of change of distance travelled with respect to time. \begin{equation}v = \frac{\mathrm{d}x}{\mathrm{d}t}\end{equation}

\sldef{Velocity} is the rate of change of displacement with respect to time. \begin{equation}\mathbf{v} = \frac{\mathrm{d}\mathbf{x}}{\mathrm{d}t}\end{equation}

\sldef{Acceleration} is the rate of change of velocity with respect to time. \begin{equation}\mathbf{a} = \frac{\mathrm{d}\mathbf{v}}{\mathrm{d}t}\end{equation}

\sldef{Average speed} is the total distance travelled over the total time taken. \begin{equation}\langle v \rangle = \frac{\Delta x}{\Delta t}\end{equation}

\sldef{Average velocity} is the total change in displacement over total time taken. \begin{equation}\langle\mathbf{v}\rangle = \frac{\Delta \mathbf{x}}{\Delta t}\end{equation}

\sldef{Average acceleration} is the total change in velocity over total time taken. \begin{equation}\langle\mathbf{a}\rangle = \frac{\Delta \mathbf{v}}{\Delta t}\end{equation}
\section{Freefall}
An object that experiences no force other than its weight and possibly drag is in freefall. Neglecting air resistance, an object in freefall near the Earth's surface experiences a constant downward acceleration \(\mathbf{g} = \SI{9.81}{\metre\per\square\second}\) towards the Earth's centre of mass.

In reality, an object will experience a drag force \(\mathbf{F}_D \propto \mathbf{v}\) for small \(\mathbf{v}\), and \(\mathbf{F}_D \propto \mathbf{v}^2\) for larger \(\mathbf{v}\). The drag force opposes the object's motion. Terminal velocity is the velocity an object reaches when drag exactly balances the object's weight.
\section{Projectile motion}
In \sldef{projectile motion}, it is assumed that
\begin{slinenum}
\item the acceleration due to gravity is constant throughout the motion, i.e. \(\mathbf{g}\) is constant
\item there is no horizontal acceleration, i.e. \(\mathbf{a}_x = 0\)
\item air resistance is negligible, i.e. \(\mathbf{F}_D = 0\).
\end{slinenum}
Projectile motion with the above assumptions generally creates a parabolic trajectory that is symmetric; the \sldef{trajectory} is the path described by a projectile. \sldef{Range} is the distance on the plane between the point of projection and point of impact.

With air resistance, projectile motion describes an asymmetric trajectory. Air resistance also decreases the object's time of flight, horizontal range and maximum height reached.
\section{Kinematics equations}
The following equations apply only when acceleration is constant.
\begin{align}
\mathbf{a} &= \frac{\Delta\mathbf{v}}{\Delta t} = \frac{\mathbf{v} - \mathbf{u}}{t} \mathrel{\therefore} \mathbf{v} - \mathbf{u} = \mathbf{a}t \mathrel{\therefore} \mathbf{v} = \mathbf{u} + \mathbf{a}t\\
\mathbf{s} &= \int_{}^{}{\mathbf{v}\mathrm{d}t} = \int_{}^{}{(\mathbf{u} + \mathbf{a}t)\mathrm{d}t} = \mathbf{u}t + \frac{1}{2}\mathbf{a}t^{2}\\
\begin{split}\mathbf{s} &= \mathbf{u}t + \frac{1}{2}\mathbf{a}t^{2} = \mathbf{u}t + \frac{1}{2}\frac{( \mathbf{v} - \mathbf{u})}{t}t^{2}%= \mathbf{u}t + \frac{1}{2}t(\mathbf{v} - \mathbf{u})
\\ &= \mathbf{u}t + \frac{1}{2}\mathbf{v}t - \frac{1}{2}\mathbf{u}t = \frac{1}{2}\mathbf{u}t + \frac{1}{2}\mathbf{v}t\\&= \frac{1}{2}(\mathbf{v} + \mathbf{u})t\end{split}\\
\begin{split}\mathbf{v}^{2} &= ( \mathbf{u} + \mathbf{a}t )^{2} = \mathbf{u}^{2} + 2\mathbf{ua}t + \mathbf{a}^{2}t^{2}\\&= \mathbf{u}^{2} + 2\mathbf{a}( \mathbf{s} - \frac{1}{2}\mathbf{a}t^{2} ) + \mathbf{a}^{2}t^{2}\\&= \mathbf{u}^{2} + 2\mathbf{as} - \mathbf{a}^{2}\mathbf{t}^{2} + \mathbf{a}^{2}\mathbf{t}^{2}\\&= \mathbf{u}^{2} + 2\mathbf{as}\end{split}
\end{align}
\end{document}


% !TeX root = constructions.tex

\part{Straightedge and Compass}\label{p.sec}

\chapter{Help, My Compass Collapsed!}\label{c.collapse}

\section{Fixed compasses and collapsing compasses}

A modern compass is a \emph{fixed compass}: the distance between the two legs can be fixed so that it is possible to copy a line segment or a circle from one position to another. I have seen geometry textbooks that present the  construction a perpendicular bisector to a line segment as follows: construct two circles centered at the ends of the line segment such that the radii are equal and \emph{greater than half the length of the segment} (left diagram):

\vspace{-2ex}

\begin{center}
\begin{tikzpicture}[scale=0.5]
\begin{scope}
\coordinate (A) at (0,0);
\coordinate (B) at (4,0);
\draw (A) node[below left] {$A$} -- (B) node[below right] {$B$};
\fill (A) circle[radius=3pt];
\fill (B) circle[radius=3pt];
\draw[name path=larc] (A) ++(-60:3cm) arc (-60:60:3cm);
\draw[name path=rarc] (B) ++(-120:3cm) arc (-120:-240:3cm);
\path [name intersections={of=larc and rarc,by={b,t}}];
\fill (t) node[above right,xshift=-2pt,yshift=5pt] {$C$} circle[radius=3pt];
\fill (b) node[below left,xshift=2pt,yshift=-5pt] {$D$} circle[radius=3pt];
\draw ($ (b) ! 1.2 ! (t)$) -- ($ (t) ! 1.2 ! (b)$);
\end{scope}
\begin{scope}[xshift=12cm]
\coordinate (A) at (0,0);
\coordinate (B) at (4,0);
\draw (A) node[below left] {$A$} -- (B) node[below right] {$B$};
\fill (A) circle[radius=3pt];
\fill (B) circle[radius=3pt];
\draw[name path=larc] (A) ++(-80:4cm) arc (-80:80:4cm);
\draw[name path=rarc] (B) ++(-100:4cm) arc (-100:-260:4cm);
\path [name intersections={of=larc and rarc,by={b,t}}];
\fill (t) node[above right,xshift=-2pt,yshift=3pt] {$C$} circle[radius=3pt];
\fill (b) node[below left,xshift=2pt,yshift=-3pt] {$D$}circle[radius=3pt];
\draw ($ (b) ! 1.2 ! (t)$) -- ($ (t) ! 1.2 ! (b)$);
\end{scope}
\end{tikzpicture}
\end{center}

\vspace{-2ex}

Euclid used a \emph{collapsing compass} whose legs fold up when the compass is lifted off the paper. Teachers often use a collapsing compass consisting of a piece of chalk tied to a string. It is impossible to maintain a fixed radius when the chalk and the end of the string are removed from the blackboard. The right diagram above shows how to construct a perpendicular bisector with a collapsing compass: the length of the segment $\overline{AB}$ is, of course, equal to the length of the segment $\overline{BA}$, so the radii of the two circles are equal.

The proof that the line constructed is the perpendicular bisector is not at all elementary because relatively advanced concepts like congruent triangles have to be used. However, the proof that the same construction results in an equilateral triangle is very simple (right diagram below). The length of $\overline{AC}$ equals the length of $\overline{AB}$ since they are radii of the same circle, and for the same reason the length of $\overline{BC}$ is equal to the length of $\overline{BA}$. We have:
\[
\overline{AC}=\overline{AB}=\overline{BA}=\overline{BC}\,.
\]

\begin{center}
\begin{tikzpicture}[scale=0.5]
\begin{scope}
\coordinate (A) at (0,0);
\coordinate (B) at (4,0);
\draw (A) node[below left] {$A$} -- (B) node[below right] {$B$};
\fill (A) circle[radius=3pt];
\fill (B) circle[radius=3pt];
\draw[name path=larc] (A) ++(-60:3cm) arc (-60:60:3cm);
\draw[name path=rarc] (B) ++(-120:3cm) arc (-120:-240:3cm);
\path [name intersections={of=larc and rarc,by={b,t}}];
\fill (t) node[above right,xshift=-2pt,yshift=5pt] {$C$} circle[radius=3pt];
\fill (b) node[below left,xshift=2pt,yshift=-5pt] {$D$} circle[radius=3pt];
\draw (A) -- (t);
\draw (B) -- (t);
\end{scope}
\begin{scope}[xshift=12cm]
\coordinate (A) at (0,0);
\coordinate (B) at (4,0);
\draw (A) node[below left] {$A$} -- (B) node[below right] {$B$};
\fill (A) circle[radius=3pt];
\fill (B) circle[radius=3pt];
\draw[name path=larc] (A) ++(-80:4cm) arc (-80:80:4cm);
\draw[name path=rarc] (B) ++(-100:4cm) arc (-100:-260:4cm);
\path [name intersections={of=larc and rarc,by={b,t}}];
\fill (t) node[above right,xshift=-2pt,yshift=3pt] {$C$} circle[radius=3pt];
\fill (b) node[below left,xshift=2pt,yshift=-3pt] {$D$}circle[radius=3pt];
\draw (A) -- (t);
\draw (B) -- (t);
\end{scope}
\end{tikzpicture}
\end{center}

The left diagram above shows that for the construction with the fixed compass the triangle will be isosceles, but not necessarily equilateral.

This construction of an equilateral triangle is the first proposition in Euclid's \emph{Elements}. The second proposition shows how to copy a given line segment $\overline{AB}$ to a segment of the same length, one of whose end points is a given point $C$. Therefore, a fixed compass adds no additional capability. Toussaint \cite{toussaint} showed that many incorrect constructions for this proposition have been given. In fact, it was Euclid who gave a correct construction! The following section presents Euclid's construction and the proof of its correctness. Then I show an incorrect construction that can be found even in modern textbooks.

\section{Euclid's construction for copying a line segment}

\textbf{Theorem:} Given a line segment $\overline{AB}$ and a point $C$, a line segment can be constructed (using a collapsing compass) at $C$ whose length is equal to the length of $\overline{AB}$:

\begin{center}
\begin{tikzpicture}[scale=0.4]
\begin{scope}
\coordinate (C) at (0,0);
\coordinate (A) at (2.5,0);
\coordinate (B) at (5.5,2);
\draw (A) node[below,xshift=-2pt,yshift=-2pt] {$A$} -- (B) node[right] {$B$};
\fill (A) circle[radius=3pt];
\fill (B) circle[radius=3pt];
\fill (C) node[below,xshift=2pt,yshift=-2pt] {$C$} circle[radius=3pt];
\end{scope}
\begin{scope}[xshift=12cm]
\coordinate (C) at (0,0);
\coordinate (A) at (2.5,0);
\coordinate (B) at (5.5,2);
\draw (A) node[below,xshift=-2pt,yshift=-2pt] {$A$} -- (B) node[right] {$B$};
\fill (A) circle[radius=3pt];
\fill (B) circle[radius=3pt];
\fill (C) node[below,xshift=2pt,yshift=-2pt] {$C$} circle[radius=3pt];
\draw (A) -- (C);
\path[name path=larc] (C) ++(-70:2.5cm) arc (-70:70:2.5cm);
\path[name path=rarc] (A) ++(-110:2.5cm) arc (-110:-250:2.5cm);
\path [name intersections={of=larc and rarc,by={d,D}}];
\fill (D) node[above] {$D$} circle[radius=3pt];
\draw (A) -- (D);
\draw (C) -- (D);
\end{scope}
\end{tikzpicture}
\end{center}

\textbf{Construction:}

Construct the line segment from $A$ to $C$.

Construct an equilateral triangle whose base is $\overline{AC}$ (right diagram above). Label the third vertex $D$. By Euclid's first proposition, the triangle can be constructed using a collapsing compass.

Construct a ray that is a continuation of $\overline{DA}$ and a ray that is a continuation of $\overline{DC}$ (left diagram below).

Construct a circle centered at $A$ with radius $\overline{AB}$. Label the intersection of the circle and the ray $\overline{DA}$ by $E$ (right diagram below).

\begin{center}
\begin{tikzpicture}[scale=0.4]
\begin{scope}
\coordinate (C) at (0,0);
\coordinate (A) at (2.5,0);
\coordinate (B) at (5.5,2);
\draw (A) node[below,xshift=-2pt,yshift=-2pt] {$A$} -- (B) node[right] {$B$};
\fill (A) circle[radius=3pt];
\fill (B) circle[radius=3pt];
\fill (C) node[below,xshift=2pt,yshift=-2pt] {$C$} circle[radius=3pt];
\draw (A) -- (C);
\path[name path=larc] (C) ++(-70:2.5cm) arc (-70:70:2.5cm);
\path[name path=rarc] (A) ++(-110:2.5cm) arc (-110:-250:2.5cm);
\path [name intersections={of=larc and rarc,by={d,D}}];
\fill (D) node[above] {$D$} circle[radius=3pt];
\draw (A) -- (D);
\draw (C) -- (D);
\draw[name path=ray2] (D) -- ($ (D) ! 3 ! (C) $);
\draw[name path=ray1] (D) -- ($ (D) ! 3 ! (A) $);
\end{scope}
\begin{scope}[xshift=12cm]
\coordinate (C) at (0,0);
\coordinate (A) at (2.5,0);
\coordinate (B) at (5.5,2);
\draw (A) node[below,xshift=-2pt,yshift=-2pt] {$A$} -- (B) node[right] {$B$};
\fill (A) circle[radius=3pt];
\fill (B) circle[radius=3pt];
\fill (C) node[below,xshift=2pt,yshift=-2pt] {$C$} circle[radius=3pt];
\draw (A) -- (C);
\path[name path=larc] (C) ++(-70:2.5cm) arc (-70:70:2.5cm);
\path[name path=rarc] (A) ++(-110:2.5cm) arc (-110:-250:2.5cm);
\path [name intersections={of=larc and rarc,by={d,D}}];
\fill (D) node[above] {$D$} circle[radius=3pt];
\draw (A) -- (D);
\draw (C) -- (D);
\draw[name path=ray2] (D) -- ($ (D) ! 3 ! (C) $);
\draw[name path=ray1] (D) -- ($ (D) ! 3 ! (A) $);
\node[draw,circle through=(B),name path=c1] at (A) {};
\path [name intersections={of=c1 and ray1,by={E,e}}];
\fill (E) node[right,xshift=2pt,yshift=-2pt] {$E$} circle[radius=3pt];
\end{scope}
\end{tikzpicture}
\end{center}

Construct a circle centered at $D$ with radius $\overline{DE}$. Label the intersection of the circle and the ray $\overline{DC}$ by $F$:

\begin{center}
\begin{tikzpicture}[scale=0.4]
\coordinate (C) at (0,0);
\coordinate (A) at (2.5,0);
\coordinate (B) at (5.5,2);
\draw (A) node[below,xshift=-2pt,yshift=-2pt] {$A$} -- node[above] {$x$} (B) node[right] {$B$};
\fill (A) circle[radius=3pt];
\fill (B) circle[radius=3pt];
\fill (C) node[below,xshift=2pt,yshift=-2pt] {$C$} circle[radius=3pt];
\draw (A) -- (C);
\path[name path=larc] (C) ++(-70:2.5cm) arc (-70:70:2.5cm);
\path[name path=rarc] (A) ++(-110:2.5cm) arc (-110:-250:2.5cm);
\path [name intersections={of=larc and rarc,by={d,D}}];
\fill (D) node[above] {$D$} circle[radius=3pt];
\draw (A) -- node[right] {$y$} (D);
\draw (C) -- node[left] {$y$} (D);
\draw[name path=ray2] (D) -- ($ (D) ! 3 ! (C) $);
\draw[name path=ray1] (D) -- ($ (D) ! 3 ! (A) $);
\node[draw,circle through=(B),name path=c1] at (A) {};
\path [name intersections={of=c1 and ray1,by={E,e}}];
\fill (E) node[right,xshift=2pt,yshift=-2pt] {$E$} circle[radius=3pt];
\node[draw,circle through=(E),name path=c2] at (D) {};
\path [name intersections={of=c2 and ray2,by={F,f}}];
\fill (F) node[left,xshift=-2pt,yshift=-2pt] {$F$} circle[radius=3pt];
\path (A) -- node[right] {$x$} (E);
\path (C) -- node[left] {$x$} (F);
\end{tikzpicture}
\end{center}

\textbf{Claim:} The length of the line segment $\overline{CF}$ is equal to the length of $\overline{AB}$.

\textbf{Proof:} $\overline{DC}=\overline{DA}$ because $\triangle ACD$ is equilateral. $\overline{AE}=\overline{AB}$ because they are radii of the same circle centered at $A$. $\overline{DF}=\overline{DE}$ because they are radii of the same circle centered at $D$. Therefore, the length of the line segment $\overline{CF}$ is:
\[
\overline{CF}=\overline{DF}-\overline{DC}=\overline{DE}-\overline{DC}=\overline{DE}-\overline{DA}=\overline{AE}=\overline{AB}\,.
\]

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{An incorrect construction for copying a line segment}\label{s.erroneous}

\textbf{Construction(\cite{rusty}):}

Construct a circle centered at $A$ with radius $\overline{AB}$:

\begin{center}
\begin{tikzpicture}[scale=0.4]
\begin{scope}
\coordinate (C) at (-2,0);
\coordinate (A) at (2.5,0);
\coordinate (B) at (4.5,1.5);
\draw (A) node[below,xshift=-2pt,yshift=-2pt] {$A$} -- (B) node[right] {$B$};
\fill (A) circle[radius=3pt];
\fill (B) circle[radius=3pt];
\fill (C) node[below,xshift=2pt,yshift=-2pt] {$C$} circle[radius=3pt];
\end{scope}
\begin{scope}[xshift=12cm]
\coordinate (C) at (-2,0);
\coordinate (A) at (2.5,0);
\coordinate (B) at (4.5,1.5);
\draw (A) node[below,xshift=-2pt,yshift=-2pt] {$A$} -- (B) node[right] {$B$};
\fill (A) circle[radius=3pt];
\fill (B) circle[radius=3pt];
\fill (C) node[below,xshift=2pt,yshift=-2pt] {$C$} circle[radius=3pt];
\node[draw,circle through=(B),name path=c1] at (A) {};
\end{scope}
\end{tikzpicture}
\end{center}

Construct a circle centered at $A$ with radius $\overline{AC}$ and a circle centered at $C$ with radius $\overline{AC}=\overline{CA}$. Label the intersections of the two circles $E,F$. Label the intersection of the circle centered at $C$ and the circle centered at $A$ with radius $\overline{AB}$ by $D$:

\begin{center}
\begin{tikzpicture}[scale=0.5]
\coordinate (C) at (-2,0);
\coordinate (A) at (2.5,0);
\coordinate (B) at (4.5,1.5);
\draw (A) node[below right] {$A$} -- (B) node[right] {$B$};
\fill (A) circle[radius=3pt];
\fill (B) circle[radius=3pt];
\fill (C) node[left,xshift=-2pt] {$C$} circle[radius=3pt];
\node[draw,circle through=(B),name path=c1] at (A) {};
\node[draw,circle through=(C),name path=c2] at (A) {};
\node[draw,circle through=(A),name path=c3] at (C) {};
\path [name intersections={of=c1 and c3,by={D,f}}];
\path [name intersections={of=c2 and c3,by={E,F}}];
\fill (D) node[below right,xshift=4pt] {$D$} circle[radius=3pt];
\fill (E) node[above,yshift=2pt] {$E$} circle[radius=3pt];
\fill (F) node[below,yshift=-2pt] {$F$} circle[radius=3pt];
\end{tikzpicture}
\end{center}

Construct a circle centered at $E$ with radius $ED$. Label the intersection of this circle with the circle centered at $A$ with radius $AC$ by $G$:

\begin{center}
\begin{tikzpicture}[scale=0.5]
\coordinate (C) at (-2,0);
\coordinate (A) at (2.5,0);
\coordinate (B) at (4.5,1.5);
\draw (A) node[below right] {$A$} -- (B) node[right] {$B$};
\fill (A) circle[radius=3pt];
\fill (B) circle[radius=3pt];
\fill (C) node[below left] {$C$} circle[radius=3pt];
\node[draw,circle through=(B),name path=c1] at (A) {};
\node[draw,circle through=(C),name path=c2] at (A) {};
\node[draw,circle through=(A),name path=c3] at (C) {};
\path [name intersections={of=c1 and c3,by={D,f}}];
\path [name intersections={of=c2 and c3,by={E,F}}];
\fill (D) node[below right,xshift=4pt] {$D$} circle[radius=3pt];
\fill (E) node[above,yshift=2pt] {$E$} circle[radius=3pt];
\fill (F) node[below,yshift=-2pt] {$F$} circle[radius=3pt];
\node[draw,circle through=(D),name path=c4] at (E) {};
\path [name intersections={of=c2 and c4,by={g,G}}];
\fill (G) node[below left,xshift=-4pt] {$G$} circle[radius=3pt];
\draw[dashed] (C) -- (G);
\draw[dashed] (A) -- (D);
\draw[thick,dotted] (A) -- (G) -- (E) -- cycle;
\draw[thick,dotted] (C) -- (D) -- (E) -- cycle;
\end{tikzpicture}
\end{center}

\textbf{Claim:} The length of the line segment $\overline{GC}$ is equal to the length of $\overline{AB}$.

\textbf{Proof:} $\overline{CD}=\overline{CE}$ are radii of the circle centered at $C$. $\overline{AE}=\overline{AG}$ are radii of the (larger) circle centered at $A$. $\overline{CD} = \overline{CE} = \overline{AE} = \overline{AG}$ since the radii of the two circles are $\overline{AC}= \overline{CA}$. $\overline{EG} = \overline{ED}$ are radii of the circle centered at $E$. Therefore, $\triangle EAG\cong \triangle DCE$ by side-side-side so $\angle GEA = \angle DEC$.

$\angle GEC = \angle GEA \!-\!\angle CEA = \angle DEC\!-\!\angle CEA = \angle DEA$. Therefore, $\triangle ADE\cong\triangle CGE$ by side-angle-side. $\overline{AB}=\overline{AD}$ are radii of the smaller circle centered at $A$, so $\overline{CG}=\overline{AD}=\overline{AB}$.

Is there an error in the proof? No! But there is a problem because the equality $\overline{AB}=\overline{GC}$ holds only when the length of $\overline{AB}$ is less that the length of $\overline{AC}$. In contrast, Euclid's construction and proof are true, independent of the relative lengths of  $\overline{AB}$ and $\overline{AC}$, and independent of the position of the point $C$ relative to the line segment $\overline{AB}$ \cite{toussaint}.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{A ``simpler'' construction for copying a line segment}

Given a line segment $\overline{AB}$ and a point $C$, if we can build a parallelogram with these three points as its vertices, we obtain a line segment with $C$ at one end whose length is equal to the length of $\overline{AB}$ (left diagram):
\begin{center}
\begin{tikzpicture}[scale=0.7]
\coordinate (A) at (0,0);
\coordinate (B) at (4,0);
\coordinate (C) at (5,2);
\draw (A) -- (B);
\path (A) -- node[above] {$x$} (B);
\fill (A) node[below left] {$A$} circle[radius=2pt];
\fill (B) node[below] {$B$} circle[radius=2pt];
\fill (C) node[above] {$C$} circle[radius=2pt];
\draw (B) -- node[right] {$y$} (C);
\coordinate (D) at ($(C)+(-40mm,0cm)$);
\draw (D) -- node[above] {$x$} (C);
\draw (A) -- node[left] {$y$} (D);
\fill (D) node[above] {$D$} circle[radius=2pt];
\begin{scope}[xshift=12cm]
\coordinate (A) at (0,0);
\coordinate (B) at (4,0);
\coordinate (C) at (5,2);
\draw ($ (B) ! 1.2 ! (A) $) -- ($ (A) ! 1.5 ! (B) $);
\path (A) -- (B);
\fill (A) node[below left,xshift=-4pt] {$A$} circle[radius=2pt];
\fill (B) node[below] {$B$} circle[radius=2pt];
\fill (C) node[above] {$C$} circle[radius=2pt];
\draw (B) -- (C);
\draw[name path=ray1] ($(C)+(-5cm,0cm)$) -- ($(C)+(1cm,0cm)$);
\draw[name path=ray2] ($(A)+(-.25,-.65)$) -- ($(A)+(1,2.6)$);
\path [name intersections={of=ray1 and ray2,by={D}}];
\fill (D) node[above left] {$D$} circle[radius=2pt];
\coordinate (E) at (C |- B);
\draw[thick,dashed] (C) -- (E);
\fill (E) node[below] {$E$} circle[radius=2pt];
\draw[rotate=-90] (C) rectangle +(10pt,10pt);
\draw (E) rectangle +(10pt,10pt);
\coordinate (F) at ($(A)!(B)!(D)$);
\fill (F) circle[radius=2pt];
\draw[thick,dashed] (B) -- (F);
\draw[rotate=-24] (F) rectangle +(10pt,10pt);
\draw[rotate=67] (B) rectangle +(10pt,10pt);
\end{scope}
\end{tikzpicture}
\end{center}
This construction can be found in \cite[pp. 207--208]{roads}.

\textbf{Construction (right diagram):}

Construct the line segment from $B$ to $C$. Construct an altitude from $C$ to the line containing the line segment $\overline{AB}$. Label the intersection by $E$. Construct an altitude to the line segment $\overline{CE}$ at $C$. This line is parallel to $\overline{AB}$. Use a similar method to construct a line parallel to $\overline{BC}$ through $A$. Label the intersection of the two lines by $D$.

$\overline{AD}\|\overline{BC}$, $\overline{AB}\|\overline{DC}$ and by definition $\overline{ABCD}$ is a parallelogram, so $\overline{AB}= \overline{CD}$ as required.

\textbf{Construction with a collapsing compass:} It is possible to construct an altitude to the line $l$ through a given point $C$ with a collapsing compass. Construct a circle centered at $C$ with a radius that is greater than the distance of $C$ from $l$. Label the intersections with $l$ by $D,E$. Construct circles centered at $D,E$ with radii $\overline{DC} = \overline{EC}$. The line connecting the intersections $C,F$ of the circles centered at $D,E$  is an altitude through $C$.
\begin{center}
\begin{tikzpicture}[scale=0.5]
\coordinate (A) at (0,0);
\coordinate (B) at (4,0);
\coordinate (C) at (5,2);
\draw[name path=ray] ($ (B) ! 1.5 ! (A) $) -- node[very near start,above] {$l$} ($ (A) ! 2.5 ! (B) $);
%\fill (A) node[below] {$A$} circle[radius=3pt];
%\fill (B) node[below] {$B$} circle[radius=3pt];
\fill (C) node[right] {$C$} circle[radius=3pt];
\draw[name path=arc] (C) ++(-160:3.5cm) arc (-160:-20:3.5cm);
\path [name intersections={of=arc and ray,by={D,E}}];
\fill (D) node[below left] {$D$} circle[radius=3pt];
\fill (E) node[below right] {$E$} circle[radius=3pt];
\draw[name path=larc] (D) ++(-60:3.5cm) arc (-60:60:3.5cm);
\draw[name path=rarc] (E) ++(-120:3.5cm) arc (-120:-240:3.5cm);
\path [name intersections={of=larc and rarc,by={b,t}}];
\fill (b) node[right] {$F$} circle[radius=3pt];
\draw ($ (b) ! 1.2 ! (t)$) -- ($ (t) ! 1.2 ! (b)$);
\end{tikzpicture}
\end{center}
The proof the correctness of this construction is much more difficult than Euclid's proof of his construction.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{Don't trust a diagram}

We can prove that \emph{all} triangles are isosceles!
\begin{center}
\begin{tikzpicture}[scale=1.1]
\coordinate (P) at (0,0);
\node[xshift=4mm,yshift=1mm] at (P) {$P$};
\coordinate [label=left:$B$] (B)  at (-2,-2);
\coordinate [label=right:$C$] (C)  at (4,-2);
\coordinate [label=above:$A$] (A)  at (-1,2);
\node[below,yshift=-12pt,xshift=2pt] at (A) {$\alpha$};
\node[below,yshift=-12pt,xshift=15pt] at (A) {$\alpha$};
\draw (A) -- (B);
\draw (A) -- (C);
\draw (B) -- (C);
\draw (A) -- (P);
\draw (B) -- (P);
\draw (C) -- (P);
\coordinate[label=left:$E$] (E) at ($ (A) ! .44 ! (B) $);
\draw[rotate=-100] (E) rectangle +(4pt,4pt);
\draw (P) -- (E);
\coordinate (F) at ($ (A) ! .33 ! (C) $);
\node[right,xshift=2pt,yshift=2pt] at (F) {$F$};
\draw[rotate=-132] (F) rectangle +(4pt,4pt);
\draw (P) -- (F);
\coordinate[label=below:$D$] (D) at ($ (B) ! .33 ! (C) $);
\draw (D) rectangle +(4pt,4pt);
\draw (P) -- (D);
\node[left] at ($ (A) ! .5 ! (E) $) {};
\node[left] at ($ (B) ! .5 ! (E) $) {};
\node[below] at ($ (B) ! .5 ! (D) $) {$a$};
\node[below] at ($ (C) ! .5 ! (D) $) {$a$};
\node[right,xshift=2pt] at ($ (A) ! .5 ! (F) $) {};
\node[right,xshift=2pt] at ($ (C) ! .5 ! (F) $) {};
\foreach \n in {A,B,C,D,E,F,P} {
  \fill (\n) circle[radius=1pt];
}
\end{tikzpicture}
\end{center}
Given an arbitrary triangle $\triangle ABC$, let $P$ be the intersection of the angle bisector of $\angle BAC$ and the perpendicular bisector of $\overline{BC}$. Label by $D,E,F$ the intersections of the altitudes from $P$ to the sides $\overline{BC}, \overline{AB}, \overline{AC}$. $\triangle APF\cong \triangle APE$ because they are right triangles with equal angles $\alpha$ and a common side $\overline{AP}$.

$\triangle DPC\cong \triangle DPB$ by side-angle-side because $\overline{PD}$ is a common side, $\angle PDB=\angle PDC$ are right angles and $\overline{BD}=\overline{DC}=a$ because $\overline{PD}$ is the perpendicular bisector of $\overline{BC}$. $\triangle EPB\cong \triangle FPC$ by side-side-angle in a right triangle, because $\overline{EP}=\overline{PF}$ by the first congruence and $\overline{PB}=\overline{PC}$ by the second congruence. By combining the equations we get that $\triangle ABC$ is isoceles:
\[
\overline{AB}= \overline{AE}+\overline{EB}=\overline{AF}+\overline{FC} =\overline{AC}\,.
\]
\newpage

The problem with the proof is that the diagram is incorrect because point $P$ is \emph{outside} the triangle, as can be seen from the following diagram:

\begin{center}
\begin{tikzpicture}
\coordinate (B) at (0,0);
\coordinate (C) at (8,0);
\path[name path=ba] (B) -- +(70:6);
\path[name path=ca] (C) -- +(140:8.5);
\path [name intersections={of=ba and ca,by={A}}];
\draw (B) -- (C) -- (A) -- cycle;
\fill (A) circle(1pt)
  node[above] {$A$}
  node[below,yshift=-12pt] {$\alpha$}
  node[below right,xshift=6pt,yshift=-12pt] {$\alpha$};
\fill (B) circle(1pt) node[left]  {$B$};
\fill (C) circle(1pt) node[right] {$C$};
\draw[name path=angle] (A) -- +(-75:9);
\draw ($(B)!.5!(C)$) -- +(0,3);
\draw[name path=perp] ($(B)!.5!(C)$) -- +(0,-3.5);
\path [name intersections={of=angle and perp,by={X}}];
\fill (X) circle(1pt);
\draw (4,0) rectangle +(8pt,8pt);
\end{tikzpicture}
\end{center}


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

\pagestyle{main}
\renewcommand{\chaptermark}[1]{\markboth{\chaptername\ \thechapter\ (#1)}{}}
\setcounter{chapter}{35}

\begin{document}

\chapter{Diffraction}
\section{Single Slit Diffraction}
\begin{itemize}
    \item \marginnote{8/17:}Shining light through only one slit still yields an interference pattern.
    \item We explain this with \textbf{diffraction}.
    \item Finding the location of minima on the screen:
    \begin{figure}[h!]
        \centering
        \begin{tikzpicture}
            \footnotesize
            \draw (0,-3) -- (0,-1) (-0.1,0) -- (0.1,0) (0,1) -- (0,3);
            \draw [very thin,dashed] (0,0) coordinate (O) -- (1,0) coordinate (N);

            \draw [blx,very thick]
                (-1.5,-2) -- ++(0,4)
                (-2,-2) -- ++(0,4)
                (-2.5,-2) -- ++(0,4)
            ;

            \draw [rex,thick,-latex] (0,1) node[circle,fill,inner sep=1.5pt,label={[yshift=2pt,black]below:$P_1$}]{} -- node[above,black]{$r_1$} ++(2,1);
            \draw [rex,thick,-latex] (0,0) node[circle,fill,inner sep=1.5pt,label={[yshift=2pt,black]below:$P_2$}]{} -- node[above,black]{$r_2$} ++(2,1) coordinate (r0);

            \draw [very thin,|-|] (-1.1,-1) -- node[left]{$a$} ++(0,2);
            \draw [very thin,|-|] (-0.5,-1) -- node[left]{$\frac{a}{2}$} ++(0,1);
            \draw [very thin,|-|] (-0.5,0) -- node[left]{$\frac{a}{2}$} ++(0,1);
            \pic [draw,angle eccentricity=1.3,pic text={$\theta$}] {angle=N--O--r0};
        \end{tikzpicture}
        \caption{Finding diffraction minima.}
        \label{fig:diffMinima}
    \end{figure}
    \begin{itemize}
        \item Let the one slit have width $a$.
        \item Only the part of the wavefront that aligns with the slit will pass through. However, according to Huygen's principle, when the light wave reaches the slit, it will act like infinitely many point sources of light all along the length of the slit.
        \item Consider two specific rays $r_1$ and $r_2$ emanating from the slit in same direction, one at the top and one in the middle. We know that if they are oriented at an angle that makes $\Delta r=\lambda/2$, then they cancel out.
        \item Generalizing, if any two rays satisfy $\frac{a}{2}\sin\theta=\lambda/2$ (i.e., satisfy $a\sin\theta=\lambda$), then they will cancel.
        \item Indeed, every $\theta$ satisfying $a\sin\theta=\lambda$ will cancel: Consider all the rays originating from every point in the slit that point in the $\theta$-direction, and notice that for any point in the slit, there will be a point $a/2$ units away from it; the rays from these two points will cancel. Thus, every ray is associated with another ray that cancels it out, guaranteeing that $\theta$ is an interference minimum.
        \item Note that if $\theta$ yields an interference minimum, then $\theta$ satisfying $a\sin\theta=m\lambda$ where $m\in\N$ will yield interference minima.
    \end{itemize}
\end{itemize}

\section{Intensity of Single Slit Diffraction}
\begin{itemize}
    \item Like before, $\theta=\ang{0}$ gives a \textbf{central diffraction maximum}.
    \item Finding the intensity maxima in general:
    \begin{figure}[h!]
        \centering
        \begin{tikzpicture}[
            every node/.style={black}
        ]
            \footnotesize
            \draw (0,-3) -- (0,-1) (-0.1,0) -- (0.1,0) (0,1) -- (0,3);
            \draw [very thin,dashed] (0,0) coordinate (O) -- (1,0) coordinate (N);

            \draw [semithick,->] (-0.3,0) -- ++(0,0.7) node[left]{$y$};

            \draw [rex,thick,-latex] (0,0.7) -- node[above]{$r$} ++(2,1);
            \draw [rex,thick,-latex] (0,0) -- node[above]{$r_0$} ++(2,1) coordinate (r0);

            \draw [very thin,|-|] (-0.7,-1) -- node[left]{$a$} ++(0,2);
            \pic [draw,angle eccentricity=1.3,pic text={$\theta$}] {angle=N--O--r0};
        \end{tikzpicture}
        \caption{Finding diffraction maxima.}
        \label{fig:diffMaxima}
    \end{figure}
    \begin{itemize}
        \item To find the intensity maxima, we derive an equation for the intensity in general as a function of $\theta$.
        \item To do so, we sum up every infinitesimal contribution of all the points along the slit with an integral, as follows.
        \item Since $\Delta r=y\sin\theta$ (see Figure \ref{fig:diffMaxima}), the wave function for the electric field wave along the arbitrary ray $r$ a distance $y$ from the central ray is given by
        \begin{align*}
            \cos(kr-\omega t) &= \cos(k[r_0+\Delta r]-\omega t)\\
            &= \cos\left( kr_0-\omega t+\frac{2\pi}{\lambda}\cdot y\sin\theta \right)
        \end{align*}
        \item It follows that the electric field $E$ at some point $P$ on the screen is given by
        \begin{align*}
            E &= A\int_{-a/2}^{a/2}\cos\left( kr_0-\omega t+\frac{2\pi\sin\theta}{\lambda}\cdot y \right)\dd{y}\\
            &= \frac{C}{\sin\theta}\cos(kr_0-\omega t)\sin\left( \frac{\pi a}{\lambda}\sin\theta \right)
        \end{align*}
        where $C$ represents a bunch of constants.
        \item Thus, since $I\propto E^2$,
        \begin{equation*}
            I \propto \frac{\sin^2\left( \frac{\pi a}{\lambda}\sin\theta \right)}{\sin^2\theta}
        \end{equation*}
        \item Additionally, if we define $\alpha=\frac{\pi a}{\lambda}\sin\theta$, then
        \begin{equation*}
            I = I_\text{max}\frac{\sin^2\alpha}{\alpha^2}
        \end{equation*}
        \item Notice that $\theta\to 0$ implies $\alpha\to 0$ implies $\sin(\alpha)/\alpha\to 1$ implies $I\to I_\text{max}$, as expected.
        \item Furthermore, since $\sin\alpha$ is bounded but $\alpha$ is not, $\sin^2(\alpha)/\alpha^2$ yields a graph of maxima that drop off in intensity as $\alpha\to\pm\infty$.
    \end{itemize}
    \item \textbf{Diffraction}: Bending of a light wave as it goes through a small slit.
    \begin{itemize}
        \item As slit width $a$ decreases, minima spread out.
    \end{itemize}
\end{itemize}

\section{Combining Interference and Diffraction}
\begin{itemize}
    \item \marginnote{8/19:}Every place you have a diffraction minimum, the wave that gets to the screen has 0 amplitude.
    \begin{itemize}
        \item If you have a point $P$ that's a diffraction minimum of both slits, interference doesn't matter --- you're going to have no intensity at $P$.
    \end{itemize}
    \item Slits $S_1$ and $S_2$ have the same diffraction pattern, just shifted by $d$.
    \begin{itemize}
        \item But if the diffraction pattern is large relative to $d$, as it usually is, we can neglect the shift.
    \end{itemize}
    \item Total intensity:
    \begin{figure}[h!]
        \centering
        \begin{tikzpicture}[
            every node/.append style={black}
        ]
            \footnotesize
            \begin{scope}[yshift=2cm]
                \draw [-stealth] (0,0) -- (0,2.5) node[above]{$I(\theta)$};
                \draw [stealth-stealth] (-3.5,0) -- (3.5,0) node[right]{$\theta$};

                \draw [orx,thick,xscale=2/pi] plot[domain=-4.33:4.33,samples=500,smooth] (\x,{2*cos(4*\x r)^2});
                \node at (1,2.4) {\normalsize 2 slits};
            \end{scope}
            \begin{scope}[yshift=-2cm]
                \draw [-stealth] (0,0) -- (0,2.5) node[above]{$I(\theta)$};
                \draw [stealth-stealth] (-3.5,0) -- (3.5,0) node[right]{$\theta$};

                \draw [orx,thick,xscale=2/pi] plot[domain=0.75:4.5,samples=500,smooth] (\x,{(2*cos(\x r)^2)/(\x*\x)});
                \draw [orx,thick,xscale=2/pi] plot[domain=-4.5:-0.75,samples=500,smooth] (\x,{(2*cos(\x r)^2)/(\x*\x)});
                \node at (1,2.4) {\normalsize 1 slit};
            \end{scope}

            \begin{scope}[xshift=10cm]
                \draw [-stealth] (0,0) -- (0,2.5) node[above]{$I(\theta)$};
                \draw [stealth-stealth] (-3.5,0) -- (3.5,0) node[right]{$\theta$};

                \draw [orx,thick,xscale=2/pi] plot[domain=-4.5:-0.75,samples=500,smooth] (\x,{(2*cos(\x r)^2)/(\x*\x)*cos(4*\x r)^2});
                \draw [orx,thick,xscale=2/pi] plot[domain=0.75:4.5,samples=500,smooth] (\x,{(2*cos(\x r)^2)/(\x*\x)*cos(4*\x r)^2});
                \draw [orx,thick,dashed,xscale=2/pi] plot[domain=0.75:4.5,samples=500,smooth] (\x,{(2*cos(\x r)^2)/(\x*\x)});
                \draw [orx,thick,dashed,xscale=2/pi] plot[domain=-4.5:-0.75,samples=500,smooth] (\x,{(2*cos(\x r)^2)/(\x*\x)});
            \end{scope}

            \draw [help lines,->,shorten >=5mm] (4,2) -- (6.5,0);
            \draw [help lines,->,shorten >=5mm] (4,-2) -- (6.5,0);
        \end{tikzpicture}
        \caption{Intensity considering both interference and diffraction.}
        \label{fig:intensityInterferenceDiffraction}
    \end{figure}
    \begin{itemize}
        \item We have that $I(\theta)=I(\theta)_\text{2 slits' interference}\times\text{diffraction envelope}$.
    \end{itemize}
\end{itemize}

\section{Circular Hole}
\begin{itemize}
    \item Consider light passing through a circular hole of diameter $a$.
    \begin{itemize}
        \item This yields concentric rings of intensity separated by nodes, i.e., a slit diffraction pattern that accounts for slits of every angle added on top of each other.
        \item As $a$ gets smaller, the central diffraction maximum gets bigger.
    \end{itemize}
    \item \textbf{Slit}: A one-dimensional opening.
    \item \textbf{Aperture}: A two-dimensional opening.
    \item We can no longer use $a\sin\theta=m\lambda$; we have to consider what happens with the extra dimensions.
    \begin{itemize}
        \item When we redo the calculation in two dimension, we get
        \begin{equation*}
            a\sin\theta = 1.22m\lambda
        \end{equation*}
        for $m\in\Z$.
        \item If $\theta$'s are small, then $\theta_\text{1st min}\approx 1.22\lambda/a$.
        \item Recall that $\theta_\text{1st min}=\theta_\text{$\frac{1}{2}$ width of central max}$, so we can use this formula to estimate the width of the central maximum.
    \end{itemize}
    \item As light passes through your pupil (an aperture), it undergoes diffraction and gets bigger before impinging on your retina.
    \begin{figure}[h!]
        \centering
        \begin{tikzpicture}
            \footnotesize
            \draw
                (3,0) -- (5,1) -- (3,2)
                (3.55,1) ellipse (3mm and 7mm)
                (4.5,0.75) to[out=120,in=-120] (4.5,1.25)
            ;
            \filldraw [draw=blx,very thick,fill=blz] (3.55,1) coordinate (pupil) ellipse (2pt and 5pt);

            \node (S1) [circle,fill=pix,inner sep=1.5pt,label={left:$S_1$}] at (0,1.6) {}
                edge [orx,thick] ($(S1)!1.25!(pupil)$)
            ;
            \node (S2) [circle,fill=pix,inner sep=1.5pt,label={left:$S_2$}] at (0,1.1) {}
                edge [orx,thick] ($(S2)!1.25!(pupil)$)
            ;

            \pic [draw,angle radius=2cm,angle eccentricity=1.15,pic text={$\theta_\text{sep}$}] {angle=S1--pupil--S2};
        \end{tikzpicture}
        \caption{Distinguishing sources of light.}
        \label{fig:lightRetina}
    \end{figure}
    \begin{itemize}
        \item Thus, to be able to distinguish two sources of light, we require $\theta_\text{sep}\geq\theta_\text{$\frac{1}{2}$ width of central max}$.
        \item For this reason, bigger telescopes are used not only to collect more light but also to minimize the effects of diffraction.
    \end{itemize}
    \item \textbf{Rayleigh criterion}: The condition for distinguishing sources of light, given by
    \begin{equation*}
        \theta_\text{sep} \geq 1.22\lambda/a
    \end{equation*}
    \item Pinhole camera.
    \begin{itemize}
        \item For a sharp focus, you want a small pinhole, improving the geometry.
        \item But if you make it too small, diffraction will come into play.
    \end{itemize}
\end{itemize}

\end{document}