\section{Contact tracing and quarantine}

\subsection{Model adaptation}
We simulate quarantining of persons identified as first degree contacts of COVID-19 patients explicitly through stratification of the compartments representing active COVID-19.
That is, the compartments representing both phases of the incubation period and both phases of active COVID-19 are duplicated into two model strata referred to as ``traced" and ``untraced".
In model initialisation, all infectious seed is assigned to the untraced stratum.
All newly infected persons commence their incubation period in the untraced stratum of the early incubation period.
As for isolated and hospitalised patients, those undergoing quarantine have their infectiousness reduced by 80\%.

\subsection{Contact tracing process}
Identification of infected persons through contact tracing is assumed to apply to those in their early incubation period, with flows added to the model that transition persons during their incubation period from the untraced to the traced stratum of this compartment type.
The rate of transition from the untraced to the traced stratum of the early incubation period is determined by the proportion of contacts traced.
It is assumed that only the contacts of identified cases can be traced, such that the case detection rate (the proportion of symptomatic cases detected) is the ceiling for the proportion of contacts traced.
The proportion of contacts of identified cases that is traced is multiplied by the proportion of contacts whose index is detected  to determine the proportion of all persons entering the incubation period who are traced.
The proportion of all contacts of infectious persons with a detected index case, \(u(t)\), is calculated as the relative contribution of ever-detected infectious individuals to the total force of infection, and is given as:

\[
u(t) = \frac
{\sum_{c \in \mathcal{C}} \sum_{s \in \mathcal{D}} \, prev_{c, s}(t) \times inf_{c, s}}
{\sum_{c \in \mathcal{C}} \sum_{s \in \mathcal{S}} \, prev_{c, s}(t) \times inf_{c, s}} \, ,
\]

where $\mathcal{C}$ is the set of infectious compartments, $\mathcal{S}$ represents all clinical strata and $\mathcal{D} \subset \mathcal{S}$ is the list of detected clinical strata.
The prevalence of infectious compartment $c$ in clinical stratum $s$ at time $t$ is represented by $prev_{c, s}(t)$, and $inf_{c, s}$ is the relative infectiousness of compartment $c$ in clinical stratum $s$.

The proportion of contacts of identified cases that is traced, \(q(t)\), is considered to decrease as the severity of the COVID-19 epidemic increases, because we expect contact tracing to decline in efficiency as more cases are identified.
That is, we assume that contact tracing is universal as COVID-19 prevalence approaches zero and declines exponentially with increasing prevalence.
The relationship between the proportion of contacts of identified patients who are quarantined and prevalence is given as:

\[q(t) = e^{-prev(t) \times \tau }\]

Rather than estimate \(\tau\) directly, we estimate the more intuitive quantity of the proportion of contacts of identified patients who would be quarantined at a particular prevalence.
Solving for the previous equation for \(\tau\), we obtain:

\[\tau = \frac{-log(q(t))}{prev(t)} \]

or \(\tau = \frac{-log(q_{0})}{prev_{0}} \) at a specific prevalence that accords with a particular value of \(q\). Fixing \(prev_{0}\) at \(10^{-4}\), we can vary \(q_{0}\) in calibration as the proportion of contacts of identified cases detected at a prevalence of one active case per thousand population.

Finally, \(q(t) \times u(t) \) gives the proportion of all infected persons who are traced. This proportion of persons entering their early latent period transition to the equivalent compartment in the traced stratum before proceeding to the late latent period.


\section{Category theory}\label{sec:category_theory}

Category theory studies objects via how they relate to other objects. It shifts the focus from how individual members behave and even has no concept of membership, upon which set theory is based.

This shift is evident from the following diagram, which is actually half of the proof of \fullref{thm:functor_adjoint_uniqueness}:
\begin{equation*}
  \begin{aligned}
    \includegraphics[page=1]{output/thm__functor_adjoint_uniqueness.pdf}
  \end{aligned}
\end{equation*}

We do still have individual objects, precisely the nodes of the diagram above, however we are only interested in how the nodes are related to each other. Chasing the relations in this diagram individually would require a lot more effort with little gain.

Categories can be defined \enquote{from the ground up} so that they may be used without an underlying set theory or logic. For our purposes, it will be more appropriate to define categories via \hyperref[def:quiver]{quivers}, a.k.a. directed multigraphs. This latter approach will be much more convenient for us, since we are working in \hyperref[def:axiom_of_universes]{\logic{ZFC+U}} and are only interested in categories insomuch as they are helpful to us.

Furthermore, categories are actually the primary motivation for us include the \hyperref[def:axiom_of_universes]{axiom of universes} in our metatheory that would otherwise include only the axioms of \hyperref[def:zfc]{\logic{ZFC}}. This is discussed further in \fullref{rem:functor_size} and \fullref{rem:functor_category_size}.


\documentclass[t]{beamer}
\usetheme{Copenhagen}
\usepackage{amsmath, tikz, tkz-euclide, xcolor}
\usetkzobj{all}
\setbeamertemplate{headline}{} % remove toc from headers
\beamertemplatenavigationsymbolsempty

\title{Right Triangle Trigonometry}
\author{}
\date{}

\AtBeginSection[]
{
  \begin{frame}
    \frametitle{Table of Contents}
    \tableofcontents[currentsection]
  \end{frame}
}

\begin{document}

\begin{frame}{}
    \titlepage
\end{frame}

\section{Write the six trig functions of an acute angle.}

\begin{frame}{The 3 Main Trig Ratios}

\begin{center}
\begin{tikzpicture}
\coordinate (A) at (0,0);
\coordinate (B) at (3,2);
\coordinate (C) at (3,0);
\draw [color=red] (C) rectangle +(-0.25,0.25);
\draw (A) -- node [midway, sloped, above] {hypotenuse} (B) -- node [midway, right] {opposite} (C) -- node [midway, below] {adjacent} cycle;
\node at (A) [xshift = 0.65cm, yshift = 0.2cm] {$\theta$};
\end{tikzpicture}
\end{center}
\vspace{11pt}
\[
\onslide<2->{\sin \theta = \dfrac{\text{opposite}}{\text{hypotenuse}}} \hspace{0.25in}
\onslide<3->{\cos \theta = \dfrac{\text{adjacent}}{\text{hypotenuse}}} \hspace{0.25in}
\onslide<4->{\tan \theta = \dfrac{\text{opposite}}{\text{adjacent}}}
\]
\newline\\
\onslide<5->{We usually remember this as SOH-CAH-TOA.}
\end{frame}

\begin{frame}{Reciprocals for SOH-CAH-TOA}
\begin{center}
\begin{tikzpicture}
\coordinate (A) at (0,0);
\coordinate (B) at (3,2);
\coordinate (C) at (3,0);
\draw [color=red] (C) rectangle +(-0.25,0.25);
\draw (A) -- node [midway, sloped, above] {hypotenuse} (B) -- node [midway, right] {opposite} (C) -- node [midway, below] {adjacent} cycle;
\node at (A) [xshift = 0.65cm, yshift = 0.2cm] {$\theta$};
\end{tikzpicture}
\end{center}
\vspace{11pt}
\[
\onslide<2->{\csc \theta = \frac{\text{hypotenuse}}{\text{opposite}}} \quad
\onslide<3->{\sec \theta = \frac{\text{hypotenuse}}{\text{adjacent}}}  \quad
\onslide<4->{\cot \theta = \frac{\text{adjacent}}{\text{opposite}}}
\]
\newline\\
\onslide<5->{Sometimes you may need to use the Pythagorean Theorem, $a^2+b^2=c^2$, in order to find any missing sides.}
\end{frame}

\begin{frame}{Example 1}
Find the value of each of the six trig functions of $\theta$.  \newline\\
\begin{minipage}{0.4\textwidth}
(a) \newline\\
\begin{tikzpicture}
\coordinate (A) at (0,0);
\coordinate (B) at (3,2);
\coordinate (C) at (3,0);
\draw [color=red] (C) rectangle +(-0.25,0.25);
\draw (A) -- (B) -- node [midway, right] {5} (C) -- node [midway, below] {12} cycle;
\node at (A) [xshift = 0.65cm, yshift = 0.2cm] {$\theta$};
\onslide<2->{\node at (A) [below, yshift=-0.75cm] {$5^2 + 12^2 = c^2$};}
\onslide<3->{\node at (A) [below, yshift=-1.75cm] {$c = \sqrt{169}=13$};}
\onslide<4->{\node at (1.5,1) [above left] {$13$};}
\end{tikzpicture}
\end{minipage}
\begin{minipage}{0.4\textwidth}
\begin{align*}
    \onslide<5->{\sin \theta &= \frac{5}{13}}   \\[18pt]
    \onslide<6->{\cos \theta &= \frac{12}{13}}   \\[18pt]
    \onslide<7->{\tan \theta &= \frac{5}{12}}   \\
\end{align*}
\end{minipage}
\end{frame}

\begin{frame}{Example 1}
\begin{minipage}{0.4\textwidth}
(a) \newline\\
\begin{tikzpicture}
\coordinate (A) at (0,0);
\coordinate (B) at (3,2);
\coordinate (C) at (3,0);
\draw [color=red] (C) rectangle +(-0.25,0.25);
\draw (A) -- (B) -- node [midway, right] {5} (C) -- node [midway, below] {12} cycle;
\node at (A) [xshift = 0.65cm, yshift = 0.2cm] {$\theta$};
% \onslide<2->{\node at (A) [below, yshift=-0.75cm] {$5^2 + 12^2 = c^2$};}
% \onslide<3->{\node at (A) [below, yshift=-1.75cm] {$c = \sqrt{169}=13$};}
\node at (1.5,1) [above left] {$13$};
\end{tikzpicture}
\end{minipage}
\begin{minipage}{0.4\textwidth}
\begin{align*}
    \onslide<2->{\csc \theta &= \frac{13}{5}}   \\[18pt]
    \onslide<3->{\sec \theta &= \frac{13}{12}}   \\[18pt]
    \onslide<4->{\cot \theta &= \frac{12}{5}}   \\
\end{align*}
\end{minipage}
\end{frame}

\begin{frame}{Example 1}
Find the value of each of the six trig functions of $\theta$.  \newline\\
\begin{minipage}{0.45\textwidth}
(b) \newline\\
\raisebox{0.35cm}{
\begin{tikzpicture}
\coordinate (A) at (0,0);
\coordinate (B) at (3,2);
\coordinate (C) at (3,0);
\draw [color=red] (C) rectangle +(-0.25,0.25);
\draw (A) -- node [midway, above] {3} (B) -- node [midway, right] {1} (C) -- cycle;
\node at (A) [xshift = 0.65cm, yshift = 0.2cm] {$\theta$};
\onslide<2->{\node at (0,-1.25) {$a^2+1^2=3^2$};}
\onslide<3->{\node at (0,-2) {$a^2 = 8$};}
\onslide<4->{\node at (0,-2.75) {$a = \sqrt{8} = 2\sqrt{2}$};}
\onslide<5->{\node at (1.5,0) [below] {$2\sqrt{2}$};}
\end{tikzpicture}}
\end{minipage}
\begin{minipage}{0.4\textwidth}
\begin{align*}
    \onslide<6->{\sin \theta &= \frac{1}{3}}   \\[18pt]
    \onslide<7->{\cos \theta &= \frac{2\sqrt{2}}{3}}   \\[18pt]
    \onslide<8->{\tan \theta &= \frac{1}{2\sqrt{2}}}
    \onslide<9->{\left(\frac{\sqrt{2}}{\sqrt{2}} \right)}
    \onslide<10->{=\frac{\sqrt{2}}{4}}\\
\end{align*}
\end{minipage}
\end{frame}

\begin{frame}{Example 1}
Find the value of each of the six trig functions of $\theta$.  \newline\\
\begin{minipage}{0.4\textwidth}
(b) \newline\\
\raisebox{0.35cm}{
\begin{tikzpicture}
\coordinate (A) at (0,0);
\coordinate (B) at (3,2);
\coordinate (C) at (3,0);
\draw [color=red] (C) rectangle +(-0.25,0.25);
\draw (A) -- node [midway, above] {3} (B) -- node [midway, right] {1} (C) -- cycle;
\node at (A) [xshift = 0.65cm, yshift = 0.2cm] {$\theta$};
\node at (1.5,0) [below] {$2\sqrt{2}$};
\end{tikzpicture}}
\end{minipage}
\begin{minipage}{0.4\textwidth}
\begin{align*}
    \onslide<2->{\csc \theta &= \frac{3}{1} = 3}   \\[18pt]
    \onslide<3->{\sec \theta &= \frac{3}{2\sqrt{2}}} \onslide<4->{\left(\frac{\sqrt{2}}{\sqrt{2}}\right)}
    \onslide<5->{ = \frac{3\sqrt{2}}{4}}   \\[18pt]
    \onslide<6->{\cot \theta &= \frac{2\sqrt{2}}{1}=2\sqrt{2}}
\end{align*}
\end{minipage}
\end{frame}

\section{Find the exact trig function values for special right triangles.}

\begin{frame}{45-45-90 Triangles}

45-45-90 triangles (also known as \textit{isosceles right triangles}) can be created by drawing a diagonal across a square:

\begin{center}
    \begin{tikzpicture}
    \tkzDefPoints{0/0/A, 3/0/B, 3/3/C, 0/3/D}
    \tkzDrawPolygon(A,B,C,D)
    \tkzMarkRightAngle[color=red](A,B,C)
    \tkzDrawSegment[dashed](A,C)
    \tkzLabelAngle[pos=0.75](B,A,C){$45^\circ$}
    \tkzLabelAngle[pos=0.75](B,C,A){$45^\circ$}
    \end{tikzpicture}
\end{center}

\end{frame}

\begin{frame}{45-45-90 Triangles}
Since each side of a square is the same length, we can use whatever length we want. For simplicity, we will use a length of 1.  \newline\\ \pause

The diagonal of the square can be found by using Pythagorean Theorem:  \pause

\begin{center}
    \begin{tikzpicture}
    \tkzDefPoints{0/0/A, 3/0/B, 3/3/C}
    \tkzDrawPolygon(A,B,C)
    \tkzMarkRightAngle[color=red](A,B,C)
    \tkzLabelAngle[pos=0.75](B,A,C){$45^\circ$}
    \tkzLabelAngle[pos=0.75](B,C,A){$45^\circ$}
    \tkzLabelSegment[right](B,C){1}
    \tkzLabelSegment[below](A,B){1}
    \tkzLabelSegment[above left, midway](A,C){$\sqrt{2}$}
    \end{tikzpicture}
\end{center}
\end{frame}

\begin{frame}{Example 2}
Find the exact values of the six trig ratios for $45^\circ$. \newline\\
\begin{minipage}{0.4\textwidth}
\begin{tikzpicture}
    \tkzDefPoints{0/0/A, 3/0/B, 3/3/C}
    \tkzDrawPolygon(A,B,C)
    \tkzMarkRightAngle[color=red](A,B,C)
    \tkzLabelAngle[pos=0.75](B,A,C){$45^\circ$}
    \tkzLabelAngle[pos=0.75](B,C,A){$45^\circ$}
    \tkzLabelSegment[right](B,C){1}
    \tkzLabelSegment[below](A,B){1}
    \tkzLabelSegment[above left, midway](A,C){$\sqrt{2}$}
    \end{tikzpicture}
\end{minipage}
\begin{minipage}{0.5\textwidth}
\begin{align*}
    \onslide<2->{\sin 45^\circ &= \frac{1}{\sqrt{2}}} \\[11pt]
    \onslide<3->{&= \frac{1}{\sqrt{2}}\frac{\sqrt{2}}{\sqrt{2}} = \frac{\sqrt{2}}{2}} \\[11pt]
    \onslide<4->{\cos45^\circ &= \frac{1}{\sqrt{2}} = \frac{\sqrt{2}}{2}} \\[11pt]
    \onslide<5->{\tan 45^\circ &= \frac{1}{1} = 1}
\end{align*}
\end{minipage}
\end{frame}

\begin{frame}{Example 2}
\begin{minipage}{0.4\textwidth}
\begin{tikzpicture}
    \tkzDefPoints{0/0/A, 3/0/B, 3/3/C}
    \tkzDrawPolygon(A,B,C)
    \tkzMarkRightAngle[color=red](A,B,C)
    \tkzLabelAngle[pos=0.75](B,A,C){$45^\circ$}
    \tkzLabelAngle[pos=0.75](B,C,A){$45^\circ$}
    \tkzLabelSegment[right](B,C){1}
    \tkzLabelSegment[below](A,B){1}
    \tkzLabelSegment[above left, midway](A,C){$\sqrt{2}$}
    \end{tikzpicture}
\end{minipage}
\begin{minipage}{0.5\textwidth}
\begin{align*}
    \onslide<2->{\csc 45^\circ &= \frac{\sqrt{2}}{1} = \sqrt{2}} \\[18pt]
    \onslide<3->{\sec45^\circ &= \frac{\sqrt{2}}{1} = \sqrt{2}} \\[18pt]
    \onslide<4->{\cot 45^\circ &= \frac{1}{1} = 1}    \\[11pt]
\end{align*}
\end{minipage}
\onslide<5->{\emph{Note}: Your answers from the above example will be the same if you replace $45^\circ$ with $\frac{\pi}{4}$.}
\end{frame}

\begin{frame}{30-60-90 Triangles}
    We can create a 30-60-90 triangle by drawing an altitude in an equilateral triangle.

\begin{center}
    \begin{tikzpicture}
    \tkzDefPoints{0/0/A, 4/0/B}
    \tkzDefPoint(60:4){C}
    \tkzDrawPolygon(A,B,C)
    \tkzDefMidPoint(A,B)
        \tkzGetPoint{D}
    \tkzDrawSegment[dashed](D,C)
    \tkzMarkRightAngle[color=red](A,D,C)
    \tkzLabelAngle[pos=0.5](D,A,C){$60^\circ$}
    \tkzLabelAngle[pos=1](D,C,A){$30^\circ$}
    \end{tikzpicture}
\end{center}
\end{frame}

\begin{frame}{30-60-90 Triangles}
Recall that the altitude of an equilateral triangle bisects one of the sides.   \newline\\    \pause

Rather than use a length of 1 for the sides of the equilateral triangle, we will use a length of 2 (if only to avoid using fractions). \newline\\ \pause

\begin{center}
    \begin{tikzpicture}
    \tkzDefPoints{0/0/A, 4/0/B}
    \tkzDefPoint(60:4){C}
    \tkzDrawPolygon(A,B,C)
    \tkzDefMidPoint(A,B)
        \tkzGetPoint{D}
    \tkzDrawSegment[dashed](D,C)
    \tkzMarkRightAngle[color=red](A,D,C)
    \tkzLabelAngle[pos=0.5](D,A,C){$60^\circ$}
    \tkzLabelAngle[pos=1](D,C,A){$30^\circ$}
    \tkzLabelSegment[below](A,D){1}
    \tkzLabelSegment[below](D,B){1}
    \tkzLabelSegment[midway, above left](A,C){2}
    \tkzLabelSegment[midway, above right](B,C){2}
    \end{tikzpicture}
\end{center}
\end{frame}

\begin{frame}{30-60-90 Triangles}
We can use the Pythagorean Theorem to find the length of the altitude, $\sqrt{3}$:

\begin{center}
    \begin{tikzpicture}
    \tkzDefPoints{0/0/A, 2/0/B}
    \tkzDefPoint(60:4){C}
    \tkzDrawPolygon(A,B,C)
    \tkzMarkRightAngle[color=red](A,B,C)
    \tkzLabelAngle[pos=0.5](B,A,C){$60^\circ$}
    \tkzLabelAngle(B,C,A){$30^\circ$}
    \tkzLabelSegment[below](A,B){1}
    \tkzLabelSegment[right](B,C){$\sqrt{3}$}
    \tkzLabelSegment[midway, above left](A,C){2}
    \end{tikzpicture}
\end{center}
\end{frame}

\begin{frame}{Example 3}
Find the exact values of the six trig ratios for $60^\circ$. \newline\\
\begin{minipage}{0.4\textwidth}
\begin{tikzpicture}
    \tkzDefPoints{0/0/A, 2/0/B}
    \tkzDefPoint(60:4){C}
    \tkzDrawPolygon(A,B,C)
    \tkzMarkRightAngle[color=red](A,B,C)
    \tkzLabelAngle[pos=0.5](B,A,C){$60^\circ$}
    \tkzLabelAngle(B,C,A){$30^\circ$}
    \tkzLabelSegment[below](A,B){1}
    \tkzLabelSegment[right](B,C){$\sqrt{3}$}
    \tkzLabelSegment[midway, above left](A,C){2}
    \end{tikzpicture}
\end{minipage}
\begin{minipage}{0.5\textwidth}
\begin{align*}
    \onslide<2->{\sin 60^\circ &= \frac{\sqrt{3}}{2}} \\[11pt]
    \onslide<3->{\cos 60^\circ &= \frac{1}{2}} \\[11pt]
    \onslide<4->{\tan 60^\circ &= \frac{\sqrt{3}}{1} = \sqrt{3}}
\end{align*}
\end{minipage}
\end{frame}

\begin{frame}{Example 3}
\begin{minipage}{0.4\textwidth}
\begin{tikzpicture}
    \tkzDefPoints{0/0/A, 2/0/B}
    \tkzDefPoint(60:4){C}
    \tkzDrawPolygon(A,B,C)
    \tkzMarkRightAngle[color=red](A,B,C)
    \tkzLabelAngle[pos=0.5](B,A,C){$60^\circ$}
    \tkzLabelAngle(B,C,A){$30^\circ$}
    \tkzLabelSegment[below](A,B){1}
    \tkzLabelSegment[right](B,C){$\sqrt{3}$}
    \tkzLabelSegment[midway, above left](A,C){2}
    \end{tikzpicture}
\end{minipage}
\begin{minipage}{0.5\textwidth}
\begin{align*}
    \onslide<2->{\csc 60^\circ &= \frac{2}{\sqrt{3}}} \\[11pt]
    \onslide<3->{&= \frac{2}{\sqrt{3}}\frac{\sqrt{3}}{\sqrt{3}} = \frac{2\sqrt{3}}{3}} \\[11pt]
    \onslide<4->{\sec 60^\circ &= \frac{2}{1} = 2} \\[11pt]
    \onslide<5->{\cot 60^\circ &= \frac{1}{\sqrt{3}}} \\[11pt]
    \onslide<6->{&= \frac{1}{\sqrt{3}}\frac{\sqrt{3}}{\sqrt{3}} = \frac{\sqrt{3}}{3}}
\end{align*}
\end{minipage}
\end{frame}

\begin{frame}{Example 4}
Find the exact values of the six trig ratios for $30^\circ$. \newline\\
\begin{minipage}{0.4\textwidth}
\begin{tikzpicture}
    \tkzDefPoints{0/0/A, 3/0/B, 3/1.73/C}
    \tkzDrawPolygon(A,B,C)
    \tkzMarkRightAngle[color=red](A,B,C)
    \tkzLabelAngle[pos=0.85](B,A,C){$30^\circ$}
    \tkzLabelAngle[pos=0.5](B,C,A){$60^\circ$}
    \tkzLabelSegment[below](A,B){$\sqrt{3}$}
    \tkzLabelSegment[right](B,C){1}
    \tkzLabelSegment[midway, above left](A,C){2}
    \end{tikzpicture}
\end{minipage}
\begin{minipage}{0.5\textwidth}
\begin{align*}
    \onslide<2->{\sin 30^\circ &= \frac{1}{2}} \\[11pt]
    \onslide<3->{\cos 30^\circ &= \frac{\sqrt{3}}{2}} \\[11pt]
    \onslide<4->{\tan 30^\circ &= \frac{1}{\sqrt{3}} = \frac{\sqrt{3}}{3}}
\end{align*}
\end{minipage}
\end{frame}

\begin{frame}{Example 4}
\begin{minipage}{0.4\textwidth}
\begin{tikzpicture}
    \tkzDefPoints{0/0/A, 3/0/B, 3/1.73/C}
    \tkzDrawPolygon(A,B,C)
    \tkzMarkRightAngle[color=red](A,B,C)
    \tkzLabelAngle[pos=0.85](B,A,C){$30^\circ$}
    \tkzLabelAngle[pos=0.5](B,C,A){$60^\circ$}
    \tkzLabelSegment[below](A,B){$\sqrt{3}$}
    \tkzLabelSegment[right](B,C){1}
    \tkzLabelSegment[midway, above left](A,C){2}
    \end{tikzpicture}
\end{minipage}
\begin{minipage}{0.5\textwidth}
\begin{align*}
    \onslide<2->{\csc 30^\circ &= \frac{2}{1} = 2} \\[11pt]
    \onslide<3->{\sec 30^\circ &= \frac{2}{\sqrt{3}} = \frac{2\sqrt{3}}{3}} \\[11pt]
    \onslide<4->{\cot 30^\circ &= \frac{\sqrt{3}}{1} = \sqrt{3}}  \\[11pt]
\end{align*}
\end{minipage}
\end{frame}

\begin{frame}{Cofunctions}
Notice how $\sin 30^\circ = \cos 60^\circ$, $\tan 30^\circ = \cot 60^\circ$, etc. This is because these ratios are \alert{cofunctions}.   \newline\\  \pause

Any pair of trig functions $f$ and $g$ for which
\[
f(\theta) = g\left(90^\circ - \theta\right)
\]
and vice versa are \textbf{cofunctions}.
\end{frame}

\section{Find missing side lengths in right triangles.}

\begin{frame}{Finding Missing Sides}
You can use SOH-CAH-TOA and your calculator to find missing sides in right triangles.
\end{frame}

\begin{frame}{Example 5}
Find the value of $x$. Round your answer to 2 decimal places. \newline\\
\begin{center}
\begin{tikzpicture}[scale=0.8]
    \tkzDefPoints{0/0/A, 3/0/B, 3/2/C}
    \tkzMarkRightAngle[color=red](C,B,A)
    \tkzDrawPolygon(A,B,C)
    \tkzLabelAngle[](B,A,C){$38^\circ$}
    \tkzLabelSegment[right](B,C){$x$}
    \tkzLabelSegment[below](A,B){14}
\end{tikzpicture}
\end{center}
\begin{align*}
    \onslide<2->{\tan 38^\circ &= \frac{x}{14}} \\[10pt]
    \onslide<3->{0.7813 &= \frac{x}{14}} \\[10pt]
    \onslide<4->{x &= 14(0.7813) \approx 10.94}
\end{align*}
\end{frame}
\end{document}


\section{Math}

Combination
\lstinputlisting{../Math/combination.hpp}

Chinese Remainder Theorem
\lstinputlisting{../Math/crt.hpp}

ExtGcd
\lstinputlisting{../Math/extGcd.hpp}

FFT
\lstinputlisting{../Math/fft.hpp}

GarnerCRT
\lstinputlisting{../Math/garnerCRT.hpp}

LagrangeInterpolation
\lstinputlisting{../Math/lagrangeInterpolation.hpp}

Matrix
\lstinputlisting{../Math/matrix.hpp}

Mod Matrix
\lstinputlisting{../Math/mod_matrix.hpp}

Number Theoretic Transform
\lstinputlisting{../Math/number_theoretic_transform.hpp}


\section{\src{comp_geopot}}

\subsection{Description}

Kernel \src{comp_geopot} is taken from the original subroutine
\src{compute_geopot} in \DYNAMICO.
%
This subroutine is originally defined in module \src{caldyn_gcm_mod}.
%
This module defines subroutine \src{caldyn}, which is the main
subroutines for dynamics part of the model, and several sub-subroutines
for various terms in the governing equation, such as potential
vorticity, geopotential, etc.
%
This subroutine calculates geopotential.

\subsection{Discretization and code}

\autoref{l:definition_comp_geopot} shows the definition part of this subroutine,
and \autoref{f:pad_comp_geopot} shows the PAD of this.

\begin{LstF90}[%
caption={Definition part of \src{compute_geopot}},%
label={l:definition_comp_geopot}%
]
SUBROUTINE compute_geopot(ps,rhodz,theta, pk,geopot)
USE icosa
USE disvert_mod
USE exner_mod
USE trace
USE omp_para
IMPLICIT NONE
  REAL(rstd),INTENT(INOUT) :: ps(iim*jjm)
  REAL(rstd),INTENT(IN)    :: rhodz(iim*jjm,llm)
  REAL(rstd),INTENT(IN)    :: theta(iim*jjm,llm)    ! potential temperature
  REAL(rstd),INTENT(INOUT) :: pk(iim*jjm,llm)       ! Exner function
  REAL(rstd),INTENT(INOUT) :: geopot(iim*jjm,llm+1) ! geopotential

  INTEGER :: i,j,ij,l
  REAL(rstd) :: p_ik, exner_ik
\end{LstF90}

Where \src{ps}, \src{rhodz},
\src{theta}, \src{pk}, and \src{geopot} are
surface pressure, mass,
potential temperature, Exner function, and geopotential, respectively.
%
These arrays except \src{ps} have two dimensions,  first one is for
horizontal index and second one is for vertical index.
%
All of these are defined in the center of control volume in horizontal,
the size of first dimension is \src{iim*jjm}.
%
Also these except \src{ps} and \src{geopot} are defined in the full
level in vertical, the size of second dimension of these are \src{llm},
while \src{geopot} has the size of \src{llm+1}.

\begin{figure}[p]
\centering
 \includegraphics[scale=.45]{figs/geopot.pdf}
 \caption{PAD of \src{compute_geopot}}
 \label{f:pad_comp_geopot}
\end{figure}

Note that in this kernel package
\src{caldyn_eta} is set as \src{eta_mass},
and
\src{boussinesq} is set as \src{.true.},
so in this subroutine only \src{geopot} is calculated as

\begin{LstF90}[numbers=none]
geopot(ij,l+1) = geopot(ij,l) + g*rhodz(ij,l)
\end{LstF90}
%
and Exner pressure
are calculated in subroutine \src{compulte_caldyn_horiz}, which is also
included in this package as kernel \src{comp_caldyn_horiz}.

\clearpage

\subsection{Input data and result}

Input data file is prepared and you can download from official server using
\file{data/download.sh} script.
%
This data file is created by original \DYNAMICO\footnotemark with
Held-Suarez case parameter set included in the original source archive.
%
\footnotetext{with slight modification by AICS.}
%
Max/min/sum of input/output data of the kernel subroutine are output as
a log.
%
Below is an example of \src{$IAB_SYS=Ubuntu-gnu-ompi} case.

\begin{LstLog}
 [KERNEL] comp_geopot
 *** Start  initialize
                iim, jjm, llm:    23    25    19
             ij_begin, ij_end:    48   528
     ij_begin_ext, ij_end_ext:    24   552
             ll_begin, ll_end:     1    19
        t_right, t_rup, t_lup:     1    23    22
     t_left, t_ldown, t_rdown:    -1   -23   -22
        u_right, u_rup, u_lup:     0  1173   575
     u_left, u_ldown, u_rdown:    -1  1150   553
           z_rup, z_up, z_lup:   598     0   597
     z_ldown, z_down, z_rdown:   -23   575   -22
                   caldyn_eta:     1
                   boussinesq:     F
                            g:     9.80000000
 +check[mass_ak         ] max=  2.2205608555404415E+04,min=  2.9655441593806341E+02,sum=  1.7315769223740909E+05
 +check[mass_bk         ] max=  9.8820601234384886E-01,min=  0.0000000000000000E+00,sum=  6.4254510678414123E+00
 *** Finish initialize
 *** Start kernel
 ### check point iteration:        1000
 ### Input ###
 +check[ps_prev         ] max=  1.0000000000000000E+05,min=  1.0000000000000000E+05,sum=  5.7500000000000000E+07
 +check[rhodz           ] max=  1.2306877011993038E+03,min=  0.0000000000000000E+00,sum=  5.3979591836733194E+06
 +check[theta           ] max=  8.0139914420291746E+02,min=  0.0000000000000000E+00,sum=  3.8582633571973117E+06
 +check[pk_prev         ] max=  1.0014594722514462E+03,min=  0.0000000000000000E+00,sum=  6.9872296819747351E+06
 +check[geopot_prev     ] max=  3.8250620498369227E+05,min=  0.0000000000000000E+00,sum=  1.1718001851963627E+09
 ### Output ###
 +check[ps              ] max=  1.0000000000000000E+05,min=  1.0000000000000000E+05,sum=  5.7500000000000000E+07
 +check[pk              ] max=  1.0014594722514462E+03,min=  0.0000000000000000E+00,sum=  6.9872296819747351E+06
 +check[geopot          ] max=  3.8250620498369227E+05,min=  0.0000000000000000E+00,sum=  1.1718001851963627E+09
 ### final iteration:        1000
 ### Validation : grid-by-grid diff ###
 +check[ps              ] max=  0.0000000000000000E+00,min=  0.0000000000000000E+00,sum=  0.0000000000000000E+00
 +check[pk              ] max=  0.0000000000000000E+00,min=  0.0000000000000000E+00,sum=  0.0000000000000000E+00
 +check[geopot          ] max=  0.0000000000000000E+00,min=  0.0000000000000000E+00,sum=  0.0000000000000000E+00
 *** Finish kernel
\end{LstLog}

Check the lines below \src{``Validation : grid-by-grid diff''} line,
that shows difference between calculated output array and
pre-calculated reference array.
These should be zero or enough small to be acceptable.
%
There are sample output log files in \file{reference/}
in each kernel program directory, for reference purpose.

\subsection{Sample of performance result}

Here's an example of the performance result part of the log output.
Below is an example executed with the machine environment described in \autoref{s:measuring_env}.
%
Note that in this program kernel part is iterated 1000 times.

\begin{LstLog}
 *** Computational Time Report
 *** ID=001 : MAIN_comp_geopot                 T=     0.824 N=   1000
\end{LstLog}


\subsection{The Riordan group}
\label{subsection:back:to:the:basics:riordan:group}

In \cite{shapiro:1991}, \citeauthor{shapiro:1991} introduces a generalization
of the concepts developed so far: a group called \emph{Riordan group}, in honor
of professor John Riordan \marginpar{Thank you John Riordan, $1903-1988$}.
This group has been defined in order to unify many themes in enumeration and
combinatoric problems; to solve binomial, inverse identities
\cite{Merlini2006103} and, more recently, combinatorial sums
\cite{Merlini2009475} and binary words counting \cite{Merlini20112988}
\\\\
Let $\mathcal{M}=\lbrace m_{nk}\rbrace_{n,k\in\mathbb{N}}$ be an \emph{infinite
lower triangular matrix}, namely:
\begin{displaymath}
     m_{nk}\in\mathbb{Z} \quad\wedge\quad n < k \rightarrow m_{nk} = 0
\end{displaymath}
Call $\mathcal{M}_{(t)}$ the vector produced by the following product,
where $t$ is a \emph{dummy variable}\marginpar{$\mathcal{M}$ is a matrix of integers,
$\mathcal{M}_{(t)}$ is a vector of \ac{fps} in $\mathbb{Z}[\![t]\!]$}:
\begin{displaymath}
    \left[
        \begin{array}{cccccc}
            1 & t & t^{2} & t^{3} & t^{4} &\ldots
        \end{array}
    \right]
    \left[
        \begin{array}{cccccc}
            m_{00} & & & &  &\\
            m_{10} & m_{11} & & &  &\\
            m_{20} & m_{21}& m_{22}& &  &\\
            m_{30} & m_{31}& m_{32}& m_{33}&  &\\
            m_{40} & m_{41}& m_{42}& m_{43}& m_{44} &\\
            \vdots & \vdots& \vdots& \vdots& \vdots & \ddots\\
        \end{array}
    \right]
\end{displaymath}
therefore $\mathcal{M}_{(t)} =
    \left[
        \begin{array}{cccccc}
            m_{0}(t) & m_{1}(t) & m_{2}(t) & m_{3}(t) &m_{4}(t) & \ldots
        \end{array}
    \right]$
with function $m_{j}$, for $j\in\mathbb{N}$, is a \ac{fps} in the ring
$\mathbb{Z}[\![t]\!]$. If there exists two analytic functions $d$
and $h$, such that $d(0)\neq0$ and $h(0)=0 \wedge h^{\prime}(0)\neq0$, which
satisfy \marginpar{matrix $\mathcal{M}$ will be denoted by the pair $(d(t),h(t))$}:
\begin{displaymath}
    m_{j}(t)=d(t)\,h(t)^{j} \quad \forall j\in\mathbb{N}
\end{displaymath}
then matrix $\mathcal{M}$ is called a \emph{Riordan array}. Such an array is
directly related to coefficients matrix $\lbrace m_{nk}\rbrace_{n,k\in\mathbb{N}}$ as follows:
\begin{displaymath}
    [t^{n}]m_{j}(t)=m_{nj}
\end{displaymath}

For the sake of clarity we derive the Riordan array which denotes the
following matrix:
%\begin{table}{!H}
    \begin{displaymath}
        %\hspace{-2.5cm}
        \left[
        \begin{array}{rrrrrrrrrr}
        1 &  &  &  &  &  &  &  &  &  \\
        1 & 1 &  &  &  &  &  &  &  &  \\
        1 & 2 & 1 &  &  &  &  &  &  &  \\
        1 & 3 & 3 & 1 &  &  &  &  &  &  \\
        1 & 4 & 6 & 4 & 1 &  &  &  &  &  \\
        1 & 5 & 10 & 10 & 5 & 1 &  &  &  &  \\
        1 & 6 & 15 & 20 & 15 & 6 & 1 &  &  &  \\
        1 & 7 & 21 & 35 & 35 & 21 & 7 & 1 &  &  \\
        1 & 8 & 28 & 56 & 70 & 56 & 28 & 8 & 1 &  \\
        1 & 9 & 36 & 84 & 126 & 126 & 84 & 36 & 9 & 1
        \end{array}
        \right]
    \end{displaymath}
%  \caption[Pascal matrix for Riordan array derivation]{Initial chunk of
%    the \emph{Pascal} matrix, defined as $\lbrace {{n}\choose{k}}\rbrace_{n,k\in\mathbb{N}}$}
%  \label{tab:pascal:matrix}
%\end{table}
\marginpar{an example: looking for Pascal array definition}
also called \emph{Pascal} triangle. In order to build the definition for array
$\mathcal{P}$ we have to find to functions $d_{\mathcal{P}}$ and
$h_{\mathcal{P}}$. Coefficients lying on the very first column belongs to
sequence $\vect{1}=\lbrace1\rbrace_{n\in\mathbb{N}}$, therefore function $m_{0}$
satisfies:
\begin{displaymath}
    m_{0}(t)=\frac{1}{1-t}
\end{displaymath}
according to \autoref{eq:1:gf}, therefore $m_{0}(t)=d(t)$, so function $d$ has been
defined.

In order to find function $h$, observe the second column. Coeffiecients lying on it
belongs to sequence $\vect{n}=\lbrace n\rbrace_{n\in\mathbb{N}}$ of natural numbers,
therefore function $m_{1}$ satisfies:
\begin{displaymath}
    m_{1}(t)=d(t)\,h(t)=\frac{t}{(1-t)^{2}}
\end{displaymath}
according to \autoref{eq:n:gf}. Simple manipulation yields:
\begin{displaymath}
    h(t)=\frac{t}{1-t}
\end{displaymath}
defining function $h$. Therefore the array $\mathcal{P}$ we are looking for is:
\begin{equation}
    \mathcal{P}=\left(\frac{1}{1-t},\frac{t}{1-t}\right)
    \label{eq:pascal:array:derived:for:example}
\end{equation}
as desired.

\begin{theorem}[Fundamental theorem]
    Let $\mathcal{M}=(d(t),h(t))$ be a Riordan matrix and $\vect{b}=
    \left[\begin{array}{cccc}b_{0}&b_{1}&b_{2}&\ldots\end{array}\right]^{T}$
    be an infinite column vector with $b_{j}\in\mathbb{Z}$, for $j\in\mathbb{N}$. Then:
    \begin{displaymath}
        \mathcal{M}_{(t)}\cdot\vect{b}=d(t)b(h(t))
    \end{displaymath}
    where function $b$ is a \ac{fps} over coefficients in $\vect{b}$.
    \label{thm:riordan:group:fundamental:theorem}
\end{theorem}
\begin{proof}
    By definition of vector $\mathcal{M}_{(t)}$:
    \begin{displaymath}
        \mathcal{M}_{(t)}\cdot\vect{b}= b_{0}\,m_{0}(t) + b_{1}\,m_{1}(t) + b_{2}\,m_{2}(t)
            + b_{3}\,m_{3}(t) + b_{4}\,m_{4}(t) + \ldots
    \end{displaymath}
    by definition of function $m_{j}$, for any $j\in\mathbb{N}$:
    \begin{displaymath}
        = b_{0}\,d(t)h(t)^{0} + b_{1}\,d(t)h(t) + b_{2}\,d(t)h(t)^{2}
            + b_{3}\,d(t)h(t)^{3} + b_{4}\,d(t)h(t)^{4} + \ldots
    \end{displaymath}
    factor out function $d$:
    \begin{displaymath}
        = d(t)\left(b_{0}\,h(t)^{0} + b_{1}\,h(t) + b_{2}\,h(t)^{2}
            + b_{3}\,h(t)^{3} + b_{4}\,h(t)^{4} + \ldots\right)
    \end{displaymath}
    finally, rewrite composing function $h$ with function $b$:
    \begin{displaymath}
        = d(t)b(h(t))
    \end{displaymath}
    as required.

\end{proof}

In the introductory paragraph we said that the current generalization
we are studying is a \emph{group}. More formally, we are going to define a
\emph{group} over a \emph{set of Riordan matrices},
denoted by $(\lbrace \mathcal{M}_{i}\rbrace_{i\in\mathbb{N}},\cdot)$,
where $\cdot$ is the \emph{group
operator}: additionally it is required to show the \emph{identity element} and,
finally, to prove that there exists an \emph{inverse} for every element in the group.
\\\\
Let $\mathcal{M}=\left(d_{\mathcal{M}}(t),h_{\mathcal{M}}(t)\right)$ and
$\mathcal{N}=\left(d_{\mathcal{N}}(t),h_{\mathcal{N}}(t)\right)$ be two Riordan matrices.
Define the \emph{group operator} as their product
\marginpar{matrix multiplication as group operator}, formally:
\begin{displaymath}
    \left(d_{\mathcal{M}}(t),h_{\mathcal{M}}(t)\right)\cdot
        \left(d_{\mathcal{N}}(t),h_{\mathcal{N}}(t)\right) =
        \left(d_{\mathcal{M}}(t)d_{\mathcal{N}}(h_{\mathcal{M}}(t)),
            h_{\mathcal{N}}(h_{\mathcal{M}}(t))\right)
\end{displaymath}
\begin{proof}
    Consider a column $j$ of matrix $\mathcal{N}$,
    for some $j\in\mathbb{N}$. Denoting by $\vect{e}_{j}$ the $j$-th versor and
    by $n_{j}(t)=d_{\mathcal{N}}(t)h_{\mathcal{N}}(t)^{j}$ the \ac{fps} over such column,
    by \autoref{thm:riordan:group:fundamental:theorem} the following holds:
    \begin{displaymath}
        \mathcal{M}_{(t)}\cdot\left(\mathcal{N}\cdot\vect{e}_{j}\right)
            = d_{\mathcal{M}}(t) d_{\mathcal{N}}(h_{\mathcal{M}}(t))
                h_{\mathcal{N}}(h_{\mathcal{M}}(t))^{j}
    \end{displaymath}
    Let $d_{\mathcal{M}\mathcal{N}}$ be a function such that
    $d_{\mathcal{M}\mathcal{N}}(t)=d_{\mathcal{M}}(t) d_{\mathcal{N}}( h_{\mathcal{M}}(t))$,
    and let $h_{\mathcal{M}\mathcal{N}}$ be a function such that
    $h_{\mathcal{M}\mathcal{N}}(t)=h_{\mathcal{N}}(h_{\mathcal{M}}(t))$, then the \ac{rhs}
    has the shape
    $d_{\mathcal{M}\mathcal{N}}(t)h_{\mathcal{M}\mathcal{N}}(t)^{j}$, which denotes the
    Riordan matrix $\mathcal{M}\mathcal{N}$, as required.

\end{proof}
\quad
\\\\
The \marginpar{$(1,t)$ is the identity element} identity element of the group
is the Riordan matrix $\mathcal{I}=(1,t)$.
\begin{proof}
    Let $\mathcal{M}=\left(d_{\mathcal{M}}(t),h_{\mathcal{M}}(t)\right)$ be a Riordan matrix.
    By definition of group operator:
    \begin{displaymath}
        \left(d_{\mathcal{M}}(t),h_{\mathcal{M}}(t)\right)\cdot \left(1,t\right) =
            \left(d_{\mathcal{M}}(t), h_{\mathcal{M}}(t)\right)
    \end{displaymath}
    since group operator $\cdot$ is no commutative in general, check the following also:
    \begin{displaymath}
        \left(1,t\right) \cdot \left(d_{\mathcal{M}}(t),h_{\mathcal{M}}(t)\right)=
            \left(d_{\mathcal{M}}(t), h_{\mathcal{M}}(t)\right)
    \end{displaymath}
    as required.
\end{proof}
\quad
\\\\
In order to find the \emph{inverse} of a Riordan matrix, we have to
introduce the concept of \marginpar{compositional inverse of a function}
\emph{compositional inverse} of an analytic function $h$.
Let $h$ be a function such that $h(0)=0 \wedge h^{\prime}(0)\neq0$, then
$\hat{h}$ is the \emph{compositional inverse} of function $h$ if and only if
$\hat{h}(h(t))=h(\hat{h}(t))=t$.
\\\\
Let $\mathcal{M}=\left(d_{\mathcal{M}}(t),h_{\mathcal{M}}(t)\right)$ be a Riordan matrix.
The inverse matrix $\mathcal{M}^{-1}$ of $\mathcal{M}$ satisfies the following relation:
\begin{displaymath}
    \mathcal{M}^{-1}=\left(
        \frac{1}{d_{\mathcal{M}}(\hat{h}_{\mathcal{M}}(t))}, \hat{h}_{\mathcal{M}}(t)
    \right)
\end{displaymath}

\begin{proof}
    By definition of inverse element\marginpar{inverse of an element in
    $\left(\lbrace \mathcal{M}_{i}\rbrace,\cdot\right)$},
    we have to find a matrix $\mathcal{M}^{-1}$ which satisfies the following relation:
    \begin{displaymath}
        \mathcal{M}\cdot\mathcal{M}^{-1}
            =\left(d_{\mathcal{M}}(t)d_{\mathcal{M}^{-1}}(h_{\mathcal{M}}(t)),
                    h_{\mathcal{M}^{-1}}(h_{\mathcal{M}}(t))\right)
            =\left(1,t\right)
    \end{displaymath}

    Looking at the first component we get:
    \begin{displaymath}
        d_{\mathcal{M}}(t)d_{\mathcal{M}^{-1}}(h_{\mathcal{M}}(t))=1
    \end{displaymath}
    which can be rewritten as\marginpar{abstracting function $g$ in the
        composition $f(g(t))$ yield $\left.\left[f(y)\right|y=g(t)\right]$,
        a trick also called ``changing variable''}:
    \begin{displaymath}
        d_{\mathcal{M}^{-1}}(h_{\mathcal{M}}(t))=\frac{1}{d_{\mathcal{M}}(t)}
            = \left.\left[
                d_{\mathcal{M}^{-1}}(y)=\frac{1}{d_{\mathcal{M}}(\hat{h}_{\mathcal{M}}(y))}
                    \right|y=h_{\mathcal{M}}(t)
                \right]
    \end{displaymath}

    On the other hand, looking at the second component we get:
    \begin{displaymath}
        h_{\mathcal{M}^{-1}}(h_{\mathcal{M}}(t))=t
    \end{displaymath}
    therefore $h_{\mathcal{M}^{-1}}=\hat{h}_{\mathcal{M}}$, as required.
\end{proof}
\quad
\\\\
It \marginpar{subgroups of the Riordan group}
is interesting to dig a little on the \emph{Riordan group}, looking at
common patterns that arises in Riordan matrices definitions. Denoting with
$\cdot$ the group operator defined as before, we report
these patterns by introducing the following \emph{subgroups}:
\begin{itemize}
    \item $\left(\lbrace \mathcal{M}_{i}=(d_{\mathcal{M}_{i}}(t),t)
        \rbrace_{i\in\mathbb{N}},\cdot\right)$, the \emph{Appell subgroup};
    \item $\left(\lbrace \mathcal{M}_{i}=(1,h_{\mathcal{M}_{i}}(t))
        \rbrace_{i\in\mathbb{N}},\cdot\right)$, the \emph{Associated subgroup};
    \item $\left(\lbrace \mathcal{M}_{i}=(d_{\mathcal{M}_{i}}(t),td_{\mathcal{M}_{i}}(t))
        \rbrace_{i\in\mathbb{N}},\cdot\right)$, the \emph{Renewal subgroup};
    \item $\left(\lbrace \mathcal{M}_{i}=(d_{\mathcal{M}_{i}}(t),h_{\mathcal{M}_{i}}(t))
        \rbrace_{i\in\mathbb{N}},\cdot\right)$, where function $d$ is \emph{even} and
        function $h$ is \emph{odd}, the \emph{Checkerboard subgroup};
    \item $\left(\left\lbrace \mathcal{M}_{i}=\left(\frac{t\,h_{\mathcal{M}_{i}}^{\prime}(t)}
            {h_{\mathcal{M}_{i}}(t)},h_{\mathcal{M}_{i}}(t)\right)
        \right\rbrace_{i\in\mathbb{N}},\cdot\right)$, the \emph{Hitting-time subgroup};
\end{itemize}
\quad
\\\\
Finally, \marginpar{a characterization using a bivariate function}
we would like to discuss another interesting definition which characterize
a Riordan array $\mathcal{M}=(d_{\mathcal{M}}(t),h_{\mathcal{M}}(t))$.
The main point is to associate a bivariate function $m$
to the infinite lower triangular matrix $\lbrace m_{nk}\rbrace_{n,k\in\mathbb{N}}$
of coefficients, used to build $\mathcal{M}$. Function $m$ is defined as follows:
\begin{displaymath}
    \begin{split}
        m(t,u) &= \sum_{k\in\mathbb{N}}{\sum_{n\geq k}{m_{nk} t^{n} u^{k}}}
            = \sum_{k\in\mathbb{N}}{u^{k}\sum_{n\geq k}{m_{nk} t^{n}}}
            = \sum_{k\in\mathbb{N}}{m_{k}(t)u^{k}}\\
            &= \sum_{k\in\mathbb{N}}{d_{\mathcal{M}}(t)\,h_{\mathcal{M}}(t)^{k}\,u^{k}}
            = \frac{d_{\mathcal{M}}(t)}{1-h_{\mathcal{M}}(t)\,u}
    \end{split}
\end{displaymath}
This characterization is more general and allows us to have \ac{fps}
$m_{j}^{(t)}(u)$ for a column $j$, if it is expanded respect to variable $t$;
and, by symmetry, to have \ac{fps} $m_{l}^{(u)}(t)$ for a row $l$, if it is
expanded respect to variable $u$.


% This is part of the TFTB Reference Manual.
% Copyright (C) 1996 CNRS (France) and Rice University (US).
% See the file refguide.tex for copying conditions.

\markright{doppler}
\section*{\hspace*{-1.6cm} doppler}

\vspace*{-.4cm}
\hspace*{-1.6cm}\rule[0in]{16.5cm}{.02cm}
\vspace*{.2cm}

{\bf \large \sf Purpose}\\
\hspace*{1.5cm}
\begin{minipage}[t]{13.5cm}
Complex Doppler signal.
\end{minipage}
\vspace*{.5cm}

{\bf \large \sf Synopsis}\\
\hspace*{1.5cm}
\begin{minipage}[t]{13.5cm}
\begin{verbatim}
[fm,am,iflaw] = doppler(N,fs,f0,d,v)
[fm,am,iflaw] = doppler(N,fs,f0,d,v,t0)
[fm,am,iflaw] = doppler(N,fs,f0,d,v,t0,c)
\end{verbatim}
\end{minipage}
\vspace*{.5cm}

{\bf \large \sf Description}\\
\hspace*{1.5cm}
\begin{minipage}[t]{13.5cm}
         {\ty doppler} returns the frequency modulation ({\ty fm}), the
         amplitude modulation ({\ty am}) and the instantaneous frequency
         law ({\ty iflaw}) of the signal received by a fixed observer from
         a moving target emitting a pure frequency {\ty f0}.\\

\hspace*{-.5cm}\begin{tabular*}{14cm}{p{1.5cm} p{8.5cm} c}
Name & Description & Default value\\
\hline
         {\ty N}  & number of points\\
         {\ty fs} & sampling frequency (in Hz)\\
         {\ty f0} & target   frequency (in Hz)\\
         {\ty d}  & distance from the line to the observer (in meters)\\
         {\ty v}  & target velocity    (in m/s)\\
         {\ty t0} & time center                  & {\ty N/2}\\
         {\ty c}  & wave velocity      (in m/s)  & {\ty 340}\\
 \hline  {\ty fm} & output frequency modulation\\
         {\ty am} & output amplitude modulation\\
         {\ty iflaw} & output instantaneous frequency law\\

\hline
\end{tabular*}
\vspace*{.2cm}

The doppler effect characterizes the fact that a signal returned from a
moving target is scaled and delayed compared to the transmitted signal. For
narrow-band signals, this scaling effect can be considered as a frequency
shift. \\

{\ty [fm,am,iflaw] = doppler(N,fs,f0,d,v,t0,c)} returns the signal received
by a fixed observer from a moving target emitting a pure frequency {\ty
f0}. The target is moving along a straight line, which gets closer to the
observer up to a distance {\ty d}, and then moves away. {\ty t0} is the
time center (i.e. the time at which the target is at the closest distance
from the observer), and {\ty c} is the wave velocity in the medium.

\end{minipage}

\newpage

{\bf \large \sf Example}\\
\hspace*{1.5cm}
\begin{minipage}[t]{13.5cm}
Plot the signal and its instantaneous frequency law received by an observer
from a car moving at the speed $v=50 m/s$, passing at 10 meters from the
observer (the radar). The rotating frequency of the engine is $f_0=65 Hz$,
and the sampling frequency is $f_s=200 Hz$ :
\begin{verbatim}
     N=512; [fm,am,iflaw]=doppler(N,200,65,10,50);
     subplot(211); plot(real(am.*fm));
     subplot(212); plot(iflaw);
     [ifhat,t]=instfreq(sigmerge(am.*fm,noisecg(N),15),11:502,10);
     hold on; plot(t,ifhat,'g'); hold off;
\end{verbatim}
\end{minipage}
\vspace*{.5cm}

{\bf \large \sf See Also}\\
\hspace*{1.5cm}
\begin{minipage}[t]{13.5cm}
\begin{verbatim}
dopnoise.
\end{verbatim}
\end{minipage}


\input{../common/common.tex}

\title{Math notes - Counting and countable sets}
\author{Uwe Hoffmann}
\hypersetup{colorlinks, pdftitle={Math notes - Counting and countable sets}}

\begin{document}

\setcounter{chapter}{1}
\section*{Counting and countable sets}

\newthought{Countable sets} and counting schemes for infinite countable sets are the topics of the problem in this note. \index{countable set}

\vspace{10 mm}
\begin{problem}
Let $P = \{ N \subset \mathbb{N}: N \text{  finite}\}$. Prove $P$ is countable.
\end{problem}

Let's revisit what it means for an infinite set to be countable: An infinite set $M$ is countable if there is a bijection \footnote{A bijection is a function that is one-to-one and onto.} from $M$ to $\mathbb{N}$.

Given this definition, the problem statement is quite remarkable: the set of all the finite subsets of $\mathbb{N}$ is not ``bigger'' than $\mathbb{N}$.
\newline

\noindent Our strategy will be to start smaller and prove certain subsets of $P$ are countable. We then expand it to $P$. We start by proving that the set of all subsets of $\mathbb{N}$ of size two is countable. We actually will prove something stronger, namely the set of ordered pairs of natural numbers is countable.

\begin{thm}\label{countingpairs}
The set of ordered pairs $\mathbb{N} \times \mathbb{N}$ is countable.
\end{thm}

\todo{Mention puzzle 136 (Catching a Spy) from Levitin: Algorithmic Puzzles}

\begin{proof}
We need a bijection from $\mathbb{N} \times \mathbb{N} \rightarrow \mathbb{N}$. There are many ways to do this
\footnote{A very elegant way is described at \url{http://www.math.upenn.edu/~wilf/website/recounting.pdf}}.

\begin{marginfigure}[1.0in]
\begin{tikzpicture}
 \node at (-2, 3)  (1l) [anchor=north west] {$(1, 1)$};
 \node at (3, 3)  (1r) [anchor=north east] {$\text{row } 1$};
 \node at (-2, 2)  (2l) [anchor=north west] {$(1, 2), (2, 1)$};
 \node at (3, 2)  (2r) [anchor=north east] {$\text{row } 2$};
 \node at (-2, 1)  (3l) [anchor=north west] {$(1, 3), (2, 2), (3, 1)$};
 \node at (3, 1)  (3r) [anchor=north east] {$\text{row } 3$};
 \node at (-2, 0)  (4l) [anchor=north west] {$(1, 4), (2, 3), (3, 2), (4, 1)$};
 \node at (3, 0)  (4r) [anchor=north east] {$\text{row } 4$};
 \node at (0, -0.5) [anchor=north east] {$\dots$};
 \draw [->] (1l) -- (1r);
 \draw [->] (2l) -- (2r);
 \draw [->] (3l) -- (3r);
 \draw [->] (4l) -- (4r);
\end{tikzpicture}
\caption{Counting all pairs.}
\label{fig:counting}
\end{marginfigure}

The main idea we are going to use for our bijection is to order the pairs $(i, j) \in \mathbb{N} \times \mathbb{N}$ in rows, such that each pair in a row has the same value when summing the components of the pair. Figure \ref{fig:counting} illustrates the idea. Row one has all pairs with components that sum up to two (in this case only one pair). Row two has all pairs with components that sum up to three, row three all pairs which sum to four, $\dots$. Notice also that
in a row the pairs are sorted in increasing order of the first component.

We count the pairs from left to right in each row and go down the rows starting at the first row. For a given pair $(i, j)$, how many pairs come before it in our counting scheme? It is in row $i + j - 1$, so there are $k: 1 \le k < i + j - 1$ rows before it.  Each row $k$ has $k$ pairs in it. This means there are
$$
\sum_{k=1}^{i+j-2} k = \frac{(i+j-2)(i+j-1)}{2}
$$
pairs in rows before our pair $(i, j)$. There are $i - 1$ pairs before $(i, j)$ in the same row. Therefore, our counting function is
$$
f:\mathbb{N} \times \mathbb{N} \rightarrow \mathbb{N}, ~~f(i, j) = i + \frac{(i+j-2)(i+j-1)}{2}
$$
Suppose we have two pairs $(i_1, j_1) \ne (i_2, j_2)$. We have two cases:

\begin{itemize}
\item $i_1+j_1=i_2+j_2$, same row, then $i_1 \ne i_2$, so $f(i_1, j_1) \ne f(i_2, j_2)$
\item $i_1+j_1 \ne i_2+j_2$, different rows, so $f(i_1, j_1) \ne f(i_2, j_2)$
\end{itemize}

This means, $f$ is one-to-one.

To prove that $f$ is onto, we consider an arbitrary $n \in \mathbb{N}$ and find a pair $(i, j)$ with $f(i, j)=n$. Working backwards and assuming we have a pair $(i, j)$ with $f(i, j)=n$, it would fall on a row $r = i + j - 1$. In each row $k$ there are $k$ pairs, $n$ is on row $r$, so
$$
\sum_{k=1}^{r-1} k = \frac{r(r-1)}{2} < n \leq \sum_{k=1}^{r} k = \frac{r(r+1)}{2}
$$
Solving for $r$ we have:\footnote{Note that $\frac{1 + \sqrt{1 + 8 n}}{2} - \frac{-1 + \sqrt{1 + 8 n}}{2} = 1$}

$$
r^2 - r - 2n < 0, ~~r^2 + r - 2n \geq 0, ~~r = \bigg\lceil \frac{-1 + \sqrt{1 + 8 n}}{2} \bigg\rceil
$$
And then
$$
i = n - \frac{r(r - 1)}{2}, ~~j = r - i + 1
$$
This means that given an arbitrary $n$, there exists a pair $(i, j)$ with $f(i, j)=n$, so $f$ is onto.

It follows that $f$ is a bijection and $\mathbb{N} \times \mathbb{N}$ is countable.
\end{proof}

A corrollary to Theorem~\ref{countingpairs} let's us expand the countable subsets of $P$ even more.

\begin{cor}
Set of all finite sequences of length $k$, $\mathbb{N}^k$ is countable.\footnote{$\mathbb{N}^k$ is the set of sequences of length k, or the cartesian product
$\mathbb{N} \times \mathbb{N} \times \dots \mathbb{N}$. The set of pairs is $\mathbb{N}^2=\mathbb{N} \times \mathbb{N}$.}
\end{cor}

\begin{proof}
Follows by induction on $k$: Assuming $\mathbb{N}^{k - 1}$ is countable, then
$$
\mathbb{N}^k = \mathbb{N}^{k - 1} \times \mathbb{N}
$$
is also countable according to Theorem~\ref{countingpairs}.
\end{proof}

From the corrollary we now know \footnote{We keep using the fact that the set of all finite subsets of $\mathbb{N}$ of size $k$ is a subset of the set of all sequences of size $k$. To see this impose an order on a set of size $k$ and you get a sequence.} that the set of all subsets of $\mathbb{N}$ of size $k$ is countable (it's a subset of $\mathbb{N}^k$). The problem in this section asks us to prove that $P$ is countable, which means the union of all these countable sets is countable. The next theorem\footnote{Exercise 1.5.3 on page 30 from \bibentry{abbott15}.} will prove just that.

\begin{thm}
Let $A_n, ~n \in \mathbb{N}$ be countable sets. Then
$$
\bigcup_{n=1}^\infty A_n
$$
is countable.
\end{thm}

\begin{proof}
$A_n$ is countable, so there exists a bijection $f_n:\mathbb{N} \rightarrow A_n$. We already know that $\mathbb{N} \times \mathbb{N}$ is countable, so there exists a bijection $g:\mathbb{N} \rightarrow \mathbb{N} \times \mathbb{N}$.

We define $F:\mathbb{N} \rightarrow \bigcup_{n=1}^\infty A_n$
$$
F(n) = f_i(j), ~\text{where}~ (i, j) = g(n)
$$
We claim that $F$ is a bijection.

Take $n_1 \ne n_2$. Then $g(n_1) \ne g(n_2)$ and $(i_1, j_2) \ne (i_2, j_2)$, so
$$
f_{i_1}(j_1) \ne f_{i_2}(j_2)
$$
It means $F(n_1) \ne F(n_2)$ and $F$ is one-to-one.

Now pick an arbitrary $a \in \bigcup_{n=1}^\infty A_n$. Then there exists $i \in \mathbb{N}$ with $a \in A_i$. \footnote{We assume here the $A_i$ are disjoint, if not we make them disjoint and their union stays the same.} There also exists $j \in \mathbb{N}$ with $f_i(j) = a$. The pair $(i, j)$ is in
$\mathbb{N} \times \mathbb{N}$, so there exists $n \in \mathbb{N}$ with $g(n)=(i, j)$. It follows that $F(n)=a$ and F is onto.
\end{proof}

\bibliographystyle{plainnat}
\bibliography{../common/math}

\end{document}