\chapter{Continuous morphisms}

This chapter uses the apparatus from the section ``Partially ordered
dagger categories''.

\section{Traditional definitions of continuity}

In this section we will show that having a funcoid or reloid $\uparrow f$
corresponding to a function $f$ we can express continuity of it by
the formula $\uparrow f\circ\mu\sqsubseteq\nu\circ\uparrow f$ (or
similar formulas) where $\mu$ and $\nu$ are some spaces.

\subsection{\index{continuity!pre-topology}Pretopology}

Let $(A,\cl_{A})$ and $(B,\cl_{B})$ be preclosure spaces. Then by
definition a function $f:A\rightarrow B$ is continuous iff $f\cl_{A}(X)\subseteq\cl_{B}(fX)$
for every $X\in\subsets A$. Let now $\mu$ and $\nu$ be endofuncoids
corresponding correspondingly to $\cl_{A}$ and $\cl_{B}$. Then the
condition for continuity can be rewritten as
\[
\uparrow^{\mathsf{FCD}(\Ob\mu,\Ob\nu)}f\circ\mu\sqsubseteq\nu\circ\uparrow^{\mathsf{FCD}(\Ob\mu,\Ob\nu)}f.
\]

\subsection{\index{continuity!proximity}Proximity spaces}

Let $\mu$ and $\nu$ be proximity spaces (which I consider a special
case of endofuncoids). By definition a $\mathbf{Set}$-morphism~$f$
is a proximity-continuous map from $\mu$
to $\nu$ iff
\[
\forall X,Y\in\mathscr{T}(\Ob\mu):(X\rsuprel{\mu}Y\Rightarrow\rsupfun fX\rsuprel{\nu}\rsupfun fY).
\]

Equivalently transforming this formula we get
\begin{gather*}
\forall X,Y\in\mathscr{T}(\Ob\mu):(X\rsuprel{\mu}Y\Rightarrow\supfun f\uparrow X\suprel{\nu}\supfun f\uparrow Y);\\
\forall X,Y\in\mathscr{T}(\Ob\mu):(X\rsuprel{\mu}Y\Rightarrow\uparrow X\suprel{f^{-1}\circ\nu\circ f}\uparrow Y);\\
\forall X,Y\in\mathscr{T}(\Ob\mu):(X\rsuprel{\mu}Y\Rightarrow X\rsuprel{f^{-1}\circ\nu\circ f}Y);\\
\mu\sqsubseteq f^{-1}\circ\nu\circ f.
\end{gather*}

So a function $f$ is proximity continuous iff $\mu\sqsubseteq f^{-1}\circ\nu\circ f$.

\subsection{\index{continuity!uniformity}Uniform spaces}

Uniform spaces are a special case of endoreloids.

Let $\mu$ and $\nu$ be uniform spaces. By definition a $\mathbf{Set}$-morphism~$f$
is a uniformly continuous map from $\mu$ to $\nu$ iff
\[
\forall\varepsilon\in\up\nu\exists\delta\in\up\nu\forall(x,y)\in\delta:(fx,fy)\in\varepsilon.
\]

Equivalently transforming this formula we get:
\begin{gather*}
\forall\epsilon\in\up\nu\exists\delta\in\up\mu\forall(x,y)\in\delta:\{(fx,fy)\}\subseteq\epsilon;\\
\forall\epsilon\in\up\nu\exists\delta\in\up\mu\forall(x,y)\in\delta:f\circ\{(x,y)\}\circ f^{-1}\subseteq\epsilon;\\
\forall\epsilon\in\up\nu\exists\delta\in\up\mu:f\circ\delta\circ f^{-1}\subseteq\epsilon;\\
\forall\epsilon\in\up\nu:\uparrow^{\mathsf{RLD}(\Ob\mu,\Ob\nu)}f\circ\mu\circ(\uparrow^{\mathsf{RLD}(\Ob\mu,\Ob\nu)}f)^{-1}\sqsubseteq\uparrow^{\mathsf{RLD}(\Ob\mu,\Ob\nu)}\epsilon;\\
\uparrow^{\mathsf{RLD}(\Ob\mu,\Ob\nu)}f\circ\mu\circ(\uparrow^{\mathsf{RLD}(\Ob\mu,\Ob\nu)}f)^{-1}\sqsubseteq\nu.
\end{gather*}
So a function $f$ is uniformly continuous iff $f\circ\mu\circ f^{-1}\sqsubseteq\nu$.

\section{\index{continuity!generalized}Our three definitions of continuity}

I have expressed different kinds of continuity with simple algebraic
formulas hiding the complexity of traditional epsilon-delta notation
behind a smart algebra. Let's summarize these three algebraic formulas:

Let $\mu$ and $\nu$ be endomorphisms of some partially ordered precategory.
Continuous functions can be defined as these morphisms $f$ of this
precategory which conform to the following formula:
\[
f\in\continuous(\mu,\nu)\Leftrightarrow f\in\Hom(\Ob\mu,\Ob\nu)\land f\circ\mu\sqsubseteq\nu\circ f.
\]
If the precategory is a partially ordered dagger precategory then
continuity also can be defined in two other ways:
\begin{gather*}
f\in\continuous'(\mu,\nu)\Leftrightarrow f\in\Hom(\Ob\mu,\Ob\nu)\land\mu\sqsubseteq f^{\dagger}\circ\nu\circ f;\\
f\in\continuous''(\mu,\nu)\Leftrightarrow f\in\Hom(\Ob\mu,\Ob\nu)\land f\circ\mu\circ f^{\dagger}\sqsubseteq\nu.
\end{gather*}

\begin{rem}
In the examples (above) about funcoids and reloids the ``dagger functor''
is the reverse of a funcoid or reloid, that is $f^{\dagger}=f^{-1}$.\end{rem}
\begin{prop}
Every of these three definitions of continuity forms a wide sub-precategory
(wide subcategory if the original precategory is a category).\end{prop}
\begin{proof}
~
\begin{description}
\item [{$\continuous$}] Let $f\in\continuous(\mu,\nu)$, $g\in\continuous(\nu,\pi)$.
Then $f\circ\mu\sqsubseteq\nu\circ f$, $g\circ\nu\sqsubseteq\pi\circ g$,
$g\circ f\circ\mu\sqsubseteq g\circ\nu\circ f\sqsubseteq\pi\circ g\circ f$.
So $g\circ f\in\continuous(\mu,\pi)$. $1_{\Ob\mu}\in\continuous(\mu,\mu)$
is obvious.
\item [{$\continuous'$}] Let $f\in\continuous'(\mu,\nu)$, $g\in\continuous'(\nu,\pi)$.
Then $\mu\sqsubseteq f^{\dagger}\circ\nu\circ f$, $\nu\sqsubseteq g^{\dagger}\circ\pi\circ g$;
\[
\mu\sqsubseteq f^{\dagger}\circ g^{\dagger}\circ\pi\circ g\circ f;\quad\mu\sqsubseteq(g\circ f)^{\dagger}\circ\pi\circ(g\circ f).
\]
So $g\circ f\in\continuous'(\mu,\pi)$. $1_{\Ob\mu}\in\continuous'(\mu,\mu)$
is obvious.
\item [{$\continuous''$}] Let $f\in\continuous''(\mu,\nu)$, $g\in\continuous''(\nu,\pi)$.
Then $f\circ\mu\circ f^{\dagger}\sqsubseteq\nu$, $g\circ\nu\circ g^{\dagger}\sqsubseteq\pi$;
\[
g\circ f\circ\mu\circ f^{\dagger}\circ g^{\dagger}\sqsubseteq\pi;\quad(g\circ f)\circ\mu\circ(g\circ f)^{\dagger}\sqsubseteq\pi.
\]
So $g\circ f\in\continuous''(\mu,\pi)$. $1_{\Ob\mu}\in\continuous''(\mu,\mu)$
is obvious.
\end{description}
\end{proof}
\begin{prop}
For a monovalued morphism $f$ of a partially ordered dagger category
and its endomorphisms $\mu$ and $\nu$
\[
f\in\continuous'(\mu,\nu)\Rightarrow f\in\continuous(\mu,\nu)\Rightarrow f\in\continuous''(\mu,\nu).
\]
\end{prop}
\begin{proof}
Let $f\in\continuous'(\mu,\nu)$. Then $\mu\sqsubseteq f^{\dagger}\circ\nu\circ f$;
\[
f\circ\mu\sqsubseteq f\circ f^{\dagger}\circ\nu\circ f\sqsubseteq1_{\Dst f}\circ\nu\circ f=\nu\circ f;\quad f\in\continuous(\mu,\nu).
\]

Let $f\in\continuous(\mu,\nu)$. Then $f\circ\mu\sqsubseteq\nu\circ f$;
\[
f\circ\mu\circ f^{\dagger}\sqsubseteq\nu\circ f\circ f^{\dagger}\sqsubseteq\nu\circ1_{\Dst f}=\nu;\quad f\in\continuous''(\mu,\nu).
\]
\end{proof}
\begin{prop}
For an entirely defined morphism $f$ of a partially ordered dagger
category and its endomorphisms $\mu$ and $\nu$
\[
f\in\continuous''(\mu,\nu)\Rightarrow f\in\continuous(\mu,\nu)\Rightarrow f\in\continuous'(\mu,\nu).
\]
\end{prop}
\begin{proof}
Let $f\in\continuous''(\mu,\nu)$. Then $f\circ\mu\circ f^{\dagger}\sqsubseteq\nu$;
$f\circ\mu\circ f^{\dagger}\circ f\sqsubseteq\nu\circ f$; $f\circ\mu\circ1_{\Src f}\sqsubseteq\nu\circ f$;
$f\circ\mu\sqsubseteq\nu\circ f$; $f\in\continuous(\mu,\nu)$.

Let $f\in\continuous(\mu,\nu)$. Then $f\circ\mu\sqsubseteq\nu\circ f$;
$f^{\dagger}\circ f\circ\mu\sqsubseteq f^{\dagger}\circ\nu\circ f$;
$1_{\Src\mu}\circ\mu\sqsubseteq f^{\dagger}\circ\nu\circ f$; $\mu\sqsubseteq f^{\dagger}\circ\nu\circ f$;
$f\in\continuous'(\mu,\nu)$.
\end{proof}
For entirely defined monovalued morphisms our three definitions of
continuity coincide:
\begin{thm}\label{cont-eq}
If $f$ is a monovalued and entirely defined morphism of a partially
ordered dagger precategory then
\[
f\in\continuous'(\mu,\nu)\Leftrightarrow f\in\continuous(\mu,\nu)\Leftrightarrow f\in\continuous''(\mu,\nu).
\]
\end{thm}
\begin{proof}
From two previous propositions.
\end{proof}
The classical general topology theorem that uniformly continuous function
from a uniform space to an other uniform space is proximity-continuous
regarding the proximities generated by the uniformities, generalized
for reloids and funcoids takes the following form:
\begin{thm}
If an entirely defined morphism of the category of reloids $f\in\continuous''(\mu,\nu)$
for some endomorphisms $\mu$ and $\nu$ of the category of reloids,
then $\mathsf{\tofcd}f\in\continuous'(\tofcd\mu,\tofcd\nu)$.\end{thm}
\begin{xca}
I leave a simple exercise for the reader to prove the last theorem.
\end{xca}

\begin{thm}
Let $\mu$ and $\nu$ be endomorphisms of some partially ordered dagger precategory and
$f\in\Hom(\Ob\mu,\Ob\nu)$ be a monovalued, entirely defined morphism. Then
\[ f\in\continuous(\mu,\nu)\Leftrightarrow f\in\continuous(\mu^{\dagger},\nu^{\dagger}). \]
\end{thm}

\begin{proof}
\begin{multline*}
f \circ \mu \sqsubseteq \nu \circ f \Leftrightarrow \mu
\sqsubseteq f^{\dagger} \circ \nu \circ f \Rightarrow \\ \mu \circ
f^{\dagger} \sqsubseteq f^{\dagger} \circ \nu \circ f \circ f^{\dagger}
\Rightarrow \mu \circ f^{\dagger} \sqsubseteq f^{\dagger} \circ \nu
\Leftrightarrow \\ f \circ \mu^{\dagger} \sqsubseteq \nu^{\dagger} \circ f
\Rightarrow f^{\dagger} \circ f \circ \mu^{\dagger} \sqsubseteq
f^{\dagger} \circ \nu^{\dagger} \circ f \Rightarrow \\ \mu^{\dagger}
\sqsubseteq f^{\dagger} \circ \nu^{\dagger} \circ f \Leftrightarrow \mu
\sqsubseteq f^{\dagger} \circ \nu \circ f.
\end{multline*}

Thus $f \circ \mu \sqsubseteq \nu \circ f \Leftrightarrow \mu \Leftrightarrow
f \circ \mu^{\dagger} \sqsubseteq \nu^{\dagger} \circ f$.
\end{proof}

\section{Continuity for topological spaces}

\begin{prop}
  The following are pairwise equivalent for funcoids $\mu$, $\nu$ and
  a monovalued, entirely defined morphism~$f\in\Hom(\Ob\mu,\Ob\nu)$:
  \begin{enumerate}
    \item\label{fcd-cont-unfold} $\forall A \in \mathscr{T} \Ob \mu, B \in \up
    \supfun{\nu} \rsupfun{f} A : \rsupfun{f^{- 1}}
    B \in \up \rsupfun{\mu} A$.

    \item\label{fcd-cont-main}  $f \in \continuous (\mu, \nu)$.

    \item\label{fcd-cont-rev} $f \in \continuous (\mu^{- 1} , \nu^{- 1})$.
  \end{enumerate}
\end{prop}

\begin{proof}
  ~
  \begin{description}
  \item[\ref{fcd-cont-main}$\Leftrightarrow$\ref{fcd-cont-rev}] By general $f \circ \mu \sqsubseteq \nu \circ
  f \Leftrightarrow f \circ \mu^{\dagger} \sqsubseteq \nu^{\dagger}
  \circ f$ formula above.

  \item[\ref{fcd-cont-unfold}$\Leftrightarrow$\ref{fcd-cont-main}] \ref{fcd-cont-unfold} is equivalent to
  $\rsupfun{\rsupfun{f^{- 1}}}
  \up \supfun{\nu} \rsupfun{f} A \subseteq \up
  \rsupfun{\mu} A$ equivalent to $\supfun{\nu} \rsupfun{f}
  A \sqsupseteq \supfun{f} \rsupfun{\mu} A$
  (used ``Orderings of filters'' chapter).
  \end{description}
\end{proof}

\begin{cor}\label{top-cont}
  The following are pairwise equivalent for topological spaces $\mu$,
  $\nu$ and a monovalued, entirely defined morphism~$f\in\Hom(\Ob\mu,\Ob\nu)$:
  \begin{enumerate}
    \item\label{top-cont-unfold} $\forall x \in \Ob \mu, B \in \up \supfun{\nu}
    \rsupfun{f} \{x\} : \rsupfun{f^{- 1}} B \in
    \up \rsupfun{\mu} \{x\}$.

    \item\label{top-cont-preim} Preimages (by $f$) of open sets are open.

    \item\label{top-cont-main} $f \in \continuous (\mu, \nu)$ that is $\supfun{f}
    \rsupfun{\mu} \{ x \} \sqsubseteq \supfun{\nu}
    \rsupfun{f} \{ x \}$ for every $x \in \Ob \mu$.

    \item\label{top-cont-rev} $f \in \continuous (\mu^{- 1} , \nu^{- 1})$ that is $\supfun{f}
    \rsupfun{\mu^{- 1}} A \sqsubseteq \supfun{\nu^{- 1}}
    \rsupfun{f} A$ for every $A \in \mathscr{T}
    \Ob \mu$.
  \end{enumerate}
\end{cor}

\begin{proof}
  \ref{fcd-cont-main} from the previous proposition is equivalent to
  $\supfun{f}\rsupfun{\mu}\{x\}\sqsubseteq\supfun{\nu}\rsupfun{f}\{x\}$
  equivalent to $\rsupfun{\rsupfun{f^{- 1}}}
  \up \supfun{\nu} \rsupfun{f} \{ x \} \subseteq
  \up \rsupfun{\mu} \{ x \}$ for every $x \in \Ob
  \mu$, equivalent to \ref{top-cont-unfold} (used ``Orderings of filters'' chapter).

  It remains to prove \ref{top-cont-main}$\Leftrightarrow$\ref{top-cont-preim}.

  \begin{description}
  \item[\ref{top-cont-main}$\Rightarrow$\ref{top-cont-preim}] Let $B$ be an open set in $\nu$. For every $x \in
  \rsupfun{f^{- 1}} B$ we have $f (x) \in B$ that is $B$ is a
  neighborhood of $f (x)$, thus $\rsupfun{f^{-1}}B$ is a neighborhood of $x$. We have
  proved that $\rsupfun{f^{- 1}} B$ is open.

  \item[\ref{top-cont-preim}$\Rightarrow$\ref{top-cont-main}] Let $B$ be a neighborhood of $f (x)$. Then there is an
  open neighborhood $B' \subseteq B$ of $f (x)$. $\rsupfun{f^{-1}}
  B'$ is open and thus is a neighborhood of $x$ ($x \in \rsupfun{f^{-1}} B'$ because $f (x) \in B'$). Consequently
  $\rsupfun{f^{-1}} B$ is a neighborhood of $x$.
  \end{description}

  Alternative proof of \ref{top-cont-preim}$\Leftrightarrow$\ref{top-cont-rev}:
  \url{http://math.stackexchange.com/a/1855782/4876}
\end{proof}

\section{\texorpdfstring{$\continuous (\mu \circ \mu^{- 1} , \nu \circ \nu^{- 1})$}{C(mu o mu\textasciicircum-1, nu o nu\textasciicircum-1)}}

\begin{prop}
  $f \in \continuous (\mu, \nu) \Rightarrow f \in \continuous'' (\mu
  \circ \mu^{- 1} , \nu \circ \nu^{- 1})$ for endofuncoids $\mu$,
  $\nu$ and monovalued funcoid $f \in \mathsf{FCD} (\Ob
  \mu, \Ob \nu)$.
\end{prop}

\begin{proof}
  Let $f \in \continuous (\mu, \nu)$.

\begin{multline*}
  X \mathrel{[f \circ \mu \circ \mu^{- 1} \circ f^{- 1}]^{\ast}}
  Z \Leftrightarrow \\ \exists p \in \atoms^{\mathscr{F}} : \left( X
  \mathrel{[\mu^{- 1} \circ f^{- 1}]^{\ast}} p \wedge p \mathrel{[f
  \circ \mu]^{\ast}} Z \right) \Leftrightarrow \\ \exists p \in
  \atoms^{\mathscr{F}} : \left( p \mathrel{[f \circ \mu]^{\ast}} X
  \wedge p \mathrel{[f \circ \mu]^{\ast}} Z \right) \Rightarrow \\ \exists
  p \in \atoms^{\mathscr{F}} : \left( p \mathrel{[\nu \circ f]^{\ast}} X
  \wedge p \mathrel{[\nu \circ f]^{\ast}} Z \right) \Leftrightarrow \\ \exists p
  \in \atoms^{\mathscr{F}} : \left( \rsupfun{f} p
  \mathrel{[\nu]^{\ast}} X \wedge \rsupfun{f} p
  \mathrel{[\nu]^{\ast}} Z \right) \Rightarrow X \mathrel{[\nu \circ \nu^{-
  1}]^{\ast}} Z
\end{multline*}
(taken into account monovaluedness of $f$ and thus that
  $\rsupfun{f} p$ is atomic or least). Thus $f \circ \mu
  \circ \mu^{- 1} \circ f^{- 1} \sqsubseteq \nu \circ \nu^{- 1}$ that is
  $f \in \continuous'' (\mu \circ \mu^{- 1} , \nu \circ \nu^{-
  1})$.
\end{proof}

\begin{prop}
  $f \in \continuous'' (\mu \circ \mu^{- 1} , \nu \circ \nu^{- 1})
  \Rightarrow f \in \continuous'' (\mu, \nu)$ for complete endofuncoids
  $\mu$, $\nu$ and principal funcoid $f \in \mathsf{FCD}
  (\Ob \mu, \Ob \nu)$, provided that $\mu$ is
  reflexive, and $\nu$ is $T_1$-separable.
\end{prop}

\begin{proof}
\begin{multline*}
  f \in \continuous'' (\mu \circ \mu^{- 1} , \nu \circ \nu^{- 1})
  \Leftrightarrow \\ f \circ \mu \circ \mu^{- 1} \circ f^{- 1}
  \sqsubseteq \nu \circ \nu^{- 1} \Rightarrow \text{(reflexivity of
  $\mu$)} \Rightarrow \\ f \circ \mu \circ f^{- 1} \sqsubseteq \nu
  \circ \nu^{- 1} \Leftrightarrow f \circ \mu^{- 1} \circ f^{- 1}
  \sqsubseteq \nu \circ \nu^{- 1} \Rightarrow \\ \langle f \circ \mu^{- 1}
  \circ f^{- 1} \rangle^{\ast} X \sqsubseteq \supfun{\nu}^{\ast}
  \langle \nu^{- 1} \rangle^{\ast} X \Rightarrow \\ \Cor \left\langle f
  \circ \mu^{- 1} \circ f^{- 1} \right\rangle^{\ast} X \sqsubseteq
  \Cor \supfun{\nu}^{\ast} \langle \nu^{- 1} \rangle^{\ast} X
  \Leftrightarrow \\ \langle f \circ \mu^{- 1} \circ f^{- 1} \rangle^{\ast}
  X \sqsubseteq \Cor \supfun{\nu}^{\ast} \langle \nu^{- 1}
  \rangle^{\ast} X \Rightarrow \\ \text{($T_1$-separability)} \Rightarrow \\ \langle
  f \circ \mu^{- 1} \circ f^{- 1} \rangle^{\ast} X \sqsubseteq \langle
  \nu^{- 1} \rangle^{\ast} X$ for any typed set $X$ on $\Ob \nu.
\end{multline*}
  Thus
  \begin{multline*}
f \in \continuous'' (\mu \circ \mu^{- 1} , \nu \circ \nu^{- 1})
  \Rightarrow f \circ \mu^{- 1} \circ f^{- 1} \sqsubseteq \nu^{- 1}
  \Leftrightarrow \\ f \circ \mu \circ f^{- 1} \sqsubseteq \nu
  \Leftrightarrow f \in \continuous'' (\mu, \nu).
  \end{multline*}
\end{proof}

\begin{thm}
  $f \in \continuous (\mu \circ \mu^{- 1} , \nu \circ \nu^{- 1})
  \Leftrightarrow f \in \continuous (\mu, \nu)$ for complete endofuncoids
  $\mu$, $\nu$ and principal monovalued and entirely defined funcoid $f
  \in \mathsf{FCD} (\Ob \mu, \Ob \nu)$, provided that
  $\mu$ is reflexive, and $\nu$ is $T_1$-separable.
\end{thm}

\begin{proof}
  Two above propositions and theorem~\ref{cont-eq}.
\end{proof}

\section{\index{continuity!of restricted morphism}Continuity of a restricted
morphism}

Consider some partially ordered semigroup. (For example it can be
the semigroup of funcoids or semigroup of reloids on some set regarding
the composition.) Consider also some lattice (\emph{lattice of objects}).
(For example take the lattice of set theoretic filters.)

We will map every object $A$ to so called \emph{restricted identity}
element $I_{A}$ of the semigroup (for example restricted identity
funcoid or restricted identity reloid). For identity elements we will
require
\begin{enumerate}
\item $I_{A}\circ I_{B}=I_{A\sqcap B}$;
\item $f\circ I_{A}\sqsubseteq f$; $I_{A}\circ f\sqsubseteq f$.
\end{enumerate}
In the case when our semigroup is ``dagger'' (that is is a dagger
precategory) we will require also $(I_{A})^{\dagger}=I_{A}$.

We can define restricting an element $f$ of our semigroup to an object
$A$ by the formula $f|_{A}=f\circ I_{A}$.

\index{restricting!rectangular}We can define \emph{rectangular restricting}
an element $f$ of our semigroup to objects $A$ and $B$ as $I_{B}\circ f\circ I_{A}$.
Optionally we can define direct product $A\times B$ of two objects
by the formula (true for funcoids and for reloids):
\[
f\sqcap(A\times B)=I_{B}\circ f\circ I_{A}.
\]

\index{restricting!square}\emph{Square restricting} of an element
$f$ to an object $A$ is a special case of rectangular restricting
and is defined by the formula $I_{A}\circ f\circ I_{A}$ (or by the
formula $f\sqcap(A\times A)$).
\begin{thm}
\label{rect-cont}For every elements~$f$, $\mu$, $\nu$ of our semigroup
and an object $A$
\begin{enumerate}
\item \label{contrestr-C}$f\in\continuous(\mu,\nu)\Rightarrow f|_{A}\in\continuous(I_{A}\circ\mu\circ I_{A},\nu)$;
\item \label{contrestr-Ci}$f\in\continuous'(\mu,\nu)\Rightarrow f|_{A}\in\continuous'(I_{A}\circ\mu\circ I_{A},\nu)$;
\item \label{contrestr-Cii}$f\in\continuous''(\mu,\nu)\Rightarrow f|_{A}\in\continuous''(I_{A}\circ\mu\circ I_{A},\nu)$.
\end{enumerate}

(Two last items are true for the case when our semigroup is dagger.)

\end{thm}
\begin{proof}
~
\begin{widedisorder}
\item [{\ref{contrestr-C}}] ~
\begin{align*}
f|_{A}\in\continuous(I_{A}\circ\mu\circ I_{A},\nu) & \Leftrightarrow\\
f|_{A}\circ I_{A}\circ\mu\circ I_{A}\sqsubseteq\nu\circ f|_{A} & \Leftrightarrow\\
f\circ I_{A}\circ I_{A}\circ\mu\circ I_{A}\sqsubseteq\nu\circ f|_{A} & \Leftrightarrow\\
f\circ I_{A}\circ\mu\circ I_{A}\sqsubseteq\nu\circ f\circ I_{A} & \Leftarrow\\
f\circ I_{A}\circ\mu\sqsubseteq\nu\circ f & \Leftarrow\\
f\circ\mu\sqsubseteq\nu\circ f & \Leftrightarrow\\
f\in\continuous(\mu,\nu).
\end{align*}

\item [{\ref{contrestr-Ci}}] ~
\begin{align*}
f|_{A}\in\continuous'(I_{A}\circ\mu\circ I_{A},\nu) & \Leftrightarrow\\
I_{A}\circ\mu\circ I_{A}\sqsubseteq(f|_{A})^{\dagger}\circ\nu\circ f|_{A} & \Leftarrow\\
I_{A}\circ\mu\circ I_{A}\sqsubseteq(f\circ I_{A})^{\dagger}\circ\nu\circ f\circ I_{A} & \Leftrightarrow\\
I_{A}\circ\mu\circ I_{A}\sqsubseteq I_{A}\circ f^{\dagger}\circ\nu\circ f\circ I_{A} & \Leftarrow\\
\mu\sqsubseteq f^{\dagger}\circ\nu\circ f & \Leftrightarrow\\
f\in\continuous'(\mu,\nu).
\end{align*}

\item [{\ref{contrestr-Cii}}] ~
\begin{align*}
f|_{A}\in\continuous''(I_{A}\circ\mu\circ I_{A},\nu) & \Leftrightarrow\\
f|_{A}\circ I_{A}\circ\mu\circ I_{A}\circ(f|_{A})^{\dagger}\sqsubseteq\nu & \Leftrightarrow\\
f\circ I_{A}\circ I_{A}\circ\mu\circ I_{A}\circ I_{A}\circ f^{\dagger}\sqsubseteq\nu & \Leftrightarrow\\
f\circ I_{A}\circ\mu\circ I_{A}\circ f^{\dagger}\sqsubseteq\nu & \Leftarrow\\
f\circ\mu\circ f^{\dagger}\sqsubseteq\nu & \Leftrightarrow\\
f\in\continuous''(\mu,\nu).
\end{align*}
\end{widedisorder}
\end{proof}

\section{Anticontinuous morphisms}

Let $\mu$ and $\nu$ be endomorphisms of some partially ordered precategory.
\emph{Anticontinuous} functions can be defined as these morphisms $f$ of this
precategory which conform to the following formula:
\[
f\in\continuous_{\ast}(\mu,\nu)\Leftrightarrow f\in\Hom(\Ob\mu,\Ob\nu)\land f\circ\mu\sqsupseteq\nu\circ f.
\]
If the precategory is a partially ordered dagger precategory then
\emph{anticontinuity} also can be defined in two other ways:
\begin{gather*}
f\in\continuous_{\ast}'(\mu,\nu)\Leftrightarrow f\in\Hom(\Ob\mu,\Ob\nu)\land\mu\sqsupseteq f^{\dagger}\circ\nu\circ f;\\
f\in\continuous_{\ast}''(\mu,\nu)\Leftrightarrow f\in\Hom(\Ob\mu,\Ob\nu)\land f\circ\mu\circ f^{\dagger}\sqsupseteq\nu.
\end{gather*}

Anticontinuity is the order dual of continuity.

\begin{thm}
For partially ordered dagger categories:
\begin{enumerate}
\item $f\in\continuous_{\ast}(\mu,\nu)\Leftrightarrow f^{\dagger}\in\continuous(\nu^{\dagger},\mu^{\dagger})$;
\item $f\in\continuous_{\ast}'(\mu,\nu)\Leftrightarrow f^{\dagger}\in\continuous''(\nu^{\dagger},\mu^{\dagger})$;
\item $f\in\continuous_{\ast}''(\mu,\nu)\Leftrightarrow f^{\dagger}\in\continuous'(\nu^{\dagger},\mu^{\dagger})$.
\end{enumerate}
\end{thm}

\begin{proof}
~
\begin{enumerate}
\item $f\in\continuous_{\ast}(f,g)\Leftrightarrow
f\circ\mu\sqsupseteq\nu\circ f\Leftrightarrow
\mu^{\dagger}\circ f^{\dagger}\sqsupseteq f^{\dagger}\circ\nu^{\dagger}\Leftrightarrow
f^{\dagger}\in\continuous(\nu^{\dagger},\mu^{\dagger})$.
\item $f\in\continuous_{\ast}'(\mu,\nu)\Leftrightarrow
\mu\sqsupseteq f^{\dagger}\circ\nu\circ f\Leftrightarrow
f^{\dagger}\circ\nu^{\dagger}\circ f\sqsubseteq\mu^{\dagger}\Leftrightarrow
f^{\dagger}\in\continuous''(\nu^{\dagger},\mu^{\dagger})$.
\item By duality.
\end{enumerate}
\end{proof}

\begin{defn}
\index{open map}An \emph{open map} from a topological space to a
topological space is a function which maps open sets into open sets.
\end{defn}

\begin{thm}
For topological spaces considered as complete funcoids,
a principal anticontinuous morphism is the same as open map.
\end{thm}

\begin{proof}
Because $f$,~$\mu$,~$\nu$ are complete funcoids, we have
\[
f\in\continuous_{\ast}(\mu,\nu)\Leftrightarrow
f\circ\mu\sqsupseteq\nu\circ f\Leftrightarrow
\Compl(f\circ\mu)\sqsupseteq\Compl(\nu\circ f).
\]
Equivalently transforming further, we get
\[
\forall x\in\Ob\mu:\supfun f\rsupfun{\mu}@\{x\}\sqsupseteq\supfun{\nu}\rsupfun
f@\{x\};
\]
\[
\forall x\in\Ob\mu,V\in\rsupfun{\mu}\{x\}:\rsupfun
fV\sqsupseteq\supfun{\nu}\rsupfun f@\{x\},
\]
what is the criterion of~$f$ being an open map.
\end{proof}


\begin{document}

	\subsection{Labelling}

	This is the last step of the pipeline and involves assigning of each voxel to the cluster corresponding to the nearest centroids, in this way a hard segmentation is achieved.

	The script takes as input the CT scan after the lung extraction and it builds the multichannel image as described before. After that it assigns each voxel to the cluster of nearest centroids, which is the one that minimizes the distance:
	\begin{equation}
		cluster = \arg\min_{S}  \sum_{i=1}^k \sum_{S} \| x - \mu_i\|
	\end{equation}

	where $x$ is the colour vector of the voxel and $\mu$ is the $ith$ centroid. During this process, the background is automatically assigned to the 0 labels, passing a mask which assumes $0$ on the voxels background and $1$ for the other one. At the end of the assignment, only the cluster corresponding to GGO and CS is selected.To summarize the process, the pseudocode of the script is reported in the algorithm,\ref{alg:labeling}.
	I have tested this algorithm on three different datasets. The results are described in the next chapter.
	\begin{algorithm}

		\SetAlgoLined
		\DontPrintSemicolon

		\SetKwFunction{Flabel}{imlabeling}
		\SetKwProg{Fn}{Function}{:}{}

		\KwData{CT scan to label, centroids}
		\KwResult{GGO label}

		image$\leftarrow$build\_multi\_channel\;
		\tcc{Compute distances and found the minimum}
		\ForEach{$c\in centroids $}
		{
			distances$\leftarrow\| image - c\|^2$\;
		}

		labels$\leftarrow\arg\min\,(distances)$\;

		\caption{Pseudo-code for the labeling script}\label{alg:labeling}

	\end{algorithm}

 	The assignment process is performed by the \textsc{imlabeling} function, which takes care to assign the background to $0$, if the suitable parameter is passed. The function is implemented as follows:

	\lstset{style=python}
	\begin{lstlisting}[language=python, caption=imlabeling, label=code:imlabeling]

	import numpy as np

	def imlabeling(image, centroids, weight = None) :

		if weight  is not None :
			distances = np.asarray([np.linalg.norm(image[weight != 0] -c,
									axis = 1) for c in centroids])

			weight[weight != 0] = np.argmin(distances, axis = 0)
			return weight
		else :
			distances = np.asarray([np.linalg.norm(image -c, axis = 3)
									for c in centroids])
			labels = np.argmin(distances, axis = 0)
			return labels

	\end{lstlisting}

\end{document}


\mychapter{16}{Lesson 16} %181121

\section{\textsc{Pke} schemes over \ddh{} assumption}

\subsection{ElGamal scheme}

Let's define a new $\Pi = (\keygen, \Enc, \Dec)$. Generate the needed public parameters $(G,g,q) \pickUAR \groupgen(1^{\lambda})$\footnotemark, then:

\footnotetext{G could be any valid group such as $\quadres_p$, or an elliptic curve group}

\begin{itemize}
    \item Key generation: $(\pk, \sk) = (g^x, x)$, where $x \pickUAR \integer_q$
    \item Encryption: $\Enc(\pk, m) = (g^r, \pk^r \cdot m)$, where $r \pickUAR \integer_q$\footnote{We need $r$ because we want to re-randomize $c$}
    \item Decryption: $\Dec(\sk, (c_1, c_2))= c_1^{-\sk} \cdot c_2$
\end{itemize}

The correctness of the scheme follows from some algebraic steps:
\begin{align*}
    \hat{m} &= \Dec(\sk, \Enc(\pk, m))          \\
            &= \Dec(x, \Enc(g^x, m))            \\
            &= \Dec(x, (g^r, (g^x)^r \cdot m))  \\
            &= (g^r)^{-x} \cdot (g^x)^r \cdot m \\
            &= m                                \\
\end{align*}

\begin{theorem}
    Assuming \textsc{ddh}, the ElGamal scheme is \textsc{cpa}-secure.
\end{theorem}

\begin{proof}
    Consider the two following games $\hybridg{0}(\lambda, b)$ and $\hybridg{1}(\lambda, b)$ defined as follows. Observe that $b$ can be fixed without loss of generality.

    \begin{cryptogame}
        {pke1}
        {$\hybridg{0}(\lambda, b) = \cryptog{gamal}(\lambda, b)$}
        {gamal}

        \receive{\shortstack[l]{
            $x \pickUAR \integer_q$ \\
            $\pk = g^x$
        }}{$\pk$}{}

        \cseqdelay
        \send{}{$m_0, m_1$}{}
        \cseqdelay
        \receive{\shortstack[l]{
            $r \pickUAR \integer_q$ \\
            $b \pickUAR \binary$ \\
            $c = \Enc(\pk, m_b) = (g^r, (g^x)^r m_b)$
        }}{$c$}{}
        \cseqdelay

        \send{}{$b'$}{\textsc{Output 1 iff} $b' = b$}

    \end{cryptogame}

    \begin{cryptogame}
        {pke2}
        {$\hybridg{1}(\lambda, b)$}
        {$\neg$gamal}

        \receive{\shortstack[l]{
            $x \pickUAR \integer_q$ \\
            $\pk = g^x$
        }}{$\pk$}{}

        \cseqdelay
        \send{}{$m_0, m_1$}{}
        \cseqdelay
        \receive{\shortstack[l]{
            $r, z \pickUAR \integer_q$ \\
            $c = (g^r, g^z m_b)$
        }}{$c$}{}
        \cseqdelay

        \send{}{$b'$}{\textsc{Output 1 iff} $b' = b$}

    \end{cryptogame}

    % The reasoning was a bit cloudy, hope now it is clearer
    %AP190915: Not so sure...
    \textbf{Note:} it is important to note that we can measure the advantage of $\adversary$, so fixed its output $Adv_{\adversary}(\lambda) = |\underbrace{\Pr[\overbrace{\adversary = 1}^{b' = 1} \knowing b = 0}_{\adversary\ loses}] - \underbrace{\Pr[\overbrace{\adversary = 1}^{b' = 1} \knowing b = 1]}_{\adversary\ wins}|$. Since $b$ is fixed the above formula will give a value $\lambda \in negl$, generally the advantage of an adversary is: $\frac{1}{2}+\lambda$ (random guessing + a negligible factor). %maybe this is a repetition but I think I never wrote it anywhere else

    \todo{Here the 1/2 value may refer to how the Katz-Lindell book exposes their proofs by leaving an arbitrary choice of $b$ to the challengers, thus limiting the probability of the adversaries' success by 1/2.

    Venturi prefers to fix $b$ beforehand, meaning the whole proof can be stated by setting b to either 0 or 1, and maintain its validity without changing anything else. In this way, he somehow bounds the probability of success to be $\leq \negl(\lambda)$}

    We will prove that:
    \[
        \hybridg{0}(\lambda, 0) \compindist \hybridg{1}(\lambda, 0) \equiv \hybridg{1}(\lambda, 1) \compindist \hybridg{0}(\lambda, 1)
    \]

    \begin{claim}
        $\forall b \in \binary \implies \hybridg{0}(\lambda, b) \compindist \hybridg{1}(\lambda, b)$
    \end{claim}

    \begin{proof}
        This proof reduces to disproving \ddh. Fix $b$ without loss of generality, and assume there exists a distinguisher $\distinguisher$ able to distinguish $H_0(\lambda,b)$ and $H_1(\lambda,b)$. Consider the game in figure \ref{cryptoredux:gamalddh}:

        \begin{cryptoredux}
            {gamalddh}
            {---}
            {ddh}
            {gamal}

            \receive{\shortstack[l]{
                $X = g^x, Y = g^y$ \\
                $Z_0 = g^{xy}, Z_1 = g^z$ \\
                $b \pickUAR \binary$
            }}{$(X, Y, Z_b)$}{}

            \invoke{}{$\pk = X$}{}
            \cseqdelay
            \return{}{$(m_0, m_1)$}{}
            \invoke{$\boxed{a = 0}$ }{$(Y, Z_b \cdot m_a)$}{}
            \cseqdelay
            \return{}{$a'$}{}

            \cseqdelay

            \send{$b' = \begin{cases}
                    0 & \textsc{iff} \boxed{a' = 0} \\
                    1 (coin?) & \textsc{else} \\
                \end{cases}
            $}{$b'$}{\textsc{Output 1 iff} $b' = b$}

        \end{cryptoredux}

        If $\distinguisher^{\textsc{gamal}}$ is able to break the cipher, then \adversary{} is in turn able to distinguish a \textsc{dh} triple from a random one, falsifying \ddh.
    \end{proof}

    \begin{claim}
        $\hybridg{1}(\lambda, 0) \equiv \hybridg{1}(\lambda, 1)$
    \end{claim}

    \begin{proof}
        This follows from the fact that:
        \[
            (g^x, (g^r, g^z m_0)) \equiv (g^x, (g^r, U_\lambda) \equiv (g^x, (g^r, g^z m_1)))
        \]
    \end{proof}

    Composing the two claims, the proof is complete.

\end{proof}

\subsubsection{Properties of of El Gamal \textsc{pke} scheme}

Some useful observations can be made about this scheme:
\begin{itemize}
    \item It is \textbf{homomorphic}: Given two ciphertexts $(c_1, c_2)$ and $(c_1', c_2')$, then doing the product between them yields another valid ciphertext:
    % I'd like to expand a bit more here, or else it may stay a bit obscure...
    \begin{align*}
        & (c_1 \cdot c_1', c_2 \cdot c_2') \\
        =& (g^{r + r'}, h^{r + r'}(m \cdot m'))
    \end{align*}
    thus, decrypting $c \cdot c'$, gives $m \cdot m'$.

    \item It is \textbf{re-randomizable}: Given a ciphertext $(c_1, c_2)$, and $r' \pickUAR \integer_q$, then computing $(g^{r'} \cdot c_1, h^{r'} \cdot c_2)$ results in a ``fresh'' encryption for the same message: the random value used at the encryption step will change from the original $r$ to $r + r'$
\end{itemize}
These observations lead to the conclusion that this scheme is not \cca-secure. However, such properties can be desirable in some use cases, where a message must be kept secret to the second party. In fact, there are some \pke{} schemes which are designed to be \textbf{fully homomorphic}, i.e. they are homomorphic for any kind of function.

Consider the following use case: a client $C$ has an object $x$ and wants to apply a function $f$ over it, but it lacks the computational power to execute it. There is another subject $S$, which is able to efficiently compute $f$, so the goal is to let it compute $f(x)$ but the client wishes to keep $x$ secret from him. This can be achieved using a \textsc{fh-pke} scheme as follows:

% QUESTION: Why use a PKE scheme (and not an SKE)? Are there some advantages-shortcomings?

\begin{cryptosequence}
    {delseccomp}
    {Delegated secret computation}

    \cseqentity{C}{Client}
    \cseqentity[2.2]{S}{Server}

    \cseqdelay

    % Client encrypts object and sends application request
    \cseqmessager{C}{\shortstack[r]{
        Object: $x$ \\
        Function: $f$ \\
        $(\pk, \sk) \pickUAR \mathcal{KG}en$ \\
        $c \pickUAR \Enc(\pk, x)$
    }}{$f, c$}{S}{}

    \cseqdelay
    \cseqdelay

    \cseqmessagel{S}{}{$f(c)$}{C}{$f(x) = \Dec(\sk, f(c))$}

\end{cryptosequence}

However one important consideration must be made: All these useful characteristics expose an inherent malleability of any fully homomorphic scheme: any attacker can manipulate ciphertexts efficiently, and with some predictable results. This compromises even \textsc{cpa} security of such schemes.

%\subsection{Cramer-Shoup \textsc{pke} scheme}
\section{Proof systems}

% Not sure if CS is defined over DDH, or this is the DDH variant of CS, making CS more abstract
This new scheme assumes \ddh{} like its ElGamal cousin, and has the advantage of being \cca-secure. A powerful tool, called \emph{Designated Verifier Non-Interactive Zero-Knowledge} (\textsc{dv-nizk} in short), or alternatively \emph{Hash-Proof System}, is used here.

\todo{the Ali Baba example would be useful here. Also, the coloured balls is a good example too (long live Wikipedia)}

Let $L \subseteq Y$ be a Turing-recognizable language in \textsc{np}, and a predicate $V \in X \times Y \to \binary$ such that:
\[
    L := \{y \in Y : \exists x \in X \implies V(x, y) = 1\}
\]
where $x$ is called a \emph{witness} of $y$.

\todo{to review and understand/better}

% AP181122-1554: CAUTION FRAGMENTED
In our case, let $x = (p, q), y = pq$, and define a scheme $\Pi$ as follows:

\[
    \Pi = (\mathcal{S}etup, \mathcal{P}rove, \mathcal{V}erify)
\]

% AP190914: Is (omega, tau) the (pk, sk) couple?
\begin{itemize}
    \item Setting up: $(\omega, \tau) \pickUAR \mathcal{S}etup(1^\lambda)$, where $\omega$ is the \emph{common reference string}, and $\tau$ is the \emph{trapdoor}
    \item Proving a statement: $\pi = \mathcal{P}rove(\omega, y, x)$
    \item Verifying: $\widehat{\pi} = \mathcal{V}erify(\tau, y)$
\end{itemize}

Correctness is defined as $\mathcal{P}rove(\omega, y, x) = \mathcal{V}erify(\tau, y)$. Some more observations:

\begin{itemize}
    \item $\omega$ is public ($ = pk$)
    \item $\tau$ is part of the secret key
    \item $\tau = (x, y) : V(x, y) = 1$ %May be false
    \item There is presumably a common third-party, which samples from the setup and publishes $\omega$, while giving $\tau$ to only B.
    \todo{Why? Can't the verifier do the setup and publish omega directly? Is honesty an issue here?}
\end{itemize}

\begin{cryptosequence}
    {csoverview}
    {Overview of Cramer-Shoup operation}

    \cseqentity{P}{Prover}
    \cseqentity[2.2]{V}{Verifier}

    \cseqdelay

    \cseqmessager{P}{\shortstack[r]{
        $\omega$\\
        $(x,y)$ s.t. $R(x,y)=1$
    }}{$\pi = \mathcal{P}rove(\omega, y, x)$}{V}{\shortstack[l]{
        $\tau, y' \in L$\\
        $Ver(\tau,y)=\tilde{\pi}\in P$\\
        check if $\pi = \tilde{\pi}$
        %Object: $x$ \\
        %Function: $f$ \\
        %$(pk, sk) \pickUAR \mathcal{KG}en$ \\
        %$c \pickUAR Enc(pk, x)$
    }}

\end{cryptosequence}

The purpose of a proof system is to give a way to convince someone (the ``verifier'') that someone else (the ``prover'') knows something (the ``statement'' $y$), and nothing more, to no one else. The proof can be computed in two different ways, this is the core notion of \emph{zero-knowledge}, $\neg \tau \implies \textsc{zk}$

\subsubsection{Properties}

\begin{itemize}
    \item \textit{honest people} \textbf{Completeness}:
    \[
        \forall y \in L, \forall (\omega, \tau) \pickUAR \mathcal{S}etup(1^\lambda) \implies \mathcal{P}rove(\omega, y, x) = \mathcal{V}erify(\tau, y)
    \]
    \item \textit{(stronger, against malicious prover)} \textbf{Soundness}: It is hard to produce a valid proof for any $y \notin L$
    \item \textit{(characteristic, against malicious verifier)} \textbf{Zero-knowledge}: Proof for $x$ can be simulated without knowing $x$ itself
\end{itemize}

\begin{definition}[$t$-universality, or $t - 1$ simulation soundness]
    % Designated verifier non-interactive zero-knowledge
    Let $\Pi$ be a \textsc{dv-nizk} scheme; it is \textit{t-universal} iff for any distinct $y_{1 \upto t} \notin L$ we have:
    \[
        (\omega, \mathcal{V}erify(\tau, y_1), \ldots, \mathcal{V}erify(\tau, y_{t})) = (\omega, v_1, \ldots, v_t)
    \]
    where $(\omega, \tau) \pickUAR \mathcal{S}etup(1^\lambda)$ and $v_{1 \upto t} \pickUAR \mathcal{P}roof$, where $\mathcal{P}roof$ is the proofs' space.
\end{definition}

\subsubsection{Enriching a proof system}

We can ``enrich'' a \textsc{dv-nizk} scheme with labels $l \in \binary^*$. Suppose to have the following:
\[
    L' = L \| \binary^* = \{(y, l) \in L \times \binary^*\}
\]
Then our scheme changes, because the statements are now compositions of a label $l$ along with te actual statement $y$; for the \textit{t-universality} property, we can now consider two distinct $(y_i, l_i)$.

\subsubsection{Membership-hard language}

\begin{definition}
    Language $L$ is \emph{membership-hard} iff there exists a language $\overline{L}$ such that:
    \begin{enumerate}
        \item $L \cap \overline{L} = \emptyset$
        \item $\exists \textsf{\textup{Sample}} \in \ppt$ outputting $y \pickUAR \mathcal{Y}$ together with $x \in \overline{X}$ such that $R(y, x) = 1$

        (therefore $(y, x) \pickUAR \textsf{\textup{Sample}}(1^{\lambda})$)
        \item $\exists \overline{\textsf{\textup{Sample}}} \in \ppt$ outputting $y \pickUAR \overline{L}$
        \item $\{y : (y, x) \pickUAR \textsf{\textup{Sample}}(1^{\lambda})\} \compindist \{y : y \pickUAR \overline{\textsf{\textup{Sample}}}(1^{\lambda})\}$
    \end{enumerate}

\end{definition}


\label{s:appendix:tight-binding}
In this appendix,
we review the assumptions of the tight-binding model
as derived from Bloch's theorem.
We denote the position and momentum operators
respectively by $\vc{Q}$ and $\vc{P}$.

\section{Transition operators}

We first define the position-space translation operator,
$T \of{\vc{r}} = e^{- i \vc{r} · \vc{P}}$,
and the momentum-space translation operator,
$T_{\vK} = e^{- i \vc{k} · \vc{Q}}$.
We assume zero magnetic field.%
\footnote{%
  For nonzero field, much of the following can be recast
  in terms of the magnetic translation operators~\cite{PhysRev.133.A1038}.
}
Each has a simple inverse:
$T^{-1} \of{\vc{r}} = T \of{- \vc{r}}$
and
$T_{\vK}^{-1} = T_{- \vK}$.
We also note the derivatives:
$∇_{\vK} T_{\vK} = - i \vc{Q} T_{\vK}$
and
$∇_{\vK} T^{-1}_{\vK} = i \vc{Q} T^{-1}_{\vK}$.

We can compute a useful commutation relation of these translations operators.
Application of the Baker–Campbell–Hausdorff formula gives
\begin{subequations}
  \begin{align}
    T \of{\vc{r}} T_{\vK}
    & = e^{- i \left( \vc{r} · \vc{P} + \vc{k} · \vc{Q} \right)
      - \frac{1}{2} \left[ \vc{r} · \vc{P}, \vc{k} · \vc{Q} \right]}, \\
    T_{\vK} T \of{\vc{r}}
    & = e^{- i \left( \vc{r} · \vc{P} + \vc{k} · \vc{Q} \right)
      + \frac{1}{2} \left[ \vc{r} · \vc{P}, \vc{k} · \vc{Q} \right]}.
  \end{align}
\end{subequations}
Only a single commutator appears above since
$\left[ \vc{r} · \vc{P}, \vc{k} · \vc{Q} \right] = - i \vc{r} · \vc{k}$.
Substituting this gives
\begin{equation}
  \label{eq:translations:commutation}
  T \of{\vc{r}} T_{\vK}
  = e^{-i \vc{r} · \vc{k}} T_{\vK} T \of{\vc{r}}.
\end{equation}

\section{Bloch Hamiltonian}

Given a Hamiltonian $H$ and a set of $N$ lattice vectors
$\left\{ \vRn{n} \right\}$ such that the Hamiltonian
commutes with each $T \of{\vRn{n}}$,
we may choose a set of common eigenvectors according to Bloch's theorem,
\begin{subequations}
  \begin{align}
    H \Ket{ψ_{n \vK}}
    & = E_{n \vK} \Ket{ψ_{n \vK}}, \\
    T \of{\vRn{m}} \Ket{ψ_{n \vK}}
    & = e^{-i \vK · \vRn{m}} \Ket{ψ_{n \vK}}.
  \end{align}
\end{subequations}
Given periodic boundary conditions,
the set of allowed $\vK$ becomes countable
and may be restricted to the first Brillouin zone
due to the periodicity of the eigenvalues
with respect to translation by a reciprocal lattice vector $\vc{G}$.
For each $\vK$, the transformation
$\Ket{u_{n \vK}} = T_{\vK} \Ket{ψ_{n \vK}}$
gives a set of states which are invariant under lattice translations, i.e.,
using \cref{eq:translations:commutation},
$T \of{\vRn{m}} \Ket{u_{n \vK}} = \Ket{u_{n \vK}}$.
A general operator then transforms according to
$A_{\vK} = T_{\vK} A T_{\vK}^{-1}$.
Note that the derivative of a transformed operator may be computed as
\begin{equation}
  ∇_{\vK} A_{\vK}
  = ∇_{\vK} \left( T_{\vK} A T_{\vK}^{-1} \right)
  = i \left[ A_{\vK}, \vc{Q} \right].
\end{equation}

\section{Tight-binding approximation}

In the tight biding model, one assumes there exists a finite set
$\left\{ \Ket{φ_ν} \right\}$ of relevant atomic orbitals.
The corresponding Bloch orbital states,
\begin{equation}
  \Ket{ϕ_{ν \vK}}
  = \frac{1}{\sqrt{N}}
    ∑_{n = 1}^N e^{i \vK ⋅ \vRn{n}}
    T \of{\vRn{n}} \Ket{φ_ν},
\end{equation}
provide a complete bases for the space
of Bloch eigenstates $\left\{ \Ket{ψ_{n \vK}} \right\}$, i.e.,
\begin{subequations}
  \begin{align}
    \Ket{ψ_{n \vK}} & = ∑_ν M_{\vK}^{ν n} \Ket{ϕ_{ν \vK}}, \\
    \Ket{ϕ_{ν \vK}} & = ∑_n W_{\vK}^{n ν} \Ket{ψ_{n \vK}},
  \end{align}
\end{subequations}
with $M_{\vK}^{ν n} = \cc{W}_{\vK}^{ν n}$.
The second overlap term in
\begin{equation}
  \Braket{ϕ_{ν' \vK} | ϕ_{ν \vK}}
  = \Braket{φ_{ν'} | φ_ν}
  + ∑_{\vRn{n} ≠ 0}^N e^{i \vK ⋅ \vRn{n}}
    \Braket{φ_{ν'} | T \of{\vRn{n}} | φ_ν}
\end{equation}
is small, thus the states
$\left\{ \Ket{φ_ν} \right\}$ are assumed formally orthonormal.

Since each $\Ket{ϕ_{n k}}$ satisfies
\begin{equation}
  T \of{\vRn{m}} \Ket{ϕ_{ν \vK}}
  = e^{-i \vK · \vRn{m}} \Ket{ϕ_{ν \vK}},
\end{equation}
the transformed orbital states
$\Ket{v_{n \vK}} = T_{\vK} \Ket{ϕ_{n k}}$
are invariant under lattice translations.
One typically knows the matrix elements
of an effective Hamiltonian
in the bases of these periodic Bloch orbitals,
\begin{equation}
  H_{\vK}^{ν ν'}
  = \Braket{v_{ν \vK} | H_{\vK} | v_{ν' \vK}}
  = ∑_n \cc{W}_{\vK}^{n ν} E_{n \vK} W_{\vK}^{n ν'},
\end{equation}
which determines the coefficients $M_{\vK}^{ν n}$.


%=======================================================================  solving_equations
\section{Solving equations}
\label{sec:solving_equations}

	Most math skills boil down to being able to manipulate and solve equations.
	Solving an equation means finding the value of the unknown in the equation.

	Check this \pgt{}{shit} out:
	\[
	 x^2-4=45.
	\]
	To solve the above equation is to answer
	the question ``What is $x$?''
	More precisely, we want to find the number that can take the
	place of $x$ in the equation so that the equality holds.
	In other words, we're asking,
	\[
	  \text{``Which number times itself minus four gives 45?''}
	\]
	That is quite a mouthful, don't you think?
	To remedy this verbosity, mathematicians often use specialized symbols to describe math operations.
	The problem is that these specialized symbols can be very confusing.
	Sometimes even the simplest math concepts are inaccessible if you don't know what the symbols mean.

	What are your feelings about math, dear reader? Are you afraid of it?
	Do you have anxiety attacks because you think it will be too difficult for you?
	Chill! Relax, my brothers and sisters. There's nothing to it.
	Nobody can magically guess the solution to an equation immediately.
	To find the solution, you must break the problem into simpler steps.
	Let's walk through this one together.

	To find $x$, we can manipulate the original equation,
	transforming it into a different equation (as true as the first) that looks like this:
	\[
	  x \; = \textrm{ only numbers.}
	\]

	\noindent
	That's what it means to \emph{solve} an equation:
	the equation is solved because the unknown is isolated on one side,
	while the constants are grouped on the other side.
	You can type the numbers on the right-hand side into a calculator and obtain the numerical value of $x$.

	By the way, before we continue our discussion,
	let it be noted: the equality symbol ($=$) means that all that is to the left of $=$
	is equal to
	all that is to the right of $=$.
	To keep this equality statement true,
	\textbf{for every change you apply to the left side of the equation,
	you must apply the same change to the right side of the equation}.

	% Keeping that rule in mind,
	To find $x$,
	we need to manipulate the original equation into its final form,
	simplifying it step by step until it can't be simplified any further.
	The only requirement is that the manipulations we make transform one true equation into another true equation.
	In this example,
	the first simplifying step is to add the number four to both sides of the equation:
	\[
	 	x^2-4  \; + 4  	=	45    \; + 4, 	    \\
	\]
	which simplifies to
	\[
		x^2 	 		=	49.
	\]
	Now the expression looks simpler, yes?
	How did I know to perform this operation?
	I wanted to ``undo'' the effects of the operation $-4$.
	We undo an operation by applying its \emphindexdef{inverse}.
	In the case where the operation is the subtraction of some amount,
	the inverse operation is the addition of the same amount.

	We're getting closer to our goal of \emph{isolating} $x$ on one side of the equation,							\index{isolate}
	leaving only numbers on the other side.
	The next step is to undo the square $x^2$ operation.
	The inverse operation of squaring a number $x^2$ is to take its square root $\sqrt{\phantom{a}\; }$,
	so that's what we'll do next. We obtain
	\[
	   \sqrt{x^2} 		= 	\sqrt{49}.
	\]
	Notice how we applied the square root  to both sides of the equation?
	If we don't apply the same operation to both sides, we'll break the equality!

	The equation $\sqrt{x^2}= \sqrt{49}$ simplifies to
	\[
	 	|x|	= 	7.
	 \]
	What's up with the vertical bars around $x$?
	The notation $|x|$ stands for the \emph{absolute value} of $x$,											\index{absolute value}
	which is the same as $x$ except we ignore the sign that indicates whether $x$ is positive or negative.
	For example $|5|=5$ and $|-5|=5$, too.
	The equation $|x|=7$ indicates that both $x=7$ and $x=-7$ satisfy the equation $x^2 = 49$.
	Seven squared is 49, $7^2=49$, and negative seven squared is also 49, $(-7)^2 = 49$,
	because the two negative signs cancel each other out.

	The final solutions to the equation $x^2-4=45$ are													\index{solution set}
	\[
	 x  = 7 \qquad \textrm{and} \qquad   x=  - 7.
	\]
	Yes, there are \emph{two} possible answers.
	You can check that both of the above values of $x$ satisfy the initial equation $x^2-4=45$.

	\bigskip

	If you are comfortable with all the notions of high school math
	and you feel you could have solved the equation $x^2-4=45$ on your own,		% TODOv6: special comment for readers who expected there to be two solutions
	then you can skim through this chapter quickly.
	If on the other hand you are wondering how the squiggle killed the power two,
	then this chapter is for you!
	In the following sections we will review all the essential concepts from
	high school math that you will need to power through the rest of this book.
	First, let me tell you about the different kinds of numbers.


\documentclass{article}
\usepackage{amsmath,amssymb}
\usepackage{hyperref}
\usepackage{graphicx}

\title{\bf{Drag Polar Analysis}}
\author{Nicholas Malaya \\ Institute for Computational Engineering and Sciences \\ University of Texas at Austin} \date{}

\begin{document}
\maketitle

\newpage

The power extracted by the turbine is,
\begin{equation}
 P = \Omega Q
\end{equation}
where the torque, Q, is,
\begin{equation}
 Q = A_R \int_0^{2\pi} \int_{r_{\text{min}}}^{r_{\text{max}}} F''_{\tau}\, r\, dr d\theta.
\end{equation}
Here, $A_R$ is the relative area coefficient which is,
\begin{equation}
A_R = \frac{c B (r_{\text{max}}-r_{\text{min}})}{\pi(r_{\text{max}}^2-r_{\text{min}}^2)}
\end{equation}
where B is the number of blades, $r_{\text{max}}$ and $r_{\text{min}}$
are the turbine radii, and $F''_{\tau}$ is the force per unit
area on the turbine, which is,
\begin{equation}
 F''_{\tau} = \frac{F_{\tau}}{cl}= \frac{1}{2}\rho U_R^2 \, C_{\tau}.
\end{equation}
with $U_R$ the magnitude of relative velocity and $c$ is the blade chord
length, which is assumed to be constant (not a function of the radius,
for instance). Finally, $C_{\tau}$ is the tangential force coefficient,
which depends on the local lift and drap coefficients, as well as the
flow angle, $\phi$,
\begin{equation}
 C_{\tau} = C_L \,\text{sin}(\phi) + C_D \,\text{cos}(\phi)
\end{equation}
Combining the equations above results in an expression for the power
that explicitly depends on the lift and drag coefficients,
\begin{equation*}
 P = \frac{\Omega \rho c B (r_{\text{max}}-r_{\text{min}})}{2 \pi(r_{\text{max}}^2-r_{\text{min}}^2)}
\int_0^{2\pi}
\int_{r_{\text{min}}}^{r_{\text{max}}} U_R(r,\theta,\Omega)^2 \left(C_L
						     \,\text{sin}(\phi)
						     + C_D
						     \,\text{cos}(\phi)
						    \right) r\,dr d\theta.
\end{equation*}
We lump the constant terms together, $E_{\tau} = \frac{\Omega \rho c B (r_{\text{max}}-r_{\text{min}})}{2 \pi(r_{\text{max}}^2-r_{\text{min}}^2)}$ and separate this equation,
\begin{align}
 P_L = E_\tau
 \int_0^{2\pi}
  \int_{r_{\text{min}}}^{r_{\text{max}}} U_R(r,\theta,\Omega)^2 \, C_L(\phi,r)
 \,\text{sin}(\phi)\, r\,dr d\theta,  \label{lift} \\
 P_D = E_\tau
 \int_0^{2\pi}
  \int_{r_{\text{min}}}^{r_{\text{max}}} U_R(r,\theta,\Omega)^2 \, C_D(\phi,r) \,\text{cos}(\phi)\, r\,dr d\theta. \label{drag}
\end{align}
Note that we have assumed $C_D = C_D(\phi,r)$ and $C_L = C_L(\phi,r)$,
namely, that the coefficients vary with the flow direction and may vary
radially, due to twisting the blade angle. Furthermore, the flow
direction, $\phi$, varies with the location as well as the blade speed,
in that $\phi=\phi(r,\theta,\Omega)$. The relative velocity is the
quantity, $U_R = U - U_\tau$, e.g. the difference in velocity between
the turbine and the flow. The turbine has no axial velocity ($w_\tau = 0$) and a
constant rotation speed, and so the two components of velocity in the
plane of rotation can be expressed as,
\begin{align}
 u_\tau = \Omega \,r\, \text{sin}(\theta)\\
 v_\tau = \Omega \,r\, \text{cos}(\theta)
\end{align}

Our objective is now to discover what these unknown functions of lift
and drag are. To do this, we specify an optimization problem such that,
\begin{equation*}
 \text{Max } P(C_L,C_D) \quad \text{ subject to: }
  \begin{cases}
   |C_L| < C_L^{\text{Max}}, \\
   0 < C_D < C_D^{\text{Max}}. \\
  \end{cases}
\end{equation*}

In words, the drag must be specified to be greater than zero, but
the lift can be negative. For these conditions, we are interested in
largest attainable values. For the drag coefficient, $C_D^{\text{Max}}$
is two. % refmunson
This corresponds to a flat plate perpendicular to the flow.
The lift coefficient peak is about 1.75. This design is not necessarily
physically realizable, but represents an absolute maximum.

%
% does this argument still work?!?
%
The integral shown in Equation \ref{lift} above can be bounded by
Schwarz's Inequality,
\begin{align*}
  \left[
    \int_0^{2\pi}
    \int_{r_{\text{min}}}^{r_{\text{max}}} C_L(\phi,r)\, U_R(r,\theta,\Omega)^2
 \,\text{sin}(\phi)\, r\,dr d\theta \right]^2 \le \\
  \int_0^{2\pi} \int_{r_{\text{min}}}^{r_{\text{max}}} C_L^2(\phi,r) dr d\theta\,
  \int_0^{2\pi} \int_{r_{\text{min}}}^{r_{\text{max}}} U_R(r,\theta,\Omega)^4
 \,\text{sin}^2(\phi)\, r^2\,dr d\theta.
\end{align*}
In this way the quantity,
\begin{equation}
  \int_0^{2\pi}
 \int_{r_{\text{min}}}^{r_{\text{max}}} C_L^2(\phi,r) dr d\theta,
\end{equation}
is clearly maximized when $C_L(\phi,r) = C_L^{\text{max}}$.
The result for Equation \ref{drag} is identical.
Therefore, our lift/drag functions may be expressed as,
\begin{align*}
 C_D(\phi) = \bar C_D \, \psi(\phi)
  \begin{cases}
   \psi(\phi) = 1 \text{ if sin}(\phi) > 0,   \\
   0 \text{ else} \\
  \end{cases} \\
 C_L(\phi) = \bar C_L \, \Psi(\phi)
  \begin{cases}
   \Psi(\phi) = 1 \text{ if cos}(\phi) > 0,   \\
   -1 \text{ else}. \\
  \end{cases}
\end{align*}
Where $\bar C_L = 1.7$ and $\bar C_D = 2.0$.

%Thus, the drag polars
%have the form,
%\begin{align*}
% &C_L(\phi) =
%  \begin{cases}
%    1.75& \quad 0^{\circ} \le \phi \le 180^{\circ}, \\
%   -1.75& \quad 180^{\circ} \le \phi \le 360^{\circ}.  \\
%  \end{cases}\\
% &C_D(\phi) =
%  \begin{cases}
%    2.0& \quad -90^{\circ} \le \phi \le 90^{\circ}, \\
%      0& \quad 90^{\circ} \le \phi \le 270^{\circ}.  \\
%  \end{cases}\\
%\end{align*}
The plot of these drag polars are shown in Figure \ref{drags}.

\begin{figure}[!htb]
  \begin{center}
    \includegraphics[width = 12 cm]{figs/drags}
    \caption{The idealized drag polars.}
    \label{drags}
  \end{center}
\end{figure}

\newpage
\section{Questions}

\begin{itemize}
 \item Does this need regularization to ensure well-posedness?
 \item Boundary conditions are periodic
 \item What about supporting twist? (e.g. $\beta = \beta(r)$)
 \item Can we constrain $C_L, C_D$?
 \item Is this just linear programming?
\end{itemize}
Betz limit is 16/27
\end{document}


\documentclass{article}
    % General document formatting
    \usepackage[margin=0.7in]{geometry}
    \usepackage[parfill]{parskip}
    \usepackage[utf8]{inputenc}
    \usepackage{amsmath}
    \usepackage{tikz}
    \usepackage{fancyhdr}

\pagestyle{fancy}
\fancyhf{}
\rhead{Edgar Jacob Rivera Rios - A01184125}

\begin{document}
\section*{2.2.1 Propositional Logic.}
Prove the following logical equivalences making use of truth tables:
\renewcommand{\labelenumi}{\alph{enumi})}
\begin{enumerate}
    \item $A \wedge (B \vee C) \equiv (A \wedge B) \vee (A \wedge C)$
    \begin{table}[h!]
        \centering
        \begin{tabular}{|c|c|c|c||c|}
            \hline
            \textbf{A} & \textbf{B} & \textbf{C} & \textbf{$A \wedge (B \vee C)$} & \textbf{$(A \wedge B) \vee (A \wedge C)$}\\
            \hline
            1 & 1 & 1 & 1 & 1\\
            \hline
            1 & 1 & 0 & 1 & 1\\
            \hline
            1 & 0 & 1 & 1 & 1\\
            \hline
            1 & 0 & 0 & 0 & 0\\
            \hline
            0 & 1 & 1 & 0 & 0\\
            \hline
            0 & 1 & 0 & 0 & 0\\
            \hline
            0 & 0 & 1 & 0 & 0\\
            \hline
            0 & 0 & 0 & 0 & 0\\
            \hline
        \end{tabular}
    \end{table}

    \item $A \vee B \equiv \neg(\neg A \wedge \neg B)$
    \begin{table}[h!]
        \centering
        \begin{tabular}{|c|c|c||c|}
            \hline
            \textbf{A} & \textbf{B} & \textbf{$A \vee B$} & \textbf{$\neg(\neg A \wedge \neg B)$}\\
            \hline
            1 & 1 & 1 & 1 \\
            \hline
            1 & 0 & 1 & 1 \\
            \hline
            0 & 1 & 1 & 1 \\
            \hline
            0 & 0 & 0 & 0 \\
            \hline
        \end{tabular}
    \end{table}

    \item $A \wedge B \equiv \neg(\neg A \vee \neg B)$
    \begin{table}[h!]
        \centering
        \begin{tabular}{|c|c|c||c|}
            \hline
            \textbf{A} & \textbf{B} & \textbf{$A \wedge B$} & \textbf{$\neg(\neg A \vee \neg B)$}\\
            \hline
            1 & 1 & 1 & 1 \\
            \hline
            1 & 0 & 0 & 0 \\
            \hline
            0 & 1 & 0 & 0 \\
            \hline
            0 & 0 & 0 & 0 \\
            \hline
        \end{tabular}
    \end{table}

    \item $A \rightarrow B \equiv \neg A \vee B$
    \begin{table}[h!]
        \centering
        \begin{tabular}{|c|c|c||c|}
            \hline
            \textbf{A} & \textbf{B} & \textbf{$A \rightarrow B$} & \textbf{$\neg A \vee B$}\\
            \hline
            1 & 1 & 1 & 1 \\
            \hline
            1 & 0 & 0 & 0 \\
            \hline
            0 & 1 & 1 & 1 \\
            \hline
            0 & 0 & 1 & 1 \\
            \hline
        \end{tabular}
    \end{table}

    \item $A \rightarrow B \equiv \neg(A \wedge \neg B)$
    \begin{table}[h!]
        \centering
        \begin{tabular}{|c|c|c||c|}
            \hline
            \textbf{A} & \textbf{B} & \textbf{$A \rightarrow B$} & \textbf{$\neg(A \wedge \neg B)$}\\
            \hline
            1 & 1 & 1 & 1 \\
            \hline
            1 & 0 & 0 & 0 \\
            \hline
            0 & 1 & 1 & 1 \\
            \hline
            0 & 0 & 1 & 1 \\
            \hline
        \end{tabular}
    \end{table}
    \newpage

    \item $((A \oplus B) \oplus B ) \equiv A$
    \begin{table}[h!]
        \centering
        \begin{tabular}{|c|c|c||c|}
            \hline
            \textbf{A} & \textbf{B} & \textbf{$((A \oplus B) \oplus B )$} & \textbf{$A$}\\
            \hline
            1 & 1 & 1 & 1 \\
            \hline
            1 & 0 & 1 & 1 \\
            \hline
            0 & 1 & 0 & 0 \\
            \hline
            0 & 0 & 0 & 0 \\
            \hline
        \end{tabular}
    \end{table}

    \item $((A \leftrightarrow B) \leftrightarrow B) \equiv A$
    \begin{table}[h!]
        \centering
        \begin{tabular}{|c|c|c||c|}
            \hline
            \textbf{A} & \textbf{B} & \textbf{$((A \leftrightarrow B) \leftrightarrow B)$} & \textbf{$A$}\\
            \hline
            1 & 1 & 1 & 1 \\
            \hline
            1 & 0 & 1 & 1 \\
            \hline
            0 & 1 & 0 & 0 \\
            \hline
            0 & 0 & 0 & 0 \\
            \hline
        \end{tabular}
    \end{table}

\end{enumerate}

\section*{2.2.2 Propositional Logic.}
Prove or disprove making use of truth tables:
\begin{enumerate}
    \item $\models (A \rightarrow B) \vee (B \rightarrow A)$
    \begin{table}[h!]
        \centering
        \begin{tabular}{|c|c|c|}
            \hline
            \textbf{A} & \textbf{B} & \textbf{$(A \rightarrow B) \vee (B \rightarrow A)$}\\
            \hline
            1 & 1 & 1 \\
            \hline
            1 & 0 & 1 \\
            \hline
            0 & 1 & 1 \\
            \hline
            0 & 0 & 1 \\
            \hline
        \end{tabular}
    \end{table}
    \\As we can see, this is a Tautology, so is proved

    \item $\models ((A \rightarrow B) \rightarrow B) \rightarrow B$
    \begin{table}[h!]
        \centering
        \begin{tabular}{|c|c|c|}
            \hline
            \textbf{A} & \textbf{B} & \textbf{$((A \rightarrow B) \rightarrow B) \rightarrow B$}\\
            \hline
            1 & 1 & 1 \\
            \hline
            1 & 0 & 0 \\
            \hline
            0 & 1 & 1 \\
            \hline
            0 & 0 & 1 \\
            \hline
        \end{tabular}
    \end{table}
    \\As we can see, there is a combination that it's not true, so this fails

    \item $\models (A \leftrightarrow B) \leftrightarrow (A \leftrightarrow (B \leftrightarrow A))$
    \begin{table}[h!]
        \centering
        \begin{tabular}{|c|c|c|}
            \hline
            \textbf{A} & \textbf{B} & \textbf{$ (A \leftrightarrow B) \leftrightarrow (A \leftrightarrow (B \leftrightarrow A))$}\\
            \hline
            1 & 1 & 1 \\
            \hline
            1 & 0 & 1 \\
            \hline
            0 & 1 & 0 \\
            \hline
            0 & 0 & 0 \\
            \hline
        \end{tabular}
    \end{table}
    \\As we can see, there is two combinations that are not true, so this fails
    \newpage

    \item $\models ((A \wedge B) \rightarrow C) \rightarrow ((A \rightarrow C) \vee (B \rightarrow C))$
    \begin{table}[h!]
        \centering
        \begin{tabular}{|c|c|c|c|}
            \hline
            \textbf{A} & \textbf{B} & \textbf{C}  & \textbf{$((A \wedge B) \rightarrow C) \rightarrow ((A \rightarrow C) \vee (B \rightarrow C))$}\\
            \hline
            1 & 1 & 1 & 1 \\
            \hline
            1 & 1 & 0 & 1 \\
            \hline
            1 & 0 & 1 & 1 \\
            \hline
            1 & 0 & 0 & 1 \\
            \hline
            0 & 1 & 1 & 1 \\
            \hline
            0 & 1 & 0 & 1 \\
            \hline
            0 & 0 & 1 & 1 \\
            \hline
            0 & 0 & 0 & 1 \\
            \hline
        \end{tabular}
    \end{table}
    \\As we can see, this is a Tautology, so is proved
\end{enumerate}
\end{document}


\section{Measurement Uncertainty Analysis}

\subsection{Devices Precision}
The precision of each devices are shown in Table~\ref{pres}.
\begin{table}
	\centering
	\begin{tabular}{|l|c|c|}
	\hline
	Devices & Precision & Unit 				\\ \hline
	Jolly balance & 0.01 & [cm] 			\\ \hline
	Ruler & 0.1 & [cm]						\\ \hline
	Timer for periods & 0.1 & [ms]			\\ \hline
	Timer for maximum speed & 0.01 & [ms]	\\ \hline
	Calliper & 0.02 & [mm]					\\ \hline
	Electronic scale & 0.01 & [g]			\\ \hline
	\end{tabular}
	\caption{Devices precision}
\label{pres}
\end{table}

\subsection{Uncertainty in Measurement for Spring Constant}
For measuring $L_i$, there is no type-A uncertainty.
Thus,
$$ u_{L_0} = 0.01 \quad [cm] $$
$$ u_{L_i} = 0.01 \quad [cm] $$
$$ u_{L_i,r} = \frac{0.01}{2.01} \cdot 100 \% = 0.49 \quad [cm] $$
For measuring $m_i$, there is no type-A uncertainty.
Thus, $$ u_m = 0.01 \quad [g] $$

$$ u_{\Delta L}=\sqrt{(\frac{\partial \Delta L}{\partial L_i})^2\cdot (u_{L_i})^2+(\frac{\partial \Delta L}{\partial L_0})^2\cdot (u_{L_0})^2}\approx1.4\times10^{-4} \quad m $$

The uncertainty of the gravity force measurement $u_{W}$ of $W=mg$ is
$$   \frac{\partial W}{\partial m} = g =9.794 \quad kg\cdot m/s^2        $$
$$   u_m = \Delta_{dev}=0.01 \quad g				                     $$
$$   u_{W} = \sqrt{(\frac{\partial W}{\partial m})^2 \cdot
(u_m)^2} = \sqrt{ {(9.794)^2\times (1\times10^{-5})^2}}
 \approx 1 \times10^{-4} \quad N										 $$

$$ k_1 = 2.3311 \pm 0.013  N/m , \quad u_{k_1,r} = 0.55 \% $$
$$ k_2 =  2.3206 \pm 0.0105  N/m , \quad u_{k_2,r} = 0.45 \% $$
$$ k_3 = 1.165 \pm 0.0380  N/m , \quad u_{k_3,r} = 3.26 \% $$

For $k_{3,theory}$  calculated from theory,
$$ k_{3,theory} = \frac{k_1 \cdot k_2 }{k_1 + k_2} =  1.1629 $$
$$ u_{k_{3,theory}}=\sqrt{
	 (\frac{\partial k_{3,theory} }{\partial k_1})^2 \cdot (u_{k_1})^2
	+(\frac{\partial k_{3,theory} }{\partial k_2})^2 \cdot (u_{k_2})^2 }
	= 0.0006 \quad N/m  $$
$$   u_{k_{3,theory},r} = \frac{0.0006 }{1.1629} \cdot 100 \% =0.05 \%  $$

\input{part/6mua1}


\chapter{Coordinate Transformations}
Let's consider our picture of spacetime as we understand in currently.
\begin{figure}[h]
    \centering
    \begin{tikzpicture}
        \node (origin) at (0,0) {}; % Origin node, not shown

        %% These are the four corners of the "square"
        \node (a) at (0,0) {};
        \node (b) at (1,-0.5) {};
        \node (c) at (5.5,1) {};
        \node (d) at (4.5,0.5) {};
        \node (e) at (5,3.5) {};
        \node (f) at (4,4) {};
        \node (g) at (1,3.5) {};
        \node (h) at (0,3) {};

        %% Curves
        \draw [name path=line-1] (a) to [bend left=10] (f);
        \draw [name path=line-2] (b) to [bend left=10] (e);
        \draw [name path=line-3] (g) to [bend left=10] (c);
        \draw [name path=line-4] (h) to [bend left=10] (d);

        %% Points
        \path [name intersections={of=line-1 and line-3,by=P}];
        \node [circle, fill=black,inner sep=1.5pt,label=90:$P$] at (P) {};

        \path [name intersections={of=line-2 and line-3,by=Q}];
        \node [circle, fill=black,inner sep=1.5pt,label=0:$Q$] at (Q) {};

        \path [name intersections={of=line-2 and line-4,by=R}];
        \node [circle, fill=black,inner sep=1.5pt,label=-90:$R$] at (R) {};

        \path [name intersections={of=line-1 and line-4,by=S}];
        \node [circle, fill=black,inner sep=1.5pt,label={[shift={(-0.35,-0.4)}]$S$}] at (S) {};

        %% Line labels
        \node [label={[shift={(0.55,-0.5)}]$x^1$}] at (a) {};
        \node [label={[shift={(0.6,0)}]$x^2$}] at (h) {};
    \end{tikzpicture}
\end{figure}
\noindent
Consider the point $Q$.
We can say that $Q$ has coordinates $(q^0, q^1, q^2, q^3) = (q^\mu)$.
Remember that, when dealing with coordinates, the superscript doesn't mean that this transforms like a contravariant vector --- it's just a (canonical) method of indexing the coordinates, and nothing more.
Right now, we are using the $x^\mu$ coordinate system, so each $q^\mu$ is measured with respect to the coordinate lines we've drawn here.
We will introduce a shorthand notation to refer to the coordinates of a point with respect to certain coordinates $x^\mu$:
\[ x^\mu(Q) = x(Q) = (q^0, q^1, q^2, q^3). \]
If it is understood what dimensions we need to represent the coordinates of a point, or we don't care about the distinction, we can simply shorten $x^\mu(Q)$ to $x(Q)$.

\subsection{The Tangent and Cotangent Spaces}
We begin with a really simple renaming; up until now, we've been creating our picture of spacetime and then assigning to each point $P$ a vector space $V_P$ a dual space $V^*_P$.
We defined the basis for $V_P$ to be the collection of differential operators $\{\bm{\partial}_\mu\}$, and chose a basis $\{\vec{d}x^\nu\}$ for $V^*_P$ such that $\langle \vec{d}x^\nu, \bm{\partial}_\mu \rangle = \delta^\nu_\mu$.
We're now going to make the small change of referring to the vector space as the \emph{tangent space} $T_P$, and the dual space as the \emph{cotangent space} $T^*_P$.
We do this because the coordinate basis $\{\bm{\partial}_\mu\},\{\vec{d}x^\nu\}$ is composed of differential operators, which are fundamentally related to the concept of tangency.
Imagine we have some function $\phi(x)$ on our space time and some operator $\mathcal{L} \in T_P$.
If a vector (our operator $\mathcal{L}$) acts on $\phi$ at a point $P$, then we get the directional derivative of $\phi$ at that point.
As a more concrete example, let's say that $\phi(x) = (x^0)^2 + \sin x^3$, and our vector field is $\bm{\partial}_0 + \bm{\partial}_3$. Then at a point $Q$, we would see a value
\[ [\bm{\partial}_0 + \bm{\partial}_3]\phi(x) = {2x^0 + \cos x^3\mid_Q} = 2q^0 + \cos q^3. \]
Whenever you see a tangent space, remember that it uses the coordinate basis.

It's really important to see that none of this makes any sense until we've established a coordinate system.
Because the coordinate basis gives us directional derivatives \emph{in the direction of the coordinate lines}, if we change our coordinate system our vectors change as well.

\subsection{Arbitrary Change of Bases}
Given a spacetime $\mathcal{S}$, there are an (uncountably) infinite many ways which we can define a coordinate system.
The entire purpose of general relativity is to show the equivalence of these systems, regardless of the basis chosen or the motion of an observer.
As it stands now, our spacetime has at every point a tangent space $T_P$ with basis $\{\bm{\partial}_\mu\}$, a cotangent space $T^*_P$ with basis $\{\vec{d}x^\nu\}$, and the tensor product spaces $\tps{T}^p_q$.
However, as long as we choose a set of linearly independent spanning differential operators from $T_P$, we can create our basis however we like.
Just as with the bases for our regular vector spaces, we can choose a new basis $\bm{\partial}_{\mu'}$ such that
\[ \bm{\partial}_{\mu'} = \tensor{\Lambda}{_{\mu'}^\mu}\bm{\partial}_\mu, \]
where $\tensor{\Lambda}{_{\mu'}^\mu}$ is of course the linear transformation matrix for these two bases.
Technically, since the tangent spaces are independent for each point, we no longer have a single transformation matrix, but rather a transformation which is itself a function on spacetime, so a more complete equation would read
\[ \bm{\partial}_{\mu'} = \tensor{\Lambda}{_{\mu'}^\mu} (x^\mu)\,\bm{\partial}_\mu. \]

\subsection{New Coordinate System}
These transformations deal with the case that we want to choose a new basis for our tangent spaces, but we can also consider the case that we change the whole coordinate system itself.
This can be thought of visually as drawing new lines on our spacetime diagram to represent our new coordinate system.
\begin{figure}[h]
    \centering
    \begin{tikzpicture}
        \node (origin) at (0,0) {}; % Origin node, not shown

        %% These are the four corners of the "square"
        \node (a) at (0,0) {};
        \node (b) at (1,-0.5) {};
        \node (c) at (5.5,1) {};
        \node (d) at (4.5,0.5) {};
        \node (e) at (5,3.5) {};
        \node (f) at (4,4) {};
        \node (g) at (1,3.5) {};
        \node (h) at (0,3) {};

        %% Curves
        \draw [name path=line-1] (a) to [bend left=10] (f);
        \draw [name path=line-2] (b) to [bend left=10] (e);
        \draw [name path=line-3] (g) to [bend left=10] (c);
        \draw [name path=line-4] (h) to [bend left=10] (d);

        %% Alt Curves
        \draw [name path=alt-1, red] (0,2.16) to [bend left=10] (5.5,3.16);
        \draw [name path=alt-2, red] (0,0.94) to [bend left=10] (5.5,1.94);
        \draw [name path=alt-3, red] (1.75,4)  to [bend left=10] (1.44,-0.3);
        \draw [name path=alt-3, red] (2.75,4)  to [bend left=10] (2.44,-0.3);

        %% Points
        \path [name intersections={of=line-1 and line-3,by=P}];
        \node [circle, fill=black,inner sep=1.5pt,label=90:$P$] at (P) {};

        \path [name intersections={of=line-2 and line-3,by=Q}];
        \node [circle, fill=black,inner sep=1.5pt,label=0:$Q$] at (Q) {};

        \path [name intersections={of=line-2 and line-4,by=R}];
        \node [circle, fill=black,inner sep=1.5pt,label=-90:$R$] at (R) {};

        \path [name intersections={of=line-1 and line-4,by=S}];
        \node [circle, fill=black,inner sep=1.5pt,label={[shift={(-0.35,-0.4)}]$S$}] at (S) {};

        %% Line labels
        \node [label={[shift={(0.55,-0.5)}]$x^1$}] at (a) {};
        \node [label={[shift={(0.6,0)}]$x^2$}] at (h) {};

        %% Alt-line Labels
        \node [label={[red]$x^{1'}$}] at (0,1.25) {};
        \node [label={[red]$x^{2'}$}] at (2.1,-0.3) {};
    \end{tikzpicture}
    \caption{Our spacetime $\mathcal{S}$ with coordinate systems $x^\mu$ and $x^{\mu'}$.}
\end{figure}
If we change the coordinates from $(x^\mu)$ to $(x^{\mu'})$, we will necessarily change the coordinate basis as well, since $\{\bm{\partial}_\mu\}$ is defined with respect to $(x^\mu)$.
Notice, however, that the points themselves don't change, although their coordinates in the respective systems will be different.
The points don't give a damn about which coordinate system is used.

When we talk about changing between coordinate systems, what we really mean are a pair of isomorphisms, $f$ and $f^{-1}$, which act such that
\begin{align*}
    f &: x^\mu \to x^{\mu'}, \\
    f^{-1} &: x^{\mu'} \to x^\mu.
\end{align*}
This means that if we have a point $Q = (q^\mu)$ in the $x^\mu$ system, then $Q$'s coordinates in the $x^{\mu'}$ system will be $f(q^\mu) = (q^{\mu'})$, and that $(q^\mu) = f^{-1} \circ f (q^\mu)$ for all points $Q \in \mathcal{S}$.
As we previously called $x^\mu (Q) = x(x)$ the coordinates in the $x^\mu$ system, we can say that $x^{\mu'}(Q) = x'(Q)$ are the coordinates in the $x^{\mu'}$ system.

Consider that if we have a function $\phi : x^\mu \to \mathbb{R}$ on our spacetime (perhaps representing the strength of an electric field at each point), then we will also need to be able to write some function $\phi' : x^{\mu'} \to \mathbb{R}$ which gives us the same values for the primed coordinates, so that $\phi(Q) = \phi'(Q)$ for all points.
If we want to write $\phi$ as a function of the primed coordinates, we can do so using the coordinate transformations we've just established, so
\[ \phi(x^\mu) = \phi(f^{-1}(x^{\mu'})) = \phi(x(x^{\mu'})). \]

Even though we've changed the coordinate system of our spacetime, and consequently the basis for our tangent spaces, the tangent spaces themselves really don't change in much the same way that the points in spacetime don't really change.
All we've done is to rename the points, but we haven't changed any of the physics associated with what goes on at those points.
What we have done is change the way that vectors at each point are \emph{written}.
Since $\{\bm{\partial}_\mu\} \not= \{\bm{\partial}_{\mu'}\}$, vectors in our tangent space will be written differently depending on which coordinate basis we choose.
We \emph{can}, however, write these new basis vectors as linear combinations of the old basis vectors, which is where the transformation matrix $\tensor{\Lambda}{_{\mu'}^{\mu}}(x)$ comes in.
The the previous section, we were free to choose $\Lambda(x)$ to be whatever we wanted, since we were just defining a new set of basis vectors while the underlying coordinate system remained the same.
Now, however, we've added a constraint.
We need to find the particular $\Lambda$ which is implied by the transformation $f$ between coordinate systems.
If we choose a particular coordinate transformation $f$, we are then \emph{forced} to use a particular basis transformation $\Lambda$ to find $\{\bm{\partial}_{\mu'}\}$.

\subsection{Finding $\Lambda$ from $f$}
Let's go back to our function $\phi(x(x^{\mu'}))$ on our spacetime.
Since we want the tangent spaces to remain the same under coordinate transformations, we know that we want
\[ \bm{\partial}_{\mu'} \phi = \bm{\partial}_\mu \phi \frac{\partial}{\partial{x^{\mu'}}}x(x^{\mu'}), \]
by a simple chain rule expansion.
Since $\phi$ is an arbitrary function, all we really care about is this inner differential, so
\[ \bm{\partial}_{\mu'} = \bm{\partial}_\mu \pdv{}{x^{\mu'}}x(x^{\mu'}). \]
This means that

\[ \Lambda = \pdv{}{x^{\mu'}} x\qty(x^\mu) = \pdv{x^\mu}{x^{\mu'}}, \]
we we simplify $x^\mu = x(x^{\mu'})$.
As a  $4\times 4$ matrix, we would write $\Lambda(x)$ as
\[ \Lambda =
    \begin{bmatrix}
        \pdv{x^0}{x^{0'}} & & \\
        & \ddots & \\
        & & \pdv{x^3}{x^{3'}}
    \end{bmatrix}.
\]
\subsection{Transforming the Cotangent Space}
Just as with our ordinary vector space and dual space, we transform the basis of the cotangent space using the inverse transformation as that of the tangent space, so $\vec{d}x^{\mu'} = \pdv{x^{\mu'}}{x^\mu} \vec{d}x^\mu$, and use the matrix $\Lambda^{-1}(x)$.

\subsection{Requisite Formalism}
When we discussed tensors and vector spaces and tensor product spaces, we did so with a very good degree of formalism.
The lessons started ``from the ground up,'' so to speak, and so they covered everything in depth.
By comparison, the latter parts of the lessons dealing with spacetime and vector fields and such have not really been covered to the same rigor.
Wrapped up in the notion of ``a spacetime $\mathcal{S}$ with a tangent space $T$, a cotangent space $T^*$, and the associated tensor product spaces $\tps{T}^p_q$ affixed to every point'' are the notions of a \emph{manifold}, a \emph{fiber bundle}, and a good deal of topology.
While understanding all of that isn't technically necessary to understanding the following sections, it does help give a good foundation for why all the hand-wavy arguments we've made so far are correct.
If you want to dive into a some (albeit distracting) mathematical formalism for these topics, now would be a good time to pause this lesson and switch to the ``What is a Manifold'' series, and then come back to complete sections 16--39.


\chapter{Preconditioning}
\label{chap:precond}

% Let us define the matrix of the linear system \eqref{eq:mhd_saddle} as $\mathcal{K}$.

The linear system \eqref{eq:mhd_saddle} is typically sparse and of large dimension, hence to efficiently solve for it we use a preconditioned iterative approach as proposed in \cite{li2010numerical}. We start by reviewing some preconditioning strategies for the incompressible Navier-Stokes and Maxwell subproblems in isolation. From these techniques we will then introduce and  numerically test  preconditioners for the full MHD system.

\section{Navier-Stokes equations}
\label{sec:NSprecond}

To start with, consider the steady state incompressible Navier-Stokes equations in isolation. Let
\begin{equation}
\label{eq:ns_coeff}
\mathcal{K}_{\rm NS}=
\begin{pmatrix}
F & B^T \\
B & 0
\end{pmatrix},
\end{equation}
be the discretised and linearised Navier-Stokes subproblem where $F~=~A~+~O$. Due to the convection term, $O$, this  system is non-symmetric and we will use GMRES to solve this subproblem \cite{saad1986gmres}. An excellent choice for a preconditioner for a saddle point system like this is to use a block diagonal or block triangular based preconditioner of the form
\begin{equation}
\label{eq:ns_pc_upper}
\mathcal{M}_{\rm NS} =
\begin{pmatrix}
F & B^T \\
0 & -S
\end{pmatrix},
\end{equation}
where the Schur complement $S$ is given by $S=B F^{-1} B^T$. It has been proved in \cite{murphy2000note} that for a suitable Krylov subspace method then the iterative scheme will converge in exactly $2$ iterations when using the block triangular preconditioner or $3$ iterations using a block diagonal where the $B^T$ is dropped from the $(1,2)$ block in $\mathcal{M}_{\rm NS}$.

In practice it is often too expensive to form and solve for the Schur complement, hence, a good approximation to it is needed. Two well known preconditioners for the incompressible Navier-Stokes equations are the Least Squares Commutator (LSC) and the Pressure Convection-Diffusion (PCD) preconditioners. Both can be found in \cite{elman2005finite} and we will just outline the procedure how these can be applied on the discrete level.

% Both methods (LSC and PCD)  start with the convection-diffusion operator associated with the velocity space $\uu{V}_h$ given by
% $$\mathcal{L} = -\nu \Delta +\uu{w} \cdot \nabla\, .$$
% As before $\uu{w}$ is the discrete velocity calculated at the previous non-linear iteration. Suppose that there is a corresponding operator defined in the pressure space
% $$\mathcal{L}_p = (-\nu \Delta +\uu{w} \cdot \nabla)_p\, .$$
% Consider the commutator of the convection-diffusion operator associated with the gradient operator
% \begin{equation} \label{eq:ContCommutator}
% \epsilon = (-\nu \Delta +\uu{w} \cdot \nabla)\nabla - \nabla (-\nu \Delta +\uu{w} \cdot \nabla)_p
% \end{equation}
% to be small. In fact, if $\uu{w}$ was constant then $\epsilon = 0$. We will be using \eqref{eq:ContCommutator} to derive both LSC and PCD.

\subsection{Pressure Convection-Diffusion (PCD)}
Before considering the PCD approach to approximate the Schur complement, we define the velocity mass matrix as $Q=(Q_{i,j})_{i,j=1}^{n_u} \in{\mathbb R}^{n_u \times n_u}$, where in terms of the basis $\{\uu{\psi_i}\}$
\begin{equation}
\label{eq:pressure_mass}
Q_{i,j}=
\int_\Omega\, \uu{\psi_j}\cdot \uu{\psi_i} \,d\uu{x}, \quad 1\leq i,j \leq n_u.
\end{equation}
In \cite[Chap. 8]{elman2005finite} the discrete commutator of the convection-diffusion operator associated with the gradient operation is introduced and given by
\begin{equation} \label{eq:DisCommutator}
    \epsilon_h = (Q^{-1}F)(Q^{-1}B^T)-(Q^{-1}B^T)(W^{-1}F_p)
\end{equation}
In this equation, $W=(W_{i,j})_{i,j=1}^{m_u} \in{\mathbb R}^{m_u \times m_u}$, $F_p=((F_{p})_{i,j})_{i,j=1}^{m_u} \in{\mathbb R}^{m_u \times m_u}$ and introduce $A_p=((A_{p})_{i,j})_{i,j=1}^{m_u} \in{\mathbb R}^{m_u \times m_u}$ (which will be used later) are mass matrix, convection diffusion operator and Laplacian matrix defined on the pressure space as:
\begin{equation}
\label{eq:PressureMass}
 \left. \begin{aligned}
W_{i,j}&= \int_\Omega\, \alpha_j \alpha_i \,dx, \ \ 1\leq i,j \leq m_u, \\
(F_{p})_{i,j}&= \nu \int_\Omega\, \grad \alpha_j \cdot \grad \alpha_i +(\uu{w} \cdot \grad \alpha_j)\alpha_i\,dx,\ \ 1\leq i,j \leq m_u, \\
(A_{p})_{i,j}&=  \int_\Omega\, \grad \alpha_j \cdot \grad \alpha_i \,dx, \ \ 1\leq i,j \leq m_u.
 \end{aligned}
 \right.
 \qquad \text{}
\end{equation}
These matricies are well-defined since our pressure spaces are continuous. Assuming that the commutator is small then pre and post multiplying \eqref{eq:DisCommutator} by $B F^{-1} Q$ and $F_p^{-1}W$, respectively, lets us separate the Schur complement to give
\begin{equation} \label{eq:SchurApprox}
    BF^{-1}B^T \approx B Q^{-1}B^T F_p^{-1} W.
\end{equation}

In general, $BF^{-1}B$ is both costly to form and usually dense, so it is impractical to use.  Our discretisation is inf-sup stable which means that there is spectral equivalency between $BQ^{-1}B^T$ and the pressure Laplacian, $A_p$, see \cite[Section 5.5.1]{elman2005finite}. Hence, the Schur complement can be approximated by:
$$S_{\rm PCD} =A_p F_p^{-1}W.$$
Applying the PCD preconditioner to the full Navier-Stokes system involves solving the system
\begin{equation} \nonumber
% \label{eq:matrix-system}
\left(
\begin{array}{cc}
F & B^T \\
0 & -A_p F_p^{-1}W
\end{array}
\right)
\,
\left(
\begin{array}{c}
x \\
y
\end{array}
\right) =
\left(
\begin{array}{c}a\\b
\end{array}
\right)
\end{equation}
at each Krylov iteration. This can be solved  efficiently by splitting it into the following two steps
\begin{itemize} \label{it:PCDsolve}
    \item[1.] Solve for $y$: $y = -W^{-1}F_p A_p^{-1}b$
    \item[2.] Solve for $x$: $x = F^{-1}(a-B^Ty).$
\end{itemize}
This means that we have one pressure Poisson solve ($A_p^{-1}$), one mass matrix solve ($W^{-1}$) and one convection-diffusion solve ($F^{-1}$) at each Krylov iteration. These solves will be done using direct solver unless specifically stated otherwise.

\subsection{Least Squares Commutator}

As for the derivation of the PCD preconditioner we start off with the discrete commutator of the convection-diffusion operator
\begin{equation} \nonumber
    \epsilon_h = (Q^{-1}F)(Q^{-1}B^T)-(Q^{-1}B^T)(W^{-1}F_p).
\end{equation}
Suppose that the $Q$-norm is defined by $\|v\|_{Q} = (Qv,v)^{\nicefrac{1}{2}}$. Then this time we minimise $\epsilon_h$ in the $Q$-norm to try to find an expression for $F_p$. The minimisation is given by
$$\min \|(Q^{-1}F)(Q^{-1}B^T)-(Q^{-1}B^T)(W^{-1}F_p) \|_Q.$$
Solving this optimisation problem, as shown in \cite{elman2005finite}, is equivalent to solving the following normal equations
$$W^{-1}BQ^{-1}B^TW^{-1}F_p = W^{-1}BQ^{-1} FQ^{-1}B^T.$$
This yields the following expression for $F_p$:
$$F_p = W(BQ^{-1}B^T)^{-1}(BQ^{-1} FQ^{-1}B^T).$$
By substitution this into expression \eqref{eq:SchurApprox} we obtain the LSC approximation to the Schur complement:
\begin{equation} \nonumber
    S = BF^{-1}B^T \approx S_{\rm LSC} = (B Q^{-1} B^T)(BQ^{-1}FQ^{-1}B^T)^{-1}(B Q^{-1} B^T).
\end{equation}
Therefore, applying the LSC preconditioner to the full Navier-Stokes system $\mathcal{K}_{\rm NS}$ in \eqref{eq:ns_coeff} involves solving for the matrix
\begin{equation} \nonumber
\left(
\begin{array}{cc}
F & B^T \\
0 & -S_{\rm LSC}
\end{array}
\right)
\,
\left(
\begin{array}{c}
x \\
y
\end{array}
\right) =
\left(
\begin{array}{c}a\\b
\end{array}
\right)
\end{equation}
at each Krylov iteration. Again, this can be split up into the following two steps:
\begin{itemize}
    \item[1.] Solve for $y$: $y = -(B Q^{-1} B^T)^{-1}(BQ^{-1}FQ^{-1}B^T)(B Q^{-1} B^T)^{-1}b$
    \item[2.] Solve for $x$: $x = F^{-1}(a-B^Ty).$
\end{itemize}
Hence, we have two pressure Poisson solves ($(B Q^{-1} B^T)^{-1}$) and one Convection-Diffusion solve ($F^{-1}$) at each Krylov iteration. In practice, we take the diagonal or lumped diagonal of $Q$ to form $B Q^{-1} B^T$. These solves, as in with the PCD preconditioner, will be done directly.

\section{Maxwell's equations}
\label{sec:MaxwellPrecond}

Next, consider the Maxwell subproblem
\begin{equation}
\label{eq:m_coeff}
\mathcal{K}_{\rm MX}=
\begin{pmatrix}
M & D^T \\
D & 0
\end{pmatrix}.
\end{equation}
As for the Navier-Stokes subproblem in Section \ref{sec:NSprecond}, we apply a block preconditioning strategy for $\mathcal{K}_{\rm MX}$ in  \eqref{eq:m_coeff}.

Recall that the $(1,1)$ block of $\mathcal{K}_{\rm MX}$ is the curl-curl operator, and hence the matrix $M$ is singular with nullity $m_b$ which corresponds to the discrete gradients. Therefore the usual Schur complement does not exist as it involves inverting $M$. To overcome this difficulty, we employ the approach in  \cite{golub2003solving,greif2006preconditioners} based on  augmentation. More precisely, we replace $M$ by $M+D^T\mathcal{W}^{-1}D$ where $\mathcal{W}\in {\mathbb R}^{m_b\times m_b}$ is a symmetric positive definite matrix, see \cite{golub2003solving,greif2006preconditioners} for more details. The addition of the matrix ($D^T\mathcal{W}^{-1}D$) removes the singularity of the $(1,1)$ block of $\mathcal{K}_{\rm MX}$ without changing the solution (since $Db = 0$). For the Maxwell subproblem the appropriate choice of $\mathcal{W}$ is the scalar Laplacian on $S_h$ defined as $L=(L_{i,j})_{i,j=1}^{m_b} \in{\mathbb R}^{m_b \times m_b}$ with
\begin{equation}
\label{eq:scalar_laplace}
L_{i,j}=\int_\Omega\,\nabla\beta_j\cdot\nabla\beta_i\,d\uu{x},
\end{equation}
see  \cite{greif2007preconditioners}. Therefore we will consider preconditioning the following augmented system:
\begin{equation}
\label{eq:AugmentMaxwell}
\bar{\mathcal{K}}_{\rm MX}=
\begin{pmatrix}
M + D^TL^{-1}D & D^T \\
D & 0
\end{pmatrix}.
\end{equation}

\subsection{An ideal preconditioner}

It has been shown in \cite{greif2007preconditioners} that an ideal preconditioner for $\bar{\mathcal{K}}_{\rm MX}$ in \eqref{eq:AugmentMaxwell} is the block diagonal matrix
\begin{equation}
\label{eq:maxwell_pc_ideal}
\mathcal{M}_{\rm iMX} =
\begin{pmatrix}
M+D^T L^{-1} D & 0 \\
0 & L
\end{pmatrix}.
\end{equation}
Applying \eqref{eq:maxwell_pc_ideal} as the preconditioner yields exactly two eigenvalues, $1$ and $-1$. Therefore using this matrix as a preconditioner means that MINRES will converge in two iterations  \cite{paige1975solution}. However, forming the matrix $M+D^T L^{-1} D$ is costly, hence, $\mathcal{M}_{\rm iMX}$  is  impractical  for large systems.

\subsection{A practical preconditioner}

A good approximation for $M+D^T L^{-1} D$ is required to make the ideal preconditioner, $\mathcal{M}_{\rm iMX}$, suitable in practise. It has been shown in \cite{greif2007preconditioners}  that $M+D^T L^{-1} D$ is spectrally equivalent to $M+X$  where $X=(X_{i,j})_{i,j=1}^{n_b}\in{\mathbb R}^{n_b \times n_b}$ is the mass matrix on the magnetic space and is defined as
\begin{equation}
\label{eq:magnetic_mass}
X_{i,j}=\int_\Omega\, \uu{\psi}_j\cdot\uu{\psi}_i\,d\uu{x}.
\end{equation}
Using this approximation leads to the practical preconditioner
\begin{equation}
\label{eq:maxwell_pc_X}
\mathcal{M}_{\rm MX} =
\begin{pmatrix}
N& 0 \\
0 & L
\end{pmatrix},
\end{equation}
where $N = M+X$.

\section{A preconditioner for the MHD problem}
\label{sec:MHDprecond}

Sections \ref{sec:NSprecond} and \ref{sec:MaxwellPrecond} looked briefly at the preconditioning strategies for the Navier-Stokes and Maxwell's equations. Using these techniques we will look at possible scalable preconditioners for the full MHD problem,
\begin{equation}
    {\mathcal K}_{\rm MH} = \left(
\begin{array}{cccc}
A+O & B^T & C^T & 0\\
B & 0 & 0 & 0\\
-C & 0 & M & D^T \\
0 & 0 & D & 0
\end{array}
\right).
\end{equation}
Using the Navier-Stokes and Maxwell subproblem preconditioners \eqref{eq:ns_pc_upper} and \eqref{eq:maxwell_pc_X} respectively, then we propose the following preconditioner for ${\mathcal K}_{\rm MH}$
\begin{equation}
\label{eq:mhd_pc_ls}
\mathcal{M}_{\rm MH} =
\left(
\begin{array}{cccc}
F & B^T & C^T & 0\\
0 & -S & 0 & 0 \\
-C & 0 & N & 0\\
0 & 0 & 0 & L
\end{array}
\right).
\end{equation}
Due to the coupling terms, $C$, the application of this precondioner is hard. To overcome this, we propose to invert  $\mathcal{M}_{\rm MH}$ by means of an inner preconditioner Krylov solver. The inner preconditioner is given by
\begin{equation}
\label{eq:mhd_pc_inner}
\mathcal{M}_{\rm innerMH} =
\left(
\begin{array}{cccc}
F & B^T & 0 & 0\\
0 & -{S} & 0 & 0 \\
0 & 0 & N & 0\\
0 & 0 & 0 & L
\end{array}
\right).
\end{equation}

\section{Preconditioners for MD and CD}

In Section \ref{sec:FEMdecouple} we introduced two decoupling schemes, namely Magnetic Decoupling (MD) and Complete Decoupling (CD). Using the results from sections \ref{sec:MaxwellPrecond} and \ref{sec:NSprecond} we will discuss the preconditioning approaches that we imply for these decoupling schemes.

\subsection{Magnetic decoupling}
\label{sec:MDprecond}

From section \ref{sec:FEMmd} the the matrix to be preconditioned is as follows:
\begin{equation}
   \mathcal{K}_{\rm MD} =
    \left(
    \begin{array}{cccc}
    F& B^T & 0 & 0\\
    B & 0 & 0 & 0 \\
    0 & 0 & M & D^T\\
    0 & 0 & D & 0
    \end{array}
    \right).
\end{equation}
Recall that removing the coupling terms completely decouples the system. This therefore enables us to use the optimal preconditioners for each of the subproblems separately and in parallel. Using the subproblem preconditioners \eqref{eq:maxwell_pc_X} and \eqref{eq:ns_pc_upper} then the optimal preconditioner for $\mathcal{K}_{\rm MD}$ is
\begin{equation}
\label{eq:mhd_pc_explicit}
\mathcal{M}_{\rm MD} =
\left(
\begin{array}{cccc}
F & B^T & 0 & 0\\
0 & -{S} & 0 & 0 \\
0 & 0 & N & 0\\
0 & 0 & 0 & L
\end{array}
\right).
\end{equation}

\subsection{Complete decoupling}
\label{sec:CDprecond}

To form an appropriate preconditioner for the CD iteration in \eqref{eq:matrix_CD} we first need to consider how to deal with the upper $(2,2)$ block matrix which corresponds to the discrete Stokes equations
\begin{equation}\nonumber
   \mathcal{K}_{\rm S} =
    \left(
    \begin{array}{cc}
    A& B^T \\
    B & 0
    \end{array}
    \right)
\end{equation}
As with the incompressible Navier-Stokes subproblem the idea for the Stokes preconditioner is again to approximate the Schur complement. The Schur complement associated with the Stokes system is
$$S_{\rm S} =  BA^{-1}B^T,$$
recall that the matrix $A$ is defined with the viscosity $\nu$ in section \ref{sec:variation}. It was shown in \cite{silvester1993fast,silvester1994fast} that the scaled pressure mass matrix, $\mbox{\small \(\frac{1}{\nu}\)} W$ defined in \eqref{eq:PressureMass}, is spectrally equivalent to the Schur complement (which is also a consequence of the inf-sup stability condition). Therefore the scalable Stokes preconditioner is
\begin{equation*}
\label{eq:mhd_pc_explicit2_1}
\begin{pmatrix}
A & 0 \\
0 & \mbox{\small \(\frac{1}{\nu}\)} W
\end{pmatrix}.
\end{equation*}
Using \eqref{eq:mhd_pc_explicit2} together with the Maxwell subproblem preconditioner  \eqref{eq:maxwell_pc_X} gives the preconditioner
\begin{equation}
\label{eq:mhd_pc_explicit2}
\mathcal{M}_{\rm CD} =
\left(
\begin{array}{cccc}
A & 0 & 0 & 0\\
0 & \mbox{\small \(\frac{1}{\nu}\)} W & 0 & 0 \\
0 & 0 & N & 0\\
0 & 0 & 0 & L
\end{array}
\right).
\end{equation}
The biggest advantage of this decoupling approach is that the matrix system is now symmetric. This means that the appropriate choice for the Krylov subspace method is MINRES for each subproblem.


\documentclass[a4paper,14pt,twoside]{book}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{soul}
\usepackage[colorlinks=true,linkcolor=red]{hyperref}
\usepackage{extsizes}
\usepackage{multicol}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{mathtools}
\begin{document}
\newcommand*{\REF}[1]{\hyperref[{#1}]{\autoref*{#1} \nameref*{#1}}}
\newcommand{\LIM}[2]{\lim_{#1 \to #2}}
\newcommand{\D}{\F{d}{dx}}
\newcommand{\DD}[2]{\F{d #1}{d #2}}
\newcommand{\B}[1]{\left(#1\right)}
\newcommand{\F}[2]{\frac{#1}{#2}}
\newcommand{\T}[1]{\textrm{#1}}
\newcommand{\N}[1]{{\fontfamily{serif}\fontsize{10}{1cm}\selectfont \rlap{#1}}}
\newcommand*{\QED}{\hfill\ensuremath{\blacksquare}}

\title{Maths}
\author{Patrolin}

{\fontsize{14.4}{1cm}\selectfont
\maketitle
\tableofcontents
\chapter{Derivatives}
The derivative is the rate of change of a function at a given point$:$ \\
\begin{align*}
	\T{When } \overbrace{\D f(x)}^{\N{the derivative of f(x)}} & > 0 \T{, } f(x) \T{ is increasing.} \\
	\T{When } \D f(x)                                          & < 0 \T{, } f(x) \T{ is decreasing.} \\
	\T{When } \D f(x)                                          & = 0 \T{, } f(x) \T{ is constant.}
\end{align*}
\pagebreak
\section{Notation}
If x is a variable, then $dx$ is a small change in $x$. \\
$dx$ is close to $0$, but not equal to $0$. $0$ is $\F{1}{\infty}$, and $\infty$ is evil! \\
\begin{align*}
	&dx \to 0 \\
\end{align*}
If y is a function of $x$, then $dy$ and $df(x)$ are the change caused by $dx$. \\
\begin{align*}
	    y &= f(x) \\
	   dy &= df(x) \\
	df(x) &= \underbrace{f(x) - f(x-dx)}_{\N{left subderivative}} = \underbrace{f(x+dx) - f(x)}_{\N{right subderivative}} \\
\end{align*}
If the function is discontinuous, then the derivative is undefined. \\
\begin{align*}
	\D f(x) &= \F{df(x)}{dx} \\
\end{align*}
Putting all of these ideas together gives us the equation for a derivative$:$ \\
$$\begin{rcases*}
	f(x)' = \D f(x) = \DD{f(x)}{x} \\
	df(x) = f(x+dx) - f(x) \\
	dx \to 0 \  (dx \ne 0) \\
\end{rcases*} \D f(x) = \LIM{h}{0} \F{f(x+h)-f(x)}{h}$$
\section{Elementary derivatives}
\subsection{$\D a = 0$}
\begin{align*}
	&a \in R \\
	f(x)    &= a                               \\
	\D f(x) &= \LIM{h}{0} \F{f(x+h) - f(x)}{h} \\
	\D a    &= \LIM{h}{0} \F{a-a}{h}           \\
	\D a    &= \LIM{h}{0} \F{0}{h}             \\
	\D a    &= 0 \  \because \  h \ne 0
\end{align*}
\subsection{$\D x^a = ax^{a-1}$}
\begin{align*}
	d(x^a)        &= (x+dx)^a - x^a \\
	d(x^a)        &= x^a
	+ \  \underbrace{\begin{matrix}
			+ (dx + x + x + x + \ldots) \\
			+ (x + dx + x + x + \ldots) \\
			+ (x + x + dx + x + \ldots) \\
			+ (x + x + x + dx + \ldots) \\
			\vdots
		\end{matrix}}_{x^{a-1}dx}
	\left. \phantom{\begin{matrix} \\ \\ \\ \\ \\ \end{matrix}} \right\}
	\T{a times}
	+ (\ldots)dx^2
	- x^a \\
	d(x^a)        &= ax^{a-1}dx + (\ldots)dx^2 \\
	\DD{(x^a)}{x} &= ax^{a-1} + (\ldots)dx \  \because \  dx \ne 0 \\
	\D x^a        &= ax^{a-1} \  \because \  dx \to 0 \\
	& \qquad \Downarrow \\
	& \D x = 1 \\
	& \D x^2 = 2x \\
	& \D x^3 = 3x^2 \\
	& \qquad \  \  \vdots \\
\end{align*}
\subsection{$\D e^x = e^x$}
This is how the value of $e$ is defined. \\
$e = 2.718\ldots$
\subsection{$\D \ln{x} = \F{1}{x}$}
If you have a function of one variable, then take the change in that
function with respect to that variable (implicit differentiation). \\
\begin{align*}
	y           &= \ln{x} \\
	e^y         &= x \\
	d(e^y)      &= d(x) \\
	e^y * dy    &= 1*dx \\
	\F{dy}{dx}  &= \F{1}{e^y} \\
	\F{d}{dx} y &= \F{1}{x} \\
	\D \ln{x}   &= \F{1}{x} \\
\end{align*}
If you have a function of many variables, apply \REF{sec:Rules} to
break it down into functions of one variable. \\
\pagebreak
\subsection{Trigonometric functions}
\N{see \url{https://lbry.tv/@3Blue1Brown:b/derivative-formulas-through-geometry}}
\begin{align*}
	&\D \sin{x} = \cos{x}  \\
	&\D \cos{x} = -\sin{x}
\end{align*}
Plus \href{https://www.priklady.eu/cs/matematika/derivace/derivace-funkce.alej}{others} which you probably don't need. \\
\section{Rules} \label{sec:Rules}
\subsection{The derivative is a linear function}
The derivative of a sum is the sum of derivatives. \\
\begin{align*}
	&\D (f(x) + g(x)) = \D f(x) \  + \  \D g(x) \\
\end{align*}
Constants can be multiplied outside. \\
\begin{align*}
	&a \in R \\
	&\D (a*x) = a * \D x \\
\end{align*}
Proof is left as an excercise to the reader. \\
\pagebreak
\subsection{Product rule}
\N{see \url{https://lbry.tv/@3Blue1Brown:b/visualizing-the-chain-rule-and-product}}
TODO(): put in a picture instead of a link
\begin{align*}
	d(f(x)*g(x))         &= df(x)*g(x) + f(x)*dg(x) + df(x)*dg(x) \\
	\F{d(f(x)*g(x))}{dx} &= \F{df(x)}{dx}*g(x) + f(x)*\F{dg(x)}{dx} + \F{df(x)}{dx}*dg(x) \\
	\D (f(x)*g(x))       &= \D f(x) * g(x) + f(x) * \D g(x) \  \because \  dg(x) \to 0 \\
\end{align*}
\begin{align*}
	&\D (x \ln x) = 1*\ln x + \F{x}{x} = \ln x + 1 \\
	&\D (\sin{x} * x^2) = \cos{x} * x^2 + \sin{x} * 2x \\
	&\D \F{\sin{x}}{x} = \D (\sin{x} * 1/x) = \F{\cos{x}}{x} - \F{\sin{x}}{x^2} \\
\end{align*}
\pagebreak
\subsection{$\DD{}{g(x)} f(g(x))$}
Derivative of $f(g(x))$ with respect to $g(x)$. \\
You simply treat $g(x)$ as if it was $x$. \\
\begin{align*}
	&\DD{}{(x^2)} (\sin{x^2}) = \DD{}{y} (\sin{y}) = \cos{y} = \cos{x^2} \\
	&\DD{}{(\sin{x})} (\sin{x})^3 = 3(\sin{x})^2 \\
	&\DD{}{(\ln{x})} (\ln{x})^{-1} = -1(\ln{x})^{-2} \\
\end{align*}
\subsection{Chain rule}
\begin{align*}
	\D f(g(x)) &= \F{df(g(x))}{dx} = \F{df(g(x))}{g(x)} \  * \  \F{dg(x)}{dx} \\
	\D f(g(x)) &= \DD{}{g(x)} f(g(x)) \  * \  \DD{}{x} g(x) \\
\end{align*}
\begin{align*}
	&\D (\sin{x^2}) = \cos{x^2} * 2x \\
	&\D \F{1}{\sin{x}} = \D (\sin x)^{-1} = -1*(\sin{x})^{-2} \  * \  \cos{x} = -\F{\cos{x}}{(\sin{x})^2} \\
	&\D \ln e^x = \F{1}{e^x} * e^x = 1
\end{align*}
\newpage
This also leads to a formula for division. \\
\begin{align*}
	\D \F{1}{g(x)}    &= -1*g(x)^{-2} * \D g(x) = -\F{\D g(x)}{g(x)^2} \\
	\D \F{f(x)}{g(x)} &= \F{\D f(x)}{g(x)} + f(x) * \D g(x) \\
	\D \F{f(x)}{g(x)} &= \F{\D f(x)}{g(x)} - f(x)*\F{\D g(x)}{g(x)^2} \\
	\D \F{f(x)}{g(x)} &= \F{\D f(x) * g(x) \  - \  f(x) * \D g(x)}{g(x)^2} \\
\end{align*}
\subsection{L'Hopital's rule}
Relies on geometric proof!
\begin{align*}
	&\LIM{x}{a} \F{g(x)}{h(x)} = \LIM{x}{a} \F{dg(x)}{dh(x)}
\end{align*}
\begin{align*}
	\LIM{x}{0} \F{\sin{x}}{x} &= \LIM{x}{0} \F{\cos{x * dx}}{1 * dx} \\
	\LIM{x}{0} \F{\sin{x}}{x} &= \LIM{x}{0} \F{\cos{x}}{1} \  \because \  dx \ne 0 \\
	\LIM{x}{0} \F{\sin{x}}{x} &= 1
\end{align*}
\subsection{Derivative of inverse function}
With $g(x)$ being the inverse of $f(x):$
\begin{align*}
	g(f(x))           &= x \\
	\D f(x) * \D g(x) &= 1 \\
	\D g(x)           &= \F{1}{\D f(x)} \\
\end{align*}
\section{Composite derivatives}
\subsection{$\D e^{-x} = -e^{-x}$}
\begin{align*}
	\D e^{-x} &= e^{-x} * (-1) \\
	\D e^{-x} &= -e^{-x} \\
\end{align*}
\subsection{$\D a^x = a^x \ln a$}
Note that $\ln a^x = x \ln a$.
\begin{align*}
	a^x    &= e^{\ln a^x} \\
	a^x    &= e^{x \ln a} \\
	\D a^x &= e^{x \ln a} * \ln a \\
	\D a^x &= a^x \ln a \\
\end{align*}
\subsection{$\D \log_a{x} = \F{1}{x \ln a}$}
\begin{align*}
	y              &= \log_a{x} \\
	a^y            &= x \\
	d(a^y)         &= d(x) \\
	a^y \ln a * dy &= 1*dx \\
	\DD{y}{x}      &= \F{1}{a^y \ln a} \\
	\D y           &= \F{1}{a^{\log_a{x}} \ln a} \\
	\D \log_a{x}   &= \F{1}{x \ln a} \\
\end{align*}
\subsection{$\D x^x = x^x * (\ln x + 1)$}
\begin{align*}
	f(x)     &= x^x \\
	\ln f(x) &= \ln (x^x) \\
	\ln f(x) &= x \ln x \\
	f(x)     &= e^{x \ln x} \\
	\D x^x   &= e^{x \ln x} * (\ln x + 1) \\
	\D x^x   &= x^x * (\ln x + 1) \\
\end{align*}
\end{document}


\subsubsection{Cone}
A cone is a transition state between one-sheet and two-sheet hyperboloids.
When the constant term in the hyperboloid's equation is 0, the top and bottom surfaces are only connected at a single point.

\begin{figure}[H]
	\centering
	\includegraphics[width=0.8\textwidth]{./Images/differentialMultivariableCalculus/cones.png}
	\caption{Cones}
\end{figure}