% !TeX root = constructions.tex

\part{Origami}\label{p.origami}

\chapter{Axioms}\label{c.axioms}

Each axiom states that a \emph{fold} exists that will place given points and lines onto points and lines, such that certain properties hold. The term fold comes from the origami operation of folding a piece of paper, but here it is used to refer to the geometric line that would be created by folding the paper.

The axioms are called the \emph{Huzita-Hatori axioms} \cite{wiki:hh}, although their final form resulted from the work of several mathematicians. Lee \cite[Chapter~4]{hwa} is a good overview of the mathematics of origami, while Martin \cite[Chapter~10]{martin} is a formal development. The reader should be aware that, \emph{by definition}, folds result in \emph{reflections}. Given a point $p$, its reflection around a fold $l$ results in a point $p'$, such that $l$ is the perpendicular bisector of the line segment $\overline{pp'}$:

\medskip

\begin{center}
\begin{tikzpicture}[scale=1.3]
\coordinate (P1) at (2,2);
\coordinate (P1P) at (6,4);
\coordinate (mid) at (4,3);
\draw[rotate=30] (mid) rectangle +(8pt,8pt);
\coordinate (m1) at ($(P1)!.5!(mid)$);
\coordinate (m2) at ($(mid)!.5!(P1P)$);
\draw[thick] (m1) -- +(120:4pt);
\draw[thick] (m1) -- +(-60:4pt);
\draw[thick] (m2) -- +(120:4pt);
\draw[thick] (m2) -- +(-60:4pt);
\draw[thick] (P1) -- (P1P);
\draw[very thick,dashed] (4.7,1.6) -- node[very near end,right,yshift=4pt] {$l$} (3.5,4);
\fill (P1) circle(1.2pt) node[above left] {$p$};
\fill (P1P) circle(1.2pt) node[above left] {$p'$};
\fill (mid) circle(1.2pt);% node[below,xshift=-2pt,yshift=-8pt] {$p_i$};
\draw[very thick,dotted,->,bend right=50] (2,1.8) to (6,3.8);
\end{tikzpicture}
\end{center}

\medskip

In the diagrams, given lines are solid, folds are dashed, auxiliary lines are dotted, and dotted arrows indicate the direction of folding the paper.

\newpage

\section{Axiom 1}\label{s.ax1}

\textbf{Axiom}
Given two distinct points $p_1=(x_1,y_1)$, $p_2=(x_2,y_2)$, there is a unique fold $l$ that passes through both of them.

%\begin{figure}[H]
\begin{center}
\begin{tikzpicture}[scale=1.2]
\draw[step=10mm,white!50!black,thin] (-1,-1) grid (8,6);
\draw[thick] (-1,0) -- (8,0);
\draw[thick] (0,-1) -- (0,6);
\foreach \x in {0,...,8}
  \node at (\x-.2,-.2) {\sm{\x}};
\foreach \y in {1,...,6}
  \node at (-.2,\y-.3) {\sm{\y}};
\coordinate (P1) at (2,2);
\coordinate (P2) at (6,4);
\draw[very thick,dashed] ($(P1)!-.75!(P2)$) -- node[very near end,below] {$l$} ($(P1)!1.5!(P2)$);
\fill (P1) circle(2pt) node[above left] {$p_1$};
\fill (P2) circle(2pt) node[above left] {$p_2$};

\draw[very thick,dotted,->,bend left=30] (2,5) to (4,1);
\end{tikzpicture}
\end{center}
%\end{figure}

\textbf{Derivation of the equation of the fold}

The equation of fold $l$ is derived from the coordinates of $p_1$ and $p_2$: the slope is the quotient of the differences of the coordinates and the $y$-intercept is derived from $p_1$:
\begin{equation}
y - y_1 = \disfrac{y_2-y_1}{x_2-x_1}(x-x_1)\,.
\end{equation}

\vspace*{-3ex}
%\newpage

\textbf{Example}

Let  $p_1=(2,2), p_2=(6,4)$. The equation of $l$ is:
\begin{form}{1.4}
y-2&=&\disfrac{4-2}{6-2}(x-2)\\
y&=&\disfrac{1}{2}x+1\,.
\end{form}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newpage

\section{Axiom 2}\label{s.ax2}

\textbf{Axiom}
Given two distinct points $p_1=(x_1,y_1)$, $p_2=(x_2,y_2)$, there is a unique fold $l$ that places $p_1$ onto $p_2$.

%\begin{figure}[H]
\begin{center}
\begin{tikzpicture}[scale=1.2]
\draw[step=10mm,white!50!black,thin] (-1,-1) grid (8,6);
\draw[thick] (-1,0) -- (8,0);
\draw[thick] (0,-1) -- (0,6);
\foreach \x in {0,...,8}
  \node at (\x-.2,-.2) {\sm{\x}};
\foreach \y in {1,...,6}
  \node at (-.2,\y-.3) {\sm{\y}};
\coordinate (P1) at (2,2);
\coordinate (P2) at (6,4);
\coordinate (mid1) at ($(P1)!.5!(P2)$);
\coordinate (mid2) at ($(P1)!.5!(P2)+(-1,2)$);

\draw[rotate=29] (mid1) rectangle +(8pt,8pt);

\draw[very thick,dotted] (P1) -- (P2);
\draw[very thick,dashed] ($(mid1)!-1.6!(mid2)$) --
  node[very near end,left,yshift=-12pt] {$l$} ($(mid1)!1.4!(mid2)$);
\fill (P1) circle(2pt) node[above left] {$p_1$};
\fill (P2) circle(2pt) node[above left] {$p_2$};

\draw[very thick,dotted,->,bend right=50] (2,1.8) to (6,3.8);
\end{tikzpicture}
\end{center}
%\end{figure}

\textbf{Derivation of the equation of the fold}

The fold $l$ is the perpendicular bisector of $\overline{p_1p_2}$. Its slope is the negative reciprocal of the slope of the line connecting $p_1$ and $p_2$. $l$ passes through the midpoint between the points:
\begin{equation}
y - \disfrac{y_1+y_2}{2} = -\disfrac{x_2-x_1}{y_2-y_1}\left(x-\disfrac{x_1+x_2}{2}\right)\,.\label{eq.midpoint1}
\end{equation}

\textbf{Example}

Let $p_1=(2,2), p_2=(6,4)$. The equation of $l$ is:
\begin{form}{1.4}
y-\left(\disfrac{2+4}{2}\right)&=&-\disfrac{6-2}{4-2}\left(x-\left(\disfrac{2+6}{2}\right)\right)\\
y&=&-2x+11\,.
\end{form}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newpage

\section{Axiom 3}\label{s.ax3}

\textbf{Axiom}
Given two lines $l_1$ and $l_2$, there is a fold $l$ that places $l_1$ onto $l_2$.

%\begin{figure}[H]
\begin{center}
\begin{tikzpicture}[scale=1.2]
\draw[step=10mm,white!50!black,thin] (-1,-1) grid (8,7);
\draw[thick] (-1,0) -- (8,0);
\draw[thick] (0,-1) -- (0,7);
\foreach \x in {0,...,8}
  \node at (\x-.2,-.2) {\sm{\x}};
\foreach \y in {1,...,7}
  \node at (-.2,\y-.3) {\sm{\y}};
\coordinate (L1a) at (2,2);
\coordinate (L1b) at (4,6);
\draw[very thick] (L1a) --
  node[very near start,right,yshift=-4pt] {$l_1$} (L1b);
\draw[thick,dotted,name path=l1] ($(L1a)!-.75!(L1b)$) --
  ($(L1a)!1.25!(L1b)$);
\coordinate (L2a) at (7,1);
\coordinate (L2b) at (4,4);
\draw[very thick] (L2a) -- (L2b);
\draw[thick,dotted,name path=l2] ($(L2a)!-.3!(L2b)$) --
  node[very near start,above,xshift=-6pt,yshift=8pt] {$l_2$}
  ($(L2a)!2!(L2b)$);
\path [name intersections = {of = l1 and l2, by = {PM}}];
\fill (PM) circle(2pt) node[below left,xshift=-9pt,yshift=-7pt] {$p_i$};

\node[above right,xshift=10pt,yshift=4pt] at (PM) {$\alpha$};
\node[below right,xshift=10pt] at (PM) {$\alpha$};
\node[above left,xshift=-3pt,yshift=12pt] at (PM) {$\beta$};
\node[above right,xshift=-3pt,yshift=12pt] at (PM) {$\beta$};

\coordinate (B1a) at (0,4.13);
\coordinate (B1b) at (6,5.1);
\draw[very thick,dashed] ($(B1a)!-.15!(B1b)$) -- node[very near start,above] {$l_{f_1}$}  ($(B1a)!1.35!(B1b)$);

\coordinate (B2a) at (3,6.73);
\coordinate (B2b) at (4,.57);
\draw[very thick,dashed] ($(B2a)!-.05!(B2b)$) --
  node[very near end,right,xshift=4pt,yshift=6pt] {$l_{f_2}$}
  ($(B2a)!1.25!(B2b)$);

\draw[very thick,dotted,->,bend right=50] (6,2.2) to (4.5,6.7);
\draw[very thick,dotted,->,bend left=50] (6.2,1.6) to (1.8,1.3);
\end{tikzpicture}
\end{center}
%\end{figure}

If the lines are parallel, let $l_1$ be $y=mx+b_1$ and let $l_2$ be $y=mx+b_2$. The fold is the line parallel to $l_1,l_2$ and halfway between them $y=mx+\disfrac{b_1+b_2}{2}$.

If the lines intersect, let $l_1$ be $y=m_1x+b_1$ and let $l_2$ be $y=m_2x+b_2$.

\textbf{Derivation of the point of intersection}

$p_i=(x_i,y_i)$, the point of intersection of the two lines, is:
\vspace{-2ex}
\begin{form}{1.3}
m_1x_i+b_2&=&m_2x_i+b_2\\
x_i &=& \disfrac{b_2-b_1}{m_1-m_2}\\
y_i &=&m_1x_i+b_1\,.
\end{form}
\vspace{-2ex}

\textbf{Example}

Let $l_1$ be $y=2x-2$ and let $l_2$ be $y=-x+8$. The point of intersection is:
\begin{form}{1.4}
x_i&=&\disfrac{8-(-2)}{2-(-1)}=\disfrac{10}{3}\\
y_i &=& 2\cdot\disfrac{10}{3}-2=\disfrac{14}{3}\,.
\end{form}

\textbf{Derivation of the equation of the slope of the angle bisector}

The two lines form an angle at their point of intersection, actually, two pairs of vertical angles. The folds are the bisectors of these angles.

If the angle of line $l_1$ relative to the $x$-axis is $\theta_1$ and the angle of line $l_2$ relative to the $x$-axis is $\theta_2$, then the fold is the line which makes an angle of $\theta_b=\disfrac{\theta_1+\theta_2}{2}$ with the $x$-axis.

$\tan\theta_1=m_1$ and $\tan\theta_2=m_2$ are given so $m_b$, the slope of the angle bisector, is:
\[
m_b=\tan\theta_b=\tan\disfrac{\theta_1+\theta_2}{2}\,.
\]
The derivation requires the use of two trigonometric identities that we derive here:
\vspace{-2ex}
\begin{form}{1.4}
\tan (\theta_1+\theta_2) &=& \disfrac{\sin(\theta_1+\theta_2)}{\cos(\theta_1+\theta_2)}\\
&=&\disfrac{\sin\theta_1\cos\theta_2+\cos\theta_1\sin\theta_2}{\cos\theta_1\cos\theta_2-\sin\theta_1\sin\theta_2}\\
&=&\disfrac{\sin\theta_1+\cos\theta_1\tan\theta_2}{\cos\theta_1-\sin\theta_1\tan\theta_2}\\
&=&\disfrac{\tan\theta_1+\tan\theta_2}{1-\tan\theta_1\tan\theta_2}\,.
\end{form}

We use this formula to obtain a quadratic equation in $\tan(\theta/2)$:
\vspace{-3ex}
\begin{form}{1.4}
\tan \theta=\disfrac{\tan(\theta/2)+\tan(\theta/2)}{1-\tan^2(\theta/2)}\\
\tan\theta \,(\tan(\theta/2))^2 \;+\; 2\,(\tan (\theta/2)) \;-\;\tan \theta = 0\,,
\end{form}
whose solutions are:
\[
\tan(\theta/2) = \disfrac{-1\pm\sqrt{1+\tan^2\theta}}{\tan\theta}\,.
\]
First derive $m_s$, the slope of $\theta_1+\theta_2$:
\[
m_s=\tan(\theta_1+\theta_2)= \disfrac{m_1+m_2}{1-m_1m_2}\,.
\]
Then derive $m_b$, the slope of the angle bisector:
\vspace{-2ex}
\begin{form}{1.4}
m_b&=& \tan\disfrac{\theta_1+\theta_2}{2}\\
&=&\disfrac{-1\pm\sqrt{1+\tan^2(\theta_1+\theta_2)}}{\tan (\theta_1+\theta_2)}\\
&=&\disfrac{-1\pm\sqrt{1+m_s^2}}{m_s}\,.
\end{form}
\textbf{Example}

For the lines $y=2x-2$ and $y=-x+8$, the slope of the angle bisector is:
\begin{form}{1.4}
m_s=\disfrac{2+(-1)}{1-(2 \cdot -1)}=\disfrac{1}{3}\\
m_b=\disfrac{-1\pm\sqrt{1+(1/3)^2}}{1/3}=-3\pm \sqrt{10}\,.
\end{form}

\textbf{Derivation of the equation of the fold}

Let us derive equation of the fold $l_{f_1}$ with the positive slope; we know the coordinates of the intersection of the two lines $m_i=\left(\disfrac{10}{3},\disfrac{14}{3}\right)$:
\begin{form}{1.3}
\disfrac{14}{3} &=& (-3+\sqrt{10}) \cdot \disfrac{10}{3} + b\\ b&=&\disfrac{44-10\sqrt{10}}{3}\\
y&=& (-3+\sqrt{10})x + \disfrac{44-10\sqrt{10}}{3}\approx 0.162x+4.13\,.
\end{form}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newpage

\section{Axiom 4}\label{s.ax4}

\textbf{Axiom}
Given a point $p_1$ and a line $l_1$, there is a unique fold $l$ perpendicular to $l_1$ that passes through point $p_1$.
%\begin{figure}[H]
\begin{center}
\begin{tikzpicture}[scale=1.2]
\draw[step=10mm,white!50!black,thin] (-1,-1) grid (8,7);
\draw[thick] (-1,0) -- (8,0);
\draw[thick] (0,-1) -- (0,7);
\foreach \x in {0,...,8}
  \node at (\x-.2,-.2) {\sm{\x}};
\foreach \y in {1,...,7}
  \node at (-.2,\y-.3) {\sm{\y}};
\coordinate (L1a) at (2,0);
\coordinate (L1b) at (5,6);
\draw[thick] (L1a) -- node[very near start,right,yshift=-4pt] {$l_1$} ($(L1a)!1.15!(L1b)$);
\fill (2,6) circle (2pt) node[above right] {$p_1$};
\draw[thick,dashed] (0,7) -- node[very near end,above right] {$l$} (8,3);
\coordinate (intersection) at (4.4,4.8);
\draw[rotate=-30] (intersection) rectangle +(8pt,8pt);

\draw[very thick,dotted,->,bend left=50] (5.4,6.3) to (3.7,3);
\end{tikzpicture}
\end{center}
%\end{figure}

\textbf{Derivation of the equation of the fold}

Let $l_1$ be $y = m_1x + b_1$ and let $p_1=(x_1,y_1)$.  $l$ is perpendicular to $l_1$ so its slope is $-\disfrac{1}{m_1}$. Since it passes through $p_1$, we can compute the intercept $b$ and write down its equation:
\vspace{-2ex}
\begin{form}{1.4}
y_1=-\disfrac{1}{m} x_1 + b\\
b= \disfrac{(my_1+x_1)}{m}\\
y=-\disfrac{1}{m} x +\disfrac{(my_1+x_1)}{m}\,.
\end{form}
\textbf{Example}

Let $p_1=(2,6)$ and let $l_1$ be $y=2x-4$. The equation of the fold $l$ is:
\[
y=-\disfrac{1}{2}x + \disfrac{2\cdot 6 + 2}{2}=-\disfrac{1}{2}x + 7\,.
\]

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newpage

\section{Axiom 5}\label{s.ax5}

\textbf{Axiom}
Given two points $p_1,p_2$ and a line $l_1$, there is a fold $l$ that places $p_1$ onto $l_1$ and passes through $p_2$.

%\begin{figure}[H]
\begin{center}
\begin{tikzpicture}[scale=1.1]
\draw[step=10mm,white!50!black,thin] (-1,-1) grid (9,9);
\draw[thick] (-1,0) -- (9,0);
\draw[thick] (0,-1) -- (0,9);
\foreach \x in {0,...,9}
  \node at (\x-.2,-.2) {\sm{\x}};
\foreach \y in {1,...,9}
  \node at (-.2,\y-.3) {\sm{\y}};
\coordinate (L1a) at (0,3);
\coordinate (L1b) at (8,-1);
\draw[thick] (L1a) -- node[near end,below right,xshift=8pt,yshift=-8pt] {$l_1$} (L1b);
\coordinate (P1) at (2,8);
\fill (P1) circle (2pt) node[above left] {$p_1$};
\coordinate (P2) at (4,4);
\fill (P2) circle (2pt) node[above left,yshift=4pt] {$p_2$};
\draw[thick,dotted,name path=L1] (8,-1) -- (-1,3.5);
\node[very thick,dotted,draw, name path = circle] at (P2)
    [circle through = (P1)] {};

\path [name intersections = {of = circle and L1, by = {P1P,P1PP}}];
\fill (P1P) circle (2pt) node[above left,xshift=-2pt,yshift=4pt] {$p_1'$};
\fill (P1PP) circle (2pt) node[above left,yshift=6pt] {$p_1''$};

\coordinate (f1) at (0,6);
\draw[thick,dashed] ($(f1)!-.25!(P2)$) -- node[very near end,above] {$l_{f_2}$} ($(f1)!2.25!(P2)$);
\coordinate (f2) at (0,2);
\draw[thick,dashed] ($(f2)!-.25!(P2)$) -- node[very near end,below,yshift=-2pt] {$l_{f_1}$} ($(f2)!2.25!(P2)$);

\draw[very thick,dotted,->,bend left=50] (2.2,7.8) to (-.2,3.2);
\draw[very thick,dotted,->,bend left=50] (2.4,7.85) to (6.1,.2);
\end{tikzpicture}
\end{center}
%\end{figure}

For a given pair of points and a line, there may be zero, one or two folds.

\textbf{Derivation of the equations of the reflections}

Let $l$ be a fold through $p_2$ and $p_1'$ be the reflection of $p_1$ around $l$. The length of $\overline{p_1p_2}$ equals the length of $\overline{p_1'p_2}$. The locus of points at distance $\overline{p_1p_2}$ \emph{from} $p_2$ is the circle centered at $p_2$ whose radius is the length of $\overline{p_1p_2}$. The intersections of this circle with the line $l_1$ give the possible points $p_1'$.

Let $l_1$ be $y=m_1x + b_1$ and let $p_1=(x_1,y_1)$, $p_2=(x_2,y_2)$. The equation of the circle centered at $p_2$ with radius the length of $\overline{p_1p_2}$ is:
\vspace{-2ex}
\begin{form}{1.2}
(x-x_2)^2 + (y-y_2)^2 = r^2\,,\quad \textrm{where}\\
r^2= (x_2-x_1)^2 + (y_2-y_1)^2\,.
\end{form}
Substituting the equation of the line into the equation for the circle:
\[
(x-x_2)^2+((m_1x+b_1)-y_2)^2=(x-x_2)^2+(m_1x+(b_1-y_2))^2=r^2\,,
\]
we obtain a quadratic equation for the $x$-coordinates of the possible intersections:
\begin{equation}
x^2(1+m_1^2) \,+\, 2(-x_2+m_1b-m_1y_2)x \,+\, (x_2^2 + (b_1^2 - 2b_1y_2+y_2^2)-r^2)=0\,.\label{eq.intersections}
\end{equation}
The quadratic equation has at most two solutions $x_1',x_1''$ and we can compute $y_1',y_1'')$ from $y=m_1x+b_1$. The reflected points are $p_1'=(x_1',y_1')$, $p_1''=(x_1'',y_1'')$.

\textbf{Example}

Let $p_1=(2,8)$, $p_2=(4,4)$ and let $l_1$ be $y=-\disfrac{1}{2}x +3$. The equation of the circle is:
\[
(x-4)^2 + (y-4)^2 = r^2=(4-2)^2+(4-8)^2=20\,.
\]
Substitute the equation of the line into the equation of the circle and simplify to obtain a quadratic equation for the $x$-coordinates of the intersections (or use Equation~\ref{eq.intersections}):
\vspace{-2ex}
\begin{form}{1.4}
(x-4)^2 + \left(\left(-\disfrac{1}{2}x+3\right)-4\right)^2&=&20\\
%\disfrac{5}{4}x^2-7x-3 &=&0\\
5x^2 -28x -12&=&0\\
(5x+2)(x-6)&=&0\,.
\end{form}
The two points of intersection are:
\[
p_1'=\left(-\disfrac{2}{5},\disfrac{16}{5}\right) = (-0.4,3.2)\,,\quad\quad p_1''=(6,0)\,.
\]

\textbf{Derivation of the equations of the folds}

The folds will be the perpendicular bisectors of $\overline{p_1p_1'}$ and $\overline{p_1p_1''}$. The equation of a perpendicular bisector is given by Equation~\ref{eq.midpoint1}, repeated here with for $p_1'$:
\begin{equation}
y - \disfrac{y_1+y_1'}{2} = -\disfrac{x_1'-x_1}{y_1'-y_1}\left(x-\disfrac{x_1+x_1'}{2}\right)\,.\label{eq.midpoint2}
\end{equation}

\textbf{Example}

For $p_1=(2,8)$ and $p_1'=\left(-\disfrac{2}{5},\disfrac{16}{5}\right)$, the equation of the fold $l_{f_1}$  is:
\vspace{-2ex}
\begin{form}{1.4}
y-\disfrac{8+(16/5)}{2}&=&-\disfrac{(-2/5)-2}{(16/5)-8}\left(x-\disfrac{2+\left(-2/5\right)}{2}\right)\\
y&=&-\disfrac{1}{2}x+6\,.
\end{form}

For $p_1=(2,8)$ and $p_1''=(6,0)$, the equation of the fold $l_{f_2}$ is:
\vspace{-2ex}
\begin{form}{1.4}
y-\disfrac{8+0}{2}&=&-\disfrac{6-2}{0-8}\left(x-\disfrac{2+6}{2}\right)\\
y&=&\disfrac{1}{2}x+2\,.
\end{form}

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

\newpage

\section{Axiom 6}\label{s.ax6}

\textbf{Axiom}
Given two points $p_1$ and $p_2$ and two lines $l_1$ and $l_2$, there is a fold $l$ that places $p_1$ onto $l_1$ and $p_2$ onto $l_2$.

%\begin{figure}[H]
\begin{center}
\begin{tikzpicture}[scale=.9]
\draw[step=10mm,white!50!black,thin] (-7,-7) grid (7,5);
\draw[thick] (-7,0) -- (7,0);
\draw[thick] (0,-7) -- (0,5);
\foreach \x in {-6,...,7}
  \node at (\x-.3,-.2) {\sm{\x}};
\foreach \y in {1,...,5}
  \node at (-.2,\y-.3) {\sm{\y}};
\foreach \y in {-6,...,-1}
  \node at (-.3,\y-.3) {\sm{\y}};

\coordinate (P1) at (0,4);
\fill (P1) circle (3pt) node[above left,xshift=-2pt] {$p_1$};
\coordinate (P2) at (0,-6);
\fill (P2) circle (3pt) node[above left,xshift=-2pt,yshift=2pt] {$p_2$};

\coordinate (P1P) at (3.1,2);
\fill (P1P) circle (3pt) node[above right,xshift=-2pt] {$p_1'$};
\coordinate (P2P) at (-6.12,-2);
\fill (P2P) circle (3pt) node[below right,xshift=2pt] {$p_2'$};

\coordinate (P1PP) at (-3.1,2);
\fill (P1PP) circle (3pt) node[above right,xshift=-2pt] {$p_1''$};
\coordinate (P2PP) at (6.12,-2);
\fill (P2PP) circle (3pt) node[below right,xshift=2pt] {$p_2''$};

\draw[very thick] (-7,2) -- node[very near start,above,xshift=-34pt] {$l_1$} (7,2);
\draw[very thick] (-7,-2) -- node[very near start,below,xshift=-34pt] {$l_2$} (7,-2);

\draw[domain=-4.8:4.8,samples=50,very thick,dotted] plot (\x,{-.13*\x*\x-4});
\draw[domain=-2.8:2.8,samples=50,very thick,dotted] plot (\x,{.25*\x*\x+3});

\draw[very thick,dashed] (-5,-7) -- (2.95,5);
\draw[very thick,dashed] (-3,5) -- (4.95,-7);

\draw[very thick,dotted,->,bend left=50] (.2,4.1) to (3,2.2);
\draw[very thick,dotted,->,bend left=50] (-.3,-6.1) to (-6.1,-2.2);

\draw[very thick,dotted,->,bend right=50] (-.2,4.1) to (-3,2.2);
\draw[very thick,dotted,->,bend right=50] (.3,-6.1) to (6.1,-2.2);
\end{tikzpicture}
\end{center}
%\end{figure}

For a given pair of points and pair of lines, there may be zero, one, two or three folds.

If a fold places $p_i$ onto $l_i$, the distance from $p_i$ to the fold is equal to the distance from $l_i$ to the fold. The locus of points that are equidistant from a point $p_i$ and a line $l_i$ is a parabola with focus $p_i$ and directrix $l_i$. A fold is any line tangent to that parabola. A detailed justification of this claim is given below.

For a fold to simultaneously place $p_1$ onto $l_1$ and $p_2$ onto $l_2$, it must be a tangent common to the two parabolas.

The formula for an arbitrary parabola is quite complex, so we limit the presentation to parabolas with the the $y$-axis as the axis of symmetry. This is not a significant limitation because for any parabola there is a rigid motion that moves the parabola so that its axis of symmetry is the $y$-axis. An example will also be given where one of the parabolas has the $x$-axis as its axis of symmetry.

\newpage

\textbf{Derivation of the equation a fold}

Let $(0,f)$ be the focus of a parabola with directrix $y=d$. Define $p=f-d$, the signed length of the line segment between the focus and the directrix.\footnote{We have been using the notation $p_i$ for points; the use of $p$ here might be confusing but it is the standard notation. The formal name for $p$ is one-half the \emph{latus rectum}.} If the vertex of the parabola is on the $x$-axis, the equation of the parabola is $y=\disfrac{x^2}{2p}$. To move the parabola up or down the $y$-axis so that its vertex is at $(0,h)$, add $h$ to the equation of the parabola: $y=\disfrac{x^2}{2p}+h$.
\begin{center}
\begin{tikzpicture}
\draw (-6,0) --
  node[very near start,below,xshift=-32pt] {$x$-\textsf{axis}} (6,0);
\draw (0,-3) --
  node[very near start,right,yshift=-20pt] {$y$-\textsf{axis}} (0,4.5);
\draw[very thick] (-6,-2) --
  node[near start,below]
  {\textsf{directrix} $\quad y=d$ \textsf{is} $y=-2$} (6,-2);
\draw[domain=-5:5,samples=50,very thick,dotted]
  plot (\x,{\x*\x/8+1});
\coordinate (F) at (0,4);
\fill (F) circle (2pt)
  node[left,xshift=-2pt,yshift=0pt] {$(0,f)\textsf{\ is\ }(0,4)$}
  node[above left,xshift=-2pt,yshift=4pt] {\textsf{focus}};
\fill (0,-2) circle (2pt);
\fill (0,1) circle (2pt)
  node[below left] {\textsf{vertex}}
  node[below left,yshift=-10pt] {$(0,1)$};
\draw[<->] (2,-1.9) --
  node[fill=white,xshift=4pt] {$p=6$} +(0,5.8);
\draw[<->] (1,.1) --
  node[fill=white] {$h=1$} +(0,.8);
\end{tikzpicture}
\end{center}
Define $a=2ph$ so that the equation of the parabola is:
\vspace{-2ex}
\begin{form}{1.2}
y=\disfrac{x^2}{2p}+\disfrac{a}{2p}\\
x^2-2py+a=0\,.
\end{form}
The equation of the parabola in the diagram above is:
\begin{form}{.9}
x^2-2\cdot 6\,y + 2\cdot 6 \cdot 1=0\\
x^2-12y +12=0\,.
\end{form}
Substitute the equation of an \emph{arbitrary} line $y=mx+b$ into the equation for the parabola to obtain an equation for the points of intersection of the line and the parabola:
\vspace{-2ex}
\begin{form}{1}
x^2-2p(mx+b)+a=0\\
x^2+(-2mp)x+(-2pb+a)=0\,.
\end{form}
The line will be a \emph{tangent} to the parabola \emph{if and only if} this quadratic equation has \emph{exactly one} solution \emph{if and only if} its discriminant is zero:
\[
(-2mp)^2\:-\:4\cdot 1\cdot (-2pb+a)=0\,,
\]
which simplifies to:
\begin{equation}
m^2p^2+2pb-a=0\,.\label{eq.disc}
\end{equation}

This is the quadratic equation with variable $m$ for the slopes of tangents to the parabola. There are an infinite number of tangents because for each $m$, there is some $b$ that makes the line a tangent by moving it up or down.\footnote{Except of course for a line parallel to the axis of symmetry.}

To obtain the common tangents to both parabolas, the equations for the two parabolas have two unknowns and can be solved for $m$ and $b$.

\textbf{Example}

Parabola 1: focus $(0,4)$, directrix $y=2$, vertex $(0,3)$, $p=2$, $a=2\cdot 2\cdot 3=12$. The equation of the parabola is:
\[
\begin{array}{l}
x^2-2\cdot 2y +12=0\,.
\end{array}
\]
Substituting into Equation~\ref{eq.disc} and simplifying:
\[
m^2+b-3=0\,.
\]
Parabola 2: focus $(0,-4)$, directrix $y=-2$, vertex $(0,-3)$, $p=-2$, $a=2\cdot -2\cdot -3=12$. The equation of the parabola is:
\[
x^2-2\cdot (-2)y+12=0\,.
\]
Substituting into Equation~\ref{eq.disc} and simplifying:
\begin{equation}
m^2-b-3=0\,.\label{eq.parabola1}
\end{equation}
The solutions of the two equations:
\vspace{-3ex}
\begin{form}{1}
m^2+b-3=0\\
m^2-b-3=0\,,
\end{form}
are $m=\pm\sqrt{3}\approx \pm 1.73$ and $b=0$. There are two common tangents that are the folds:
\[
y=\sqrt{3}x\,,\quad y=-\sqrt{3}x\,.
\]

\textbf{Example}

Parabola 1 is unchanged.

Parabola 2: focus $(0,-6)$, directrix $y=-2$, vertex $(0,-4)$, $p=-4$, $a=2\cdot -4\cdot -4=32$. The equation of the parabola is:
\[
x^2-2\cdot (-4)y +32=0\,.
\]
Substituting into Equation~\ref{eq.disc} and simplifying:
\[
2m^2-b-4=0\,.
\]
The solutions of the two equations (using Equation~\ref{eq.parabola1} for the first parabola):
\vspace{-2ex}
\begin{form}{1}
m^2+b-3=0\\
2m^2-b-4=0\,,
\end{form}
are $m=\pm\sqrt{\disfrac{7}{3}}\approx \pm 1.53$ and $b=\disfrac{2}{3}$. There are two common tangents that are folds:
\[
y=\sqrt{\disfrac{7}{3}}x+\disfrac{2}{3}\,,\quad y=-\sqrt{\disfrac{7}{3}}x+\disfrac{2}{3}\,.
\]

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

\textbf{Example}

Let us now define a parabola whose axis of symmetry is the $x$-axis.

Parabola 1 is unchanged.

Parabola 2: focus $(4,0)$, directrix $x=2$, vertex $(3,0)$, $p=2$, $a=2\cdot 2\cdot 3=12$. The equation of the parabola is:
\[
y^2-4x+12 = 0\,.
\]
This is an equation with $y^2$ and $x$ instead of $x^2$ and $y$, so we can't use Equation~\ref{eq.disc} and we must perform the derivation again.

Substitute the equation for a line:
\vspace{-2ex}
\begin{form}{1}
(mx+b)^2-4x+12=0\\
m^2x^2+(2mb-4)x+(b^2+12)=0\,,
\end{form}
set the discriminant equal to zero and simplify:
\vspace{-2ex}
\begin{form}{1}
(2mb-4)^2\:-\:4m^2(b^2+12)=0\\
-3m^2-mb+1=0\,.
\end{form}
If we try to solve the two equations (using Equation~\ref{eq.parabola1} for the first parabola):
\vspace{-2ex}
\begin{form}{1}
m^2+b-3=0\\
-3m^2-mb+1=0\,,
\end{form}
we obtain a cubic equation with variable $m$:
\begin{equation}
m^3-3m^2-3m+1=0\,.\label{eq.cubic}
\end{equation}
Since a cubic equation has at least one and at most three (real) solutions, there can be one, two or three common tangents. There can also be no common tangents if the two equations have no solution, for example, if one parabola is ``contained'' with another: $y=x^2$, $y=x^2+1$.

The formula for solving cubic equations is quite complicated, so I used a calculator on the internet and obtained three solutions:
\[
m=3.73\,, \;m=-1\,, \; m=0.27\,.
\]
Choosing $m=0.27$, $b=3-m^2=2.93$, and the equation of the fold is:
\[
y=0.27x+2.93\,.
\]

From the form of Equation~\ref{eq.cubic}, we might guess that $1$ or $-1$ is a solution:
\vspace{-2ex}
\begin{form}{1}
1^3-3\cdot 1^2-3\cdot 1+1=-4\\
(-1)^3-3\cdot (-1)^2-3\cdot(-1)+1=0\,.
\end{form}
Divide Equation~\ref{eq.cubic} by $m-(-1)=m+1$ to obtain the quadratic equation $m^2-4m+1$ whose roots are $2\pm\sqrt{3}\approx 3.73, 0.27$.

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

\textbf{Derivation of the equations of the reflections}

We derive the position of the reflection $p_1'=(x_1',y_1')$ of $p_1=(x_1,y_1)$ around some tangent line $l_t$ whose equation is $y=m_tx+b_t$. The derivation is identical for any tangent and for $p_2$.

To reflect $p_1$ around $l_t$, we find the line $l_p$ with equation $y=m_px+b_p$ that is perpendicular to $l_t$ and passes through $p_1$:
\vspace{-2ex}
\begin{form}{1.2}
y=-\disfrac{1}{m_t}x+b_p\\
y_1=-\disfrac{1}{m_t}x_1+b_p\\
y=\disfrac{-x}{m_t}+\left(y_1+\disfrac{x_1}{m_t}\right)\,.
\end{form}

Next we find the intersection $p_t=(x_t,y_t)$ of $l_t$ and $l_p$:
\vspace{-3ex}
\begin{form}{1.7}
m_tx_t+b_t=\disfrac{-x_t}{m_t}+\left(y_1+\disfrac{x_1}{m_t}\right)\\
x_t=\disfrac{\left(y_1+\disfrac{x_1}{m_t}-b_t\right)}{\left(m_t+\disfrac{1}{m_t}\right)}\\
y_t=m_tx_t+b_t\,.
\end{form}
The reflection $p_1'$ is easy to derive because the intersection $p_t$ is the midpoint between $p_1$ and its reflection $p_1'$:
\vspace{-2ex}
\begin{form}{1.3}
x_t=\disfrac{x_1+x_1'}{2}\,,\quad y_t=\disfrac{y_1+y_1'}{2}\\
x_1'=2x_t-x_1\,,\quad y_1'=2y_t-y_1\,.
\end{form}

\textbf{Example}

$p_1=(0,4)$, $l_1$ is $y=\sqrt{3}x$:
\vspace{-2ex}
\begin{form}{1.3}
x_t=\disfrac{\left(4+\disfrac{0}{\sqrt{3}}-0\right)}{\left(\sqrt{3}+\disfrac{1}{\sqrt{3}}\right)}=\sqrt{3}\\
y_t=\sqrt{3}\sqrt{3}+0=3\\
x_1'=2x_t-x_1=2\sqrt{3}-0=2\sqrt{3}\approx 3.46\\
y_1'=2y_t-y_1=2\cdot 3 - 4 = 2\,.
\end{form}

\bigskip

\textbf{A fold is any tangent to a parabola}

Students are usually introduced to parabolas as the graphs of second degree equations $y=ax^2+bx+c$. However, parabolas can be defined geometrically: given a point, the \emph{focus}, and a line, the \emph{directrix}, the locus of points equidistant from the focus and the directrix defines a parabola.

The following diagram shows the focus---the large dot at $p=(0,f)$, and the directrix---the thick line $d$ whose equation is $y=-f$. The resulting parabola is shown as a dotted curve. Its \emph{vertex} $p_2$ is at the origin of the axes.

\begin{center}
\begin{tikzpicture}[scale=1]
\draw (-6,0) -- node[very near start,below,xshift=-32pt] {$x$-\textsf{axis}} (6,0);
\draw (0,-3) -- node[very near start,right,yshift=-20pt] {$y$-\textsf{axis}} (0,4.5);
\draw[ultra thick] (-6,-2) -- node[near start,below] {\textsf{directrix} $d: \quad y=-f$} (6,-2);
\draw[domain=-6:6,samples=50,very thick,dotted] plot (\x,{\x*\x/8});
\coordinate (F) at (0,2);
\fill (F) circle (3pt) node[above left,xshift=-2pt,yshift=15pt] {$(0,f)$} node[above left,xshift=-2pt,yshift=30pt] {\textsf{focus}} node[above right] {$p$};
\fill (0,0) circle (1.5pt) node[below right] {$p_2$};
\fill (0,-2) circle (1.5pt);
\fill (2,-2) circle (1.5pt);
\fill (3,-2) circle (1.5pt);
\fill (5,-2) circle (1.5pt);
\coordinate (FP) at (-5,-2);
\fill (FP) circle (1.5pt) node[below] {$p'$};
\coordinate (F1) at (2,.5);
\fill (F1) circle (1.5pt) node[below right] {$p_3$};
\coordinate (F2) at (3,1.125);
\fill (F2) circle (1.5pt) node[below right] {$p_4$};
\coordinate (F3) at (5,3.125);
\fill (F3) circle (1.5pt) node[below right] {$p_5$};
\coordinate (F4) at (-5,3.125);
\fill (F4) circle (1.5pt) node[above right] {$p_1$};
\draw (F) -- node[left] {$a_2$} (0,0) -- node[left] {$a_2$} (0,-2);
\draw (F) -- node[near end,left] {$a_3$} (F1) -- node[left] {$a_3$} (2,-2);
\draw (F) -- node[near end,above] {$a_4$} (F2) -- node[left] {$a_4$} (3,-2);
\draw (F) -- node[above] {$a_5$} (F3) -- node[left] {$a_5$} (5,-2);
\draw (F) -- node[above] {$a_1$} (F4) -- node[left] {$a_1$} (FP);
\draw[thick,dashed] ($(F4)!-.4!(-2.5,0)$) -- node[very near end,right,xshift=2pt] {$l_1$} ($(F4)!1.8!(-2.5,0)$);
\draw (0,-2) rectangle +(8pt,8pt);
\draw (2,-2) rectangle +(8pt,8pt);
\draw (3,-2) rectangle +(8pt,8pt);
\draw (5,-2) rectangle +(8pt,8pt);
\draw (-5,-2) rectangle +(8pt,8pt);
\end{tikzpicture}
\end{center}

We have selected five points $p_i$, $i=1,\ldots,5$ on the parabola. Each point $p_i$ is at a distance of $a_i$ both from the focus and from the directrix. Drop a perpendicular from $p_i$ to the directrix and let $p_i'$ be the intersection of the perpendicular and the directrix. Using Axiom~2, construct the line $l_i$ by folding $p$ onto $p_i'$. Since $p_i$ is on the parabola, $\overline{p'p_i}=\overline{p_{i}p}=a_i$. The diagram shows the fold $l_1$ through $p_1$.

\newpage

\textbf{Theorem} The folds are tangents to the parabola.

\textbf{Proof (Oriah Ben Lulu)}
In the following diagram, the focus is $p$, the directrix is $l$, $p'$ is a point on the directrix and $m$ is the fold that places $p$ on $p'$. By definition, $m$ is the perpendicular bisector of $\overline{pp'}$. Let $s$ be the intersection of $\overline{pp'}$ and $m$; then $\overline{ps}=\overline{p's}=a$ and $m\perp \overline{pp'}$.

\begin{center}
\begin{tikzpicture}[scale=1.1]
\draw[ultra thick] (-6,-2) -- node[near end, below] {$l$} (6,-2);
\draw[domain=-5.5:5.5,samples=50,very thick,dotted] plot (\x,{\x*\x/8});
\coordinate (F) at (0,2);
\fill (F) circle (2pt) node[above right] {$p$};
\coordinate (FP) at (-3,-2);
\fill (FP) circle (1.5pt) node[below] {$p'$};
\coordinate (F4) at (-3,1.125);
\fill (F4) circle (1.5pt) node[above right] {$r$};
\coordinate (F5) at (-5,2.775);
\fill (F5) circle (1.5pt) node[left,yshift=-4pt] {$q$};
\coordinate (F5p) at (-5,-2);
\fill (F5p) circle (1.5pt) node[below] {$p''$};
\draw (F) -- node[above] {$b$} (F4) -- node[left] {$b$} (FP);
\draw (F) -- node[above] {$c$} (F5);
\draw (F5) -- node[left] {$d$} (F5p);
\draw[thick,dashed,name path=fold] ($(F4)+(140:4)$) -- (F4) -- node[below,xshift=-2pt,yshift=-2pt] {$m$} ($(F4)+(-40:5.1)$);
\draw (FP) rectangle +(8pt,8pt);
\draw (F5p) rectangle +(8pt,8pt);
\draw (F5) -- (FP);
\draw[name path=base] (F) -- (FP);
\path [name intersections = {of = base and fold, by = {G}}];
\fill (G) circle (1.5pt) node[below,yshift=-4pt] {$s$};
\draw[rotate=140] (G) rectangle +(6pt,6pt);
\path (FP) -- node[left] {$c$} (F5);
\path (F) -- node[below] {$a$} (G) -- node[below] {$a$} (FP);
\end{tikzpicture}
\end{center}
Let $r$ be the intersection of a perpendicular to $l$ through $p'$ and the fold $m$. Then $\triangle psr\cong \triangle p'sr$ by side-angle-side, since $\overline{ps}=\overline{p's}$,  $\angle psr=\angle p'sr=90^\circ$ and $\overline{rs}$ is a common edge. It follows that $\overline{pr}=\overline{p'r}=b$ and therefore $r$ must be on the parabola.

Choose a point $p''$ on the directrix that is \emph{distinct} from $p'$ and suppose that $m$ is also the fold that places $p$ on $p''$. Let $q$ be the intersection of the perpendicular to $l$ through $p''$ and the fold $m$. As before, we can prove that $\overline{pq}=\overline{p'q}=c$. Let $\overline{qp''}=d$. If $q$ is on the parabola then $d=\overline{qp''}=\overline{qp}=c$. But $c$ is the hypotenuse of the right triangle $\triangle qp''p'$ and cannot be equal to one of its sides $d$.

We have proved that $m$ intersects the parabola in only one point so it is a tangent to the parabola.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newpage

\section{Axiom 7}\label{s.ax7}

\textbf{Axiom}
Given one point $p_1$ and two lines $l_1$ and $l_2$, there is a fold $l$ that places $p_1$ onto $l_1$ and is perpendicular to $l_2$.

%\begin{figure}[H]
\begin{center}
\begin{tikzpicture}[scale=1.2]
\draw[step=10mm,white!50!black,thin] (-1,-1) grid (9,8);
\draw[thick] (-1,0) -- (9,0);
\draw[thick] (0,-1) -- (0,8);
\foreach \x in {0,...,9}
  \node at (\x-.2,-.2) {\sm{\x}};
\foreach \y in {1,...,8}
  \node at (-.2,\y-.3) {\sm{\y}};

\coordinate (P1) at (5,3);
\fill (P1) circle (2pt) node[below left] {$p_1$};

\coordinate (P1P) at (2.75,5.25);
\fill (P1P) circle (2pt) node[left,xshift=-4pt] {$p_1'$};

\draw[very thick] (1,0) -- node[very near start,right,xshift=2pt] {$l_1$} (3,6);
\draw[very thick,name path=l2] (8,3) -- node[very near start,right,xshift=-2pt,yshift=6pt] {$l_2$} (5,6);

\draw[thick,dotted] ($(1,0)!-.15!(3,6)$) -- ($(1,0)!1.34!(3,6)$);

\draw[thick,dotted] ($(8,3)!-.3!(5,6)$) -- ($(8,3)!1.65!(5,6)$);

\draw[thick,dotted] ($(P1)!-.4!(P1P)$) -- node[very near start,below,yshift=-4pt] {$l_p$} ($(P1)!1.5!(P1P)$);

\draw[very thick,dashed,name path=fold] (-.5,-.25) -- node[very near end,above,xshift=4pt,yshift=6pt] {$l$} (7.5,7.75);

\coordinate (mid) at ($(P1)!.5!(P1P)$);
\fill (mid) circle (2pt) node[below,yshift=-8pt] {$p_m$};

\path [name intersections = {of = fold and l2, by = {perp}}];
\draw[rotate=-45] (mid) rectangle +(8pt,8pt);
\draw[rotate=-45] (perp) rectangle +(8pt,8pt);

\draw[very thick,dotted,->,bend right=50] (5.1,3.2) to (3,5.2);
\end{tikzpicture}
\end{center}
%\end{figure}

\textbf{Derivation of the equation of the fold}

Let $p_1=(x_1,y_1)$, let $l_1$ be $y = m_1x + b_1$ and let $l_2$ be $y=m_2x+b_2$.

Since the fold $l$ is perpendicular to $l_2$, and the line $l_p$ containing $\overline{p_1p_1'}$ is perpendicular to $l$, it follows that $l_p$ parallel to $l_2$:
\[
y=m_2x+b_p\,.
\]
$l_p$ passes through $p_1$ so $y_1=m_2x_1+b_p$ and its equation is:
\[
y=m_2x+(y_1-m_2x_1)\,.
\]
$p_1'=(x_1',y_1')$, the reflection  of $p_1$ around the fold $l$, is the intersection of $l_1$ and $l_p$:
\vspace{-2ex}
\begin{form}{1.2}
m_1x_1'+b_1=m_2x_1'+(y_1-m_2x_1)\\
x_1'=\disfrac{y_1-m_2x_1-b_1}{m_1-m_2}\\
y_1'=m_1x_i'+b_1\,.
\end{form}
The midpoint $p_m=(x_m,y_m)$ of $l_p$ between $p_1$ and $p_1'$ is on the fold $l$:
\[
(x_m,y_m)=\left(\disfrac{x_1+x_1'}{2},\disfrac{y_1+y_1'}{2}\right)\,.
\]
The equation of the fold $l$ is the perpendicular bisector of $\overline{p_1p_1'}$. First compute the intercept of $l$ which passes through $p_m$:
\vspace{-2ex}
\begin{form}{1.3}
y_m=-\disfrac{1}{m_2}x_m+b_m\\
b_m=y_m+\disfrac{x_m}{m_2}\,.
\end{form}
The equation of the fold $l$ is:
\[
y=-\disfrac{1}{m_2}x+\left(y_m+\disfrac{x_m}{m_2}\right)\,.
\]

\vspace*{-1ex}

\textbf{Example}

Let $p_1=(5,3)$, let $l_1$ be $y=3x-3$ and let $l_2$ be $y=-x+11$.
\vspace{-2ex}
\begin{form}{1.3}
x_1'=\disfrac{3-(-1)\cdot 5-(-3)}{3-(-1)}=\disfrac{11}{4}\\
y_1'=3\cdot \disfrac{11}{4} + (-3)=\disfrac{21}{4}\\
	p_m=\left(\disfrac{5+\disfrac{11}{4}}{2},\disfrac{3+\disfrac{21}{4}}{2}\right)=\left(\disfrac{31}{8},\disfrac{33}{8}\right)\,.
\end{form}
The equation of the fold $l$ is:
\[
y=-\disfrac{1}{-1}\cdot x+\left(\disfrac{33}{8}+\disfrac{\disfrac{31}{8}}{-1}\right)=x+\disfrac{1}{4}\,.
\]


\subsection{Brownian motion}

brownian motion in stats. given we start at a, what is chance be end up at b? normal. do 1d then multi d


\section{Likelihood components}

The objective function $L$ is the weighted sum of the individual components
indexed by kind of data $i$, and fishery/survey $f$ as appropriate:

\begin{equation}
	L = \sum_{i=1}^{I}\sum_{f=1}^{A_f}\lambda_{i,f} L_{i,f}+\lambda_R L_R + \sum_{\theta}^{}\lambda_\theta L_\theta + \sum_{P}^{}\lambda_P L_P
\end{equation}

where $L$ is the total objective function, $i$ is the index of the objective
function component, $A_f$ is the number of fleets, $L_{i,f}$ is the
objective function for data kind $i$ for the fishery/survey $f$,
$\lambda_{i,f}$ is a weighting factor for each objective function component,
$\theta$ is the parameter priors, and $P$ is the random parameter deviations.

The components of the objective function based on the model set-up and data are:

\begin{longtable}{p{1cm} p{3.5cm} p{5.5cm} Rp{5cm}}
	\hline
	Index & Source & Data/Parameter & Error structure\Tstrut\Bstrut\\
	\hline
	$i$ & fishery/survey $f$ & CPUE or Abundance index & user choice \Tstrut\\
	$i$ & fishery $f$        & Discard biomass         & user choice \Tstrut\\
	$i$ & fishery/survey $f$ & Mean body weight        & normal \Tstrut\\
	$i$ & fishery/survey $f$ & Length composition      & multinomial or Dirichlet-multinomial\Tstrut\\
	$i$ & fishery/survey $f$ & Age composition         & multinomial or Dirichlet-multinomial\Tstrut\\
%	$i$ & fishery/survey $f$ & Dirichlet data weighting& gamma in log-space\Tstrut\\
	$i$ & fishery/survey $f$ & Mean size-at-age        & normal \Tstrut\\
	$i$ & fishery/survey $f$ & Tag-recapture 1         & multinomial \Tstrut\\
	$i$ & fishery/survey $f$ & Tag-recapture 2         & negative binomial\Tstrut\\
	$i$ & fishery $f$        & Initial equilibrium catch & normal \Tstrut\\
	$R$ & 					 & Recruitment deviations  & lognormal \Tstrut\\
	$P$ & 					 & Random parameter devs.  & normal \Tstrut\\
	$\theta$ & 				 & Parameter priors	       & user choice\Tstrut\\
	$F_B$ & 				 & F ballpark penalty	   &  \Tstrut\\
	$C_P$ &				     & Crash penalty           &  \Tstrut\Bstrut\\
	\hline
\end{longtable}
%Full description of likelihood distributions by source will be added in the future.

%\subsection{CPUE or abundance index}

%The distribution for CPUE or abundance index data can be lognormal, student-t, or normal.  The %lognormal likelihood formulation is:

%\begin{equation} L_{i,f} = N(ln(\sigma)) + \sum_{y=1}^{N_y}\frac{(ln(I_{y,f})-ln(Q_f B_{y,f}))^2}{2\sigma^2}
%\end{equation}

\pagebreak


\subsection{Metric parameters}

The parameters of the dissimilarity metrics are varied to determine which values give the best results. The methods were tested with different parameters on the set of images\footnote{available here: \url{http://people.csail.mit.edu/taegsang/Documents/jigsawCode.zip}} first used by Cho et al. \cite{cho} and then in \cite{robust} and \cite{greedy} for puzzle pieces of size 28 by 28 pixels. The number of pieces of the puzzle in then of 432. The error is expressed as the percentage of badly positioned pieces for all the 20 images of the set.

\paragraph{M+S} \mbox{}

The parameter $r$ from \autoref{eq:ms} is varied from 1 to 20. The accuracy for each value is shown in \autoref{fig:ms}.

\begin{figure}[H]
\centering
\input{fig/param_ms}
\caption{Performance of the M+S for various values of the $r$ parameter}
\label{fig:ms}
\end{figure}

The accuracy is maximum for $r=16$, hence this value will be retained for the final solver. This is also the value of $r$ that yielded the best results in \cite{robust}, which confirms this experimental result.

\paragraph{M+pq} \mbox{}

The parameter $r$ from \autoref{eq:mpq} is varied. The accuracy for each value is shown in \autoref{fig:param_pq}.

\begin{figure}[H]
\centering
\input{fig/param_pq}
\caption{Performance of the M+pq for various values of the $r$ parameter}
\label{fig:param_pq}
\end{figure}

When the $(L_p)^q$ is combined with the MGC, the best results are obtained when $r=9$, which will be retained. This M+pq combination has not been used in the literature, so that this conclusion only relies on the present experiments.

For both the M+S and the M+pq, the performance appears to be better when the contribution from the MGC is more significant than the contribution of the methods based on the pixel intensities.

\subsection{Performance comparison}

The metrics with optimal parameters are then used again on the same set of images. Their performance is compared for piece sizes of 84 by 84 pixels, 56 by 56 pixels and 28 by 28 pixels.

\begin{figure}[H]
    \centering
    \input{fig/perf84.tex}
    \caption{Performance comparison for bloc sizes of 84 pixels. The MGC is outperforming all others with an accuracy of 93.2\%.}
    \label{fig:perf84}
\end{figure}

The results for pieces of 84 by 84 pixels are shown in \autoref{fig:perf84}. When the size of the piece has a relatively high value, the solver is very accurate. As expected, the $(L_p)^q$ metric is performing better than the SSD as it has a very similar working principle but penalizes less the natural steep edges at the boundaries of the pieces. Surprisingly, the MGC is outperforming the more advanced M+S and M+pq metrics. The additional information brought by the pixel intensities degrades the information brought by the color gradients.

\begin{figure}[H]
    \centering
    \input{fig/perf56.tex}
    \caption{Performance comparison for bloc sizes of 56 pixels. The M+S is outperforming all others with an accuracy of 87.2\%.}
    \label{fig:perf56}
\end{figure}

It is worth noting that a mean accuracy of 90\% does not indicate in this case that each puzzle is reconstructed with 10\% of errors. Actually, most images are reconstructed very well, but a few of them are not accurately at all, dropping the mean.

The tendencies observed above are not true anymore when the size of the puzzle pieces goes down. In \autoref{fig:perf56} are shown the results for 54 by 54 pixels pieces, where it appears that the M+S is the most accurate method. When the border is smaller, less information is available and the combination of the color and gradient information allows to get more accuracy. An unexpected observation is that even if the SSD alone is far from being as accurate as the $(L_p)^q$, the combination of the SSD and the MGC outperforms the combination of the $(L_p)^q$ and the MGC.

\begin{figure}[H]
    \centering
    \input{fig/perf28.tex}
    \caption{Performance comparison for bloc sizes of 28 pixels. The M+S is outperforming all others with an accuracy of 66.3\%.}
    \label{fig:perf28}
\end{figure}

Lastly, the solver was tested on small pieces of 28 by 28 pixels. The side of the pieces being very small, there is little information available and the accuracy drops to 66\%. Still, the M+S metric is the one outperforming the others, and the conclusions from the 56 by 56 case hold.


%\subsection{Reinforcement Learning}

%\begin{frame}{What is reinforcement learning?}
%\only<1->{Simply put, reinforcement learning (RL) is used to solve a task from rewards or costs.}
%\begin{itemize}
%\item<2-> \textbf{Setup:} Consider an agent in an environment that acts over time ($t = 1,2,\ldots, T$)
%\begin{enumerate}
%\item<3-> Currently at state $s_t$
%\item<4-> Decide on an action $a_t = \pi(s_t)$
%\item<5-> Receive cost $c_t$
%\item<6-> Assigned next state $s_{t + 1}$
%\end{enumerate}
%\begin{center}
%\includegraphics<3>[width=0.2\textwidth]{img/agent-1.png}
%\includegraphics<4>[width=0.2\textwidth]{img/agent-2.png}
%\includegraphics<5>[width=0.2\textwidth]{img/agent-3.png}
%\includegraphics<6->[width=0.2\textwidth]{img/agent-4.png}
%\end{center}
%\item<7-> \textbf{Goal:} Learn a policy function $\pi(s)$
%that minimizes
%\begin{align*}
%\sum_{t = 1}^T c_t
%\end{align*}
%\end{itemize}
%\end{frame}

%\begin{frame}{Model-free reinforcement learning}
%In model-free RL, we learn a policy by directly optimizing the objective
%\begin{align*}
%\pi_\theta^*(s) = \argmin_\theta \sum_{t = 1}^T c_t.
%\end{align*}
%\pause
%\begin{center}
%\includegraphics<1->[width=0.3\textwidth]{img/model-free.png}
%\end{center}
%Examples of model-free algorithms include:
%\begin{itemize}
%\item Q-learning
%\item Trust-region policy optimization
%\item Generalized advantage estimation
%\end{itemize}
%\end{frame}

%\begin{frame}{Model-free vs. model-based RL}
%%Do we explicitly want to model how the environment behaves?

%An environment can be broken down into two independent components:
%\pause
%\begin{itemize}
%\item \textbf{Dynamics function}: $\state_{t + 1} \sim p(s_{t + 1}| s_t, a_t)$
%\pause
%\item \textbf{Cost function}: $c_t = C(s_t, a_t)$
%\end{itemize}
%\pause
%\metroset{block=fill}
%\begin{block}{Model-free}
%Learn a black-box policy $\pi_\theta(s_t)$ by directly optimizing $\sum_{t = 1}^T c_t$
%\end{block}
%\pause
%\metroset{block=fill}
%\begin{block}{Model-based}
%Learn a model of the environment ($\dynmodel(\state_{t+1}|\state_t,\action_t)$,  $\costmodel(\state_t,\action_t)$).
%Then, learn a policy $\pi_\theta(s_t)$ with model-predictive control (MPC).
%\end{block}
%%\begin{center}
%%\includegraphics<1->[width=0.5\textwidth]{img/model-free.png}
%%\includegraphics<2->[width=0.5\textwidth]{img/model-based.png}
%%\end{center}
%\end{frame}


\documentclass{ximera}
\input{../preamble}
\title{The Disk and Washer Methods}
%%%%%\author{Philip T. Gressman}

\begin{document}
\begin{abstract}
  We practice setting up calculations related to the disk and washer methods.
\end{abstract}
\maketitle

\section*{Online Texts}
\begin{itemize}
\item \link[OpenStax II 2.2 (beginning with the Disk Method)]{https://openstax.org/books/calculus-volume-2/pages/2-2-determining-volumes-by-slicing}
\item \link[Ximera OSU: The Washer Method]{https://ximera.osu.edu/mooculus/calculus2/solidsOfRevolution/digInWasherMethod}
\end{itemize}

\section*{Examples}

\begin{example}
Suppose the region below the graph $y = \sqrt{\sin x}$ and above the $x$-axis between $x=0$ and $x=\pi$ is revolved around the $x$-axis. Compute the volume of the resulting solid.
\begin{center}
\begin{image}
\includegraphics[width=4in]{diskwasher/disksin.png}
\end{image}
\end{center}
\begin{itemize}
\item Because the axis of rotation lies perfectly along the boundary of the region, the \wordChoice{\choice[correct]{disk}\choice{washer}} method can be used.
\item The radius $R$ is the length of a \wordChoice{\choice{horizontal}\choice[correct]{vertical}} extending from the axis to the graph $y = \sqrt{\sin x}$.
\item Thus we know that the radius $R$ must equal
\begin{multipleChoice}\choice[correct]{$R(x) = \sqrt{\sin x} - 0 = \sqrt{\sin x}$}\choice{$R(y) = \arcsin y^2 - 0 = \arcsin y^2$}\end{multipleChoice}
\item We conclude that
\[ V = \int_{\answer{0}}^{\answer{\pi}} \pi \left( \answer{\sqrt{\sin x}} \right)^2 d\answer{x} = \answer{2\pi}. \]
\end{itemize}
\end{example}

\begin{example}
Suppose the region between the graphs $y = x/2$ and $y=x^2/4$ is revolved around the axis $x=0$. Compute the volume of the resulting solid.
\begin{center}
\begin{image}
\includegraphics[width=4in]{diskwasher/washer1.png}
\end{image}
\end{center}
\begin{itemize}
\item Because the axis of rotation does not lie along the boundary of the region, the \wordChoice{\choice{disk}\choice[correct]{washer}} method can be used.
\item In this case, radius will equal the length of a \wordChoice{\choice[correct]{horizontal}\choice{vertical}} extending from the axis to the graphs $y = x/2$ and $y = x^2/4$.
\item
\begin{multipleChoice}
\choice{$R_{\mathrm{outer}} (x) = x/2 $ and $r_{\mathrm{inner}}(x) = x^2/4$}
\choice[correct]{$R_{\mathrm{outer}} (y) = 2 \sqrt{y} $ and $r_{\mathrm{inner}}(y) = 2 y$}
\end{multipleChoice}
\item We conclude that
\[ V = \int_{\answer{0}}^{\answer{1}} \pi \left[  \left( \answer{2 \sqrt{y}} \right)^2 - \left( \answer{2 y} \right)^2  \right] d\answer{y} = \answer{\frac{2 \pi}{3}}. \]
\end{itemize}
\end{example}

\end{document}


% Created 2021-09-24 Fri 15:01
% Intended LaTeX compiler: pdflatex
\documentclass[presentation,aspectratio=169, usenames, dvipsnames]{beamer}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{grffile}
\usepackage{longtable}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\usepackage{textcomp}
\usepackage{amssymb}
\usepackage{capt-of}
\usepackage{hyperref}
\usepackage{khpreamble}
\usepackage{amssymb}
\usepgfplotslibrary{groupplots}
\newcommand*{\shift}{\operatorname{q}}
\definecolor{ppc}{rgb}{0.1,0.1,0.6}
\definecolor{iic}{rgb}{0.6,0.1,0.1}
\definecolor{ddc}{rgb}{0.1,0.6,0.1}
\usetheme{default}
\author{Kjartan Halvorsen}
\date{\today}
\title{Root locus}
\hypersetup{
 pdfauthor={Kjartan Halvorsen},
 pdftitle={Root locus},
 pdfkeywords={},
 pdfsubject={},
 pdfcreator={Emacs 26.3 (Org mode 9.4.6)},
 pdflang={English}}
\begin{document}

\maketitle

\section{Repetition}
\label{sec:org1a1505a}
\begin{frame}[label={sec:org8fc1eb3}]{Block diagram algebra}
\begin{center}
  \includegraphics[width=.6\linewidth]{../../figures/block-simple-feedback}
\end{center}

Transfer function from \(r(t)\) to \(y(t)\):
\[ \frac{Y(s)}{R(s)} = \frac{G(s)}{ 1+ G(s)}\]

\pause
\alert{Mason's} gain formula: \(G_c(s) = \frac{Y(s)}{R(s)} = \frac{\sum_k T_k\Delta_k}{\Delta}\)

For simple systems with one loop only: \[G_c(s) = \frac{Y(s)}{R(s)} = \frac{\text{Forward path gain}}{1+\text{Loop gain}}\]
\end{frame}

\begin{frame}[label={sec:org5b4dfeb}]{Block diagram algebra}
\alert{Activity} Pair the block-diagram with the correct closed-loop transfer function!

\begin{longtable}{cccc}
\textcolor{red}{A} & \textcolor{red}{B} & \textcolor{red}{C} & \textcolor{red}{D}\\
\includegraphics[width=3cm]{../../figures/block-simple-control-feedback} & \includegraphics[width=3cm]{../../figures/block-simple-control-feedback2} & \includegraphics[width=3cm]{../../figures/block-simple-control-feedback3} & \includegraphics[width=3cm]{../../figures/block-simple-control-feedback4}\\
\end{longtable}

\begin{longtable}{cccc}
\textcolor{blue!80!black}{I} & \textcolor{blue!80!black}{II} & \textcolor{blue!80!black}{III} & \textcolor{blue!80!black}{IV}\\
\(\frac{Y(s)}{R(s)}=\frac{G(s)F(s)}{1 + G(s)}\) & \(\quad \frac{Y(s)}{R(s)}=\frac{G(s)}{1 + G(s)F(s)}\quad\) & \(\frac{Y(s)}{R(s)}=\frac{1}{1 + G(s)F(s)}\) & \(\frac{Y(s)}{R(s)}=\frac{G(s)F(s)}{1 + G(s)F(s)}\)\\
\end{longtable}
\end{frame}

\section{Proportional control of the DC motor}
\label{sec:orga100b65}

\begin{frame}[label={sec:org799eb1e}]{The DC motor}
\begin{columns}
\begin{column}{0.5\columnwidth}
\begin{center}
 \includegraphics[width=1.0\linewidth]{../../figures/block-DC-feedback-white}
\end{center}
\end{column}
\begin{column}{0.5\columnwidth}
\begin{center}
 \def\ggain{200}
 \def\Tcnst{0.1}
 \begin{tikzpicture}
   \begin{axis}[
   width=7cm,
   height=6cm,
   grid = both,
   xlabel = {Time [s]},
   ylabel = {Ang vel [rad/s]},
   %xtick = {0, \tdelay, \tone, \two},
   %xticklabels = {0, $\theta$, $\theta+\frac{\tau}{3}$, $\theta + \tau$},
   %ytick = {0, \yone, \ytwo, \uampl, \yfinal},
   %yticklabels = {0, $0.283y_{f}$, $0.632y_f$, $u_f$, $y_f$},
   xmin = -0.2, xmax=2,
   minor y tick num=9,
   minor x tick num=9,
   every major grid/.style={red, opacity=0.5},
   ]
     \addplot [thick, green!50!black, no marks, domain=-0.2:2, samples=100] {(x>0)*\ggain*(1 - exp(-(x/\Tcnst)))};
  \end{axis}
 \end{tikzpicture}
\end{center}

\pause

\alert{Activity} What is the angle (approximately) rotated by the motor after 0.1s starting from still?
\end{column}
\end{columns}
\end{frame}
\begin{frame}[label={sec:orgfc31248}]{The normalized DC motor}
\begin{columns}
\begin{column}{0.5\columnwidth}
\begin{center}
 \includegraphics[width=1.0\linewidth]{../../figures/block-normalized-DC-feedback-white}
\end{center}
\end{column}

\begin{column}{0.5\columnwidth}
\begin{center}
 \def\ggain{1}
 \def\Tcnst{1}
 \begin{tikzpicture}
   \begin{axis}[
   width=7cm,
   height=6cm,
   grid = both,
   xlabel = {Time [$\tau$]},
   ylabel = {Ang vel [20 rad/$\tau$], angle [20 rad]},
   %xtick = {0, \tdelay, \tone, \two},
   %xticklabels = {0, $\theta$, $\theta+\frac{\tau}{3}$, $\theta + \tau$},
   %ytick = {0, \yone, \ytwo, \uampl, \yfinal},
   %yticklabels = {0, $0.283y_{f}$, $0.632y_f$, $u_f$, $y_f$},
   xmin = -2, xmax=20,
   minor y tick num=9,
   minor x tick num=9,
   every major grid/.style={red, opacity=0.5},
   ]
     \addplot [thick, green!50!black, no marks, domain=-2:20, samples=100] {(x>0)*\ggain*(1 - exp(-(x/\Tcnst)))};
     \addplot [thick, red!60!black, no marks, domain=-0.2:5, samples=100] {(x>0)*\ggain*(x + exp(-(x/\Tcnst)) -1)};
   \end{axis}
 \end{tikzpicture}
\end{center}

\pause
\alert{Activity} What is the settling time (approximately) for the velocity (in \(\tau\) and in seconds)?
\end{column}
\end{columns}
\end{frame}

\begin{frame}[label={sec:org21ba7f1}]{Proportional control of the normalized DC motor}
\begin{columns}
\begin{column}{0.5\columnwidth}
\begin{center}
 \includegraphics[width=1.0\linewidth]{../../figures/block-DC-feedback}
\end{center}

\pause
\end{column}
\begin{column}{0.5\columnwidth}
\begin{center}
 \def\ggain{1}
 \def\Tcnst{1}
 \begin{tikzpicture}
   \begin{axis}[
   width=7cm,
   height=6cm,
   grid = both,
   xlabel = {Time [$\tau$]},
   ylabel = {Angle [20 rad]},
   title = {$K=1$},
   %xtick = {0, \tdelay, \tone, \two},
   %xticklabels = {0, $\theta$, $\theta+\frac{\tau}{3}$, $\theta + \tau$},
   %ytick = {0, \yone, \ytwo, \uampl, \yfinal},
   %yticklabels = {0, $0.283y_{f}$, $0.632y_f$, $u_f$, $y_f$},
   xmin = -2, xmax=20,
   minor y tick num=4,
   minor x tick num=4,
   every major grid/.style={red, opacity=0.5},
   ]
     \addplot [thick, black, no marks, domain=-2:20, samples=200] {x>0};
     \addplot [thick, red!60!black, no marks, domain=-0.2:20, samples=100] {(x>0)*(1 - (exp(-x/2)* (sqrt(3)* cos(deg((sqrt(3)* x)/2)) + sin(deg((sqrt(3)* x)/2))))/sqrt(3))};
   \end{axis}
 \end{tikzpicture}
\end{center}

\pause
\alert{Activity} What is the overshoot (in percent) and rise time (in seconds)?
\end{column}
\end{columns}
\end{frame}

\begin{frame}[label={sec:orge679d4d}]{Proportional control of the normalized DC motor}
\begin{columns}
\begin{column}{0.5\columnwidth}
\begin{center}
 \includegraphics[width=1.0\linewidth]{../../figures/block-DC-feedback}
\end{center}
\end{column}

\begin{column}{0.5\columnwidth}
Closed-loop transfer function:
\[ G_c(s) = \frac{K}{s(s+1) + K}\]

Characteristic equation:
\[ s^2 + s + K = 0\]

\alert{Activity} Solve the characteristic equation!
\end{column}
\end{columns}
\end{frame}

\section{The root locus diagram}
\label{sec:org4970f26}

\begin{frame}[label={sec:orgd41484a}]{Root locus}
\begin{center}
 \includegraphics[width=1.0\linewidth]{../../figures/block-rlocus}
\end{center}

\alert{How do the closed-loop poles depend on \(K\)?}
\end{frame}

\begin{frame}[label={sec:org9835fe2}]{Root locus definition}
Let
\[\begin{cases} P(s)&=s^n+a_1s^{n-1}+\dots+a_n = (s-p_1)(s-p_2)\cdots(s-p_n)\\
Q(s)&=s^m+b_1s^{m-1}+\dots+b_m=(s-q_1)(s-q_2)\cdots(s-q_m) \end{cases},\ \ \ n\ge m \]
The root locus shows how the roots to the equation
\begin{equation}
\label{eq:P(s)+KQ(s)=0}
P(s)+K\cdot Q(s)=0,\ \ \ 0\le K<\infty
\end{equation}
depend on the parameter \(K\). The root locus consists of the set of all points in the complex plane that are roots to \eqref{eq:P(s)+KQ(s)=0} for some non-negative value of \(K\).
\end{frame}

\begin{frame}[label={sec:org39778df}]{Characteristics of the root locus}
The polynomial \(P(s)+KQ(s)=0\) above will always have \(n\) roots. Each gives a \emph{branch} in the root locus. Since the polynomials \(P(s)\) and \(Q(s)\) have real-valued coefficients, all roots are either real or complex-conjugated pairs. This means that the root locus is \emph{symmetric about the real axis.} Other characteristics
\begin{itemize}
\item Start points - marked by crosses
\item End points - marked  by circles
\item Asymptotes
\item Pieces of the real axis
\end{itemize}
\end{frame}

\begin{frame}[label={sec:org30616d2}]{Start- and end points}
\begin{description}
\item[{Start points}] These are the \(n\) roots of \(P(s) + KQ(s)\) for \(K=0\), i.e. the roots of \(P(s)\). These are the open-loop poles, and are marked with crosses '\(\times\)'
\item[{End points}] These are the \(m\) (finite) roots of \(P(s)+KQ(s)\) when \(K\to\infty\), and are hence the roots of \(Q(s)\). The end points are marked with circles '\(\circ\)'
\end{description}
\end{frame}

\begin{frame}[label={sec:orgeba0533}]{The real axis}
Those parts of the real axis that have an \alert{odd number} of real-valued start- or end points to the right (including multiplicity) belong to the root locus.
\end{frame}

\begin{frame}[label={sec:org4bf6958}]{Asymptotes, directions}
The directions of the asymptotes are given by the expression
\[ \theta_k = \arg s = \frac{(2k+1)\pi}{n-m}, \; k \in \mathbb{Z} \]
Example: 6 start points and 3 end points gives \(n-m = 6-3 = 3\) and the directions

\begin{columns}
\begin{column}{0.35\columnwidth}
\[ \theta = \begin{cases} \frac{\pi}{3}, & k=0\\ \pi, & k=1\\ -\frac{\pi}{3}, & k=-1 \end{cases}. \]
\end{column}

\begin{column}{0.65\columnwidth}
\begin{center}
\includegraphics[width=0.8\linewidth]{root-locus-ex-3asymptotes-crop}
\end{center}
\end{column}
\end{columns}
\end{frame}

\begin{frame}[label={sec:org0b3a832}]{Asymptotes, intersection with the real axis}
\begin{columns}
\begin{column}{0.4\columnwidth}
\[ ip = \frac{ \sum_{i=1}^n p_i - \sum_{i=1}^m q_i}{n-m}, \]
where \(\{p_i\}\) are the starting points (open-loop poles) and \(\{q_i\}\) are the end points (open-loop zeros).
\end{column}

\begin{column}{0.6\columnwidth}
\pgfmathsetmacro{\impart}{sqrt(3)/2}
 \begin{center}
\small
   \begin{tikzpicture}[scale=1.4, block/.style={draw, minimum width=12mm, minimum height=8mm},]
   \draw[->] (-4, 0) -- node[right, pos=1] {Re} (0.5, 0);
   \draw[->] (0, -1.3) -- node[right, pos=0.96] {Im} (0, 1.3);
   \draw (-1, 0) -- ++(0,-0.2) node[below] {-1};
   \draw (-2, 0) -- ++(0,-0.2) node[below] {-2};
   \draw (-3, 0) -- ++(0,-0.2) node[below] {-3};
   \node[red, ] at (0,0) {\large $\times$};
   \node[red] at (-1, 0) {\large $\times$};
   \node[red] at (-3, 0) {\large $\times$};
   \node[green!80!black,] at (-2, 0) {\large $\circ$};
   %\node[green!80!black] at (-0.5, 0) {\large $\circ$};

   \end{tikzpicture}

 \end{center}
\end{column}
\end{columns}
\end{frame}

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

\begin{frame}[label={sec:org3b1b3e2}]{Examples}
\end{frame}

\begin{frame}[label={sec:org8ebc182}]{Motor driving an elastic shaft}
 \small
 \begin{center}
   \includegraphics[width=0.4\linewidth]{../../figures/elastic-shaft.jpg}

   \begin{tikzpicture}[scale=0.7, transform shape, block/.style={draw, minimum width=12mm, minimum height=8mm},]
     \node[block] (plant) {$G(s)$};
     \node[circle, draw, inner sep=1pt, right of=plant, node distance=2cm] (sum) {\tiny $\Sigma$};
     \node[block, above of=sum, node distance=2cm] (load) {$H(s)$};
     \draw[->] (plant) ++ (-2cm, 0) -- node[very near start, above] {$T_i(t)$} (plant);
     \draw[->] (load) ++ (0,1cm) -- node[very near start, left] {$T_l(t)$} (load);
     \draw[->] (plant) -- (sum);
     \draw[->] (load) -- (sum);
     \draw[->] (sum) -- node[very near end, above] {$\theta_2(t)$} ++(2cm, 0);
   \end{tikzpicture}

   \end{center}

\begin{align*}
\Theta_2(s) &= \underbrace{\frac{k + bs}{s^2(J_1J_2s^2 + bs + k)}}_{G(s)}T_i(s) \underbrace{- \frac{J_1s^2 + bs + k}{s^2(J_1J_2s^2 + bs + k)}}_{H(s)}T_l(s)
   \end{align*}
\end{frame}

\begin{frame}[label={sec:orgd640ec7}]{Motor driving an elastic shaft}
\begin{columns}
\begin{column}{0.4\columnwidth}
PD-control

\begin{center}
  \begin{tikzpicture}[scale=0.9, transform shape, block/.style={draw, minimum width=12mm, minimum height=8mm},]
    \node[block] (plant) {$\frac{s+1}{s(s^2 + s + 1)}$};
    \node[block, left of=plant, node distance=3cm] (pd) {$K(2s + 1)$};
    \node[circle, draw, inner sep=1pt, left of=pd, node distance=2cm] (sum) {\tiny $\Sigma$};
    \node[coordinate, left of=sum,] (input) {};
    \draw[->] (input) -- node[very near start, above] {$r$} (sum);
    \draw[->] (sum) -- node[ above] {$e$} (pd);
    \draw[->] (pd) -- node[above] {$T_i$} (plant);
    \draw[->] (plant) -- node[coordinate] (meas) {}
            node[very near end, above] {$v_2$} ++(2cm, 0);
    \draw[->] (meas) -- ++(0, -15mm) -| node[left, pos=0.9] {$-$} (sum);
  \end{tikzpicture}
\end{center}
\end{column}
\begin{column}{0.6\columnwidth}
\pgfmathsetmacro{\impart}{sqrt(3)/2}
 \begin{center}
\small
   \begin{tikzpicture}[scale=1.4, block/.style={draw, minimum width=12mm, minimum height=8mm},]
   \draw[->] (-2, 0) -- node[right, pos=1] {Re} (0.5, 0);
   \draw[->] (0, -1.3) -- node[right, pos=0.96] {Im} (0, 1.3);
   \draw (0,\impart) -- ++(0.2, 0) node[right] {$i\frac{\sqrt{3}}{2}$};
   \draw (0,-\impart) -- ++(0.2, 0) node[right] {$-i\frac{\sqrt{3}}{2}$};
   \draw (-0.5, 0) -- ++(0,-0.2) node[below] {-0.5};
   \draw (-1, 0) -- ++(0,-0.2) node[below] {-1};
   %\node[red, ] at (0,0) {\large $\times$};
   %\node[red] at (-0.5, \impart) {\large $\times$};
   %\node[red] at (-0.5, -\impart) {\large $\times$};
   %\node[green!80!black,] at (-1, 0) {\large $\circ$};
   %\node[green!80!black] at (-0.5, 0) {\large $\circ$};

   \end{tikzpicture}

 \end{center}

\alert{Activity} Indicate the start- and end points.
\end{column}
\end{columns}
\end{frame}

\begin{frame}[label={sec:org51c1623}]{Motor driving an elastic shaft}
\begin{center}
  \includegraphics[width=.7\linewidth]{../../figures/shaft-rlocus}
\end{center}
\end{frame}

\begin{frame}[label={sec:orgb89c6ed}]{Harmonic oscillator}
\begin{columns}
\begin{column}{0.4\columnwidth}
P-control

\begin{center}
  \begin{tikzpicture}[scale=0.9, transform shape, block/.style={draw, minimum width=12mm, minimum height=8mm},]
    \node[block] (plant) {$\frac{1}{s^2 + 1}$};
    \node[block, left of=plant, node distance=2cm] (pd) {$K$};
    \node[circle, draw, inner sep=1pt, left of=pd, node distance=2cm] (sum) {\tiny $\Sigma$};
    \node[coordinate, left of=sum,] (input) {};
    \draw[->] (input) -- node[very near start, above] {$r$} (sum);
    \draw[->] (sum) -- node[ above] {$e$} (pd);
    \draw[->] (pd) -- node[above] {} (plant);
    \draw[->] (plant) -- node[coordinate] (meas) {}
            node[very near end, above] {$y$} ++(2cm, 0);
    \draw[->] (meas) -- ++(0, -15mm) -| node[left, pos=0.9] {$-$} (sum);
  \end{tikzpicture}
\end{center}
\end{column}
\begin{column}{0.6\columnwidth}
\pgfmathsetmacro{\impart}{sqrt(3)/2}
 \begin{center}
\small
   \begin{tikzpicture}[scale=1.4, block/.style={draw, minimum width=12mm, minimum height=8mm},]
   \draw[->] (-3, 0) -- node[right, pos=1.02] {Re} (0.5, 0);
   \draw[->] (0, -1.3) -- node[right, pos=0.96] {Im} (0, 1.3);
   \draw (0,\impart) -- ++(0.2, 0) node[right] {$i$};
   \draw (0,-\impart) -- ++(0.2, 0) node[right] {$-i$};
   %\draw (-0.5, 0) -- ++(0,-0.2) node[below] {-0.5};
   \draw (-1, 0) -- ++(0,-0.2) node[below] {-1};
   %%\node[red, ] at (0,0) {\large $\times$};
   %\node[red] at (-0.5, \impart) {\large $\times$};
   %\node[red] at (-0.5, -\impart) {\large $\times$};
   %\node[green!80!black,] at (-1, 0) {\large $\circ$};
   %\node[green!80!black] at (-0.5, 0) {\large $\circ$};

   \end{tikzpicture}

 \end{center}

\alert{Activity} Indicate the start- and end points, and the asymptotes.
\end{column}
\end{columns}
\end{frame}

\begin{frame}[label={sec:orgb98a32b}]{Harmonic oscillator}
\begin{columns}
\begin{column}{0.4\columnwidth}
Lead-compensator

\begin{center}
  \begin{tikzpicture}[scale=0.9, transform shape, block/.style={draw, minimum width=12mm, minimum height=8mm},]
    \node[block] (plant) {$\frac{1}{s^2 + 1}$};
    \node[block, left of=plant, node distance=2cm] (pd) {$K\frac{2s + 1}{s+2}$};
    \node[circle, draw, inner sep=1pt, left of=pd, node distance=2cm] (sum) {\tiny $\Sigma$};
    \node[coordinate, left of=sum,] (input) {};
    \draw[->] (input) -- node[very near start, above] {$r$} (sum);
    \draw[->] (sum) -- node[ above] {$e$} (pd);
    \draw[->] (pd) -- node[above] {} (plant);
    \draw[->] (plant) -- node[coordinate] (meas) {}
            node[very near end, above] {$y$} ++(2cm, 0);
    \draw[->] (meas) -- ++(0, -15mm) -| node[left, pos=0.9] {$-$} (sum);
  \end{tikzpicture}
\end{center}
\end{column}
\begin{column}{0.6\columnwidth}
\pgfmathsetmacro{\impart}{sqrt(3)/2}
 \begin{center}
\small
   \begin{tikzpicture}[scale=1.4, block/.style={draw, minimum width=12mm, minimum height=8mm},]
   \draw[->] (-3, 0) -- node[right, pos=1.02] {Re} (0.5, 0);
   \draw[->] (0, -1.3) -- node[right, pos=0.96] {Im} (0, 1.3);
   \draw (0,\impart) -- ++(0.2, 0) node[right] {$i$};
   \draw (0,-\impart) -- ++(0.2, 0) node[right] {$-i$};
   \draw (-0.5, 0) -- ++(0,-0.2) node[below] {-0.5};
   \draw (-2, 0) -- ++(0,-0.2) node[below] {-2};
   %%\node[red, ] at (0,0) {\large $\times$};
   %\node[red] at (-0.5, \impart) {\large $\times$};
   %\node[red] at (-0.5, -\impart) {\large $\times$};
   %\node[green!80!black,] at (-1, 0) {\large $\circ$};
   %\node[green!80!black] at (-0.5, 0) {\large $\circ$};

   \end{tikzpicture}

 \end{center}

\alert{Activity} Indicate the start- and end points, and the asymptotes.
\end{column}
\end{columns}
\end{frame}

\begin{frame}[label={sec:org73b4861}]{Pair the root locus plots with the correct transfer function}
\begin{columns}
\begin{column}{0.3\columnwidth}
\begin{align*}
G_1(s) &= K\frac{s+2}{s(s+4)}\\ G_2(s) &= K\frac{s+2}{s(s+4)(s+8)}\\
G_3(s) &= K\frac{s+2}{s^2(s+4)}\\ G_4(s) &= K \frac{1}{s^2(s+4)}.
\end{align*}

\begin{center}
 \includegraphics[width=1.0\linewidth]{../../figures/}
\end{center}
\end{column}
\begin{column}{0.7\columnwidth}
\begin{center}
\includegraphics[width=1.0\linewidth]{../../figures/rlocus_2x2-crop}
\end{center}
\end{column}
\end{columns}
\end{frame}
\end{document}