\documentclass[main.tex]{subfiles}
\begin{document}

\section{Sheet 12}

\subsection{Gravitational wave detection}

\subsubsection{Linear order edges stationarity}

We consider a perturbed metric  \(g_{\mu \nu } = \eta_{\mu \nu } + h_{\mu \nu }\), and we denote as \(h\) the perturbative order in the correction to the Minkowski metric (\emph{not} the trace of \(h_{\mu \nu }\), which is gauge-dependent and usually set to zero).

We take a test mass in Minkowski spacetime, and we choose a coordinate system such that at a certain starting time \(\tau_0 \) this point is stationary, so at this time \(u^{\mu }(\tau = \tau_0  ) = u^{\mu }_{0} = [1, \vec{0}]^{\top}\) for this mass.

At a following time the gravitational wave arrives, and perturbs the test mass: the mass, by following geodesic motion with respect to the perturbed metric, will move with respect to the coordinates. This is described by the geodesic equation
%
\begin{align} \label{eq:geodesic-equation}
u^{\nu } \nabla_{\nu } u^{\mu } = \dv{ u^{\mu } }{\tau } + \Gamma^{\mu }_{\alpha \beta } u^{\alpha } u^{\beta } = 0
\,.
\end{align}

We want to prove that, in our gauge, the test mass does not acquire velocity to linear order in \(h\).
First of all, to zeroth order in \(h\) the mass is in a Minkowski spacetime so, the Christoffel symbols are all zero and it does not move. In fact, the Christoffel symbols are made up of terms of the form \(\Gamma \sim g^{-1} \partial g = g^{-1} \partial h\), which is  \(\mathcal{O}(h)\) at least.
The velocity, on the other hand, is nonzero at linear order: \(u^{\mu } = u^{\mu }_{0} + \mathcal{O}(h)\).

We wish to consider equation \eqref{eq:geodesic-equation} to linear order; more specifically we are interested in the second term \(\Gamma^{\mu }_{\alpha \beta } u^{\alpha } u^{\beta }\), which defines the time evolution of the 4-velocity. For this to be first order the velocity must be considered only to constant order, since the Christoffel symbols are already first order.

Therefore we are left with
%
\begin{subequations}
\begin{align}
\dv{ u^{\mu }}{\tau } &= - \Gamma^{\mu }_{\alpha \beta } u^{\alpha }_{0} u^{\beta }_{0} = - \Gamma^{\mu }_{00} \\
&= - \frac{1}{2} \eta^{\mu \nu } \qty(2h_{\nu  0, 0} + h_{00,\nu }) = 0 \marginnote{The inverse metric must be considered only to constant order, otherwise the term is second order}
\,,
\end{align}
\end{subequations}
%
which vanishes because, in our gauge, \(h_{\mu 0} = 0\) for all \(\mu \).

\subsubsection{Linear order gravitational wave \(\Delta T / T\)}

We consider a gravitational wave
%
\begin{align}
h_{ij} (t, \vec{x}) = \cos(kt - \vec{k} \cdot \vec{x}) \sum _{r = \times , +} e_{ij}^{r} h_{r}
\,,
\end{align}
%
where
%
\begin{subequations}
\begin{align}
e_{ij}^{+} = \left[\begin{array}{cc}
1 &  0 \\
0 & -1
\end{array}\right] \qquad \text{and} \qquad
e_{ij}^{ \times } = \left[\begin{array}{cc}
0 & 1 \\
1 & 0
\end{array}\right]
\,
\end{align}
\end{subequations}
%
and \(\vec{k}^2 = k^2\). In principle the cosine could have an arbitrary phase added to the argument, but we set it to zero for simplicity.
Also, we set \(\vec{k} = k \hat{z}\).

Our interferometer configuration is as follows at order \(h^{0}\): we have the beamsplitter at coordinates \(\vec{B} = [0,0,0]^{\top}\) and the two mirrors at coordinates \(\vec{M}_{1} = T [\cos(\alpha ), \sin(\alpha ),0]^{\top} T \hat{L}_{1}\) and \(\vec{M}_{2} = T [ \cos(\alpha + \pi /2), \sin(\alpha + \pi /2),0]^{\top} = T \hat{L}_{2}\), for some angle \(\alpha \): this means that the arms are orthogonal and at a certain angle with respect to the incoming gravitational wave's basis axes.
We also defined some basis vectors aligned along the interferometer's arms.

We start off two beams of light at the beamsplitter at \(t=0\), and see how much time they each take to reach their respective mirrors. If these are the times \(T_{1,2}\) we then define \(\Delta T = \abs{T_1 - T_2 }\) and compute \(\Delta T / T\).

Photons' trajectories are defined by \(\dd{s^2} = 0\): so, if we parametrize a photon trajectory by \(x^{\mu }_{p} (\lambda ) = \lambda [1, \hat{L}_{p}]^{\top}\) (for \(p = 1, 2\)) this means that the photon's 4-velocity is
%
\begin{align}
u^{\mu }_{p} = \dv{}{\lambda } x^{\mu }_{p}(\lambda ) = [1, \hat{L}_{p}]
\,,
\end{align}
%
so if we assume the 4-velocity is normalized in the perturbed metric we find
%
\begin{subequations}
\begin{align}
0=\dd{s^2} &= - \dd{t_{p}^2} + \qty(\delta_{ij} + h_{ij}) \hat{L}^{i}_{p} \hat{L}^{j}_{p} \dd{\lambda^2}   \marginnote{\(\hat{L}\) is a unit vector}[.5cm]\\
\dd{t_{p}^2}  &= \qty(1 + h_{ij} \hat{L}^{i}_{p} \hat{L}^{j}_{p}) \dd{\lambda^2}  \\
\dd{t_{p}}  &= \sqrt{1 + h_{ij} \hat{L}^{i}_{p} \hat{L}^{j}_{p}} \dd{\lambda} \approx \qty(1 + \frac{1}{2} \abs{\hat{L}_{p}}_{h}^2) \dd{\lambda }
\,,
\end{align}
\end{subequations}
%
where by \(\abs{\hat{L}_{p}}_{h}\) we mean the norm of the vector \(\hat{L}\) taken with respect to the bilinear form \(h_{ij}\).

Now, we can compute the integral giving us the total time:
%
\begin{subequations}
\begin{align}
T_{p} &= \int \dd{t_{p}}  \\
&\approx \int \qty(1 + \frac{1}{2} \abs{\hat{L}_{p}}_{h}^2) \dd{\lambda }  \\
&= T + \frac{1}{2} \int \dd{\lambda } \cos(kt-\vec{k}\cdot \vec{x})  \qty(\sum_{r} e^{r}_{ij} h_{r} )\hat{L}^{i}_{p}\hat{L}^{j}_{p}
\,,
\end{align}
\end{subequations}
%
where \(t\) and \(\vec{x}\) are to be considered as functions of \(\lambda \): \(t=\lambda \) and \(\vec{x} = \hat{L}_{p} \lambda \), but by what we have assumed \(\vec{k} \cdot \vec{x} =0\) since the gravitational wave is perpendicular to the interferometer's plane.

Before assuming anything else, let us compute the bilinear form contribution. For brevity we will denote a cosine as \(c\) and a sine as \(s\). Then, for both \(p =1\) and \(p=2\) we will have:
%
\begin{subequations}
\begin{align}
e_{ij}^{+} \hat{L}^{i}_{p} \hat{L}^{j}_p
= \left[\begin{array}{ccc}
c & s & 0
\end{array}\right]
\left[\begin{array}{ccc}
1 & 0 & 0 \\
0 & -1 & 0 \\
0 & 0 & 0
\end{array}\right]
\left[\begin{array}{c}
c \\
s \\
0
\end{array}\right]= c^2- s^2
\,
\end{align}
\end{subequations}
%
for the plus polarization, and
%
\begin{subequations}
\begin{align}
e_{ij}^{ \times } \hat{L}^{i}_{p} \hat{L}^{j}_p
= \left[\begin{array}{ccc}
c & s & 0
\end{array}\right]
\left[\begin{array}{ccc}
0 & 1 & 0 \\
1 & 0 & 0 \\
0 & 0 & 0
\end{array}\right]
\left[\begin{array}{c}
c \\
s \\
0
\end{array}\right]= 2cs
\,
\end{align}
\end{subequations}
%
for the cross polarization. Now, recall that
%
\begin{align}
\cos^2 x - \sin^2 x = \cos(2x) \qquad \text{and} \qquad
2 \sin x \cos x = \sin (2 x)
\,,
\end{align}
%
and \emph{also} notice that we need to evaluate these expressions for \(x = \alpha \) for the first arm, with \(p=1\), and for \(x = \alpha + \pi /2\) for the other arm, with \(p=2\). Then, since all the dependence is on trigonometric functions of \emph{two times} \(x\) we must have that the correction on one arm is exactly equal in value and opposite in sign to the correction on the other arm, since the argument of the trigonometric functions changes by \(\pi \) and both sine and cosine are odd under translations of \(\pi \).

This means that in the global expression for \(\Delta T\) we will have twice the same term: then we can collect them, and find
%
\begin{align}
\Delta T = \qty(h_{+} \cos(2 \alpha ) + h_{ \times } \sin(2 \alpha )) \int \dd{\lambda } \cos(\lambda k)
\,,
\end{align}
%
where \(k\) is the wavenumber / frequency of the gravitational wave, while \(\lambda \) must be integrated from 0 to \(T\), the length of the interferometer arms.

The dimensions of the argument of the cosine are \SI{}{m/s}, so in order to make it adimensional we need to divide it by \(c\). The typical order of magnitude of the frequencies of GWs detected at the LIGO/VIRGO detectors is around \(f = \SI{100}{Hz}\), while the length of the arms is around \(T =\SI{4}{km}\). Therefore, the argument of the cosine is bounded by
%
\begin{align}
\frac{2 \pi f T }{c} \lesssim \frac{\SI{100}{Hz} \times \SI{4}{km}}{c} \approx \num{e-2}
\,,
\end{align}
%
where we used the relation between frequency and angular velocity: \(k = 2 \pi f\). This is small but not exceedingly small: we can approximate \(\cos(\lambda k ) = \const\) but our predictions will not exceed second-significant-digit accuracy.

With this approximation, the integral will equal the size of the integration region times the value of the cosine, leaving us with:
%
\begin{align}
\Delta T = \qty(h_{+} \cos(2 \alpha ) + h_{ \times } \sin(2 \alpha )) T \cos(t k)
\,,
\end{align}
%
which will vary in time in general, but if the light starts at \(t=0\) then in our approximation the cosine will always equal \(1\).  In the end  then we will be left with:
%
\begin{align}
\frac{\Delta T}{T} = h_{+} \cos(2 \alpha ) + h_{ \times } \sin(2 \alpha )
\,.
\end{align}

\subsubsection{Return trip \(\Delta T / T\)}

If we want to consider the return trip, almost everything will be the same except:
\begin{enumerate}
  \item the starting time and arrival time will change;\label{it:starting-time}
  \item the unit vectors \(\hat{L}\) will change into \(- \hat{L}\). \label{it:parity}
\end{enumerate}

Point \ref{it:starting-time} is not a concern if we are in the small frequency approximation: the cosine  will still almost be equal to 1, although the approximation will get a little worse.

Point \ref{it:parity} is not a concern either: the \(h-\)norm \(\hat{L} \rightarrow h_{ij} \hat{L}^{i} \hat{L}^{j}\) is symmetric, so the norm of a unit vector does not change under parity.

This means that over the time of the return trip a difference \(\Delta T _{\text{return}} = \Delta T _{\text{forward}}\) will be accumulated, so when we calculate \(\Delta T _{\text{total}} / (2T)\) we will get the same result we did with just the forward trip.

\subsubsection{Exact integration}

We now wish to calculate the global time difference without assuming \(k \lambda \) is small. As we saw before the contributions for the forward and backward journeys are the same, so we need to evaluate the integral
%
\begin{align}
\int_{0}^{2T} \cos(\lambda k) \dd{\lambda }
= \left. \frac{1}{k} \sin(\lambda k ) \right\vert_{\lambda = 0}^{\lambda = 2T} = \frac{\sin(2Tk)}{k}
\,,
\end{align}
%
and, as expected, if \(Tk \sim 0\) then
%
\begin{align}
\frac{\sin(2Tk)}{k} \sim \frac{2Tk}{k} = 2T
\,.
\end{align}

So, the proper formula is
%
\begin{align}
\frac{\Delta T}{2T} =
\qty(h_{+} \cos(2 \alpha ) + h_{ \times } \sin(2 \alpha ))
\frac{\sin(2Tk)}{2Tk}
\,.
\end{align}

This vanishes for all the zeros of \(\sin(2Tk)\): for \(k=0\) this is expected (there is no gravitational wave) but it is weird for \(2Tk = n \pi \), \(n \in \mathbb{Z} \setminus \qty{0}\).

Let us look at the first weird case: \(2Tk = \pi \) to get an idea.

In that case, we have \(k =  \pi / 2T \), so the frequency of the GW is \(f = k / 2 \pi  =  1/ 4 T\).

Since gravitational waves travel at velocity 1, we have \(fP = 1\), where \(f\) and \(P\) are respectively the  frequency and period of the GW (spatial or temporal: it is equivalent, since \(c=1\)).
This means that, in the case we are considering, the wavelength of the GW is precisely equal to twice the length of the interferometer's arm, since we found \(P = 4T\).

More generally, we will have \(k = n \pi /2T\)
%
\begin{align}
P = \frac{1}{f} = \frac{2 \pi }{k} = \frac{4 \pi T}{n \pi } = \frac{4T}{n}
\,,
\end{align}
%
and we have proven that at precisely those frequencies the gravitational wave will have a vanishing net effect, since it will go through precisely \(n\) cycles during the beam's trajectory.

% The factor of 2 is \emph{probably} connected with the spin-2 nature of gravitons (i.\ e.\ the fact that they are symmetric under rotations of \(\pi \) around the wavevector).

\end{document}


\documentclass[12pt]{article}
\author{David Alves}

\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{dirtytalk}
\usepackage[a4paper]{geometry}
\usepackage{forest}
\usepackage{listings}
\usepackage{mathtools}
\usepackage{multicol}
\usepackage{nth}
\usepackage{relsize}
\usepackage{skak}
\usepackage{tikz}
\usepackage{tikz-qtree}
\usepackage{titling}
\usepackage{wrapfig}
\usepackage{xcolor}

\usetikzlibrary{decorations.pathreplacing}
\usetikzlibrary{patterns}

\DeclarePairedDelimiter\ceil{\lceil}{\rceil}
\DeclarePairedDelimiter\floor{\lfloor}{\rfloor}

\def\multichoose#1#2{\ensuremath{\left(\kern-.3em\left(\genfrac{}{}{0pt}{}{#1}{#2}\right)\kern-.3em\right)}}

\newcommand{\ts}[1]{\textsuperscript{#1}}

\newcommand{\ProblemStatement}[1]{
\subsection*{Problem Statement}
#1
\subsection*{Solution}
}

% If uncommented, next line hides problem statements
%\renewcommand{\ProblemStatement}[1]{}

\title{Math 142 Problem Set 13}
\author{David Alves}
\date{2016-12-01}

\begin{document}
\pagenumbering{gobble}

\begin{center}
\large \thetitle \\
\theauthor \\
\thedate
\end{center}

\subsection*{Sources}

    \begin{itemize}
    \item http://tex.stackexchange.com and https://www.sharelatex.com for help with \LaTeX
    \end{itemize}

\section{Patriotic Octagons}
\ProblemStatement{
Suppose you have to paint each edge of an octagon red, white, or blue. Find the
number of ways to do this, counting two painting methods the same if they can be
obtained from each other by rotation.
}

There are 834 ways of painting the sides of an octagon red, white, or blue that
are distinct under rotation.

\begin{proof}
Let $G = C_8$, the cyclic group of 8 elements. Let 1 denote the identity
permutation in $G$, $g$ denote rotation by 1, $g^2$ denote rotation by two, etc.
We know that $Fix(g^k)$ is the number of colors (3) to the power of the number
of cycles in $g^k$, since each cycle must have all elements the same color.
Below are the cycles counts for each permutation.

\subsubsection*{One Cycle}

\begin{tikzpicture}
\node at (0,0) {$g$};
\node[shape=circle] (A) at (0,1.5) {1};
\node[shape=circle] (B) at (1.06,1.06) {2};
\node[shape=circle] (C) at (1.5,0) {3};
\node[shape=circle] (D) at (1.06,-1.06) {4};
\node[shape=circle] (E) at (0,-1.5) {5};
\node[shape=circle] (F) at (-1.06,-1.06) {6};
\node[shape=circle] (G) at (-1.5,0) {7};
\node[shape=circle] (H) at (-1.06,1.06) {8};
\draw [->] (A) edge[bend left=10] (B);
\draw [->] (B) edge[bend left=10] (C);
\draw [->] (C) edge[bend left=10] (D);
\draw [->] (D) edge[bend left=10] (E);
\draw [->] (E) edge[bend left=10] (F);
\draw [->] (F) edge[bend left=10] (G);
\draw [->] (G) edge[bend left=10] (H);
\draw [->] (H) edge[bend left=10] (A);
\end{tikzpicture}
\begin{tikzpicture}
\node at (0,0) {$g^7$};
\node[shape=circle] (A) at (0,1.5) {1};
\node[shape=circle] (B) at (1.06,1.06) {2};
\node[shape=circle] (C) at (1.5,0) {3};
\node[shape=circle] (D) at (1.06,-1.06) {4};
\node[shape=circle] (E) at (0,-1.5) {5};
\node[shape=circle] (F) at (-1.06,-1.06) {6};
\node[shape=circle] (G) at (-1.5,0) {7};
\node[shape=circle] (H) at (-1.06,1.06) {8};
\draw [->] (A) edge[bend right=10] (H);
\draw [->] (B) edge[bend right=10] (A);
\draw [->] (C) edge[bend right=10] (B);
\draw [->] (D) edge[bend right=10] (C);
\draw [->] (E) edge[bend right=10] (D);
\draw [->] (F) edge[bend right=10] (E);
\draw [->] (G) edge[bend right=10] (F);
\draw [->] (H) edge[bend right=10] (G);
\end{tikzpicture}
\begin{tikzpicture}
\node at (0,0) {$g^3$};
\node[shape=circle] (A) at (0,1.5) {1};
\node[shape=circle] (B) at (1.06,1.06) {2};
\node[shape=circle] (C) at (1.5,0) {3};
\node[shape=circle] (D) at (1.06,-1.06) {4};
\node[shape=circle] (E) at (0,-1.5) {5};
\node[shape=circle] (F) at (-1.06,-1.06) {6};
\node[shape=circle] (G) at (-1.5,0) {7};
\node[shape=circle] (H) at (-1.06,1.06) {8};
\draw [->] (A) edge[bend right=10] (D);
\draw [->] (B) edge[bend right=10] (E);
\draw [->] (C) edge[bend right=10] (F);
\draw [->] (D) edge[bend right=10] (G);
\draw [->] (E) edge[bend right=10] (H);
\draw [->] (F) edge[bend right=10] (A);
\draw [->] (G) edge[bend right=10] (B);
\draw [->] (H) edge[bend right=10] (C);
\end{tikzpicture}
\begin{tikzpicture}
\node at (0,0) {$g^5$};
\node[shape=circle] (A) at (0,1.5) {1};
\node[shape=circle] (B) at (1.06,1.06) {2};
\node[shape=circle] (C) at (1.5,0) {3};
\node[shape=circle] (D) at (1.06,-1.06) {4};
\node[shape=circle] (E) at (0,-1.5) {5};
\node[shape=circle] (F) at (-1.06,-1.06) {6};
\node[shape=circle] (G) at (-1.5,0) {7};
\node[shape=circle] (H) at (-1.06,1.06) {8};
\draw [->] (A) edge[bend left=10] (F);
\draw [->] (B) edge[bend left=10] (G);
\draw [->] (C) edge[bend left=10] (H);
\draw [->] (D) edge[bend left=10] (A);
\draw [->] (E) edge[bend left=10] (B);
\draw [->] (F) edge[bend left=10] (C);
\draw [->] (G) edge[bend left=10] (D);
\draw [->] (H) edge[bend left=10] (E);
\end{tikzpicture}

\subsubsection*{Two Cycles}
\begin{tikzpicture}
\node at (0,0) {$g^2$};
\node[shape=circle] (A) at (0,1.5) {1};
\node[shape=circle] (B) at (1.06,1.06) {2};
\node[shape=circle] (C) at (1.5,0) {3};
\node[shape=circle] (D) at (1.06,-1.06) {4};
\node[shape=circle] (E) at (0,-1.5) {5};
\node[shape=circle] (F) at (-1.06,-1.06) {6};
\node[shape=circle] (G) at (-1.5,0) {7};
\node[shape=circle] (H) at (-1.06,1.06) {8};
\draw [->] (A) edge[bend right=30] (C);
\draw [->] (B) edge[bend right=30] (D);
\draw [->] (C) edge[bend right=30] (E);
\draw [->] (D) edge[bend right=30] (F);
\draw [->] (E) edge[bend right=30] (G);
\draw [->] (F) edge[bend right=30] (H);
\draw [->] (G) edge[bend right=30] (A);
\draw [->] (H) edge[bend right=30] (B);
\end{tikzpicture}
\begin{tikzpicture}
\node at (0,0) {$g^6$};
\node[shape=circle] (A) at (0,1.5) {1};
\node[shape=circle] (B) at (1.06,1.06) {2};
\node[shape=circle] (C) at (1.5,0) {3};
\node[shape=circle] (D) at (1.06,-1.06) {4};
\node[shape=circle] (E) at (0,-1.5) {5};
\node[shape=circle] (F) at (-1.06,-1.06) {6};
\node[shape=circle] (G) at (-1.5,0) {7};
\node[shape=circle] (H) at (-1.06,1.06) {8};
\draw [->] (A) edge[bend left=30] (G);
\draw [->] (B) edge[bend left=30] (H);
\draw [->] (C) edge[bend left=30] (A);
\draw [->] (D) edge[bend left=30] (B);
\draw [->] (E) edge[bend left=30] (C);
\draw [->] (F) edge[bend left=30] (D);
\draw [->] (G) edge[bend left=30] (E);
\draw [->] (H) edge[bend left=30] (F);
\end{tikzpicture}\\

\noindent\begin{minipage}{.35\textwidth}
\subsubsection*{Four Cycles}
\begin{tikzpicture}
\node at (0,0) {$g^4$};
\node[shape=circle] (A) at (0,1.5) {1};
\node[shape=circle] (B) at (1.06,1.06) {2};
\node[shape=circle] (C) at (1.5,0) {3};
\node[shape=circle] (D) at (1.06,-1.06) {4};
\node[shape=circle] (E) at (0,-1.5) {5};
\node[shape=circle] (F) at (-1.06,-1.06) {6};
\node[shape=circle] (G) at (-1.5,0) {7};
\node[shape=circle] (H) at (-1.06,1.06) {8};
\draw [->] (A) edge[bend left=20] (E);
\draw [->] (B) edge[bend left=20] (F);
\draw [->] (C) edge[bend left=20] (G);
\draw [->] (D) edge[bend left=20] (H);
\draw [->] (E) edge[bend left=20] (A);
\draw [->] (F) edge[bend left=20] (B);
\draw [->] (G) edge[bend left=20] (C);
\draw [->] (H) edge[bend left=20] (D);
\end{tikzpicture}
\end{minipage}%
\begin{minipage}{.5\textwidth}
\subsubsection*{Eight Cycles}
\begin{tikzpicture}
\node at (0,.15) {\textbf{(id)}};
\node[shape=circle] (A) at (0,1.5) {1};
\node[shape=circle] (B) at (1.06,1.06) {2};
\node[shape=circle] (C) at (1.5,0) {3};
\node[shape=circle] (D) at (1.06,-1.06) {4};
\node[shape=circle] (E) at (0,-1.5) {5};
\node[shape=circle] (F) at (-1.06,-1.06) {6};
\node[shape=circle] (G) at (-1.5,0) {7};
\node[shape=circle] (H) at (-1.06,1.06) {8};
\draw [->] (A) edge[loop above,looseness=4] (A);
\draw [->] (B) edge[loop above,looseness=4] (B);
\draw [->] (C) edge[loop above,looseness=4] (C);
\draw [->] (D) edge[loop above,looseness=4] (D);
\draw [->] (E) edge[loop above,looseness=4] (E);
\draw [->] (F) edge[loop above,looseness=4] (F);
\draw [->] (G) edge[loop above,looseness=4] (G);
\draw [->] (H) edge[loop above,looseness=4] (H);
\end{tikzpicture}
\end{minipage}

Therefore we have the following cardinalities for $Fix(g^k)$:

\begin{center}
\begin{tabular}{ rcccl }
    $|Fix(1)|  $ &=& $3^8$ &=& 6561\\
    $|Fix(g)|  $ &=& $3^1$ &=& 3\\
    $|Fix(g^2)|$ &=& $3^2$ &=& 9\\
    $|Fix(g^3)|$ &=& $3^1$ &=& 3\\
    $|Fix(g^4)|$ &=& $3^4$ &=& 81\\
    $|Fix(g^5)|$ &=& $3^1$ &=& 3\\
    $|Fix(g^6)|$ &=& $3^2$ &=& 9\\
    $|Fix(g^7)|$ &=& $3^1$ &=& 3\\
\end{tabular}
\end{center}

By the Polya-Burnside theorem, the number of orbits (aka distinct paintings
after considering rotation) is $\frac{1}{|G|}\sum_{g \in G} |Fix(g)|$, thus we
have $\frac{1}{8}(6561 + 3 + 9 + 3 + 81 + 3 + 9 + 1) = $ 834 total ways to
paint the octagon.
\end{proof}

\section{Thanksgiving Dinner}
\ProblemStatement{
Your grandmother cooked a turkey, stuffng, cornbread, 2 distinguishable salads
(Caesar and spinach) and 3 distinguishable desserts (pumpkin pie, chocolate
mayhem cake, and sweet potato pie). You're allowed to eat or not eat any
particular of these 8 dishes (we assume you have infinite stomach space), but
you have to follow The Granny's Rule, which is that you cannot have any type of
dessert if you do not eat at least one salad. How many ways of eating are there?
(again, we do not care about the amount you are eating of each food, just
whether you eat it or not).
}

There are 200 possible ways of eating.

\begin{proof}
Assume for a moment that only the 2 salads and 3 deserts existed. There would be 4
possibilities for salad consumption and 8 possibilities for dessert consumption.
3 of the 4 salad possibilities (the ones where at least one salad is eaten)
allow any dessert possibility, while the last one (where no salad is eaten)
allows only one desert possibility (the one where no desert is eaten). Thus we
have $3 \times 8 + 1 \times 1 = 25$ possible meals when we only consider salad
and desert. There are no restrictions on the other courses, so for each of those
25 valid salad-dessert combinations there are 8 possibilities for the
other dishes, giving $8 \times 25 = 200$ possible meals in total.
\end{proof}

\section{Thankfulness}
\ProblemStatement{
What are you thankful for?
}

I'm thankful for my health and my family. It's been a good year and we've been
very fortunate. In particular my wife and I had a baby daughter in January and
she's happy and healthy, so I'm very thankful for her.

\section{Generating with Powers of Ten}
\ProblemStatement{
Show with generating functions that every nonnegative integer has a unique
decimal expansion (think about what this means; consult earlier homework for
help).
}

\begin{proof}
We can represent the decimal expansions using this generating function:

\[
\prod_{i=0}^{\infty} \left(1 + x^{10^i} + x^{2\times10^i} + \dots + x^{8\times10^i} + x^{9\times10^i}\right)
\]

The term where $i=0$ is the ones place, $i=1$ is the tens place, etc., while the 10 choices inside the parentheses represent the choices for that digit. In order to show that every nonnegative integer has a unique representation, we must show that

\[
\prod_{i=0}^{\infty} \left(1 + x^{10^i} + x^{2\times10^i} + \dots + x^{8\times10^i} + x^{9\times10^i}\right) = 1 + x + x^2 + x^3 + \dots
\]

We prove this by induction. Let $p(n)$ be the following statement:

\[
\prod_{i=0}^{n} \left(1 + x^{10^i} + x^{2\times10^i} + \dots + x^{8\times10^i} + x^{9\times10^i}\right) = 1 + x + x^2 + x^3 + \dots + x^{10^{n+1}-1}
\]
\\
$p(0)$ is the statement $(1 + x + x^2 + x^3 + \dots + x^8 + x^9) = (1 + x + x^2 + x^3+ \dots + x^8 + x^9)$, which is true. Next we must show that if $p(n)$ is true, $p(n+1)$ must also be true.\\

Multiplying both sides of $p(n)$ by $(1 + x^{10^{n+1}} + x^{2\times10^{n+1}} + \dots + x^{8\times10^{n+1}} + x^{9\times10^{n+1}})$ gives:

\begin{align*}
\prod_{i=0}^{n+1} \left(1 + x^{10^i} + x^{2\times10^i} + \dots + x^{8\times10^i} + x^{9\times10^i}\right) =
                    (1)\left(1 + x + x^2 + x^3 + \dots + x^{10^{n+1}-1}\right) + \\
\left(x^{       {10^{n+1}}}\right)\left(1 + x + x^2 + x^3 + \dots + x^{10^{n+1}-1}\right) +\\
\left(x^{2\times{10^{n+1}}}\right)\left(1 + x + x^2 + x^3 + \dots + x^{10^{n+1}-1}\right) +\\
\left(x^{3\times{10^{n+1}}}\right)\left(1 + x + x^2 + x^3 + \dots + x^{10^{n+1}-1}\right) +\\
\left(x^{4\times{10^{n+1}}}\right)\left(1 + x + x^2 + x^3 + \dots + x^{10^{n+1}-1}\right) +\\
\left(x^{5\times{10^{n+1}}}\right)\left(1 + x + x^2 + x^3 + \dots + x^{10^{n+1}-1}\right) +\\
\left(x^{6\times{10^{n+1}}}\right)\left(1 + x + x^2 + x^3 + \dots + x^{10^{n+1}-1}\right) +\\
\left(x^{7\times{10^{n+1}}}\right)\left(1 + x + x^2 + x^3 + \dots + x^{10^{n+1}-1}\right) +\\
\left(x^{8\times{10^{n+1}}}\right)\left(1 + x + x^2 + x^3 + \dots + x^{10^{n+1}-1}\right) +\\
\left(x^{9\times{10^{n+1}}}\right)\left(1 + x + x^2 + x^3 + \dots + x^{10^{n+1}-1}\right) +\\
\end{align*}
Multiplying through gives
\begin{align*}
\prod_{i=0}^{n+1} \left(1 + x^{10^i} + x^{2\times10^i} + \dots + x^{8\times10^i} + x^{9\times10^i}\right) =
\left(1 + x + x^2 + \dots + x^{10^{n+1}-2} + x^{10^{n+1}-1}\right) + \\
\left(x^{10^{n+1}} + x^{10^{n+1}+1} + x^{10^{n+1}+2} + \dots + x^{10^{n+1} + x^{10^{n+1}-2}} + x^{10^{n+1} + x^{10^{n+1}-1}}\right) +\\
\left(x^{2\times10^{n+1}} + x^{2\times10^{n+1}+1} + x^{2\times10^{n+1}+2} + \dots + x^{2\times10^{n+1} + 10^{n+1}-2} + x^{2\times10^{n+1} + 10^{n+1}-1}\right) +\\
\left(x^{3\times10^{n+1}} + x^{3\times10^{n+1}+1} + x^{3\times10^{n+1}+2} + \dots + x^{3\times10^{n+1} + 10^{n+1}-2} + x^{3\times10^{n+1} + 10^{n+1}-1}\right) +\\
\left(x^{4\times10^{n+1}} + x^{4\times10^{n+1}+1} + x^{4\times10^{n+1}+2} + \dots + x^{4\times10^{n+1} + 10^{n+1}-2} + x^{4\times10^{n+1} + 10^{n+1}-1}\right) +\\
\left(x^{5\times10^{n+1}} + x^{5\times10^{n+1}+1} + x^{5\times10^{n+1}+2} + \dots + x^{5\times10^{n+1} + 10^{n+1}-2} + x^{5\times10^{n+1} + 10^{n+1}-1}\right) +\\
\left(x^{6\times10^{n+1}} + x^{6\times10^{n+1}+1} + x^{6\times10^{n+1}+2} + \dots + x^{6\times10^{n+1} + 10^{n+1}-2} + x^{6\times10^{n+1} + 10^{n+1}-1}\right) +\\
\left(x^{7\times10^{n+1}} + x^{7\times10^{n+1}+1} + x^{7\times10^{n+1}+2} + \dots + x^{7\times10^{n+1} + 10^{n+1}-2} + x^{7\times10^{n+1} + 10^{n+1}-1}\right) +\\
\left(x^{8\times10^{n+1}} + x^{8\times10^{n+1}+1} + x^{8\times10^{n+1}+2} + \dots + x^{8\times10^{n+1} + 10^{n+1}-2} + x^{8\times10^{n+1} + 10^{n+1}-1}\right) +\\
\left(x^{9\times10^{n+1}} + x^{9\times10^{n+1}+1} + x^{9\times10^{n+1}+2} + \dots + x^{9\times10^{n+1} + 10^{n+1}-2} + x^{9\times10^{n+1} + 10^{n+1}-1}\right)\\
\end{align*}

which can be simplified to

\[
\prod_{i=0}^{n+1} \left(1 + x^{10^i} + x^{2\times10^i} + \dots + x^{8\times10^i} + x^{9\times10^i}\right) = 1 + x + x^2 + x^3 + \dots + x^{10^{n+2}-1}
\]

Since this is $p(n+1)$, we have shown that if $p(n)$ is true then $p(n+1)$ must be true, which completes the inductive proof.

\end{proof}

\section{Majority Rules}
\ProblemStatement{
Say $(2n + 1)$ people, including you, have a majority vote in a company for
allowing or disallowing hats to be worn in the company. If you know everyone
else is going to vote uniformly randomly for \say{yes} or \say{no}, what is the
probability that your vote is \say{critical}? (we define your vote to be
\say{critical} if after we fix everyone else's vote, you voting one way or
other changes the result) (optional: with a computer, explore the probability
that your vote is critical for big $n$, or for there being 3 outcomes instead
of 2)
}

The probability that your vote is \say{critical} is
\[
    \binom{2n}{n}\left(\frac{1}{2}\right)^{2n}
\]

\begin{proof}
First we observe that your vote is only critical if the other $2n$ votes
are tied with $n$ voting yes and $n$ voting no. If they were not tied, there
would have to be at least $n+1$ votes on one side and at most $n-1$ votes on
the other, so your vote would not be critical since there is a difference of
two.

There are $\binom{2n}{n}$ ways to choose the $n$ yes votes from among the $2n$
total votes. For each of those ways, the probability that it will occur is
$(\frac{1}{2})^n$ (the chance that all $n$ of the yes voters will vote yes)
times $(\frac{1}{2})^n$ (the chance that all $n$ of the no voters will vote
no). This gives an overall probability of $\binom{2n}{n}(\frac{1}{2})^{2n}$
\end{proof}

\subsection*{Optional}
Here's a Python program which generates $2n$ random votes and measures how often they are evenly split for large values of $n$:
\begin{center}
\begin{lstlisting}[language=Python]
#!/usr/bin/env python3
import random

def is_close(n):
    v = random.getrandbits(2*n)
    return bin(v).count('1') == n

def p_close(n, trials):
    return sum(is_close(n) for i in range(trials)) / trials

for exp in range(20):
    n = 2**exp
    trials = min(2**24, 2**(34-exp))
    print(exp, n, trials, p_close(n, trials), sep='\t')
\end{lstlisting}
\end{center}

\noindent Here's a table summarizing the output:

\begin{center}
\begin{tabular}{ lllr }
\hline
    $n$ & Measured Probability & Predicted Probability & Trials Run\\
\hline
$2^0    = 1     $ & 0.5001128315925598    & 0.5                 & 16777216 \\
$2^1    = 2     $ & 0.37497973442077637   & 0.375               & 16777216 \\
$2^2    = 4     $ & 0.2733776569366455    & 0.273438            & 16777216 \\
$2^3    = 8     $ & 0.19642597436904907   & 0.196381            & 16777216 \\
$2^4    = 16    $ & 0.13995373249053955   & 0.13995             & 16777216 \\
$2^5    = 32    $ & 0.09931820631027222   & 0.0993468           & 16777216 \\
$2^6    = 64    $ & 0.07034200429916382   & 0.0703861           & 16777216 \\
$2^7    = 128   $ & 0.04979640245437622   & 0.0498191           & 16777216 \\
$2^8    = 256   $ & 0.03525400161743164   & 0.0352446           & 16777216 \\
$2^9    = 512   $ & 0.02493804693222046   & 0.02492780589297954 & 16777216 \\
$2^{10} = 1024  $ & 0.017606258392333984  & 0.01762877240484652 & 16777216 \\
$2^{11} = 2048  $ & 0.012477874755859375  & 0.0124661853637603  & 8388608  \\
$2^{12} = 4096  $ & 0.008898258209228516  & 0.0088151932204816  & 4194304  \\
$2^{13} = 8192  $ & 0.006194591522216797  & 0.0062333780167465  & 2097152  \\
$2^{14} = 16384 $ & 0.004390716552734375  & 0.0044076974932754  & 1048576  \\
$2^{15} = 32768 $ & 0.003177642822265625  & 0.0031167246762524  & 524288   \\
$2^{16} = 65536 $ & 0.00229644775390625   & 0.0022038613571975  & 262144   \\
$2^{17} = 131072$ & 0.00154876708984375   & 0.0015583667966430  & 131072   \\
$2^{18} = 262144$ & 0.00140380859375      & 0.001101932254924   & 65536    \\
$2^{19} = 524288$ & 0.000946044921875     & 0.000779183955637   & 32768    \\
\end{tabular}
\end{center}

\section{Time Spent \& Thoughts}

This was a much easier problem set than usual. Problem \#1 tests a hard to understand topic, but it's a very straightforward application of the topic, so it wasn't bad. The decimal problem was a huge pain just because of the volume of equations and making sure that I didn't have any typos in them. I enjoyed the optional part of problem 5, but the rest of the problem set wasn't very interesting. I spent about four hours doing this homework.

\end{document}


\documentstyle[11pt,reduce]{article}
\title{A \REDUCE{} package for the computation of several matrix
normal forms}
\author{Matt Rebbeck \\
Konrad-Zuse-Zentrum f\"ur Informationstechnik Berlin \\
Takustra\"se 7  \\
D--14195 Berlin -- Dahlem \\
Federal Republic of Germany \\[0.05in]
E--mail: neun@zib.de \\[0.05in]
}
\date{February 1994}
\begin{document}
\maketitle
\index{NORMFORM package}

\section{Introduction}
When are two given matrices similar? Similar matrices have the same
trace, determinant, \hspace{0in} characteristic polynomial,
\hspace{0in} and eigenvalues, \hspace{0in} but the matrices
\begin{displaymath}
\begin{array}{ccc} {\cal U} = \left( \begin{array}{cc} 0 & 1 \\ 0 &
0 \end{array} \right) & $and$ & {\cal V} = \left( \begin{array}{cc}
0 & 0 \\ 0 & 0 \end{array} \right) \end{array}
\end{displaymath}
are the same in all four of the above but are not similar. Otherwise
there could exist a nonsingular ${\cal N} {\in} M_{2}$ (the set of
all $2 \times 2$ matrices) such that ${\cal U} = {\cal N} \, {\cal V}
\, {\cal N}^{-1} = {\cal N} \, {\it 0} \, {\cal N}^{-1} = {\it 0}$,
which is a contradiction since ${\cal U} \neq {\it 0}$.

Two matrices can look very different but still be similar. One
approach to determining whether two given matrices are similar is to
compute the normal form of them. If both matrices reduce to the same
normal form they must be similar.

{\small NORMFORM} is a package for computing the following normal
forms of matrices:

\begin{verbatim}
 - smithex
 - smithex_int
 - frobenius
 - ratjordan
 - jordansymbolic
 - jordan
\end{verbatim}

The package is loaded by {\tt load\_package normform;}

By default all calculations are carried out in {\cal Q} (the rational
numbers). For {\tt smithex}, {\tt frobenius}, {\tt ratjordan},
{\tt jordansymbolic}, and {\tt jordan}, this field can be extended.
Details are given in the respective sections.

The {\tt frobenius}, {\tt ratjordan}, and {\tt jordansymbolic} normal
forms can also be computed in a modular base. Again, details are given
in the respective sections.

The algorithms for each routine are contained in the source code.

{\small NORMFORM} has been converted from the normform and Normform
packages written by T.M.L. Mulders and A.H.M. Levelt. These have been
implemented in Maple [4].

\section{smithex}

\subsection{function}

{\tt smithex}(${\cal A},\, x$) computes the Smith normal form ${\cal S}$
of the matrix ${\cal A}$.

It returns \{${\cal S}, {\cal P}, {\cal P}^{-1}$\} where ${\cal S},
{\cal P}$, and ${\cal P}^{-1}$ are such that ${\cal P S P}^{-1} =
{\cal A}$.

${\cal A}$ is a rectangular matrix of univariate polynomials in $x$.

$x$ is the variable name.

\subsection{field extensions}

Calculations are performed in ${\cal Q}$. To extend this field the
{\small ARNUM} package can be used. For details see {\it section} 8.

\subsection{synopsis}

\begin{itemize}
\item The Smith normal form ${\cal S}$ of an n by m matrix ${\cal A}$
with univariate polynomial entries in $x$ over a field {\it F} is
computed. That is, the polynomials are then regarded as elements of the
{\it E}uclidean domain {\it F}($x$).

\item The Smith normal form is a diagonal matrix ${\cal S}$ where:

  \begin{itemize}
  \item rank(${\cal A}$) = number of nonzero rows (columns) of
        ${\cal S}$.
  \item ${\cal S}(i,\, i)$ is a monic polynomial for 0 $< i \leq $
        rank(${\cal A}$).
  \item ${\cal S}(i,\, i)$ divides ${\cal S}(i+1,\, i+1)$ for 0 $< i
        <$ rank(${\cal A}$).
  \item ${\cal S}(i,\,i)$ is the greatest common divisor of all $i$ by
        $i$ minors of ${\cal A}$.
  \end{itemize}

      Hence, if we have the case that $n = m$, as well as
      rank(${\cal A}$) $= n$, then product (${\cal S}(i,\,i),
      i=1\ldots n$) = det(${\cal A}$) / lcoeff(det$({\cal A}), \, x$).

\item The Smith normal form is obtained by doing elementary row and
      column operations. This includes interchanging rows (columns),
      multiplying through a row (column) by $-1$, and adding integral
      multiples of one row (column) to another.

\item Although the rank and determinant can be easily obtained from
      ${\cal S}$, this is not an efficient method for computing these
      quantities except that this may yield a partial factorization of
      det(${\cal A}$) without doing any explicit factorizations.

\end{itemize}

\subsection{example}

{\tt load\_package normform;}

\begin{displaymath}
{\cal A} = \left( \begin{array}{cc} x & x+1 \\ 0 & 3*x^2 \end{array}
\right)
\end{displaymath}

\begin{displaymath}
\hspace{-0.5in}
\begin{array}{ccc}
{\tt smithex}({\cal A},\, x) & = &
\left\{ \left( \begin{array}{cc} 1 & 0 \\
0 & x^3 \end{array} \right), \left( \begin{array}{cc} 1 & 0 \\ 3*x^2
& 1 \end{array} \right), \left( \begin{array}{cc} x & x+1 \\ -3 & -3
\end{array} \right) \right\} \end{array}
\end{displaymath}

\section{smithex\_int}

\subsection{function}

Given an $n$ by $m$ rectangular matrix ${\cal A}$ that contains
{\it only} integer entries, {\tt smithex\_int}(${\cal A}$) computes the
Smith normal form ${\cal S}$ of ${\cal A}$.

It returns \{${\cal S}, {\cal P}, {\cal P}^{-1}$\} where ${\cal S},
{\cal P}$, and ${\cal P}^{-1}$ are such that ${\cal P S P}^{-1} =
{\cal A}$.

\subsection{synopsis}

\begin{itemize}
\item The Smith normal form ${\cal S}$ of an $n$ by $m$ matrix
${\cal A}$ with integer entries is computed.

\item The Smith normal form is a diagonal matrix ${\cal S}$ where:

  \begin{itemize}
  \item rank(${\cal A}$) = number of nonzero rows (columns) of
        ${\cal S}$.
  \item sign(${\cal S}(i,\, i)$) = 1 for 0 $< i \leq $ rank(${\cal A}$).
  \item ${\cal S}(i,\, i)$ divides ${\cal S}(i+1,\, i+1)$ for 0 $< i
        <$ rank(${\cal A}$).
  \item ${\cal S}(i,\,i)$ is the greatest common divisor of all $i$ by
        $i$ minors of ${\cal A}$.
  \end{itemize}

      Hence, if we have the case that $n = m$, as well as
      rank(${\cal A}$) $= n$, then abs(det(${\cal A}$)) =
      product(${\cal S}(i,\,i),i=1\ldots n$).

\item The Smith normal form is obtained by doing elementary row and
      column operations. This includes interchanging rows (columns),
      multiplying through a row (column) by $-1$, and adding integral
      multiples of one row (column) to another.
\end{itemize}

\subsection{example}

{\tt load\_package normform;}

\begin{displaymath}
{\cal A} = \left( \begin{array}{ccc} 9 & -36 & 30 \\ -36 & 192 & -180 \\
30 & -180 & 180  \end{array}
\right)
\end{displaymath}

{\tt smithex\_int}(${\cal A}$) =
\begin{center}
\begin{displaymath}
\left\{ \left( \begin{array}{ccc} 3 & 0 & 0 \\ 0 & 12 & 0 \\ 0 & 0 & 60
\end{array} \right), \left( \begin{array}{ccc} -17 & -5 & -4 \\ 64 & 19
& 15 \\ -50 & -15 & -12 \end{array} \right), \left( \begin{array}{ccc}
1 & -24 & 30 \\ -1 & 25 & -30 \\ 0 & -1 & 1 \end{array} \right) \right\}
\end{displaymath}
\end{center}

\section{frobenius}

\subsection{function}

{\tt frobenius}(${\cal A}$) computes the Frobenius normal form
${\cal F}$ of the matrix ${\cal A}$.

It returns \{${\cal F}, {\cal P}, {\cal P}^{-1}$\} where ${\cal F},
{\cal P}$, and ${\cal P}^{-1}$ are such that ${\cal P F P}^{-1} =
{\cal A}$.

${\cal A}$ is a square matrix.

\subsection{field extensions}

Calculations are performed in ${\cal Q}$. To extend this field the
{\small ARNUM} package can be used. For details see {\it section} 8.

\subsection{modular arithmetic}

{\tt frobenius} can be calculated in a modular base. For details see
{\it section} 9.

\subsection{synopsis}

\begin{itemize}
\item ${\cal F}$ has the following structure:
      \begin{displaymath}
      {\cal F} = \left( \begin{array}{cccc} {\cal C}{\it p_{1}} &  &  &
      \\  & {\cal C}{\it p_{2}} &  &  \\  &  & \ddots &  \\  &  &  &
      {\cal C}{\it p_{k}} \end{array} \right)
      \end{displaymath}
      where the ${\cal C}({\it p_{i}})$'s are companion matrices
      associated with polynomials ${\it p_{1}, p_{2}},\ldots,
      {\it p_{k}}$, with the property that ${\it p_{i}}$ divides
      ${\it p_{i+1}}$ for $i =1\ldots k-1$. All unmarked entries are
      zero.

\item The Frobenius normal form defined in this way is unique (ie: if
      we require that ${\it p_{i}}$ divides ${\it p_{i+1}}$ as above).
\end{itemize}

\subsection{example}

{\tt load\_package normform;}

\begin{displaymath}
{\cal A} = \left( \begin{array}{cc} \frac{-x^2+y^2+y}{y} &
\frac{-x^2+x+y^2-y}{y} \\ \frac{-x^2-x+y^2+y}{y} & \frac{-x^2+x+y^2-y}
{y} \end{array} \right)
\end{displaymath}

{\tt frobenius}(${\cal A}$) =
\begin{center}
\begin{displaymath}
\left\{ \left( \begin{array}{cc} 0 & \frac{x*(x^2-x-y^2+y)}{y} \\ 1 &
\frac{-2*x^2+x+2*y^2}{y} \end{array} \right), \left( \begin{array}{cc}
1 & \frac{-x^2+y^2+y}{y} \\ 0 & \frac{-x^2-x+y^2+y}{y} \end{array}
\right), \left( \begin{array}{cc} 1 & \frac{-x^2+y^2+y}{x^2+x-y^2-y} \\
0 & \frac{-y}{x^2+x-y^2-y} \end{array} \right) \right\}
\end{displaymath}
\end{center}

\section{ratjordan}

\subsection{function}

{\tt ratjordan}(${\cal A}$) computes the rational Jordan normal form
${\cal R}$ of the matrix ${\cal A}$.

It returns \{${\cal R}, {\cal P}, {\cal P}^{-1}$\} where ${\cal R},
{\cal P}$, and ${\cal P}^{-1}$ are such that ${\cal P R P}^{-1} =
{\cal A}$.

${\cal A}$ is a square matrix.

\subsection{field extensions}

Calculations are performed in ${\cal Q}$. To extend this field the
{\small ARNUM} package can be used. For details see {\it section} 8.

\subsection{modular arithmetic}

{\tt ratjordan} can be calculated in a modular base. For details see
{\it section} 9.

\subsection{synopsis}

\begin{itemize}
\item ${\cal R}$ has the following structure:
      \begin{displaymath}
      {\cal R} = \left( \begin{array}{cccccc} {\it r_{11}} \\  &
      {\it r_{12}} \\  &  & \ddots \\  &  &  & {\it r_{21}}  \\ &  &
      &  & {\it r_{22}} \\ &  &  &  &  & \ddots \end{array} \right)
      \end{displaymath}

      The ${\it r_{ij}}$'s have the following shape:
      \begin{displaymath}
      {\it r_{ij}} = \left( \begin{array}{ccccc} {\cal C}({\it p}) &
      {\cal I}  &  &  & \\  &  {\cal C}({\it p}) & {\cal I}  & & \\ &
      & \ddots & \ddots & \\ &  &  &  {\cal C}({\it p}) & {\cal I} \\ &
      &  &  & {\cal C}({\it p}) \end{array} \right)
      \end{displaymath}

      where there are e${\it ij}$ times ${\cal C}({\it p})$ blocks
      along the diagonal and ${\cal C}({\it p})$ is the companion
      matrix  associated with the irreducible polynomial ${\it p}$. All
      unmarked entries are zero.
\end{itemize}

\subsection{example}

{\tt load\_package normform;}

\begin{displaymath}
{\cal A} = \left( \begin{array}{cc} x+y & 5 \\ y & x^2  \end{array}
\right)
\end{displaymath}

{\tt ratjordan}(${\cal A}$) =
\begin{center}
\begin{displaymath}
\left\{ \left( \begin{array}{cc} 0 & -x^3-x^2*y+5*y \\ 1 &
x^2+x+y \end{array} \right), \left( \begin{array}{cc}
1 & x+y \\ 0 & y \end{array} \right), \left( \begin{array}{cc} 1 &
\frac{-(x+y)}{y} \\ 0 & \hspace{0.2in} \frac{1}{y} \end{array} \right)
\right\}
\end{displaymath}
\end{center}

\section{jordansymbolic}

\subsection{function}

{\tt jordansymbolic}(${\cal A}$) \hspace{0in} computes the Jordan
normal form ${\cal J}$of the matrix ${\cal A}$.

It returns \{${\cal J}, {\cal L}, {\cal P}, {\cal P}^{-1}$\}, where
${\cal J}, {\cal P}$, and ${\cal P}^{-1}$ are such that ${\cal P J P}^
{-1} = {\cal A}$. ${\cal L}$ = \{ {\it ll} , $\xi$ \}, where $\xi$ is
a name and {\it ll} is a list of irreducible factors of ${\it p}(\xi)$.

${\cal A}$ is a square matrix.

\subsection{field extensions}

Calculations are performed in ${\cal Q}$. To extend this field the
{\small ARNUM} package can be used. For details see {\it section} 8.

\subsection{modular arithmetic}

{\tt jordansymbolic} can be calculated in a modular base. For details
see {\it section} 9.

\subsection{extras}

If using {\tt xr}, the X interface for \REDUCE, the appearance of the
output can be improved by switching {\tt on looking\_good;}. This
converts all lambda to $\xi$ and improves the indexing, eg: lambda12
$\Rightarrow \xi_{12}$. The example ({\it section} 6.6) shows the
output when this switch is on.

\subsection{synopsis}

\begin{itemize}
\item A {\it Jordan block} ${\jmath}_{k}(\lambda)$ is a $k$ by $k$
      upper triangular matrix of the form:

      \begin{displaymath}
      {\jmath}_{k}(\lambda) = \left( \begin{array}{ccccc} \lambda & 1
      &  &  & \\  &  \lambda & 1  & & \\ &
      & \ddots & \ddots & \\ &  &  &  \lambda & 1 \\ &
      &  &  & \lambda \end{array} \right)
      \end{displaymath}

      There are $k-1$ terms ``$+1$'' in the superdiagonal; the scalar
      $\lambda$ appears $k$ times on the main diagonal. All other
      matrix entries are zero, and ${\jmath}_{1}(\lambda) = (\lambda)$.

\item A Jordan matrix ${\cal J} \in M_{n}$ (the set of all $n$ by $n$
      matrices) is a direct sum of {\it jordan blocks}.

      \begin{displaymath}
      {\cal J} = \left( \begin{array}{cccc} \jmath_{n_1}(\lambda_{1})
      \\  & \jmath_{n_2}(\lambda_{2}) \\ & & \ddots \\ & & &
      \jmath_{n_k}(\lambda_{k}) \end{array} \right),
      {\it n}_{1}+{\it n}_{2}+\cdots +{\it n}_{k} = n
      \end{displaymath}

      in which the orders ${\it n}_{i}$ may not be distinct and the
      values ${\lambda_{i}}$ need not be distinct.

\item Here ${\lambda}$ is a zero of the characteristic polynomial
      ${\it p}$ of ${\cal A}$. If ${\it p}$ does not split completely,
      symbolic names are chosen for the missing zeroes of ${\it p}$.
      If, by some means, one knows such missing zeroes, they can be
      substituted for the symbolic names. For this,
      {\tt jordansymbolic} actually returns $\{ {\cal J,L,P,P}^{-1} \}$.
      ${\cal J}$ is the Jordan normal form of ${\cal A}$ (using
      symbolic names if necessary). ${\cal L} = \{ {\it ll}, \xi \}$,
      where $\xi$ is a name and ${\it ll}$ is a list of irreducible
      factors of ${\it p}(\xi)$. If symbolic names are used then
      ${\xi}_{ij}$ is a zero of ${\it ll}_{i}$. ${\cal P}$ and
      ${\cal P}^{-1}$ are as above.
\end{itemize}

\subsection{example}

{\tt load\_package normform;}\\
{\tt on looking\_good;}

\begin{displaymath}
{\cal A} = \left( \begin{array}{cc} 1 & y \\ y^2 & 3  \end{array}
\right)
\end{displaymath}

{\tt jordansymbolic}(${\cal A}$) =
\begin{eqnarray}
 & & \left\{ \left( \begin{array}{cc} \xi_{11} & 0 \\ 0 & \xi_{12}
\end{array} \right) ,
\left\{ \left\{ -y^3+\xi^2-4*\xi+3 \right\}, \xi \right\}, \right.
\nonumber \\ & & \hspace{0.1in} \left. \left( \begin{array}{cc}
\xi_{11} -3 & \xi_{12} -3 \\ y^2 & y^2
\end{array} \right), \left( \begin{array}{cc} \frac{\xi_{11} -2}
{2*(y^3-1)} & \frac{\xi_{11} + y^3 -1}{2*y^2*(y^3+1)} \\
\frac{\xi_{12} -2}{2*(y^3-1)} & \frac{\xi_{12}+y^3-1}{2*y^2*(y^3+1)}
\end{array} \right) \right\} \nonumber
\end{eqnarray}

\vspace{0.2in}
\begin{flushleft}
\begin{math}
{\tt solve(-y^3+xi^2-4*xi+3,xi)}${\tt ;}$
\end{math}
\end{flushleft}

\vspace{0.1in}
\begin{center}
\begin{math}
\{ \xi = \sqrt{y^3+1} + 2,\, \xi = -\sqrt{y^3+1}+2 \}
\end{math}
\end{center}

\vspace{0.1in}
\begin{math}
{\tt {\cal J}  = sub}{\tt (}{\tt \{ xi(1,1)=sqrt(y^3+1)+2,\, xi(1,2) =
-sqrt(y^3+1)+2\},}
\end{math}
\\ \hspace*{0.29in} {\tt first  jordansymbolic (${\cal A}$));}

\vspace{0.2in}
\begin{displaymath}
{\cal J} = \left( \begin{array}{cc} \sqrt{y^3+1} + 2 & 0 \\ 0 &
-\sqrt{y^3+1} + 2 \end{array} \right)
\end{displaymath}

\vspace{0.2in}
For a similar example ot this in standard {\REDUCE} (ie: not using
{\tt xr}), see the {\it normform.log} file.

\vspace{0.5in}

\section{jordan}

\subsection{function}

{\tt jordan}(${\cal A}$) computes the Jordan normal form
${\cal J}$ of the matrix ${\cal A}$.

It returns \{${\cal J}, {\cal P}, {\cal P}^{-1}$\}, where
${\cal J}, {\cal P}$, and ${\cal P}^{-1}$ are such that ${\cal P J P}^
{-1} = {\cal A}$.

${\cal A}$ is a square matrix.

\subsection{field extensions}

Calculations are performed in ${\cal Q}$. To extend this field the
{\small ARNUM} package can be used. For details see {\it section} 8.

\subsection{note}
In certain polynomial cases {\tt fullroots} is turned on to compute the
zeroes. This can lead to the calculation taking a long time, as well as
the output being very large. In this case a message {\tt ***** WARNING:
fullroots turned on. May take a while.} will be printed. It may be
better to kill the calculation and compute {\tt jordansymbolic} instead.

\subsection{synopsis}

\begin{itemize}
\item The Jordan normal form ${\cal J}$ with entries in an algebraic
      extension of ${\cal Q}$ is computed.

\item A {\it Jordan block} ${\jmath}_{k}(\lambda)$ is a $k$ by $k$
      upper triangular matrix of the form:

      \begin{displaymath}
      {\jmath}_{k}(\lambda) = \left( \begin{array}{ccccc} \lambda & 1
      &  &  & \\  &  \lambda & 1  & & \\ &
      & \ddots & \ddots & \\ &  &  &  \lambda & 1 \\ &
      &  &  & \lambda \end{array} \right)
      \end{displaymath}

      There are $k-1$ terms ``$+1$'' in the superdiagonal; the scalar
      $\lambda$ appears $k$ times on the main diagonal. All other
      matrix entries are zero, and ${\jmath}_{1}(\lambda) = (\lambda)$.

\item A Jordan matrix ${\cal J} \in M_{n}$ (the set of all $n$ by $n$
      matrices) is a direct sum of {\it jordan blocks}.

      \begin{displaymath}
      {\cal J} = \left( \begin{array}{cccc} \jmath_{n_1}(\lambda_{1})
      \\  & \jmath_{n_2}(\lambda_{2}) \\ & & \ddots \\ & & &
      \jmath_{n_k}(\lambda_{k}) \end{array} \right),
      {\it n}_{1}+{\it n}_{2}+\cdots +{\it n}_{k} = n
      \end{displaymath}

      in which the orders ${\it n}_{i}$ may not be distinct and the
      values ${\lambda_{i}}$ need not be distinct.

\item Here ${\lambda}$ is a zero of the characteristic polynomial
      ${\it p}$ of ${\cal A}$. The zeroes of the characteristic
      polynomial are computed exactly, if possible. Otherwise they are
      approximated by floating point numbers.
\end{itemize}

\subsection{example}

{\tt load\_package normform;}

\begin{displaymath}
{\cal A} = \left( \begin{array}{cccccc} -9 & -21 & -15 & 4 & 2 & 0 \\
-10 & 21 & -14 & 4 & 2 & 0 \\ -8 & 16 & -11 & 4 & 2 & 0 \\ -6 & 12 & -9
& 3 & 3 & 0 \\ -4 & 8 & -6 & 0 & 5 & 0 \\ -2 & 4 & -3 & 0 & 1 & 3
\end{array} \right)
\end{displaymath}

\begin{flushleft}
{\tt ${\cal J}$ = first jordan$({\cal A})$;}
\end{flushleft}

\begin{displaymath}
{\cal J} = \left( \begin{array}{cccccc} 3 & 0 & 0 & 0 & 0 & 0 \\ 0 & 3
& 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 \\
 0 & 0 & 0 & 0 & i+2 & 0 \\ 0 & 0 & 0 & 0 & 0 & -i+2
\end{array} \right)
\end{displaymath}

\newpage

\section{arnum}

The package is loaded by {\tt load\_package arnum;}. The algebraic
field ${\cal Q}$ can now be extended. For example, {\tt defpoly
sqrt2**2-2;} will extend it to include ${\sqrt{2}}$ (defined here by
{\tt sqrt2}). The {\small ARNUM} package was written by Eberhard
Schr\"ufer and is described in the {\it arnum.tex} file.

\subsection{example}

{\tt load\_package normform;} \\
{\tt load\_package arnum;} \\
{\tt defpoly sqrt2**2-2;} \\
(sqrt2 now changed to ${\sqrt{2}}$ for looks!)
\vspace{0.2in}

\begin{displaymath}
{\cal A} = \left( \begin{array}{ccc} 4*{\sqrt{2}}-6 & -4*{\sqrt{2}}+7 &
-3*{\sqrt{2}}+6 \\ 3*{\sqrt{2}}-6 & -3*{\sqrt{2}}+7 & -3*{\sqrt{2}}+6
\\ 3*{\sqrt{2}} & 1-3*{\sqrt{2}} & -2*{\sqrt{2}}   \end{array} \right)
\end{displaymath}
\vspace{0.2in}

\begin{eqnarray}
{\tt ratjordan}({\cal A}) & = &
\left\{ \left( \begin{array}{ccc} {\sqrt{2}} & 0 & 0 \\ 0 & {\sqrt{2}}
& 0 \\ 0 & 0 & -3*{\sqrt{2}}+1 \end{array} \right), \right. \nonumber
\\ & & \hspace{0.1in} \left. \left( \begin{array}{ccc} 7*{\sqrt{2}}-6
& \frac{2*{\sqrt{2}}-49}{31} & \frac{-21*{\sqrt{2}}+18}{31} \\
3*{\sqrt{2}}-6 & \frac{21*{\sqrt{2}}-18}{31} & \frac{-21*{\sqrt{2}}+18}
{31} \\ 3*{\sqrt{2}}+1 & \frac{-3*{\sqrt{2}}+24}{31} &
\frac{3*{\sqrt{2}}-24}{31} \end{array} \right), \right. \nonumber \\ &
& \hspace{0.1in} \left. \left( \begin{array}{ccc} 0 & {\sqrt{2}}+1 &
1 \\ -1 & 4*{\sqrt{2}}+9 & 4*{\sqrt{2}} \\ -1 & -\frac{1}{6}*{\sqrt{2}}
+1 & 1 \end{array} \right) \right\} \nonumber
\end{eqnarray}

\newpage

\section{modular}

Calculations can be performed in a modular base by switching {\tt on
modular;}. The base can then be set by {\tt setmod p;} (p a prime). The
normal form will then have entries in ${\cal Z}/$p${\cal Z}$.

By also switching {\tt on balanced\_mod;} the output will be shown using
a symmetric modular representation.

Information on this modular manipulation can be found in {\it chapter}
9 (Polynomials and Rationals) of the {\REDUCE}  User's Manual [5].

\subsection{example}

{\tt load\_package normform;} \\
{\tt on modular;} \\
{\tt setmod 23;}
\vspace{0.1in}

\begin{displaymath}
{\cal A} = \left( \begin{array}{cc} 10 & 18 \\ 17 & 20 \end{array}
\right)
\end{displaymath}

{\tt jordansymbolic}(${\cal A}$) =
\begin{center}
\begin{displaymath}
\left\{ \left( \begin{array}{cc} 18 & 0 \\ 0 & 12 \end{array} \right),
\left\{ \left\{ \lambda + 5, \lambda + 11  \right\}, \lambda \right\},
\left( \begin{array}{cc} 15 & 9 \\ 22 & 1 \end{array} \right), \left(
\begin{array}{cc} 1 & 14 \\ 1 & 15 \end{array} \right) \right\}
\end{displaymath}
\end{center}
\vspace{0.2in}

{\tt on balanced\_mod;}
\vspace{0.2in}

{\tt jordansymbolic}(${\cal A}$) =
\begin{center}
\begin{displaymath}
\left\{ \left( \begin{array}{cc} -5 & 0 \\ 0 & -11 \end{array} \right),
\left\{ \left\{ \lambda + 5, \lambda + 11  \right\}, \lambda \right\},
\left( \begin{array}{cc} -8 & 9 \\ -1 & 1 \end{array} \right), \left(
\begin{array}{cc} 1 & -9 \\ 1 & -8 \end{array} \right) \right\}
\end{displaymath}
\end{center}

\newpage
\begin{thebibliography}{6}
\bibitem{MulLev} T.M.L.Mulders and A.H.M. Levelt: {\it The Maple
        normform and Normform packages.} (1993)
\bibitem{Mulders} T.M.L.Mulders: {\it Algoritmen in De Algebra, A
        Seminar on Algebraic Algorithms, Nigmegen.} (1993)
\bibitem{HoJo} Roger A. Horn and Charles A. Johnson: {\it Matrix
        Analysis.} Cambridge University Press (1990)
\bibitem{Maple} Bruce W. Chat\ldots [et al.]: {\it Maple (Computer
        Program)}. Springer-Verlag (1991)
\bibitem{Reduce} Anthony C. Hearn: {\REDUCE} {\it User's Manual 3.6.}
	RAND (1995)
\end{thebibliography}

\end{document}


\documentclass[aspectratio=169]{beamer}
\input{../util/beamerpreamble.tex}

\title[GB13604]{GB13604 - Maths for Computer Science}
\subtitle[]{Lecture 3 -- Number Theory}
\author[Claus Aranha]{Claus Aranha\\{\footnotesize caranha@cs.tsukuba.ac.jp}}
\institute[COINS]{College of Information Science}
\date[2020-10-21]{2020-10-21\\{\tiny Last updated \today}}

\begin{document}

\begin{frame}
  \maketitle

  \begin{columns}
    \column{0.8\textwidth}
    {\smaller This course is based on Mathematics for Computer Science, Spring
    2015, by Albert Meyer and Adam Chlipala, Massachusetts Institute
    of Technology OpenCourseWare.}
    \column{0.2\textwidth}
    \includegraphics[width=\textwidth]{../img/by-nc-sa}
  \end{columns}
\end{frame}

\begin{frame}{Lecture Outline}

  Number Theory: From division to the RSA algorithm (textbook chapter 8).\bigskip

  \begin{itemize}
    \item Division and the Greatest Common Divisor (GCD);
    \item Primality, and simple cryptography;
    % First part of Turing crypto here
    \item Modular Arithmetic, and Euler's theorem;
    % Second part of Turing crypto here
    \item The RSA public key algorithm;
  \end{itemize}\bigskip

  Let's get started!
\end{frame}

\input{01_Divisibility.tex}
\input{02_CommonDivisor.tex}
\input{03_Primality.tex}
% Turing Code 1.0
\input{04_ModularArithmetic.tex}
% Turing Code 2.0
\input{05_RSA.tex}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\section{Conclusion}

\input{../util/lastslide.tex}
\end{document}


\documentclass[t,usenames,dvipsnames]{beamer}
\usetheme{Copenhagen}
\setbeamertemplate{headline}{} % remove toc from headers
\beamertemplatenavigationsymbolsempty

\usepackage{amsmath, tkz-euclide, tikz, xcolor, pgfplots, array}
\usetkzobj{all}
\pgfplotsset{compat = 1.16}
\usetikzlibrary{arrows.meta, calc, decorations.pathreplacing}
\pgfplotsset{every axis/.append style = {axis lines = middle, axis line style = {<->}}}
\pgfplotsset{every tick label/.append style={font=\tiny}}
\everymath{\displaystyle}

\title{Trig Equations}
\author{}
\date{}

\AtBeginSection[]
{
  \begin{frame}
    \frametitle{Objectives}
    \tableofcontents[currentsection]
  \end{frame}
}

\begin{document}

\begin{frame}
    \maketitle
\end{frame}

\section{Solve trigonometric equations}

\begin{frame}{Trig Equations}
    A \alert{trigonometric equation} is one that contains a trig function with variable, such as $\sin x = \frac{1}{2}$.
\end{frame}

\begin{frame}{Trig Equations}
\begin{center}
\begin{tikzpicture}
\begin{axis}[
xmin = -5, xmax = 12,
ymin = -1.5, ymax = 1.5,
xtick = {-3.67, 0.524, 2.618, 6.809, 8.901},
xticklabels = {$-\frac{7\pi}{6}$, $\frac{\pi}{6}$, $\frac{5\pi}{6}$, $\frac{13\pi}{6}$, $\frac{17\pi}{6}$}
]
\addplot [<->,>=stealth,very thick,domain=-4:10.5, samples = 300, smooth, blue] {sin(deg(x))};
\addplot+ [<->, domain=-5:12, no marks, very thick] {0.5};
\addplot [color=blue, mark=*] coordinates {(-3.67,0.5) (0.524,0.5) (2.618,0.5) (6.809,0.5) (8.901,0.5)};
\end{axis}
\end{tikzpicture}
\end{center}
\end{frame}

\begin{frame}{General Form of Solutions}
The \alert{general form} of this solution is
\[x = \frac{\pi}{6}+2\pi n \quad \text{or} \quad x = \frac{5\pi}{6} + 2\pi n \]

where $2\pi$ is the \alert{period} of the sine function.  \newline\\  \pause

Since there are an infinite number of solutions, we will usually confine our answers to be between 0 and $2\pi$.
\end{frame}

\begin{frame}{How to Solve a Trig Equation}
    \begin{enumerate}
        \item Get the trig function by itself, if possible.    \newline\\
        \item Solve for the variable using inverse trig.
    \end{enumerate}
\end{frame}

\begin{frame}{Example 1}
Solve each of the following in the interval $[0, 2\pi)$.    \newline\\
(a) \quad $\cos(2x) = -\frac{\sqrt{3}}{2}$
\begin{align*}
    \onslide<2->{2x &= 150^\circ + 360n & 2x &= 210 + 360n} \\[8pt]
    \onslide<3->{x &= 75^\circ + 180n & x &= 105^\circ + 180n} \\[8pt]
    \onslide<4->{x &= 75^\circ, \, 255^\circ & x &= 105^\circ, \, 285^\circ} \\[8pt]
\end{align*}
\onslide<5->{
\[ x = \left\{\frac{5\pi}{12}, \, \frac{7\pi}{12}, \, \frac{17\pi}{12}, \, \frac{19\pi}{12} \right\} \]}
\end{frame}

\begin{frame}{Example 1}
(b) \quad $\csc\left(\frac{1}{3}x-\pi\right) = \sqrt{2}$
\begin{align*}
    \onslide<2->{\frac{1}{3}x - 180^\circ &= 45^\circ + 360n & \frac{1}{3}x - 180^\circ &= 135^\circ + 360n}   \\[8pt]
    \onslide<3->{\frac{1}{3}x &= 225^\circ + 360n & \frac{1}{3}x &= 315^\circ + 360n} \\[8pt]
    \onslide<4->{x &= 675^\circ + 1080n & x &= 945^\circ + 1080n} \\[8pt]
\end{align*}
\begin{center}
    \onslide<5->{No angles between 0 and $2\pi$}
\end{center}
\end{frame}

\begin{frame}{Example 1}
(c) \quad $\cot(3x) = 0$
\begin{align*}
    \onslide<2->{3x &= 90^\circ + 180n & 3x &= 270^\circ + 180n} \\[8pt]
    \onslide<3->{x &= 30^\circ + 60n & x &= 90^\circ + 60n} \\[8pt]
    \onslide<4->{x &= 30^\circ, 90^\circ, 150^\circ, 210^\circ, 270^\circ, 330^\circ & x &= 90^\circ, 150^\circ, \dots} \\
\end{align*}
\[ \onslide<5->{x = \left\{\frac{\pi}{6}, \, \frac{\pi}{2}, \, \frac{5\pi}{6}, \, \frac{7\pi}{6}, \, \frac{3\pi}{2}, \, \frac{11\pi}{6}\right\}} \]
\end{frame}

\begin{frame}{Example 1}
(d) \quad $\sec^2 x = 4$
\begin{align*}
    \onslide<2->{\sqrt{\sec^2 x} &= \pm\sqrt{4} & &} \\[6pt]
    \onslide<3->{\sec x &= 2 & \sec x &= -2} \\[6pt]
    \onslide<4->{x &= 60^\circ, 300^\circ & x &= 120^\circ, 240^\circ}
\end{align*}

\onslide<5->{\[ x = \left\{ \frac{\pi}{3}, \frac{2\pi}{3}, \frac{4\pi}{3}, \frac{5\pi}{3}\right\} \]}
\end{frame}

\begin{frame}{Example 1}
(e) \quad $\tan\left(\frac{x}{2}\right) = -3$
\begin{align*}
    \onslide<2->{\frac{x}{2} &= \tan^{-1}(-3) + 180n & (\arctan(-3) \approx -143^\circ)}    \\[12pt]
    \onslide<3->{x &= 2\tan^{-1}(-3) + 360n & (2\arctan(-3) \approx -286^\circ)} \\[12pt]
    \onslide<4->{x &= 2\tan^{-1}(-3) + 360^\circ} \\[12pt]
    \onslide<5->{x &= 2\tan^{-1}(-3) + 2\pi  &}
\end{align*}
\end{frame}

\begin{frame}{Using Algebraic Techniques and Trig Identities}
The following examples make use of trig identities and algebraic techniques to solve the equations.
\end{frame}

\begin{frame}{Example 2}
Solve each in the interval $[0, 2\pi)$  \newline\\
(a) \quad $3\sin^3 x = \sin^2 x$
\begin{align*}
    \onslide<2->{3\sin^3 x - \sin^2 x &= 0 & &} \\[6pt]
    \onslide<3->{\sin^2 x(3\sin x - 1) &= 0 & &} \\[6pt]
    \onslide<4->{\sin^2 x &= 0 & 3\sin x - 1 &= 0} \\[6pt]
    \onslide<5->{\sin x &= 0 & \sin x = \frac{1}{3}} \\[6pt]
    \onslide<6->{x &= 0, 180^\circ & x &\approx 19.471^\circ, 160.529^\circ}
\end{align*}
\[ \onslide<7->{x = \left\{0, \, \arcsin\left(\frac{1}{3}\right), \, \pi - \arcsin\left(\frac{1}{3}\right), \, \pi \right\}}
\]
\end{frame}

\begin{frame}{Example 2}
(b) \quad $\sec^2 x = \tan x + 3$
\begin{align*}
    \onslide<2->{\tan^2 x + 1 &= \tan x + 3} \\[6pt]
    \onslide<3->{\tan^2 x - \tan x - 2 &= 0} \\[6pt]
    \onslide<4->{(\tan x - 2)(\tan x + 1) &= 0}
\end{align*}
\begin{align*}
    \onslide<5->{\tan x - 2 &= 0 & \tan x + 1 &= 0} \\
    \onslide<6->{\tan x &= 2 & \tan x &= -1}    \\
    \onslide<7->{x &\approx 63.5^\circ, 243.5^\circ & x &= 135^\circ, 315^\circ}
\end{align*}
\[
\onslide<8->{x = \left\{\arctan(2), \, \frac{3\pi}{4}, \, \pi + \arctan(2), \, \frac{7\pi}{4} \right\}}
\]
\end{frame}

\begin{frame}{Example 2}
(c) \quad $\cos(2x) = 3\cos x - 2$
\begin{align*}
    \onslide<2->{2\cos^2 x - 1 &= 3\cos x - 2} \\
    \onslide<3->{2\cos^2 x - 3\cos x + 1 &= 0} \\
    \onslide<4->{(2\cos x - 1)(\cos x - 1) &= 0}
\end{align*}
\begin{align*}
    \onslide<5->{2\cos x - 1 &= 0 & \cos x - 1 &= 0} \\
    \onslide<6->{\cos x &= \frac{1}{2} & \cos x &= 1} \\[6pt]
    \onslide<7->{x &= 60^\circ, 300^\circ & x &= 0}
\end{align*}

\[
\onslide<8->{x = \left\{ 0, \, \frac{\pi}{3}, \, \frac{5\pi}{3} \right\}}
\]
\end{frame}

\begin{frame}{Example 2}
(d) \quad $\sin(2x) = \sqrt{3}\cos x$
\begin{align*}
    \onslide<2->{2\sin x \cos x &= \sqrt{3}\cos x} \\
    \onslide<3->{2\sin x \cos x - \sqrt{3} \cos x &= 0} \\
    \onslide<4->{\cos x(2\sin x - \sqrt{3}) &= 0} \\
\end{align*}
\begin{align*}
    \onslide<5->{\cos x &= 0 & 2\sin x - \sqrt{3} &= 0} \\
    \onslide<6->{x &= 90^\circ, 270^\circ & 2\sin x &= \sqrt{3}} \\
    \onslide<7->{& & \sin x &= \frac{\sqrt{3}}{2}} \\[6pt]
    \onslide<8->{& & x &= 60^\circ, 120^\circ}
\end{align*}
\end{frame}

\begin{frame}{Example 2}
    \begin{align*}
        x &= 60^\circ, \, 90^\circ, \, 120^\circ, \, 270^\circ \\[12pt]
        \onslide<2->{x &= \left\{\frac{\pi}{3}, \, \frac{\pi}{2}, \, \frac{2\pi}{3}, \, \frac{3\pi}{2} \right\}}
    \end{align*}
\end{frame}

\end{document}


% !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}


\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}