\documentclass[a4paper,11pt]{article}

\input{packages.tex}
\input{tikz.tex}
\input{thmstyle.tex}
\input{macros.tex}

% opening
\title{Some notes on the compatibility of embeddings using Allombert's algorithm}
\author{}

\begin{document}

\maketitle

%\begin{abstract}

%\end{abstract}

%\tableofcontents

%\clearpage

\section{Towers of $\ell$-adic extensions, $\ell\neq2$}
\label{sec:ladic}

Let $p$ be a prime number, we are interested in the tower of $\ell$-adic extensions of
$k=\mathbb{F}_p$, where $\ell\notin\left\{ 2, p
\right\}$ is an other prime
number. For each $i$, we denote by
$\mathbb{F}_{p^{\ell^i}}$ the extension of degree $\ell^i$, $\zeta_{\ell^i}$ a
$\ell^i$-th primitive root of unity and $r_{\ell^i}$ the integer such that
$k(\zeta_{\ell^i})\cong\mathbb{F}_{p^{r_{\ell^i}}}$. We also denote by
$A_{\ell^i}=\mathbb{F}_{p^{\ell^i}}\otimes
k(\zeta_{\ell^i})$ the algebra used to solve Hilbert 90 problems, and
$\alpha_{\ell^i}\in A_{\ell^i}$ the
solution that we use.

We have $r_{\ell}=\omega_{(\mathbb{Z}/\ell\mathbb{Z})^\times}(p)$, where
$\omega_{(\mathbb{Z}/\ell\mathbb{Z})^\times}(p)$ denotes the order of $p$ in
$(\mathbb{Z}/\ell\mathbb{Z})^\times$. If we denote by $\upsilon=v_\ell(p^{r_\ell}-1)$
the $\ell$-adic valuation of $p^{r_\ell}-1$, we get
\[
  r_\ell = r_{\ell^2} = \cdots = r_{\ell^{\upsilon}},
\]
and if $i\geq\upsilon$, we have $r_{\ell^{i+1}}=\ell r_{\ell^i}$.

Assume we have an integer $n\in\mathbb{N}$, a root
$\zeta_{\ell^n}$ and a solution of Hilbert 90 $\alpha_{\ell^n}\in A_{\ell^n}$. We are interested in
constructing the embedding $\mathbb{F}_{p^{\ell^n}}\emb
\mathbb{F}_{p^{\ell^{n+1}}}$, using Allombert's algorithm. We
first compute
\[
  g = \gcd(\pi_{\ell^n}(x^\ell), \Phi_{\ell^{n+1}}(x)),
\]
where $\pi_{\ell^n}$ is the minimal polynomial of $\zeta_{\ell^n}$ over $k$ and
$\Phi_{\ell^{n+1}}$ is the $\ell^{n+1}$-th cyclotomic polynomial. We set
$\pi_{\ell^{n+1}}$ to be an irreducicle factor of $g$ and we take
$\zeta_{\ell^{n+1}}$ a root
of $\pi_{\ell^{n+1}}$. We then define
$A_{\ell^{n+1}}=\mathbb{F}_{p^{\ell^{n+1}}}\otimes k(\zeta_{\ell^{n+1}})$ and
\[
\begin{array}{cccc}
  N_{\ell^{n+1}/\ell^n,\, \bm{\ell^{n+1}}}: & A_{\bm{\ell^{n+1}}} & \to &
  A_{\bm{\ell^{n+1}}} \\
  & \gamma & \mapsto & \prod_{j=0}^{\ell-1} (1 \otimes
  \sigma^{jr_{\ell^n}})(\gamma)
\end{array}
\]
where $\sigma$ is the Frobenius automorphism of $k$. If the domain of the map is
clear within the given context, we will omit the second index and only note
$N_{\ell^{n+1}/\ell^n}$. We note that, in particular, given
$\gamma=x\otimes y\in A_{\ell^{n+1}}$ a simple tensor, if
$r_{\ell^{n+1}}=r_{\ell^n}$, we have $N_{\ell^{n+1}/\ell^n}(\gamma) =
\gamma^\ell$, and if $r_{n+1}=\ell r_n$, we have $N_{\ell^{n+1}/\ell^n}(\gamma) = x^\ell\otimes
N_{k(\zeta_{\ell^{n+1}})/k(\zeta_{\ell^n})}(y)$, where
$N_{k(\zeta_{\ell^{n+1}})/k(\zeta_{\ell^n})}$ is the
norm of the extension $k(\zeta_{\ell^{n+1}})$ over $k(\zeta_{\ell^n})$. More generally, if $\gamma\in
A_{\ell^{n+1}}$ is not a simple tensor, we have that
\[
  (1\otimes\sigma^{r_{\ell^n}})(N_{\ell^{n+1}/\ell^n}(\gamma)) =
  N_{\ell^{n+1}/\ell^n}(\gamma),
\]
so we still have
\[
  N_{\ell^{n+1}/\ell^n}(\gamma)\in \mathbb{F}_{p^{\ell^{n+1}}}\otimes \phi_{k(\zeta_{\ell^n})\emb
k(\zeta_{\ell^{n+1}})}(k(\zeta_n)).
\]

We indeed embed $k(\zeta_{\ell^n})$ in $k(\zeta_{\ell^{n+1}})$ by sending
$\zeta_{\ell^n}$ to
$\zeta_{\ell^{n+1}}^\ell$ and we denote by $\phi_{k(\zeta_{\ell^n})\emb
k(\zeta_{\ell^{n+1}})}$ this embedding. We also note
\[
  \Phi_{A_{\ell^n}\emb
  A_{\ell^{n+1}}}=\phi_{\mathbb{F}_{p^{\ell^n}}\emb\mathbb{F}_{p^{\ell^{n+1}}}}\otimes\phi_{k(\zeta_{\ell^n})\emb
k(\zeta_{\ell^{n+1}})}
\]
an embedding from the algebra $A_{\ell^n}$ in $A_{\ell^{n+1}}$, where $\phi_{\mathbb{F}_{p^{\ell^n}}\emb\mathbb{F}_{p^{\ell^{n+1}}}}$ is some
embedding of $\mathbb{F}_{p^{\ell^n}}$ in $\mathbb{F}_{p^{\ell^{n+1}}}$.
With that choice we have that
\[
  N_{\ell^{n+1}/\ell^n}(1\otimes\zeta_{\ell^{n+1}})=\Phi_{A_{\ell^n}\emb
  A_{\ell^{n+1}}}(1\otimes\zeta_{\ell^n}).\footnote{If $r_{\ell^{n+1}}=r_{\ell^n}$,
  $N_{\ell^{n+1}/\ell^n}(1\otimes\zeta_{n+1})=1\otimes\zeta_{n+1}^\ell$. If
  $r_{\ell^{n+1}}=\ell r_{\ell^n}$, it means that
  there are no roots of $X^\ell-\zeta_{\ell^n}$ in $k(\zeta_{\ell^n})$. Since there are $\ell$-roots of unity in
  $k(\zeta_{\ell^n})$, the polynomial $X^\ell-\zeta_{\ell^n}$ is either irreducible or splits
  into linear polynomial over $k(\zeta_{\ell^n})[X]$. The polynomial $X^\ell
  -\zeta_{\ell^{n+1}}^\ell=X^\ell-\phi_{\mathbb{F}_{p^{\ell^n}}\emb
  \mathbb{F}_{p^{\ell^{n+1}}}}(
  \zeta_{\ell^n})$ is
  the minimal polynomial of $\zeta_{\ell^{n+1}}$ over $\phi_{\mathbb{F}_{p^{\ell^n}}\emb
  \mathbb{F}_{p^{\ell^{n+1}}}}(k(\zeta_{\ell^n}))$ and the product of its
  roots (\ie the norm of $\zeta_{\ell^{n+1}}$) is (up to the sign) the constant
  coefficient, so
  $N_{\ell^{n+1}/\ell^n}(1\otimes\zeta_{\ell^{n+1}})=\Phi_{A_{\ell^n}\emb
  A_{\ell^{n+1}}}(1\otimes\zeta_{\ell^n})$.}
\]
We also see that $N_{\ell^{n+1}/\ell^n}$ and $\sigma\otimes1$ commute, and for any $\alpha,
\beta\in A_{\ell^{n+1}}$, we have that \[
  N_{\ell^{n+1}/\ell^n}(\alpha\beta) =
  N_{\ell^{n+1}/\ell^n}(\alpha)N_{\ell^{n+1}/\ell^n}(\beta).
\]
So if $\beta\in A_{\ell^{n+1}}$ is a nonzero solution of the Hilbert 90 problem
in $A_{\ell^{n+1}}$ for
$1\otimes\zeta_{\ell^{n+1}}$, \ie
\[
  (\sigma\otimes 1)(\beta) = (1\otimes\zeta_{\ell^{n+1}})\beta,
\]
then $N_{\ell^{n+1}/\ell^n}(\beta)$ is a nonzero solution of Hilbert 90 for
$\Phi_{A_{\ell^n}\emb A_{\ell^{n+1}}}(1\otimes\zeta_{\ell^n})$:
\begin{align*}
  (\sigma\otimes1)(N_{\ell^{n+1}/\ell^n}(\beta)) &= N_{\ell^{n+1}/\ell^n}((\sigma\otimes1)(\beta)) \\
  &= N_{\ell^{n+1}/\ell^n}(1\otimes\zeta_{\ell^{n+1}})N_{\ell^{n+1/\ell^n}}(\beta) \\
  &= \Phi_{A_{\ell^n}\emb A_{\ell^{n+1}}}(1\otimes\zeta_n)N_{\ell^{n+1}/\ell^n}(\beta).
\end{align*}
This also implies that $N_{\ell^{n+1}/\ell^n}(\beta)$ is in fact in
$\Phi_{A_{\ell^n}\emb A_{\ell^{n+1}}}(A_{\ell^n})$, so we have that
\[
  N_{\ell^{n+1}/\ell^n}(\beta) = (1\otimes a)\Phi_{A_{\ell^n}\emb
  A_{\ell^{n+1}}}(\alpha_n),
\]
with $1\otimes a\in \Phi_{A_{\ell^n}\emb A_{\ell^{n+1}}}(1\otimes
k(\zeta_{\ell^n}))$ and $a\neq0$, because the solutions of Hilbert 90 in
$\Phi_{A_{\ell^n}\emb A_{\ell^{n+1}}}(A_{\ell^n})$
form a $\phi_{k(\zeta_{\ell^n})\emb k(\zeta_{\ell^{n+1}})}(k(\zeta_{\ell^n}))$ vector space of dimension $1$. We now want to find an
element $1\otimes b\in1\otimes k(\zeta_{\ell^{n+1}})$ such that
\[
N_{\ell^{n+1}/\ell^n}(1\otimes b)=1\otimes a^{-1}.
\]
We distinguish two
cases: $r_{n+1}=\ell r_n$ and $r_{n+1}=r_n$.
Let us first assume that $r_{\ell^{n+1}}=\ell r_{\ell^n}$, it means that
\[
  \phi_{k(\zeta_{\ell^n})\emb k(\zeta_{\ell^{n+1}})}(k(\zeta_{\ell^n}))\subsetneq
k(\zeta_{\ell^{n+1}})
\]
and that $N_{\ell^{n+1}/\ell^{n}}$ operates as the norm
$N_{k(\zeta_{n+1})/k(\zeta_n)}$ on the right side of $A_{\ell^{n+1}}$. Since this norm
is surjective we can find the  element $b$ such that $N_{\ell^{n+1}/\ell^n}(1\otimes b)=1\otimes a^{-1}$ and
we set
\[
  \alpha_{\ell^{n+1}}\eqdef (1\otimes b)\beta,
\]
in order to have
\[
  N_{\ell^{n+1}/\ell^n}(\alpha_{\ell^{n+1}})=\Phi_{A_{\ell}\emb
  A_{\ell^{n+1}}}(\alpha_{\ell^n}).
\]
In order to compute $b$ we remark that either the element
$a^{-1}$ is a $\ell$-th power in $\phi_{k(\zeta_{\ell^m})\emb
k(\zeta_{\ell^{n+1}})}(k(\zeta_{\ell^n}))$, or the polynomial
$X^\ell-a^{-1}$ is irreducible in $\phi_{k(\zeta_{\ell^m})\emb
k(\zeta_{\ell^{n+1}})}(k(\zeta_{\ell^n}))[X]$, so computing an $\ell$-th
root of $a^{-1}$ is sufficient. In the case where $r_{\ell^{n+1}}=r_{\ell^n}$,
there is only one of the $\ell$ possible roots $\zeta_{\ell^{n+1}}$ such that
$a$ is a $\ell$-th power, at least for $\ell\neq2$.

More generally, in the case of embeddings
$\mathbb{F}_{p^{\ell^m}}\emb\mathbb{F}_{p^{\ell^n}}$, with $m<n$ two integers, we can similarly define
\[
\begin{array}{cccc}
  N_{\ell^{n}/\ell^m,\, \bm{\ell^{n}}}: & A_{\bm{\ell^{n}}} & \to &
  A_{\bm{\ell^{n}}} \\
  & \gamma & \mapsto & \prod_{j=0}^{\ell^{n-m}-1} (1 \otimes
  \sigma^{jr_{\ell^m}})(\gamma)
\end{array}
\]
and
\[
  \Phi_{A_{\ell^m}\emb A_{\ell^n}}(\alpha_{\ell^m})\eqdef
  N_{\ell^n/\ell^m}(\alpha_{\ell^{n}}).
\]
We see that the norms are transitive, \ie for each triple of integers $m, n, o$
such that $m<n<o$,
we have
\[
  N_{\ell^o/\ell^m}=N_{\ell^{n}/\ell^{m}}\circ N_{\ell^o/\ell^n}.
\]
These ``norms'' commute with the morphisms of algebra $\Phi$, so we obtain
\[
  \Phi_{A_{\ell^m}\emb A_{\ell^o}}(\alpha_{\ell^m}) = \Phi_{A_{\ell^{n}}\emb
A_{\ell^{o}}}\circ \Phi_{A_{\ell^{m}}\emb
A_{\ell^{n}}}(\alpha_{\ell^m}).
\]
And as a corollary we obtain that the embeddings between the finite fields of
the $\ell$-adic tower obtained via $\Phi$ are compatible.

\section{Composita using norms, $\ell\neq2$}

The considerations in Section~\ref{sec:ladic} generalize to the case of
embeddings between composita, but depending on the nature of the composita,
there can be more or less additionnal work.

\subsection{Composita without new primes}
\label{sec:comp-norm-wo}

Let $m, n\in\mathbb{N}$
two integers such that $m\,|\,n$ and such that for all prime $\ell$ such that
$\ell\,|\,n$, we also have $\ell\,|\,m$. In other words, we want $m$ and $n$ to
have the same set of primes in their factorization. Our goal is to extend the
results of Section~\ref{sec:ladic} to the embedding
$\mathbb{F}_{p^m}\emb\mathbb{F}_{p^n}$. Let us note
\[
  m = \prod_i \ell_i^{\alpha_i}
\]
the factorization of $m$ into primes. For now, we also assume that for all $i$,
we have
\[
  \alpha_i\geq h(\ell_i)
\]
where, for any prime $\ell$,
\[
  h(\ell) = v_\ell(p^{r_\ell}-1)
\]
with $v_\ell$ being the $\ell$-adic valuation and
$r_\ell=\omega_{(\mathbb{Z}/\ell\mathbb{Z})^\times}(p)$ is the multiplicative
order of $p$ in the group $(\mathbb{Z}/\ell\mathbb{Z})^\times$, meaning that
$r_\ell$ is the number such that we have
\[
  k(\zeta_\ell)=\mathbb{F}_p(\zeta_\ell)=\mathbb{F}_{p^{r_\ell}},
\]
where $\zeta_\ell$ refers to a $\ell$-th primitive root of unity.
In the end, these numbers mean that given an integer $\nu\in\mathbb{N}$, if
$1\leq\nu\leq h(\ell)$, we have
\[
  k(\zeta_{\ell^\nu}) = \mathbb{F}_{p^{r_\ell}},
\]
and if $\nu\geq h(\ell)$, we have
\[
  k(\zeta_{\ell^\nu}) = \mathbb{F}_{p^{\ell^{\nu-h(\ell)}\times r_\ell}}.
\]
Since $r_\ell\leq\ell-1$, these conditions on $n$ and $m$ are equivalent to the fact that
\[
  [k(\zeta_n):k(\zeta_m)] = n/m.
\]

We define $A_n=\mathbb{F}_{p^n}\otimes k(\zeta_n)$ and
\[
\begin{array}{cccc}
  N_{n/m}: & A_n & \to & A_n \\
  & \gamma & \mapsto & \prod_{j=0}^{n/m-1} (1\otimes \sigma^{jd})(\gamma)
\end{array}
\]

where $d$ is the degree of the extension $k(\zeta_m)$ over $k$. We embed
$k(\zeta_m)$ in $k(\zeta_n)$ by sending $\zeta_m$ to $\zeta_n^{n/m}$. With that
choice we have that
\[
  N_{n/m}(1\otimes\zeta_n) = \Phi_{A_m\emb A_n}(1\otimes\zeta_m),
\]
with
\[
  \Phi_{A_m\emb
  A_n}=\phi_{\mathbb{F}_{p^m}\emb\mathbb{F}_{p^n}}\otimes\phi_{k(\zeta_m)\emb
  k(\zeta_n)}.
\]
Indeed, if $n = \ell m$ for a prime $\ell$ dividing $m$, the arguments of
Section~\ref{sec:ladic} still hold and the more general case follows by
transitivity of the ``norm'' $N$, \ie given $m\,|\,n\,|\,o$, we have
$N_{o/m}=N_{n/m}\circ N_{o/n}$. As in the previous section, we see that
$N_{n/m}$ is multiplicative and that if $\beta\in A_n$ is a nonzero solution of
the Hilbert 90 problem in $A_n$ for $1\otimes\zeta_n$, then $N_{n/m}(\beta)$ is
an element of $A_m$ and is a nonzero solution of Hilbert 90 for
$1\otimes\zeta_m$. Therefore, as the solutions of Hilbert 90 in $A_m$ for
$1\otimes\zeta_m$ form a dimension one $k(\zeta_m)$-vector space and since
$N_{n/m}$ is the usual norm of the extension $k(\zeta_n)$ over $k(\zeta_m)$
(which is surjective) on the right part of $A_n=\mathbb{F}_{p^n}\otimes
k(\zeta_n)$, we can conclude that the compatibility can be achieved, as in
Section~\ref{sec:ladic}\footnote{So here we just say that we can achieve to
  obtain an element $\alpha_n\in A_n$ such that
  $N_{n/m}(\alpha_n)=\Phi(\alpha_m)$ for a certain $m\,|\,n$, and that it is
  possible for all choice of $m$, but it \emph{does not} mean that we can do it
simultaneously for all $m$.}.

Now, if we have one $i$ with $\alpha_i\leq h(\ell_i)$, it is not clear how to
extend the results of the last section.

\subsection{Composita with new primes}
\label{sec:comp-norm-w}

\section{Composita using chinese remainder}
\label{sec:comp-crt}

As we saw in Section~\ref{sec:comp-norm-wo}, if we use only norms, we can
compatibly embed finite fields $\mathbb{F}_{p^m}\emb\mathbb{F}_{p^n}$ if
$[k(\zeta_n):k(\zeta_m)]=n/m$. We will now present a different technique that
still uses norms on the different towers of $\ell$-adic extensions, but
constructs the composita using chinese remainder. Let us start with a simple
example. We let $\ell\in\mathbb{N}$ and $m\in\mathbb{N}$ be two different prime numbers and we will
investigate the compatibility of the embeddings between $\mathbb{F}_{p^\ell}$,
$\mathbb{F}_{p^{\ell m}}$ and $\mathbb{F}_{p^{\ell^2 m^2}}$. Let $u_1, u_2, v_1,
v_2\in \mathbb{N}$ be integers such that
\[
  u_1\ell+u_2m=1
\]
\[
  v_1\ell^2+v_2m^2=1.
\]
Let $\zeta_\ell$ (resp. $\zeta_m$) be a $\ell$-th (resp. $m$-th) primitive root
of unity. Using the construction described in Section~\ref{sec:ladic}, we denote
by $\zeta_{\ell^2}$ (resp. $\zeta_{m^2}$) an $\ell^2$-th (resp. $m^2$-th)
primitive root of unity and $\alpha_{\ell^2}\in A_{\ell^2}$ (resp.
$\alpha_{m^2}\in A_{m^2}$) a nonzero solution of Hilbert $90$ in $A_{\ell^2}$
for $1\otimes\zeta_{\ell^2}$ (resp. in $A_{m^2}$ for $1\otimes\zeta_{m^2}$) such that
\[
  N_{\ell^2/\ell}(\alpha_{\ell^2})=\Phi_{A_\ell\emb A_{\ell^2}}(\alpha_\ell)
\]
\[
  N_{m^2/m}(\alpha_{m^2})=\Phi_{A_m\emb A_{m^2}}(\alpha_m).
\]
We also define\footnote{This is an abuse of notation.}
\[
  \zeta_{\ell m}=\zeta_\ell^{u_2}\zeta_{m}^{u_1}
\]
and
\[
  \zeta_{\ell^2 m^2}=\zeta_{\ell^2}^{v_2}\zeta_{m^2}^{v_1},
\]
so that $\zeta_{\ell m}^\ell = \zeta_m$, $\zeta_{\ell m}^\ell=\zeta_m$,
$\zeta_{\ell^2m^2}^{\ell^2}=\zeta_{m^2}$ and $\zeta_{\ell^2
m^2}^{m^2}=\zeta_{\ell^2}$, and
\[
  \alpha_{\ell m}=\Phi_{A_\ell\emb A_{\ell m}}(\alpha_\ell)^{u_2}\Phi_{A_m\emb
    A_{\ell m}}(\alpha_m)^{u_1}
\]
\[
  \alpha_{\ell^2 m^2}=\Phi_{A_{\ell^2}\emb A_{\ell^2
  m^2}}(\alpha_{\ell^2})^{v_2}\Phi_{A_{m^2}\emb
  A_{\ell^2 m^2}}(\alpha_{m^2})^{v_1}
\]
where the images of the maps $\Phi$ are obtained using Allombert's algorithm.

With these definitions, we get:
\begin{align*}
  \alpha_{\ell m}^m &= \Phi_{A_\ell\emb A_{\ell m}}(\alpha_\ell)^{u_2m}\Phi_{A_m\emb
    A_{\ell m}}(\alpha_m)^{u_1m} \\
  &= \Phi_{A_\ell\emb A_{\ell m}}(\alpha_\ell)^{1-u_1\ell}\Phi_{A_m\emb
    A_{\ell m}}(\alpha_m)^{u_1m} \\
    &= \left( \cfrac{\Phi_{A_m\emb A_{\ell m}}(\alpha_{m}^m)}{\Phi_{A_\ell\emb A_{\ell
    m}}(\alpha_\ell^\ell)}\right)^{u_1} \Phi_{A_\ell\emb A_{\ell
    m}}(\alpha_\ell).
\end{align*}

We then define
\[
\begin{array}{cccc}
  C_{\ell m/\ell,\, \bm{\ell m}}: & A_{\bm{\ell m}} & \to & A_{\bm{\ell m}} \\
  & x & \mapsto & \left( \cfrac{\Phi_{A_{\ell}\emb A_{\bm{\ell
  m}}}(\alpha_{\ell}^{\ell})}{\Phi_{A_{m}\emb A_{\bm{\ell
  m}}}(\alpha_{m}^{m})}\right)^{u_1} x^{m},
\end{array}
\]
or simply $C_{\ell m/\ell}$ if there is no ambiguity about the domain of the
map. With this definition, we obtain
\[
  C_{\ell m/\ell}(\alpha_{\ell m}) = \Phi_{A_{\ell}\emb A_{\ell
  m}}(\alpha_{\ell}),
\]
and we similarly define $C_{\ell m/m}$, $C_{\ell^2m^2/\ell^2}$, and
$C_{\ell^2m^2/m^2}$. We also define
\[
  C_{\ell^2m^2/\ell m}(\cdot) = \left(N_{\ell^2/\ell,\,\bm{\ell^2m^2}}\circ
  C_{\ell^2m^2/\ell^2}(\cdot)\right)^{u_2}\times \left(N_{m^2/m,\,\bm{\ell^2m^2}}\circ
  C_{\ell^2m^2/m^2}(\cdot)\right)^{u_1}
\]
and
\[
  \Phi_{A_{\ell m}\emb A_{\ell^2 m^2}}(\alpha_{\ell m})\eqdef C_{\ell^2m^2/\ell
  m}(\alpha_{\ell^2m^2}).
\]
We then have
\begin{align*}
  N_{\ell^2/\ell,\,\bm{\ell^2m^2}}\circ C_{\ell^2m^2/\ell^2}(\alpha_{\ell^2m^2})
  &= N_{\ell^2/\ell,\,\bm{\ell^2m^2}}(\Phi_{A_{\ell^2}\emb
  A_{\ell^2m^2}}(\alpha_{\ell^2})) \\
  &= \Phi_{A_{\ell^2}\emb
  A_{\ell^2m^2}}(N_{\ell^2/\ell,\,\bm{\ell^2}}(\alpha_{\ell^2})) \\
  &= \Phi_{A_{\ell^2}\emb A_{\ell^2m^2}}\circ\Phi_{A_\ell\emb
    A_{\ell^2}}(\alpha_\ell),
\end{align*}
where the first and the third equality are obtained by definition of
$C_{\ell^2m^2/\ell^2}$ and $N_{\ell^2/\ell}$, and the second equality holds
because the ``norms'' $N$ and the morphims of algebra $\Phi$ commute. We
similarly obtain
\[
  N_{m^2/m,\,\bm{\ell^2m^2}}\circ C_{\ell^2m^2/m^2}(\alpha_{\ell^2m^2}) =
  \Phi_{A_{m^2}\emb A_{\ell^2m^2}}\circ\Phi_{A_m\emb
    A_{m^2}}(\alpha_m),
\]
and so it follows from the definition of $\Phi_{A_{\ell m}\emb
A_{\ell^2m^2}}(\alpha_{\ell m})$ that
\begin{align*}
  \Phi_{A_{\ell m}\emb A_{\ell^2m^2}}(\alpha_{\ell m}) &= \\
  \left(\Phi_{A_{\ell^2}\emb A_{\ell^2m^2}}\circ\Phi_{A_\ell\emb
    A_{\ell^2}}(\alpha_\ell)\right)^{u_2}
    &\times \left(\Phi_{A_{m^2}\emb A_{\ell^2m^2}}\circ\Phi_{A_m\emb
      A_{m^2}}(\alpha_m)\right)^{u_1}.
\end{align*}
Now, we define
\[
  \Phi_{A_{\ell}\emb A_{\ell^2m^2}}\eqdef\Phi_{A_{\ell^2}\emb
  A_{\ell^2m^2}}\circ\Phi_{A_{\ell}\emb A_{\ell^2}},
\]
and we wonder if we have the equality
\[
  \Phi_{A_{\ell}\emb A_{\ell^2m^2}}(\alpha_\ell)\overset{?}{=}\Phi_{A_{\ell
  m}\emb A_{\ell^2m^2}}\circ\Phi_{A_{\ell}\emb A_{\ell m}}(\alpha_\ell).
\]
Then, if we note
\[
  \gamma = \cfrac{\Phi_{A_{\ell}\emb A_{\bm{\ell
  m}}}(\alpha_{\ell}^{\ell})}{\Phi_{A_{m}\emb A_{\bm{\ell
  m}}}(\alpha_{m}^{m})},
\]
we have
\begin{align*}
  \Phi_{A_{\ell m }\emb A_{\ell^2m^2}}(C_{\ell m/\ell}(\alpha_{\ell m})) &=
  \Phi_{A_{\ell m}\emb A_{\ell^2m^2}}(\gamma^{u_1}\alpha_{\ell m}^m)\\
  &= \Phi_{A_{\ell m}\emb A_{\ell^2 m^2}}(\gamma)^{u_1}\Phi_{A_{\ell m}\emb
  A_{\ell^2 m^2}}(\alpha_{\ell m})^{m}\\
  &= \Phi_{A_{\ell^2}\emb A_{\ell^2m^2}}\circ\Phi_{A_{\ell}\emb
  A_{\ell^2}}(\alpha_\ell).
\end{align*}
To obtain the last equality, we use the fact that $\gamma\in k(\zeta_{\ell m})$,
and that the embeddings between the cyclotomic fields $k(\zeta)$ are well
defined and are compatible. In the end we have the wanted equality, that ensures
compatibility between the embeddings of the finite fields $\mathbb{F}_{p^\ell}$,
$\mathbb{F}_{p^{\ell m}}$, and $\mathbb{F}_{p^{\ell^2m^2}}$. Let us now look at
the general case.

\paragraph{General case.} We take three integers $l, m, n\in\mathbb{N}$ such
that
\[
  l\,|\,m\,|\,n
\]
and we assume that they are all coprime with the characteristic $p$. We write
\begin{align*}
  l &=\prod_{i\in\mathfrak{I}}q_i^{a_i}\\
  m &=\prod_{j\in\mathfrak{J}}q_j^{b_j}\\
  n &=\prod_{k\in\mathfrak{K}}q_k^{c_k}
\end{align*}
the prime decomposition of $l$, $m$ and $n$, where the $q$'s are primes, the
sets $\mathfrak I\subset\mathfrak J\subset\mathfrak K$ are some indices sets,
and the coefficients $a_i$, $b_j$ and $c_k$ are integers. We also note $u_i$
some coefficients such that
\[
  \sum_{i\in\mathfrak I}u_i L_i = 1
\]
with
\[
  L_i = \prod_{j\in\mathfrak I,\, j\neq i}q_j^{a_j}.
\]
Similarly, we note
\[
  \sum_{j\in\mathfrak J}v_jM_j = 1
\]
with
\[
  M_j = \prod_{k\in\mathfrak J,\,k\neq j}q_k^{b_k}.
\]
We assume that each $q$-adic tower of extensions of $\mathbb{F}_p$ has a set of
well defined ``norms'' that are compatible, along with roots of unity and
solutions of Hilbert 90, as described in
Section~\ref{sec:ladic}\footnote{The case of $q=2$ is not treated yet, as well
as the first steps in the construction of the tower, where the fact that the
cyclotomic fields may not grow is a problem. Still, we will consider these
norms as black boxes and we will explicitly tell when we use one of their
properties.}. We then define
\[
  \zeta_{l}\eqdef\prod_{i\in\mathfrak
  I}(\zeta_{q_i^{a_i}})^{u_i}\footnote{This is (again) an abuse of notation.}
\]
and
\[
  \alpha_l \eqdef \prod_{i\in\mathfrak I}\Phi_{A_{q_i^{a_i}}\emb
A_l}(\alpha_{q_i^{a_i}})^{u_i}
\]
where the images $\Phi_{A_{q_i^{a_i}}\emb A_{l}}(\alpha_{q_i^{a_i}})$ are
computed using Allombert's algorithm. We similarly define $\zeta_m$, $\alpha_m$,
$\zeta_n$ and $\alpha_n$. With these choices, $\zeta_l$ is a primitive $l$-th
root of unity and $\alpha_l$ is a solution of Hilbert 90 in $A_l$ for the root
$1\otimes\zeta_l$. We also obtain, for any $i\in\mathfrak I$:
\begin{align*}
  \alpha_l^{L_i} &= \prod_{j\in\mathfrak I}\Phi_{A_{q_j^{a_j}}\emb
A_l}(\alpha_{q_j^{a_j}})^{u_jL_i}\\
 &= (\prod_{j\in\mathfrak I,\,j\neq i}\Phi_{A_{q_j^{a_j}}\emb
A_l}(\alpha_{q_j^{a_j}})^{u_jL_i}) \Phi_{A_{q_i^{a_i}}\emb
A_l}(\alpha_{q_i^{a_i}})^{u_iL_i} \\
 &= (\prod_{j\in\mathfrak I,\,j\neq i}\Phi_{A_{q_j^{a_j}}\emb
A_l}(\beta_{q_j^{a_j}})^{u_jL_{i,j}}) \Phi_{A_{q_i^{a_i}}\emb
A_l}(\alpha_{q_i^{a_i}})^{1-\sum_{j\in\mathfrak I,\,j\neq i}u_jL_j} \\
&= (\prod_{j\in\mathfrak I,\,j\neq i}\Bigl(\cfrac{\Phi_{A_{q_j^{a_j}}\emb
A_l}(\beta_{q_j^{a_j}})}{\Phi_{A_{q_i^{a_i}}\emb
A_l}(\beta_{q_i^{a_i}})}\Bigr)^{u_jL_{i, j}})\Phi_{A_{q_i^{a_i}}\emb
A_l}(\alpha_{q_i^{a_i}})
\end{align*}
where $L_{i, j}\eqdef\prod_{k\in\mathfrak I,\, k\neq i, j}q_k^{a_k}$ and
$\beta_{q_j^{a_j}}\eqdef
(\alpha_{q_j^{a_j}})^{q_j^{a_j}}\in1\otimes\mathbb{F}_{p}(\zeta_{q_j^{a_j}})$.
Then, if we note
\[
  \gamma_{i} \eqdef \prod_{j\in\mathfrak I,\,j\neq i}\Bigl(\cfrac{\Phi_{A_{q_j^{a_j}}\emb
A_l}(\beta_{q_j^{a_j}})}{\Phi_{A_{q_i^{a_i}}\emb
A_l}(\beta_{q_i^{a_i}})}\Bigr)^{u_jL_{i,j}},
\]
we also define
\[
  C_{l/q_i^{a_i}}(\alpha_l)\eqdef \gamma_i^{-1}\alpha_l^{L_i}
\]
and we have that
\[
  C_{l/q_i^{a_i}}(\alpha_l)=\Phi_{A_{q_i^{a_i}}\emb
  A_{l}}(\alpha_{q_i^{a_i}}).
\]
We similarly define $C_{m/q_j^{b_j}}(\alpha_m)$ for any $j\in\mathfrak J$ and
$C_{n/q_k^{c_k}}(\alpha_n)$ for any $k\in\mathfrak K$. We are now able to define
\[
  C_{m/l}(\alpha_m) \eqdef\prod_{i\in\mathfrak
  I}N_{q_i^{b_i}/q_i^{a_i},\,\bm{m}}(C_{m/q_i^{b_i}}(\alpha_m))^{u_i}
\]
and we will note $\Phi_{A_l\emb
A_m}=\phi_{\mathbb{F}_{p^l}\emb\mathbb{F}_{p^m}}\otimes\phi_{\mathbb{F}_{p}(\zeta_l)\emb\mathbb{F}_p(\zeta_m)}$ the (well defined) morphism of algebra
such that
\[
  \Phi_{A_l\emb A_m}(\alpha_l) \eqdef C_{m/l}(\alpha_m).
\]
It follows that
\begin{align*}
  \Phi_{A_l\emb A_m}(\alpha_l) &= \prod_{i\in\mathfrak
  I}N_{q_i^{b_i}/q_i^{a_i},\,\bm{m}}(\Phi_{A_{q_i^{b_i}}\emb
A_m}(\alpha_{q_i^{b_i}}))^{u_i}\\
&= \prod_{i\in\mathfrak I}\Phi_{A_{q_i^{b_i}}\emb
A_m}(N_{q_i^{b_i}/q_i^{a_i},\,\bm{q_i^{b_i}}}(\alpha_{q_i^{b_i}}))^{u_i}\\
&= \prod_{i\in\mathfrak I}\Phi_{A_{q_i^{b_i}}\emb
A_m}\circ\Phi_{A_{q_i^{a_i}}\emb A_{q_i^{b_i}}}(\alpha_{q_i^{a_i}})^{u_i}
\end{align*}
since the morphisms of algebra $\Phi$ and the ``norms'' $N$ commute. As done
above, we similarly define $C_{n/m}(\alpha_n)$, $C_{n/l}(\alpha_n)$ and the
morphisms $\Phi_{A_m\emb A_n}$ and $\Phi_{A_l\emb A_n}$. We can now state our
compatibility result.
\begin{prop}
We have the equality
\[
  \Phi_{A_l\emb A_n}(\alpha_l) = \Phi_{A_m\emb A_n}\circ\Phi_{A_l\emb
  A_m}(\alpha_l).
\]
\end{prop}
\begin{proof}
  We have
  \[
    \Phi_{A_m\emb A_n}(\alpha_m)=\prod_{j\in\mathfrak J}\Phi_{A_{q_j^{c_j}}\emb
  A_n}\circ\Phi_{A_{q_j^{b_j}}\emb A_{q_j^{c_j}}}(\alpha_{q_j^{b_j}})^{v_j}
  \]
  and
  \begin{align*}
 \Phi_{A_m\emb A_n}\circ\Phi_{A_l\emb A_m}(\alpha_l)   &= \Phi_{A_m\emb
 A_n}(C_{m/l}(\alpha_m)) \\
 &= \Phi_{A_m\emb A_n}(\prod_{i\in\mathfrak
 I}(N_{q_{i}^{b_i}/q_i^{a_i}}(C_{m/q_i^{b_i}}(\alpha_m))^{u_i})\\
 &= \prod_{i\in\mathfrak I}N_{q_i^{b_i}/q_i^{a_i}}(\Phi_{A_m\emb
 A_n}(C_{m/q_i^{b_i}}(\alpha_m)))^{u_i},
  \end{align*}
  since $\Phi_{A_m\emb A_n}$ is a morsphim of algebra and commute with
  $N_{q_i^{b_i}/q_i^{a_i}}$. For each $i\in\mathfrak I$, we then have
  \begin{align*}
    \Phi_{A_m\emb A_n}(C_{m/q_i^{b_i}}(\alpha_m)) &= \Phi_{A_m\emb
    A_n}(\lambda_i^{-1}\alpha_m^{M_i})\\
    &= \Phi_{A_m\emb A_n}(\lambda_i^{-1})\Phi_{A_m\emb A_n}(\alpha_m)^{M_i},
  \end{align*}
  with
  \[
    \lambda_i\eqdef \prod_{j\in\mathfrak I,\,j\neq i}\Bigl(\cfrac{\Phi_{A_{q_j^{b_j}}\emb
A_m}(\beta_{q_j^{b_j}})}{\Phi_{A_{q_i^{b_i}}\emb
A_m}(\beta_{q_i^{b_i}})}\Bigr)^{v_jM_{i,j}}.
  \]
And finally
  \begin{align*}
    \Phi_{A_m\emb A_n}(\alpha_m)^{M_i} &= \prod_{j\in\mathfrak J}\Phi_{A_{q_j^{c_j}}\emb
  A_n}\circ\Phi_{A_{q_j^{b_j}}\emb A_{q_j^{c_j}}}(\alpha_{q_j^{b_j}})^{v_jM_i}\\
  &= \prod_{j\in\mathfrak J,\,j\neq i}\Bigl(\cfrac{\Phi_{A_{q_j^{c_j}}\emb
  A_n}\circ\Phi_{A_{q_j^{b_j}}\emb A_{q_j^{c_j}}}(\beta_{q_j^{b_j}})}{\Phi_{A_{q_i^{c_i}}\emb
  A_n}\circ\Phi_{A_{q_i^{b_i}}\emb
  A_{q_i^{c_i}}}(\beta_{q_i^{b_i}})}\Bigr)^{v_jM_{i,j}}\\
  &\times\Phi_{A_{q_i^{c_i}}\emb
  A_n}\circ\Phi_{A_{q_i^{b_i}}\emb A_{q_i^{c_i}}}(\alpha_{q_i^{b_i}})\\
  &= \Phi_{A_m\emb A_n}(\lambda_i)\times\Phi_{A_{q_i^{c_i}}\emb
  A_n}\circ\Phi_{A_{q_i^{b_i}}\emb A_{q_i^{c_i}}}(\alpha_{q_i^{b_i}}),
  \end{align*}
  because the elements $\beta$ are all in cyclotomic fields and the embeddings
  are well defined and commute in these fields. In the end we get
  \begin{align*}
  \Phi_{A_m\emb A_n}\circ\Phi_{A_l\emb A_m}(\alpha_l) &= \prod_{i\in\mathfrak
  I}N_{q_i^{b_i}/q_i^{a_i}}(\Phi_{A_{q_i^{c_i}}\emb
A_n}\circ\Phi_{A_{q_i^{b_i}}\emb A_{q_i^{c_i}}}
  (\alpha_{q_i^{b_i}}))^{u_i}\\
&= \prod_{i\in\mathfrak I}\Phi_{A_{q_i^{c_i}}\emb
A_n}\circ\Phi_{A_{q_i^{b_i}}\emb A_{q_i^{c_i}}}\circ\Phi_{A_{q_i^{a_i}}\emb
A_{q_i^{b_i}}}(\alpha_{q_i^{a_i}})^{u_i}\\
&= \prod_{i\in\mathfrak I}\Phi_{A_{q_i^{c_i}}\emb
A_n}\circ\Phi_{A_{q_i^{a_i}}\emb A_{q_i^{c_i}}}(\alpha_{q_i^{a_i}})^{u_i}\\
&= \Phi_{A_l\emb A_n}(\alpha_l).
  \end{align*}
  The last equality is just the definition of $\Phi_{A_l\emb A_n}(\alpha_l)$ and
  the third equality comes from the fact that we know that the morphisms of algebra
  $\Phi$ commute on each $q_i$-adic tower.
\end{proof}
As a corollary, we obtain that the embeddings obtained via the maps $\Phi$ are
compatible.
\section{Techniques using traces}
We notice that we can in fact solve some of our problems using traces too.
\paragraph{In $\ell$-adic towers.} We keep the same notations as in the previous
sections, especially for the roots $\zeta$, the algebras $A$, the solutions of
Hilbert $90$ $\alpha$, the morphisms of algebra $\Phi$, and so on. We construct the roots
of unity in the same way that we used to, meaning that
\[
  (1\otimes\zeta_{\ell^{n+1}})^\ell = \Phi_{A_{\ell^n}\emb
  A_{\ell^{n+1}}}(1\otimes\zeta_{\ell^n}).
\]
Let $\ell\notin \left\{ 2, p \right\}$ be a prime number and
$n\in\mathbb{N}$ some integer. Let $\alpha_{\ell^{n}}\in A_{\ell^{n}}$ be a
solution of Hilbert $90$ for the root $1\otimes\zeta_{\ell^{n}}$ and $\beta\in
A_{\ell^{n+1}}$ a solution in $A_{\ell^{n+1}}$ for the root
$1\otimes\zeta_{\ell^{n+1}}$. We see that
$\beta^\ell$ is a solution of Hilbert $90$ for the root
$(1\otimes\zeta_{\ell^{n+1}})^\ell=\Phi_{A_{\ell^n}\emb
A_{\ell^{n+1}}}(1\otimes\zeta_{\ell^n})$. What we want is to be able to define
$\alpha_{\ell^{n+1}}\in A_{\ell^{n+1}}$ such that
\[
  (\alpha_{\ell^{n+1}})^\ell = \Phi_{A_{\ell^n}\emb
  A_{\ell^{n+1}}}(\alpha_{\ell^n}),
\]
sadly we do not have any warranty that $\beta^{\ell}\in\Phi_{A_{\ell^n}\emb
A_{\ell^{n+1}}}(A_{\ell^n})$, we only know that
$\beta^{\ell}\in\phi_{\mathbb{F}_{p^{\ell^n}}\emb
\mathbb{F}_{p^{\ell^{n+1}}}}(\mathbb{F}_{p^{\ell^n}})\otimes
k(\zeta_{\ell^{n+1}})$. If $k(\zeta_{\ell^{n+1}})=k(\zeta_{\ell^n})$, then the
last remark is not an obstruction and as already claimed, we can find a suitable
root $\zeta_{\ell^{n+1}}$ and a solution satisfying $\alpha_{\ell^{n+1}}$.
Otherwise we can use a trace-like function that sends the scalars into the
smaller field $\phi_{k(\zeta_{\ell^{n}})\emb
k(\zeta_{\ell^{n+1}})}(k(\zeta_{\ell^{n}}))$, as we did before with the
norm-like function. Let us define
\[
\begin{array}{cccc}
  T_{\ell^{n+1}/\ell^n,\, \bm{\ell^{n+1}}}: & A_{\bm{\ell^{n+1}}} & \to &
  A_{\bm{\ell^{n+1}}} \\
  & \sum_{i}x_i\otimes y_i & \mapsto & \sum_i
  x_i\otimes\Tr_{k(\zeta_{\ell^{n+1}})/k(\zeta_{\ell^{n}})}(y_i)
\end{array}
\]
where $\Tr_{k(\zeta_{\ell^{n+1}})/k(\zeta_{\ell^{n}})}$ denotes the usual trace
for the extension $k(\zeta_{\ell^{n+1}})/k(\zeta_{\ell^{n}})$. If the domain of the map is
clear within the given context, we will omit the second index and only note
$T_{\ell^{n+1}/\ell^n}$. Using the fact that $\sigma\otimes1$ and
$T_{\ell^{n+1}/\ell^{n}}$ commute and that $T_{\ell^{n+1}/\ell^n}$ is
$1\otimes\phi_{k(\zeta_{\ell^n})\emb
k(\zeta_{\ell^{n+1}})}(k(\zeta_{\ell^{n}}))$ linear, we see that
$T_{\ell^{n+1}/\ell^n}(\beta^\ell)$ is still a solution of Hilbert $90$ for the
root $\Phi_{A_{\ell^n}\emb A_{\ell^{n+1}}}(1\otimes\zeta_{\ell^n})$ and that
$T_{\ell^{n+1}/\ell^n}(\beta^\ell)\in\Phi_{A_{\ell^n}\emb
A_{\ell^{n+1}}}(A_{\ell^n})$. It follows that we can find an element
$\alpha_{\ell^{n+1}}\in A_{\ell^{n+1}}$ such that
\[
  T_{\ell^{n+1}/\ell^n}((\alpha_{\ell^{n+1}})^\ell) = \Phi_{A_{\ell^{n}}\emb
  A_{\ell^{n+1}}}(\alpha_{\ell^{n}}).
\]
\paragraph{In composita.}

\section{Embeddings between tensor products}
\label{sec:tensor-products}
In this section, we briefly investigate the nature of the injective morphisms of algebra
between tensor products of the form
\[
  A\eqdef\mathbb{F}_{p^{\ell_1}}\otimes
\mathbb{F}_{p^{m_1}}
\]
and
\[
  B\eqdef\mathbb{F}_{p^{\ell_2}}\otimes\mathbb{F}_{p^{m_2}}.
\]
We show that
\begin{prop}
 There exist an injective morphism of algebra $\Phi$ from $A$ to $B$ if and only if
 $\ell_1\,|\,\ell_2$ and $m_1\,|\,m_2$.
\end{prop}
We denote by $\sigma$ the
Frobenius morphism and by $\Phi$ an injective morphism (\ie embedding) of algebra from $A$ to
$B$.

\section{Existence of a compatible lattice}
\label{sec:existence}
We use the same notations as in the previous sections, in particular the
definitions of the maps $\Phi$ and $N$ still hold.
In this section we will investigate the existence of a compatible lattice. We
first define a tower of algebras: let $(d_n)_{n\in\mathbb{N}}$ the sequence
defined by $d_0=1$, $d_1=2$, $d_2=2^2\cdot 3=12$, and more generally
\[
  d_n = \prod_{j=1}^n p_j^{n+1-j}
\]
for $n\geq1$, with $p_j$ the $j$-th prime number. We also define
$D=\left\{d_n\,|\,n\in\mathbb{N}\right\}$. We have
\[
  d_0\,|\,d_1\,|\,d_2\,|\,\cdots\,|\,d_{n-1}\,|\,d_n\,|\,d_{n+1}\,|\,\cdots,
\]
in other words if $a\leq b$, $d_a\,|\,d_b$. These divisibility properties allow
us to define the tower of algebras
\[
  A_{p-1}\emb A_{p^{2}-1}\emb\cdots\emb A_{p^{d_{n-1}}-1}\emb
  A_{p^{d_n}-1}\emb\cdots.
\]
In particular
\[
  A_{p-1}\eqdef
\mathbb{F}_{p^{p-1}}\otimes\mathbb{F}_{p}(\zeta_{p-1})=\mathbb{F}_{p^{p-1}}\otimes\mathbb{F}_p\cong\mathbb{F}_{p^{p-1}}
\]
and for $n\geq1$
\[
  A_{p^{d_n}-1}=\mathbb{F}_{p^{p^{d_n}-1}}\otimes\mathbb{F}_p(\zeta_{p^{d_n}-1})=\mathbb{F}_{p^{p^{d_n}-1}}\otimes\mathbb{F}_{p^{d_n}}.
\]
We know that $\mathbb{F}_{p^{d_n}}$ contains a primitive $(p^{d_n}-1)$-th root
of unity: aby primitive element of $\mathbb{F}_{p^{d_n}}$ is in fact such a
root. That is why we write
$\mathbb{F}_{p^{d_n}}=\mathbb{F}_{p}(\zeta_{p^{d_n}-1})$, but we have not
specified which roots we consider.
We construct the roots of unity in the following way: we first choose any $(p-1)$-th primitive root of unity and we continue by recurrence. Assume we have
chosen a primitive $(p^{d_{n-1}}-1)$-th root of unity
$\zeta_{p^{d_{n-1}}-1}\in\mathbb{F}_{p^{d_{n-1}}}$
for a certain $n\geq1$. By surjectivity of the norm, we can find an element
$y\in\mathbb{F}_{p^{d_n}}$ such that
\begin{align*}
  N_{\mathbb{F}_{p^{d_n}}/\mathbb{F}_{p^{d_{n-1}}}}(y)&=y^{\frac{p^{d_n}-1}{p^{d_{n-1}}-1}}\\
  &=\zeta_{p^{d_{n-1}}-1}.
\end{align*}
Since $\zeta_{p^{d_{n-1}}-1}$ is primitive, $y$ is also primitive, in other
words $y$ is a $p^{d_n}-1$ primitive root of unity, and we define
$\zeta_{p^{d_n}-1}\eqdef y$1.

We now construct solutions of the Hilbert $90$ problem in each floor of our
tower. We first choose any solution $\alpha_{p-1}\in A_{p-1}$ of Hilbert $90$
associated with the root $\zeta_{p-1}$, and we continue by recurrence. Assume we
have constructed a solution $\alpha_{p^{d_{n-1}}-1}\in A_{p^{d_{n-1}}-1}$ of
Hilbert $90$ associated with the root $\zeta_{p^{d_{n-1}}-1}$ for a certain
$n\geq1$. Then, like in the previous sections, we can find a nonzero solution
$\beta\in A_{p^{d_n}-1}$ of the Hilbert $90$ with the root $\zeta_{p^{d_n}-1}$,
and we get
\[
  N_{p^{d_n}-1/p^{d_{n-1}}-1}(\beta)=(1\otimes\lambda)\Phi_{A_{p^{d_{n-1}}-1}\emb
  A_{p^{d_n}-1}}(\alpha_{p^{d_{n-1}}-1}),
\]
where $1\otimes\lambda$ is an element in the subfield $\Phi_{A_{p^{d_{n-1}}-1}\emb
A_{p^{d_n}-1}}(1\otimes\mathbb{F}_{p^{d_{n-1}}})$. Since the map
$N_{p^{d_n}-1/p^{d_{n-1}}-1}$ acts on $1\otimes\mathbb{F}_{p^{d_n}}$ as the
usual norm $N_{\mathbb{F}_{p^{d_n}}/\mathbb{F}_{p^{d_{n-1}}}}$, we can again use
the surjectivity of the norm to ``correct'' our element $\beta$ as was done in
the previous sections. In the end we obtain an element $\alpha_{p^{d_n}-1}$ such
that
\[
  N_{p^{d_n}-1/p^{d_{n-1}}-1}(\alpha_{p^{d_n}-1})=\Phi_{A_{p^{d_{n-1}}-1}\emb
  A_{p^{d_n}-1}}(\alpha_{p^{d_{n-1}}-1}).
\]
Since our norm-like functions $N$ are transitive, the compatibility of the
morphisms of algebra $\Phi$, and the compatibility of the associated morsphims
of fields $\phi$ follows. But we have only constructed algebras of the form
$A_{p^d-1}$ with $d\in D$, so our lattice has a lot of holes. We can first plug
the holes of the form $A_{p^{n}-1}$ for any $n\in\mathbb{N}$ (not just $n\in
D$), by defining
\[
  f_n \eqdef \min\left\{ d\in D\,,\,n\,|\,d \right\}
\]
and\footnote{We should say that
  everything is embedded in a big space for that to make sense.}
\begin{align*}
  \zeta_{p^n-1}&\eqdef  N_{p^{f_n}-1/p^n-1}(\zeta_{p^{f_n}-1})\\
  \alpha_{p^n-1}&\eqdef
  N_{p^{f_n}-1/p^n-1}(\alpha_{p^{f_n}-1}).
\end{align*}
Here again, by transitivity of the norms, we achieve compatibility with the
morphisms of algebra $\Phi$ between algebras of the form $A_{p^n-1}$ for $n\in\mathbb{N}$.

Let us now deal with the general case of two integers $\ell\,|\,m$. We define
$a=\omega_{\mathbb{Z}/\ell\mathbb{Z}}(p)$ (respectively
$b=\omega_{\mathbb{Z}/m\mathbb{Z}}(p)$) the multiplicative order of $p$ in
$\mathbb{Z}/\ell\mathbb{Z}$ (resp. in $\mathbb{Z}/m\mathbb{Z}$). We thus define
\[
  \alpha_\ell\eqdef(\alpha_{p^a-1})^{\frac{p^a-1}{\ell}}\in A_{\ell}=\mathbb{F}_{p^\ell}\otimes \mathbb{F}_{p^a}
\]
and
\[
  \alpha_m\eqdef(\alpha_{p^b-1})^{\frac{p^{b}-1}{m}}\in A_m=\mathbb{F}_{p^m}\otimes \mathbb{F}_{p^b}.
\]
If $a=b$ then we have
\[
  \alpha_{\ell}=\alpha_m^{m/\ell},
\]
but if $a<b$, we need to take additionnal care of the right part of the tensor,
the ``scalar'' part. In that case we have
\[
  \alpha_\ell=N_{p^b-1/p^a-1}((\alpha_{p^b-1})^{\frac{p^a-1}{\ell}})
\]
and we can also write
\begin{align*}
  (\alpha_{p^b-1})^{\frac{p^a-1}{\ell}}&=(\alpha_{p^b-1})^{\frac{p^b-1}{\ell\cdot\frac{p^b-1}{p^a-1}}}\\
  &\eqdef \alpha_{\ell v}.
\end{align*}
with $v\eqdef\frac{p^b-1}{p^a-1}$.

We see that we have an equality linking $\alpha_\ell$ and
$\alpha_{\ell v}$, though the natural thing would be an
equality linking $\alpha_\ell$ and $\alpha_m$. Unfortunately the map
$N_{p^b-1/p^a-1}=N_{m/\ell}$ send $\zeta_{m}$ to
$\zeta_{m}^{v}$, and this is not necessarily an $\ell$-th primitive root of unity.
By starting elsewhere in the tower, namely $\alpha_{\ell v}$ instead of
$\alpha_{\ell \frac{m}{\ell}}$, we ensure that we arrive on the right root of
unity $\zeta_{\ell}$. Note that we do not necessarily have
$\frac{m}{\ell}\,|\,v$.

In fact, we do not have to go \emph{that high} in the tower, but we will risk to
obtain an other primitive $\ell$-th root of unity and we will have to apply
corrections. Let us write
\[
  \ell=\prod_{j\in\mathcal P_\ell}q_j^{\alpha_j}
\]
the prime decomposition of $\ell$, where $\mathcal P_\ell$ is a set of indices
and the $q_j$'s are primes. We also write
\[
  m=\prod_{j\in\mathcal P_m}q_j^{\beta_j}
\]
and it follows that $\mathcal P_\ell\subset\mathcal P_m$ and that for all
$j\in\mathcal P_\ell$, $\alpha_j\leq\beta_j$. Now denote by $\nu_j(v)$ the
$q_j$-adic valuation of $v$. Our problem happens when, for $j\in\mathcal
P_\ell$,
\[
  \nu_j(v)\neq \beta_j-\alpha_j=\nu_j(m/\ell)
\]
because it eliminates too much (or too little) of the $q_j$ part of the root $\zeta_\ell$. That
is why we can consider to go only as high as
\[
  \eta=\prod_{j\in\mathcal
  P_\ell}q_j^{\alpha_j+\nu_j(v)}\times\prod_{j\in\mathcal P_m\setminus \mathcal
  P_\ell}q_j^{\beta_j}.
\]
Indeed, with that choice we elimate just as much of each $q_j$ as we want.

\section{TODO}
\begin{itemize}
  \item How to use traces
  \item Using norms with composita
    \begin{itemize}
      \item what can go bad with roots of unity
      \item how to fix it
    \end{itemize}
\end{itemize}
\end{document}


\section{Global Motion Estimation}
\label{sec:02-gme}
Videos are, at their core, sequences of images called frames; we can spot the motion happening between a given pair of frames by detecting which pixels changed position with respect to that pair of frames.

This information can be encoded in a human-understandable format by presenting the \textit{needle diagram} of the two frames; this kind of representation is shown in \cref{fig:needle-diagram}.

\begin{figure}
    \centering
    \includegraphics[width=.7\linewidth]{../assets/images/bbme-0-res.png}
    \caption{Needle diagram between two frames of a video sequence.}
    \label{fig:needle-diagram}
\end{figure}

It is pretty clear what information this figure is conveying: for each couple of frames we mark with an arrow the shift that the pixel has made. This gives us an indication of the actual movement of the recorded objects.

However, the motion that we are able to extract from the two frames is what is usually called "apparent motion", which is a combination of two different factors:
\begin{itemize}
    \item the global motion, which corresponds to the motion of the camera;
    \item the effective motion of the objects recorded.
\end{itemize}

An important task in computer vision is the global motion estimation, which aims to distinguish these two different types of motion.
In particular, this information is highly important for a number of applications, amongst which we find video coding, motion compensation, object segmentation and egomotion estimation.

The task of distinguishing which movement is to be classified as global motion and which one is to be classified as object motion instead is not so easy. In fact, there is no clear feature that distinguishes the moving objects from the static background, and this leads to the need for complex tools to differentiate the two types of motion.

% Therefore, to model motion we usually assign to each pixel a vector which describes the shift in the coordinates of that pixel.

\subsection{Motion Models}
\label{sec:motion-models}

The main approach to global motion estimation consists in using a motion model to describe the motion of the camera.

% What is a motion model?
Motion models describe the motion of the entire visual field through an equation. Basically, the underpinning idea is to write an equation which, given a pixel in a certain position $(x,y)$, returns the position that the same pixel will have in the next frame, if its motion is due only to camera motion.

There is a number of motion models that can be used to describe global motion, ranging from very simple translational models - that can describe only translation motion - to more complex models, allowing to describe pan, tilt, zoom and roll motion patterns. The reader can use as reference \cref{fig:camera-motion} as an illustration of these types of motion.

\begin{figure}
    \centering
    \includegraphics[width=.9\linewidth]{../assets/images/camera-movement.png}
    \caption{Different types of camera motion. Source: \url{https://cinestudy.org/2020/06/29/camera-movement/}.}
    \label{fig:camera-motion}
\end{figure}

All the motion models are defined as functions of some parameters; to get the camera motion in a certain sequence we need to estimate the parameters of the motion model for that precise sequence. Taking as example the motion model we used in this project - the affine motion model - and all the models that describe a rigid motion, the shift in the position of a pixel can be described as in \cref{eq:affine-model-representation}.

\input{../assets/math/affine-model-representation.tex}

Here $p'$ represents the position of the pixel after the camera motion. The matrix $R$ is used to describe rotation and the vector $T$ for the translation component.

The affine motion model can describe simple motions that can be described by linear functions as translation, rotation and zooming (see \cite{Ren20} for in depth explanation).

Usually the affine model is used under the assumptions that the rotation and translation are on the image plane, and that depth $Z$ is approximately constant (as from \cite{WangBook}); these assumptions are reasonable as long as the motion occurring between the two frames we are analyzing is not too large.
Under these assumptions, the affine model can be represented as \cref{eq:affine-model-direct-estimation}, where we need to estimate the 6 parameters $a =[a_1, a_2, a_3, b_1, b_2, b_3 ]$.

\input{../assets/math/affine-model-direct-estimation.tex}

\subsection{Parameter Estimation}
There are two different approaches to estimate the parameters of a motion model:
\begin{itemize}
    \item a direct approach, which computes the best parameters by optimizing an overdetermined system in the pixel domain;
    \item an indirect approach, which minimizes the approximation error between the motion field obtained with an estimation and the motion field obtained by the motion model.
\end{itemize}

The first approach derives from the equation of the optical flow; in the case of the affine model, it describes the motion of each pixel as in \cref{eq:affine-model-direct-estimation}.
This equation can be applied to any subset of pixels of the frames, therefore the system turns out to be overdetermined and we can solve it using some optimization method, for instance gradient descent.

The second approach - indirect estimation - aims to minimize some error measure between the ground truth motion field and the motion field returned by the motion model.

Therefore, indirect estimation needs, as a preprocessing step, to get the motion field from a motion estimation method - e.g. block-based motion estimation. This motion field is then used as \textit{ground truth} to find the parameters of the motion model that minimize some error measure between this motion field and the one returned by the motion model.

An aspect of this procedure worth highlighting is that it works on the motion field rather than directly on the pixel domain. Hence, it can compute motion of blocks instead of single pixels, reducing the overall complexity of the procedure.

The process is summarized in \cref{eq:indirect-estimation}, where
\begin{itemize}
    \item $a$ is the parameter vector;
    \item $p$ is the single pixel (or block);
    \item $gt(p)$ is the ground truth motion vector for $p$;
    \item $MM(p,a)$ is the motion vector that the motion model would predict for $p$ with parameters $a$;
    \item $E$ is some error measure that accounts for the difference between the two motion vectors, usually a \(p\)-norm distance.
\end{itemize}

\input{../assets/math/indirect-estimation.tex}

Once we minimize \cref{eq:indirect-estimation}, we obtain the values of the parameter vector $a$ that encode the camera motion of the video sequence we are analyzing.

\subsection{Robust Estimation}
Since motion in video sequences can be pretty fast and complex, it is often the case that some parts of the scene move in such a way that they insert noise in the motion estimation process.
In particular, it is quite expected to find fast moving objects which we refer to as \emph{outliers}: they are objects manifesting some kind of intrinsic motion - not caused by camera motion - which pollutes the estimation of the parameters of the motion model.

In order to solve this problem, a common approach is to introduce some strategy to remove the outliers from the motion estimation process and, consequently, obtain a robust estimation of the motion field.


\section{Explicit recursion}
\label{sec-explicit-recursion}

% There are two ways to define the representation of values. Those that have information about which fields of the constructors of the datatype in question are recursive versus those that do not.

The previous implementation of the \texttt{length} function is implemented for a shallow representation. A shallow representation means that the recursion of the datatype is not explicitly marked. Therefore, we can only convert one layer of the value into a generic representation using the \texttt{from} function.

Alternatively, by marking the recursion of the datatype explicitly, also called the deep representation, the entire value can be converted into a generic representation in one go. To mark the recursion, a fixed-point operator (\texttt{Fix}) is introduced. Then, using the fixed-point operator we can define a from function that given the pattern functors have an instance of Functor\footnote{The Functor instances for the pattern functors can be found in Section \ref{app-inst-functor-patfun}}, return a generic representation of the entire value.

\begin{minted}{haskell}
data Fix f = In { unFix :: f (Fix f) }

deepFrom :: (Regular a, Functor (PF a)) => a -> Fix (PF a)
deepFrom = In . fmap deepFrom . from
\end{minted}

Subsequently, we can define a \texttt{cata} function which can use the explicitly marked recursion by applying a function at every level of the recursion. Then using the \texttt{cata} function we can define the same \texttt{length} function as in the previous section, but just in a single line. However, this deep representation does come at the cost that the implementation is less efficient than the shallow representation.

\begin{minted}{haskell}
cata :: Functor f => (f a -> a) -> Fix f -> a
cata = f . fmap (cata f) . unFix

length' :: (Regular a, GLength (PF a), Functor (PF a), Foldable (PF a))
        => a -> Int
length' = cata ((1+) . sum) . deepFrom
\end{minted}


% !TeX root = ../main.tex
\documentclass[../main.tex]{subfiles}
\begin{document}
\section{Model Parametrization}
\begin{definition}\label{M:Parameter}
For any point matrix \(\tensor{X^\pm_{\lambda,n}\left(\theta,\phi_1,\phi_2,\dots,\phi_n\right)}{}\),
\(n\)-dimensional vector \(\tensor{\theta}{}\)
is defined as\textit{position parameter}.
\end{definition}
\begin{definition}\label{M:Vector}
For point matrix \(\tensor{X}{}\),
\(\left(n+1\right)\)-dimensional column vector \(\tensor{p}{}\coloneqq\frac{1}{\lambda}\tensor{X}{}\cdot\tensor{e}{^1}=\frac{1}{\lambda}\tensor{X}{_1}\)
is defined as\textit{position vector}.
\end{definition}
\begin{definition}\label{M:Vector:Set}
\(P^\ast\left(\lambda,n\right)\) is a set of position vectors.
\end{definition}
\begin{lemma}\label{M:Vector:Position}
For point matrix \(X=PO\)
where \(P\) and \(O\) are position and orientation matrix respectively,
\(\tensor{p}{}=\frac{1}{\lambda}\tensor{X}{_1}=\frac{1}{\lambda}\tensor{P}{_1}\).
\end{lemma}
\begin{proof}[\proofof{M:Vector:Position}]
\begin{align*}
\tensor{p}{^i}
&=\frac{1}{\lambda}\tensor{X}{^i_1}&&\text{\cref{M:Vector}}\\
&=\frac{1}{\lambda}\sum_j{\tensor{P}{^i_j}\tensor{O}{^j_1}}&&\text{\cref{Matrix:Product}}\\
&=\frac{1}{\lambda}\tensor{P}{^i_1}&&\text{\cref{M:Orientation}}\\
\tensor{p}{}
&=\frac{1}{\lambda}\tensor{P}{_1}&&\qedhere
\end{align*}
\end{proof}
\begin{lemma}\label{M:Vector:Value}
Given position parameter \(\tensor{\theta}{}\), position vector can be evaluated as the following.
\[
\psi_0^{-1}\colon\tensor{\theta}{}\mapsto\tensor{p}{}
=\frac{1}{\lambda}
\begin{pmatrix}
\prod_{j\in\Set{1..n}}{\cos_\lambda{\tensor{\theta}{^j}}}\\
\sin_\lambda{\tensor{\theta}{^{i-1}}}\prod_{j\in\Set{i..n}}{\cos_\lambda{\tensor{\theta}{^j}}}\\
\sin_\lambda{{\tensor{\theta}{^n}}}\\
\end{pmatrix}\text{.}
\]
\end{lemma}
\begin{proof}[\proofof{M:Vector:Value}]
Simplify \cref{M:Vector:Position,M:Position}.
\end{proof}
\begin{lemma}\label{M:Parameter:Value}
Given position vector \(\tensor{p}{}\), position parameter can be calculated as the following.
\begin{align*}
\psi_0
&\colon\tensor{p}{}\mapsto\tensor{\theta}{}
=
\begin{pmatrix}
\arcsin_\lambda^{\sign{\frac{1}{\lambda}\tensor{p}{^1}}}{\frac{\tensor{p}{^2}}{\prod_{j\in\Set{2..n}}{\cos_\lambda{\tensor{\theta}{^j}}}}}\\
\arcsin_\lambda{\frac{\frac{1}{\lambda}\tensor{p}{^{i+1}}}{\prod_{j\in\Set{i+1..n}}{\cos_\lambda{\tensor{\theta}{^j}}}}}\\
\arcsin_\lambda{\frac{1}{\lambda}\tensor{p}{^{n+1}}}\\
\end{pmatrix}\\
&\in
\begin{cases}
P\to\left(-\frac{\pi}{\lambda},\frac{\pi}{\lambda}\right]\times\left[-\frac{1}{2}\frac{\pi}{\lambda},\frac{1}{2}\frac{\pi}{\lambda}\right]^{n-1}&\text{if \(\lambda>0\)}\\
P\to\R^{n}&\text{if \(\lambda\le0\)}\\
\end{cases}
\end{align*}
where \(\cos_\lambda\left(\arcsin_\lambda^{\pm}\left(x\right)\right) =\pm\cos_\lambda\left(\arcsin_\lambda\left(x\right)\right)\).
\end{lemma}
\begin{proof}[\proofof{M:Parameter:Value}]
From \cref{M:Vector:Value},
\begin{align*}
\tensor{p}{}
&=\frac{1}{\lambda}
\begin{pmatrix}
\prod_{j\in\Set{1..n}}{\cos_\lambda{\tensor{\theta}{^j}}}\\
\sin_\lambda{\tensor{\theta}{^{i-1}}}\prod_{j\in\Set{i..n}}{\cos_\lambda{\tensor{\theta}{^j}}}\\
\sin_\lambda{{\tensor{\theta}{^n}}}\\
\end{pmatrix}\\
\frac{1}{\lambda}\sin_\lambda{{\tensor{\theta}{^n}}}&=\tensor{p}{^{n+1}}\\
\tensor{\theta}{^n}&=\arcsin_\lambda{\lambda\tensor{p}{^{n+1}}}\\
\frac{1}{\lambda}\sin_\lambda{\tensor{\theta}{^{i-1}}}\prod_{j\in\Set{i..n}}{\cos_\lambda{\tensor{\theta}{^j}}}&=\tensor{p}{^{i}}\\
\sin_\lambda{\tensor{\theta}{^{i-1}}}&=\frac{\lambda\tensor{p}{^{i}}}{\prod_{j\in\Set{i..n}}{\cos_\lambda{\tensor{\theta}{^j}}}}\\
\tensor{\theta}{^{i-1}}&=\arcsin_\lambda{\frac{\lambda\tensor{p}{^{i}}}{\prod_{j\in\Set{i..n}}{\cos_\lambda{\tensor{\theta}{^j}}}}}\\
\tensor{\theta}{^i}&=\arcsin_\lambda{\frac{\lambda\tensor{p}{^{i+1}}}{\prod_{j\in\Set{i+1..n}}{\cos_\lambda{\tensor{\theta}{^j}}}}}\\
\tensor{p}{^1}&=\frac{1}{\lambda}\prod_{j\in\Set{1..n}}{\cos_\lambda{\tensor{\theta}{^j}}}\\
\cos_\lambda{\tensor{\theta}{^1}}\prod_{j\in\Set{2..n}}{\cos_\lambda{\tensor{\theta}{^j}}}&=\lambda\tensor{p}{^1}\\
\sign\cos_\lambda{\tensor{\theta}{^1}}\prod_{j\in\Set{2..n}}\sign{\cos_\lambda{\tensor{\theta}{^j}}}&=\sign\lambda\sign\tensor{p}{^1}\\
\sign\cos_\lambda{\tensor{\theta}{^1}}\prod_{j\in\Set{2..n}}{+1}&=\sign\lambda\sign\tensor{p}{^1}\\
\sign\cos_\lambda{\tensor{\theta}{^1}}&=\sign\lambda\sign\tensor{p}{^1}\\
\theta&=\begin{pmatrix}
\arcsin_\lambda^{\sign\lambda\sign{\tensor{p}{^1}}}{\frac{\tensor{p}{^2}}{\prod_{j\in\Set{2..n}}{\cos_\lambda{\tensor{\theta}{^j}}}}}\\
\arcsin_\lambda{\frac{\tensor{p}{^{i+1}}}{\prod_{j\in\Set{i+1..n}}{\cos_\lambda{\tensor{\theta}{^j}}}}}\\
\arcsin_\lambda{\tensor{p}{^{n+1}}}\\
\end{pmatrix}
\end{align*}
\end{proof}
\begin{lemma}\label{M:CoordinateChart}
\[
\Psi=\Set{\psi|
\psi^{-1}
\in S^n\to P
\colon\tensor{\theta}{}\mapsto P_{\lambda,n}\left(\tensor{\theta}{}+\tensor{x}{}\right)
\text{ for }
\tensor{x}{}\in\R^n
}
\] is a coordinate chart of a \(C^\infty\) differential structure on \(P\)
for\[
S=
\begin{cases}
\left(-\frac{1}{2}\frac{\pi}{\lambda},+\frac{1}{2}\frac{\pi}{\lambda}\right)&\text{\(\lambda>0\)}\\
\R&\text{\(\lambda\le0\)}
\end{cases}
\]
\end{lemma}
\begin{proof}[\proofof{M:CoordinateChart}]
From \cref{Manifold}, It is sufficient to shows that
\begin{APAenumerate}
\item \(R_\psi\) is an open subset of real vector space (defined),
\item \(\bigcup_{\psi\in\Psi} D_\psi=P\) (obvious),
\item transition map is in differentability class \(C^\infty\).
\end{APAenumerate}
\begin{subproof}{\(\bigcup_{\psi\in\Psi} D_\psi=P\)}
\begin{align*}
M\in P
&\implies\exists\theta_0, M=P_{\lambda,n}\left(\theta_0\right)\\
&\implies\exists\theta_0, M=P_{\lambda,n}\left(0 +\theta_0\right)\\
&\implies M\in R_{\psi^{-1}}\\
&\implies M\in D_{\psi}\\
&\implies M\in\bigcup_{\psi\in\Psi} D_\psi\\
P&\subset\bigcup_{\psi\in\Psi}D_\psi\\
M\in\bigcup_{\psi\in\Psi} D_\psi
&\implies\exists\psi\in\Psi, M\in D_\psi\\
&\implies\exists\psi\in\Psi, M\in R_{\psi^{-1}}\\
&\implies\exists x_0\exists\theta\in S^n, M=P_{\lambda,n}\left(\theta+x_0\right)\\
&\implies\exists x_0, M=P_{\lambda,n}\left(0+x_0\right)\\
&\implies\exists x_0, M=P_{\lambda,n}\left(x_0\right)\\
&\implies M\in P\\
\bigcup_{\psi\in\Psi}D_\psi&\subset P\\
\bigcup_{\psi\in\Psi} D_\psi&= P
\end{align*}
\end{subproof}
\begin{subproof}{every transition map is in differentability class \(C^\infty\)}
Consider \(\psi_1,\psi_2\in\Psi\) and \(x_1, x_2\in\R^n\) where
\[
\psi_i^{-1}
\in S^n\to R
\colon\tensor{\theta}{}\mapsto P\left(\tensor{\theta}{}+x_i\right)
\text{.}
\]
If \(\psi_1^{-1}\left(\theta_1\right)=\psi_2^{-1}\left(\theta_2\right)\),
\begin{align*}
\psi_1^{-1}\left(\theta_1\right)
&=\psi_2^{-1}\left(\theta_2\right)\\
\psi_0^{-1}\left(\theta_1+x_1\right)
&=\psi_0^{-1}\left(\theta_2+x_2\right)\\
\psi_0^{-1}\left(\phi_1\right)
&=\psi_0^{-1}\left(\phi_2\right)&\text{(Let \(\phi_i =\theta_i+x_i\))}\\
\frac{1}{\lambda}
\begin{pmatrix}
\prod_{j\in\Set{1..n}}{\cos_\lambda{\tensor{{\phi_1}}{^j}}}\\
\sin_\lambda{\tensor{{\phi_1}}{^{i-1}}}\prod_{j\in\Set{i..n}}{\cos_\lambda{\tensor{{\phi_1}}{^j}}}\\
\sin_\lambda{{\tensor{{\phi_1}}{^n}}}\\
\end{pmatrix}
&=
\frac{1}{\lambda}
\begin{pmatrix}
\prod_{j\in\Set{1..n}}{\cos_\lambda{\tensor{{\phi_2}}{^j}}}\\
\sin_\lambda{\tensor{{\phi_2}}{^{i-1}}}\prod_{j\in\Set{i..n}}{\cos_\lambda{\tensor{{\phi_2}}{^j}}}\\
\sin_\lambda{{\tensor{{\phi_2}}{^n}}}\\
\end{pmatrix}&\text{\cref{M:Vector:Value}}\\
\begin{pmatrix}
\prod_{j\in\Set{1..n}}{\cos_\lambda{\tensor{{\phi_1}}{^j}}}\\
\sin_\lambda{\tensor{{\phi_1}}{^{i-1}}}\prod_{j\in\Set{i..n}}{\cos_\lambda{\tensor{{\phi_1}}{^j}}}\\
\sin_\lambda{{\tensor{{\phi_1}}{^n}}}\\
\end{pmatrix}
&=
\begin{pmatrix}
\prod_{j\in\Set{1..n}}{\cos_\lambda{\tensor{{\phi_2}}{^j}}}\\
\sin_\lambda{\tensor{{\phi_2}}{^{i-1}}}\prod_{j\in\Set{i..n}}{\cos_\lambda{\tensor{{\phi_2}}{^j}}}\\
\sin_\lambda{{\tensor{{\phi_2}}{^n}}}\\
\end{pmatrix}
\end{align*}
If \(\lambda\ge 0\), by mathematical induction, \(\phi_1=m\frac{\pi}{\lambda}\pm\phi_2\).
If \(\lambda\le 0\), by mathematical induction, \(\phi_1 =\phi_2\).
Hence, the transition map \(\tau_{1,2} =\psi_2\circ\psi_1^{-1}\)
is in the form of linear function \(\theta\mapsto c\pm\theta\)
and is in differentability class \(C^\infty\).
\end{subproof}
\end{proof}
\subsection{Locus of position vector}
\begin{lemma}\label{SphericalLocus}
For \(\lambda>0\), \(P\) is a \(\left(n+1\right)\)-sphere of radius \(\abs{\lambda}^{-1}\).
\end{lemma}
\begin{proof}[\proofof{SphericalLocus}]
Simplify \cref{M:Vector:Value} using \cref{M:Trigonometry:Pythagorean}.
\end{proof}
\begin{lemma}\label{HyperbolicLocus}
For \(\lambda<0\), \(P\) is a backward sheet of a two-sheeted \(\left(n+1\right)\)-hyperboloid of radius \(\abs{\lambda}^{-1}\).
\end{lemma}
\begin{proof}[\proofof{HyperbolicLocus}]
Simplify \cref{M:Vector:Value} using \cref{M:Trigonometry:Pythagorean}.
\end{proof}
\begin{lemma}\label{EuclideanLocus}
For \(\lambda\to0\), \(P\) is a \(n\)-Euclidean plane at \(\tensor{p}{^1}=\infty\).
\end{lemma}
\begin{proof}[\proofof{EuclideanLocus}]
Using limits.
\end{proof}
\end{document}


% -*- TeX-master: "master.tex" -*-

\setcounter{section}{8}
\setcounter{subsection}{1}
\subsection{Type algebra, Curry-Howard-Lambek isomorphism}

\subsubsection{Type algebra}

We have learned the correspondence between some categorical structures and
algebra.

\begin{figure}[h]
\centering
\begin{tabular}{ll}
\hline
Algebra      & Categorical Structure         \\ \hline
$a + b$      & Coproduct                     \\
$a \times b$ & Product                       \\
$a^b$        & Exponential (Function Object) \\ \hline
\end{tabular}
\caption{Categorical representation of algebra operations}
\end{figure}

Now we figure out how to do algebra in the category of types. Look at this
algebra expression,

\[
  a^{b+c} = a^b \times a^c
\]

This is essentially saying that \code{Either b c -> a} is equivalent to a pair
of functions \code{(b -> a, c -> a)}. We can do case analysis: Either type gives
one of its params, if given parameter is \code{b}, it should call function
\code{b -> a}; if given \code{c}, it should call \code{c -> a}. It works. It's
easy to show the other way around from \code{(b -> a, c -> a)} to \code{Either b
  c -> a}.

Let's see the next one,

\[
  (a^b)^c = a^{b\times c}
\]

It should be easy to recognize this pattern is exactly what currying does, that
is, \code{c -> (b -> a)} is equivalent to \code{(b, c) -> a}.

Next one,

\[
  (a\times b)^c = a^c\times b^c
\]

This is saying \code{c->(a,b)} is equivalent to \code{(c -> a, c -> b)}, which
makes sense since given a function that takes a \code{c} and spit out \code{a}
and \code{b} is the same as given two function, both take a \code{c}, one spit
out \code{a} and another one spit out \code{b}.

All above algebra holds in Haskell and other BCCC languages.

\subsubsection{Curry-Howard-Lambek isomorphism}

We started to realize that the algebra we learned in high school seems to apply
to a broader and a broader range of things. Starting from numbers, then to variables,
then to functions, then to types and categories. All these things are so similar
and the similarity extends further.

The other thing fall out from this is that the same structures here we see in
types and categories appear in logics as well. This is the famous
\textbf{Curry-Howard isomorphism}, or \textbf{Proposition as Types}. So all
these we talked about in type theory and categories today actually have
one-to-one correspondence in logic.

The isomorphism between type theory and logic starts with identifying what it
means to be a proposition. A proposition is a statement that can either be true
or false. In type theory, a type can be either inhabited or not. The truth of a
proposition corresponds to that the type has elements, that is, they are
inhabited.

Most of the types we learned are inhabited, while there are some that are not,
so they corresponds to false propositions. A classic example we know is the
\code{Void} type, which has no members.

Another thing we have in logic is proof. If we want to prove a proposition we
can construct an element of the corresponding type. In logic there are two basic
propositions true and false, true is always true, and false is always false. The
corresponding things in type is: \code{Void} type corresponds to false,
\code{Unit} type corresponds to true.

Then we have conjunction ($\land$). The conjunction of $a$ and $b$ ($a\land b$)
is corresponds to the pair \code{(a,b)} in type theory. We can only form the
pair type if only we have both an element from $a$ and an element from $b$.

Disjunction ($\lor$) works similarly, in the way that $a \lor b$ corresponds to
\code{Either a b}. If we have either an element of $a$ or an element of $b$, we
can construct a \code{Either a b}.

Implication ($\Rightarrow$) corresponds to the function type. $a \Rightarrow b$
corresponds to the function type \code{a -> b}. The function type \code{a -> b}
is essentially meaning, give me an element of \code{a}, I'll give you an element
of \code{b}. In other words, if I have the function then I can produce \code{b}
from \code{a}. The same is true for implication. In logic, if we have
$(a\Rightarrow b) \land a$ we can conclude $b$. Likewise, if we have an
inhibited pair \code{(a -> b, b)}, we can derive an element of \code{b}.

\begin{figure}[h!]
\centering
\begin{tabular}{lll}
\hline
Category        & Logic            & Type              \\\hline
terminal object & true             & \code{()}         \\
initial object  & false            & \code{Void}       \\
product         & $a\land b$       & \code{(a,b)}      \\
coproduct       & $a\lor b$        & \code{Either a b} \\
exponetial      & $a\Rightarrow b$ & \code{a -> b}     \\
\hline
\end{tabular}
\caption{Table showing the correspondance}
\end{figure}

Curry-Howard proposed the correpondence between logic and type theory, and
Lambek contributed the correspondence between them and category theory.

A cartesian closed category is a model for logic and also a model for type
theory, where all these three things are the same. Some mathematicians may
discover some idea in logic, and then computer scientist can pick it up and find
it can be some type. Some modern concepts are discovered and found applicable in
different fields in this way. An example is Linear Logic, which computer
scientists translated into programming languages using Curry-Howard
Correspondence, called Linear Type. In a linear type system each object is used
exactly once. This system makes up the basis of Rust's ownership and C++'s
\code{unique_ptr}.


\section{Ring theory}\label{sec:ring_theory}

As discussed in \fullref{rem:additive_magma}, commutative and non-commutative groups are quite different despite having similar definitions. Rings are extensions of \hyperref[def:abelian_group]{abelian groups}, which allow multiplication with more than members of \( \BbbZ \).

For commutative rings, this second operation is often truly an extension of \fullref{def:magma/exponentiation} to arbitrary ring elements. For noncommutative ring, this second operation is usually given by function composition.

This section also describes \hyperref[def:module]{modules}, which are important both as generalizations of \hyperref[def:vector_space]{vector spaces} and as a tool to study rings. \hyperref[def:ring_ideal]{Ring ideals} are instances of submodules, for example.

In an attempt to encompass the \hyperref[def:natural_number]{natural numbers}, \hyperref[def:lattice_ideal]{lattice ideals} and \hyperref[def:polynomial_algebra]{polynomials} and \hyperref[def:array/matrix]{matrices} over \hyperref[def:tropical_semiring]{tropical semirings}, we have chosen to use \hyperref[def:semiring]{semirings}, \hyperref[def:semimodule]{semimodules} and \hyperref[def:semiring_ideal]{semiring ideals} as fundamental notions.

\begin{figure}[h]
  \caption{Some important semirings}\label{fig:ring_hierarchy}
  \smallskip
  \hfill
  \begin{forest}
    [
      {\hyperref[def:semiring]{semiring}}
        [{\hyperref[def:noetherian_semiring]{noetherian}}, name=noetherian]
        [
          {\hyperref[def:zerosumfree]{zerosumfree}}
            [{\hyperref[def:semilattice/distributive_lattice]{distributive lattice}}, name=lattice]
        ]
        [
          {\hyperref[def:semiring/commutative]{commutative}}, name=commutative
            [
              {\hyperref[def:integral_domain]{integral domain}}, name=domain
                [
                  {\hyperref[def:gcd_domain]{greatest common divisor domain}}
                    [
                      {\hyperref[def:unique_factorization_domain]{unique factorization domain}}, name=ufd
                        [
                          {\hyperref[def:principal_ideal_domain]{principal ideal domain}}, name=pid
                            [
                              {\hyperref[def:euclidean_domain]{Euclidean domain}}
                              [{\hyperref[def:field]{field}}, name=field]
                            ]
                        ]
                    ]
                ]
            ]
        ]
        [{\hyperref[def:entire_semiring]{entire}}, name=entire]
        [
          {\hyperref[def:ring]{ring}}, name=ring
          [{\hyperref[def:division_ring]{division ring}}, name=division]
          [{\hyperref[def:ring/simple]{simple ring}}, name=simple]
        ]
    ]
    \draw[-] (ring) to (domain);
    \draw[-] (entire) to (domain);
    \draw[-] (commutative) to (lattice);
    \draw[-] (division) to[out=south, in=east] (field);
    \draw[-] (simple) to[out=south, in=east] (field);
    \draw[-] (noetherian) to[out=south, in=west] (pid);
  \end{forest}
  \hfill\hfill
\end{figure}


\documentclass{beamer}

\usepackage{beamerthemevictor,comment,verbatim,graphicx,amssymb}

\input{tutmacs}
\input{slidemacs}
\input idxmacs

\begin{document}

\title{Bezier curves}
\author{Victor Eijkhout}
\date{Notes for CS 594 -- Fall 2004}

\frame{\titlepage}

\section{Introduction}
\frame{
  \frametitle{Fonts}
\begin{itemize}
\item Use of Bezier in fonts
\item Bitmap vs outline (vector)
\item Curve descriptions are scalable, smaller
\item<2-> More processing
\item<2-> More intelligence in the rasterizer
\end{itemize}
}

\frame{
  \frametitle{Requirements}
\begin{itemize}
\item Description unique, simple to compute
\item Easy to change shape (design)
\item Well behaved: small change in parameter gives small change in
  shape
\item Smoothly composable
\end{itemize}
}

\frame{
  \frametitle{Two basic problems:}
\begin{itemize}
\item Points known, smooth curve required
\item Function known, approximation required
\end{itemize}
}

\subsectionframe{Interpolation}

\frame{
  \frametitle{Lagrange interpolation}
\begin{itemize}
\item Given points $(x_1,f_1)\ldots(x_n,f_n)$, draw curve
\item $n$ points: polynomial of degree~$n-1$ (actually, order)
\[ p(x)=p_{n-1}x^{n-1}+\cdots+p_1x+p_0 \]
\item equations $p(x_i)=f_i$ to solve
\end{itemize}
}

\frame{
\begin{itemize}
\item System of equations
\begin{eqnarray*}
p_{n-1}x_1^{n-1}+\cdots+p_1x_1+p_0&=&f_1\\
&\ldots\\
p_{n-1}x_n^{n-1}+\cdots+p_1x_n+p_0&=&f_n
\end{eqnarray*}
written as $X\bar p=\bar f$, where
\[ X=\bigl(x_i^j\bigr),\quad
   \bar p=\begin{pmatrix}p_1\\ \vdots\\ p_{n-1}
   \end{pmatrix}
   ,\quad
   \bar f=\begin{pmatrix}f_1-p_0\\ \vdots\\ f_n-p_0
   \end{pmatrix}
   \]
\item not stable
\end{itemize}
}

\frame{
  \frametitle{Lagrange polynomials}
\begin{itemize}
\item $p^{(k)}$:
\[ p^{(k)}(x) = c_k
    (x-x_1)\cdots(x-x_{k-1})\,(x-x_{k+1})\cdots(x-x_n) \]
where $c_k$ is chosen so that~$p^{(k)}(x_k)=1$.
\item<2-> $p^{(i)}(x_j)=\delta_{ij}$, so
\begin{equation} p(x) = \sum_i f_ip^{(i)}(x),\qquad
    p^{(i)}(x)=\prod_{j\not=i}{x-x_j\over x_i-x_j}
    \label{eq:lagrange}\end{equation}
\end{itemize}
}

\frame{
  \frametitle{Hermite interpolation}
\begin{itemize}
\item Dictate function values and derivatives
\item Hermite polynomials
\[ q^{(k)} = c_k
    (x-x_1)^2\cdots(x-x_{k-1})^2\cdot (x-x_k)\cdot
    (x-x_{k+1})^2\cdots(x-x_n)^2 \]
where $c_k$ is chosen so that $q^{(k)'}(x_k)=1$.
\item<2-> Combination of $p^{(k)}$ and $q^{(k)}$ polynomials:\\
match values and derivatives
\end{itemize}
}

\subsectionframe{Approximation}

\frame{
  \frametitle{Distance, convergence}
\begin{itemize}
\item Approximate known curve
\item cheaper computation, use uniform computations
\item distance?
\item<2-> Family of approximating curves $f_n$
\item<2-> Does $|f-f_n|\rightarrow0$?
\end{itemize}
}

\frame{
  \frametitle{Convergence}
\begin{itemize}
\item Pointwise convergence
\[ \forall_{x\in I,\epsilon}\exists_N\forall_{n\geq N}:
    \left|f_n(x)-f(x)\right|\leq\epsilon.
\]
\item<2-> Uniform convergence
\[ \forall_\epsilon\exists_N\forall_{x\in I,n\geq N}:
    \left|f_n(x)-f(x)\right|\leq\epsilon.
\]
\end{itemize}
}

\frame{
  \frametitle{non-uniform convergence}
\pgfimage{hat-function}
}

\frame{
  \frametitle{Problems with high degree polynomials}
\pgfimage[width=2.5in]{runge}
\begin{itemize}
\item Better location of points
\item Better polynomials
\item<2-> Not use high degree polynomial
\end{itemize}
}

\subsectionframe{Computations}

\frame{
  \frametitle{Lagrange polynomials}
\begin{itemize}
\item $n$ terms of $n$ multiplications each:
\[ p(x) = \sum_i f_ip^{(i)}(x),\qquad
    p^{(i)}(x)=\prod_{j\not=i}{x-x_j\over x_i-x_j}
\]
\item quadratic cost
\item<2-> Down to linear:
\[ p(x) = \prod_i(x-t_i)\cdot\sum_i{y_i\over x-t_i},
    \qquad y_i=f_i/\prod_{j\not=i}(x_i-x_j),
\]
with $y_i$ precomputed
\item<3-> complicated story with derivatives
\end{itemize}
}

\subsectionframe{Divided differences}
\newcommand\kdd[1]{\kddl{1}{#1}}
\newcommand\kddl[2]{[\tau_{#1},\ldots,\tau_{#2}]}

\frame{
  \frametitle{Definition}
\begin{itemize}
\item $n$-th divided difference $\kdd{n+1}g$ is leading coefficient of
  $n+1$-st order ($\Pi_{<n+1}$, degree~$n$ or lower) polynomial that
  agrees with~$g$ in $\tau_1,\ldots,\tau_{n+1}$
\item<2-> Zeroeth divided difference:
constant polynomial, match $g(\tau_1)=g_1$:
 $[\tau_1]g=g_1$
\item<3-> First divided difference: linear function, leading
  coefficient is slope
\[ [\tau_1,\tau_2]g={g(\tau_2)-g(\tau_1)\over \tau_2-\tau_1}
    ={[\tau_2]g-[\tau_1]g\over \tau_2-\tau_1}
\]
\item<3-> recurrence?
\end{itemize}
}

\frame{
  \frametitle{Relation}
\begin{itemize}
\item Let $p_{k+1}\in\prod_{<k+1}$ agree with~$g$ in
$\tau_1\ldots\tau_{k+1}$, and $p_k\in\prod_{<k}$ with~$g$ in
$\tau_1\ldots\tau_k$, then
\begin{equation}
    p_{k+1}(x)-p_k(x)=\kdd{k+1}g\prod_{i=1}^k(x-\tau_i).
    \label{eq:pk-diff}
\end{equation}
\item<2->
Proof. $p_k$ is of a lower order, so
\[ p_{k+1}-p_k=\kdd{k+1}gx^k+cx^{k-1}+\cdots.\]
\item $p_{k+1}-p_k$ is zero in~$t_i$ for~$i\leq\nobreak k$:
\[ p_{k+1}-p_k=C\prod_{i=1}^k(x-\tau_i). \]
\item therefore $C=\kdd{k+1}g$.
\end{itemize}
}

\frame{
\begin{itemize}
\item Repeat this:
\begin{equation}
    p_{k+1}(x)=\sum_{m=1}^{k+1}\kdd{m}g\prod_{i=1}^{m-1}(x-\tau_i),
    \label{eq:p-sum-diffs}
\end{equation}
\item can be evaluated as
\begin{footnotesize}
\[
\begin{array}{rcl}
 p_{k+1}(x) &=&
 \kdd{k+1}g\prod^k(x-\tau_i)+\kdd{k}g\prod^{k-1}(x-\tau_i)\\
    &=&\kdd{k+1}g(x-\tau_k)\bigl(c_k
                +\kdd{k}g(x-\tau_{k-1})\bigl(c_{k-1}+\cdots
\end{array}
\]
\end{footnotesize}
where $c_k=\kdd{k}g/\kdd{k+1}g$
\item Horner's rule
\end{itemize}
}

\frame{
  \frametitle{Construction of divided differences}
\begin{itemize}
\item Recursive:
\[
    \kdd{n+1}g=\left(\kdd{n}g-\kddl{2}{n+1}g\right)/(\tau_1-\tau_{n+1}).
\]
\item Proof. Three polynomials given:\\
 $p^{(1)}_n\in\prod_{<n}$ agrees with~$g$ on
  $\tau_1\ldots\tau_n$;\\
 $p^{(2)}_n\in\prod_{<n}$ agrees with~$g$ on
  $\tau_2\ldots\tau_{n+1}$;\\
 $p_{n-1}\in\prod_{<n-1}$ agrees with~$g$ on
  $\tau_2\ldots\tau_n$.
\item then
\[ \begin{array}{rcl}
  p^{(1)}_n-p_{n-1}&=&\kdd{n}g\prod_{j=2}^n(x-\tau_j)\\
  p^{(2)}_n-p_{n-1}&=&\kddl{2}{n+1}g\prod_{j=2}^n(x-\tau_j)
\end{array}
\]
\end{itemize}
}

\frame{
  \frametitle{}
\begin{itemize}
\item $p_{n+1}$ agrees with~$g$ on $\tau_1\ldots\tau_{n+1}$:
\[ \begin{array}{rcl}
  p_{n+1}-p^{(1)}&=&\kdd{n+1}g\prod_{j=1}^n(x-\tau_j)\\
  p_{n+1}-p^{(2)}&=&\kdd{n+1}g\prod_{j=2}^{n+1}(x-\tau_j)
\end{array} \]
\item Subtracting gives for $p^{(1)}_n-p^{(2)}_n$:
\begin{footnotesize}
\[ \left(\kdd{n}g-\kddl{2}{n+1}g\right)\prod_{j=2}^n(x-\tau_j)
  = \kdd{n+1}g\left(\prod_{j=2}^{n+1}-\prod_{j=1}^n\right)
        (x-\tau_j)
\]
\end{footnotesize}
\item Fill in $\tau_2\ldots\tau_n$: zero\\
With $x=\nobreak\tau_1$
\begin{footnotesize}
\[ \left(\kdd{n}g-\kddl{2}{n+1}g\right)\prod_{j=2}^n(\tau_1-\tau_j)
  = \kdd{n+1}g\prod_{j=2}^{n+1}(\tau_1-\tau_j)
\]
\end{footnotesize}
\end{itemize}
}

\sectionframe{Parametric curves}

\frame{
  \frametitle{Functions are not enough}
\begin{itemize}
\item no unique mapping $x\mapsto y$: circle
\item implicit $f(x,y)=0$ trouble with half circle
\item parametric: \[ P=P(t) = \begin{pmatrix}x(t)\\ y(t)
    \end{pmatrix}.\]
\item parametric interpolation: $P=tP_2+(1-t)P_1$:\\
$P(0)=P_1$, $P(1)=P_2$;\\
\[ P(t)=(\cos 2\pi t,\sin 2\pi t) \]
\end{itemize}
}

\subsection{Cubics}

\frame{
  \frametitle{Cubics}
\begin{itemize}
\item Flexible enough: 4 degrees of freedom\\
location and direction in two points\\
(Hermite strategy)
\item Higher degrees harder to control
\end{itemize}
}

\frame{
  \frametitle{Formal description}
\begin{itemize}
\item Matrix/Vector description: $Q(t)=C\cdot T$
\item coefficient matrix
\begin{footnotesize}
\[ C=\begin{pmatrix}c_{11}&c_{12}&c_{13}&c_{14}\\
    c_{21}&c_{22}&c_{23}&c_{24}\\ c_{31}&c_{32}&c_{33}&c_{34}
    \end{pmatrix}
    ,\qquad
    T=\begin{pmatrix}1\\ t\\ t^2\\ t^3
    \end{pmatrix}
\]
\end{footnotesize}
\item  Direction:
\begin{footnotesize}
\[ {dQ(t)\over dt}=C\cdot {dT\over dt}=
    C\cdot\begin{pmatrix}0\\ 1\\ 2t\\ 3t^2
    \end{pmatrix}
\]
\end{footnotesize}
\item Hermite example: $P_1=Q(0)$,
$R_1=Q'(0)$, $P_2=Q(1)$, and~$R_2=\nobreak Q'(1)$
\begin{footnotesize}
\[ C\cdot \begin{pmatrix}1&0&1&0\\ 0&1&1&1\\ 0&0&1&2\\ 0&0&1&3
    \end{pmatrix}
    =[P_1,R_1,P_2,R_2],
\]
\end{footnotesize}
\end{itemize}
}

\frame{
  \frametitle{Blending functions}
\begin{itemize}
\item Description $C=G\cdot M$
in terms of basis polynomials and geometry matrix:
\begin{equation}
  Q(t) = G\cdot M\cdot T =
    \begin{pmatrix}g_{11}&g_{12}&g_{13}&g_{14}\\
        g_{21}&g_{22}&g_{23}&g_{24}\\ g_{31}&g_{32}&g_{33}&g_{34}
    \end{pmatrix}
    \cdot \begin{pmatrix}m_{11}&\ldots&m_{14}\\ \vdots&&\vdots\\
        m_{41}&\ldots&m_{44}
    \end{pmatrix}
    \cdot T
\label{eq:geom}
\end{equation}
If we introduce new basis polynomials $\pi_i(t)=M_{i*}\cdot T$, then we
see that $Q_x=G_{11}\pi_1+G_{12}\pi_2+G_{13}\pi_3+G_{14}\pi_4$,
$Q_y=G_{21}\pi_1+\cdots$, et cetera.
\end{itemize}
}

\frame{
  \frametitle{Computing the basis matrix $M$}
Hermite case: geometric constraints $[Q(0),Q'(0),Q(1),Q'(1)]$\\
From $Q=G\cdot M\cdot T$:
\[ Q(t)= G_H\cdot M_H\cdot T(t),\qquad
   Q'(t) = G_H\cdot M_H\cdot T'(t). \]
Applying to $t=0$ and $t=1$:
\[ Q_H\equiv[Q(0),Q'(0),Q(1),Q'(1)] = G_H\cdot M_H\cdot T_H \]
where
\begin{footnotesize}
\[ T_H=[T(0),T'(0),T(1),T'(1) ]
     =\begin{pmatrix}1&0&1&0\cr 0&1&1&1\cr 0&0&1&2\cr 0&0&1&3
     \end{pmatrix}
\]
\end{footnotesize}
\begin{footnotesize}
But now $G_H=Q_H$. It now follows that
\[ M_H=T_H^{-1}
    =\begin{pmatrix}1&0&-3&2\cr 0&1&-2&1\cr 0&0&3&-2\cr 0&0&-1&1
    \end{pmatrix}
\]
\end{footnotesize}
}

\frame{
  \frametitle{}
\begin{itemize}
\item $Q=G\cdot M\cdot T$ with
\[ M_H=T_H^{-1}
    =\begin{pmatrix}1&0&-3&2\\ 0&1&-2&1\\ 0&0&3&-2\\ 0&0&-1&1
    \end{pmatrix}.
\]
\item Writing this out, we find the cubic Hermite polynomials
\[ P_1(t)=2t^3-3t^2+1,\quad P_2(t)=t^3-2t^2+t,\quad
    P_3(t)=-2t^3+3t^2,\quad P_1(t)=t^3-t^2
\]

\end{itemize}
}

\newcommand\picandsrc[2]
{\leavevmode\pgfimage[height=1.3in]{#1}
\begin{minipage}{2in}
\begin{footnotesize}
\verbatiminput{#2.gp}
\end{footnotesize}
\end{minipage}
}

\frame[containsverbatim]{
  \frametitle{Hermite basis functions}
\picandsrc{hermite}{hermite}
}

\frame{
  \frametitle{Example of Hermite interpolation}
Curve $.3P_1-2P_2+P_3-2P4$:\\
through $(0,.3)$ and~$(1,1)$, with slope~$-2$ in
both~$x=0,1$.

\pgfimage[height=1.5in]{herminp}
}

\frame{
  \frametitle{Hermite parametric curves}
Both coordinates parametric:
\[ Q = \left({.1\atop .2}\right)P_1+\left({1\atop 0}\right)P_2
    +\left({.9\atop .3}\right)P_3+\left({0\atop -1}\right)P_4.
\]
\picandsrc{hermpara}{hermpara}
}

\frame{
  \frametitle{Smoothness}
\picandsrc{hermpara2}{hermpara2}
}

\subsectionframe{Splines}

\frame{
  \frametitle{Bernstein polynomials}
\begin{itemize}
\item $z(t)=(1-t)^3z_1+3(1-t)^2tz_2+3(1-t)t^2z_3+t^3z_4$
\pgfimage[height=2in]{bernshtein}
\end{itemize}
}

\frame{
  \frametitle{Derivation from Hermite basis}
\begin{itemize}
\item Hermite direction vectors~$R_1,R_2$,\\
replace by control points~$P_1',P_2'$:
\[ R_1=3(P_1'-P1), \quad R_2=3(P_2-P_2') \]
\item Geometry matrix
\[ G_B=[P_1,P_1',P_2',P_2]\quad
   G_H=[P_1,R_1,P_2,R_2]
    = [P_1,P_1',P_2',P_2] M_{BH} = G_B\cdot M_{BH}
\]
with
\[
     M_{BH}=\begin{pmatrix}1&-3&0&0\\ 0&3&0&0\\ 0&0&0&-3\\ 0&0&1&3
     \end{pmatrix}
\]
\end{itemize}
}

\frame{
\begin{itemize}
\item Define
\[ M_B=M_{BH}\cdot M_H=
   \begin{pmatrix}1&-3&3&-1\\ 0&3&-6&3\\ 0&0&3&-3\\ 0&0&0&1
   \end{pmatrix}
\]
the Bezier curves:
\[ Q(t)=G_H\cdot M_H\cdot T(t)=G_B\cdot M_{BH}\cdot M_H\cdot T(t)
    =G_B\cdot M_B\cdot T(t)
\]
\item Per component: $Q_x(t)=g_{11}B_1(t)+g_{12}B_2(t)+\cdots$
where
\[ \begin{array}{rll}
B_1(t) &= 1-3t+3t^2 -t^3&=(1-t)^3\\
B_2(t) &= 3t-6t^2+3t^3&=3t(1-t)^2\\
B_3(t) &= 3t^2-3t^3&=3t^2(1-t)\\
B_4(t) &=          &=t^3
\end{array}
\]
\end{itemize}
}

\frame{
  \frametitle{Enclosing hull}
\begin{itemize}
\item Bernshtein polynomials
\[ z(t)=(1-t)^3z_1+3(1-t)^2tz_2+3(1-t)t^2z_3+t^3z_4 \]
\item With all $z_i\equiv1$:
\[ z(t)=(t+(1-t))^3\equiv1 \]
\item $\Rightarrow$ Bezier curve components are weighted averages
\item $\Rightarrow$ curve containes in convex hull of control points
\end{itemize}
}

\frame{
  \frametitle{Calculation of Bezier curves}
\begin{itemize}
\item The simple way: $Q(t)=G\cdot M\cdot T(t)$
\begin{itemize}
\item 2 multiplications to form the terms $t^2$ and~$t^3$ in~$T$;
\item 16 multiplications and 12 additions forming~$M\cdot T$;
\item 12 multiplications and 9 additions forming $G\cdot(M\cdot T)$.
\end{itemize}
\item Improvement: store $\tilde M=G\cdot M$:
\begin{itemize}
\item two multiplications for~$T$;
\item 12 multiplications and 9 additions for forming $\tilde M\cdot
  T$.
\end{itemize}
\end{itemize}
}

\frame{
  \frametitle{Calculation with divided differences}
\begin{footnotesize}
\begin{itemize}
\item $Q(t)=G\cdot M\cdot T(t)$, $x$ component:
\[ x(t) = \sum_kc_kt^{k-1}\qquad c_k=\sum_jG_{1j}M_{jk}. \]
\item  recall
\[  M_B=\begin{pmatrix}1&-3&3&-1\\ 0&3&-6&3\\ 0&0&3&-3\\ 0&0&0&1
        \end{pmatrix}
\]
\item  writing $g_j\equiv G_{1j}$:
\[ c_1=g_1,\quad c_2=3(g_2-g_1),\quad
    c_3=3(g_3-2g_2+g_1),\quad c_4=g_4-3g_3+3g_2-g_1. \]
\item These are divided differences:
\[ \begin{array}{lcl}\relax [2,1]g&=&g_2-g_1,\\
 \relax [3,2,1]g&=&[3,2]g-[2,1]g=(g_3-g_2)-(g_2-g_1)\\
         &=&g_3-2g_2+g_1\\
 \relax [4,3,2,1]&=&[4,3,2]g-[3,2,1]g=(g_4-2g_3+g_2)-(g_3-2g_2+g_1)\\
         &=&g_4-3g_3+3g_2-g_1
    \end{array}
\]
\end{itemize}
\end{footnotesize}
}

\sectionframe{Practical use of splines}

\frame{
  \frametitle{Piecewise curves}
\pgfimage[height=2in]{bezier2}
}

\frame{
  \frametitle{Spline drawing}
\begin{itemize}
\item Divided difference algorithm is good for single points
\item<2-> Whole curve: compute step by step $Q(n\delta)$, $n=0,1,\ldots$
\item<3-> Other tricks: recursive bisection; use line drawing when curve
  is flat enough
\item<3-> (flatness test through control points for Bezier)
\end{itemize}
}

\end{document}

\frame{
  \frametitle{}
\begin{itemize}
\item
\end{itemize}
}


\chapter*{Summary}
%\pagestyle{empty}
%\pagenumbering{}
\markboth{}{}
\addcontentsline{toc}{chapter}{Summary}
In this thesis we studied the light propagation within optical systems.
Optical engineers are interested in design systems in such a way the desired output distribution of light is obtained. Ray tracing is a forward method where a set of rays is traced within the system from source to target. The propagation of light is determined computing the position and the direction of every ray for all the optical surfaces that it encounters. There are many ways to implement the ray tracing process. Monte Carlo (MC) ray tracing is often used in non-imaging optics. Rays are randomly traced from source to target and each time that a ray hits an optical surface the coordinates of the intersection point of the ray with the surface and the new ray direction are calculated. The output variables are computed dividing the target into intervals, the so-called bins, and counting the rays that fall into each bin. To obtain the desired accuracy, millions of rays are required, therefore the method is extremely computationally expensive and it converges as the inverse of the square root of the number of rays traced.
\\ \indent
MC ray tracing can be improved using, as sample of points, a low discrepancy sequence instead of random points. Discrepancy can be interpreted as a measure of how much the sample distribution differs from a uniformly distributed sample. The discrepancy is therefore zero for uniformly distributed points. A low discrepancy sequence gives a sample of points which are regularly distributed but not exactly uniformly distributed. Quasi Monte Carlo (QMC) ray tracing is implemented tracing a set of rays whose position and direction are given by the coordinates of a low discrepancy sequence of points.
The main advantage of QMC ray tracing is its rate of convergence, it is faster than MC for low dimensional problems. Nevertheless, it has some disadvantages. First, it is not easy to give an error estimation for QMC ray tracing. Second, for high dimensional spaces the QMC can become very slow. Third, it is still a binning procedure. Hence, the accuracy depends both on the number of rays traced and on the number of bins.
\\ \indent
In order to improve the existing methods, the phase space (PS) of the optical system is considered in this thesis. The PS of an optical surface gives information about the position and the direction of every ray on that surface where the direction is expressed with respect to the normal of the surface. In PS, the ray's direction is given by the sine of the angle that the ray forms with respect to the normal of the surface multiplied by the index of refraction of the medium in which the ray is located.
In two dimensions, the PS is a two-dimensional space where the coordinates of every ray are specified by one position coordinate and one angular coordinate.
For three dimensional systems the PS is a four dimensional space because every ray is specified by two position and two angular coordinates. Our idea is to use the structure of PS to trace only the rays close to the discontinuities of the luminance at the target PS.
Two new approaches based on PS are presented in this work. They are tested for two-dimensional systems.
\\ \indent The first method is called ray tracing on PS and it is based on the source and the target PS representation of the optical system. It takes into account the sequence of optical lines that each ray hits when it propagates inside the system, that is the ray path. We note that the source and target phase spaces are partitioned into different regions each of them is formed by the rays that follow the same path. The idea is to use the edge-ray principle proved by Ries and Rabl (1994) which states that all rays that are neighbors at the source PS remain close to each other at the target PS. To this purpose, a nonuniform triangulation of the source PS is constructed in such a way that new triangles are added to the triangulation only where boundaries occur.
Assuming constant luminance, we only need to compute the boundaries of the regions in target PS to obtain the output photometric variables.
We test the method for optical systems where both reflection and refraction laws are involved.
 Numerical results show that ray tracing on PS is faster and more accurate compared to MC ray tracing.
% Nevertheless, PS ray tracing can be further improved. Indeed, the triangulation refinement allows tracing only the rays close to the boundaries and an approximation of those boundaries is needed to compute the output intensity distribution. The ideal situation would be that only the rays located exactly on the boundaries of the regions at target PS are traced inside the system
\\ \indent The second method is called backward ray mapping, it employs not only the source and the target PS, but also the PS of \textit{all} the other lines that constitute the system.
All lines can be modeled as detectors of the incident light and emitters of the reflected light.
Moreover, we assume that the source can only emit light and the target can only receive light.
Therefore, one PS is taken into account for the source and one for the target. For the other surfaces both the source and target PS are considered.
Furthermore, instead of starting from the source, the new method starts tracing back rays from target.
In order to determine the coordinates of these rays, an inverse map from the target to the source PS is constructed as a concatenation of the maps that relate the PS of two different lines.
Employing this map we are able to detect the rays that are located on the boundaries of the regions with positive luminance in target PS.
First, we implement the method for systems formed by straight and reflective lines. In this particular case, the boundaries of the regions that form every PS can be computed analytically. This allows us to obtain the exact target intensity distribution. The results are shown for a two-faceted cup and a multi-faceted cup. In both cases we note significant advantages both in terms of the accuracy and the computational time. Second, the method is developed for systems formed by curved lines. In this case the boundaries cannot be determined analytically and therefore a numerical procedure is involved. In particular, we apply a bisection method on target PS. We compare our method to QMC ray tracing and we observe significant advantages using the PS method. Finally, the ray mapping method in PS is applied to systems where also Fresnel reflection is taken into account. Preliminar results show that the method is suitable also for systems where Fresnel reflection plays a role.