%\begin{document}
\section{Separate Networks}%
\label{sec:separate_networks}
% \subsection{Single Network}%
% \label{subsec:single_network}
%
Recall that a single leapfrog step (in the \emph{forward} \((d = +1)\)
direction) of the L2HMC algorithm consists of the following 4 updates:
% \vspace{-20pt}
\begin{enumerate}
  \item \(\mathrm{\textbf{vNet}}: \zeta_{1} \coloneqq (x, \partial_{x}U(x), t)
    \longrightarrow (S_{v}, T_{v}, Q_{v})\):
    \begin{equation}
      \vp = v \odot \exp{\left(\frac{\eps}{2}S_{v}(\zeta_{1})\right)}%
             - \frac{\eps}{2}\left[\partial_{x}\,U(x)\odot \exp{\left(\eps
               Q_{v}(\zeta_{1})\right)}%
             + T_{v}(\zeta_{1})\right]
    \end{equation}
  \item \(\mathrm{\mathbf{xNet}}: \zeta_{2} \coloneqq
    (x_{\bar{m}^{t}}, \vp, t) \longrightarrow (S_{x}, T_{x}, Q_{x})\):
    \begin{equation}
      \xp = x_{\bar{m}^{t}} + m^{t}\odot \left[x \odot \exp{\left(\eps
              S_{x}(\zeta_{2})\right)}%
            + \eps\left(\vp\odot\exp{\left(\eps Q_{x}(\zeta_{2})\right)}
            + T_{x}(\zeta_{2})\right)\right]
    \end{equation}
  \item \(\mathrm{\mathbf{xNet}}: \zeta_{3} \coloneqq (x_{m^{t}}^{\prime}, \vp,
    t) \longrightarrow (S_{x}, T_{x}, Q_{x})\):
    \begin{equation}
      \xpp = x^{\prime}_{m^{t}} + \bar{m}^{t}\odot \left[\xp \odot \exp{\left(\eps
              S_{x}(\zeta_{3})\right)}%
            + \eps\left(\vp\odot\exp{\left(\eps Q_{x}(\zeta_{3})\right)}
            + T_{x}(\zeta_{3})\right)\right]
    \end{equation}
  \item \(\mathrm{\mathbf{vNet}}: \zeta_{4} \coloneqq (\xpp,
    \partial_{x}U(\xpp), t) \longrightarrow (S_{v}, T_{v}, Q_{v})\):
    \begin{equation}
      \vpp = \vp \odot \exp{\left(\frac{\eps}{2}S_{v}(\zeta_{4})\right)}%
              - \frac{\eps}{2}\left[\partial_{x}\,U(\xpp)\odot \exp{\left(\eps
                  Q_{v}(\zeta_{4})\right)}%
              + T_{v}(\zeta_{4})\right].
    \end{equation}
\end{enumerate}
%

A complete trajectory (of \(\Nlf\) leapfrog steps) is then obtained via
\(\Nlf\) successive applications of the above procedure, followed by a MH
accept/reject step.
%
Note that in this approach we use the \textbf{same two networks for all
leapfrog steps}, namely: \(\{\mathrm{\mathbf{xNet}}, \mathrm{\mathbf{vNet}}\}\),
which update \(\{x, v\}\) respectively.
%
% \subsection{Separate Networks}%
% \label{subsec:separate_networks}
%
This can be generalized by introducing \textbf{different networks for each
leapfrog step} (e.g.\@ the first LF step uses \(\{\xNet^{(1)},
\vNet^{(1)}\}\), the second uses \(\{\xNet^{(2)}, \vNet^{(2)}\}\), \(\ldots\), and
the final step uses \(\{\xNet^{(\Nlf)}, \vNet^{(\Nlf)}\}\)).
%
While this approach dramatically increases the number of trainable parameters,
it is also vastly more expressive and allows the model to learn independent
updates for each leapfrog step.
%

Explicitly, let \(\LBtheta^{(i)}: \xi \rightarrow \xip\) denote the operator which performs
the \(i^{th}\) (augmented) leapfrog step in the direction \(d\), and introduce
\(\Gamma_{\pm}^{(i)}: \left(v; \zeta_{v}\right) \rightarrow \vp\),
\(\Lambda_{\pm}^{(i)}: \left(x; \zeta_{x}\right)\rightarrow \xp\),
%
where \(\zeta_{v} = (x, \partial_{x}U(x), t)\), \(\zeta_{x} = (x, v, t)\).
% , and
% the functions \(\GammaPMi, \LambdaPMi\) update the momentum and position
% variables, respectively.
%
We can then write the full position and momentum updates in terms of these
functions
%
\begin{align}
  \Gamma_{\pm}^{(i)}\left(v; \zeta_{v}\right) % \coloneqq \vp =
    &= \begin{cases}%\,\,\,
      v \odot \exp{\left(\frac{\eps}{2}\Svi(\zeta_{v})\right)}%
        - \frac{\eps}{2}\left[\partial_{x}\,U(x)\odot \exp{\left(\eps
            \Qvi(\zeta_{v})\right)}%
        + \Tvi(\zeta_{v})\right]
        &\quad (d = + 1)\\
      % -------------------
      % \vspace{0.75cm}%\,\,\,
      % -------------------
      \left\{v + \frac{\eps}{2}\left[\partial_{x}\,U(x)\odot
          \exp{\left(\eps \Qvi(\zeta_{1})\right)}%
            + \Tvi(\zeta_{1})\right]\right\} \odot
            \exp{\left(-\frac{\eps}{2}\Svi(\zeta_{1})\right)}
      &\quad (d = - 1)
    \end{cases}\\
  %%%%%%%%%%%%%%%%%
  % \vspace{2.5cm}
    &\quad \nonumber \\
  %%%%%%%%%%%%%%%%%
  \Lambda_{\pm}^{(i)}\left(x; \zeta_{x}\right) % \coloneqq \xp
    &= \begin{cases}%\,\,\,%
      x \odot \exp{\left(\eps
        \Sxi(\zeta_{x})\right)}%
        + \eps\left[\vp\odot\exp{\left(\eps \Qxi(\zeta_{x})\right)}
        + \Txi(\zeta_{x})\right]%
      &\quad (d = + 1) \\
      % -------------------
      % \vspace{0.75cm}%\,\,\,
      % -------------------
      \left\{x - \eps{\left[\vp\odot\exp{\left(\eps \Qxi(\zeta_{x})\right)}%
          + \Txi(\zeta_{x})\right]}\right\}\odot \exp{\left(-\eps
          \Sxi(\zeta_{x})\right)}%
      &\quad (d = + 1)
  \end{cases}\\
\end{align}
%
We can write the \(i^{th}\) leapfrog step as:
%
\begin{enumerate}
  \item \(v \longrightarrow \vp = \Gamma_{\pm}^{(i)}(v; \zeta_{v})\)
  \item \(x \longrightarrow \xp = x_{\bar{m}^{t}} +
    \Lambda_{\pm}^{(i)}(x_{m^{t}}; \zeta_{x})\)
  \item \(\xp \longrightarrow \xpp = \xp_{\bar{m}^{t}} +
    \Lambda_{\pm}^{(i)}(\xp_{m^{t}}; \zeta_{x}^{\prime})\)
  \item \(\vp \longrightarrow \vpp = \Gamma_{\pm}^{(i)}(\vp; \zeta_{v}^{\prime\prime})\)
\end{enumerate}
%
and we can obtain a complete trajectory (of \(\Nlf\) leapfrog steps) by
succesively applying the above steps.
%


\section{DNN accelerator: The Need}

The dominant computation of choice in many DNN workloads are either vector-matrix multiplication, matrix-matrix multiplication or convolution. All three operations have high data-parallelism in general and systolic arrays is a better fit for such accelerators. Figure \ref{fig:conv} gives an example and Figure \ref{fig:convcode} is the 7 dimensional loop that represents a convolution.

\begin{figure}[h]
    \centering
    \begin{subfigure}{0.5\textwidth}
        \centering
        \includegraphics[width=\linewidth]{images/convEx.png}
        \caption{Convolution Operation}
        \label{fig:conv}
    \end{subfigure}%
    \begin{subfigure}{0.5\textwidth}
        \centering
        \includegraphics[width=\linewidth]{images/convCode.png}
        \caption{7D convolution code (Courtesy: CS6886 Slides)}
        \label{fig:convcode}
    \end{subfigure}

\end{figure}

% \begin{figure}[h]
%     \centering
%     \includegraphics[scale=0.5]{images/convEx.png}
%     \caption{Convolution Operation}
%     \label{fig:conv}
% \end{figure}

% \begin{figure}[h]
%     \centering
%     \includegraphics[scale=0.5]{images/convCode.png}
%     \caption{7D convolution code (Courtesy: CS6886 Slides)}
%     \label{fig:convcode}
% \end{figure}

%\section{What's and Why's of Systolic Arrays}
%This question is best answered by the seminal paper from HT Kung and the modern Tensor Processing Unit (TPU).


\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{amsmath,amssymb,amsthm}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{corollary}{Corollary}[theorem]
\newtheorem{lemma}[theorem]{Lemma}
\title{Mathematics Handout - Logaritmics}
\author{Daniel Frederico Lins Leite}
\date{July 2016}
\begin{document}
\section{Introduction}
\maketitle
\begin{proof}{Exp is continuous}
\[x^l = A => log_x A = l\]
\[x^m = B => log_x B = m\]
\[x^n = A*B => log_x(A*B) = n\]
\[x^n = x^l*x^m\]
\[x^n = x^(l+m)\]
Given that power in bijective and onto *
\[n = l+m\]
\[log_x (A*B) = log_x A + log_x B\]
\end{proof}
\begin{proof}{Logarithm Division Rule}
\[x^l = A => log_x A = l\]
\[x^m = B => log_x B = m\]
\[x^n = A/B => log_x(A/B) = n\]
\[x^n = (x^l)/(x^m)\]
\[x^n = x^l*x^(-m)\]
Given that power in bijective and onto *
\[n=l-m\]
\[log_x (A/B) = log_x A - log_x B\]
\end{proof}
\begin{proof}{Logarithm Division Rule}
\[log_x A = B => x^B = A\]
First multiply the left side for c
\[C*(log_x A) = C*B\]
Now  raise the right side to C
\[(x^B)^C =  A^C\]
Given the Power rule
\[x^(B*C) = A^C\]
We can write this expression as log as
\[log_x (A^C) = B*C\]
Which give use
\[log_x (A^C) = C*(log_x A)\]
\end{proof}
\end{document}


\documentclass[]{article}
\usepackage{amssymb,amsmath}
\usepackage{html}
\begin{document}
\section{Complete Elliptic Integrals of First, Second, and Third
Kind}
Function subprograms \texttt{RELI1C}, \texttt{RELI2C}, \texttt{RELI3C}
and \texttt{DELI1C}, \texttt{DELI2C}, \texttt{DELI3C} calculate
the complete elliptic integrals of the first, second and
third kind, respectively.

Function subprograms \texttt{RELIGC} and \texttt{DELIGC} calculate a general
complete elliptic integral.

Function subprograms \texttt{RELIKC}, \texttt{RELIEC} and \texttt{DELIKC},
\texttt{DELIEC} calculate the complete elliptic integrals K$(k)$ and
E$(k)$.

On CDC and Cray computers, the double-precision versions \texttt{DELI1C}
etc. are not available.

Mainly for reasons of numerical stability, the algorithms are based on
the following definitions:

\textbf{First kind:}
\begin{eqnarray*}
\mathbf{F}_1^*(k') \ = \  \displaystyle
\int_0^\infty \frac{d\xi}{\sqrt{(1+\xi^2)(1+{k'}^2\xi^2)}}
\qquad ({k'}^2 > 0).
\end{eqnarray*}
\textbf{Second kind:}
\begin{eqnarray*}
\mathbf{F}_2^*(k',a,b) \ = \ \displaystyle
\int_0^\infty \frac{a+b\xi^2}{(1+\xi^2)\sqrt{(1+\xi^2)(1+{k'}^2\xi^2)}}
\, d\xi \qquad ({k'}^2 > 0).
\end{eqnarray*}
\textbf{Third kind:}
\begin{eqnarray*}
\mathbf{F}_3^*(k',p) \ = \ \displaystyle
\int_0^\infty \frac{1+\xi^2}{(1+p\xi^2)\sqrt{(1+\xi^2)(1+{k'}^2\xi^2)}}
\, d\xi \qquad ({k'}^2 > 0, \ p \ne 0).
\end{eqnarray*}

Note that $\mathbf{F}_1^*(k') = \mathbf{F}_2^*(k',1,1) =
\mathbf{F}_3^*(k',1)$. For $p < 0$, the integral $\mathbf{F}_3^*$ is
defined by its principal value.

\textbf{The general integral:}
\begin{eqnarray*}
\mathbf{G}(k',p,a,b) & = & \displaystyle
\int_0^\infty \frac{a+b\xi^2}{(1+p\xi^2)\sqrt{(1+\xi^2)(1+{k'}^2\xi^2)}}
\, d\xi  \\[3mm]
& = & \displaystyle \int_0^{\pi/2} \frac{a \cos^2 \phi + b \sin^2 \phi}
{\cos^2 \phi + p \sin^2 \phi} \frac{d\phi}
{\sqrt{\cos^2 \phi + {k'}^2 \sin^2 \phi}} \qquad ({k'}^2 > 0).
\end{eqnarray*}
For $p < 0$, this integral is defined by its principal value.
See \textbf{Notes} for special cases.

\textbf{The functions K(k) and E(k):}
\begin{eqnarray*}
\mathrm{K}(k) & = & \displaystyle \int_0^{\pi/2}
\frac{d\psi}{\sqrt{1-k^2\sin^2 \psi}} \qquad (|k| < 1), \\
\mathrm{E}(k) & = & \displaystyle \int_0^{\pi/2}
\sqrt{1-k^2\sin^2 \psi} \, d\psi \qquad (|k| \le 1).
\end{eqnarray*}
\newpage
Other common definitions of the complete elliptic integrals and their
relations to $\mathbf{F}_1^*$, $\mathbf{F}_2^*$, $\mathbf{F}_3^*$ are
listed here for convenience ($k^2+{k'}^2 = 1$): \\[2mm]
\textbf{First kind:}
$$ \begin{array}{rcl}
F(k,\pi/2) & = & \mathrm{K}(k) \quad = \quad \mathbf{F}_1^*(k') \qquad
(|k| < 1), \\[6mm]
\widehat{F}(1,k) & = & \displaystyle \int_0^1
\frac{d\eta}{\sqrt{(1-\eta^2)(1-k^2\eta^2)}} \quad = \quad
\mathbf{F}_1^*(k') \qquad (|k| < 1).
\end{array} $$
\textbf{Second kind:}
$$ \begin{array}{rcl}
E(k,\pi/2) & = & \mathrm{E}(k) \quad = \quad \mathbf{F}_2^*(k',1,{k'}^2)
\qquad (|k| \le 1), \\[6mm]
\widehat{E}(1,k) & = & \displaystyle \int_0^1
\sqrt{\frac{1-k^2 \eta^2}{1-\eta^2}} \, d\eta \quad = \quad
\mathbf{F}_2^*(k',1,{k'}^2) \qquad (|k| \le 1).
\end{array} $$
\textbf{Third kind:}
$$ \begin{array}{rclcl}
\Pi(\pi/2,h,k) & = & \displaystyle \int_0^{\pi/2}
\frac{d\psi}{(1+h\sin^2 \psi)\sqrt{1-k^2\sin^2 \psi}} & = &
\mathbf{F}_3^*(k',h+1) \qquad (|k| < 1), \\[6mm]
\widehat{\Pi}(1,h,k) & = & \displaystyle \int_0^1
\frac{d\eta}{(1+h\eta^2)\sqrt{(1-\eta^2)(1-k^2\eta^2)}} & = &
\mathbf{F}_3^*(k',h+1) \qquad (|k| < 1).
\end{array} $$
\subsection{Structure}
\texttt{FUNCTION} subprograms \\
User Entry Names:
\begin{htmlonly}
\begin{tabular}{llllll}
\end{htmlonly}
%begin{latexonly}
\begin{tabular}[t]{l*{5}{@{\hspace{4pt}}l}}
%end{latexonly}
\texttt{RELI1C}, & \texttt{RELI2C}, & \texttt{RELI3C}, & \texttt{RELIGC}, &
\texttt{RELIKC}, & \texttt{RELIEC} \\
\texttt{DELI1C}, & \texttt{DELI2C}, & \texttt{DELI3C}, & \texttt{DELIGC}, &
\texttt{DELIKC}, & \texttt{DELIEC}
\end{tabular} \\
Obsolete User Entry Names:
\begin{tabular}[t]{l@{\hspace{4pt}}l}
\texttt{ELLICK} $\equiv$ \texttt{RELIKC}, &
\texttt{ELLICE} $\equiv$ \texttt{RELIEC}, \\
\texttt{DELLIK} $\equiv$ \texttt{DELIKC}, &
\texttt{DELLIE} $\equiv$ \texttt{DELIEC}
\end{tabular} \\
Files Referenced: \texttt{Unit 6} \\
External References: \texttt{MTLMTR}{N002}, \texttt{ABEND}{Z035}
\subsection{Usage}
In any arithmetic expression, with $\mathtt{AK}=k$ and $\mathtt{AKP}=k'$,
\begin{center}
\begin{tabular}{l@{\quad or \quad}l@{\quad has the value \quad}l}
\texttt{RELI1C(AKP)} & \texttt{DELI1C(AKP)} & $\mathbf{F}_1^*(k')$,\\
\texttt{RELI2C(AKP,A,B)} & \texttt{DELI2C(AKP,A,B)} &
$\mathbf{F}_2^*(k',\mathtt{A,B})$,\\
\texttt{RELI3C(AKP,AK2,P)} & \texttt{DELI3C(AKP,AK2,P)} &
$\mathbf{F}_3^*(k',\mathtt{P})$, \\
\texttt{RELIGC(AKP,P,A,B)} & \texttt{DELIGC(AKP,P,A,B)} &
$\mathbf{G}(k',\mathtt{P,A,B})$, \\
\texttt{RELIKC(AK)} & \texttt{DELIKC(AK)} & K$(k)$, \\
\texttt{RELIEC(AK)} & \texttt{DELIEC(AK)} & E$(k)$,
\end{tabular}
\end{center}
where \texttt{RELI1C} etc are of type \texttt{REAL}, \texttt{DELI1C} etc are of
type \texttt{DOUBLE PRECISION}, and \texttt{AKP}, \texttt{AK}, \texttt{AK2}, \texttt{A},
\texttt{B} and \texttt{P} have the same type as the function name.

The redundant parameter \texttt{AK2} in \texttt{RELI3C} and \texttt{DELI3C}
permits improved accuracy when $k^2$ is small, i.e. $k' \approx 1$. In
this case, $\mathtt{AK2} = k^2$ should be calculated using
higher-precision arithmetic and then truncated before calling the
subprogram.
\newpage
\subsection{Method}
The evaluation of $\mathbf{F}_1^*$, $\mathbf{F}_2^*$, $\mathbf{F}_3^*$
is based on the Landen transformation, that of $\mathbf{G}$ on the Bartky
transformation. For details, see Ref. 1--3. For K$(k)$ and E$(k)$
Chebyshev approximations are used (see Ref. 4).
\subsection{Accuracy}
The \texttt{REAL} functions (except on CDC and Cray computers) have full
single-precision accuracy. The \texttt{REAL} functions on CDC and Cray, and
the \texttt{DOUBLE PRECISION} functions on all computers have an accuracy
approximately two significant digits less than the machine precision.
\subsection{Restrict}
1. \quad \texttt{RELI1C} and \texttt{DELI1C:} \ $\mathtt{AKP \ne 0}$. \\
2. \quad \texttt{RELI2C} and \texttt{DELI2C:} \ $\mathtt{AKP \ne 0}$
or $\mathtt{AKP = 0}$ and $\mathtt{B = 0}$. \\
3. \quad \texttt{RELI3C} and \texttt{DELI3C:} \ \texttt{AKP*P $\ne$ 0}. \\
4. \quad \texttt{RELIGC} and \texttt{DELIGC:} \ $\mathtt{AKP \ne 0}$. \\
5. \quad \texttt{RELIKC} and \texttt{DELIKC:} \ $\mathtt{|AK| \le 1}$, \qquad
\texttt{RELIEC} and \texttt{DELIEC:} \ $\mathtt{|AK| < 1}$. \\
\subsection{Error messages}
Error \texttt{C347.1:} Restriction 1 is not satisfied. \\
Error \texttt{C347.2:} Restriction 2 is not satisfied. \\
Error \texttt{C347.3:} Restriction 3 is not satisfied. \\
Error \texttt{C347.4:} Restriction 4 is not satisfied. \\
Error \texttt{C347.5:} Restriction 5 is not satisfied. \\
In all cases, the function value
is set equal to zero, and a message is written on \texttt{Unit 6},
unless subroutine \texttt{MTLSET} (N002) has been called.
\subsection{Notes}
Every linear combination of the three special complete elliptic
integrals K$(k)$, E$(k)$, $\Pi(h,k)$ may be expressed in terms of
$\mathbf{G}(k',p,a,b)$:
$$\begin{array}{rcl}
\lambda \mathrm{K}(k) + \mu \mathrm{E}(k) & = &
\mathbf{G}(k',1,\lambda+\mu,\lambda+\mu {k'}^2) \\
\lambda \mathrm{K}(k) + \mu \Pi(h,k) & = &
\mathbf{G}(k',h+1,\lambda+\mu,\lambda (h+1)+\mu)
\end{array} $$
Special examples are
$$\begin{array}{rcl}
\mathrm{K}(k)                           & = & \mathbf{G}(k',1,1,1), \\
\mathrm{E}(k)                           & = & \mathbf{G}(k',1,1,{k'}^2)\\
(\mathrm{K}(k)-\mathrm{E}(k))/k^2       & = & \mathbf{G}(k',1,0,1), \\
(\mathrm{K}(k)-{k'}^2\mathrm{E}(k))/k^2 & = & \mathbf{G}(k',1,1,0), \\
\Pi(h,k)                                & = & \mathbf{G}(k',h+1,1,1),\\
(\mathrm{K}(k)-\Pi(h,k))/h              & = & \mathbf{G}(k',h+1,0,1),\\
\end{array} $$
If $ab \ge 0$ then $\mathbf{G}$ will evaluate any linear
combination of K$(k)$, E$(k)$, $\Pi(h,k)$ without cancellation
(such as would occur, for example, if (K$(k)-$E$(k))/k^2$ were to be
computed from values of K$(k)$ and E$(k)$ which had been computed
separately.

Other functions which can be represented by $\mathbf{G}$ are the Jacobian
Zeta function $\mathbf{Z}(\Phi,k)$ and the Heuman Lambda function
$\Lambda_0(\Phi,k)$ (see Ref. 5):
$$\begin{array}{rcl@{\qquad}l}
\mathbf{Z}(\Phi,k) & = & \displaystyle k^2 \,
\frac{\sin \Phi \cos \Phi}{\mathrm{K}(k)} \, \mathbf{G}(k',q,0,\sqrt{q})
& (q = \cos^2 \Phi + {k'}^2 \sin^2 \Phi) \\[4mm]
\Lambda_0(\Phi,k) & = & \displaystyle \frac{2}{\pi}
\sqrt{q} \sin \Phi \ \mathbf{G}(k',q,1,{k'}^2) &
(q = 1 + k^2 \tan^2 \Phi).
\end{array} $$
\emph{(Quoted from Ref. 3, slightly modified)}.\\
\newpage
\subsection{Source}
The subprograms for $\mathbf{F}_1^*$, $\mathbf{F}_2^*$ are based on the
Algol60 procedures \emph{cel1, cel2} in Ref. 1, those for
$\mathbf{F}_3^*$ on \emph{cel3} in Ref. 2, and those for $\mathbf{G}$
on \emph{cel} in Ref. 3.
\subsection{References}
\begin{enumerate}
\item R. Bulirsch, Numerical calculation of elliptic integrals and
elliptic functions, Numer. Math. \textbf{7} (1965) 78--90.
\item R. Bulirsch, Numerical calculation of elliptic integrals and
elliptic functions II, Numer. Math. \textbf{7} (1965) 353--354.
\item R. Bulirsch, Numerical calculation of elliptic integrals and
elliptic functions III, Numer. Math. \textbf{13} (1969) 305--315.
\item W.J. Cody, Chebyshev approximations for the complete elliptic
integrals $K$ and $E$, Math. Comp. \textbf{19} (1965) 105--112.
\item P.F. Byrd and M.D. Friedman, Handbook of elliptic integrals
for engineers and scientists, 2nd ed., Springer-Verlag Berlin (1971)
33--37.
\end{enumerate}
$\bullet$
\end{document}


%!TEX output_directory = <<temp>>
%!TEX copy_output_on_build = true

\documentclass[11pt]{article}

\usepackage[utf8]{inputenc}

\usepackage{amsmath}		% lets you input equations in math mode
\usepackage{graphicx}		% lets you include images
\usepackage{enumerate}		% lets you make lists
\usepackage{hyperref}		% lets you make links
\usepackage{subcaption}     % if you want to use subcaptions
\usepackage[all]{hypcap}	% makes links refer to figures and not captions
\usepackage{relsize}		% lets you use relative font sizes
\usepackage{caption}        % lets you add captions
\usepackage{array}          % lets you specify table column widths
\usepackage{float}
\usepackage{array}
\usepackage{cellspace}
\usepackage[margin=1in, paperwidth=8.5in, paperheight=11in]{geometry} %
\usepackage{xcolor}
\usepackage{natbib}
\usepackage{bibtopic}

\setlength\cellspacebottomlimit{8pt}
\newcommand\cincludegraphics[2][]{\raisebox{-.3\height}{\includegraphics[#1]{#2}}}

% place graphics in ./img/
\graphicspath{ {img/} }

\begin{document}

\title{Numerical Solver for Airflow}
\author{Bogdan Vitoc \\ William Fairman \\ Chris Lather}
% \date{date here} % leave this commented to display the current date
\maketitle

\begin{abstract}
   In this project, we apply concepts from vector calculus to find the airflow around any 2-dimensional shape. We make the assumptions that air is an incompressible and irrotational fluid in order to reduce the scope of our project while maintaining a realistic outcome for subsonic air speeds. We use the relaxation algorithm to solve Laplace's equation and ghost points to enforce a Neumann boundary condition at our surface boundary. We succeeded in producing vector-plots and animations visualizing the air velocity around an object.
\end{abstract}

\section{The Velocity Field}
Our velocity field ($\vec{V}$) consists of a fluid and an impermeable region for the fluid to flow around. In order to compute ($\vec{V}$), we have to implement a set of governing equations that produce favorable characteristics. In our case, we decided to make the velocity field irrotational and incompressible by implementing the following equations.

\begin{align}
    \nabla \times \vec{V} = 0 \label{nocurl} \\
    \nabla \cdot \vec{V} = 0 \label{nodiv}
\end{align}

By setting the curl of $\vec{V}$ to 0 (Eq. \ref{nocurl}), $\vec{V}$ is now considered path-independent and can be referred to as the gradient of a potential field. This potential field is known as the velocity potential field and is referred to as $\Phi$. If the divergence of $\vec{V}$ is also equal to 0 (Eq. \ref{nodiv}), then we can claim that $\Phi$ is a minimal surface defined by Laplace's equation

\begin{align}
    \nabla^2 \Phi = 0
\end{align}

In this case our velocity potential is now a scalar field that represents the minimal amount of energy across the system: allowing the gradient of such a field to accurately represent fluid flow.

%%This section needs more explanation
%%Include paragraph about why this is true. Characteristics fo minial surface, %%trade-off of our assumptions

\section{Relaxation Method}
The numerical solution to solve the Laplacian of a scalar field can be found through various algorithms. One of the most simple ways to solve the Laplacian is to set each point in the field equal to an average of it's neighbors. This method, known as relaxation, is an iterative approach to finding the Laplacian and fully solves the equation at $\text{time} = \infty$. For our velocity potential field, the value for each discrete fluid point is equal to

\begin{align}
 \Phi_{i,j} = \frac{\Phi_{i-1,j} + \Phi_{i,j-1} + \Phi_{i,j+1} +\Phi_{i+1,j} }{4}
\end{align}

\section{Surface Condition}
The above equations are able to satisfy the conditions for airflow outside the boundary of our object. However, we must add one more parameter to our solution to account for the airflow at the surface of our boundary. For these models, air does not flow through the object. In order to prevent airflow through an object, we must define the $\vec{V}$ to be tangent to the surface of the object. This is true when the dot product between the velocity vector and normal vector of the surface is equal to 0.

\begin{figure} [H] % H: forces layout according to position in the source
	\centering
	\includegraphics[width=0.5\textwidth]{lin_surface_condition.png}
	\captionsetup{margin={0.2\textwidth,0.2\textwidth}}
	\caption{Our simulation is considered realistic when the fluid velocity at the surface is anti-parallel to the normal vector at the surface.}
	%\caption*{\small (Egestas Justo Commodo)}
	\label{components}
\end{figure}

$\vec{V}$ can be re-written as the gradient of $\Phi$ and the equation can be reduced to

\begin{align}
    \text{grad}(\Phi) \cdot \hat{\textbf{n}} = 0
\end{align}

In order to make this condition true, we must set discrete points within the surface to a value that will eventually remove any perpendicular components of airflow when the relaxation method is applied to the surface points. The internal points that are manipulated to satisfy the surface condition are called ghost points.

\begin{figure} [H] % H: forces layout according to position in the source
	\centering
	\includegraphics[width=0.4\textwidth]{lin_ghost.png}
	\captionsetup{margin={0.2\textwidth,0.2\textwidth}}
	\caption{A visualization of ghost points and fluid points bordering a surface. The continuous surface does not need to pass through a point in the numerical grid. Any point located directly on the surface would be classified as a fluid point.}
	%\caption*{\small (Egestas Justo Commodo)}
\end{figure}

\section{Ghost Points}
In order for a ghost point to affect a fluid point, the ghost point must touch the fluid point along one of its cardinal sides (North, South, East, West). Flipping this logic around gives us the conditions for selecting our ghost points. If a point internal to the surface comes into contact with a fluid point along one of its cardinal sides, that internal point is a ghost point because it has the ability to make the boundary condition true.

\subsection{Setting Values}
To find the appropriate value for a ghost point, we must take a closer look at the boundary condition for $\vec{V}$.

\begin{align}
    \text{grad}(\Phi) \cdot \hat{\textbf{n}} = 0 \\
    \begin{bmatrix} \frac{\partial\Phi}{\partial x} \\[6pt] \frac{\partial\Phi}{\partial y} \end{bmatrix}
    \cdot
    \begin{bmatrix} X_n \\  Y_n \end{bmatrix} = 0
\end{align}

If we choose our surface to be a straight horizontal line, the normal vector can be reduced to:
\begin{align}
    \begin{bmatrix} X_n \\  Y_n \end{bmatrix}
    =
    \begin{bmatrix} 0 \\  1 \end{bmatrix}
\end{align}

This allows us to further refine our boundary condition:
\begin{align}
    \text{grad}(\Phi) \cdot \hat{\textbf{n}} = 0 \\
    \begin{bmatrix} \frac{\partial\Phi}{\partial x} \\[6pt] \frac{\partial\Phi}{\partial y} \end{bmatrix}
    \cdot
    \begin{bmatrix} 0 \\  1 \end{bmatrix}  = 0 \\
    \frac{\partial\Phi}{\partial y} = 0
\end{align}

When we implement a discrete representation of $\frac{d\Phi}{dy}$,we can now claim that:
\begin{align}
    \frac{\partial\Phi}{\partial y} &= \frac{\Phi_{i,j+1} - \Phi_{i,j-1}}{2} = 0 \\
    \Phi_{i,j-1} &= \Phi_{i,j+1}
\end{align}
The value of each ghost point is selected by copying the value of a point mirrored directly across the surface, called the mirror point. If we make the ghost point equal to its mirrored fluid point, the normal component of the gradient between the two values of $\Phi$ will be 0, satisfying the boundary condition. Conceptually, by setting an inner ring of ghost points equal to an outer ring of fluid points, we can guarantee the slope across the surface to be tangential (Fig. \ref{components}).

\begin{figure} [H] % H: forces layout according to position in the source
	\centering

	\includegraphics[width=0.6\textwidth]{lin_graphic.png}
	\captionsetup{margin={0.2\textwidth,0.2\textwidth}}
	\caption{Setting the ghost point equal to the value of its mirrored fluid point will satisfy the boundary condition.}
	%\caption*{\small (Egestas Justo Commodo)}
\end{figure}

%%Add image
However, in a discrete setting, the number of ghost points will always be less than the number of exterior fluid points because the perimeter of the fluid points coming into contact with the surface is larger than the perimeter of ghost points (at least on a surface without concavities).

\begin{figure} [H] % H: forces layout according to position in the source
	\centering

	\includegraphics[width=0.40\textwidth]{lin_graphic_2.png}
	\captionsetup{margin={0.2\textwidth,0.2\textwidth}}
	\caption{The perimeter of fluid and ghost points is represented by two rings with discrete points equally spaced along both rings. The number of fluid points is larger than the number of ghost points}
	%\caption*{\small (Egestas Justo Commodo)}
\end{figure}

This inequality makes it difficult to find a fluid point that is a direct mirror of each ghost point. However, if we make the ghost points equal to a \textit{set} of fluid points nearby, we can force that area to be approximately equipotential.

\subsection{Stencil Average}
To approximate the value of our ghost points, we decided to equate each ghost point to the average value of all the fluid points it touches in a 25-point stencil. Other mirroring techniques are discussed in \cite{lekven2017verification}

\begin{figure} [H] % H: forces layout according to position in the source
	\centering

	\includegraphics[width=0.4\textwidth]{lin_ghost_stencil.png}
	\captionsetup{margin={0.2\textwidth,0.2\textwidth}}
	\caption{Each ghost point mirrored from an average of its surrounding fluid points. One might accurately assume a 9-point stencil to be more reasonable. The 25-point average is an artifact of a flawed POV.}
	%\caption*{\small (Egestas Justo Commodo)}
\end{figure}

\subsection{Initial Conditions}
We need an exterior airflow to give our surface something to disrupt. We create this fluid flow by enforcing Dirichlet boundary conditions on all sides of our field. Since we want the air to be flowing to the right, the left side holds a positive velocity potential while the right side is held at 0. The top and bottom must be held at some value since the relaxation method does not work at a boundary. We choose to hold the top and bottom at zero as well.

\begin{figure} [H] % H: forces layout according to position in the source
	\centering
	\includegraphics[width=0.4\textwidth]{initial_flow.png}
	\captionsetup{margin={0.2\textwidth,0.2\textwidth}}
	\caption{Initial air flow (e.g. from wind).}
	%\caption*{\small (Egestas Justo Commodo)}
\end{figure}

This does result in a non-parallel airflow most noticeably near the top and bottom. To counteract this effect we made our fluid domain very tall relative to our object. Alternatively the top and bottom sides could be given the same boundary condition as the shape, enforcing a parallel airflow, as if in a wind tunnel. Not only would this increase accuracy, but it would bring big savings in computation time.

\section{Results}
We decided to setup our simulation environment in Matlab over Mathematica due to its heightened abilities to handle numerical calculations. In order to take advantage of our numerical solver's ability to work for almost any surface, we needed an easy way to define and import complex surfaces. Our final program can convert black and white images into a discrete surface.

Our initial proof of concept was to model the airflow around an ellipse. The velocity potential field ($\Phi$) is shown below:

\begin{figure} [H] % H: forces layout according to position in the source
	\centering
	\includegraphics[width=0.5\textwidth]{flow.png}
	\captionsetup{margin={0.2\textwidth,0.2\textwidth}}
	\caption{Velocity potential around an ellipse.}
	%\caption*{\small (Egestas Justo Commodo)}
\end{figure}
In this example, $\Phi$ is represented as a color range between bright yellow and purple: where yellow is an area of high potential and purple is an area of low potential. The outline of our object can be seen as an area of low potential because the internal points of the object are set to 0.

The velocity vector $\vec{V}=\nabla\cdot\Phi$  can be shown when taking the gradient of the field.
\begin{figure} [H] % H: forces layout according to position in the source
	\centering
	\includegraphics[width=0.5\textwidth]{flow_vec.png}
	\captionsetup{margin={0.2\textwidth,0.2\textwidth}}
	\caption{Vector field representing the gradient of the velocity potential field.}
\end{figure}
While the figure shows an accurate representation of airflow, the airflow as a whole is hard to visualize due to the size of the vector arrows. After modifying our code, we settled on representing airflow as a stream-line plot with $\Phi$ overlaid in the background.

\subsection{Airflow Graphics}
Below is a selection of figures that reflect the ability of our code to parse a black and white image and calculate the accompanying airflow. Each image has an accompanying video that can be found here: \href{https://drive.google.com/drive/folders/1YatS7map3rJvWgA_mO1nS_kQ8kbgIf8t}{https://drive.google.com/drive/folders/1YatS7map3rJvWgA\_mO1nS\_kQ8kbgIf8t}

\begin{figure} [H] % H: forces layout according to position in the source
	\centering
	\includegraphics[width=0.6\textwidth]{airfoil.png}
	\captionsetup{margin={0.2\textwidth,0.2\textwidth}}
	\caption{Airflow around an airfoil.}
	%\caption*{\small (Egestas Justo Commodo)}
\end{figure}

\begin{figure} [H] % H: forces layout according to position in the source
	\centering
	\includegraphics[width=0.6\textwidth]{arrowhead.png}
	\captionsetup{margin={0.2\textwidth,0.2\textwidth}}
	\caption{Airflow around an arrowhead.}
	%\caption*{\small (Egestas Justo Commodo)}
\end{figure}

\begin{figure} [H] % H: forces layout according to position in the source
	\centering
	\includegraphics[width=0.6\textwidth]{swallow.png}
	\captionsetup{margin={0.2\textwidth,0.2\textwidth}}
	\caption{Airflow around an African Swallow carrying a coconut.}
	%\caption*{\small (Egestas Justo Commodo)}
\end{figure}

\begin{btSect}[abbrvnat]{references}
   \section*{References}
   \btPrintCited
\end{btSect}

\begin{btSect}[plainnat]{supplementary}
   \section*{Further Reading}
   \btPrintAll%  see manual for alternatives...
\end{btSect}

\end{document}


\chapter{Assignment: Feature Selection}
\label{hw:feature-selection}

\newthought{It is important to understand which features are relevant for the model.} But different scoring methods estimate feature importance differently. We got to know some univariate and some (?) multivariate methods. This time we have 40 rodents, some of which are sick and some which are healthy. Which animals are sick?

\marginnote{To load the hamsters and rabbits data set copy and paste the below URL to the URL field of the File widget.
\break\break
\url{https://docs.google.com/spreadsheets/d/1cWc0DANnmAQZkbCgIivI9F1SNg13GWys-9SheZzDYoI/edit?usp=sharing}
\break\break
Set \textit{disease} as the target variable in the File widget.
}

\begin{figure}[h]
  \centering
  \includegraphics[scale=0.7]{feature-selection-workflow.png}%
  \caption{$\;$}
  \label{fig:wf1}
\end{figure}

\begin{enumerate}
    \item Use Rank widget to determine which features are important for predicting sick animals. Which feature(s) is the most important? Do not forget to check several scoring methods. Why are they different?
    \item Which scoring method will you use here? Can you explain why? Mosaic Display will help you answer the question.
    \item Now use this data set to predict the disease. Which model performs best? Why?
    \item How would the model perform on new data? Use Google Sheet to create a few more rodents with the same characteristics as above to test the model.
\end{enumerate}


%!TEX root = ../thesis.tex

\chapter{Third chapter}

In mathematics, a field is a set on which addition, subtraction, multiplication, and division are defined and behave as the corresponding operations on rational and real numbers do. A field is thus a fundamental algebraic structure which is widely used in algebra, number theory, and many other areas of mathematics.

The best known fields are the field of rational numbers, the field of real numbers and the field of complex numbers. Many other fields, such as fields of rational functions, algebraic function fields, algebraic number fields, and p-adic fields are commonly used and studied in mathematics, particularly in number theory and algebraic geometry. Most cryptographic protocols rely on finite fields, i.e., fields with finitely many elements.

The relation of two fields is expressed by the notion of a field extension. Galois theory, initiated by Évariste Galois in the 1830s, is devoted to understanding the symmetries of field extensions. Among other results, this theory shows that angle trisection and squaring the circle cannot be done with a compass and straightedge. Moreover, it shows that quintic equations are algebraically unsolvable.

Fields serve as foundational notions in several mathematical domains. This includes different branches of mathematical analysis, which are based on fields with additional structure. Basic theorems in analysis hinge on the structural properties of the field of real numbers. Most importantly for algebraic purposes, any field may be used as the scalars for a vector space, which is the standard general context for linear algebra. Number fields, the siblings of the field of rational numbers, are studied in depth in number theory. Function fields can help describe properties of geometric objects.


\subsection{Random Forest}

Random forest is an algorithm developed from decision tree. Trees that are grown very deep tend to learn highly irregular patterns: they overfit their training sets. Random forest is a way of averaging multiple deep decision trees, trained on different parts of the same training set, with the goal of reducing the variance. This comes at the expense of a small increase in the bias and some loss of interpretability, but generally greatly boosts the performance in the final model.

The major advantage of random forest is that it is robust against colinearity, and we can rank the importance of variable based on out-of-bag error\cite{breiman2001random}. As it is easy to carry out and require no data assumption, we decided to first run it to get a better idea about which variable is more vital in weather forecast.

\begin{figure}[h]
\centering
\begin{minipage}[t]{0.48\textwidth}
\centering
\includegraphics[width = .99\textwidth]{vimp.png}
\caption{Importance of Attributes}
\label{vimp}
\end{minipage}
\begin{minipage}[t]{0.48\textwidth}
\centering
\includegraphics[width = .99\textwidth]{errf.png}
\caption{Error Rate of Random Forest on Training Data}
\label{errf}
\end{minipage}
\end{figure}

As shown in Figure \ref{vimp}, the PRCP is the most important variable. This is intuitively correct as it is the most relative variable. Also we can see our feature engineering plays an important role. The TDIF (temperature difference) and other variables about wind are ranking from \engordnumber{2} to \engordnumber{6}. This give us a sense of what variable should be used in the $k$-NN, since $k$-NN prefers a lower dimension input data.

In Figure \ref{errf}, the error rate become stable when tree number is greater than 100. As the green line is the error rate of predicting days with precipitation and the red line is for days without. The model has a better ability in predicting days without precipitation. This can be numerically confirmed from the confusion matrix in Table \ref{tblrf}. The type \uppercase\expandafter{\romannumeral1} error is higher than type \uppercase\expandafter{\romannumeral2} error, which means the model makes more mistake in predicting days with precipitation. The overall test errors are shown in Table \ref{tblrf}.

Although random forest has many advantages, it still can't deal with the situation when data are not linear separable. So in that case we should try kernel SVM for the next step.

\begin{table}[h]
\setlength{\belowcaptionskip}{5pt}
\caption{Confusion Matrix and Error Rates of Random Forest}
\label{tblrf}
\centering
\renewcommand\arraystretch{1.5}
\begin{tabular}{rrrrr}
\hline
\hline
 & & \multicolumn{2}{c}{True Condition} & \\
\hline
 & & Non-Precipitation & Precipitation & \\
\cline{1-4}
\multirow{2}{*}{Prediction} & {Non-Precipitation} & 339 & 51 & \\
\cline{2-4}
&Precipitation&52&217&\\
\hline
&Error Rate & 0.1329 & 0.1902 & 0.1562\\
\cline{2-5}
& & Type \uppercase\expandafter{\romannumeral1} & Type \uppercase\expandafter{\romannumeral2} & Overall\\
\hline
\end{tabular}
\end{table}


\section{Dataset Bias Tables}
\label{app:confusion}

\begin{table}[H]
  \centering
  \begin{tabular}{l|ll}
    \multicolumn{1}{c|}{} & \multicolumn{2}{c}{\textbf{Reference}} \\
    \textbf{Prediction}   & \texttt{FALSE}       & \texttt{TRUE}   \\ \cline{2-3}
    \texttt{FALSE}        & $85855$              & $4488$          \\
    \texttt{TRUE}         &   $816$              & $1583$
  \end{tabular}
  \caption{The predictions and reference values for running 5-fold cross
    validation on the training dataset with a maximum tree depth of 4.}
  \label{app:tab:confusion1}
\end{table}

\begin{table}[H]
  \centering
  \begin{tabular}{l|ll}
    \multicolumn{1}{c|}{} & \multicolumn{2}{c}{\textbf{Reference}} \\
    \textbf{Prediction}   & \texttt{FALSE}       & \texttt{TRUE}   \\ \cline{2-3}
    \texttt{FALSE}        & $85941$              & $4570$          \\
    \texttt{TRUE}         &   $729$              & $1501$
  \end{tabular}
  \caption{The predictions and reference values for running 5-fold cross
    validation on the training dataset with a maximum tree depth of 6.}
  \label{app:tab:confusion2}
\end{table}

\begin{table}[H]
  \centering
  \begin{tabular}{l|ll}
    \multicolumn{1}{c|}{} & \multicolumn{2}{c}{\textbf{Reference}} \\
    \textbf{Prediction}   & \texttt{FALSE}       & \texttt{TRUE}   \\ \cline{2-3}
    \texttt{FALSE}        & $85914$              & $4507$          \\
    \texttt{TRUE}         &   $757$              & $1564$
  \end{tabular}
  \caption{The predictions and reference values for running 5-fold cross
    validation on the training dataset with a maximum tree depth of 8.}
  \label{app:tab:confusion3}
\end{table}

\begin{table}[H]
  \centering
  \begin{tabular}{l|ll}
    \multicolumn{1}{c|}{} & \multicolumn{2}{c}{\textbf{Reference}} \\
    \textbf{Prediction}   & \texttt{FALSE}       & \texttt{TRUE}   \\ \cline{2-3}
    \texttt{FALSE}        & $5143$               & $1297$          \\
    \texttt{TRUE}         &  $928$               & $4774$
  \end{tabular}
  \caption{The predictions and reference values for running 5-fold cross
    validation on the training dataset with a maximum tree depth of 4. This is
    using a dataset with the same number of retained an unretained observations.}
  \label{app:tab:confusion11}
\end{table}

\begin{table}[H]
  \centering
  \begin{tabular}{l|ll}
    \multicolumn{1}{c|}{} & \multicolumn{2}{c}{\textbf{Reference}} \\
    \textbf{Prediction}   & \texttt{FALSE}       & \texttt{TRUE}   \\ \cline{2-3}
    \texttt{FALSE}        & $5042$               & $1162$          \\
    \texttt{TRUE}         & $1029$               & $4909$
  \end{tabular}
  \caption{The predictions and reference values for running 5-fold cross
    validation on the training dataset with a maximum tree depth of 6. This is
    using a dataset with the same number of retained an unretained observations.}
  \label{app:tab:confusion22}
\end{table}

\begin{table}[H]
  \centering
  \begin{tabular}{l|ll}
    \multicolumn{1}{c|}{} & \multicolumn{2}{c}{\textbf{Reference}} \\
    \textbf{Prediction}   & \texttt{FALSE}       & \texttt{TRUE}   \\ \cline{2-3}
    \texttt{FALSE}        & $5053$               & $1174$          \\
    \texttt{TRUE}         & $1018$               & $4897$
  \end{tabular}
  \caption{The predictions and reference values for running 5-fold cross
    validation on the training dataset with a maximum tree depth of 8. This is
    using a dataset with the same number of retained an unretained observations.}
  \label{app:tab:confusion33}
\end{table}


\chapter{Counter-examples about funcoids and reloids}

For further examples we will use the filter defined by the formula
\[
\Delta=\bigsqcap^{\mathscr{F}(\mathbb{R})}\setcond{\mathopen]-\epsilon;\epsilon\mathclose[}{\epsilon\in\mathbb{R},\epsilon>0}.
\]
I will denote $\Omega(A)$ the Fr\'echet filter on a set $A$.
\begin{example}\label{fcd-not-infdist}
There exist a funcoid $f$ and a set $S$ of funcoids such that $f\sqcap\bigsqcup S\neq\bigsqcup\rsupfun{f\sqcap}S$.\end{example}
\begin{proof}
Let $f=\Delta\times^{\mathsf{FCD}}\uparrow^{\mathscr{F}(\mathbb{R})}\{0\}$
and $S=\setcond{\uparrow^{\mathsf{FCD}(\mathbb{R},\mathbb{R})}(]\epsilon;+\infty[\times\{0\})}{\epsilon\in\mathbb{R},\epsilon>0}$.
Then
\begin{multline*}
f\sqcap\bigsqcup S=(\Delta\times^{\mathsf{FCD}}\uparrow^{\mathscr{F}(\mathbb{R})}\{0\})\sqcap\uparrow^{\mathsf{FCD}(\mathbb{R},\mathbb{R})}(]0;+\infty[\times\{0\})=\\
(\Delta\sqcap\uparrow^{\mathscr{F}(\mathbb{R})}]0;+\infty[)\times^{\mathsf{FCD}}\uparrow^{\mathscr{F}(\mathbb{R})}\{0\}\ne\bot^{\mathsf{FCD}(\mathbb{R},\mathbb{R})}
\end{multline*}
while $\bigsqcup\rsupfun{f\sqcap}S=\bigsqcup\{\bot^{\mathsf{FCD}(\mathbb{R},\mathbb{R})}\}=\bot^{\mathsf{FCD}(\mathbb{R},\mathbb{R})}$.\end{proof}
\begin{example}
There exist a set $R$ of funcoids and a funcoid $f$ such that $f\circ\bigsqcup R\neq\bigsqcup\rsupfun{f\circ}R$.\end{example}
\begin{proof}
Let $f=\Delta\times^{\mathsf{FCD}}\uparrow^{\mathscr{F}(\mathbb{R})}\{0\}$,
$R=\setcond{\uparrow^{\mathbb{R}}\{0\}\times^{\mathsf{FCD}}\uparrow^{\mathbb{R}}]\epsilon;+\infty[}{\epsilon\in\mathbb{R},\epsilon>0}$.

We have $\bigsqcup R=\uparrow^{\mathbb{R}}\{0\}\times^{\mathsf{FCD}}\uparrow^{\mathbb{R}}]0;+\infty[$;
$f\circ\bigsqcup R=\uparrow^{\mathsf{FCD}(\mathbb{R},\mathbb{R})}(\{0\}\times\{0\})\ne\bot^{\mathsf{FCD}(\mathbb{R},\mathbb{R})}$
and $\bigsqcup\rsupfun{f\circ}R=\bigsqcup\{\bot^{\mathsf{FCD}(\mathbb{R},\mathbb{R})}\}=\bot^{\mathsf{FCD}(\mathbb{R},\mathbb{R})}$.\end{proof}
\begin{example}
There exist a set $R$ of reloids and a reloid $f$ such that $f\circ\bigsqcup R\neq\bigsqcup\rsupfun{f\circ}R$.\end{example}
\begin{proof}
Let $f=\Delta\times^{\mathsf{RLD}}\uparrow^{\mathscr{F}(\mathbb{R})}\{0\}$,
$R=\setcond{\uparrow^{\mathbb{R}}\{0\}\times^{\mathsf{RLD}}\uparrow^{\mathbb{R}}]\epsilon;+\infty[}{\epsilon\in\mathbb{R},\epsilon>0}$.

We have $\bigsqcup R=\uparrow^{\mathbb{R}}\{0\}\times^{\mathsf{RLD}}\uparrow^{\mathbb{R}}]0;+\infty[$;
$f\circ\bigsqcup R=\uparrow^{\mathsf{RLD}(\mathbb{R},\mathbb{R})}(\{0\}\times\{0\})\ne\bot^{\mathsf{RLD}(\mathbb{R},\mathbb{R})}$
and $\bigsqcup\rsupfun{f\circ}R=\bigsqcup\{\bot^{\mathsf{RLD}(\mathbb{R},\mathbb{R})}\}=\bot^{\mathsf{RLD}(\mathbb{R},\mathbb{R})}$.\end{proof}
\begin{example}
There exist a set $R$ of funcoids and filters $\mathcal{X}$ and
$\mathcal{Y}$ such that
\begin{enumerate}
\item \label{count-join-rel}$\mathcal{X}\suprel{\bigsqcup R}\mathcal{Y}\land\nexists f\in R:\mathcal{X}\suprel f\mathcal{Y}$;
\item \label{count-join-fun}$\supfun{\bigsqcup R}\mathcal{X}\sqsupset\bigsqcup\setcond{\supfun f\mathcal{X}}{f\in R}$.
\end{enumerate}
\end{example}
\begin{proof}
~
\begin{widedisorder}
\item [{\ref{count-join-rel}}] Take $\mathcal{X}=\Delta$ and $\mathcal{Y}=\top^{\mathscr{F}(\mathbb{R})}$,
$R=\setcond{\uparrow^{\mathsf{FCD}(\mathbb{R},\mathbb{R})}(]\epsilon;+\infty[\times\mathbb{R})}{\epsilon\in\mathbb{R},\epsilon>0}$.
Then $\bigsqcup R=\uparrow^{\mathsf{FCD}(\mathbb{R},\mathbb{R})}(]0;+\infty[\times\mathbb{R})$.
So $\mathcal{X}\suprel{\bigsqcup R}\mathcal{Y}$ and $\forall f\in R:\lnot(\mathcal{X}\suprel f\mathcal{Y})$.
\item [{\ref{count-join-fun}}] With the same $\mathcal{X}$ and $R$ we
have $\supfun{\bigsqcup R}\mathcal{X}=\top^{\mathscr{F}(\mathbb{R})}$
and $\supfun f\mathcal{X}=\bot^{\mathscr{F}(\mathbb{R})}$ for every
$f\in R$, thus $\bigsqcup\setcond{\supfun f\mathcal{X}}{f\in R}=\bot^{\mathscr{F}(\mathbb{R})}$.
\end{widedisorder}
\end{proof}
\begin{example}
$\bigsqcup_{\mathcal{B}\in T}(\mathcal{A}\times^{\mathsf{RLD}}\mathcal{B})\ne\mathcal{A}\times^{\mathsf{RLD}}\bigsqcup T$
for some filter $\mathcal{A}$ and set of filters $T$ (with a common
base).\end{example}
\begin{proof}
Take $\mathbb{R}_{+}=\setcond{x\in\mathbb{R}}{x>0}$, $\mathcal{A}=\Delta$,
$T=\setcond{\uparrow\{x\}}{x\in\mathbb{R}_{+}}$ where $\mathord\uparrow=\mathord{\uparrow^{\mathbb{R}}}$.

$\bigsqcup T=\uparrow\mathbb{R}_{+}$; $\mathcal{A}\times^{\mathsf{RLD}}\bigsqcup T=\Delta\times^{\mathsf{RLD}}\uparrow\mathbb{R}_{+}$.

$\bigsqcup_{\mathcal{B}\in T}(\mathcal{A}\times^{\mathsf{RLD}}\mathcal{B})=\bigsqcup_{x\in\mathbb{R}_{+}}(\Delta\times^{\mathsf{RLD}}\uparrow\{x\})$.

We'll prove that $\bigsqcup_{x\in\mathbb{R}_{+}}(\Delta\times^{\mathsf{RLD}}\uparrow\{x\})\ne\Delta\times^{\mathsf{RLD}}\uparrow\mathbb{R}_{+}$.

Consider $K=\bigcup_{x\in\mathbb{R}_{+}}(\{x\}\times]-1/x;1/x[)$.

$K\in\up(\Delta\times^{\mathsf{RLD}}\uparrow\{x\})$ and thus $K\in\up\bigsqcup_{x\in\mathbb{R}_{+}}(\Delta\times^{\mathsf{RLD}}\uparrow\{x\})$
. But $K\notin\up(\Delta\times^{\mathsf{RLD}}\uparrow\mathbb{R}_{+})$.\end{proof}
\begin{thm}
For a filter $a$ we have $a\times^{\mathsf{RLD}}a\sqsubseteq1_{\Base(a)}^{\mathsf{RLD}}$
only in the case if $a=\bot^{\mathscr{F}(\Base(a))}$ or $a$ is a
trivial ultrafilter.\end{thm}
\begin{proof}
If $a\times^{\mathsf{RLD}}a\sqsubseteq1_{\Base(a)}^{\mathsf{RLD}}$
then there exists $m\in\up(a\times^{\mathsf{RLD}}a)$ such that $m\sqsubseteq1_{\Base(a)}^{\mathbf{Rel}}$.
Consequently there exist $A,B\in\up a$ such that $A\times B\sqsubseteq1_{\Base(a)}^{\mathbf{Rel}}$
what is possible only in the case when $\uparrow A=\uparrow B=a$
is trivial a ultrafilter or the least filter.\end{proof}
\begin{cor}
Reloidal product of a non-trivial atomic filter with itself is non-atomic.\end{cor}
\begin{proof}
Obviously $(a\times^{\mathsf{RLD}}a)\sqcap1_{\Base(a)}^{\mathsf{RLD}}\ne\bot^{\mathsf{RLD}}$
and $(a\times^{\mathsf{RLD}}a)\sqcap1_{\Base(a)}^{\mathsf{RLD}}\sqsubset a\times^{\mathsf{RLD}}a$.\end{proof}
\begin{example}
There exist two atomic reloids whose composition is non-atomic and
non-empty.\end{example}
\begin{proof}
Let $a$ be a non-trivial ultrafilter on $\mathbb{N}$ and $x\in\mathbb{N}$.
Then
\begin{multline*}
(a\times^{\mathsf{RLD}}\uparrow^{\mathbb{N}}\{x\})\circ(\uparrow^{\mathbb{N}}\{x\}\times^{\mathsf{RLD}}a)=\bigsqcap_{A\in a}^{\mathsf{RLD}(\mathbb{N},\mathbb{N})}((A\times\{x\})\circ(\{x\}\times A)=\\
\bigsqcap_{A\in a}^{\mathsf{RLD}(\mathbb{N},\mathbb{N})}(A\times A)=a\times^{\mathsf{RLD}}a
\end{multline*}
is non-atomic despite of $a\times^{\mathsf{RLD}}\uparrow^{\mathbb{N}}\{x\}$
and $\uparrow^{\mathbb{N}}\{x\}\times^{\mathsf{RLD}}a$ are atomic.\end{proof}
\begin{example}
There exists non-monovalued atomic reloid.\end{example}
\begin{proof}
From the previous example it follows that the atomic reloid $\uparrow^{\mathbb{N}}\{x\}\times^{\mathsf{RLD}}a$
is not monovalued.\end{proof}
\begin{example}
Non-convex reloids exist.\end{example}
\begin{proof}
Let $a$ be a non-trivial ultrafilter. Then $\id_{a}^{\mathsf{RLD}}$
is non-convex. This follows from the fact that only reloidal products
which are below $1_{\Base(a)}^{\mathsf{RLD}}$ are reloidal products
of ultrafilters and $\id_{a}^{\mathsf{RLD}}$ is not their join.\end{proof}

\begin{example}\label{fcd-comp-ent}
There exists (atomic) composable funcoids~$f$ and~$g$ such that
\[ H\in\up(g\circ f)\nRightarrow \exists F\in\up f,G\in\up g: H\sqsupseteq G\circ F. \]
\end{example}

\begin{proof}
Let $a$ be a nontrivial ultrafilter and $p$ be an arbitrary point, $f = a
\times^{\mathsf{FCD}} \{ p \}$, $g = \{ p \}
\times^{\mathsf{FCD}} a$. Then $g \circ f = a
\times^{\mathsf{FCD}} a$. Take $H = 1$. Let $F\in\up f$ and $G\in\up g$. We have $F \in \up (A_0
\times^{\mathsf{FCD}} \{ p \})$, $G \in \up (\{ p \}
\times^{\mathsf{FCD}} A_1)$ where $A_0, A_1 \in \up a$ (take $A_0=\rsupfun{F}@\{p\}$ and similarly for~$A_1$). Thus $G
\circ F \sqsupseteq A_0 \times A_1$ and so $H \notin \up (G \circ F)$.
\end{proof}

\begin{example}
$\torldin f\ne\torldout f$ for a funcoid $f$.\end{example}
\begin{proof}
Let $f=1_{\mathbb{N}}^{\mathsf{FCD}}$. Then $\torldin f=\bigsqcup_{a\in\atoms^{\mathscr{F}(\mathbb{N})}}(a\times^{\mathsf{RLD}}a)$
and $\torldout f=1_{\mathbb{N}}^{\mathsf{RLD}}$. But we have shown
above $a\times^{\mathsf{RLD}}a\nsqsubseteq1_{\mathbb{N}}^{\mathsf{RLD}}$
for non-trivial ultrafilter $a$, and so $\torldin f\nsqsubseteq\torldout f$.\end{proof}
\begin{prop}
\label{fcd-meet-frechet}$1_{\mathfrak{U}}^{\mathsf{FCD}}\sqcap\uparrow^{\mathsf{FCD}(\mathfrak{U},\mathfrak{U})}((\mathfrak{U}\times\mathfrak{U})\setminus\id_{\mathfrak{U}})=\id_{\Omega(\mathfrak{U})}^{\mathsf{FCD}}\ne\bot^{\mathsf{FCD}(\mathfrak{U},\mathfrak{U})}$
for every infinite set $\mathfrak{U}$.\end{prop}
\begin{proof}
Note that $\supfun{\id_{\Omega(\mathfrak{U})}^{\mathsf{FCD}}}\mathcal{X}=\mathcal{X}\sqcap\Omega(\mathfrak{U})$
for every filter $\mathcal{X}$ on $\mathfrak{U}$.

Let $f=1_{\mathfrak{U}}^{\mathsf{FCD}}$, $g=\uparrow^{\mathsf{FCD}(\mathfrak{U},\mathfrak{U})}((\mathfrak{U}\times\mathfrak{U})\setminus\id_{\mathfrak{U}})$.

Let $x$ be a non-trivial ultrafilter on $\mathfrak{U}$. If $X\in\up x$
then $\card X\ge2$ (In fact, $X$ is infinite but we don't need this.)
and consequently $\rsupfun gX=\top^{\mathscr{F}(\mathfrak{U})}$.
Thus $\supfun gx=\top^{\mathscr{F}(\mathfrak{U})}$. Consequently
\[
\supfun{f\sqcap g}x=\supfun fx\sqcap\supfun gx=x\sqcap\top^{\mathscr{F}(\mathfrak{U})}=x.
\]
Also $\supfun{\id_{\Omega(\mathfrak{U})}^{\mathsf{FCD}}}x=x\sqcap\Omega(\mathfrak{U})=x$.

Let now $x$ be a trivial ultrafilter. Then $\supfun fx=x$ and $\supfun gx=\top^{\mathscr{F}(\mathfrak{U})}\setminus x$.
So
\[
\supfun{f\sqcap g}x=\supfun fx\sqcap\supfun gx=x\sqcap(\top^{\mathscr{F}(\mathfrak{U})}\setminus x)=\bot^{\mathscr{F}(\mathfrak{U})}.
\]
Also $\supfun{\id_{\Omega(\mathfrak{U})}^{\mathsf{FCD}}}x=x\sqcap\Omega(\mathfrak{U})=\bot^{\mathscr{F}(\mathfrak{U})}$.

So $\supfun{f\sqcap g}x=\supfun{\id_{\Omega(\mathfrak{U})}^{\mathsf{FCD}}}x$
for every ultrafilter $x$ on $\mathfrak{U}$. Thus $f\sqcap g=\id_{\Omega(\mathfrak{U})}^{\mathsf{FCD}}$.\end{proof}
\begin{example}
There exist binary relations $f$ and $g$ such that $\uparrow^{\mathsf{FCD}(A,B)}f\sqcap\uparrow^{\mathsf{FCD}(A,B)}g\ne\uparrow^{\mathsf{FCD}(A,B)}(f\cap g)$
for some sets $A$, $B$ such that $f,g\subseteq A\times B$.\end{example}
\begin{proof}
From the proposition above.\end{proof}
\begin{example}
There exists a principal funcoid which is not a complemented element
of the lattice of funcoids.\end{example}
\begin{proof}
I will prove that quasi-complement of the funcoid $1_{\mathbb{N}}^{\mathsf{FCD}}$
is not its complement (it is enough by proposition~\ref{compl-is-pseud}). We have:
\begin{align*}
(1_{\mathbb{N}}^{\mathsf{FCD}})^{\ast} & =\\
\bigsqcup\setcond{c\in\mathsf{FCD}(\mathbb{N},\mathbb{N})}{c\asymp1_{\mathbb{N}}^{\mathsf{FCD}}} & \sqsupseteq\\
\bigsqcup\setcond{\uparrow^{\mathbb{N}}\{\alpha\}\times^{\mathsf{FCD}}\uparrow^{\mathbb{N}}\{\beta\}}{\alpha,\beta\in\mathbb{N},\uparrow^{\mathbb{N}}\{\alpha\}\times^{\mathsf{FCD}}\uparrow^{\mathbb{N}}\{\beta\}\asymp1_{\mathbb{N}}^{\mathsf{FCD}}} & =\\
\bigsqcup\setcond{\uparrow^{\mathbb{N}}\{\alpha\}\times^{\mathsf{FCD}}\uparrow^{\mathbb{N}}\{\beta\}}{\alpha,\beta\in\mathbb{N},\alpha\ne\beta} & =\\
\uparrow^{\mathsf{FCD}(\mathbb{N},\mathbb{N})}\bigcup\setcond{\{\alpha\}\times\{\beta\}}{\alpha,\beta\in\mathbb{N},\alpha\ne\beta} & =\\
\uparrow^{\mathsf{FCD}(\mathbb{N},\mathbb{N})}(\mathbb{N}\times\mathbb{N}\setminus\id_{\mathbb{N}})
\end{align*}
(used corollary \ref{fcd-compl-join}). But by proved above $(1_{\mathbb{N}}^{\mathsf{FCD}})^{\ast}\sqcap1_{\mathbb{N}}^{\mathsf{FCD}}\ne\bot^{\mathscr{F}(\mathbb{N})}$.\end{proof}
\begin{example}
There exists a funcoid $h$ such that $\up h$ is not a filter.\end{example}
\begin{proof}
Consider the funcoid $h=\id_{\Omega(\mathbb{N})}^{\mathsf{FCD}}$.
We have (from the proof of proposition \ref{fcd-meet-frechet}) that
$f\in\up h$ and $g\in\up h$, but $f\sqcap g\notin\up h$.\end{proof}
\begin{example}
There exists a funcoid $h\ne\bot^{\mathsf{FCD}(A,B)}$ such that $\torldout h=\bot^{\mathsf{RLD}(A,B)}$.\end{example}
\begin{proof}
Consider $h=\id_{\Omega(\mathbb{N})}^{\mathsf{FCD}}$. By proved above
$h=f\sqcap g$ where $f=1_{\mathbb{N}}^{\mathsf{FCD}}=\uparrow^{\mathsf{FCD}(\mathbb{N},\mathbb{N})}\id_{\mathbb{N}}$,
$g=\uparrow^{\mathsf{FCD}(\mathbb{N},\mathbb{N})}(\mathbb{N}\times\mathbb{N}\setminus\id_{\mathbb{N}})$.

We have $\id_{\mathbb{N}},\mathbb{N}\times\mathbb{N}\setminus\id_{\mathbb{N}}\in\GR h$.

So
\[
\torldout h=\bigsqcap^{\mathsf{RLD}}\up h=\bigsqcap^{\mathsf{RLD}(\mathbb{N},\mathbb{N})}\GR h\sqsubseteq\uparrow^{\mathsf{RLD}(\mathbb{N},\mathbb{N})}(\id_{\mathbb{N}}\cap(\mathbb{N}\times\mathbb{N}\setminus\id_{\mathbb{N}}))=\bot^{\mathsf{RLD}(\mathbb{N},\mathbb{N})};
\]
and thus $\torldout h=\bot^{\mathsf{RLD}(\mathbb{N},\mathbb{N})}$.\end{proof}
\begin{example}
There exists a funcoid $h$ such that $\tofcd\torldout h\ne h$.\end{example}
\begin{proof}
It follows from the previous example.\end{proof}
\begin{example}
$\torldin\tofcd f\ne f$ for some convex reloid $f$.\end{example}
\begin{proof}
Let $f=1_{\mathbb{N}}^{\mathsf{RLD}}$. Then $\tofcd f=1_{\mathbb{N}}^{\mathsf{FCD}}$.
Let $a$ be some non-trivial ultrafilter on $\mathbb{N}$. Then $\torldin\tofcd f\sqsupseteq a\times^{\mathsf{RLD}}a\nsqsubseteq1_{\mathbb{N}}^{\mathsf{RLD}}$
and thus $\torldin\tofcd f\nsqsubseteq f$.\end{proof}
\begin{example}
There exist composable funcoids $f$ and $g$ such that
\[
\torldout(g\circ f)\sqsupset\torldout g\circ\torldout f.
\]
\end{example}
\begin{proof}
$f=\id_{\Omega(\mathbb{N})}^{\mathsf{FCD}}$ and $g=\top^{\mathscr{F}(\mathbb{N})}\times^{\mathsf{FCD}}\uparrow^{\mathbb{N}}\{\alpha\}$
for some $\alpha\in\mathbb{N}$. Then $\torldout f=\bot^{\mathsf{RLD}(\mathbb{N},\mathbb{N})}$
and thus $\torldout g\circ\torldout f=\bot^{\mathsf{RLD}(\mathbb{N},\mathbb{N})}$.

We have $g\circ f=\Omega(\mathbb{N})\times^{\mathsf{FCD}}\uparrow^{\mathbb{N}}\{\alpha\}$.

$\torldout(\Omega(\mathbb{N})\times^{\mathsf{FCD}}\uparrow^{\mathbb{N}}\{\alpha\})=\Omega(\mathbb{N})\times^{\mathsf{RLD}}\uparrow^{\mathbb{N}}\{\alpha\}$
by properties of funcoidal reloids.

% Really:
% \begin{align*}
% \torldout(\Omega(\mathbb{N})\times^{\mathsf{FCD}}\uparrow^{\mathbb{N}}\{\alpha\}) & =\\
% \bigsqcap^{\mathsf{RLD}}\up(\Omega(\mathbb{N})\times^{\mathsf{FCD}}\uparrow^{\mathbb{N}}\{\alpha\}) & =\\
% \bigsqcap_{K\in\up\Omega(\mathbb{N})}^{\mathsf{RLD}(\mathbb{N},\mathbb{N})}(K\times\uparrow^{\mathbb{N}}\{\alpha\});\\
% F\in\up\bigsqcap_{K\in\up\Omega(\mathbb{N})}^{\mathsf{RLD}(\mathbb{N},\mathbb{N})}(K\times\uparrow^{\mathbb{N}}\{\alpha\}) & \Leftrightarrow F\in\up\left(\bigsqcap_{K\in\up\Omega(\mathbb{N})}^{\mathscr{F}}K\times^{\mathsf{RLD}}\uparrow^{\mathbb{N}}\{\alpha\}\right)
% \end{align*}
% for every $F\in\subsets(\mathbb{N}\times\mathbb{N})$. Thus
% \[
% \bigsqcap_{K\in\up\Omega(\mathbb{N})}^{\mathsf{RLD}}(K\times\uparrow^{\mathbb{N}}\{\alpha\})=\bigsqcap_{K\in\up\Omega(\mathbb{N})}^{\mathscr{F}}K\times^{\mathsf{RLD}}\uparrow^{\mathbb{N}}\{\alpha\}=\Omega(\mathbb{N})\times^{\mathsf{RLD}}\uparrow^{\mathbb{N}}\{\alpha\}.
% \]

% So $\torldout(\Omega(\mathbb{N})\times^{\mathsf{FCD}}\uparrow^{\mathbb{N}}\{\alpha\})=\Omega(\mathbb{N})\times^{\mathsf{RLD}}\uparrow^{\mathbb{N}}\{\alpha\}$.

Thus $\torldout(g\circ f)=\Omega(\mathbb{N})\times^{\mathsf{RLD}}\uparrow^{\mathbb{N}}\{\alpha\}\ne\bot^{\mathsf{RLD}(\mathbb{N},\mathbb{N})}$.\end{proof}
\begin{conjecture}
For every composable funcoids~$f$ and~$g$
\[
\torldout(g\circ f)\sqsupseteq\torldout g\circ\torldout f.
\]
\end{conjecture}

\begin{example}
$\tofcd$ does not preserve binary meets.\end{example}
\begin{proof}
$\tofcd(1_{\mathbb{N}}^{\mathsf{RLD}}\sqcap(\top^{\mathsf{RLD}(\mathbb{N},\mathbb{N})}\setminus1_{\mathbb{N}}^{\mathsf{RLD}}))=\tofcd\bot^{\mathsf{RLD}(\mathbb{N},\mathbb{N})}=\bot^{\mathsf{FCD}(\mathbb{N},\mathbb{N})}$.

On the other hand,
\begin{multline*}
\tofcd1_{\mathbb{N}}^{\mathsf{RLD}}\sqcap\tofcd(\top^{\mathsf{RLD}(\mathbb{N},\mathbb{N})}\setminus1_{\mathbb{N}}^{\mathsf{RLD}})=\\
1_{\mathbb{N}}^{\mathsf{FCD}}\sqcap\uparrow^{\mathsf{FCD}(\mathbb{N},\mathbb{N})}(\mathbb{N}\times\mathbb{N}\setminus\id_{\mathbb{N}})=\id_{\Omega(\mathbb{N})}^{\mathsf{FCD}}\ne\bot^{\mathsf{FCD}(\mathbb{N},\mathbb{N})}
\end{multline*}
(used proposition \ref{fcd-discr}).\end{proof}
\begin{cor}
$\tofcd$ is not an upper adjoint (in general).
\end{cor}
Considering restricting polynomials (considered as reloids) to ultrafilters,
it is simple to prove that each that restriction is injective if not
restricting a constant polynomial. Does this hold in general? No,
see the following example:
\begin{example}
There exists a monovalued reloid with atomic domain which is neither
injective nor constant (that is not a restriction of a constant function).\end{example}
\begin{proof}
(based on \cite{MO44055}) Consider the function $F\in\mathbb{N}^{\mathbb{N}\times\mathbb{N}}$
defined by the formula $(x,y)\mapsto x$.

Let $\omega_{x}$ be a non-trivial ultrafilter on the vertical line
$\{x\}\times\mathbb{N}$ for every $x\in\mathbb{N}$.

Let $T$ be the collection of such sets $Y$ that $Y\cap(\{x\}\times\mathbb{N})\in\omega_{x}$
for all but finitely many vertical lines. Obviously $T$ is a filter.

Let $\omega\in\atoms T$.

For every $x\in\mathbb{N}$ we have some $Y\in T$ for which $(\{x\}\times\mathbb{N})\cap Y=\emptyset$
and thus $\uparrow^{\mathbb{N}\times\mathbb{N}}(\{x\}\times\mathbb{N})\sqcap\omega=\bot^{\mathscr{F}(\mathbb{N}\times\mathbb{N})}$.

Let $g=(\uparrow^{\mathsf{RLD}(\mathbb{N},\mathbb{N})}F)|_{\omega}$.
If $g$ is constant, then there exist a constant function $G\in\up g$
and $F\cap G$ is also constant. Obviously $\dom\uparrow^{\mathsf{RLD}(\mathbb{N}\times\mathbb{N},\mathbb{N})}(F\cap G)\sqsupseteq\omega$.
The function $F\cap G$ cannot be constant because otherwise $\omega\sqsubseteq\dom\uparrow^{\mathsf{RLD}(\mathbb{N}\times\mathbb{N},\mathbb{N})}(F\cap G)\sqsubseteq\uparrow^{\mathbb{N}\times\mathbb{N}}(\{x\}\times\mathbb{N})$
for some $x\in\mathbb{N}$ what is impossible by proved above. So
$g$ is not constant.

Suppose that $g$ is injective. Then there exists an injection $G\in\up g$.
$F\sqcap G\in\up g$ is an injection which depends only on the first argument.
So $\dom(F\sqcap G)$ intersects each vertical line by atmost one element that
is $\overline{\dom(F\sqcap G)}$ intersects every vertical line by the whole
line or the line without one element. Thus $\overline{\dom(F\sqcap G)}\in T\sqsupseteq\omega$
and consequently $\dom(F\sqcap G)\notin\omega$ what is impossible.

Thus $g$ is neither injective nor constant.
\end{proof}

\section{Second product. Oblique product}
\begin{defn}
\index{product!second}$\mathcal{A}\times_{F}^{\mathsf{RLD}}\mathcal{B}=\torldout(\mathcal{A}\times^{\mathsf{FCD}}\mathcal{B})$
for every filters $\mathcal{A}$ and $\mathcal{B}$. I will call it
\emph{second product} of filters $A$ and $\mathcal{B}$.\end{defn}
\begin{rem}
The letter $F$ is the above definition is from the word ``funcoid''.
It signifies that it seems to be impossible to define $\mathcal{A}\times_{F}^{\mathsf{RLD}}\mathcal{B}$
directly without referring to funcoidal product.\end{rem}
\begin{defn}
\index{product!oblique}\emph{Oblique products} of filters $\mathcal{A}$
and $\mathcal{B}$ are defined as
\begin{align*}
\mathcal{A}\ltimes\mathcal{B} & =\bigsqcap\setcond{\uparrow^{\mathsf{RLD}}f}{f\in\mathbf{Rel}(\Base(\mathcal{A}),\Base(\mathcal{B})),\exists B\in\up\mathcal{B}:\uparrow^{\mathsf{FCD}}f\sqsupseteq\mathcal{A}\times^{\mathsf{FCD}}\uparrow B};\\
\mathcal{A}\rtimes\mathcal{B} & =\bigsqcap\setcond{\uparrow^{\mathsf{RLD}}f}{f\in\mathbf{Rel}(\Base(\mathcal{A}),\Base(\mathcal{B})),\exists A\in\up\mathcal{A}:\uparrow^{\mathsf{FCD}}f\sqsupseteq\uparrow A\times^{\mathsf{FCD}}\mathcal{B}}.
\end{align*}
\end{defn}

\begin{prop}
  ~
  \begin{enumerate}
    \item $\mathcal{A} \ltimes B = \mathcal{A} \times^{\mathsf{RLD}}_F
    B$ if $\mathcal{A}$ and $B$ are filters and $B$ is principal.

    \item $A \rtimes \mathcal{B} = A \times^{\mathsf{RLD}}_F
    \mathcal{B}$ if $A$ and $\mathcal{B}$ are filters and $A$ is principal.
  \end{enumerate}
\end{prop}

\begin{proof}
  $A \rtimes \mathcal{B} = \bigsqcap^{\mathsf{RLD}} \setcond{ f
  }{ f \in \mathbf{Rel}, f \sqsupseteq A
  \times^{\mathsf{FCD}} \mathcal{B} } = A
  \times^{\mathsf{RLD}}_F \mathcal{B}$. The other is analogous.
\end{proof}

\begin{prop}
$\mathcal{A}\times_{F}^{\mathsf{RLD}}\mathcal{B}\sqsubseteq\mathcal{A}\ltimes\mathcal{B}\sqsubseteq\mathcal{A}\times^{\mathsf{RLD}}\mathcal{B}$
for every filters $\mathcal{A}$, $\mathcal{B}$.\end{prop}
\begin{proof}
~
\begin{align*}
\mathcal{A}\ltimes\mathcal{B} & \sqsubseteq\\
\bigsqcap\setcond{\uparrow^{\mathsf{RLD}}f}{f\in\mathbf{Rel}(\Base(\mathcal{A}),\Base(\mathcal{B})),\exists A\in\up\mathcal{A},B\in\up\mathcal{B}:\uparrow^{\mathsf{FCD}}f\sqsupseteq\uparrow A\times^{\mathsf{FCD}}\uparrow B} & \sqsubseteq\\
\bigsqcap\setcond{\uparrow A\times^{\mathsf{RLD}}\uparrow B}{A\in\up\mathcal{A},B\in\up\mathcal{B}} & =\\
\mathcal{A}\times^{\mathsf{RLD}}\mathcal{B}.\\
\mathcal{A}\ltimes\mathcal{B} & \sqsupseteq\\
\bigsqcap\setcond{\uparrow^{\mathsf{RLD}}f}{f\in\mathbf{Rel}(\Base(\mathcal{A}),\Base(\mathcal{B})),\uparrow^{\mathsf{FCD}}f\sqsupseteq\mathcal{A}\times^{\mathsf{FCD}}\mathcal{B}} & =\\
\bigsqcap\setcond{\uparrow^{\mathsf{RLD}}f}{f\in\up(\mathcal{A}\times^{\mathsf{FCD}}\mathcal{B})} & =\\
\torldout(\mathcal{A}\times^{\mathsf{FCD}}\mathcal{B}) & =\\
\mathcal{A}\times_{F}^{\mathsf{RLD}}\mathcal{B}.
\end{align*}
\end{proof}
\begin{conjecture}
$\mathcal{A}\times_{F}^{\mathsf{RLD}}\mathcal{B}\sqsubset\mathcal{A}\ltimes\mathcal{B}$
for some filters $\mathcal{A}$, $\mathcal{B}$.
\end{conjecture}
A stronger conjecture:
\begin{conjecture}
$\mathcal{A}\times_{F}^{\mathsf{RLD}}\mathcal{B}\sqsubset\mathcal{A}\ltimes\mathcal{B}\sqsubset\mathcal{A}\times^{\mathsf{RLD}}\mathcal{B}$
for some filters $\mathcal{A}$, $\mathcal{B}$. Particularly, is
this formula true for $\mathcal{A}=\mathcal{B}=\Delta\sqcap\uparrow^{\mathbb{R}}]0;+\infty[$?
\end{conjecture}
The above conjecture is similar to Fermat Last Theorem as having no
value by itself but being somehow challenging to prove it (not expected
to be as hard as FLT however).
\begin{example}
$\mathcal{A}\ltimes\mathcal{B}\sqsubset\mathcal{A}\times^{\mathsf{RLD}}\mathcal{B}$
for some filters $\mathcal{A}$, $\mathcal{B}$.\end{example}
\begin{proof}
It's enough to prove $\mathcal{A}\ltimes\mathcal{B}\neq\mathcal{A}\times^{\mathsf{RLD}}\mathcal{B}$.

Let $\Delta_{+}=\Delta\sqcap\uparrow^{\mathbb{R}}]0;+\infty[$. Let
$\mathcal{A}=\mathcal{B}=\Delta_{+}$.

Let $K=(\le)|_{\mathbb{R}\times\mathbb{R}}$.

Obviously $K\notin\up(\mathcal{A}\times^{\mathsf{RLD}}\mathcal{B})$.

$\mathcal{A}\ltimes\mathcal{B}\sqsubseteq\uparrow^{\mathsf{RLD}(\Base(\mathcal{A}),\Base(\mathcal{B}))}K$
and thus $K\in\up(\mathcal{A}\ltimes\mathcal{B})$ because
\[
\uparrow^{\mathsf{FCD}(\Base(\mathcal{A}),\Base(\mathcal{B}))}K\sqsupseteq\Delta_{+}\times^{\mathsf{FCD}}\uparrow B=\mathcal{A}\times^{\mathsf{FCD}}\uparrow B
\]
for $B=]0;+\infty[$
because for every $X\in\corestar\Delta_{+}$ there is $x\in X$ such that $x\in]0;\epsilon[$ (for every positive $\epsilon$)
and thus $]\epsilon;+\infty[\subseteq\rsupfun{K}\{x\}$ so having
\[\rsupfun{K}X = ]0;+\infty[ \in \GR\rsupfun{\Delta_{+}\times^{\mathsf{FCD}}\uparrow B}X.\]

Thus $\mathcal{A}\ltimes\mathcal{B}\neq\mathcal{A}\times^{\mathsf{RLD}}\mathcal{B}$.\end{proof}
\begin{example}
\label{secprod-neq}$\mathcal{A}\times_{F}^{\mathsf{RLD}}\mathcal{B}\sqsubset\mathcal{A}\times^{\mathsf{RLD}}\mathcal{B}$
for some filters $\mathcal{A}$, $\mathcal{B}$.\end{example}
\begin{proof}
This follows from the above example.\end{proof}
\begin{conjecture}
$(\mathcal{A}\ltimes\mathcal{B})\sqcap(\mathcal{A}\rtimes\mathcal{B})\ne\mathcal{A}\times_{F}^{\mathsf{RLD}}\mathcal{B}$
for some filters $\mathcal{A}$, $\mathcal{B}$.\end{conjecture}
(Earlier I presented a proof of the negation of this conjecture, but it was in error.)
\begin{example}
$(\mathcal{A}\ltimes\mathcal{B})\sqcup(\mathcal{A}\rtimes\mathcal{B})\sqsubset\mathcal{A}\times^{\mathsf{RLD}}\mathcal{B}$
for some filters $\mathcal{A}$, $\mathcal{B}$.\end{example}
\begin{proof}
(based on \cite{MO72638}) Let $\mathcal{A}=\mathcal{B}=\Omega(\mathbb{N})$.
It's enough to prove $(\mathcal{A}\ltimes\mathcal{B})\sqcup(\mathcal{A}\rtimes\mathcal{B})\neq\mathcal{A}\times^{\mathsf{RLD}}\mathcal{B}$.

Let $X\in\up\mathcal{A}$, $Y\in\up\mathcal{B}$ that is $X\in\Omega(\mathbb{N})$,
$Y\in\Omega(\mathbb{N})$.

Removing one element $x$ from $X$ produces a set $P$. Removing
one element $y$ from $Y$ produces a set $Q$. Obviously $P\in\Omega(\mathbb{N})$,
$Q\in\Omega(\mathbb{N})$.

Obviously $(P\times\mathbb{N})\cup(\mathbb{N}\times Q)\in\up((\mathcal{A}\ltimes\mathcal{B})\sqcup(\mathcal{A}\rtimes\mathcal{B}))$.

$(P\times\mathbb{N})\cup(\mathbb{N}\times Q)\nsupseteq X\times Y$
because $(x,y)\in X\times Y$ but $(x,y)\notin(P\times\mathbb{N})\cup(\mathbb{N}\times Q)$
for every $X\in\up\mathcal{A}$, $Y\in\up\mathcal{B}$.

Thus some $(P\times\mathbb{N})\cup(\mathbb{N}\times Q)\notin\up(\mathcal{A}\times^{\mathsf{RLD}}\mathcal{B})$
by properties of filter bases.\end{proof}
\begin{example}
$\torldout\tofcd f\ne f$ for some convex reloid $f$.\end{example}
\begin{proof}
Let $f=\mathcal{A}\times^{\mathsf{RLD}}\mathcal{B}$ where $\mathcal{A}$
and $B$ are from example \ref{secprod-neq}.

$\tofcd(\mathcal{A}\times^{\mathsf{RLD}}\mathcal{B})=\mathcal{A}\times^{\mathsf{FCD}}\mathcal{B}$
by proposition \ref{fcd-of-rprod}.

So $\torldout\tofcd(\mathcal{A}\times^{\mathsf{RLD}}\mathcal{B})=\torldout(\mathcal{A}\times^{\mathsf{FCD}}\mathcal{B})=\mathcal{A}\times_{F}^{\mathsf{RLD}}\mathcal{B}\ne\mathcal{A}\times^{\mathsf{RLD}}\mathcal{B}$.\end{proof}


\newpage
\section{Trigonometry}\label{sec:Trigonometry}
In this section we review the definitions of trigonometric functions.

\input{1-review/1-3-1-angles-sectors-circles}
\input{1-review/1-3-2-trig-functions}
\input{1-review/1-3-3-exact-trig-ratios}
\input{1-review/1-3-4-graphs-trig-functions}
\input{1-review/1-3-5-trig-identities}

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

\Opensolutionfile{solutions}[ex]
\section*{Exercises for \ref{sec:Trigonometry}}

\begin{enumialphparenastyle}

%\vfill\null
%\columnbreak

\begin{multicols}{2}
%%%%%%%%%%
\begin{ex}
Convert from degrees to radians.\\
$\begin{array}{cccc}
(a) \hspace{1mm} 90^{\circ} & (b) \hspace{1mm} 135^{\circ} & (c) \hspace{1mm} 210^{\circ} & (d) \hspace{1mm} 300^{\circ}
\end{array}$
\begin{sol}
$\begin{array}{cccc}
	(a) \hspace{1mm} \pi/2 & (b) \hspace{1mm} 3\pi/4 & (c) \hspace{1mm} 7\pi/6 & (d) \hspace{1mm} 5\pi/3
\end{array}$
\end{sol}
\end{ex}

\begin{ex}
	Convert from radians to degrees.\\
	$\begin{array}{cccc}
	(a) \hspace{1mm} \ds{\frac{\pi}{3}} & (b) \hspace{1mm} \ds{\frac{7\pi}{12}} & (c) \hspace{1mm} \ds{\frac{3\pi}{2}} & (d) \hspace{1mm} \ds{\frac{-5\pi}{12}}
	\end{array}$
\begin{sol}
	$\begin{array}{cccc}
	(a) \hspace{1mm} 60^{\circ} & (b) \hspace{1mm} 105^{\circ} & (c) \hspace{1mm} 270^{\circ} & (d) \hspace{1mm} 285^{\circ}
	\end{array}$
\end{sol}
\end{ex}

\begin{ex}
	If a circle has radius $5 \,\, cm$, find the length of arc subtended by a central angle of $\pi /6$.
\end{ex}
\begin{sol}
	$\ds{5\pi/6 \,\, cm}$
\end{sol}

\begin{ex}
	Find the radius of a circular sector with angle $\pi /4 $ and arc length $2\pi \,\, cm$.
\begin{sol}
	$8 \,\,cm$
\end{sol}
\end{ex}

%%%%%%%%%%
\begin{ex}
	Compute the following:
	\begin{multicols}{2}
		\begin{enumerate}
			\item	$\sin(3\pi)$
			\item	$\sec(5\pi / 6)$
			\item	$\cos(-\pi / 3)$
			\item	$\csc(4\pi / 3)$
			\item	$\tan(7\pi / 4)$
			\item	$\cot(13\pi  /4)$
		\end{enumerate}
	\end{multicols}
\begin{sol}
  $\begin{array}{llllll}
  (a) $0$ & (b) $-2\sqrt{3}/3$ & (c) $1/2$ & (d) $-2\sqrt{3}/3$ & (e) $-1$ & (f) $1$
\end{array}$
\end{sol}
\end{ex}

\begin{ex}
If $\ds{\cos \theta =\frac{2}{5}}$ and $0 <\theta <\pi/2$, find the other five trigonometric functions of $\theta$.
\begin{sol}
	$\ds{\sin \theta = \frac{\sqrt{21}}{5} ; \hspace{4mm} \tan \theta = \frac{\sqrt{21}}{2} ; \hspace{4mm} \csc \theta = \frac{5}{\sqrt{21}} ; \hspace{4mm} \sec \theta = \frac{5}{2} ; \hspace{4mm} \cot \theta = \frac{2}{\sqrt{21}}  }$
\end{sol}
\end{ex}

\begin{ex}
Find all values of $\theta$ that satisfy the equation. Express your answer in radians.\\
$\begin{array}{ll}
(a) \hspace{1mm} \sin \theta = -1 & (b) \hspace{1mm}  \cos 2\theta = 1/2
\end{array}$
\begin{sol}
(a) $2n\pi-\pi/2$, any integer $n$; (b) $n\pi\pm\pi/6$, any integer $n$
\end{sol}
\end{ex}

%%%%%%%%%%
\begin{ex}
If $\sin\theta=\frac{3}{5}$ and $\frac{\pi}{2}<\theta<\pi$, then find $\sec\theta$.
\begin{sol}
$-\frac{5}{4}$
\end{sol}
\end{ex}

%%%%%%%%%%
\begin{ex}
Suppose that $\tan\theta=x$ and $\pi<\theta<\frac{3\pi}{2}$, find $\sin\theta$ and $\cos\theta$ in terms of $x$.
\begin{sol}
$\sin\theta=-x/\sqrt{x^{2}+1}$, $\cos\theta=-1/\sqrt{x^{2}+1}$.
\end{sol}
\end{ex}

%%%%%%%%%%
\begin{ex}
Find an angle $\theta$ such that $-\frac{\pi}{2}<\theta<\frac{\pi}{2}$ and $\sin\theta=\sin\frac{23\pi}{7}$.
\begin{sol}
$-\frac{2\pi}{7}$ is the unique answer.
\end{sol}
\end{ex}

%%%%%%%%%%
\begin{ex}
Use an angle sum identity to compute the following. \\

\vspace{-2mm} \hspace{4mm}  (a) \hspace{1mm} $\cos(\pi/12)$ \hspace{1cm} (b) \hspace{1mm} $\tan(5\pi/12)$
\begin{sol}
(a) $(\sqrt{2}+\sqrt{6})/4$; \hspace{1cm} (b) $-(1+\sqrt3)/(1-\sqrt3)=2+\sqrt3$
\end{sol}
\end{ex}

%%%%%%%%%%
\begin{ex} Sketch the following functions:
	\begin{multicols}{2}
		\begin{enumerate}
			\item	$y=2\sin x$
			\item	$y=\sin 3x$
			\item	$y=\sin(-x)$
			\item   $\ds{y=\cos \left(x-\frac{\pi}{3} \right)}$
			\item   $y=|\sin x|$
			\item   $\ds{y=2+\sin \left(x+\frac{\pi}{4} \right)}$
		\end{enumerate}
	\end{multicols}
\end{ex}

%%%%%%%%%%
\begin{ex} Verify the following identities
 \begin{enumerate}
	\item	$\ds{\frac{\cos^2 t }{1-\sin t } = 1+\sin t }$
	\item	$\ds{2\csc 2\theta=\sec \theta \csc \theta} $
	\item	$\ds{\sin 3\theta - \sin \theta  = 2\cos 2\theta\sin \theta}$
\end{enumerate}
\end{ex}

%%%%%%%%%%
\begin{ex} Find all values of $x$ in the interval $[0, \, 2\pi]$ that satisfy the equation.\\
\begin{multicols}{2}
	\begin{enumerate}
		\item $\ds{\sin 2x =1}$
	    \item $\ds{\sin x = \tan x}$
	    \item $\ds{\cos x = \sin 2x}$
	    \item $\ds{2\cos x + 1 =0}$
	     \item $\ds{2\sin x -1 -\sin^2 x = 0}$
	 \end{enumerate}
\end{multicols}
\begin{sol}
 (a)  (b) (c) (d) (e) $t=\pi/2$
\end{sol}
\end{ex}

\end{multicols}

\end{enumialphparenastyle}


\section{The Integers and the Real Numbers}

\begin{enumerate}
  \item
  \begin{align*}
  (x+y) + z &= x + (y + z)\\
  (x\cdot y) \cdot z &= x \cdot (y \cdot z)
  \end{align*}

  \item \begin{align*}
    x + y &= y + x\\
    x \cdot y &= y \cdot x
  \end{align*}

  \item $\exists$ element of $\mathbb{R}$ called \textbf{zero}, denoted by $0$, such that
  \begin{equation*}
    x + 0 = x, \forall x \in \mathbb{R}
  \end{equation*}

  \item $\exists$ element of $\mathbb{R}$ called \textbf{one}, denoted by $1$, such that
  \begin{equation*}
    x \cdot 1 = x, \forall x \in \mathbb{R}
  \end{equation*}

  \item \begin{equation*}
    x \cdot (y + z) = (x \cdot y) + (x \cdot z)
  \end{equation*}

  \item \begin{align*}
    &\text{If } x>y, \text{ then } x + z > y + z\\
    &\text{If } x>y \text{ and } z > 0, \text{ then } x \cdot z > y \cdot z
  \end{align*}
\end{enumerate}

\begin{itemize}
  \item Properties 1-5 define a field
  \item Properties 1-6 define an ordered field
  \item Properties 7-8 by themselves define a linear continuum
\end{itemize}

\begin{definition}
  A \textbf{section} $S_n$ is defined as
  \begin{equation}
    S_{n+1} = \pbrac{
      1, 2, \dots, n
    }
  \end{equation}
\end{definition}

\section*{Exercises}

\bx{
  \TODO: Too lazy
}

\bx{
  \TODO: too lazy
}

\bx{
  \ea{
    \item If we take the intersection of any two inductive sets, call this
    intersection $A$, we know that $1 \in A$, and we still can inductively show
    that for any $x \in A$, that $x + 1 \in A$ as well, since $x$ is part of two
    inductive sets.
    We can then use induction to prove that the intersection of an arbitrary
    collection of inductive sets is also inductive.

    \item Proving the basic properties \begin{enumerate}[label=(\arabic*)]
      \item $1 > 0$ and $1 \in \mathbb{Z}$, so $1 \in \Zp$. Now for any
      $x \in \Zp$, the number $x+1$ is still an integer, and since $x >
      0$, we know $x + 1 > 0$, which means $x + 1 \in \Zp$ as well.
      Therefore, we conclude $\Zp$ is inductive.

      \item \AFSOC $A \neq \Zp$. Then we know that $\exists x \in
      \Zp, x \not\in A$. However, if we use induction from 1, we can
      show that $x \in A$, which is a contradiction. Therefore we conclude $A =
      \Zp$.
    \end{enumerate}
  }
}

\bx{
  \ea{
    \item We have $a \in \Zp$. We just want to inductively show that $a + x \in \Zp, \forall x \in \Zp$.
    We can do this by induction.
    \label{chap1:sec4:prob5:parta}
    \item Induction on $b$ \label{chap1:sec4:prob5:partb}
    \item We can either casework here, with $a = 0, a \geq 1$, or we can show that $a-1$ is inductive.
    \label{chap1:sec4:prob5:partc}
    \item We can use induction on $d$, via \ref{chap1:sec4:prob5:partc}
    \item We can use induction on $d$, both ways (positive and negative directions)
  }
}

\bx{
  \begin{enumerate}
    \item $a^na^m = a^{n+m}$, shown by \ref{chap1:sec4:prob5:parta}
    \label{chap1:sec4:prob6:parta}
    \item $(a^n)^m = a^{nm}$, shown by \ref{chap1:sec4:prob5:partb}
    \item $a^mb^m = (ab)^{m}$, induction on $m$, and you have to use the
    property in \ref{chap1:sec4:prob6:parta} for $(ab)^m \cdot ab = (ab)^{m+1}$.
  \end{enumerate}
}

\bx{
  \TODO: probably just doing induction in another direction
}

\bx{
  \ea{
    \item This is a corollary of the Axiom of Completness, which states that every nonempty set of real numbers that is bounded above has a least upper bound.
    \item Informally, suppose we have some $\epsilon > 0$ that is the $\inf$ of this set, then we can always find $1/n < \epsilon$, so therefore this $\epsilon$ is not the $\inf$, and we conclude that $0$ is the $\inf$.
    \item \TODO: induction proof, idea is that $a^n$ gets smaller as $n$ increases, and can be smaller than any $\epsilon$. We have to show this property by induction.
  }
}

\bx{
  \ea{
    \item Follows from that $\mathbb{Z} \subset \mathbb{R}$.
    \item \AFSOC there are two such numbers, $n_1, n_2 \in \mathbb{Z}$. WLOG $n_1 > n_2$, Then we can find that
    \begin{align*}
      n_1 &< x < n_1 + 1\\
      n_2 < x < n_2 + 1 \implies
      -n_2 - 1 &< -x < -n_2\\
      \implies n_1 - n_2 - 1 &< 0 < n_1 - n_2 + 1
    \end{align*}
    which is impossible, since $n_1 - n_2 - 1 \geq 0$, which is $\not< 0$, so
    therefore we cannot have more than one $n$.

    Now to show the existence of this $n$, we can use a contradiction argument
    along with an induction argument to show no such $n$ exists would imply $x
    \not\in \mathbb{R}$.

    I'm sure there's a more straightforward proof with lower bounds...using the
    fact that $\mathbb{Z}$ has a greatest lower bound.

    \item We have $n \geq x > y + 1 > y \geq m$ for $m, n \in \mathbb{Z}$.

    Either $y+1$ is an integer, in which case $n = y+1$. If $y+1$ is not an
    integer, then we know it is bounded below by some $b \in \mathbb{Z}$ such that $b < y + 1 < b + 1$,
    which we know must be $<x$, and $>y$, since if it were $\leq y$, then we could choose
    $b' = b + 1$, and $b' > y$ and $b' \leq y+1$, and thus $b$ would not satisfy $b + 1 > y+1$.
    In this case, $n = b$, and we have $x > n > y, n \in \mathbb{Z}$.

    \label{chap1:sec4:prob9:partc}

    \item We know that $x - y > 0$, so we can find some $n \in \mathbb{Z}$ such that $n(x - y) > 1$.
    Using \ref{chap1:sec4:prob9:partc}, we can find some $m \in \mathbb{Z}$ such that
    \begin{align*}
      nx &> m > ny\\
      x &> \frac{m}{n} > y
    \end{align*}

    let $z = m/n$.
  }
}

\bx{
    \ea{
      \item First, let's show
      \begin{align*}
        (x+h)^2 = x^2 + 2xh + h^2 &\leq x^2 + h(2x + 1)\\
        \implies h^2 &\leq h\\
        \implies h &\leq 1\tag{Given, since $h<1$}
      \end{align*}

      Notice in the last step, if $h = 0$, then we don't divide and $0^2 \leq 0$ holds.

      \begin{align*}
        (x-h)^2 = x^2 - 2xh + h^2 &\geq x^2 - 2xh\\
        \implies h^2 &\geq 0\\
        \implies h &\geq 0\tag{Given, since $h\geq 0$}
      \end{align*}

      Notice in the last step, if $h = 0$, then we don't divide and $0^2 \geq 0$ holds.

      \item If we have $x^2 < a$, then we know $(x+h)^2 \leq x^2 + h(2x + 1)$, so we can find an $h$ by considering the RHS and making it $< a$.
      We can do this by solving for $h$, which gives us
      \begin{equation*}
        h < \frac{a - x^2}{2x+1}
      \end{equation*}

      The other part of the problem is more of the same algebra.

      \item $B$ is bounded above by $1 + a$, and $a/2 \in B$.
      If we let $b = \sup B$, then $b^2$ cannot be $<a$, or else we can find
      some $(b + h)^2 < a, h > 0$, and show that this $b$ is not the $\sup$.

      \item \TODO: I'm stuck
    }
}

\bx{
  \ea{
    \item We know from exercises before that since $m/2 \not\in \mathbb{Z}$
    since $m$ is odd, we know $\exists n \in \mathbb{Z}$ such that $n < m/2 < n+1$.
    Now consider,
    \begin{equation*}
      2n < m < 2n+2
    \end{equation*}

    Since $m \in \mathbb{Z}$, we conclude $m = 2n+1$.

    \item $p \cdot q = (2m+1) \cdot (2n+1) = 4mn + 2m + 2n + 1 = 2(2mn + m + n) + 1$, which is in the form $2N+1$, so therefore $p \cdot q$ is odd.
    For $p^n$ to be odd, we show by induction.

    \item Honestly I think this is by definition of $\mathbb{Q}$. The hint in the textbook implies the proof should be something about finding the denominator in reduced form.
    \item I really hope you can show $\sqrt{2}$ is irrational by the time you take topology...
  }
}


\chapter{Future Work} \label{ch:future_work}
This chapter covers a few ideas for future work that could improve upon the current state of the SCOUt project.

\noindent
\textbf{Artificial Neural Network Integration.}
Original ideas for the adaptive control schema included the use of an artificial neural network (ANN).
The ANN would take an agent state and a list of valid actions as input and output the selected action.
Due to the dynamic nature of agent states, use of an ANN was ruled out.
If an agent changes the sensors it is equipped with, the ANN would need to account for a new set of input values due to the different set of \texttt{ElementState}s that would be found in the \texttt{AgentState}.
However, the memory-based approach required the use of several weights to guide each state comparison and action scoring equation.
Our solution was to optimize the weight set using a genetic algorithm (GA).
Use of an ANN in place of the state comparison equations would eliminate the need for external weights to be provided.
This could further enhance the adaptability of SCOUt's decision model.
State-action rewards (SARs) could be compared against the current state by passing attributes through the ANN to output difference scores.
The ANN could be trained with backpropagation using the existing simulation platform and the short-term and long term-reward systems.
This model would likely require the ANN to remain ``open'' in the sense that its weights are constantly being trained during every operation.

\noindent
\textbf{Improved Memory Management.}
Improvements to both the process of saving and loading the SCOUt controller's memory could be made.
For saving memory, the application of cluster would cut down on memory storage requirements.
Currently, SCOUt saves the last 20 SARs from each operation, and uniformly samples 5 percent of the remaining SARs.
Instead of only saving a sub-set, all SARs could be saved in memory and a data clustering algorithm could later be applied to ``clean-up'' the memory.
The clusters could then be averaged and given a weight based on the number of SARs that fell within the cluster.
This would eliminate redundancies within the memory set, as well as reduce the amount of computational time required for the controller to conduct state comparisons.
As for loading memory, an adaptive approach could be taken to select only a sub-set of the SARs to use in each operation.
The controller could begin by analyzing the given goal and agent setup to choose SARs from memory that correlate to the operation at hand.
We expect that this would have two positive effects: less memory means less computational time for the action decision model, and a more concise memory set would yield higher performance results.

\noindent
\textbf{Integration of Goals into Agent States.}
Currently, the only place that we see the reflection of the current goal in SCOUt's decision model is with the \texttt{indicator} flag found in each \texttt{ElementState}.
A higher-level approach could be taken so that the decision model analyzes an \textit{OperationState} rather than just an \texttt{AgentState}.
This could be achieved by classifying the goal type and goal instance.
For example, a \textit{Find Human} \textit{OperationState} would also include a current goal type of ``anomaly searching'' and a goal instance of ``human'' since this is the specific anomaly that the agent is searching for.
These attributes could then be weighted into the state comparison system to produce a more concise \textit{OverallStateDifference} score.


\section{Conclusion}
\label{sec:conclusion}

In this report, we described a complete model of the Algorand consensus protocol in Coq. We also outlined the statement and machine-checkable proof of the asynchronous safety theorem, a key property of the Algorand protocol, while also highlighting the assumptions under which the theorem holds. Our formal proof of safety (along with other lemmas leading up to it) gives additional assurance in the correctness of the protocol.

Concerning future efforts, the model we developed as part of this effort is generic in that it captures the dynamics of the Algorand consensus protocol in a way that is orthogonal to the properties that we verify about it. This means that the model can be readily used to verify other properties of the protocol beyond asynchronous safety, including most importantly \emph{liveness}~\cite{Chen2019}. In fact, we anticipate that many of the smaller results shown about the protocol and used in the proof of safety will also constitute essential ingredients of a liveness proving effort. Nevertheless, proving liveness will likely require showing many additional results, especially related to timely message delivery and network partitioning, some of which were not needed for the safety argument. Future work also includes connecting our model to verified cryptographic primitives and results.