\documentclass[11pt]{article}
\usepackage{enumitem}
\usepackage{amssymb}
\usepackage{amsmath}

\begin{document}
\title{MATH1830 --- Assignment 5}
\author{Dylan Pinn --- 24160547}
\maketitle

Let $A = \mathcal{P}(\{1,2,3,4\})$. Let $f$, $g$ and $h$ be the following functions.

$ f: A \to A$ defined by $(X) = X \cap \{1,4\}$
\begin{equation*}
  g: A \to \mathbb{Z} \text { defined by } g(X) =
  \begin{cases}
      -1 & \text{if } X = \emptyset \\
      \text{ the smallest element of X} & if X \not = \emptyset
   \end{cases}
\end{equation*}

$h: \{1,2,3,4\} \to A$ defined by $h(x)=\{1,2,3,4\} - \{x\}$

\section*{Question 1}

\begin{enumerate}[label=(\roman*)]
  \item Write down $f(\{1,2\})$
  $$= \{1,2\} \cap \{1,4\} = \{1\}$$

  \item Write down $g(\{2,4\})$
  $$= \{2\}$$

  \item Write down $h(4)$
  $$= \{1,2,3\}$$

  \item Write down $f(h(1))$
  $$h(1) = \{1\}$$
  $$f(\{1\}) = \{1\}$$
\end{enumerate}

\break
\section*{Question 2}

\begin{enumerate}[label=(\roman*)]
  \item Is $f$ one-to-one?

  To show that it is not one-to-one we must show that $f(x_1) = f(x_2)$ and $x_1 \not = x_2$

  By using the values of $x_1 = \{1,2\}$ and $x_2 = \{1,3\}$ we can show that the functions of both of these do not match.

  \begin{equation*}
    f(x_1) = \{1,2\} \cap \{1,4\} = \{1\} \\
    f(x_2) = \{1,3\} \cap \{1,4\} = \{1\}
  \end{equation*}

  \item Is $g$ one-to-one?
  \item Is $h$ one-to-one?
\end{enumerate}

\section*{Question 3}

\begin{enumerate}[label=(\roman*)]
  \item Write down the image of $f$.
  $$= \mathcal{P}(\{1,4\})$$

  \item Write down the image of $g$.
  $$= \{-1, 1, 2, 3, 4\}$$

  \item Write down the image of $h$.
  $$= \mathcal{P}(1,2,3,4) -  \{\}$$
\end{enumerate}

\section*{Question 4}

\begin{enumerate}[label=(\roman*)]
  \item How many functions are there with domain $A$ and codomain $\{0,1\}$?

  The domain has 16 elements $(2^4)$.

  For each input, we can decide if it's mapped to a 0 or 1.

  We can do this $2^{16} = 65536$ ways.

  \item How many one-to-one functions are there wth domain $A$ and codomain $\{0,1\}$?

  Each element in A is mapped to $\{0,1\}$. To find out the number of permutations of this:
  $$= \frac{n!}{(n-k)!}$$

  We use number of elements of $A$ as $n$ and the number of elements in the codomain as $k$. This gives:
  $$\frac{16!}{(16-2)!} = 240$$

  \item How many onto functions are there with domain $A$ and codomain $\{0,1\}$?
\end{enumerate}
\end{document}


\section{Boolean algebra}
\label{sec:boole}
\index{Boolean algebra}
%
Boolean algebra has a long history. George Boole (\lifetime{1815}{1864}), John Venn (\lifetime{1834}{1923}) and William Stanley Jevons (\lifetime{1835}{1882}) pioneered an algebraic structure $\langle B, \lor, \land, \neg, 0, 1\rangle$ with the following properties ($x$ and $y$ are boolean expressions and therefore in $B$)~\cite[10]{Sat20}:
%
\begin{itemize}
  \item $\land$ and $\lor$ are binary operators. $\neg$ is an unary operator.
  \item $0, 1 \in B$
  \item $x \land y = y \land x; x \lor y = y \lor x$
  \item $x \lor (y \land z) = (x \lor y) \land (x \lor z); x \land (y \lor z) = (x \land y) \lor (x \land z)$
  \item $x \lor \neg x = 1; x \land \neg x = 0$
  \item $1 \land x = x; 0 \lor x = x$
\end{itemize}

In the following sections boolean algebra will be used to derive clauses for the \gls{sat} solver. De Morgan's laws are a set of transformation rules in boolean algebra of equivalent statements. The following one will be used in the document:

\[
  \neg (x \land y) \qquad\Leftrightarrow\qquad (\neg x) \land (\neg y)
\]

\section{Satisfiability}
\label{sec:sat}
\index{Satisfiability}
%
The satisfiability problem states the following question:
\begin{quote}
  ``Is a given boolean system in conjunctive normal form \emph{satisfiable}?''
\end{quote}
%
Satisfiability or consistency in logic refers to a property of a boolean expression. A boolean equation is satisfiable if and only if there exists some truth assignment for the given expression which evaluates to true.

\index{Cook-Levin theorem}
The Cook-Levin theorem states that the \gls{sat} problem is NP-complete. This was proven in 1971 by Stephen Cook~\cite{Sat01} and Leonid Levin~\cite{Sat02} independently. As such \gls{sat} problems seem to be computationally infeasible for larger problem sizes and \gls{sat} solvers are tools to solve those NP-complete problems in the best possible way.

\index{Conjunctive normal form}
\index{Disjunctive normal form}
\index{Clauses}
A $k$-SAT problem (with $k \in \mathbb{N}$) is a \gls{sat} problem in \gls{cnf} with at maximum $k$ literals per clause. A \gls{cnf} is the conjunction of disjunctions (so-called \emph{clauses}). A \gls{dnf} is the disjunction of conjunctions.

\section{SAT solving techniques}
\label{sec:satsolvers}
\index{SAT solvers}
%
\index{DIMACS format}
In 1958 Martin Davis and Hilary Putnam proposed the CNF as input for satisfiability problems in an unpublished manuscript for the NSA~\cite{Sat20}. The DIMACS format has been developed as universal input format for SAT solvers~\cite{Sat09}.

\gls{sat} solvers today are variants of the DPLL algorithm. In the original design, four techniques are discussed:
\begin{description}
  \item[Unit clause.] Clauses with one literal are immediately processed and taken as assignment. A literal is a boolean variable or its negation.
  \item[Pure literal rule.] If all occurences of a variable happen with the same polarity, all those clauses can be discarded if the variable gets assigned its polarity.
  \item[Elimination of atomic formulas.] Formulas which are atomic for the given equation system get eliminated.
  \item[Splitting rule.] Even a single variable might split the whole search space and shall be used as an advantage for speedup.
\end{description}
%
The first two techniques are explicitly part of the DPLL algorithm. The often cited paper for the DPLL algorithm is Davis' ``A Computing Procedure for Quantification Theory''~\cite{Sat05} and a discussion of the history is provided in ``Early History and Perspectives of Automated Deduction''~\cite{Sat06}. A discussion of possible approaches to this problem is given by Jun Gu, Paul W. Purdom, John Franco and Benjamin Wah~\cite{Sat08}.

Further efforts were especially put into efficient representation of the search space with techniques like early pruning, replacement of a tree-like search space with a DAG-like search space and variable choice heuristics~\cite[24]{Sat20}.

Two further rules are considered:
\begin{description}
  \item[Shortest clause rule.]
    Prefer the assignment of a variable from an existing clause containing the fewest unset literals.
  \item[Majority rule.]
    Prefer the assignment of a variable with the maximum difference between the number of its positive and negative literals.
\end{description}

\subsection{Assumptions}
\label{sec:satsolvers-assumptions}
\index{Assumptions (SAT solvers)}
%
The interface of a \gls{sat} solver typically consists of a function to add clauses and a solve function. As such most of the current \gls{sat} solvers work incrementally; they allow to add clauses to the \gls{sat} solver and to repeatedly invoke the solve function.

Assumptions are a separate concept which allows the user to specify hints. An assumption is one assignment of a variable that will be lost after one SAT solver evaluation. This way the user has a certain level of control which variables are evaluated.

Assumptions can be simply integrated to the \gls{cnf} as unit clauses if their value shall be assigned persistently.
% TODO: better research. Where are assumptions studied?

\subsection{Runtime analysis}
\label{sec:satsolvers-runtime}
%
Satisfiability of a CNF formula~$\phi$ with $n$ boolean variables can be decided in time $\mathcal{O}(2^n \abs{\phi})$ by enumerating all assignments of the variables. Also the number of literals $l$ and number of clauses $m$ have to be considered.

In 2002 researchers found some deterministic algorithm~\cite{Sat07} using local search to solve $k$-SAT instances with the best runtime to this day: $(2 - 2/(k+1))^n$. However the general \gls{sat} problem is not limited to a number of literals per clause.

Because the desired runtime is not always achieved, focus is put on the encoding and transformation of SAT instances. Grigorii Samuilovich Tseitin got famous for his research in transformations and encoding like the Tseitin encoding. In a recent paper~\cite{Sat22} Peter Stuckey points out that there are no original SAT problems and we should focus on representing problems in the way they originally appear. SAT research is closely related to the field of \gls{csp}, which also considers other encodings.

In terms of performance the following properties of a \gls{cnf} can be used as measurement~\cite{Sat20}:
\begin{description}
  \item[Encoding size.]
    is defined by the number of clauses, literals or variables.
    We always add clauses to SAT solvers making the boolean system larger. But symmetry-breaking clauses and blocked clauses can actually improve evaluation speed.
  \item[Consistency properties.]
    This includes arc consistency and forward checking.
  \item[Solution density.]
    The number of solutions divided by $2^n$ ($n$ as the number of variables). The higher the solution density, the faster a satisfying solution can be found.
\end{description}

\section{Obtain CNF and DNF from truth table}
\label{sec:cnf-dnf}
%
\index{Truth table}
Truth tables have 2 dimensions and list all possible boolean variable configurations and their outcome for a given function. Ludwig Wittgenstein established binary truth tables in his philosophical book ``Tractatus Logico-Phulosophicus''.

Having a boolean function we can always determine an equivalent \gls{cnf} or \gls{dnf}.

\begin{description}
  \item[Disjunctive normal form.]
    The disjunctive normal form can be retrieved by extracting all configurations resulting in value true. Each configuration represents a conjunction of literals. Literals are generated by taking the variable corresponding to the truth value\footnote{Value true for a variable $v$ yields the literal $v$. Value false yields the literal $\neg v$.}. The DNF is the disjunction of the configurations.
  \item[Conjunctive normal form.]
    The conjunctive normal form can be retrieved by extracting all false configurations. Each configuration represents a disjunction of literals and literals are created with opposite polarity\footnote{Value true for a variable $v$ yields the literal $\neg v$. Value false yields the literal $v$.}. The CNF is the conjunction of the configurations.
\end{description}

It is important to point out that building the truth table takes $\mathcal{O}(2^n)$ for $n$ variables if constant runtime is assumed for the evaluation of the boolean function. This leads to a problem in our implementation. In general we don't know the functions to be used in advance, but require the equivalent \gls{cnf} for the \gls{sat} solver. In our implementation we generate the truth table for every function to be used to retrieve all outcomes.


\section{Examples}
\label{sec:examples}

We now see three applicative examples of the Marciani Normal Form and Marciani's
Rule.
Let us first consider a very simple application.

\begin{example}
	Let us consider the context-free grammar $G$ with axiom $S$ and
	the following productions

	\begin{flalign*}
		S&\rightarrow abcS|Sdef|ghi|\varepsilon
	\end{flalign*}

	The grammar is in MNF, thus we know it generates a context-free language.
	The language generated by $G$ is denoted by the regular expression

	\begin{equation*}
		(abc)^{*}(ghi+\varepsilon)(def)^{*}
	\end{equation*}
\end{example}

Let us now consider a slightly more complex application.

\begin{example}
	Let us consider the context-free grammar $G$ with axiom $S$ and
	the following productions

	\begin{flalign*}
		S&\rightarrow aAS|SBdef|CD|\varepsilon \\
		A&\rightarrow uA|Av|m \\
		B&\rightarrow xB|By|n \\
		C&\rightarrow gC|Ch|i \\
		D&\rightarrow pD|Dq|r
	\end{flalign*}

	The grammar is in MNF, thus we know it generates a context-free language.
	The language generated by $G$ is denoted by the regular expression

	\begin{equation*}
		(au^{*}mv^{*})^{*}(g^{*}ih^{*}p^{*}rq^{*}+\varepsilon)(x^{*}ny^{*}def)^{*}
	\end{equation*}
\end{example}

We now consider an application on a grammar in the notable Chomsky Normal Form
(CNF) \cite{chomsky1959certain}.

\begin{example}
	Let us consider the context-free grammar $G$ with axiom $S$ and the following
	productions

	\begin{flalign*}
		S&\rightarrow AS|SB|CD|z|\varepsilon \\
		A&\rightarrow UA|AU|m \\
		B&\rightarrow XB|BX|n \\
		C&\rightarrow UC|CU|i \\
		D&\rightarrow XD|DX|r \\
		U&\rightarrow u \\
		X&\rightarrow x
	\end{flalign*}

	The grammar is in MNF, thus we know it will generate a context-free language.
	The language generated by $G$ is denoted by the regular expression

	\begin{equation*}
		(u^{*}mu^{*})^{*}(u^{*}iu^{*}x^{*}rx^{*}+z+\varepsilon)(x^{*}nx^{*})^{*}
	\end{equation*}
\end{example}


\chapter{}

\rmk{1} As a reminder, for a canonical exponential family
\[
f(\mathbf{x} \mid \eta)=h(\mathbf{x}) \exp \{\langle\eta, T(\mathbf{x})\rangle-A(\eta)\}, \quad \eta \in \operatorname{int}(\mathcal{E}) \neq \emptyset
\]
it is true that
\[
\frac{\partial^{k}}{\partial \eta^{k}} \int f(\mathbf{x} \mid \eta) G(d \mathbf{x})=\int \frac{\partial^{k}}{\partial \eta^{k}} f(\mathbf{x} \mid \eta) G(d \mathbf{x}), \quad k \in \mathbb{N}
\]
where \(\frac{\partial^{k}}{\partial \eta^{k}}\) represents the vector derivative with respect to \(\eta\).

\rmk{2} As another reminder, the application of the theorem on asymptotic efficiency essentially boils down to verifying the conditions
\begin{enumerate}[(a)]
    \item \(\int f\left(x_{1} \mid \theta\right) G\left(d x_{1}\right)\) can be differentiated twice under the integral sign;
    \item the third derivative of \(\log f\left(x_{1} \mid \theta\right)\) is uniformly bounded by an integrable random variable (i.e., \(M\left(X_{1}\right)\) such that \(\left.\mathbb{E}_{\theta}\left|M\left(X_{1}\right)\right|<\infty\right)\).
\end{enumerate}
In all problems where \(\theta\) appears, it denotes the parameter or vector of parameters, accordingly.

\begin{ex}
    Let \(\left\{X_{n}\right\}_{n \in \mathbb{N}} \stackrel{\text { i.i.d. }}{\sim} \mathcal{N}(\theta, 1), \theta \in \mathbb{R}\). Recall that the Hodges estimator is defined by
\[
\delta(\mathbf{X})=\left\{\begin{array}{cl}
\bar{X}, & \text { if }|\bar{X}| \geq n^{-1 / 4} \\
a \bar{X}, & \text { if }|\bar{X}|<n^{-1 / 4}
\end{array}\right.
\]
where \(0<a<1\). For \(g(\theta)=\theta\), prove that
\[
\sqrt{n}(\delta(\mathbf{X})-g(\theta)) \stackrel{d}{\rightarrow} \mathcal{N}(0, v(\theta)), \quad n \rightarrow \infty
\]
where
\[
v(\theta)=\left\{\begin{array}{cc}
1, & \text { if } \theta \neq 0 \\
a^{2}, & \text { if } \theta=0
\end{array}\right.
\]
(suggestion: for the case \(\theta \neq 0\), break up
\[
\sqrt{n}(\delta(\mathbf{X})-\theta)=\sqrt{n}(\bar{X}-\theta) 1_{\left\{|\bar{X}| \geq n^{-1 / 4}\right\}}+a \sqrt{n}(\bar{X}-\theta) 1_{\left\{|\bar{X}|<n^{-1 / 4}\right\}}+(a-1) \theta \sqrt{n} 1_{\left\{|\bar{X}|<n^{-1 / 4}\right\}} .
\]
Now show that \(\mathbb{P}_{\theta}\left(|\bar{X}|<n^{-1 / 4}\right) \rightarrow 0\) as \(\left.n \rightarrow \infty\right)\).
\end{ex}

\begin{solution}
    For the case $\theta=0$, $P(|\bar{X}|\geqslant n^{-1/4})\to 0$,
    \begin{align*}
        \sqrt{n}(\delta(\mathbf{X})-\theta)&=\sqrt{n}(\bar{X}-\theta) 1_{\left\{|\bar{X}| \geq n^{-1 / 4}\right\}}+\sqrt{n}(a\bar{X}-\theta) 1_{\{|\bar{X}|<n^{-1/4}\}}\\
        &=a\sqrt{n}\bar{X}.
    \end{align*}
    $Var(a\sqrt{n}\bar{X})=a^2. $

    \noindent For the case $\theta\neq 0$,
    \[
        \begin{aligned}
            P(|\bar{X}|<n^{-1/4})&=P(\sqrt{n}|\bar{X}-\theta+\theta|<n^{1/4})=P(|Z+\sqrt{n}\theta|<n^{1/4})\\
            &=\Phi(n^{1/4}-\sqrt{n}\theta)-\Phi(-n^{1/4}-\sqrt{n}\theta)\to 0.
        \end{aligned}
    \]
    So, $\sqrt{n}(\delta(X)-\theta)\to \sqrt{n}(\bar{X}-\theta)\to \mathcal{N}(0,1)$.
\end{solution}

\begin{ex}
    \label{ex:7.2}
    Determine whether or not the location families based on the following densities have unique roots.
    \begin{enumerate}[(a)]
        \item \label{ex:7.2.a} \(f(x)=\frac{1}{\sqrt{2 \pi}} \exp \left\{-\frac{1}{2} x^{2}\right\}, x \in \mathbb{R}\);
        \item \(f(x)=\frac{e^{-x}}{\left(1+e^{-x}\right)^{2}}, x \in \mathbb{R}\).
    \end{enumerate}
\end{ex}

\begin{solution}
    \begin{enumerate}[(a)]
        \item \[
            f(\mathbf{x}, \theta)=(2\pi)^{-n/2} \exp\left(-\frac{1}{2}\sum_{i=1}^n(x_i-\theta)^2\right)
        \]
        \[
            l(\theta)=-\frac{n}{2}\log 2\pi-\frac{1}{2}\left(\sum_{i=1}^n(x_i-\theta)^2\right).
        \]
        \[
            \frac{\pder l(\theta)}{\pder \theta}=\sum_{i=1}^nx_i-n\theta=0\Rightarrow \theta=\sum x_i/n.
        \]
        So, it has the unique root.
        \item \[
            f(\mathbf{x}, \theta)=\exp\left(-\sum_{i=1}^n x_i-n\theta\right)\prod_{i=1}^n(1+e^{-x_i-\theta})^{-2}.
        \]
        \[
            l(\theta)=-\sum_{i=1}^n x_i-n\theta-2\sum_{i=1}^n\log(1+e^{-x_i-\theta}).
        \]
        \[
            \frac{\pder l(\theta)}{\pder \theta}=-n+2\sum_{i=1}^n\frac{e^{-x_i-\theta}}{1+e^{-x_i-\theta}}
        \]
        This log likelihood function is monotone decreasing, and $l(\theta)\to n$, when $\theta\to-\infty$; $l(\theta)\to -n$, when $\theta\to\infty$. So, it must have a unique root.
    \end{enumerate}
\end{solution}

\begin{ex}
    Consider a sample \(X_{1}, \cdots, X_{n}\) from a Poisson distribution conditioned to be positive, i.e.,
    \[
        \mathbb{P}\left(X_{1}=x\right)=\frac{\theta^{x} e^{-\theta}}{x !\left(1-e^{-\theta}\right)} . \quad x \in \mathbb{N} .
    \]
    Show that the likelihood equation has a unique root for all values of \(x\).
\end{ex}

\begin{solution}
    \[
        f(X)=\frac{\theta^{\sum x_i} e^{-n\theta}}{\prod x_i! (1-e^{-\theta})^n}.
    \]
    \[
        l(\theta)=\sum x_i \log \theta-n\theta-\sum_{i=1}^n\log x_i!-n\log (1-e^{-\theta}).
    \]
    \[
        \frac{\partial}{\partial\theta}l(\theta)=\frac{\sum x_i}{\theta}-\frac{n}{1-e^{-\theta}}=0.
    \]
    \[
        \frac{\theta}{1-e^{-\theta}}=\bar{X}.
    \]
    The range of left side is $(1, \infty)$ and the left side is monotone increasing. So, unless $\bar{X}=1$, $\theta$ has a unique root.
\end{solution}

\begin{ex}
    The so-called digamma function \(\Gamma^{\prime}(\alpha) / \Gamma(\alpha), \alpha>0\), is an increasing function of \(\alpha\). Use this fact to prove that, for a sample \(X_{1}, \cdots, X_{n} \stackrel{\text { i.i.d. }}{\sim} \Gamma(\alpha, 1)\), the likelihood equation has a unique root. Can we arrive at the same conclusion by using a general result for canonical exponential families?
\end{ex}

\begin{solution}
    Let $\psi(\alpha)$ be digamma function.
    \[
        f(X)=\frac{(\prod x_i)^{\alpha-1}e^{-\sum x_i}}{n\Gamma(\alpha)}.
    \]
    \[
        l(\theta)=(\alpha-1)\sum_{i=1}^n \log x_i-n\log (\Gamma(\alpha))-\sum_{i=1}^n x_i.
    \]
    \[
        \frac{\partial}{\partial\theta}l(\theta)=\sum_{i=1}^n\log x_i-n\psi(\alpha)=0.
    \]
    \[
        \psi(\alpha)=\frac{\sum_{i=1}^n \log x_i}{n}>0.
    \]
    And because $\log (\alpha)-1/(2\alpha)>\psi(\alpha)>\log (\alpha)-1/\alpha$, we can find a $\alpha_0$, which satisfies the above equation.

    \noindent For canonical exponential families, $l'(\eta)/l(\eta)=\sum T(x_i)-nA'(\eta)$. Then, because $A(\eta)$ is convex, $A'(\eta)$ is increasing. And $E(T(X))=A'(\eta)$, we can also find a unique $\eta$ which satisfies $A'(\eta)=\sum T(x_i)/n$.
\end{solution}

\begin{ex}
    Let \(\left\{Y_{n}\right\}_{n \in \mathbb{N}}\) be a random sequence defined on a probability space \((\Omega, \mathcal{F}, \mathbb{P})\). This sequence is said to be bounded in probability (or tight) if
    \[
        \forall \varepsilon>0, \exists m(\varepsilon)>0 \text { such that } \mathbb{P}\left(\left|Y_{n}\right|>m(\varepsilon)\right)<\varepsilon, \quad n \in \mathbb{N} .
    \]
    Notation: \(Y_{n}=O_{\mathbb{P}}(1)\).
    \begin{enumerate}[(a)]
        \item Let \(\left\{M\left(X_{n}\right)\right\}_{n \in \mathbb{N}}\) be an i.i.d. sequence, \(\mathbb{E}\left|M\left(X_{1}\right)\right|<\infty\). Prove that
        \[
        Y_{n}:=\frac{1}{n} \sum_{i=1}^{n} M\left(X_{i}\right)
        \]
        is bounded in probability.
        \item Let \(\left\{Y_{n}\right\}_{n \in \mathbb{N}}\) and \(\left\{Z_{n}\right\}_{n \in \mathbb{N}}\) be random sequences such that \(Y_{n}=O_{\mathbb{P}}(1)\) and \(Z_{n}=o_{\mathbb{P}}(1)\) (i.e., \(\left\{Z_{n}\right\}_{n \in \mathbb{N}}\) converges to zero in probability). Prove that \(Y_{n} Z_{n}=o_{\mathbb{P}}(1)\).
    \end{enumerate}
\end{ex}

\begin{solution}
    \begin{enumerate}[(a)]
        \item Because $Y_n\sim \mathcal{N}(\mu, \sigma^2)$. $\forall\ \varepsilon$, we can find a $A$ that satisfies:
        \[
            \begin{aligned}
                P(|Y_n|>A)&=P(Y_n>A)+P(Y_n<-A)\\
                &=P\left(\frac{A-\mu}{\sigma}<Z_n\right)+P\left(Z_n<\frac{-A-\mu}{\sigma}\right)\\
                &=1-\Phi\left(\frac{A-\mu}{\sigma}\right)+\Phi\left(\frac{-A-\mu}{\sigma}\right)<\varepsilon.
            \end{aligned}
        \]
        So, $Y_n$ is bounded in probability.
        \item $\forall\ \varepsilon>0$, let $M$ satisfies $P(|Y_n|>M)<\varepsilon$,
        \begin{align*}
            P(|Y_nZ_n|>\varepsilon)&=P(|Y_nZ_n|>\varepsilon, |Y_n|>M)+P(|Y_nZ_n|>\varepsilon, |Y_n|<M)\\
            &\leqslant \varepsilon +P(|Z_n|>\varepsilon/M)\\
            &\leqslant \varepsilon+\frac{\varepsilon}{M}=\varepsilon'.
        \end{align*}
        $\forall\ \varepsilon>0$, $\exists\ m(\varepsilon)=M\varepsilon/(M+1)$, such that
        \[
            P(|Y_nZ_n|>m(\varepsilon))<\varepsilon.
        \]
    \end{enumerate}
\end{solution}

\begin{ex}
    (this problem revisits the key steps of the proof of asymptotic efficiency of a consistent sequence of roots)

    For some \(\theta, \theta_{0} \in \Theta=(\underline{\theta}, \bar{\theta})\) (without loss of generality, \(\left.\theta>\theta_{0}\right)\), if the likelihood function is smooth enough (more specifically, three times differentiable in \(\theta\) over \(\Theta\) ), then we can use the Taylor expansion (with Lagrange residual)
    \begin{equation}
        \label{eq:7.6}
        \ell^{\prime}(\hat{\theta}_n)=\ell^{\prime}\left(\theta_{0}\right)+\left(\widehat{\theta}_{n}-\theta_{0}\right) \ell^{\prime \prime}\left(\theta_{0}\right)+\frac{1}{2}\left(\widehat{\theta}_{n}-\theta_{0}\right)^{2} \ell^{\prime \prime \prime}\left(\theta^{*}\right)
    \end{equation}
    where \(\theta^{*} \in\left(\theta_{0}, \theta\right)\) and the derivatives are all with respect to \(\theta\).
    \begin{enumerate}[(a)]
        \item If \(\theta\) is a root of the likelihood equation, conclude that
        \[
            \sqrt{n}\left(\theta-\theta_{0}\right)=\frac{(1 / \sqrt{n}) \ell^{\prime}(\theta_0)}{-(1 / n) \ell^{\prime \prime}\left(\theta_{0}\right)-(1 / 2 n)\left(\theta-\theta_{0}\right) \ell^{\prime \prime \prime}\left(\theta^{*}\right)}.
        \]
        \item  Prove that
        \[
            \frac{1}{\sqrt{n}} \ell^{\prime}\left(\theta_{0}\right) \stackrel{d}{\rightarrow} \mathcal{N}\left(0, I\left(\theta_{0}\right)\right), \quad n \rightarrow \infty.
        \]
        \item Prove that
        \[
            -\frac{1}{n} \ell^{\prime \prime}\left(\theta_{0}\right) \stackrel{\mathbb{P}}{\rightarrow} I\left(\theta_{0}\right), \quad n \rightarrow \infty.
        \]
        \item In expression (\ref{eq:7.6}), assume \(\theta\) is replaced by a consistent sequence of roots \(\left\{\hat{\theta}_{n}\right\}\). Show that
        \[
        \frac{1}{n} \ell^{\prime \prime \prime}\left(\theta_{n}^{*}\right)
        \]
        is bounded in probability. Use this fact and the previous parts to show that the sequence of roots \(\left\{\widehat{\theta}_{n}\right\}\) is asymptotically efficient.
    \end{enumerate}
\end{ex}

\begin{solution}
    \begin{enumerate}[(a)]
        \item Here, $\ell(\theta)$ is log-likelihood function. $\theta$ is root,
        \[
            \ell^{\prime}\left(\theta_{0}\right)+\left(\theta-\theta_{0}\right) \ell^{\prime \prime}\left(\theta_{0}\right)+\frac{1}{2}\left(\theta-\theta_{0}\right)^{2} \ell^{\prime \prime \prime}\left(\theta^{*}\right)=0,
        \]
        \[
            \left(\theta-\theta_{0}\right)=\frac{\ell^{\prime}\left(\theta_{0}\right)}{-\ell^{\prime \prime}\left(\theta_{0}\right)-\frac{1}{2}\left(\theta-\theta_{0}\right) \ell^{\prime \prime \prime}\left(\theta^{*}\right)},
        \]
        \[
            \sqrt{n}\left(\theta-\theta_{0}\right)=\frac{(1/\sqrt{n})\ell^{\prime}\left(\theta_{0}\right)}{-(1/n)\ell^{\prime \prime}\left(\theta_{0}\right)-\frac{1}{2n}\left(\theta-\theta_{0}\right) \ell^{\prime \prime \prime}\left(\theta^{*}\right)}.
        \]
        \item \begin{align*}
            \frac{1}{\sqrt{n}} \ell^{\prime}\left(\theta_{0}\right) =\sqrt{n}/n \sum\left(\log'(f(X_i|\theta_0))\right)
        \end{align*}
        Noticing that $E(\log'(f(X_i|\theta_0)))=0$, $Var(\log'(f(X_i|\theta_0)))=I(\theta_0)$, $E(\log'(f(X_i|\theta_0)))\stackrel{d}{\to}\mathcal{N}(0, I(\theta_0)/n)$. So,
        \[
            \frac{1}{\sqrt{n}} \ell^{\prime}\left(\theta_{0}\right) =\sqrt{n}/n \sum\left(\log'(f(X_i|\theta_0))\right)\stackrel{d}{\to}\mathcal{N}(0, I(\theta_0)).
        \]
        \item \[
            -\frac{1}{n}l''(\theta_0)=\frac{1}{n} \sum\frac{f'^2(X_i|\theta_0)-f(X_i|\theta_0)f''(X_i|\theta_0)}{f^2(X_i|\theta_0)}\stackrel{P}{\to}I(\theta_0)+E(\log''(f(X_i|\theta_0)))=I(\theta_0).
        \]
        \item Because $\ell'''(X_i, \theta)<M(X_i)$,  let $M(X)=\max (M(X_1), \cdots, M(X_n))$. \[
            \frac{1}{n} \ell^{\prime \prime \prime}\left(\theta_{n}^{*}\right)=\frac{1}{n}\sum \ell'''(X_i|\theta)<M(X)\to E(M(X)).
        \]
        So, $\frac{1}{n} \ell^{\prime \prime \prime}\left(\theta_{n}^{*}\right)$ is a bound in probability.

        Finally, $n\to\infty$, $\widehat{\theta}_n\to\theta_0$, \[
            \sqrt{n}(\widehat{\theta}_n-\theta)\sim\frac{\mathcal{N}(0, I(\theta))}{I(\theta)}=\mathcal{N}\left((0, {\frac{1}{I(\theta)}}\right).
        \]
    \end{enumerate}
\end{solution}

\begin{ex}
    (this problem is about casting new light on a well-known result)

    Consider an i.i.d. sample \(X_{1}, \cdots, X_{n}\) from the location family \(f(x-\mu), \mu \in \mathbb{R}\), where
    \[
        f(x)=\frac{1}{\sqrt{2 \pi} \sigma_{0}} \exp \left\{-\frac{1}{2 \sigma_{0}^{2}} x^{2}\right\}
    \]
    and \(\sigma_{0}\) is known.
    \begin{enumerate}[(a)]
        \item Show that the likelihood equation has a unique root. Is it related to the ML estimator?
        \item Conclude that the sequence of roots thus obtained is consistent.
        \item Conclude that such sequence is asymptotically efficient. Calculate the asymptotic variance.
    \end{enumerate}
\end{ex}

\begin{solution}
    \begin{enumerate}[(a)]
        \item Same as (\ref{ex:7.2}.\ref{ex:7.2.a}). It is MLE.
        \item $\mu=\sum x_i/n$. From LLN,
        \[
            \delta(X)=\frac{\sum_{i=1}^nX_i}{n}\to\bar{X}=\mu.
        \]
        So, it is consistent.
        \item \[
            \bar{X}\sim\mathcal{N}(\mu,\sigma_0^2/n)\Rightarrow\sqrt{n}(\delta-\mu)\to \mathcal{N}\left(0, \sigma_0^2\right).
        \]
        Because $I(\mu)=1/\sigma^2$, $\delta$ is asymptotically efficient.
    \end{enumerate}
\end{solution}

\begin{ex}
    Let \(X_{1}, \cdots, X_{n} \stackrel{\text { i.i.d. }}{\sim} \operatorname{NegBin}(m, p)\), i.e.,
    \[
        \mathbb{P}\left(X_{1}=x\right)=\left(\begin{array}{c}
        m+x-1 \\
        m-1
        \end{array}\right) p^{m}(1-p)^{x}, \quad x=0,1,2, \cdots
    \]
    Find an EL estimator of \(p\).
\end{ex}

\begin{solution}
    Assume $m$ is known.
    \[
        \ell'(p)=\frac{nmp^{nm-1}(1-p)^{\sum x_i}+p^{nm}\sum x_i(1-p)^{\sum x_i-1}}{p^{nm}(1-p)^{\sum x_i}}=\frac{nm(1-p)+p\sum x_i}{p(1-p)}.
    \]
    $p\neq 0$ or $1$, $\ell'(p)=0$ has the unique root $\hat{p}=\frac{nm}{nm-\sum x_i}$. So, it is also the efficient likelihood estimator.
\end{solution}

\begin{ex}
    Let \(X_{1}, \cdots, X_{n} \stackrel{\text { i.i.d. }}{\sim} \mathcal{N}\left(\theta, a \theta^{2}\right), \theta>0\), and \(a>0\) is known. Find an explicit expression for an EL estimator of \(\theta\).
\end{ex}

\begin{solution}
    \[
        \ell(\theta)=-\frac{n}{2}\log\left(2\pi a\theta^2\right)-\frac{1}{2a\theta^2}\sum(x_i-\theta)^2.
    \]
    \[
        \ell'(\theta)=-\frac{n}{\theta}+\frac{\sum(x_i-\theta)^2}{a\theta^3}+\frac{\sum(x_i-\theta)}{a\theta^2}= 0.
    \]
    \[
        \hat{\theta}=\frac{2\sum x_i}{1\pm\sqrt{1+4an}}.
    \]
    Because $\theta>0$, the root is unique, i.e., $\hat{\theta}=\frac{2\sum x_i}{1+\sqrt{1+4an}}$.
\end{solution}

\begin{ex}
    We now extend the theorem on efficient likelihood (EL) estimators for canonical exponential families to the multiparameter case.

    Let \(X_{1}, \cdots, X_{n}\) be an i.i.d. sample from a multiparameter canonical exponential family. Under assumptions analogous to those for the univariate case, with probability \(\rightarrow 1\) as \(n \rightarrow \infty\) there exist solutions
    \[
        \widehat{\theta}_{n}=\hat{\theta}_{n}(\mathbf{X})
    \]
    of the likelihood equations such that
    \begin{enumerate}[(i)]
        \item \(\hat{\theta}_{j n} \stackrel{\mathbb{P}}{\rightarrow} \theta_{j}, n \rightarrow \infty\);
        \item \(\sqrt{n}\left(\widehat{\theta}_{n}-\theta\right) \stackrel{d}{\rightarrow} \mathcal{N}\left(0, I(\theta)^{-1}\right), n \rightarrow \infty\);
        \item \(\widehat{\theta}_{j n}\) is asymptotically efficient in the sense that
        \[
            \sqrt{n}\left(\hat{\theta}_{j n}-\theta_{j}\right) \stackrel{d}{\rightarrow} \mathcal{N}\left(0,\left(I(\theta)^{-1}\right)_{j j}\right), \quad n \rightarrow \infty.
        \]
    \end{enumerate}
    Here, we define
    \[
        I(\theta)=\mathbb{E}_{\theta}\left[\left(\frac{\partial}{\partial \theta} \log f(x \mid \theta)\right)\left(\frac{\partial}{\partial \theta} \log f(x \mid \theta)\right)^T\right]
    \]
    As before, under smoothness we have
    \[
        I(\theta)=-\mathbb{E}\left(\frac{\partial^{2}}{\partial \theta \partial \theta^T} \log f(x \mid \theta)\right)
    \]
    So, let \(X_{1}, \cdots, X_{n}\) be an i.i.d. sample from a multiparameter canonical exponential family
    \[
        f(x \mid \boldsymbol{\eta})=h(x) \exp \{\langle\boldsymbol{\eta}, T(x)\rangle-A(\boldsymbol{\eta})\}
    \]
    Assume that \(\mathcal{E} \neq \emptyset, \mathcal{E} \subseteq \mathbb{R}^{k}\), is open and that identifiability holds.
    \begin{enumerate}[(a)]
        \item Conclude that, with probability \(\rightarrow 1\) as \(n \rightarrow \infty, \widehat{\boldsymbol{\eta}}_{\mathrm{ML}}\) exists and is unique, and find its expression.
        \item Conclude that
        \[
            \sqrt{n}\left(\widehat{\boldsymbol{\eta}}_{\mathrm{ML}}-\boldsymbol{\eta}\right) \stackrel{d}{\rightarrow} \mathcal{N}\left(0, \frac{1}{Var_{\boldsymbol{\eta}}(T)}\right), \quad n \rightarrow \infty
        \]
        i.e., \(\widehat{\boldsymbol{\eta}}_{\mathrm{ML}}\) is an EL estimator of \(\boldsymbol{\eta}\).
    \end{enumerate}
\end{ex}

\begin{solution}
    多参数的情况不写了, 不可能考.
\end{solution}

\begin{ex}
    An estimator \(\delta_{n}(\mathbf{X})\) is called \(\sqrt{n}\)-consistent to \(\theta\) if \(\sqrt{n}\left(\delta_{n}(\mathbf{X})-\theta\right)\) is bounded in probability. Let \(\left\{X_{n}\right\}_{n \in \mathbb{N}}\) be an i.i.d. sequence such that \(\mathbb{E} X_{1}^{2}<\infty\). Show that \(\bar{X}_{n}\) is \(\sqrt{n}\)-consistent to \(\mu:=\mathbb{E} X_{1}\).

    (hint: Prohorov's theorem ensures that boundedness in probability is equivalent to the existence of a subsequence that converges weakly).
\end{ex}

\begin{solution}
    这题和上面那个有啥区别吗?
\end{solution}

\begin{ex}
    Let \(\tilde{\theta}_{n}(\mathbf{X})\) be a \(\sqrt{n}\)-consistent estimator of \(\theta\) under the log-likelihood \(\ell(\theta \mid \mathbf{X})\). Under the conditions of the asymptotic normality theorem for EL estimators, it can be shown that the estimator
    \begin{equation}
        \label{eq:7.12}
        \delta_{n}(\mathbf{X}):=\tilde{\theta}_{n}(\mathbf{X})-\frac{\ell^{\prime}\left(\tilde{\theta}_{n}(\mathbf{X})\right)}{\ell^{\prime \prime}\left(\tilde{\theta}_{n}(\mathbf{X})\right)}
    \end{equation}
    is also asymptotically efficient (Theorem 6.4.3 in Lehmann and Casella (1998)).
    Let \(\{f(x-\theta)\}_{\theta \in \Theta}\) be a location family based on the symmetric (around zero) and a.c. density \(f\) with finite second moments. Assume that the likelihood equation
    \[
    \frac{\partial}{\partial \theta} \log f(\mathbf{x} \mid \theta)=0
    \]
    has potentially multiple roots. Use (\ref{eq:7.12}) to find an asymptotically efficient estimator for \(\theta\)

    (hint: look at the previous problem).

    \rmk{3} It is clear that the expression (0.3) stems from one step of Newton-Raphson's method.
\end{ex}

\begin{solution}
    We know that $\sqrt{n}(\bar{X}-\theta)$ is bounded in probability, so we can use Theorem 6.4.3 to find an asymptotically efficient estimator for $\theta$:
    \[
        \delta_n(X)=\bar{X}-\frac{\ell'(\bar{X})}{\ell''(\bar{X})}.
    \]
    吐了, 这题到底在干啥.
\end{solution}

\begin{ex}
    Let \(\left\{X_{n}\right\}_{n \in \mathbb{N}} \stackrel{\text { i.i.d. }}{\sim} \mathcal{N}\left(\mu, \sigma^{2}\right), \mu \in \mathbb{R}, \sigma^{2}>0\), and let \(h(x)=x^{2}\).
    \begin{enumerate}[(a)]
        \item Construct asymptotic approximations to \(\mathbb{E}_{\theta} h(\bar{X})\) and \(Var_{\theta} h(\bar{X})\).
        \item Based on the properties of Gaussian distributions, compute \(\mathbb{E}_{\theta} h(\bar{X})\) and \(Var_{\theta} h(\bar{X})\) explicitly and compare the expressions with the approximations obtained in (a). Do the approximations orders match?
    \end{enumerate}
\end{ex}

\begin{solution}
    \begin{enumerate}[(a)]
        \item $\hat{x}_{ML}=\bar{X}$. From Delta method, take $T(X)=\bar{X}$, $h(x)=x^2$.
        \[
            n(\bar{X}^2-\mu^2)\stackrel{d}{\to}1/2 \sigma^2 2 \chi_1^2=\sigma^2\chi_1^2.
        \]
        $E(\bar{X}^2): \mu^2+\sigma^2/n$, $Var(\bar{X}^2): \frac{2\sigma^4}{n^2}$.
        \item $\bar{X}\sim \mathcal{N}(\mu,\sigma^2/n)$.
        \[
            E(\bar{X}^2)=\sigma^2/n+\mu^2, \quad Var(\bar{X}^2)=\mu^4+6\mu^2\sigma^2/n+3\sigma^4/n^2.
        \]
        The order is match.
    \end{enumerate}
\end{solution}

\begin{ex}
    Consider the following setup.
    \begin{itemize}
        \item \(\left\{X_{n}\right\}_{n \in \mathbb{N}}\) : i.i.d. sequence, \(X_{1} \sim \mathcal{P}=\left\{\mathbb{P}_{\theta}\right\}_{\theta \in \Theta}\);
        \item \(\mathbb{E}_{\theta} X_{1}=\mu, Var_{\theta} X_{1}=\sigma^{2}>0, \mathbb{E}_{\theta} X_{1}^{4}<\infty\);
        \item \(h: I \rightarrow \mathbb{R}\) is a 4-times differentiable function, where \(\mathbb{P}_{\theta}\left(X_{1} \in I\right)=1, \theta \in \Theta\);
        \item \(\left|h^{(i v)}(x)\right| \leq M<\infty, x \in I\);
        \item \(c_{n}=1+\frac{a}{n}+O\left(\frac{1}{n^{2}}\right), n \in \mathbb{N}, a \in \mathbb{R}\).
    \end{itemize}
    Consider the estimator \(\delta_{n}(\bar{X})=h\left(c_{n} \bar{X}\right)\). Show that
    \[
        Var_{\theta} \delta_{n}(\bar{X})=\frac{\sigma^{2}}{n}\left[h^{\prime}(\mu)\right]^{2}+O\left(\frac{1}{n^{2}}\right) .
    \]
\end{ex}

\begin{solution}
    6.2.a.
\end{solution}

\begin{ex}
    Let \(\left\{X_{n}\right\}_{n \in \mathbb{N}} \stackrel{\text { i.i.d. }}{\sim} \mathcal{N}\left(\mu, \sigma^{2}\right), \mu \in \mathbb{R}, \sigma^{2}>0\), and let \(h(x)=e^{x^{4}}\). It is clear that all moments of \(X\) and all derivatives of \(h\) exist.
    \begin{enumerate}[(a)]
        \item Show that \(\mathbb{E}\left|h\left(\bar{X}_{n}\right)\right|=\infty, n \in \mathbb{N}\). Conclude that
        \[
            \mathbb{E}_{\theta} \sqrt{n}\left[h\left(\bar{X}_{n}\right)-h(\mu)\right]^{2}=\infty, \quad n \in \mathbb{N} .
        \]
        \item By contrast, assuming \(\mu \neq 0\), show that \(\sqrt{n}\left[h\left(\bar{X}_{n}\right)-h(\mu)\right]\) has a normal limit distribution with finite variance.
        \item Conclude that the theorem seen in class on the approximation of moments does require bounded derivatives.
    \end{enumerate}
\end{ex}

\begin{solution}
    \begin{enumerate}[(a)]
        \item \[
            E\left(e^{x^4}\right)=\int A\exp\left(B(x-\mu)^2+x^4\right)\der x
        \]
        $x\to\infty$, $A\exp\left(B(x-\mu)^2+x^4\right)\to\infty$. So, $E\left(e^{x^4}\right)\to\infty$. Samilarly,
        \[
            E(e^{2x^4})=\infty.
        \]
        So, $E(\sqrt{n}(h(\bar{X}_n)-h(\mu))^2)=\infty$.
        \item $Var(\bar{X})=\sigma^2/n<\infty$. From Delta method, it has a normal limit distribution with finite variance.
        \item
    \end{enumerate}
\end{solution}

\begin{ex}
    The Hardy-Weinberg principle from population genetics describes an idealized situation where there are no evolutionary influences.

    Assume that two alleles \(A\) and \(a\) appear in a population's gene pool with frequencies \(\theta\) and \(1-\theta, 0<\theta<1\), respectively. The principle states that, in equilibrium, the frequencies of the genotypes \(A A, A a\) and \(a a\) will remain constant from generation to generation at
    \[
    p_{1}(\theta)=\theta^{2}, \quad p_{2}(\theta)=2 \theta(1-\theta), \quad p_{3}(\theta)=(1-\theta)^{2},
    \]
    respectively.

    Assume that a sample \(\mathbf{X}=\left(X_{1}, X_{2}, X_{3}\right)\) is drawn. If the population is very large, then we can suppose that the sampling was done with replacement, whence
    \[
    \mathbb{P}(\mathbf{X}=\mathbf{x} \mid \theta)=\frac{n !}{x_{1} ! x_{2} ! x_{3} !} p_{1}(\theta)^{x_{1}} p_{2}(\theta)^{x_{2}} p_{3}(\theta)^{x_{3}}, \quad \sum_{i=1}^{3} x_{i}=n .
    \]
    What is the probability that \(\widehat{\theta}_{\mathrm{ML}}\) exists, and how does it behave as \(n \rightarrow \infty\) ?
\end{ex}


\documentclass[11pt]{amsart}

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{xcolor}

\DeclareMathOperator\erf{erf}

\newcommand{\airgrid}{\mathrm{air-grid}}
\newcommand{\app}{a}
\newcommand{\cutin}{\mathrm{cut-in}}
\newcommand{\cutout}{\mathrm{cut-out}}
\newcommand{\extra}{\mathrm{extra}}
\newcommand{\grav}{\mathrm{grav}}
\newcommand{\groundinverter}{\mathrm{ground\;inv.}}
\newcommand{\kiteinverter}{\mathrm{kite\;inv.}}
\newcommand{\kite}{k}
\newcommand{\lp}{\mathrm{loop}}
%\newcommand{\max}{\mathrm{max}}
\newcommand{\motor}{\mathrm{motor}}
\newcommand{\path}{\mathrm{path}}
\newcommand{\prop}{\mathrm{prop}}
\newcommand{\swept}{\mathrm{swept}}
\newcommand{\sys}{\mathrm{sys}}
\newcommand{\tether}{\mathrm{tether}}
\newcommand{\wind}{w}

\definecolor{matlab1}{rgb}{0, 0.4470, 0.7410}
\definecolor{matlab2}{rgb}{0.8500, 0.3250, 0.0980}
\definecolor{matlab3}{rgb}{0.9290, 0.6940, 0.1250}
\definecolor{matlab4}{rgb}{0.4940, 0.1840, 0.5560}
\definecolor{matlab5}{rgb}{0.4660, 0.6740, 0.1880}
\definecolor{matlab6}{rgb}{0.3010, 0.7450, 0.9330}
\definecolor{matlab7}{rgb}{0.6350, 0.0780, 0.1840}

\title{Crosswind kite power curve}
\author{Makani Technologies LLC}
\date{June 28, 2016}

\begin{document}
\maketitle

\section{Fundamentals}
\label{sec:fundamentals}

Traditional wind turbines use the power coefficient, $C_P$, as a
critical performance metric:
%
\begin{equation}
C_P = \frac{P}{\frac{1}{2} \rho v_{\wind}^3 A_{\swept}}
\end{equation}
%
This is the value that is optimized in the celebrated Betz limit,
which says that the maximum achievable power coefficient is $C_P \approx 0.593$.
Notably the power coefficient is referenced to the {\it swept area} of
the wind turbine blades, which is reasonable given the limited swept
area available to a traditional wind turbine.

For kite based systems, where system cost is correlated with kite size
rather than the vast swept area, it makes sense to reference the power
coefficient to {\it kite area}.  This value is referred to as $\zeta$:
%
\begin{equation}
\label{eqn:zeta}
\zeta = \frac{P}{\frac{1}{2} \rho v_{\wind}^3 A_{\kite}}
\end{equation}

However, optimizing a system for the maximum $C_P$ or $\zeta$ is not
the same as optimizing for cost!  In fact, optimizing a system for
maximum $\zeta$ actually increases the maximum tension, a substantial
cost driver, over a Betz limited system by a factor of two.  To
describe how efficiently a system converts tension into power, it is
useful to introduce another dimensionless variable, the tension
efficiency, $\eta_T$:
%
\begin{equation}
\label{eqn:eta_T}
\eta_T = \frac{P}{T v_{\wind}}
\end{equation}
%
According to actuator disk theory, for a Betz limited system, the wind
velocity at the disk, where it may be assumed the force is applied, is
$\frac{2}{3} v_{\wind}$.  Thus, the tension efficiency for a Betz
limited system is $\eta_T = \frac{2}{3}$.

To calculate the corresponding tension efficiency for a kite power
system that attempts to maximize $\zeta$, i.e. a Loyd limited system,
it is first necessary to relate $\zeta$ to physical properties of the
kite.  Ignoring power efficiency losses and the typically low
induction factors of kite propellers, the power generated by the kite
is approximately, $P = D_{\prop} v_{\kite}$, where $D_{\prop}$ is the
drag on all the propellers and $v_{\kite}$ is the airspeed of the
kite.  Substituting this into Eq. \ref{eqn:zeta}, it is found that
%
\begin{equation}
\label{eqn:zeta_prop}
\zeta = C_{D_{\prop}} \left(\frac{v_{\kite}}{v_{\wind}} \right)^3
\end{equation}

The kite-to-wind speed ratio, which figures prominently in
Eq. \ref{eqn:zeta_prop}, may be related to the lift and drag
coefficients of the kite through simple force balance.  Specifically,
the airspeed of a kite traveling perpendicular to the wind is given
by:
%
\begin{equation}
\label{eqn:kite_speed}
v_{\kite} = \sqrt{1 + \left(\frac{C_L}{C_D}\right)^2} v_{\wind}
          \approx \frac{C_L}{C_D} v_{\wind}
\end{equation}
%
Here the drag coefficient, $C_D$, may be divided into two components:
system drag, $C_{D_{\sys}}$, and propeller drag, $C_{D_{\prop}}$.  The
system drag coefficient includes parasitic drag, induced drag, and
tether drag, and to a large degree is fixed during flight.  The
propeller drag coefficient, however, may be tuned over a wide range.

To optimize propeller drag for various metrics, e.g. $\zeta$ or
$\eta_T$, it is useful to express the tunable propeller drag
coefficient as a fraction, $k$, of the fixed system drag coefficient:
$C_{D_{\prop}} = k C_{D_{\sys}}$.  Now, the kite-to-wind speed ratio,
$\lambda$, from Eq. \ref{eqn:kite_speed} is
%
\begin{equation}
\label{eqn:lambda}
\lambda = \frac{v_{\kite}}{v_{\wind}} = \frac{C_L}{C_{D_{\sys}}} \frac{1}{1 + k}
\end{equation}
%
Thus, $\zeta$ from Eq. \ref{eqn:zeta_prop} is
%
\begin{equation}
\zeta = \frac{C_L^3}{C_{D_{\sys}}^2} \frac{k}{(1+k)^3}
\end{equation}
%
And finally, using the approximation for tension,
$T = \frac{1}{2} \rho v_{\kite}^2 A_{\kite} C_L$, the tension efficiency, $\eta_T$,
from Eq. \ref{eqn:eta_T}, is
%
\begin{equation}
\eta_T = \frac{k}{1 + k}
\end{equation}

\begin{figure}
\begin{center}
\begin{tikzpicture}
\begin{axis}[axis lines=middle, samples=200,
    grid=both,
    grid style={line width=1pt, draw=gray!10},
    x label style={at={(axis description cs:0.5,-0.1)}, anchor=north},
    y label style={at={(axis description cs:-0.1,.5)}, rotate=90, anchor=south},
    xlabel={Propeller drag fraction, $k$ [\#]},
    ylabel={Metric [\#]},
    legend pos=south east]
\addplot[matlab1, domain=0:2] {1 / (1 + x)};
\addplot[matlab2, domain=0:2] {x / (1 + x)^3 / (4/27)};
\addplot[matlab3, domain=0:2] {x / (1 + x)};
\legend{$\lambda / \lambda_0$, $\zeta / \zeta_{\max}$, $\eta_T$};
\end{axis}
\end{tikzpicture}
\caption{Kite performance metrics as a function of the propeller drag
  fraction.}
\end{center}
\end{figure}

There are many interesting things to note from the three dimensionless
performance metrics described above ($\lambda$, $\zeta$, and $\eta_T$):
\begin{itemize}
\item The kite speed is proportional to the system's
  lift-to-drag ratio, as expected, and this is tunable with the
  propeller drag.

\item The $C_L^3$ in the $\zeta$ metric really encourages high lift
  coefficients.  This effect is even more dramatic considering the
  high drag penalty imposed by the tether, which makes the increase in
  induced drag with $C_L^2$ less important when compared to other
  systems that optimize for the endurance metric.

\item Maximizing $\zeta$ requires setting the propeller drag to half
  the system drag, $k = \frac{1}{2}$.  From Eq. \ref{eqn:lambda}, this
  is equivalent to saying that the kite should fly at $\frac{2}{3}$ of
  its zero-propeller-drag speed.

\item The tension efficiency is independent of any system parameter
  save the propeller drag fraction.

\item Finally, optimizing for $\zeta$ results in a tension efficiency
  of $\eta_T = \frac{1}{3}$.  Thus, maximizing $\zeta$ results in half
  the tension efficiency of a Betz limited system.  Of course, it is
  not necessary to fly a system at maximum $\zeta$; and if $k$ is
  increased to 2, the system will achieve the same tension efficiency
  as a Betz limited device, but $\zeta$ will drop by a factor of 2.
\end{itemize}

\section{Ideal power curve}

\begin{figure}[h]
\label{fig:power_curve}
\begin{center}
\begin{tikzpicture}
  \def\CL{2.1};
  \def\CDsys{0.18};
  \def\costheta{1};
  \def\etaairgrid{1};
  \def\Tmax{150};  % [kN]
  \def\Pmax{600};  % [kW]
  \def\zetamax{(4/27 * \CL^3 / \CDsys^2)};
  \def\Ak{32.9};
  \def\rho{1.2};
  \def\vkitemin{30};
  \def\P0{(0.5 * \rho * \Ak * \CDsys * \vkitemin^3 / 1000)};
  \def\vcutin{(\CDsys / \CL * \vkitemin / \costheta)};
  \def\vT{((\Tmax * 1000 / 3 / (0.5 * \rho * \Ak * \zetamax))^0.5 / \costheta)};
  \def\vP{(\Pmax / (\etaairgrid * \Tmax * \costheta) + 2 * \vT / 3)};
  \def\loydcoeff{(\etaairgrid * \costheta^3 * 0.5 * \rho * \Ak * \zetamax / 1000)};

\begin{axis}[axis lines=middle, samples=200,
    grid=both,
    grid style={line width=1pt, draw=gray!10},
    x label style={at={(axis description cs:0.5,-0.1)}, anchor=north},
    y label style={at={(axis description cs:-0.1,.5)}, rotate=90, anchor=south},
    xlabel={Wind speed [m/s]},
    ylabel={Power [kW]},
    legend pos=north west]
  \addplot[matlab1, domain=0:(\vcutin)] {0};
  \addplot[matlab2, domain=(\vcutin):(1.5 * \vcutin)] {\etaairgrid * \P0 * (x / \vcutin - 1)};
  \addplot[matlab3, domain=(1.5 * \vcutin):(\vT)] {\loydcoeff * x^3};
  \addplot[matlab4, domain=(\vT):(\vP)] {\etaairgrid * \costheta * \Tmax * (x - 2 * \vT / 3)};
  \addplot[matlab5, domain=(\vP):(\vP + 2)] {\Pmax};
  \legend{$v_{\wind,\cutin}$, $v_{\kite,\min}$, $\zeta_{\max}$, $T_{\max}$, $P_{\max}$};

  \addplot[matlab3, dashed, domain=2:(1.5 * \vcutin)] {\loydcoeff * x^3};
  \addplot[matlab3, dashed, domain=(\vT):(\vT + 2)] {\loydcoeff * x^3};
  \addplot[matlab2, dashed, domain=2:(\vcutin)] {\etaairgrid * \P0 * (x / \vcutin - 1)};

  \draw[gray, dashed] (axis cs:{\vcutin}, 50) -- (axis cs:{\vcutin}, 150)
  node [above, black] {$v_{\wind,\cutin}$};
  \draw[gray, dashed] (axis cs:{1.5 * \vcutin}, 100) -- (axis cs:{1.5 * \vcutin}, 250)
  node [above, black] {$v_{\wind,v_{\kite}}$};
  \draw[gray, dashed] (axis cs:{\vT}, {\loydcoeff * \vT^3 - 50}) -- (axis cs:{\vT}, {\loydcoeff * \vT^3 / 2})
  node [below, black] {$v_{\wind,T}$};
  \draw[gray, dashed] (axis cs:{\vP}, 550) -- (axis cs:{\vP}, 450)
  node [below, black] {$v_{\wind,P}$};

\end{axis}
\end{tikzpicture}
\caption{Representative ideal power curve showing the
  airspeed-limited, Loyd-limited, tension-limited, and power-limited
  segments.  This particular power curve assumes: $A_{\kite} = 32.9$
  m$^2$, $v_{\kite,\min} = 30$ m/s, $\zeta_{\max} = 42.3$, $T_{\max} = 150$
  kN, $P_0 = 96$ kW, and $P_{\max} = 600$ kW.}
\end{center}
\end{figure}

%% \begin{figure}
%% \label{fig:power_curve}
%% \begin{center}
%% \begin{tikzpicture}
%% \begin{axis}[axis lines=middle, samples=200,
%%     grid=both,
%%     grid style={line width=1pt, draw=gray!10},
%%     x label style={at={(axis description cs:0.5,-0.1)}, anchor=north},
%%     y label style={at={(axis description cs:-0.1,.5)}, rotate=90, anchor=south},
%%     xlabel={Wind speed [m/s]},
%%     ylabel={Power [kW]},
%%     legend pos=north west]
%%   \addplot[matlab1, domain=0:3.43] {0};
%%   \addplot[matlab2, domain=3.43:5.14] {127.9 * (x / 3.43 - 1)};
%%   \addplot[matlab3, domain=5.14:8.42] {0.4702 * x*x*x};
%%   \addplot[matlab4, domain=8.42:11.61] {100 * (x - 5.61)};
%%   \addplot[matlab5, domain=11.61:15] {600};
%%   \legend{$v_{\wind,\cutin}$, $v_{\kite,\min}$, $\zeta_{\max}$, $T_{\max}$, $P_{\max}$};

%%   \addplot[matlab3, dashed, domain=2:5.14] {0.4702 * x*x*x};
%%   \addplot[matlab3, dashed, domain=7.96:11.61] {0.4702 * x*x*x};
%%   \addplot[matlab2, dashed, domain=2:3.42] {127.9 * (x / 3.43 - 1)};

%%   \draw[gray, dashed] (axis cs:3.43, 50) -- (axis cs:3.43, 150)
%%   node [above, black] {$v_{\wind,\cutin}$};
%%   \draw[gray, dashed] (axis cs:5.14, 100) -- (axis cs:5.14, 250)
%%   node [above, black] {$v_{\wind,v_{\kite}}$};
%%   \draw[gray, dashed] (axis cs:8.42, 250) -- (axis cs:8.42, 150)
%%   node [below, black] {$v_{\wind,T}$};
%%   \draw[gray, dashed] (axis cs:11.61, 550) -- (axis cs:11.61, 450)
%%   node [below, black] {$v_{\wind,P}$};
%% \end{axis}
%% \end{tikzpicture}
%% \caption{Representative ideal power curve showing the
%%   airspeed-limited, Loyd-limited, tension-limited, and power-limited
%%   segments.  This particular power curve assumes: $A_{\kite} = 32.9$
%%   m$^2$, $v_{\kite,\min} = 30$ m/s, $\zeta_{\max} = 23.8$, $T_{\max} = 100$
%%   kN, $P_0 = 127.9$ kW, and $P_{\max} = 600$ kW.}
%% \end{center}
%% \end{figure}

Figure \ref{fig:power_curve} shows the general form of a crosswind
kite power curve.  Below the cut-in wind speed, $v_{\wind,\cutin}$,
the system generates no power, or negative power if it is necessary to
keep the kite flying.  Then, there is a small range of low wind speeds
where the system is limited by the requirement to maintain some
minimum airspeed, $v_{\kite,\min}$.  Next, the curve is Loyd-limited,
or only limited by the maximum achievable $\zeta$.  Here the kite is
trying to extract as much power as possible from the wind regardless
of tension.  At some wind speed, $v_{\wind,T}$, however, it becomes
important to limit the tension.  Here, the propeller drag fraction is
increased from the Loyd optimal of $k = \frac{1}{2}$ to the maximum
value available for the system or until the system's power limit is
reached.  This curve clearly lies below the Loyd-limited curve.  The
final section above $v_{\wind,P}$ is the power limited section.  Power
may be dumped either by further increasing $k$ and slowing the wing
down or by shifting the flight path off from downwind.

It is possible to describe the power curve from
Fig. \ref{fig:power_curve} in terms of the fundamental limitations of
the system: $v_{\kite,\min}$, $\zeta_{\max}$, $T_{\max}$, and either
$k_{\max}$ or $P_{\max}$ depending on whether the power limit is set
by the propellers or the electrical power system.  In the following,
the functional form of the power curve in each of the sections is
derived.

The cut-in wind speed is the wind speed at which the kite maintains
some minimum airspeed, $v_{\kite,\min}$, while using zero thrust,
i.e. $k=0$.
%
\begin{equation}
v_{\wind,\cutin} = \frac{C_{D_{\sys}}}{C_L} v_{\kite,\min}
\end{equation}
%
Below the cut-in wind speed, it generally makes sense to land the
kite.  However, if it is necessary that the kite keep flying, then $k$
must be chosen to satisfy the minimum airspeed requirement.  It turns
out that the minimum airspeed requirement also constrains the power
curve slightly above $v_{\wind,\cutin}$ up to the airspeed-limit wind
speed threshold, $v_{\wind,v_{\kite}} = \frac{3}{2} v_{\wind,\cutin}$.
%
\begin{equation}
k = \frac{C_L}{C_{D_{\sys}}} \frac{v_{\wind}}{v_{\kite,\min}} - 1,\;\;\;\;
v_{\wind} < v_{\wind,v_{\kite}}
\end{equation}
%
Thus, the power curve in the airspeed-limited section is
%
\begin{equation}
P(v_{\wind}) = P_0 \left( \frac{v_{\wind}}{v_{\wind,\cutin}} - 1 \right),\;\;\;\;
v_{\wind} < v_{\wind,v_{\kite}}
\end{equation}
%
where $P_0 = \frac{1}{2} \rho v_{\kite,\min}^3 A_{\kite} C_{D_{\sys}}$
is the power necessary to keep the kite flying at its minimum airspeed
without wind.

The Loyd-limited section is simple and follows the expected
$v_{\wind}^3$ function.  The propeller drag is held at the optimal
$k=\frac{1}{2}$ value and thus the power curve is:
%
\begin{equation}
P(v_{\wind}) = \frac{1}{2} \rho v_{\wind}^3 A_{\kite} \zeta_{\max},\;\;\;\;
v_{\wind,v_{\kite}} < v_{\wind} < v_{\wind,T}
\end{equation}
%
where $v_{\wind,T}$ is the tension-limit wind speed threshold to be
derived below.

The next section is the tension-limited section.  Recall that here the
power curve is shifted down by slowing the kite down by increasing the
propeller drag.  To determine the appropriate propeller drag fraction
that meets the tension requirement, combine equations \ref{eqn:zeta}
and \ref{eqn:eta_T}, substituting $T_{\max}$ for tension:
%
\begin{equation}
\frac{1}{2} \rho v_{\wind}^3 A_{\kite} \frac{C_L^3}{C_{D_{\sys}}^2} \frac{k}{(1 + k)^3}
= T_{\max} v_{\wind} \frac{k}{1 + k}
\end{equation}
%
and solve for $k$:
%
\begin{equation}
k = \frac{3}{2} \sqrt{\frac{\frac{1}{2} \rho A_{\kite} \zeta_{\max}}{T_{\max} / 3}} \cdot v_{\wind} - 1
\end{equation}
%
The tension limited section begins when $k > \frac{1}{2}$.  Thus, the
threshold wind speed, $v_{\wind,T}$, for the tension limited section,
expressed in terms of limits of the system, is:
%
\begin{equation}
v_{\wind,T} = \sqrt{\frac{T_{\max} / 3}{\frac{1}{2} \rho A_{\kite} \zeta_{\max}}}
\end{equation}
%
From this it is also possible to derive an extremely simple form for
the maximum power in the tension limited section as a function of wind
speed:
%
\begin{equation}
P(v_{\wind}) = T_{\max} \left( v_{\wind} - \frac{2}{3} v_{\wind,T} \right),\;\;\;\;
v_{\wind,T} < v_{\wind} < v_{\wind,P}
\end{equation}

The start of the power limited section may either be set by the
fundamental limitations of the electrical power system, $P_{\max}$, or
by the maximum drag fraction, $k_{\max}$, achievable with the
propellers.  In a balanced system, these limits should be consistent
with each other, but it is useful to derive the form of the power
curve for each case.  In the power system limited case, the threshold
wind speed, $v_{\wind,P}$, for the power limited section is:
%
\begin{equation}
v_{\wind,P} = \frac{P_{\max}}{T_{\max}} + \frac{2}{3} v_{\wind,T}
\end{equation}
%
In the propeller drag limited case, there is essentially a maximum
tension efficiency, which can be used to convert the tension limit to
a power limit.  Thus,
%
\begin{equation}
v_{\wind,P} = \frac{2}{3} (1 + k_{\max}) v_{\wind,T}
\end{equation}
%
and the maximum power, $P_{\max}$, is
%
\begin{equation}
P_{\max} = \frac{2 (T_{\max} / 3)^{3/2} k_{\max}}{ \sqrt{\frac{1}{2} \rho A \zeta_{\max}}}
\end{equation}

Putting this all together in one place, the power curve is defined by:
%
\begin{equation}
P(v_{\wind}) =
\begin{cases}
  0 &
  v_{\wind} \le v_{\wind,\cutin} \\

  P_0 \left(\frac{v_{\wind}}{v_{\wind,\cutin}} - 1 \right) &
  v_{\wind,\cutin} < v_{\wind} \le \frac{3}{2} v_{\wind,\cutin} \\

  \frac{1}{2} \rho v_{\wind}^3 A_{\kite} \zeta_{\max} &
  \frac{3}{2} v_{\wind,\cutin} < v_{\wind} \le v_{\wind,T} \\

  T_{\max} \left( v_{\wind} - \frac{2}{3} v_{\wind,T} \right) &
  v_{\wind,T} < v_{\wind} \le v_{\wind,P} \\

  P_{\max} &
  v_{\wind,P} < v_{\wind} \le v_{\wind,\cutout} \\

  0 &
  v_{\wind} > v_{\wind,\cutout}
\end{cases}
\end{equation}

\section{Efficiency losses}

\subsection{Air-to-grid losses}

The simplified analysis in Sec. \ref{sec:fundamentals} assumes that
the power generated is equal to propeller drag times airspeed,
$P = D_{\prop} v_{\kite}$; however this does not take into account the
efficiency of the propellers in converting aerodynamic power into
mechanical shaft power.  Moreover, the shaft power from the propellers
goes through multiple conversions, from mechanical to electrical and
between AC and DC, and is transmitted down the tether.  Each of the
conversions and transmissions has an associated power loss and
efficiency.  The total efficiency between the aerodynamic forces on
the kite and the electrical power at the grid, $\eta_{\airgrid}$, is
given by:
%
\begin{equation}
  \label{eqn:total_efficiency}
  \eta_{\airgrid} = \eta_{\prop} \cdot \eta_{\motor} \cdot \eta_{\kiteinverter}
  \cdot \eta_{\tether} \cdot \eta_{\groundinverter}
\end{equation}

The efficiency loss for the tether is simply the power loss from
resistive heating in the tether $i^2 R_{\tether}$:
%
\begin{equation}
  \label{eqn:tether_efficiency}
  \eta_{\tether} = 1 - \frac{P_{\kite} R_{\tether}}{V_{\kite}^2}
\end{equation}

\begin{table}[h]
\begin{tabular}{lcl}
\hline
\hline
Efficiency               & Typical value & Source \\
\hline
$\eta_{\prop}$           & 0.81          & \textsc{xrotor}, Rev. 2 props \\
$\eta_{\motor}$          & 0.95          & YASA engineering report \\
$\eta_{\kiteinverter}$   & 0.96          & Dyno measurements \\
$\eta_{\tether}$         & 0.95          & Eq. \ref{eqn:tether_efficiency} \\
$\eta_{\groundinverter}$ & 0.96          & Satcon datasheet \\
\hline
$\eta_{\airgrid}$        & 0.67          & Eq. \ref{eqn:total_efficiency} \\
\hline
\hline
\end{tabular}
\caption{Total efficiency stack-up.}
\end{table}

\subsection{Off-downwind losses}

The simplified analysis in Sec. \ref{sec:fundamentals} also assumes
that the flight path of the kite is normal to the direction of the
wind.  To modify this analysis to account for a flight path that is
centered at some elevation and azimuth angle off downwind, simply
replace the wind velocity, $v_{\wind}$, with the wind velocity
perpendicular to the flight path, $v_{\wind, \perp}$.
%
\begin{equation}
v_{\wind, \perp} = v_{\wind} \cos \theta
\end{equation}
%
Here $\theta$ is the angle between the normal vector of the flight
path and the wind vector.

\subsection{Gravity losses}

Significant power is lost due to various effects from the velocity
changes caused by gravity.  The exact form of this loss depends on the
propeller strategy used.  There are two naive propeller strategies,
neither optimal, which can be used to determine the worst case gravity
loss.

The first propeller strategy, which is the easiest to analyze, is the
constant airspeed strategy, where a term is added to the nominal
propeller drag to exactly cancel the force of gravity.  The loss here
occurs because the conversion of power from aerodynamic power to
electrical grid power and back is not perfectly efficient.  The exact
form of the power loss with this strategy is
%
\begin{equation}
  \label{eqn:gravity_loss1}
  P_{\grav} = \frac{m g_{\parallel} v_{\kite}}{\pi}
  \left( \eta_{\airgrid} - 1/\eta_{\airgrid} \right)
\end{equation}

The second propeller strategy is the constant drag fraction strategy.
Here, the control system ignores the speed variations caused by
gravity.  One way to view this strategy is that the kite is storing
the excess energy during the down stroke as the kinetic energy in the
kite and then reusing this energy on the upstroke.  Storing and
reusing the energy in this manner is more efficient than converting
the power to and from electrical power.

To analyze this strategy, assume that the velocity of the kite takes
the approximate form
%
\begin{equation}
  v_{\kite} \approx v_{\kite,0} + \Delta v \sin \psi
\end{equation}
%
where $\psi$ is the angle around the loop.  The velocity modulation
fraction, $a = \Delta v / v_{\kite,0}$, is approximately:
%
\begin{equation}
  \label{eqn:velocity_modulation}
  a = \frac{\Delta v}{v_{\kite,0}} \approx
      \frac{m g_{\parallel} R_{\path}}
           {m v_{\kite, 0}^2 +
            \frac{1}{2} \rho v_{\kite, 0}^2 A_{\kite} C_{D_{\sys}} (1 + k) R_{\path}}
\end{equation}
%

There are two main power loss mechanisms due to the velocity
variation.  The first mechanism is simply that the kite is no longer
flying at the optimal airspeed.  The effect of this can be found by
integrating the extra drag force on the kite,
$D_{\extra} = \frac{1}{2} \rho C_D A_{\kite} v_{\kite} \Delta v$, around
the loop.  The second mechanism is that, while the kite generates the
same amount of energy per loop, the loops take longer for larger
modulations.  Combining these effects, the power loss due to gravity
is:
%
\begin{equation}
  \label{eqn:gravity_loss2}
  P_{\grav} = \; P(v_{\wind}) \left( 1 - \sqrt{1 - a^2} - \frac{a^2}{2} \sqrt{1 - a^2} \right)
\end{equation}
%
Note that this quantity is defined to be positive for a power less.

\section{Realistic power curve}

Equation \ref{eqn:real_power_curve} describes the modified power curve
after applying the efficiency losses from the previous section:
%
\begin{equation}
  \label{eqn:real_power_curve}
P(v_{\wind}) =
\begin{cases}
  0 &
  v_{\wind} \le v_{\wind,\cutin} \\

  \eta_{\airgrid} \cdot P_0 \left(\frac{v_{\wind}}{v_{\wind,\cutin}} - 1 \right) - P_{\grav} &
  v_{\wind,\cutin,0} < v_{\wind} \le \frac{3}{2} v_{\wind,\cutin,0} \\

  \eta_{\airgrid} \cdot \frac{1}{2} \rho v_{\wind}^3 A_{\kite} \zeta_{\max} \cos^3 \theta - P_{\grav} &
  \frac{3}{2} v_{\wind,\cutin,0} < v_{\wind} \le v_{\wind,T} \\

  \eta_{\airgrid} \cdot T_{\max} \cos \theta \left( v_{\wind} - \frac{2}{3} v_{\wind,T} \right) - P_{\grav} &
  v_{\wind,T} < v_{\wind} \le v_{\wind,P} \\

  P_{\max} &
  v_{\wind,P} < v_{\wind} \le v_{\wind,\cutout} \\

  0 &
  v_{\wind} > v_{\wind,\cutout}
\end{cases}
\end{equation}
%
Note that because of the complicated form of the gravity power losses
(see Eq. \ref{eqn:gravity_loss1} and Eq. \ref{eqn:gravity_loss2}), they
are included as a wind speed independent constant for now.

\begin{equation}
P_0 = \frac{1}{2} \rho v_{\kite, \min}^3 A_{\kite} C_{D_{\sys}}
\end{equation}

\begin{equation}
v_{\wind, \cutin, 0} = \frac{C_{D_{\sys}}}{C_L} \frac{v_{\kite, \min}}{\cos \theta}
\end{equation}

\begin{equation}
  v_{\wind, \cutin} = \left(1 + \frac{P_{\grav}}{\eta_{\airgrid} P_0} \right)
  \frac{C_{D_{\sys}}}{C_L} \frac{v_{\kite, \min}}{\cos \theta}
\end{equation}

\begin{equation}
v_{\wind, T} = \frac{1}{\cos \theta}
\sqrt{\frac{T_{\max} / 3}{\frac{1}{2} \rho A_{\kite} \zeta_{\max}}}
\end{equation}

\begin{equation}
v_{\wind, P} = \frac{P_{\max} + P_{\grav}}{\eta_{\airgrid} T_{\max} \cos \theta} + \frac{2}{3} v_{\wind, T}
\end{equation}

\begin{figure}[h]
\label{fig:real_power_curve}
\begin{center}
\begin{tikzpicture}
  \def\CL{2.1};
  \def\CDsys{0.18};
  \def\costheta{0.866};
  \def\etaairgrid{0.67};
  \def\Tmax{200};  % [kN]
  \def\Pmax{600};  % [kW]
  \def\Pgrav{50};  % [kW]
  \def\zetamax{(4/27 * \CL^3 / \CDsys^2)};
  \def\Ak{32.9};
  \def\rho{1.2};
  \def\vkitemin{30};
  \def\P0{(0.5 * \rho * \Ak * \CDsys * \vkitemin^3 / 1000)};
  \def\vcutin{(\CDsys / \CL * \vkitemin / \costheta)};
  \def\vT{((\Tmax * 1000 / 3 / (0.5 * \rho * \Ak * \zetamax))^0.5 / \costheta)};
  \def\vP{(\Pmax / (\etaairgrid * \Tmax * \costheta) + 2 * \vT / 3)};
  \def\vPtrue{(\vP + \Pgrav / (\etaairgrid * \costheta * \Tmax))};
  \def\vcutintrue{((1 + \Pgrav/(\etaairgrid * \P0)) * \vcutin)};
  \def\loydcoeff{(\etaairgrid * \costheta^3 * 0.5 * \rho * \Ak * \zetamax / 1000)};

\begin{axis}[axis lines=middle, samples=200,
    grid=both,
    grid style={line width=1pt, draw=gray!10},
    x label style={at={(axis description cs:0.5,-0.1)}, anchor=north},
    y label style={at={(axis description cs:-0.1,.5)}, rotate=90, anchor=south},
    xlabel={Wind speed [m/s]},
    ylabel={Power [kW]},
    legend pos=north west]
  \addplot[matlab1, domain=0:(\vcutintrue)] {0};
  %\addplot[matlab2, domain=(\vcutin):(1.5 * \vcutin)] {\etaairgrid * \P0 * (x / \vcutin - 1) - \Pgrav};
  \addplot[matlab3, domain=(\vcutintrue):(\vT)] {\loydcoeff * x^3 - \Pgrav};
  \addplot[matlab4, domain=(\vT):(\vPtrue)] {\etaairgrid * \costheta * \Tmax * (x - 2 * \vT / 3) - \Pgrav};
  \addplot[matlab5, domain=(\vPtrue):(\vPtrue + 2)] {\Pmax};
  \legend{$v_{\wind,\cutin}$, $\zeta_{\max}$, $T_{\max}$, $P_{\max}$};

  \addplot[matlab3, dashed, domain=(1.5 * \vcutin):(\vcutintrue)] {\loydcoeff * x^3 - \Pgrav};
  \addplot[matlab3, dashed, domain=(\vT):(\vT + 2.5)] {\loydcoeff * x^3 - \Pgrav};
  \addplot[matlab2, dashed, domain=2:(1.5 * \vcutin)] {\etaairgrid * \P0 * (x / \vcutin - 1) - \Pgrav};

  \def\costheta{1};
  \def\etaairgrid{1};
  \addplot[gray!50, domain=(\vcutin):(1.5 * \vcutin)] {\etaairgrid * \P0 * (x / \vcutin - 1)};
  \addplot[gray!50, domain=(1.5 * \vcutin):(\vT)] {\loydcoeff * x^3};
  \addplot[gray!50, domain=(\vT):(\vP)] {\etaairgrid * \costheta * \Tmax * (x - 2 * \vT / 3)};
  \addplot[gray!50, domain=(\vP):(\vP + 2)] {\Pmax};

  \def\costheta{1};
  \def\etaairgrid{0.67};
  \addplot[gray!50, dashed, domain=(\vcutin):(1.5 * \vcutin)] {\etaairgrid * \P0 * (x / \vcutin - 1)};
  \addplot[gray!50, dashed, domain=(1.5 * \vcutin):(\vT)] {\loydcoeff * x^3};
  \addplot[gray!50, dashed, domain=(\vT):(\vP)] {\etaairgrid * \costheta * \Tmax * (x - 2 * \vT / 3)};
  \addplot[gray!50, dashed, domain=(\vP):(\vP + 2)] {\Pmax};

  \def\costheta{0.866};
  \def\etaairgrid{0.67};
  \addplot[gray!50, dotted, domain=(\vcutin):(1.5 * \vcutin)] {\etaairgrid * \P0 * (x / \vcutin - 1)};
  \addplot[gray!50, dotted, domain=(1.5 * \vcutin):(\vT)] {\loydcoeff * x^3};
  \addplot[gray!50, dotted, domain=(\vT):(\vP)] {\etaairgrid * \costheta * \Tmax * (x - 2 * \vT / 3)};
%  \addplot[gray!50, dotted, domain=(\vP):(\vP + 2)] {\Pmax};

  \def\costheta{0.866};
  \def\etaairgrid{0.67};
  \draw[gray, dashed] (axis cs:{\vcutintrue}, 25) -- (axis cs:{\vcutintrue}, 150)
  node [above, black] {$v_{\wind,\cutin}$};
  %% \draw[gray, dashed] (axis cs:{1.5 * \vcutin}, 100) -- (axis cs:{1.5 * \vcutin}, 250)
  %% node [above, black] {$v_{\wind,v_{\kite}}$};
  \draw[gray, dashed] (axis cs:{\vT}, {\loydcoeff * \vT^3 - 100}) -- (axis cs:{\vT}, {\loydcoeff * \vT^3 / 2})
  node [below, black] {$v_{\wind,T}$};
  \draw[gray, dashed] (axis cs:{\vPtrue}, 550) -- (axis cs:{\vPtrue}, 450)
  node [below, black] {$v_{\wind,P}$};

\end{axis}
\end{tikzpicture}
\caption{Realistic power curve (colored) versus the ideal power curve
  (solid gray), power curve with conversion losses (dashed gray),
  power curve with conversion and off-downwind losses (dotted gray).
  This particular power curve assumes: $A_{\kite} = 32.9$ m$^2$,
  $v_{\kite,\min} = 30$ m/s, $\zeta_{\max} = 42.3$, $T_{\max} = 200$
  kN, $P_0 = 96$ kW, $P_{\max} = 600$ kW, $\theta = 30^{\circ}$,
  $\eta_{\airgrid} = 0.67$, and $P_{\grav} = 50$ kW.}
\end{center}
\end{figure}

\section{Mean power production}

The utility of a power curve is that it enables the calculation of the
mean power production, $\bar{P}$, at a site with a given wind
distribution.  The mean power production is found by integrating the
power curve weighted by the probability distribution function of the
wind speeds:
%
\begin{equation}
\bar{P} = \int_0^{v_{\wind,\cutout}} dv\, p(v) P(v)
\end{equation}

Assuming a Rayleigh distribution, Eq. \ref{eqn:rayleigh}, for the
distribution of wind speeds, it is possible to derive a closed form
solution for the mean power production of a kite system in terms of
the site's mean wind speed, $\bar{v}$, and the limits of the kite
system.
%
\begin{equation}
\label{eqn:rayleigh}
p(v) = \frac{\pi}{2} \frac{v}{\bar{v}^2} \exp \left(-\frac{\pi}{4} \frac{v^2}{\bar{v}^2} \right)
\end{equation}
%
The mean power is composed of terms from the Loyd-limited, tension
limited, and power limited sections of the power curve.
\begin{equation}
\bar{P} = \bar{P}_{\zeta} + \bar{P}_T + \bar{P}_P - \bar{P}_{\grav}
\end{equation}
%
Ignoring the gravity losses for now, the functional form of each of
these components is:
%
\begin{align}
\bar{P}_{\zeta} =&\;
\eta_{\airgrid} \cdot \frac{1}{2} \rho \zeta_{\max} \cos^3 \theta A \bar{v}^3 \\ \notag
&\times \left[\frac{6}{\pi} \erf \left(\frac{\sqrt{\pi}}{2} \frac{v_{\wind,T}}{\bar{v}}\right) -
\frac{v_{\wind,T}}{\bar{v}} \exp \left(-\frac{\pi}{4}\frac{v_{\wind,T}^2}{\bar{v}^2}\right)
\left(\frac{6}{\pi} + \frac{v_{\wind,T}^2}{\bar{v}^2}\right)
\right]
\end{align}

\begin{align}
\bar{P}_T =&\; \eta_{\airgrid} \cdot T_{\max} \cos \theta \bar{v} \\ \notag
           & \times \bigg[
\erf \left(\frac{\sqrt{\pi}}{2} \frac{v_{\wind,P}}{\bar{v}}\right) -
\erf \left(\frac{\sqrt{\pi}}{2} \frac{v_{\wind,T}}{\bar{v}}\right) \\ \notag
%
& \phantom{\times \bigg[} + \left(\frac{2}{3} \frac{v_{\wind,T}}{\bar{v}} -
\frac{v_{\wind,P}}{\bar{v}}\right)
\exp \left( -\frac{\pi}{4} \frac{v_{\wind,P}^2}{\bar{v}^2} \right) +
\frac{1}{3} \frac{v_{\wind,T}}{\bar{v}}
\exp \left( -\frac{\pi}{4} \frac{v_{\wind,T}^2}{\bar{v}^2} \right) \bigg]
\end{align}

\begin{equation}
\bar{P}_P = P_{\max} \exp \left( -\frac{\pi}{4} \frac{v_{\wind,P}^2}{\bar{v}^2}\right)
\end{equation}

\begin{equation}
  \bar{P}_{\grav} = P_{\grav} \left[
    \exp \left(-\frac{\pi}{4} \frac{v_{\wind,\cutin}^2}{\bar{v}^2} \right) -
    \exp \left(-\frac{\pi}{4} \frac{v_{\wind,P}^2}{\bar{v}^2} \right)
    \right]
\end{equation}

%% \subsection{Cost analysis}

%% In this simplified analysis, we assume some cost per unit power,
%% $c_P$, some cost per unit tension, $c_T$, and some cost per unit kite
%% area, $c_A$.

%% \begin{equation}
%% C = c_P P_{\max} + c_T T_{\max} + c_{\zeta A} \zeta A
%% \end{equation}

\section{Appendix}

\subsection{Gravity power loss}

Here is a sketch of the derivation of the velocity modulation for the
constant drag fraction strategy (see Eq. \ref{eqn:velocity_modulation}).

\begin{equation}
  m \dot v_{\kite} = m g_{\parallel} \cos \psi +
                     \frac{1}{2} \rho v_{\app} A (C_L v_{\wind} - C_D v_{\kite})
\end{equation}

\begin{equation}
  v_{\kite}(t) = v_{\kite, 0} + \delta v_{\kite}(t)
\end{equation}

Assuming $\delta v_{\kite}$ is small:
%
\begin{equation}
  m \delta \dot v_{\kite} = m g_{\parallel} \cos \psi -
                            \frac{1}{2} \rho v_{\kite, 0} C_D A \delta v_{\kite}
\end{equation}

\begin{align}
  \Delta v_{\kite} &= \int_{side}^{top} d \delta v_{\kite} \\
                   &= \int_0^{\pi/2} d\psi \frac{R_{\path}}{v_{\kite, 0}}
                      \left(g_{\parallel} \cos \psi -
                      \frac{1}{2} \rho \frac{v_{\kite, 0}}{m} A C_D \delta v_{\kite} \right)
\end{align}

\begin{equation}
  \frac{\Delta v}{v_{\kite,0}} \approx
  \frac{m g_{\parallel} R_{\path}}
       {m v_{\kite, 0}^2 +
        \frac{1}{2} \rho v_{\kite, 0}^2 A_{\kite} C_D R_{\path}}
\end{equation}

The time it takes to go around the loop is

\begin{equation}
  T_{\lp} = \int_0^{2 \pi} d\psi \frac{R}{v_{\kite,0} + \delta v}
          = \frac{R}{v_{\kite,0}} \int_0^{2 \pi} d\psi \frac{1}{1 + a \sin \psi}
          = \frac{T_{\lp,0}}{\sqrt{1 - a^2}}
\end{equation}
%
where $a = \Delta v / v_{\kite,0}$.

The energy made in a loop is

\begin{align}
  E_{\lp} &= \int_0^{2 \pi} d\psi R \frac{1}{2} \rho v_{\kite}^2 A_{\kite} \eta_{\airgrid} k C_{D_{\sys}} \\
          &= \int_0^{2 \pi} d\psi R \frac{1}{2} \rho v_{\kite,0}^2 (1 + a \sin \psi)^2 A_{\kite} \eta_{\airgrid}k C_{D_{\sys}} \\
          &= \frac{1}{2} \rho v_{\kite,0}^2 R A_{\kite} \eta_{\airgrid} k C_{D_{\sys}} \left(1 + \frac{a^2}{2} \right) 2 \pi
\end{align}

The power loss due to gravity may be found by comparing the $a=0$
power to the expected power.

\begin{align}
  P_{\grav} &= \frac{E_{\lp,0}}{T_{\lp,0}} - \frac{E_{\lp}}{T_{\lp}} \\
            &= P_0 \left( 1 - \sqrt{1 - a^2} - \frac{a^2}{2} \sqrt{1 - a^2} \right)
\end{align}

\end{document}


\documentclass{article}
\usepackage{latexsym}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{graphicx}

\newtheorem{theorem}{Theorem}[section]
\begin{document}
\title{"Fermat's" Two Squares (aka Christmas) Theorem}
\author{Dave Neary}

\maketitle

\section{Fermat's Two Squares Theorem}

The theorem states that an odd prime $p$ can be written as the sum of two squares of
positive integers:
\[ p = a^2 + b^2 , a, b \in \mathbb{N} \]
if and only if it is of the form $4k+1, k\in \mathbb{N}$.

This theorem was stated by Fermat without proof, and it was several decades before a proof
was provided. Since then, several proofs have been discovered, including one which relies
on the characteristics of the Gaussian integers, and another which we can prove using a
very pretty geometry-based involution. I present these two proofs (with dependent tools)
below.

\section{Dedekind's Proof in Gaussian Integers}

\subsection{Gaussian Integers}

The Gaussian integers $\mathbb{Z}[i]$ are complex numbers of the form
\[ \mathbb{Z}[i] = \{a+ib:a,b\in \mathbb{Z}, i=\sqrt{-1}\}\]

The Gaussian integers are closed under the standard multiplication operator
$(a+ib) \times (c+id) = (ac-bd) + i(bc+ad)$, which is commutative (meaning
$z_1 \times z_2 = z_2 \times z_1$), and they have a multiplicative and additive
identity. They are therefore a ring.

By defining a norm function $N(a+bi) = a^2+b^2$, we can also define Euclidean division of
Gaussian integers. That is, for $a,b \in \mathbb{Z}[i]$, there exist $q,r \in \mathbb{Z}[i],
\text{ s.t. } a=qb+r, \text{ with } N(r)<N(b)$. So we can use classic division
algorithms like  the Euclidean algorithm and Bézout's itentity on Gaussian integers. This
characteristic means that $\mathbb{Z}[i]$ is a Euclidean domain, and, as a result, a Unique
Factorization Domain.

What this means is that, given any element $x \in \mathbb{Z}[i]$, we can find a unique
factorization of $x$ in irreducible elements $\{p_i\}$ and a unit $u$ such that:
\[ x = up_1p_2\cdots p_n \text{ with } n\geq 0 \]

In the ring of integers, we call these irreducible elements primes, and in the Gaussian
integers, we will call them Gaussian primes. The Gaussian integers has four units,
$\pm 1, \pm i$.

\subsection{Fermat's Little Theorem}

For the Two Squares theorem, we will be using a sub-ring of the Gaussian integers, the
Gaussian integers $\pmod{p}$ defined as $\{a+ib:a,b\in \mathbb{Z}/p\mathbb{Z}, i=\sqrt{-1}\}$.
Again, this set is closed under multiplication and addition, and we will denote the set
$\mathbb{Z}[i]/(p)$. The notation $(p)$ denotes a prime ideal of the Gaussian integers - the
subset of the Gaussian integers that can be generated from the irreducible element $p$.

We will need some well-known results from modular arithmetic to complete the proof. The first
of these is Fermat's Little Theorem, which states:

\begin{theorem}For every prime $p \in \mathbb{N}$, and $a \in \mathbb{N}$ :
\[ a^p \equiv p \pmod{p} \]
\end{theorem}

\begin{proof}
If $a\equiv 0 \pmod{p}$ then $a^p \equiv 0 = a \pmod{p}$

If $\gcd(a,p)=1$:
\[a \times n \equiv a \times m \pmod{p} \implies a(n-m) \equiv 0 \pmod{p} \]

Since $\gcd(a,p)=1$: $n-m\equiv 0 \pmod{p} \implies n = m \pmod{p}$. Therefore:

\[ \{i: 0 < i < p, i \in \mathbb{N}\} = \{a\times i, 0 < i < p, i \in \mathbb{N} \} \]

That is, the set of the non-zero integers mod $p$ is a derangement of itself when we
multiply each element by any member of the set, so if we multiply all of the elements
together we get the same number. That is:

\[ \prod_{i=1}^{p-1} i \equiv \prod_{i=1}^{p-1} a\times i \]
\[ (p-1)! \equiv a^{p-1}\times (p-1)! \]

And since all numbers in $(p-1)!$ are relatively prime to $p$, we can divide across on both sides to
leave: $1 \equiv a^{p-1}$
\end{proof}

We will use this result to identify a criterion for identifying numbers that can square to a
certain value.

\subsection{Quadratic residues and the Euler criterion}

Fermat's Little Theorem proves that all numbers $\pmod{p}$ have a multiplicative order of at
most $p-1$, but clearly there are numbers with a smaller order. For example, $1^i = 1$ for all
$i$, and $(-1)^i = 1$ for all even $i$.

Quadratic residues in $\mathbb{Z}/p\mathbb{Z}$ are numbers which have a square root in
$\mathbb{Z}/p\mathbb{Z}$. For example, in $\mathbb{Z}/5\mathbb{Z}$, $1^2 \equiv 4^2 \equiv 1
\pmod{5}$, and $2^2 \equiv 3^2 \equiv 4 \pmod{5}$, so $\{1,4\}$ is the set of quadratic residues
$\pmod{5}$. We can show that for a prime $p$, exactly $\frac{p+1}{2}$ of the members of
$\mathbb{Z}/p\mathbb{Z}$ are quadratic residues (including 0), and $\frac{p-1}{2}$ are quadratic
non-residues.

In particular, 1 has two square roots $\pmod{p}: \pm 1$. If we can show that
\[\sqrt{a^{p-1}} = a^{\frac{p-1}{2}} = 1\]
then that implies that there is some number $m \in \mathbb{Z}/p\mathbb{Z}$ such that $m^2 = a$,
since $m^{p-1} = 1$ for all $m \neq 0$. This test for quadratic residues is called Euler's
criterion, and is formally defined for odd primes as:
\[a^{\frac{p-1}{2}} =
\left\{
	\begin{array}{ll}
		1  & \mbox{if there exists } m \in \mathbb{Z}/p\mathbb{Z} \mbox{ such that } m^2 \equiv a \pmod{p} \\
		-1  & \mbox{if } a \mbox{ is a quadratic non-residue in } \mathbb{Z}/p\mathbb{Z} \\
	\end{array}
\right. \]

\subsection{The Two Squares Theorem}

We now have all of the tools we need to prove the Two Squares theorem.

First, it is trivial to prove that no prime of the form $4k+3$ can be written as the sum of two
squares by noticing that $n^2 \equiv 0 \mbox{ or } 1 \pmod{4}$ for all $n\in \mathbb{N}$, so
$a^2+b^2 = 0,1 \mbox{ or } 2 \pmod{4}$, but $p \equiv 3 \pmod{4}$.

Now, for $p=4k+1$, we must show that there exist $a,b \in \mathbb{N}$ such that $p=a^2+b^2$. There
is a second question, regarding the uniqueness of this solution, which we will not prove here.

Note that $(-1)^{\frac{p-1}{2}} = 1$ since $\frac{p-1}{2}=2k$, so -1 is a quadratic
residue $\pmod{p}$. Therefore, there must be an $a \in \mathbb{Z}/p\mathbb{Z}$ such that
$a^2 + 1 \equiv 0 \pmod{p}$. Now, in $\mathbb{Z}[i]/(p)$, we can factor $a^2+1$ into
$(a-i)(a+i)$. Since $N(a+i)=N(a-i)<N(p)$ (since $a < p$), $p$ does not divide either $a+i$ or
$a-i$, and therefore, $p$ is not a prime in $\mathbb{Z}[i]/(p)$, so there exists some Gaussian
prime factorization of $p = (x+iy)(x-iy)$ - giving $p = x^2+y^2$.

I like this proof, because once we know that the Gaussian integers are a UFD, we can use all of
the other tools we get from modular arithmetic to show that $p$ must have non-trivial factors.
However, understanding the proof does require an understanding of modular arithmetic and rings.

\section{Zagier's one sentence proof}

The following proof uses a transformation which appears to come from out of nowhere, but as we
shall see, has a very intuitive geometric explanation. The full statement of the proof is:

Let $p=4k+1$ be prime, let $\mathbb{N}$ denote the natural numbers, and consider the finite set
$S=\{(x,y,z) \in \mathbb{N}^3: x^2+4yz = p\}$ of triples of numbers. Then $S$ has two
involutions: $(x,y,z) \to (x,z,y)$ with fixed points when $y=z$ (corresponding to
$p=x^2+(2y)^2$ a sum of two squares) and the following:
\[ (x,y,z) \to
\left\{
	\begin{array}{ll}
		(x+2z,z,y-x-z)  & \mbox{if } x< y-z \\
		(2y-x,y,x-y+z)  & \mbox{if } y-z < x < 2y \\
		(x-2y,x-y+z,y)  & \mbox{if } x > 2y \\
	\end{array}
\right. \]
which has exactly one fixed point at $(x,y,z) = (1,1,k)$. Two involutions over the same
set must have sets of fixed points of the same parity, and since the second involution
has exactly one fixed point, the first involution must have at least one fixed point, so
$p$ must be expressible as the sum of two squares.

\subsection{Involutions}

The key to this proof is understanding involutions, and their fixed points. An involution
is simply a function which is its own inverse, that is, $x = f(f(x))$. Every involution is
a bijection - that is, every element of the range has an element of the domain that maps
onto it, and every element of the domain maps onto a different element of the range.

As a result, points in a set can have an order of 1 ($f(x)=x$, or $x$ is a fixed point
of $f$) or 2 ($f(x)=y, y(y)=x, x\neq y$) under an involution.

If you have two involutions on the same set, then if there is one fixed point in the first,
that means that the total number of solutions is odd (one fixed points and $k$ pairs of
points of order 2).

Then if there is a second involution, that must also apply to the same odd number of
elements of the set, and as a result, there must be an odd number of fixed points in this second involution too (specifically, at least one fixed point)

But where did that very complicated mapping come from? The time has come to talk about
windmills.

\subsection{Geometric representation of triples $(x,y,z)$}

Let's tease apart the "one-line" proof to see what's going on graphically.

First, let us verify that the involutions actually make sense.

For the members of the set $S=\{(x,y,z):p=x^2+4yz, x, y, z \in \mathbb{N}\}$, since
$p = 4k+1$, and $4yz$ is even, $x$ can be any odd number less than
$\sqrt{p}$. Since we are guaranteed that $x=2a+1$ for $a\in \mathbb{N}_0$, we can be
sure that $p-x^2 = 4k+1 -(4a^2+4a+1) = 4(k-a^2-a)$ is a multiple of 4, with $k>a^2+a$.
$(x,y,z) \in S \implies (x,z,y) \in S$ - so we are guaranteed that the first
transformation is an involution.

For the second transformation, we can consider a triple $(x,y,z)$ as a geometric
arrangement of a square of side $x$, plus four equal rectangles of size $y\times z$
arranged symmetrically around the central square. In the diagram below \ref{fig:windmill1},
we have one mapping for $p=89$ with $(x,y,z)=(5,8,2)$ mapping to $(x,y,z)=(9,2,1)$ under the
mapping $(x,y,z) \to (x+2z,z,y-x-z)$, and the inverse transformation corresponding
to $(x,y,z) \to (x-2y,x-y+z,y)$. The shapes we see for this form are the windmill
forms the proof is known for.

\begin{figure}
	\includegraphics[width=\linewidth, bb=0px 0px 800px 400px]{windmill1.png}
	\caption{Mapping $(5,8,2) \to (9,2,1)$}
	\label{fig:windmill1}
\end{figure}

To show an alternative arrangement, we can swap $y$ and $z$ in the initial arrangement
to get $(x,y,z)=(5,2,8)$, which transforms under the rule $(x,y,z) \to (x-2y, x-y+z, y)$
to $(x,y,z) = (1, 11, 2)$, and transforms under the inverse rule $(x,y,z) \to
(x+2z, z, y-x-z)$ (and note that at each stage, $x^2+4yz = 89$). In this arrangement,
the windmill pattern is clearer.

\begin{figure}
%	\includegraphics[width=\linewidth, bb=0px 0px 1200px 715px]{windmill2.png}
	\includegraphics[width=\linewidth, viewport=0px 0px 1200px 715px]{windmill2.png}
	\caption{Mapping $(5,2,8) \to (1,11,2)$}
	\label{fig:windmill2}
\end{figure}

There are exactly two representations in $(x,y,z)$ for each shape
which is a solution to $p=x^2+4yz$, representing different ways of "wrapping" the
rectangles around the inside square, except for one representation, which is represented
by $(x,y,z) = (1,1,k)$ - this shape is a 1x1 square in the center, and four long and thin
rectangles pointing out at each side. For this configuration, there is no alternative way
to get a larger central square - this is guaranteed to be the only fixed point of the
transformation (since $y-z < x < 2y$, the rule $(x,y,z) \to (2y-x, y, x-y+z)$ is applied).

And going all the way back to our starting point, since we have exactly one fixed point
in this involution, and it is applied to the same set as the alternative involution,
the alternative must also have a fixed point. QED.

\appendix

\section{Using the Euclidean algorithm on $\mathbb{Z}[i]$}

We can find $\gcd(a,b), a,b \in \mathbb{Z}[i]$ using the Euclidean algorithm
as follows (example using $11 + 7i$ and $18 - i$):

\[N(11+7i) = 170, N(18-i)=324 \]

So we start with $18-i$ on the LHS.

\[ \frac{18 - i}{11 + 7i} = \frac{(18 - i)(11 - 7i)}{11^2+7^2} = \frac{205 - 137i}{170} \]

Rounding the real and imaginary parts to the nearest integers, we get

\[ 18 - i = (1 - i)(11 + 7i) + 3i \]

Now we repeat with $11 + 7i, 3i$, noting that $N(3i) = 9$:

\[ \frac{11+7i}{3i} = \frac{(11 + 7i)(-3i)}{9} = \frac{7 -11i}{3} \]
\[ 11 + 7i = (2 - 4i)(3i) +i \]

And the GCD is the unit $i$ (or 1).

\end{document}


\documentclass[../PHYS306Notes.tex]{subfiles}

\begin{document}
\section{Lecture 20}
\subsection{Lecture Notes - Free Rotation of Spinning Top \& Euler Angles}
\subsubsection{Euler Equations Review}
\begin{center}
    \includegraphics[scale=0.5]{Lecture-20/l20-img1.png}
\end{center}
A rotating dumbbell consists of two masses $m$ which move in circles at a $z$ displacement $l$ and $-l$, joined by a massless rod. The angular velocity vector is $\bm{\omega} = \omega\zhat$. Consider the body frame where the positions of the masses are $(0, a, l)$ and $(0, -a, -l)$. What are the principle axes of inertia?
\begin{center}
    \includegraphics[scale=0.5]{Lecture-20/l20-img2.png}
\end{center}
\begin{s}
A). The principle axes of inertia are aligned with the symmetries of the body. If there is a symmetry axes, we can expect this to correspond to a principle axis.
\end{s}
\begin{center}
    \includegraphics[scale=0.5]{Lecture-20/l20-img3.png}
\end{center}
Followup: What is the components of the angular velocity vector in this frame? (where $\theta$ is the angle formed by the z-axis/rotation axis and the mass?)
\begin{s}
$\bm{\omega} = \m{\omega\cos\theta \\ \omega\sin\theta \\ 0}$ by trigonometry.
\end{s}
Consider the body frame aligned with the principle axes of inertia (as sketched). What are Euler's equations in this frame?
\begin{s}
We first recall the three moments of inertia:
\[\lambda_1 = 0\]
\[\lambda_2 = 2m(a^2 + l^2)\]
\[\lambda_3 = 2m(a^2 + l^2)\]
We also recall the Euler equations:
\[\Gamma_1 = \lambda_1\dot{\omega}_1 - (\lambda_2 - \lambda_3)\omega_2\omega_3\]
\[\Gamma_2 = \lambda_2\dot{\omega}_2 - (\lambda_3 - \lambda_1)\omega_1\omega_3\]
\[\Gamma_3 = \lambda_3\dot{\omega}_3 - (\lambda_1 - \lambda_2)\omega_1\omega_2\]
In this case, we have that $\omega_3$ along $\v{v}_3$ is zero (from the previous problem) and that the time derivatives of all of the $\omega_i$s are zero (as the dumbell rotates at constant velocity. From this we get:
\[\Gamma_1 = 0\]
\[\Gamma_2 = 0\]
\[\Gamma3 = 2m(a^2 + l^2)\omega^2\sin\theta\cos\theta\]
\end{s}
Cosnider the body frame aligned with the principle axes of inertia.  In this frame, the torque is constant in the 3 directions (out of the page). How can you describe the torque in the space frame?
\begin{s}
Since $\v{L}$ is rotating and $\bm{\Gamma}$ is perpendicular to this and rotating with it (in the lab frame), we therefore have that $\abs{\bm{\Gamma}}$ is constant and it is rotating about the z axis.
\end{s}
What is the angular momentum in the body frame?
\begin{s}
$\v{L} = \II\bm{\omega}$, and since $\II$ is diagonal in the body frame, we have:
\[\v{L} = \II\bm{\omega} = \m{0 & 0 & 0 \\ 0 & 2m(a^2+l^2) & 0 \\ 0 & 0 & 2m(a^2 + l^2)}\m{\omega\cos\theta \\ \omega\sin\theta \\ 0} = \m{0 \\ 2m(a^2+l^2)\omega\sin\theta \\ 0}\]
\end{s}

\subsubsection{Free Rotation of symmetric top}
Here, we study the motion of a symmetric top. This means that $\lambda_1 = \lambda_2$. In addition, no torque, so $\bm{\Gamma} = \v{0}$. Writing down the Euler equations (where the LHS will be zero), we then have:
\[0 = \lambda_1\dot{\omega}_1 - (\lambda_2 - \lambda_3)\omega_2\omega_3\]
\[0 = \lambda_2\dot{\omega}_2 - (\lambda_3 - \lambda_1)\omega_1\omega_3\]
\[0 = \lambda_3\dot{\omega}_3 - (\lambda_1 - \lambda_2)\omega_1\omega_2\]
Since $\lambda_1 - \lambda_2 = 0$, we therefore find that $\dot{\omega}_3 = 0$ and hence $\omega_3$ is constant (as lines up with our experience. Writing the other equations down (making the substitution that $\lambda_2 = \lambda_1$, we have:
\[\dot{\omega}_1 = \frac{\lambda_1 - \lambda_3}{\lambda_1}\omega_2\omega_3\]
\[\dot{\omega}_2 = -\frac{\lambda_1 - \lambda_3}{\lambda_1}\omega_1\omega_3\]
Let us define $\Omega_b = \frac{\lambda_1 - \lambda_3}{\lambda_1}\omega_3$, then we have:
\[\dot{\omega}_1 = \Omega_b\omega_2\]
\[\dot{\omega}_2 = -\Omega_b\omega1\]
Let us add $i$ times the second equation to the first equation. Then, define $\eta = \omega_1 + i\omega_2$. We then have:
\[\dot{\omega}_1 + i\dot{\omega}_2 = \dot{\eta} = \Omega_b(\omega_2 - i\omega_1) = -i\Omega_b\eta\]
This has a complex exponential solution:
\[\eta(t) = \eta_0\exp(-i\Omega_b t)\]
Suppose $\eta_0 = \omega_0$. then:
\[\eta(t) = \omega_0\exp(-i\Omega_b t)\]
Takign the real and imaginary parts to recover $\omega_1$ and $\omega_2$, we get:
\[\bm{\omega} = \m{\omega_0\cos(\Omega_b t) \\ -\omega_0\sin(\Omega_b t) \\ \omega_3}\]
From which we can see tha the free top undergoes precession. We can check that $\dot{bm{\omega}} = \bm{\Omega}_b \times \bm{\omega}$ which would indeed correspond to rotation. We note that $\abs{\bm{\omega}}$ is a constant here. Visually, we could think of these as follows:
\begin{center}
    \includegraphics[scale=0.5]{Lecture-20/l20-img4.png}
    \includegraphics[scale=0.5]{Lecture-20/l20-img5.png}
    \includegraphics[scale=0.5]{Lecture-20/l20-img6.png}
\end{center}

\subsubsection{Rotation Matrices}
We need to establish a more systematic way to go from body to lab frame (i.e. rotating the coordinate system).
\begin{center}
    \includegraphics[scale=0.5]{Lecture-20/l20-img7.png}
\end{center}
These rotations are performed through rotation matrices. The first picture is a rotation around the z axis. The matrix that does this is
\[R_z = \m{\cos\theta & \sin\theta & 0 \\ -\sin\theta & \cos\theta & 0 \\ 0 & 0 & 1}\]
The second picture is a rotation around the y axis. The matrix that does this is:
\[R_y = \m{\cos\theta & 0 & -\sin\theta \\ 0 & 1 & 0 \\ \sin\theta & 0 & \cos\theta}\]
Where the minus sign is switched in order to preserve the handedness of the coordinate system. X is the same, with:
\[R_x = \m{1 & 0 & 0 \\ 0 & \cos\theta & \sin\theta \\ 0 & -\sin\theta & \cos\theta}\]
In general, to go from one coordinate system to another, we can decompose the rotations into rotations about x, y, and z. But note that the \textbf{order matters}! This brings us to discussion of Euler angles.

\subsubsection{Euler Angles}
The Euler angles gives us a convention for the order of rotations.
\begin{center}
    \includegraphics[scale=0.5]{Lecture-20/l20-img8.png}
\end{center}
\begin{enumerate}[1.]
\item First, we rotate around the z-axis by $\phi$.
\item Next, we rotate around the \textbf{new} y axis by $\theta$
\item Finally, we rotate around the \textbf{new} z-axis by $\psi$.
\end{enumerate}
Next day: A general Lagrangian for rigid systems, and then applying this to a spinning top with Torque applied to it. Then, we get into Hamiltonian mechanics!
\end{document}