\documentclass[a5paper]{book}

\usepackage{matex}

\begin{document}

\titlePage{ $ Algebraic Equations $ }{ $ Martin Azpillaga $ }

\part{ $ Definitions $ }

\chapter{ $ Roots of unity, Extensions and Galois Group $ }

\introduction
{
	$
	In this first chapter, we discuss the definitions involved in the subsequent three sections:\\
	1. Roots of the unity who form cyclotomic polynomials and cyclotomic fields.\\
	2. Algebraic and Transcendent extensions over fields. Normal extensions.\\
	3. Galois Group of an algebraic extension.
	$
}

\section{ $ Roots of unity $ }
{
	\subsection{ $ nth root of unity $ }

	\letbe
	{
		K $ field $.
		n \in \N.
		x \in \K
	}
	\then{ x }{ $ a nth root of unity in $ K }
	{
		x^n = 1
	}
	\denote
	{
		\set{ x \in \K }[ x^n = 1 ] \as \mu_n(\K).
		\set{ x \in \K }[ \ex{ n \in \N }{ x^n = 1 } ] \as \mu(K)
	}

	\subsection{ $ nth Primitive root of unity $ }

	\letbe
	{
		K $ field $.
		x \in \mu_n(K)
	}
	\then{ x }{ $ a primitive root of unity in $ K }
	{
		\order{ x } = n
	}
	\denote
	{
		\set{ x \in \mu_n(\K) }[ \order{ x } = n ] \as \mu_n^*(K)
	}

	\subsection{ $ nth Cyclotomic Polynomial $ }

	\letbe
	{
		n \in \N
	}
	\call{ $ nth Cyclotomic Polynomial $ }
	{
		f(X) = \productoryoverset{ (X - \zeta ) }{ \zeta }{ \mu_n^*(\K) } \in \C[X]
	}
	\denote
	{
		f(X) \as \Phi_n(X)
	}

	\subsection{ $ Mobius' function $ }

	\call{ $ Mobius' function $ }
	{
		\definedfunction{ f }{ \N }{ \set{ 0,+1,-1 } }{ x }{ \multiple[ \{ ]
		{
			+1, \qquad n = 1.
			+0, \qquad \ex{ p \in \N }{ p $ prime $ \logicand a^2 | n }.
			-1, \qquad *
		} }
	}
	\denote
	{
		f \as \mu
	}

	\newpage

}

\section{ $ Classification of Field Extensions $ }
{
	\subsection{ $ Field Extension $ }

	\letbe
	{
		K, k $ fields $
	}
	\then{ K }{ $ an extension of $ k }
	{
		k \subset K
	}
	\denote
	{
		k \subset K \as K|k
	}

	\subsection{ $ Algebraic extension $ }

	\letbe
	{
		K|k $ field extension $
	}
	\then{ \theta \in K }{ $ an algebraic element over $ k }
	{
		\ex f(X) \in k[X] \suchthat f(\theta) = 0
	}
	\then{ K|k }{ $ an algebraic extension $ }
	{
		\all{ \theta \in K }
		{
			\theta $ algebraic over $ k
		}
	}
	\denote
	{
		K|k $ no algebraic extension $ \as K|k $ transcendent extension $
	}

	\subsection{ $ Cyclotomic Extension $ }

	\letbe
	{
		n \in \N.
		\zeta \in \mu_n^*(\C)
	}
	\call{ $ nth cyclotomic field $ }
	{
		Q( \zeta ) \extends \Q
	}

	\subsection{ $ Quadratic extension $ }

	\letbe
	{
		k $ field $ \suchthat car(k) \neq 2.
		K|k $ field extension $
	}
	\then{ K|k }{ $ a quadratic extension $ }
	{
		[ K : k ] = 2
	}

	\subsection{ $ Normal Extension $ }

	\letbe
	{
		K|k $ algebraic extension $
	}
	\then{ K|k }{ $ a normal extension over $ k }
	{
		\ex{ f(X) \in k(X) $ irreductible $ }{ f(X) $ splits in $ K }
	}

	\subsection{ $ Separable extension $ }

	\letbe
	{
		K|k $ algebraic extension $
	}
	\then{ \theta \in K }{ $ a separable element over $ k }
	{
		\ex{ f(X) \in k[X] }{ f(\theta) = 0 \logicand f(X) $ separable in $ K[X] }
	}
	\then{ K|k }{ $ a separable extension $ }
	{
		\all{ \theta \in K }
		{
			\theta $ separable over $ k
		}
	}

	\subsection{ $ Simple extension $ }

	\letbe
	{
		K \extends k $ field extension $.
	}
	\then{ K \extends k }{ $ a simple extension $ }
	{
		\ex{ \theta \in K }{ K = k(\theta) }
	}
	\denote
	{
		\theta \as $ primitive element of $ K \extends k
	}

	\subsection{ $ Galois extension $ }

	\letbe
	{
		K \extends k $ algebraic extension $
	}
	\then{ K \extends k }{ $ a Galois extension $ }
	{
		K \extends k $ normal extension $.
		K \extends k $ separable extension $
	}

}

\section{ $ Properties of field extensions $ }
{
	\subsection{ $ Evaluation function $ }

	\letbe
	{
		K|k $ field extension $.
		\theta \in K
	}
	\call{ $ Evaluation function of $ \theta $ over $ k }
	{
		\definedfunction{ f }{ k[X] }{ K }{ p(X) }{ p(\theta) }
	}
	\denote
	{
		f \as \Psi_\theta.
		Im \; \psi_\theta \as k[\theta].
		$ fraction field of $ k[\theta] \as k(\theta)
	}

	\subsection{ $ Minimal Polynomial $ }

	\letbe
	{
		K|k $ field extension $.
		\theta \in K $ algebraic over $ k
	}
	\call{ $ Minimal Polynomial of $ \theta $ in $ K|k }
	{
		f(X) \in k[X] \suchthat \logicand \multiple[ \{ ]
		{
			f(X) \neq 0.
			f(X) $ irreducible $.
			f(\theta) = 0
		}
	}
	\denote
	{
		f(X) \as Irr(\theta,k)(X)
	}

	\subsection{ $ Extension Degree $ }

	\letbe
	{
		K|k $ field extension $
	}
	\call{ $ degree of $ K|k }
	{
		\dim_k K \in \N \cup \set{ \infty }
	}
	\denote
	{
		\dim_k K \as [ K : k ].
		[K:k] \in \N : K|k $ finite extension $
	}

	\newpage

	\subsection{ $ Splitting field $ }

	\letbe
	{
		k $ field $.
		f \in k[X].
		\family{ \theta_i }{ i }[ 1 ][ n ] $ roots of $ f
	}
	\call{ $ splitting field of $ f }
	{
		k \vect{ \theta_i }{ i }[ 1 ][ n ]
	}

	\subsection{ $ Field Composition $ }

	\letbe
	{
		K_1|k, K_2|k $ field extensions $
	}
	\call{ $ the composition of $ K_1 $ and $ K_2 }
	{
		<K_1,K_2>
	}
	\denote
	{
		<K_1,K_2> \as K_1K_2
	}

	\subsection{ $ Separability degree $ }

	\letbe
	{
		k|k $ algebraic extension $.
		\closed{k} $ algebraic closure of $ k
	}
	\call{ $ separability degree of $ K|k }
	{
		\# \set{ \sigma \in \functionspace{ K }{ \closed{k} } }[ \sigma \; k$-immersion$ ]
	}
	\denote
	{
		\# \set{ \sigma \in \functionspace{ K }{ \closed{k} } }[ \sigma \; k$-immersion$ ] \as [K:k]_s
	}
}

\section{ $ Galois Group $ }
{

	\subsection{ $ Fixed Field $ }

	\letbe
	{
		K_1, K_2 $ fields $.
		\function{ \sigma }{ K_1 }{ K_2 }
	}
	\call{ $ the fixed field of $ k_1 $ by $ \sigma }
	{
		\set{ x \in K_1 }[ \sigma(x) = x ]
	}
	\denote
	{
		\set{ x \in K_1 }[ \sigma(x) = x ] \as K_1^\sigma
	}

	\newpage

	\subsection{ $ k-Immersion $ }

	\letbe
	{
		K_1|k, K_2|k $ field extensions $.
		\function{ \sigma }{ K_1 }{ K_2 }
	}
	\then{ \sigma }{ $ a $k$-immersion $ }
	{
		k \subset K_1^\sigma
	}
	\denote
	{
		\sigma \; k $-immersion $ \logicand \sigma $ automorphism $ \as \sigma $ $ k $-automorphism $
	}

	\subsection{ $ k-Automorphism $ }

	\letbe
	{
		K \extends k $ field extensions $.
		\function{ \sigma }{ K }{ K }
	}
	\then{ \sigma }{ $ a $k$-automorphism $ }
	{
		\sigma \; k$-immersion$.
		\sigma $ isomorphism $
	}
	\denote
	{
		\sigma \; k $-immersion $ \logicand \sigma $ automorphism $ \as \sigma $ $ k $-automorphism $
	}

	\subsection{ $ Galois Group $ }

	\letbe
	{
		K|k $ field extension $
	}
	\call{ $ Galois group of $ K|k }
	{
		\set{ \sigma \in \functionspace{ K }{ K } }[ \sigma $ $ k $-autmorphism $ ]
	}
	\denote
	{
		\set{ \sigma \in \functionspace{ K }{ K } }[ \sigma $ $ k $ autmorphism $ ] \as Gal(K|k)
	}

	\newpage

}

\section{ $ Finite Fields $ }
{

	\subsection{ $ Finite Field $ }

	\letbe
	{
		k $ field $
	}
	\then{ k }{ $ a finite field $ }
	{
		\# k \in \N
	}
	\denote
	{
		\ex{ p,n \in \N  }{ p $ prime $ \logicand \# k = p^n } \as \F_{p^n}
	}

	\subsection{ $ Frobenius' Automorphism $ }

	\letbe
	{
		\F_{p^n} $ finite field $
	}
	\call{ $ Frobenius' automorphism of $ \F_{p^n} }
	{
		\definedfunction{ f }{ \F_{p^n} }{ \F_{p^n} }{ x }{ x^p }
	}
	\denote
	{
		f \as \phin_p
	}

	\newpage

}

\section{ $ Separability $ }
{

}

\section{ $ Norm and trace $ }
{

	\subsection{ $ Norm $ }

	\letbe
	{
		K|k $ finite extension $
	}
	\call{ $ Norm of $ K|k }
	{
		\definedfunction{ f }{ K }{ k }{ \theta }{ det( m_\theta ) }
	}
	\denote
	{
		f \as N_{K|k}
	}

	\subsection{ $ Trace $ }

	\letbe
	{
		K|k $ finite extension $
	}
	\call{ $ trace of $ K|k }
	{
		\definedfunction{ f }{ K }{ k }{ \theta }{ tr( m_\theta ) }
	}
	\denote
	{
		f \as Tr_{K|k}
	}

	\subsection{ $ Cyclic extension $ }

	\letbe
	{
		K|k $ Galois extension $
	}
	\then{ K|k }{ $ a cyclic extension $ }
	{
		Gal(K|k) $ cyclic $
	}

	\subsection{ $ Abelian extension $ }

	\letbe
	{
		K|k $ Galois extension $
	}
	\then{ K|k }{ $ an abelian extension $ }
	{
		Gal(K|k) $ abelian $
	}

	\subsection{ $ Resoluble by radicals $ }

	\letbe
	{
		k $ field $.
		f(X) \in k[X]
	}
	\then{ f(X) }{ $ resoluble by radicals $ }
	{
		\ex{ K|k }{ K|k $radical extension $ }
	}
	\denote
	{
		property \as notation.
	}
}

\part{ $ Propositions $ }

\chapter{ $ Roots of unity, Field extensions and Galois Group $ }

\introduction
{
	$
	Basic propositions over:\\
	1. Roots of unity. \\
	2. Field extensions. \\
	3. Galois Group
	$
}

\section{ $ Roots of unity $ }
{

	\subsection{ $ The Group of Roots of Unity $ }

	\letbe
	{
		K $ field $
	}
	\proposition
	{
		\mu(K) \substructure K^*
	}
	\demonstration
	{
		\all{ x,y \in \mu(K) }
		{
			1
		}
		\mu(K) \substructure K^*
	}
	\newpage

	\subsection{ $ The group of nth roots $ }

	\letbe
	{
		K $ field $.
		n \in N
	}
	\proposition
	{
		\mu_m(K) \normal K^*
	}
	\demonstration
	{
		$ Follow 3 steps $.

		\step{ 1 }{ \mu_n(K) \subset K^* }
		{
			\mu_n(K) \subset \mu(K) \subset K^*
		}.

		\step{ 2 }{ $ Define a group morphism $ }
		{
			\definedfunction{ \phi_n }{ K^* }{ K^* }{ x }{ x^n }.

			\all{ x,y \in K^* }
			{
				\phi_n(x)\phi_n(y) = x^ny^n = (xy)^n = \phi_n(xy)
			}
		}

		\step{ 3 }{ $ Identify $ \mu_n(K) $ with the kernel $ }
		{
			Ker \phi_n = \mu_n(K)
		}

	}
	\newpage

	\subsection{ $ Finite subgroups of the multiplicative group $ }

	\letbe
	{
		K $ field $.
		G \substructure K^* $ finite $
	}
	\proposition
	{
		\ex{ m \in \N }{ G = \mu_m(K) }.
		G $ cyclic $
	}
	\demonstration
	{
		$ Follow 2 steps $.

		\step{ 1 }{ $ Find $ m }
		{
			\be{ m }{ \max \set{ \order{ x } }[ x \in G ] } \in \N.

			\all{ x \in G }
			{
				\order{x} \divides m \imp x^m = 1.

				x \in \mu(K)
			}

			G = \mu_m(K)

		}

		\step{ 2 }{ G $ cyclic $ }
		{
			\ex{ \zeta \in G }{ \order{\zeta} = m }.

			<\zeta> \subset G = \mu_m(K).

			\multiple[ \{ ][ \} ]
			{
			 	\card{ G } \geq \order{\zeta} = m.
			 	\card{ G } \leq \card{\mu_m(K)} \leq m
			} \imp \card{ G } = m.

			G = <\zeta> \imp G $ cyclic $
		}
	}
	\newpage

	\subsection{ $ Characterization of nth roots by cyclotomic polynomials $ }

	\letbe
	{
		n \in \N
	}
	\proposition
	{
		X^n-1 = \prod_{ d \divides n } \Phi_d(X)
	}
	\demonstration
	{
		\be{ f(X) }{ X^n-1 } \in \C[X].

		\be{ g(X) }{ \prod_{d \divides n} \Phi_d(X) } \in \C[X].

		$ Follow 3 steps $.

		\step{ 1 }{ f(X) $ and $ g(X) $ have the same roots $ }
		{
			\all{ x \in \C }[ f(x) = 0 ]
			{
				x \in \mu_n(\C).

				\be{ d }{ \order{x} } \in \N.

				x \in \mu_d^*(\C) \imp \Phi_d(x) = 0 \imp g(x) = 0
			}

			\all{ y \in \C }[ g(y) = 0 ]
			{
				\ex{ d \in \N }{ d|n \logicand \Phi_d(y) = 0 }.

				y \in \mu_d^*(\C) \imp y^d = 1 \imp y^n = 1 \imp f(y) = 06
			}
		}

		\step{ 2 }{ f(X) $ and $ g(X) $ are monic $ }
		{
			f $ monic $.

			\all{ d \in \N }[ d \divides n ]
			{
				\Phi_d(X) $ monic $
			}

			g(X) $ monic $
		}

		\step{ 3 }{ f(X) $ and $ g(X) $ are separable $ }
		{
			D(f(X)) = nX^{n-1}.

			mcd \set{ X^n-1, nX^{n-1} } = 1.

			f(X) $ separable $.

			\all{ x \in \C }[ x \in \mu_d^*(\C) ]
			{
				\all{ d' \in \N }[ d \divides n \logicand d' \neq d ]
				{
					x \nin \mu_{d'}^*(\C)
				}
			}

			g(X) $ separable $
		}

		f(X) = g(X)

	}
	\newpage

	\subsection{ $ Mobius' lemma $ }

	\letbe
	{
		n \in \N
	}
	\proposition
	{
		\sum_{d \divides n } \mu(d) = 0
	}
	\demonstration
	{
		\ex{ \family{ p_i}{ i }[ 1 ][ r ], \family{ a_i }{ i }[ 1 ][ r ] \subset \N }{ \productory{ p_i^{a_i} }{ i }[ 1 ][ r ] $ prime factorization of $ n}.

		\all{ d \in \N }[ d \divides n ]
		{
			\ex{ \family{ b_i }{ i }[ 1 ][ r ] \subset \N }{ \all{ i \in \indexes{1}{r} }
			{
				b_i \leq a_i.
				\productory{ p_i^{b_i} }{ i }[ 1 ][ r ] $ prime factorization of $ n
			} }

			\mu(d) \neq 0 \ifandonlyif \all{ i \in \indexes{1}{r} }
			{
				b_i \in \set{ 0,1 }
			}
		}

		\sum_{d \divides n } \mu(d) = \sumatory{ \combinatory{ r }{ k } (-1)^k }{ k }[ 0 ][ r ] = \sumatory{ \combinatory{ r }{ k } (-1)^k1^{r-k} }{ k }[ 0 ][ r ] = (-1+1)^r = 0
	}
	\newpage

	\subsection{ $ Recursive formula for cyclotomic polynomials $ }

	\letbe
	{
		n \in \N
	}
	\proposition
	{
		\Phi_n(X) = \prod_{d \divides n} (X^d - 1)^{\mu(\frac{n}{d})}
	}
	\demonstration
	{
		\prod_{d|n}(X^d-1)^{\mu(\frac{n}{d})} =.

		= \prod_{d|n}(X^{\frac{n}{d}}-1)^{\mu(d)} =.

		= \prod_{d|n} \prod_{\delta|\frac{n}{d}} \Phi_{\delta}(X)^{\mu(d)}.

		= \prod_{\delta|n} \prod_{d|\frac{n}{\delta}} \Phi_{\delta}(X)^{\mu(d)} =.

		= \prod_{\delta|n} \Phi_{\delta}(X)^{\sum_{d|\frac{n}{\delta}} \mu(d)}.

		\sum_{d|\frac{n}{\delta}} \mu(d) \neq 0 \ifandonlyif \delta = n.

		\prod_{\delta|n} \Phi_{\delta}(X)^{\sum_{d|\frac{n}{\delta}} \mu(d)} = \Phi_n(X)^1 = \Phi_n(X)
	}
	\newpage

	\subsection{ $ Classification of cyclotomic polynomials $ }

	\letbe
	{
		n \in \N
	}
	\proposition
	{
		\Phi_n(X) \in \Z[X]
	}
	\demonstration
	{
		\Phi_n(X) = \prod_{d|n}(X^{\frac{n}{d}}-1)^{\mu(d)}.

		\mu(d) = 1 \ifandonlyif d = 1 \imp \Phi_n(X) = \frac{ X^n - 1 }{\prod_{1<d|n}(X^{\frac{n}{d}}-1)^{\mu(d)}}.

		\be{ f(X) }{ X^n - 1 }.

		\be{ g(X) }{ \prod_{1<d|n}(X^{\frac{n}{d}}-1)^{\mu(d) }}.

		\Phi_1(X) = X - 1 \in \Z[X] \imp $ induction $ \imp g(X) \in \Z[X].

		\multiple[ \{ ][ \} ]
		{
			f(X), g(X) $ monics $.
			f(X), g(X) \in \Z[X]
		}\imp \Phi_n(X) = \frac{f(X)}{g(X)} \in \Z[X]
	}
	\newpage

	\subsection{ $ Irreductibility of cyclotomic polynomials $ }

	\letbe
	{
		n \in \N
	}
	\proposition
	{
		\Phi_n(X) $ irreductible over $ \Q[X]
	}
	\demonstration
	{
		I dont want to do this
	}
	\newpage
}

\section{Extensiones de cuerpos}
{

	\subsection{ $ Classification of the image of the evaluation function $ }

	\letbe
	{
		K \divides k $ field extension $.
		\theta \in K
	}
	\proposition
	{
		\theta $ algebraic over $ k \imp k[\theta] = k(\theta).
		\theta $ transcendent over $ k \imp k[\theta] \isomorph k(\theta)
	}
	\demonstration
	{
		$ Separate 2 cases: $.

		\case{ \theta $ algebraic over $ k }
		{
			k $ field $ \imp k $ PID $ \imp k[X] $ PID $.

			Ker(\Phi_\theta) $ principal $ \imp \ex{ f(X) \in k[X] }{ Ker(\Phi_\theta) = (f(X)) }.

			K $ field $ \imp K $ integral domain $.

			k[\theta] \subset K \imp k[\theta] $ integral domain $.

			$ Isomorphy theorem :$ k[X]/f(X) \isomorph k[\theta].

			\multiple[ \{ ][ \} ]
			{
				k[X]/f(X) \isomorph k[\theta].
				k[\theta] $ integral domain $
			} \imp (f(X)) $ prime ideal $.

			k[X] $ UFD $ \imp (f(X)) $ irreductible ideal $ \imp (f(X)) $ maximal ideal $.

			k[X]/(f(X)) $ field $ \imp k[\theta] $ field $.

			k[\theta] = k(\theta)
		}
		\case{ \theta $ transcendent over $ k }
		{
			Ker( \Psi_\theta ) = (0).

			$Isomorphy theorem: $ k[\theta] \isomorph k[X]/(0) \isomorph k[X]
		}

	}
	\newpage

	\subsection{ $ Inclusion of finite extensions in algebraic extensions $ }

	\letbe
	{
		K \extends k $ finite field extension $
	}
	\proposition
	{
		K \extends k $ algebraic extension $
	}
	\demonstration
	{
		\all{ \theta \in K }
		{
			\be{ n }{ dim_k K } \in \N.

			\family{ \theta^i }{ i }[ 0 ][ n ] $linearly dependent$.

			\ex{ \family{ a_i }{ i }[ 0 ][ n ] \subset k }{ \ex{ i \in \indexes{1}{n} }{ \sumatory{ a_i\theta^i }{ i }[ 0 ][ n ] = 0 } }.

			\be{ f(X) }{ \sumatory{ a_i\theta^i }{ i }[ 0 ][ n ] } \in k[X].

			f(X) \neq 0 \logicand f(\theta) = 0 \imp \theta $ algebraic over $ k
		}

		K \extends k $ algebraic extension $
	}
	\newpage

	\subsection{ $ Degree behaviour in extension towers $ }

	\letbe
	{
		K \extends k, L \extends K $ field extensions $
	}
	\proposition
	{
		[L:k] = [L:K][K:k]
	}
	\demonstration
	{
		\exists \; \family{ \theta_i }{ i } \subset K \; k$-base of $ K.

		\exists \; \family{ \theta'_j }{ j } \subset K \; K$-base of $ L.

		\all{ \theta \in K }
		{
			\ex{ \family{ a'_k }{ j } \subset K }{ \theta = \sumatory{ a'_j\theta'_j }{ j } }.

			\all{ j \in J }
			{
				\ex{ \family{ a_{i,j} }{ i } \subset k }{ a'_j = \sumatory{ a'_{i,j}\theta_i }{ i } }
			}

			\theta = \sumatory{ a_{i,j}\theta_i\theta'_j }{ (i,j) }

		}

		\set{ \theta_i\theta'_j}_{(i,j) \in I \times J } \; k-$base of $ L.

		[L:k] = dim_k L = \# (I \times J) = \#I \cdot \#J = [K:k][L:K]
	}
	\newpage

	\subsection{ $ Degree behaviour in base exchanges $ }

	\letbe
	{
		K \extends k, L \extends k $ finite extensions $
	}
	\proposition
	{
		[KL:K] \leq [L:k]
	}
	\demonstration
	{
		\be{ n }{ dim_k L } \in \N.

		\ex{ \family{ \theta_i }{ i }[ 1 ][ n ] \subset L }{ L = k \vect{ \theta_i }{ i }[ 1 ][ n ] }.

		KL = K \vect{ \theta_i }{ i }[ 1 ][ n ].

		[KL:K] = \productory{ [K \vect{ \theta_i }{ i }[ 1 ][ r+1 ] : K \vect{ \theta_i }{ i }[ 1 ][ r ] ] }{ r }[ 1 ][ n-1 ].

		[L:k] = \productory{ [k \vect{ \theta_i }{ i }[ 1 ][ r+1 ] : k \vect{ \theta_i }{ i }[ 1 ][ r ] ] }{ r }[ 1 ][ n-1 ].

		\all{ r \in \indexes{1}{n-1} }
		{
			k \subset K \imp k \vect{ \theta_i }{ i }[ 1 ][ r ] \subset K \vect{ \theta_i }{ i }[ 1 ][ r ].

			[K \vect{ \theta_i }{ i }[ 1 ][ r+1 ] : K \vect{ \theta_i }{ i }[ 1 ][ r ] ] \leq [k \vect{ \theta_i }{ i }[ 1 ][ r+1 ] : k \vect{ \theta_i }{ i }[ 1 ][ r ]
		}

		[KL:K] \leq [L:k]
	}
	\newpage
}

\section{ $ Classification of field extensions $ }
{

	\subsection{ $ Invariancy of Cyclotomic prime extensions by composition and intersection $ }

	\letbe
	{
		n,m \in \N \suchthat mcd(n,m) = 1.
		\Q(\zeta_n) \extends \Q(\zeta_m) $ cyclotomic extensions $
	}
	\proposition
	{
		\Q(\zeta_n,\zeta_m) = \Q(\zeta_n\zeta_m)

		\Q(\zeta_n) \cap \Q(\zeta_m) = \Q
	}
	\demonstration
	{
		$ Follow 2 steps $.

		\step{ 1 }{ \Q(\zeta_n,\zeta_m) $ cyclotomic extension $ }
		{
			\rightinclusion
			{
				\order{ \zeta_n\zeta_m } = \order{ \zeta_n }\order{ \zeta_m } = \phin(n)\phin(m).

				mcd(m,n) = 1 \imp \phin(n)\phin(m) = \phin(nm) \imp \zeta_n\zeta_m \in \mu_{nm}(\C).

				\be{ \zeta }{ \zeta_n\zeta_m } \in \mu_{nm}(\C).

				(\zeta^m)^n = 1 \imp \zeta^m \in \mu_n(\C).

				\ex{ r \in \N }{ (\zeta^m)^r = \zeta_n }.

				\zeta_n \in \Q(\zeta).

				\similarly{ \zeta_m \in \Q(\zeta) }.

				\Q(\zeta_n,\zeta_m) \subset \Q(\zeta)
			}
			\leftinclusion
			{
				\zeta_n, \zeta_m \in \Q(\zeta_n,\zeta_m) \imp \zeta_n\zeta_m \in \Q(\zeta_n,\zeta_m)
			}
		}

		\step{ 2 }{ \Q(\zeta_n) \cap \Q(\zeta_m) = \Q }
		{
			[\Q(\zeta_n,\zeta_m):\Q] = [\Q(\zeta_m,\zeta_n):\Q(\zeta_n)][ \Q(\zeta_n) : \Q].

			\phin(mn) = [\Q(\zeta_m,\zeta_n) : \Q(\zeta_n)]\phin(n).

			[\Q(\zeta_m,\zeta_n): \Q(\zeta_n) ] = \phin(m).

			[\Q(\zeta_m,\zeta_n): \Q(\zeta_n) ] \leq [ \Q(\zeta_m) : \Q(\zeta_m) \cap \Q(\zeta_n) ] \leq [\Q(\zeta_m) : \Q ].

			\phin(m) \leq [ \Q(\zeta_m) : \Q(\zeta_m) \cap \Q(\zeta_n) ] \leq \phin(m).

			[ \Q(\zeta_m) : \Q(\zeta_m) \cap \Q(\zeta_n) ] = \phin(m).

			[\Q(\zeta_m) \cap \Q(\zeta_n) : \Q ] = \frac{ \phin(m) }{ \phin(m) } = 1.

			\Q(\zeta_m) \cap \Q(\zeta_n) = \Q
		}
	}
	\newpage

	\subsection{ $ Inclusion of Quadratic extensions in Simple extensions $ }

	\letbe
	{
		K \extends k $ quadratic extension $
	}
	\proposition
	{
		K \extends k $ simple extension $
	}
	\demonstration
	{
		[K : k ] = 2 \imp \ex{ \theta \in K }{ \theta \nin k }.

		k \subset k(\theta) \subset K.

		2 = [ K : k ] = [ K : k(\theta) ][k(\theta):k].

		\theta \nin k \imp [k(\theta):k] \geq 2.

		[K : k(\theta) ] = 1 \imp K = k(\theta).

		K \extends k $ simple extension $
	}
	\newpage

	\subsection{ $ Inclusion of Quadratic extensions in Normal extensions $ }

	\letbe
	{
		K \extends k $ quadratic extension $
	}
	\proposition
	{
		K \extends k $ normal extension $
	}
	\demonstration
	{
		K \extends k $ quadratic extension $ \imp K \extends k $ simple extension $.

		\ex{ \theta \in K }{ \theta \nin k \logicand K = k(\theta) }.

		\set{ 1,\theta } k$-base of $ K.

		\set{ 1,\theta, \theta^2 } $ linearly dependent $ \imp \ex{ b,c \in k }{ \theta^2 + b\theta + c = 0 }.

		\be{ \eta }{ 2\eta + b } \in K.

		\eta^2 = 4\eta^2 + b^2 + 4b\eta = b^2 - 4c \in k.

		\be{ f(X) }{ X^2 - \eta^2 } \in k[X].

		\eta, -\eta \nin k \imp f(X) $ irreductible over $ k[X].

		\eta, -\eta \in K \imp f(X) $ splits over $ K[X].

		k(\theta) $ splitting field of $ f(X).

		K \extends k $ normal extension $

	}
	\newpage

}

\section{ $ Galois Group $ }
{

	\subsection{ $ Determination of automorphisms by minimal polynomial root images $ }

	\letbe
	{
		K \extends k $ algebraic extension $.
		f(X) $ irreductible over $ k[X].
		\theta, \theta' \in K $ roots of $ f(X)
	}
	\proposition
	{
		\ex{ ! \; \function{ \sigma }{ k(\theta) }{ k(\theta') } }{ \sigma \; k$-automorphism $ \logicand \sigma(\theta) = \theta' }
	}
	\demonstration
	{
		$ Follow 2 steps $.

		\step{ 1 }{ $ Existence of $ \sigma }
		{
			\exists \rho: k[X]/(Irr(\theta,k)(X)) \to k(\theta) $ isomorphism $.

			\exists \rho': k[X]/(Irr(\theta',k)(X)) \to k(\theta') $ isomorphism $.

			\be{ \sigma }{ \rho' \circ \rho^{-1} } \in \functionspace{ k(\theta) }{ k(\theta') }.

			\sigma $ isomorphism $
		}

		\step{ 2 }{ \sigma $ determined by $ \theta $'s image $ }
		{
			\all{ \function{ \sigma' }{ k(\theta) }{ k(\theta') } }[ \sigma' \; k$-isomorphism $ \logicand \sigma'(\theta) = \theta' ]
			{
				\all{ x \in k(\theta) }
				{
					\ex{ \family{ a_i }{ i }[ 1 ][ r ] \subset k }{ x = \sumatory{ a_i\theta^i }{ i }[ 1 ][ r ] }.

					\sigma'(x) = \sumatory{ \sigma'(a_i)\sigma'(\theta)^i }{ i }[ 1 ][ r ] = \sumatory{ a_i\theta'^i }{ i }[ 1 ][ r ].

					\sigma(x) = \sigma'(x)
				}

				\sigma' = \sigma
			}
		}
	}
	\newpage

	\subsection{ $ Inclusion of immersions in automorphims $ }

	\letbe
	{
		K \extends k $ algebraic extension $.
		\function{ \sigma }{ K }{ K } k$-immersion$
	}
	\proposition
	{
		\sigma \in Aut(K)
	}
	\demonstration
	{
		demonstration.
	}
	\newpage

	\subsection{ $ Fundamental theorem of Galois theory $ }

	\letbe
	{
		K \extends k $ algebraic extension $.
		S(Gal(K \extends k)) $ set of all subgroups of $ Gal(K \extends k).
		C(K \extends k) $ set of all subfields between $ K \extends k
	}
	\proposition
	{
		\ex{ \phi \in \functionspace{ S(Gal(K \extends k) }{ C(K \extends k) } }{ \phi $ biyective $ }
	}
	\demonstration
	{
		demonstration.
	}
	\newpage

}
\section{ $ Finite Fields $ }
{

	\subsection{ $ Fermat's little theorem $ }

	\letbe
	{
		\F_{p^n} $ finite field $
	}
	\proposition
	{
		\all{ x \in \F }[ x \neq 0 ]
		{
			x^{p^n-1} = 1
		}.

		\all{ x \in \F }
		{
			x^{p^n} = x
		}
	}
	\demonstration
	{
		$ Separate 2 cases: $.

		\case{ x = 0 }
		{
			0^{p^n} = 0
		}
		\case{ x \neq 0 }
		{
			\order{ x } \divides \card{ F^* } = p^n-1.

			x^{p^n-1} = 1 \imp x^p = x
		}
	}
	\newpage

	\subsection{ $ Polynomials over finite prime fields $ }

	\letbe
	{
		\F_p $ finite field $.
		f(X) \in \F_p[X]
	}
	\proposition
	{
		f(X)^p = f(X^p)
	}
	\demonstration
	{
		\all{ i \in \family{ k }{ k }[ 1 ][ p-1 ] \subset \N  }
		{
			p \divides \combinatory{p}{i} \imp \combinatory{p}{i} \congruent{p} 0
		}

		\all{ a,b \in \F_p }
		{
			(a+b)^p = \sumatory{ \combinatory{p}{i} a^ib^{p-i} }{ i }[ 0 ][ p ] \congruent{p} a^p + b^p
		}

		\be{ n }{ gr(f(X)) } \in \N.

		\ex{ \family{ a_i }{ i }[ 0 ][ n ] \subset \F_p }{ f(X) = \sumatory{ a_iX^i }{ i }[ 0 ][ n ] }.

		f(X)^p = \sumatory{ a_i^pX^{pi} }{ i }[ 0 ][ n ].

		$Fermat's little theorem$ \imp f(X)^p \congruent{p} \sumatory{ a_i(X^p)^i }{ i }[ 0 ][ n ] \congruent{p} f(X^p)
	}
	\newpage

	\subsection{ $ Classification of characteristic and order $ }

	\letbe
	{
		\F $ finite field $
	}
	\proposition
	{
		\ex{ p \in \N }{ p $ prime $ \logicand car(\F) = p }.

		\ex{ r \in \N }{ \# \F = p^r }
	}
	\demonstration
	{
		demonstration.
	}
	\newpage

	\subsection{ $ Cyclotomic finite fields $ }

	\letbe
	{
		let.
	}
	\proposition
	{
		proposition.
	}
	\demonstration
	{
		demonstration.
	}
	\newpage

	\subsection{ $ Determination of Galois group over Finite fields $ }

	\letbe
	{
		q \in \N $ prime power $.
		n \in \N
	}
	\proposition
	{
		Gal( \F_{q^n} \extends \F_q ) = < \phin_q >
	}
	\demonstration
	{
		demonstration.
	}
	\newpage
}

% \subsection{Los carácteres ciclotómicos son isomorfismos de grupos}

% \sean

% \item $\f{\chi_n}{Gal(\Q(\zeta_n) | \Q ) }{ \Z/n\Z }$ carácter ciclotómico $n$-ésimo

% \teorema

% \item $\chi_n$ isomorfismo de grupos

% \demostracion

% \item Bien definido

% $\sigma|_\Q(\zeta_n)^*$ automorfismo de grupos

% $\order{ \sigma( \zeta_n ) } = \order{ \zeta_n } \rightarrow \sigma( \zeta_n ) \in \mu_n(\Q(\zeta_n))$

% $\nex{ r }{ (\Z/n\Z)^* }{ \sigma(\zeta_n) = \zeta_n^r }$

% $\chi(\sigma) \in \Z/n\Z$

% \item Independiente de la raíz n-ésima

% \nall{ \zeta_n' }{ \mu_n(\C) }{

% $\nex{ r }{ (\Z/n\Z)^* }{ \zeta_n' = \zeta_n^r }$

% $\sigma(\zeta_n') = \sigma(\zeta_n^r) = \sigma(\zeta_n)^r = \zeta_n^{\chi(\sigma)r} = \zeta_n'^{\chi(\sigma)}$

% }

% \item Morfismo de grupos

% \nall{ \sigma, \tau }{ Gal( \Q(\zeta_n) | \Q ) }{

% $(\zeta_n)^{\chi(\sigma\circ\tau)} = (\sigma\circ\tau)(\zeta_n) = \sigma(\tau(\zeta_n)) = \sigma(\zeta_n^{\chi(\tau)}) = \sigma(\zeta_n)^{\chi(\tau)} = \zeta_n^{\chi(\tau)\chi(\sigma)}$

% $ \chi( \sigma \circ \tau ) = \chi(\sigma) \chi(tau)$

% }

% \item Inyectivo

% \nall{ \sigma, \tau }{ Gal( \Q(\zeta_n) | \Q ) }{

% $\chi(\sigma) = \chi(\tau)$

% $\sigma(\zeta_n) = \tau(\zeta_n)$

% \nall{ q }{ \Q }{

% $\sigma( q ) = \tau( q ) = q$

% }

% $\sigma = \tau$

% }

% \item Exhaustivo: \nall{ r }{ (\Z/n\Z)^* }{

% $\ex \f{\rho}{\Q(\zeta_n)}{\Q(\zeta_n)} \tq \rho(\zeta_n) = \zeta_n^r$

% }

% \fin{}

% \subsection{El subcuerpo de cuerpos ciclotómicos que queda fijo por todo automorfismo}

% \sean

% \item $\zeta_n \in \mu_n(\C)$
% \item $K < \Q(\zeta_n)$

% \teorema

% \item $K$ fijo para todo automorismo de $\Q(\zeta_n) \leftrightarrow K = \Q$

% \demostracion

% \item $\sea{ \zeta }{\zeta_n}$

% $\sea{ G }{ Gal( \Q(\zeta) | \Q ) }$

% $\sea{K}{ \Q(\zeta)^G }$

% $\Q \subset K \rightarrow K(\zeta) = \Q(\zeta)$

% $\sea{ f(X) }{ Irr(\zeta,K)(X) }$

% \nall{ \sigma }{ G }{

% $f(\sigma(\zeta)) = \sigma(f(\zeta)) = \sigma(0) = 0$

% }

% \nall{ \zeta' }{ \mu_n(\C) }{

% $\zeta'$ raiz de $f(X)$

% }

% $gr(f(X)) > \phin(n) \rightarrow [\Q(\zeta) : K ] > \phin(n)$

% $[\Q(\zeta) : K ] \leq [\Q(\zeta) : \Q ] \rightarrow [\Q(\zeta) : K ] = \phin(n)$

% $[K:\Q] = \frac{[\Q(\zeta) : \Q]}{[\Q(\zeta) : K ]} = 1$

% $K = \Q$

% \fin{\newpage}

% \section{Grupo de Galois}

% \subsection{Existe un unico k-isomorfismo que envia la raiz de una extension a la otra raíz}

% \sean

% \item $K \ext k$, $L \ext k$ extensiones algebraicas de cuerpos
% \item $f(X) \in k[X]$ irreductible
% \item $\theta \in K$, $\theta' \in L$ raíces de f(X)

% \teorema

% \item $ \ex ! \f{ \sigma }{ k(\theta) }{ k(\theta') } \tq \sigma k$-isomorfismo $\y \sigma(\theta) = \theta'$

% \demostracion

% \item Existencia

% $\ex \f{\sigma}{k[X]/(Irr(\theta,k)(X))}{k(\theta)}$ isomorfismo

% $\ex \f{\sigma'}{k[X]/(Irr(\theta',k)(X))}{k(\theta')}$ isomorfismo

% $\sea{\rho}{\sigma'^{-1} \circ \sigma}$

% $\rho$ isomorfismo de $k(\theta)$ a $k(\theta')$

% \item Unicidad

% $\sigma$ $k$-inmersión $\rightarrow \all a \in k: \sigma(a) = a$

% $\threepartfunction{ \sigma : K}{ K }{ a \in k }{ a }{ \theta }{ \theta' }$

% Es la única $k$-inmersión

% \fin{\newpage}

% \subsection{Toda k-inmersión de K en K es un k-automorfismo}

% \sean

% \item $K \ext k$ extension algebraica de cuerpos
% \item $\f{\sigma}{ K }{ K } k-$inmersión

% \teorema

% \item $\sigma$ $k$-automorfismo

% \demostracion

% \item $\sigma$ morfismo de anillos $\rightarrow \sigma$ inyectivo

% Caso $K | k$ finito:

% $\sigma$ endomorfismo inyectivo de espacios vectoriales finito $\rightarrow \sigma$ exhaustivo

% Caso $K | k$ no finito:

% \nall{ \theta' }{ K }{

% $\sea{ f(X) }{ Irr(\theta',k)(X) }$

% $\sea{ K' }{ <k, \theta_i>_{i=1}^r} \tq \theta_i $ raíz de $f(X) \y \theta_i \in K$

% $K'|k$ algebraica $\rightarrow K'|k$ finito

% $\sea{ \sigma' }{ \sigma|_K' }$

% $\sigma'$ $k$-inmersión de $K'$ en $K$

% $\sigma(K') \subset K' \rightarrow \sigma k$-inmersión $K'$ en $K'$

% $K' \ext k$ finito $\rightarrow \sigma'$ $k$-automorfismo

% $\nex{ \theta }{ K' }{ \sigma(\theta) = \theta' }$

% }

% $\sigma$ exhaustivo

% \fin{\newpage}

% \section{ Cuerpos finitos }

% \subsection{La característica de un cuerpo finito es primo y su cardinal potencia de ese primo}

% \sean

% \item $\F$ cuerpo finito

% \teorema

% \item $\nex{ p }{ \N }{ p $primo $\y car(F) = p}$

% \item $\nex{ r }{ \N }{ \#F = p^r }$

% \demostracion

% \item $\ex C $cuerpo $\tq C \iso \Z/p\Z \y C < \F$

% $car(\F) = p$

% $\F$ es $C$-espacio vectorial

% $\sea{ r }{ dim_C \F }$

% $\#F = p^r$

% \fin{}

% \subsection{Los cuerpos finitos de orden primo ampliados por una raíz de la unidad de orden no multiplo de p son cuerpos finitos de orden una potencia de dicho primo}

% \sean

% \item $p \in \N$ primo
% \item $d \in \N \tq p\nmid d$
% \item $\zeta_d \in \mu_d(\cerr{\F_p})$

% \teorema

% \item $\nex{ r }{ \Nm }{ \F_p(\zeta_d) = \F_{p^r}}$

% \item $\all s \in \N \tq d | p^s -1$: $r|s$

% \demostracion

% \item $\F_p(\zeta) \ext \F_p$

% $\sea{ r }{ dim_{\F_p} \F_p(\zeta) }$

% $\# F_p(\zeta) = p^r$

% $\F_{p^r}^*$ cíclico $\y \#\F_{p^r}^* = p^r -1 $

% $d | p^r - 1$

% \item \alltq{ s }{ \N }{ d | p^s -1 }{

% $\zeta \in \mu_{p^s-1}(\cerr{F_p}) \rightarrow \zeta \in \F_{p^s}$

% $\F_{p^r} \subset \F_{p^s} \rightarrow p^r | p^s$

% $r|s$

% }

% \fin{\newpage}

% \subsection{Los grupos de Galois sobre cuerpos finitos están generados por el autormorfismo de Frobenius}

% \sean

% \item $q \in \N$ primo
% \item $n \in \N$

% \teorema

% \item $Gal( \F_{q^n} | \F_q ) = < \phin_q>$

% \demostracion

% \item $[\F_{q^n} : \F_q ] = n$

% $\# Gal( \F_{q^n} | \F_q ) \leq [\F_{q^n} : \F_q ] = n$

% \item $\order{ \phin_q } = n$:

% $\ex{ \zeta }{ \mu_{q^n-1}(\cerr{\F_q}) }{ \F_{q^n} = \F(\zeta)}$

% \nall{ k }{ \Nm }{

% $\phin_{q}^k(\zeta) = (\zeta^q)^k = \zeta^{q^k} = \phin_{q^k}(\zeta)$

% $\phin_q^k = Id \leftrightarrow \zeta^{q^k} = \zeta$

% $\zeta^{q^n-1} = 1 \rightarrow n | k$

% }

% $\order{\phin_q} = n$

% $\# Gal( \F_{q^n} | \F_q ) = n$

% $Gal( \F_{q^n} | \F_q ) =  < \phin_q>$
% \fin{\newpage}

% \subsection{Teoría de Galois sobre cuerpos finitos}

% \sean

% \item $\sea{ \mathcal{S}(q^n,q) }{ \conj{ H \subset Gal( \F_{q^n} \ext \F_q ) }{ H \sub Gal ( \F_{q^n} \ext \F_q )}}$
% \item $\sea{ \mathcal{C}(q^n,q) }{ \conj{ K \ext \F_q }{ \F_{q^n} \ext K }}$

% \teorema

% \item $\ex \f{ \phi }{ \mathcal{S}(q^n, q) }{ \mathcal{C}(q^n,q)} \tq \phi$ biyectiva

% \demostracion

% \item \alltq{ d }{ \N }{ d | n}{

% $Gal(\F_{q^n} \ext \F_{q^d} ) < Gal(\F_{q^n} \ext \F_{q} )$

% }

% $\sea{ \phi(\F_{q^d} \ext \F_{q}) }{ Gal(\F_{q^n} \ext \F_{q^d} ) }$

% \item $\all H < G:$

% $\sea{ phi^{-1}(H) }{ \F_{q^n}^H | \F_q }$

% \item Inversas mutuas

% $\all H < G:$

% $\ex d \in \N \tq d|n \y H = <\phin_q^d>$

% $\F_{q^n}^{<\phin_q^d>} = \F_{q^d}$

% $\phi^{-1}(<\phin_q^d>) = \F_{q^d} \ext \F_q$

% $\phi(\F_{q^d} \ext \F_q) = Gal(\F_{q^n} \ext \F_{q^d}) = <\phin_q^d>$

% \item $\phi \circ \phi^{-1} = Id$

% \fin{}

\end{document}


\section{Clustering}
\smallskip \hrule height 2pt \smallskip

\begin{itemize}
	\item Unsupervised learning: detect patterns in unlabeled data.
		Sometimes labels are too expensive, unclear, etc. to get them.
		Examples:
		\begin{itemize}
			\item group e-mails or search results
			\item find categories of customers
			\item detect anomalous program execuations
		\end{itemize}
	\item Useful when you don't know what you are looking for.
	\item Requires a definition of "similar".  One option: small (squared) euclidean distance.
	\item You can label then use the clusters, or use the clusters for the next level of analysis.
\end{itemize}

\subsection{K-Means}
\begin{itemize}
	\item An iterative clustering algorithm.  \hfill \\
	\item No step size.  Discrete optimization.
	\item Hard assignments.  Each point gets classified by one and only one cluster.
	\item will converge, but may converge on local (not global) optimum.
		\begin{itemize}
			\item Every time you start the algorithm, you could end up n a different place.
			\item Can run it a bunch of times. % week 9 audio
			\item you are running a non-convex optimization: your final output is dependent on your initialization.
		\end{itemize}
	\item you have to chose a number of clusters.
	\item Objective: minimize the distances between each point and closest center.
	\item You want your output to have a large distance between clusters and a small distance between points in a cluster.  (intra vs inter cluster distance).
	You want it to latch onto clumps of the data that are far apart from each other. % week 9 audio
		\begin{itemize}
			\item intra: \hfill \\
				E.g. measure $|x_i - c_i|_2^2$ for each cluster.
			\item inter:  \hfill \\
				Dist between closest two points in different clusters. \hfill \\
				Distance between means.  \hfill \\
				Standard deviation of cluster distances. \hfill \\
		\end{itemize}
\end{itemize}

Pick K random points as cluster means: $c^1, \dots, c^k$.  \hfill \\
Alternate:
\begin{itemize}
	\item Assign each example $x^i$ to the mean $c^i$ that is closest to it
	\item Set each mean $c^i$ to the average of its assigned points.
\end{itemize}
Stop when no points' assignments change. \hfill \\

Minimizing a loss that is a function of the points, assignments, and means:
$$ L( \{ x*i \},  \{ a*j \},   \{ c*k \}) = \sum_i dist(x^i, c^{a^i})$$
Coordinate gradient descent on L.  \hfill \\

More formally:
\begin{itemize}
	\item Data: $\{ x^j | j = 1 \dots n \}$
	\item For $ t = 1 \dots T$:  (or stop if assignments don't change): \hfill \\
		Fix means ($c$) while you change the assignments ($a$): \hfill \\
		\begin{itemize}
			\item for $ j = 1 \dots n$: (recompute cluster assignments):
				$$ a^j = \argmin_i dist(x^j, c^i)  $$
		\end{itemize}
	\item fix assignments ($a$) while you change the means ($c$): \hfill \\
		for $j = 1 \dots k$: (recompute cluster centers)
		$$ c^j = \frac{1}{|\{ i | a^i = j \}|}  \sum_{\{ i | a^i = j \}} x^i$$
\end{itemize}
Note:  the point y with minimum squared Euclidean distance to a set of points {x} is their mean

\includegraphics[width=3.6in]{figures/kmeans_algorithm_example.pdf}

\subsubsection{K-Means gets stuck in local optima.}

\includegraphics[width=1.8in]{figures/k-means_gets_stuck.pdf}

\subsection{Agglomerative Clustering}
Will not converge to a global optimum. \hfill \\  % TA 3/15/2016
Will not always find the true patterns in the data.  \hfill \\  % TA 3/15/2016
It has to deal with the issue of local optima just like k-means (which can prevent you from finding the "true" patterns)

First merge very similar instances. \hfill \\
Then incrementally build larger clusters out of smaller clusters. \hfill \
Limiting the number of pairs of pairs, we can control the number of clusters.
\begin{itemize}
	\item Distance = 0 means each point is its own cluster
        \item Distances = infinity --> all in one cluster.
\end{itemize}

\includegraphics[width=1.0in]{figures/agg_clustering.pdf}

Algorithm:
\begin{itemize}
	\item Maintain a set of clusters.
	\item Initially each instance is its own cluster
	\item Repeat:
		\begin{itemize}
			\item pick the two closest clusters
			\item merge them into a new cluster
			\item stop when there is only one cluster left.
		\end{itemize}
	\item produces not one clustering, but a family of clusterings represented by a dendogram.

		\includegraphics[width=1.0in]{figures/dendogram.pdf}
\end{itemize}

\includegraphics[width=2.7in]{figures/agglomerative_clustering_distance_options.pdf}

The intra-cluster distance: a metric of how well the clustering algorithm works
$$ S_1 = \sum_{j=1}^3 \sum_i |x_i - x_c|_2^2 + \sum_{i,j} |c_j, c_i|_2^2 $$ % wk 9 audio

You have to be extremely lucky to find a data set where the result isn't dependent on the start.

Can run it a bunch of times. % week 9 audio
For each pair of points, we have a vote:  \hfill \\
Do they belong to the same cluster? \hfill \\
Look at score from score of clustering algorithm \hfill \\
We get a full graph where edge scores are "do they belong to the same 					cluster"  (and more audio I missed?) \hfill \\
Then you need to find out which components are connected.  \hfill \\

For each pair of points, we have an edge distance.  \hfill \\
Within-cluster edges should be strong edges.    \hfill \\
This strength should be common across clustering results.  \hfill \\
Cut the graph into three pieces.    \hfill \\
The score of the cut is the summation of the edges you break.   \hfill \\
Cutting edges with small scores is good.   \hfill \\

\subsection{Probabilistic Clustering}
\begin{itemize}
	\item Can use a probabilistic model that allows cluster overlaps, clusters of different sizes, etc.
	\item You can tell a generative story for the data.  \hfill \\
		$P(X|Y) P(Y)$ is common.
	\item The challenge: estimate model parameters without labeled data.
\end{itemize}

\subsection{Gaussian Mixture Models}
\begin{itemize}
	\item We have clumps of data. Each clump is described with a gaussian.  % wk 10 audio
	\item Like softening k-means.  You belong to cluster 1 with a score of 0.1, cluster 2 with score of 0.3, cluster 3 with score of 0.6
	\item Think of clusters as probabilistic.
	\item Assume m-dimensional data points.
	\item P(Y) is still multinomial, with k classes.
	\item $P(\mathbb{X} | Y=i), i=1 \dots k$ are $k$ multivariate Gaussians.
		\begin{itemize}
			\item mean $\mu_i$ is a m-dimensional vector.
			\item variance $\Sigma_i$ is an $m$ by $m$ matrix.
			\item $|x|$ is the determinant of matrix x.
		\end{itemize}
\end{itemize}

$$ P(X=x | Y=i) = \frac{1}{\sqrt{(2 \pi)^m | \Sigma_i |}} \exp \left(  \frac{1}{2}(x - \mu_i)^T \Sigma_i^{-1} (x- \mu_i) \right) $$

\subsubsection{GMM is not Gaussian Naive Bayes}
(We did GNB before logistic regression) \hfill \\
Gaussian Naive Bayes : multinomial over clusters $Y$, Gaussian over each $X_i$ given $Y$:
$$ P(Y_i = y_k) = \theta_k $$
(Again, $\theta$ is the model parameters)
$$ P(X_i = x | Y = y_k) = \frac{1}{\sigma_{ik} \sqrt{2 \pi}} \exp \left(  \frac{-(x - \mu_{ik}^2}{2 \sigma_{ik}^2} \right) $$
? Would assume the input dimensions $X_i$ do not co-vary. \hfill \\

If the input dimensions $X_i$ do co-vary, we can use Gaussian Mixture Models.

\subsubsection{Gaussian Mixture Model Assumption}
We want to do something like MLE but now we have multiple Gaussians. \hfill \\
You don't know which label should be used for each data point(which is red, blue, green). \hfill \\
Need to guess $k$ Gaussians without knowing the $\mu$s.  \hfill \\

You can marginalize: \hfill \\
Model probability without knowing who belongs to who: marginalize over all possible y values.   \hfill \\
You are estimating $P(X|Y)$, but you don't know $Y$.   \hfill \\
You can get rid of $Y$ and get $P(X)$ by summing over $y_i$.  \hfill \\
Get $Y$ out of the equation by summing over all possible values. \hfill \\
If it was a probability table, we would be losing a column. \hfill \\

\begin{itemize}
	\item $P(Y)$: there are $k$ components
	\item $P(X | Y)$: each component generates data from a Gaussian with mean $\mu_i$ and covariance matrix $\Sigma_i$
	\item Assume each of the features are independent of each other. \hfill \\ % week 10 audio
		Then can write down $P(X|Y)$ as prod of $P(X_i | Y)$.  \hfill \\ % week 10 audio
        		Each of them will be a Gaussian distribution. \hfill \\  % week 10 audio
	\item  Can encode the whole $P(X|Y)$ with a multi-dimensional gaussian. \hfill \\  % week 10 audio
		For 2D data, this gives a circle.  \hfill \\  % week 10 audio
		For 3D data, this gives a bump.  \hfill \\  % week 10 audio
		 When we go to 100-dim space, we also have a mu.   \hfill \\  % week 10 audio
		 	Distribution is 100-dimensional. \hfill \\  % week 10 audio
			Sigma in 100-dim space is 100 by 100 covariance matrix. \hfill \\  % week 10 audio
\end{itemize}

Each data point is sampled from a \textbf{generative process}
\begin{itemize}
	\item Pick a component at random: \hfill \\
		choose component $i$ with probability $P(y=i)$
	\item Datapoint $\sim N(\mu_i, \Sigma_i)$
\end{itemize}

\includegraphics[width=1.0in]{figures/GMM_cartoon.pdf}

\subsubsection{Supervised MLE for GMM}
(Detour/review) \hfill \\

How do we estimate parameters for Gaussian Mixtures with fully supervised data? \hfill \\
Define objective and solve optimization: \hfill \\
From above:
$$ P(X=x | Y=i) = \frac{1}{\sqrt{(2 \pi)^m | \Sigma_i |}} \exp \left(  \frac{1}{2}(x - \mu_i)^T \Sigma_i^{-1} (x- \mu_i) \right) $$
And we know $ \displaystyle \mu_{ML} = \frac{1}{n} \sum_{i=1}^n x^i$ and $ \displaystyle \Sigma_{ML} = \frac{1}{n} \sum_{i=1}^n (x^i - \mu_{ML}) (x^i - \mu_{ML})^T$ \hfill \\

But we don't know Y, so we can't do that.  \hfill \\

Instead, we maximize the marginal likelihood.  (marginal means a variable is integrated out).
$$ \argmax_{\theta} \prod_i P(x^j; \theta) = \argmax \prod_j \sum_{i=1}^k P(y^j=i, x^j; \theta) $$

This is always a hard problem.  \hfill \\
There is usually no closed form solution.  \hfill \\
Even when $P(X, Y; \theta)$ is convex, $P(X; \theta)$ generally isn't.  \hfill \\
For all but the simplest  $P(X; \theta)$, we will also have to do gradient ascent, in a big messy space with lots of local optima.   \hfill \\

\subsubsection{Simple GMM example: learn means only}
\includegraphics[width=2.5in]{figures/gmm_for_means_only.pdf}

We solve this using EM below.

\includegraphics[width=2.9in]{figures/learning_general_mixtures_of_Gaussians.pdf}

\subsubsection{EM for GMM: learn means of 1D data}
\includegraphics[width=2.5in]{figures/gmm--means_only-1.pdf}

\includegraphics[width=3.3in]{figures/gmm--means_only-2.pdf}

\subsubsection{EM for GMM in general}

\includegraphics[width=3.3in]{figures/EM_for_GMM.pdf}

\subsubsection{EM with hard assignments, and only learning means $\rightarrow$ K-means}

\includegraphics[width=3.3in]{figures/em_to_kmeans.pdf}


\chapter{Introduction}
\label{chap:chapter1}
\pagenumbering{arabic}\hspace{3mm}

The basic job of a compiler is code translation from a high level
language to a target assembly language. But, compilers also perform
multiple optimizations in the intermediate stages of translation,
so that the finally generated code performs better than just a normal
translated code. There might be a one time overhead of
running optimizations, but the performance gain visible over multiple
executions of the code outweighs it.

A typical modern day compiler performs a large number of optimizations
like induction variable analysis, loop interchange, loop invariant code
motion, loop unrolling, global value numbering, dead code
optimizations, constant folding and propagation, common subexpression
elimination etc. One common feature of most of these optimizations is
detecting equivalent program subexpressions.

Checking semantic equivalence of program subexpressions has been shown
to be an undecidable problem, even when all the conditional statements
are considered as non deterministic. So in most of the cases, compilers
try to find some restricted form of expression equivalence. One such
form of expression equivalence is \textbf{Herbrand equivalence} (see
\autoref{sec:HerbrandEquivalence}).
Detecting equivalence of program subexpressions can be used for
variety of applications. Compilers can use these to perform several
of the optimizations mentioned earlier like constant propagation,
common subexpression elimination etc. Program verification tools can
use these equivalences to discover loop invariants and to verify
program assertions. This information is also important for discovering
equivalent computations in different programs, which can be used by
plagiarism detection tools and translation validation tools \cite
{Necula, Pnueli}, which compare a program with an optimized version
in order to check correctness of the optimizer.

\section{Herbrand Equivalence}
\label{sec:HerbrandEquivalence}
A formal definition of \textbf{Herbrand equivalence} is given in
\cite{Ruthing}.
Informally, two expressions are \textbf{Herbrand equivalent at a program
point}, if and only if they have syntactically the same value at that
given point, \textbf{across all the execution paths} from the start
of the program which reaches that point. For the purpose of analysis,
the operators themselves are treated as uninterprated functions with
no semantic significance, only syntactic information is taken into
consideration (see example in \autoref{sec:ASimpleExample}).

For \textbf{Herbrand equivalence analysis}, the universe is the set
of all possible expressions that can be formed using the constants,
variables and operators used in the program. And for each program
point, partition it such that two expressions are Herbrand equivalent
at that point if and only if they belong to the same partition class
of that point.

\section{A Simple Example}
\label{sec:ASimpleExample}

\begin{figure}[!ht]
    \centering {
        \setlength{\fboxsep}{8pt}
        \fbox{\includegraphics[scale=0.55]{HerbrandEquivalenceTrans.png}}
    }
    \caption{Example of Herbrand Equivalence}
    \label{fig:HerbrandEquivalenceTrans}
\end{figure}

\autoref{fig:HerbrandEquivalenceTrans} shows a simple example of Herbrand
equivalence analysis. All the expressions that belongs to the same set at
a program point are Herbrand equivalent at that point.

\begin{itemize}
    \item   Initially all the expressions are in separate sets, ie.
    they are inequivalent to each other. In particular, note that
    $X + 2$ and $2 + X$ are inequivalent because the operators are
    being treated uninterprated with no semantic information of them,
    which means there is no knowledge of commutativity of $+$.
    \item   After assignment $X = 2$, any occurrence of $X$ in an
    expression can equally be replaced with $2$. So, now all expressions
    with $2$ in place of $X$ and vice versa are equivalent - that means
    $2 + 2$, $2 + X$, $X + 2$, $X + X$ are all equivalent - this still
    is just syntactic information because $X$ and $2$ are equivalent.
    However, if $4$ is also in the universe of expressions, $2 + 2$ and
    $4$ are not equivalent as this is semantic information about operator $+$.
    \item   After assignment $Y = X$, any occurrence of $Y$ in
    an expression can be replaced with $X$. Because $X$ and $2$ are already
    equivalent, it means now $2$, $X$, and $Y$ are all equivalent to
    each other. And two expressions are equivalent if one can be
    obtained from the other by replacing one of these three with any of the
    other two. For this example, it means that any two expressions of
    the same length are equivalent.
\end{itemize}

\begin{figure}[!ht]
    \centering {
        \setlength{\fboxsep}{8pt}
        \fbox{\includegraphics[scale=0.54]{HerbrandEquivalenceConv.png}}
    }
    \caption{Example of Herbrand Equivalence analysis at a confluence point}
    \label{fig:HerbrandEquivalenceConv}
\end{figure}

\autoref{fig:HerbrandEquivalenceConv} shows what happens at a
\textbf{confluence point} - a point where multiple execution paths meet.
Two expressions are Herbrand equivalent at the confluence point only if
they are Herbrand equivalent at all the predecessor points.
\begin{itemize}
    \item   In the left branch $2$, $Y$, $Z$ are equivalent and
    so are expressions which are interconvertible by replacement
    of any of these three, with the other two.
    \item   The case with the right branch is similar, except $X$ is
    equivalent to $2$ and $Z$ instead of $Y$.
    \item   At the confluence point, only $2$ and $Z$ are equivalent
    because they are equivalent at both the predecessors points. $X$
    is equivalent to $2$ and $Z$ at the right predecessor but not
    the left one and $Y$ is equivalent to $2$ and $Z$ at the left
    predecessor but not the right. As before, expressions obtained by
    replacing $2$ with $Z$ and vice versa are equivalent.
\end{itemize}

\section{Goal of the Project}
\label{sec:GoalOfTheProject}
Babu, Krishnan and Paleri \cite{Babu} has given an algorithm for
Herbrand equivalence analysis restricted to program expressions. The
basic goal of this project is to refine this general algorithm and
then implement it for \href{https://llvm.org/}{Clang/LLVM compiler}.
The implementation is also to be benchmarked using \href{https://www.spec.org/}
{SPEC} CPU benchmarks. Finally, a proof of correctness of the
algorithm based on the theoretical work of Babu et al. \cite{Babu}
has to be presented.

\section{Organization of the Report}
\label{sec:OrganizationOfTheReport}
\autoref{chap:chapter2} gives an overview of the previous works
related to Herbrand equivalence; then summary of works of Babu et al.
\cite{Babu} is specifically presented in \autoref{chap:chapter3} as
it is closely related to the project. The updated algorithm for
Herbrand equivalence analysis is given in \autoref{chap:chapter4}.
\autoref{chap:chapter5} presents some important test cases on which
the Herbrand analysis algorithm can be checked for correctness.
\autoref{chap:chapter6} discusses about Clang/LLVM compiler and also
provides a tutorial for writing LLVM optimzation passes.
\autoref{chap:chapter7} and \autoref{chap:chapter8} explains the
implementation of the algorithm done for Clang/LLVM compiler and a
toy language respectively. Finally, \autoref{chap:chapter9} provides
the details of the attempt made for proving the correctness of the
algorithm. \autoref{chap:chapter10} concludes the report.


\newpage\section{Pedal Triangles}

	\den{Pedal Triangles}{Let $ P $ be an arbitrary point, let $ \triangle A_1B_1C_1 $ be its pedal triangle wrt $ \triangle ABC $. Let $ A', B', C' $ and $ A_0, B_0, C_0 $ be the feet of the altitudes and the midpoints of $ \triangle ABC $. \\

		\[ B_1C_1\cap B_0C_0=A_2,\ C_1A_1\cap C_0A_0 = B_2,\ A_1B_1\cap A_0B_0 = C_2 \]
		\[ B'C'\cap B_0C_0=A_3,\ C'A'\cap C_0A_0=B_3,\ A'B'\cap A_0B_0=C_3 \]}

	\theo{https://www.awesomemath.org/wp-pdf-files/math-reflections/mr-2015-02/article_1_bocanu.pdf}{Fontene's First Theorem}{$ A_1A_2, B_1B_2, C_1C_2 $ are concurrent at the intersection of $ \odot A_1B_1C_1 $ and $ \odot A_0B_0C_0 $}

	\lem{}{$ A'A_3, B'B_3, C'C_3 $ and $ A_0A_3, B_0B_3, C_0C_3 $ concur at the nine point circle of $ \triangle ABC. $}

	\theo{https://www.awesomemath.org/wp-pdf-files/math-reflections/mr-2015-02/article_1_bocanu.pdf}{Fontene's Second Theorem}{Let the concurrency point in the first theorem be $ Q $. Then, if the line $ OP $ is fixed and $ P $ moves along that line, $ Q $ will stay fixed.}

	The previous result leads to another beautiful result:

	\lem{}{Suppose a varying point $ P $ is chosen on the Euler Line of $ \triangle ABC $. Then the pedal circle of $ P $ wrt $ \triangle ABC $ intersects the 9p circle at a fixed point which is the Euler Reflection Point of the median triangle.}


\documentclass[12pt,letterpaper]{article}

\usepackage[margin=1.9cm]{geometry}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage{pgfplots}
\usepackage{siunitx}

\usepgfplotslibrary{fillbetween}

\pgfplotsset{compat=1.16}

\begin{document}
\section*{Part 1 High Pass Filter}
\subsection*{1.}
\begin{tikzpicture}
    \begin{axis}[
        title = {Gain vs frequency},
        xlabel = $\log{f}$,
        ylabel = $\frac{V_out}{V_in}$,
        xmin = 2,
        xmax = 5,
        ymin = 0,
        ymax = 1,
        axis lines=left,
        grid = both,
        height = 6cm,
        width = 17cm,
        legend pos=south west
    ]
    \addplot table [x=logf, y=VoutVin, col sep=comma, mark=none] {Part1.csv} ;
    \addplot [name path=passregion, mark=none, black, domain=2:5, opacity=0.5] {0.7071067812} node[above,pos=0.9] {Pass Region};

    \path[name path=axis] (axis cs:2,1) -- (axis cs:5,1);
    \addplot [
        thick,
        color=black,
        fill=black,
        fill opacity=0.05
    ]
    fill between[
        of=passregion and axis,
        soft clip={domain=2:5},
    ];

\end{axis}
\end{tikzpicture}
\subsection*{2.}
    Pass region calculation:
    \begin{align*}
    \text{Half Power Voltage} &= \frac{10}{\sqrt{2}} = \SI{7.071067812}{\volt}\\
    \text{Pass Region} &= \frac{\text{Half Power Voltage}}{\SI{10}{\volt}} = 0.707
    \end{align*}
\subsection*{3.}
    Lowest frequency that passes occurs at $\log(f) \simeq 3.8$, therefore $f = \SI{e3.8}{\hertz} = \SI{6309.57}{\hertz}$
\section*{Part 2 Low Pass Filter}
\subsection*{4.}
\begin{tikzpicture}
    \begin{axis}[
        title = {Gain vs frequency},
        xlabel = $\log{f}$,
        ylabel = $\frac{V_out}{V_in}$,
        xmin = 2,
        xmax = 5,
        ymin = 0,
        ymax = 1,
        axis lines=left,
        grid = both,
        height = 6cm,
        width = 17cm,
        legend pos=south west
    ]

    \addplot table [x=logf, y=VoutVin, col sep=comma, mark=none] {Part2.csv} ;
    \addplot [name path=passregion, mark=none, black, domain=2:5, opacity=0.5] {0.7071067812} node[above,pos=0.9] {Pass Region};

    \path[name path=axis] (axis cs:2,1) -- (axis cs:5,1);
    \addplot [
        thick,
        color=black,
        fill=black,
        fill opacity=0.05
    ]
    fill between[
        of=passregion and axis,
        soft clip={domain=2:5},
    ];

\end{axis}
\end{tikzpicture}
\subsection*{7.}
    Pass region calculation:
    \begin{align*}
    \text{Half Power Voltage} &= \frac{2}{\sqrt{2}} = \SI{1.414213562}{\volt}\\
    \text{Pass Region} &= \frac{\text{Half Power Voltage}}{\SI{2}{\volt}} = 0.707
    \end{align*}
\subsection*{6.}
    Lowest frequency that passes occurs at $log(f) \simeq 3.75$, or $f = \SI{e3.75}{\hertz} = \SI{5623.41}{\hertz}$
\section*{Part 3 Band Pass Filter}
\subsection*{7.}
\begin{tikzpicture}
    \begin{axis}[
        title = {Gain vs frequency},
        xlabel = $\log{f}$,
        ylabel = $\frac{V_out}{V_in}$,
        xmin = 2,
        xmax = 5,
        ymin = 0,
        ymax = 1,
        axis lines=left,
        grid = both,
        height = 6cm,
        width = 17cm,
        legend pos=south west
    ]

    \addplot table [x=logf, y=VoutVin, col sep=comma, mark=none] {Part3.csv} ;
    \addplot [name path=passregion, mark=none, black, domain=2:5, opacity=0.5] {0.7071067812} node[above,pos=0.9] {Pass Region};

    \draw (3.502836639, 0) -- (3.502836639, 1);

    \path[name path=axis] (axis cs:2,1) -- (axis cs:5,1);
    \addplot [
        thick,
        color=black,
        fill=black,
        fill opacity=0.05
    ]
    fill between[
        of=passregion and axis,
        soft clip={domain=2:5},
    ];
\end{axis}
\end{tikzpicture}
\subsection*{8.}
    Lowest frequency that passes occurs at $log(f) \simeq 3.75$, or $f = \SI{e3.75}{\hertz} = \SI{5623.41}{\hertz}$
\subsection*{9.}
    The lower bound occurs at $log(f) \simeq 3.15$, or $f = \SI{e3.15}{\hertz} = \SI{1412.54}{\hertz}$. The upper bound occurs at $log(f) \simeq 3.85$, or $f = \SI{e3.85}{\hertz}= \SI{7079.46}{\hertz}$.

\subsection*{10}
    The resonant frequency obtained in the lab was $\SI{3183}{\hertz}$. This is in direct correlation with the value calculated in the prelab assuming ideal conditions.

    The percent error calculated was:
    \begin{align}
        \frac{|3183-3183.1|}{3183.1} \times 100\% = \num[round-precision=3, round-mode = figures]{-3.14159153d-3}\%
    \end{align}

\end{document}


% !TEX root = thesis.tex

\chapter{A short dictionary of dimension-based GIS terms}
\label{ch:dictionary}

\begin{multicols}{2}

\begin{description}
\footnotesize

\item[ambient space]
the space in which objects are embedded.

\item[area]
1.\ measure of the 2D extent of an object;
2.\ 2D combinatorial element;
{\color{gray} 3.\ 2D geometric object}.

\item[ball]
1.\ ($\rightarrow$\ same as 3-\emph{ball}) topological definition of the space within a 2-sphere (\ie\ a sphere), often defined as the space within a certain distance (the radius) from a point in $\mathbb{R}^3$ (the centre);
2.\ ($\rightarrow$\ often $n$-\emph{ball}) topological definition of the space within an $(n-1)$-sphere, often defined as the space within a certain distance (the radius) from a point in $\mathbb{R}^n$ (the centre);
3.\ geometric definition of a perfectly round filled 3D object.

\item[body]
$n$-dimensional combinatorial element in an $n$D context.

\item[box]
1.\ cuboid;
2.\ orthotope of any dimension.

\item[cavity]
3D hole.

\item[cell]
1.\ ($\rightarrow$\ sometimes $n$-\emph{cell}) $n$D combinatorial element;
{\color{gray} 2.\ 3D combinatorial element}.

\item[cell complex]
topological space formed by a set of cells glued along common faces, all faces of a cell in the complex should be in the complex.

\item[circle]
1.\ topological definition of the space at a certain distance (the radius) from a point in $\mathbb{R}^2$ (the centre);
2.\ geometric definition of a perfectly round hollow 2D object.

\item[closed]
1.\ topological definition of an object that includes its boundary;
2.\ geometric definition of an object in $n$D, usually defined using boundary representation, that encloses an $n$D subspace.

\item[congruent]
having the same shape and size.

\item[cube]
1.\ ($\rightarrow$\ same as $3$-\emph{cube}) 3D polyhedron with 6 square facets;
2.\ ($\rightarrow$\ usually $n$-\emph{cube}) $n$-orthotope with identical $(n-1)$-cube facets, akin to a square in 2D and a cube in 3D.

\item[cuboid]
1.\ box-shaped 3D polyhedron with 6 rectangular facets, its opposite facets are congruent and parallel;
{\color{gray} 2.\ parallelotope}.

\item[curve]
1.\ 1D geometric object, often with a non-linear geometry;
2.\ 1D combinatorial element;
3.\ 1-manifold.

\item[cut-line]
degenerate part of a 2D shape forming a curve and protruding inwards from its boundary.

\item[disk]
topological definition of the space within a circle, often defined as the space within a certain distance (the radius) from a point in $\mathbb{R}^2$ (the centre).

\item[edge]
1D combinatorial element.

\item[face]
1.\ 2D combinatorial element;
2.\ ($\rightarrow$\ sometimes \emph{$n$-face of $X$}) $n$D combinatorial element on the boundary of $X$;
{\color{gray} 3.\ ($\rightarrow$\ usually \emph{face of $X$}) $(n-1)$D combinatorial element on the boundary of an $n$D combinatorial element $X$}.

\item[facet]
1.\ $(n-1)$D combinatorial element in an $n$D context;
2.\ ($\rightarrow$\ often \emph{facet of $X$}) $(n-1)$D combinatorial element on the boundary of an $n$D combinatorial element $X$;
{\color{gray} 3.\ 2D combinatorial element}.

\item[flat]
unbounded geometric object with linear geometry of any dimension, such as a point, line or plane.

\item[hole]
1.\ 2D void region;
2.\ $n$D void region.

\item[hyperball]
higher-dimensional ball.

\item[hypercell]
1.\ higher-dimensional combinatorial element;
2.\ 4D combinatorial element.

\item[hypercube]
1.\ higher-dimensional cube;
2.\ 4-cube.

\item[hyperplane]
1.\ $(n-1)$D linear subspace in an $n$D context;
{\color{gray} 2.\ plane in a higher-dimensional context.}

\item[hyperrectangle]
higher-dimensional orthotope.

\item[hypersphere]
higher-dimensional sphere.

\item[hypersurface]
$(n-1)$D subspace in an $n$D context, often curved;

\item[interval]
topological definition of the space between two points in $\mathbb{R}$ (the endpoints).

\item[Lebesgue measure]
measure of the $n$D extent of an object, akin to length in 1D, area in 2D and volume in 3D.

\item[length]
measure of the 1D extent of an object.

\item[line segment]
1D geometric object.

\item[manifold]
($\rightarrow$\ sometimes $n$-\emph{manifold}) topological space that resembles $\mathbb{R}^n$ at every point.

\item[manifold with boundary]
($\rightarrow$\ sometimes $n$-\emph{manifold with boundary}) topological space that resembles $\mathbb{R}^n$ at every point in its interior.

\item[node]
0D combinatorial element.

\item[open]
1.\ topological definition of an object that does not include its boundary;
2.\ geometric definition of an object in $n$D, usually defined using boundary representation, that does not enclose any $n$D subspace.

\item[orthotope]
($\rightarrow$\ sometimes $n$-\emph{orthotope}) $n$-polytope with congruent parallel facets forming right angles to each other, akin to a rectangle in 2D and a cuboid in 3D.

\item[parallelepiped]
3D polyhedron bounded by 6 parallelogram-shaped 2D faces.

\item[parallelogram]
polygon bounded by 4 parallel and have the same shape.

\item[parallelotope]
a polytope whose opposite facets are parallel and have the same shape, akin to a parallelogram in 2D and a parallelepiped in 3D.

\item[peak]
1.\ $(n-3)$D combinatorial element in an $n$D context;
2.\ ($\rightarrow$\ \emph{peak of $X$}) $(n-3)$D combinatorial element on the boundary of an $n$D combinatorial element $X$;

\item[plane]
2D unbounded linear subspace.

\item[point]
1.\ 0D geometric element;
2.\ topological definition of the space at one location.

\item[polychoron]
4D geometric object with linear geometry.

\item[polygon]
2D geometric object with linear geometry, possibly with holes.

\item[polygonal curve]
curve formed by a sequence of line segments joined at their endpoints.

\item[polyhedron]
1.\ 3D geometric object with linear geometry, possibly with holes;
{\color{gray} 2.\ an $n$D geometric object with linear geometry}.

\item[polyline]
curve formed by a sequence of line segments joined at their endpoints.

\item[polyteron]
5D geometric object with linear geometry.

\item[polytope]
$n$D geometric object with linear geometry.

\item[puncture]
0D (point) hole, often formed from a degenerate polyline or polygon.

\item[ridge]
1.\ $(n-2)$D combinatorial element in an $n$D context;
2.\ ($\rightarrow$\ \emph{ridge of $X$}) $(n-2)$D combinatorial element on the boundary of an $n$D combinatorial element $X$.

\item[line string]
curve formed by joining a sequence of vertices by straight line segments, represented by these vertices.

\item[linear ring]
2D geometric object with linear geometry represented as a sequence of vertices.

\item[ring]
2D combinatorial element represented by its 1D boundary.

\item[subfacet]
1.\ $(n-2)$D combinatorial element in an $n$D context;
2.\ ($\rightarrow$\ \emph{subfacet of $X$}) $(n-2)$D combinatorial element on the boundary of an $n$D combinatorial element $X$.

\item[shell]
3D geometric object with linear geometry without 3D holes, usually defined as the volume enclosed by its 2D boundary, often represented as a set of 2D faces.

\item[simplex]
1.\ ($\rightarrow$\ sometimes \emph{$n$-simplex}) combinatorial element with $n+1$ vertices and $n+1$ facets;
2.\ ($\rightarrow$\ sometimes \emph{$n$-simplex}) geometric object based on $n+1$ affinely independent vertices, akin to a point in 0D, a line segment in 1D, a triangle in 2D, or a tetrahedron in 3D.

\item[simplicial complex]
1.\ ($\rightarrow$\ sometimes \emph{abstract simplicial complex}) topological space formed by a set of simplices glued along common faces, all faces of a simplex in the complex should be in the complex;
2.\ ($\rightarrow$\ sometimes \emph{geometric simplicial complex}) abstract simplicial complex where simplices are embedded into Euclidean space, their interiors should not intersect geometrically.

\item[solid]
1.\ 3D geometric object with linear geometry, possibly with 3D holes, often represented as a set of shells;
2.\ object defined based on solid modelling, often as opposed one based on boundary representation;
3.\ an object containing its interior (as opposed to \emph{hollow}).

\item[spike]
degenerate part of a 2D shape forming a curve, often protruding outwards from its boundary.

\item[sphere]
1.\ ($\rightarrow$\ same as $2$-\emph{sphere}) topological definition of the space at a certain distance (the radius) from a point in $\mathbb{R}^3$ (the centre);
2.\ ($\rightarrow$\ often $n$-\emph{sphere}) topological definition of the space at a certain distance (the radius) from a point in $\mathbb{R}^{n+1}$ (the centre);
3.\ geometric definition of a perfectly round hollow 3D object.

\item[surface]
1.\ 2-manifold;
2.\ 2D combinatorial element.

\item[tesseract]
4-cube: polychoron with 8 cubical facets.

\item[vertex]
0D combinatorial element.

\item[volume]
1.\ measure of the 3D extent of an object;
2.\ 3D combinatorial element.

\item[wire]
2D combinatorial element represented by its 1D boundary.

\end{description}

\end{multicols}

% \begin{table}
% \scriptsize
% \begin{tabular}{ccccccc}
% \toprule
% \multicolumn{7}{c}{dimension} \\
% $n$ & 0 & 1 & 2 & 3 & 4 \\
% \midrule
% \multicolumn{7}{c}{topological} \\
% $n$-simplex & vertex & edge & face & volume \\
% $n$-cell & vertex & edge & face & volume \\
% $n$-sphere & pair of points & circle & sphere \\
% $n$-ball & & interval & disk & ball \\
% open $n$-ball & & open interval & open disk & open ball \\
% $n$-manifold & discrete space & curve & surface \\
% \midrule
% \multicolumn{7}{c}{geometric} \\
% $n$-simplex & point & line segment & triangle & tetrahedron & pentachoron \\
% $n$-cube & point & square & cube & tesseract \\
% $n$-orthotope & point & line segment & rectangle & cuboid/box \\
% $n$-parallelotope & point & line segment & parallelogram & parallelepiped \\
% prismatic $n$-polytope & & line segment & rectangle & prism & prismatic polychoron \\
% $n$-polytope & point & line segment & polygon & polyhedron & polychoron \\
% \midrule
% \multicolumn{7}{c}{other} \\
% $n$-th Lebesgue measure & length & area & volume \\
% & & collinear & coplanar \\
% \bottomrule
% \end{tabular}
% \end{table}


\input{coredef.tex}

%opening
\def\ntitle{Graph Theory}
\def\nauthor{mostanes}
\def\npart{II}
\def\nterm{Michelmas}
\def\nyear{2018}
\def\nlecturer{Paul Russel}
\begin{document}

	\mktitlepage

	\newpage

	\setcounter{section}{-1}

\section{Preface}
The course is self-contained and has almost no prerequisites (the only ones are mainly IA material). The book recommended for a more in-depth study of the material is I. B. Bollobas's "Modern Graph Theory" (published by Springer).

\newpage

\section{Introduction}
A preliminary definition of graphs:
\begin{definition}
	A graph consists of some 'vertices' with soem pairs of vertices joined by 'edges'
\end{definition}

\subsection{Types of graph problems:}
\subsubsection{Bridges of Konigsberg}
\begin{question}Is it possible to walk round the city crossing each bridge precisely once and returning to the starting point?
\end{question}
\begin{question}
Is it possible to walk round the multigraph traversing each edge precisely once and finishing at the starting vertex?
\end{question}
\subsubsection{Four Colour Problem}
\begin{question}
	How many colours are needed to colour a map?
\end{question}
\subsubsection{Simultaneous coset representation}
Let $G$ be a finite group and $H \leq G$. Let $n = \left|G:H\right|$. Then we know $\exists a_i, b_i \in G$ s.t. $a_i H$ are the left cosets and $H b_i$ are the right cosets of $H$ in $G$.
\begin{question}
	$\exists ? c_i $ s.t. $c_i H$ are the left cosets and $H c_i$ are the right cosets of $H$ in $G$
\end{question}
By considering $X$ the set of left cosets and $Y$ the set of right cosets of $H$ in $G$, let $E = X \cup Y$ and $V = \left\lbrace (gH, Hg) : g \in G \right\rbrace$.
\begin{question}
	$\exists ? \epsilon \subset E$ s.t. $\forall v \in V$, $\exists$ unique $e \in \epsilon$ s.t. $e$ has $v$ as an endpoint
\end{question}
\subsubsection{Fermat equation mod p}
$x^n + y^n = z^n$ has no non-trivial solutions in $\Z$ if $n \geq 3$.
\begin{question}
	Does $x^n + y^n = z^n$ have any non-trivial solutions in $\Z_p$?
\end{question}
\begin{theorem}
	Let $n \in \N$. Then for $\forall$ sufficiently large $p$, there are $x,y,z \neq 0 \pmod{p}$ with $x^n + y^n \equiv z^n \pmod{p}$.
\end{theorem}
\begin{proof}
	Let $G = \Z_p^\times$, the multiplicative group of residues modulo $p$. Let $H = \left\lbrace g^n : g \in G \right\rbrace \leq G$. We want $x, y, z \in H$ s.t. $x+y=z$.\\
	Looking at the cosets of $H$, we have $\left|H\right| \geq \frac{\left|G\right|}{n}$. We also note that $\forall g \in G$, if $\exists u,v,w \in gH$, then $g^{-1}u + g^{-1}v = g^{-1}w$ and $g^{-1}u, g^{-1}, g^{-1}w \in H$. We have reduced the problem to the following combinatorial statement:
\end{proof}
\begin{theorem}[Schur's theorem]
	Let $n$ be a positive integer. Then for $\forall$ sufficiently large $k$, if $\left[k\right] = \left\lbrace 1, 2, ..., k \right\rbrace$ is partitioned in $n$ parts, $\exists u, v, w$ in the same part s.t. $u+v=w$.
\end{theorem}

\end{document}


\documentclass{memoir}
\usepackage{notestemplate}

\begin{document}
If $\text{Span}(v_1,\ldots,v_m) = V$, we say that $v_1,\ldots,v_m$ "span" the space $V$. \\

We call the set of unit vectors of a space the \textbf{standard basis}.
\begin{defn}
	A vector space $V$ is \textbf{finite-dimensional} if $V = span(v_1,\ldots,v_m)$.
\end{defn}
If a vector space is not finite-dimensional, then we say it is \textbf{infinite-dimensional}. To maintain convention, if \(V = F[x]\), then \(\textrm{deg}(0) = -\infty\).
\begin{thm}
	\(F[x]\) is infinite-dimensional.
\end{thm}

\subsection{Linear Independence}
\begin{defn}[Linear independence]
	A list $v_1,\ldots,v_m$ of vectors is \textbf{linearly independent} if and only if
	\begin{align*}
	a_1v_1+\ldots+a_mv_m = \vec{0}\implies a_1,\ldots,a_m = 0
	\end{align*}

\end{defn}
	A list of vectors in $V$ is \textbf{linearly dependent} if it is not linearly independent.\\

	We can also say that a list in $V$ is linearly dependent if there exist $a_1,\ldots,a_m$ not all zero such that $a_1v_1+\ldots+a_mv_m = 0$.

\begin{lemma}
	If \(v_1,\ldots,v_m\) are linearly independent, then there is exactly one way to write $v \in \text{Span}(v_1,\ldots,v_m)$ as a linear combination of the vectors.
\end{lemma}
\begin{thm}
Let $V$ be a finite-dimensional vector space. If \(v_1,\ldots,v_m\) is an arbitrary set of linearly independent vectors in \(V\) and \(w_1,\ldots,w_k\) is an arbitrary set of vectors that span \(V\), then \(m\leq k\).

\end{thm}
\begin{lemma}[Linear Dependence Lemma]
	Let $v_1,\ldots,v_m \in V$ be a set of linearly dependent vectors. Then there exists an index $j$ such that \begin{itemize}
		\item $v_j \in \text{Span}(v_1,\ldots,v_{j-1})$
		\item $\text{Span}(v_1,\ldots,v_m) = \text{Span}(v_1,\ldots,v_{j-1},v_{j+1},\ldots,v_m)$
	\end{itemize}
\end{lemma}
\begin{lemma}[Finite-dimensional subspaces]
	Every subspace of a finite-dimensional vector space is finite-dimensional.
\end{lemma}

\end{document}


\subsubsection{Entity Relationship Model}\label{sec:EntityRelationModel}
The entity relationship model is a graphical representation of how database relations are structured.
This is done in an \textit{entity relationship} (ER) diagram, and is commonly used facilitate database design from specifications of enterprise schemas\cite{DBSBook}.
In the ER model, we differentiate between \textit{entity sets}, representing domain elements, and \textit{relationships sets}, representing the relationships between the domain elements.
The entity sets are represented graphically with a rectangle, and relationship sets connecting the entity sets are represented with a diamond\cite{DBSBook}.
The attributes associated with the entity- and relationship sets can be modelled using ovals\cite{KatjaFirstPP}, however other alternatives exists.\footnote{Our style of choice is presented in Chapter 6.10 of \citetitle{DBSBook} \textit{\citefield[]{DBSBook}[]{edition}}}
Similar to the relational model, the entities (tuples) must be uniquely identified by one or more attributes. This is denoted by underlining the attributes of the entity sets.

The ER model has notations that denote the participation of each entity in a connecting relationship\cite{DBSBook}.
In this project, we will use \text{min-max} notation; this notation denotes the minimum and maximum amount of entities participating in a relationship.

\begin{figure}[htp]
    \centering
    \includegraphics[scale=0.5]{Images/book_example_w_cardinality.png}
    \caption{ER diagram of the book and book owner example.}
    \label{fig:ER_Book_Example}
\end{figure}

Figure \ref{fig:ER_Book_Example} shows an ER diagram equivalent to the $book$, $owns$, and $book\_owner$ relations from equation \ref{eq:relational_schema} and \ref{eq:bookOwnerExample}.
In figure \ref{fig:ER_Book_Example} we also see the participation cardinalities of the two entity sets.
The relationship from $book\_owner$ to $owns$ is one of total participation. That is, each book owner entity must own at least one book.
\begin{figure}[h]
    \centering
    \includegraphics[scale=0.5]{Images/cardinalities.png}
    \caption{Participation ratios for ER relationships.}
    \label{fig:ERDiagram_Cardinality}
\end{figure}
The participation from $book$ to $owns$ is partial.
Thus, the model represents that books can be in the database, even if no one owns it, and that a book can be owned by multiple book owners.
Graphical notation of participation connections can be seen in figure \ref{fig:ERDiagram_Cardinality}.

Other forms of entity sets exist. For instance, a weak entity set, denoted by an oval with doubled edges, is an entity set whose existence is based on another entity set.
Relationship sets connecting a weak entity set to its identifying entity set will not have any attributes\cite{DBSBook}.
A weak entity set is identified by its \textit{identifying entity set}'s primary key along with some of its own attributes.
The relationship between a weak entity set and its identifying set is always many-to-one with total participation of the weak entity set.

The ER model can be converted into the \textit{relational model}\cite{DBSBook}. The relational model is described using relations, thus we can describe operations that can be performed on the relations using set notation and relational algebra.
Therefore, it is useful to be able to convert an ER model into an equivalent relational model\cite{DBSBook}, where domains of attributes can be defined and operations on the entity sets described mathematically.

\subsubsection*{Converting ER Models to Relations}
When converting an ER diagram into an equivalent relational model, we must consider the domains of the attributes in the ER model since these need to be described in the relational model\cite{DBSBook}. Having the domain of the relations described makes it possible to establish well-defined operations that can be performed on the relations.\\\\
\textbf{Strong entity sets}\\\\
Strong entity sets are converted by taking each attribute of the entity set, and creating a single relation with corresponding attributes.
The primary key of the entity set is chosen as primary key for the relation\cite{DBSBook}.\\
As an example of converting a strong entity, we can use the book owner example from figure \ref{fig:ER_Book_Example}. In this example, \texttt{Book} is a strong entity. The relation created from the book entity can be seen in equation \ref*{eq:StrongEntity}. The attributes from the entity are added to the relation and the primary key of the book entity, \texttt{ISBN}, is used as the primary key for the relation.

\begin{equation}\label{eq:StrongEntity}
    \begin{split}
        Book(\underline{ISBN : text} , title : text , author\_name : text , number\_of\_pages : \mathbb{Z}^+)
    \end{split}
\end{equation}
\\
\textbf{Many-to-many relationships}\\\\
When converting many-to-many relationships to a relation, one creates a single relation with primary key attributes from the participating entity sets\cite{DBSBook}. These keys are used as foreign key to reference the converted entities participating in the relationship.
The remaining attributes of the entity set is similarly mapped to the relation.\\
As an example, in the book owner example, there is a many-to-many relationship between a \texttt{book\_owner} and a \texttt{book} called \texttt{Owns}. As can be seen in equation \ref{eq:ManyToMany}, to convert the relationship set into a relation, the keys of the participating entities must be put into the relation.

\begin{equation}\label{eq:ManyToMany}
    \begin{split}
        owns(\underline{owner\_id \rightarrow book\_owner}, \underline{ISBN \rightarrow book})
    \end{split}
\end{equation}
\\
\textbf{Many-to-one relationships}\\\\
If we have a many-to-one relationship between two sets, we can combine the relationship set and the relation created from the entity set on the 'many' side into a single relation. This relation will use the primary key of the entity set as its primary key, and have a foreign referencing the relation created from the 'one' side of the relationship\cite{DBSBook}.\\
As an example, if we for the book owner example instead assume that a book could have only one owner, it would be a many-to-one relationship. To convert the relationship set to a relation, the relationship set should be merged with the 'many' side of the relations created, which in this case would be the book as it only has one owner, but an owner can have many books. The relation created from this can be seen in equation \ref*{eq:ManyToOne}, which has the attributes of the initial book relation and a foreign key to the \texttt{book\_owner}.

\begin{equation}\label{eq:ManyToOne}
    \begin{split}
        Book(\underline{ISBN : text} , title : text , author\_name : text , \\number\_of\_pages : \mathbb{Z}^+, owner\_id \rightarrow Book\_owner)
    \end{split}
\end{equation}
\\
\textbf{One-to-one relationships}\\\\
When converting one-to-one relationships with total participation, we simply create a union of the attributes of the participating entity sets and the relationship set\cite{DBSBook}. If there is not total participation, two relations are created from the entity set, and a foreign key is placed on one of the sets.\\
As an example, assume that a book can only be owned by one book owner, and that a book owner has only one book. It would then be a one-to-one relationship. Assuming total participation between these entities, a relation can be formed from the union of the two relations' attributes. The union is seen in equation \ref*{eq:TotalOneToOne}.

\begin{equation}\label{eq:TotalOneToOne}
    \begin{split}
        r(\underline{owner\_id:\mathbb{Z}^+},\underline{ISBN: text}, name:text, title:text, author\_name:text, \\ number\_of\_pages:\mathbb{Z}^+).
    \end{split}
\end{equation}
\\
If instead the entities have partial participation, a foreign key is placed on either of the relations. In equation \ref{eq:PartialOneToOne} the foreign key is placed on the book owner.

\begin{equation}\label{eq:PartialOneToOne}
    \begin{split}
        Book(\underline{ISBN : text} , title : text , author\_name : text , number\_of\_pages : \mathbb{Z}^+) \\
        book\_owner(\underline{owner\_id:\mathbb{Z}^+} , name:text , ISBN \rightarrow Book)
    \end{split}
\end{equation}
\\
\textbf{Weak entity sets}\\\\
When representing weak entity sets, one creates a relation containing the attributes of the weak entity set as well as the attributes of the identifying set's primary key.
The primary key of the identifying relation will also serve as a foreign key to the identifying relation\cite{DBSBook}.
The relationship set is simply ignored, as the relationship set will not have any attributes\cite{DBSBook}. \\
As an example assume that a book owner is a weak entity, which uses a book as an identifying attribute. As can be seen in equation \ref{eq:WeakEntity}, the relation for, the weak entity, book owner gains a foreign key to a book as part of its own primary key.

\begin{equation}\label{eq:WeakEntity}
    \begin{split}
        Book(\underline{ISBN : text} , title : text , author\_name : text , number\_of\_pages : \mathbb{Z}^+) \\
        book\_owner(\underline{ISBN \rightarrow Book}, \underline{owner\_id:\mathbb{Z}^+} , name:text)
    \end{split}
\end{equation}
\\

sections/Chapter 3 Sprint 1/ER_Model.tex


\documentclass[12pt]{cdblatex}
\usepackage{exercises}
\usepackage{fancyhdr}
\usepackage{footer}

\begin{document}

% --------------------------------------------------------------------------------------------
\section*{Exercise 3.6 Commutation of $\nabla$ on the Riemann tensor -- simple computation}

\begin{cadabra}
   {a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w#}::Indices(position=independent).

   DD{#}::Derivative.
   \nabla{#}::Derivative.

   RabcdF := R_{a b c d} -> A_{a} B_{b} C_{c} D_{d}.      # cdb(RabcdF.000,RabcdF)
   RabcdB := A_{a} B_{b} C_{c} D_{d} -> R_{a b c d}.      # cdb(RabcdB.000,RabcdB)

   derivDD := DD_{b c}{V?_{a}}} -> R^{d}_{a b c} V?_{d}.  # cdb(derivDD.000,derivDD)

   nablaDD := \nabla_{f}{\nabla_{e}{R_{a b c d}}}
            - \nabla_{e}{\nabla_{f}{R_{a b c d}}} -> DD_{e f}{R_{a b c d}}.

   # product rule for DD acting on A_{a} B_{b} C_{c} D_{d}
   pruleDD := DD_{e f}{A_{a} B_{b} C_{c} D_{d}} -> DD_{e f}{A_{a}} B_{b} C_{c} D_{d}
                                                 + A_{a} DD_{e f}{B_{b}} C_{c} D_{d}
                                                 + A_{a} B_{b} DD_{e f}{C_{c}} D_{d}
                                                 + A_{a} B_{b} C_{c} DD_{e f}{D_{d}}.
                                                          # cdb(pruleDD.000,pruleDD)

   expr :=   \nabla_{f}{\nabla_{e}{R_{a b c d}}}
           - \nabla_{e}{\nabla_{f}{R_{a b c d}}}.         # cdb (ex-0306.100, expr)

   substitute   (expr,nablaDD)                            # cdb (ex-0306.101, expr)
   substitute   (expr,RabcdF)                             # cdb (ex-0306.102, expr)
   substitute   (expr,pruleDD)                            # cdb (ex-0306.103, expr)
   substitute   (expr,derivDD)                            # cdb (ex-0306.104, expr)
   sort_product (expr)                                    # cdb (ex-0306.105, expr)
   substitute   (expr,RabcdB)                             # cdb (ex-0306.106, expr)

\end{cadabra}

\begin{dgroup*}[spread={3pt}]
   \Dmath*{\cdb{ex-0306.100} = \Cdb*{ex-0306.101}
                             = \Cdb*{ex-0306.102}
                             = \Cdb*{ex-0306.103}
                             = \Cdb*{ex-0306.104}
                             = \Cdb*{ex-0306.105}
                             = \Cdb*{ex-0306.106}}
\end{dgroup*}

\end{document}


% Created 2017-08-28 lun 15:25
\documentclass[a4paper]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fixltx2e}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{float}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\usepackage{textcomp}
\usepackage{marvosym}
\usepackage{wasysym}
\usepackage{amssymb}
\usepackage{hyperref}
\tolerance=1000
\usepackage{khpreamble}
\author{Kjartan Halvorsen}
\date{Due Thursday 2017-08-24 at midnight}
\title{Control Engineering - homework 1}
\hypersetup{
  pdfkeywords={},
  pdfsubject={},
  pdfcreator={Emacs 24.5.1 (Org mode 8.2.10)}}
\begin{document}

\maketitle

\section*{Proportional control of a DC-motor}
\label{sec-1}

Consider a simple model of a DC-motor, where the inductance in the motor is neglected:
\begin{center}
\includegraphics[width=0.3\linewidth]{dc-motor-circuit}
\end{center}
A model of the motor is given by
\[ Y(s) = \frac{K_f}{s(1+sT)} \left( U(s) + D(s)\right), \]
where $y(t)$ is the angle of the motor shaft, $u(t)$ is the voltage to the motor and $d(t)$ is a load disturbance (from whatever the motor is trying to move).

\begin{enumerate}
\item Determine the motor's \emph{weighting function} $g(t)$.
\item In order to achieve a position servo, proportional feedback control is applied: \[ u(t) = K(y_{ref} - y). \] Draw a block-diagram of the closed-loop system with a block for the controller ($F(s)=K$), a block for the DC-motor, $y$ as output signal, and $y_{ref}$ and $d$ as input signals. Name all the signals in the diagram.
\item The closed-loop system can be written
\[ Y(s) = G_c(s) Y_{ref}(s) + G_d(s) D(s). \]
Determine the transfer functions $G_c(s)$ and $G_d(s)$, and determine the poles of the closed-loop system (note that the two transfer functions will have the same denominator).
\item Determine the final values of the output signal, i.e.
\[ \lim_{t \to \infty} y(t) \]
for the two cases
\begin{enumerate}
\item The reference signal $y_{ref}(t)$ is a unit step and there is no disturbance $d(t)=0$.
\item The reference signal is zero and the disturbance $d(t)$ is a unit step.
\end{enumerate}
\item Determine the final value of the control error \(e(t) = y_{ref}(t) - y(t)\) when the reference signal $y_{ref}(t)$ is a unit ramp
\[ y_{ref}(t) = \begin{cases} t & t\ge 0\\ 0 & t<0 \end{cases} \]
and there is no disturbance.
\end{enumerate}

\section*{Solutions}
\label{sec-2}
\begin{enumerate}
\item The motor's \emph{weighting function} $g(t)$. This is the inverse laplace transform of the transfer function.
\begin{align*}
g(t) &= \laplaceinv{G(s)} = \laplaceinv{\frac{K_f}{s(1+sT)}} = \laplaceinv{\frac{A}{s} + \frac{B}{1+sT}}\\
&= \laplaceinv{\frac{A}{s}} + \laplaceinv{\frac{B}{1+sT}} = A u_h(t) + \frac{B}{T}\mexp{-\frac{t}{T}}u_h(t),
\end{align*}
where $u_h(t)$ is the Heaviside step function. The constants A and B are determined by writing
\[ \frac{K_f}{s(1+sT)} = \frac{A}{s} + \frac{B}{1+sT}. \]
$A$ is found by multiplying each side first by $s$ and letting $s\to 0$, which gives
\[ A = K_f \]
$B$ is found by the same method to be
\[ B = - K_f T \]
So, the weighting function is
\[ g(t) = K_f \left( 1 - \mexp{-\frac{t}{T}}\right)u_h(t). \]
It is OK to write the solution without the step-function, since we are considering only causal systems, and are using the uni-lateral Laplace transform.
\item Block-diagram of the closed-loop system
     \begin{center}
\begin{tikzpicture}[scale = 0.8, node distance=20mm, block/.style={rectangle, draw, minimum width=15mm}, sumnode/.style={circle, draw, inner sep=2pt}]

\node[coordinate] (refinput) {};
\node[sumnode, right of=refinput, node distance=20mm] (sumerr) {\tiny $\sum$};
\node[block, right of=sumerr] (controller) {$F(s)$};
\node[above of=controller, node distance=6mm] {controller};
\node[sumnode, right of=controller, node distance=16mm] (sum) {\tiny $\sum$};
\node[block, right of=sum, node distance=20mm] (tank) {$\frac{K_f}{s(1+sT)}$};
\node[above of=tank, node distance=6mm] {DC-motor};
\node[coordinate, right of=tank, node distance=20mm] (output) {};
\node[coordinate, above of=sum, node distance=12mm] (disturbance) {};

\draw[->] (refinput) -- node[above, pos=0.3] {$y_{ref}(t)=0$} (sumerr);
\draw[->] (sumerr) -- node[above] {$e(t)$} (controller);
\draw[->] (controller) -- node[above] {$u(t)$} (sum);
\draw[->] (sum) -- node[above] {} (tank);
\draw[->] (tank) -- node[coordinate] (measure) {} node[above, pos=0.8] {$y(t)$} (output);
\draw[->] (disturbance) -- node[right, pos=0.2] {$v(t)$} (sum);
\draw[->] (measure) -- ++(0,-14mm) -| node[right, pos=0.95] {$-$} (sumerr);

\end{tikzpicture}
\end{center}

\item The closed-loop system
\[ Y(s) = G_c(s) Y_{ref}(s) + G_d(s) D(s) \] is found by block-diagram calculations to be
\[ Y(s) = \frac{\frac{K_f}{s(1+sT)}F(s)}{1 + \frac{K_f}{s(1+sT)}F(s)}Y_{ref}(s) +
                    \frac{\frac{K_f}{s(1+sT)}}{1 + \frac{K_f}{s(1+sT)}F(s)}D(s)\]
\[ Y(s) = \frac{K_f F(s)}{s(1+sT) + K_fF(s)}Y_{ref}(s) + \frac{K_f}{s(1+sT) + K_fF(s)} D(s). \]
With proportional controller \( F(s) = K \)
\[ Y(s) = \frac{K_f K}{s(1+sT) + K_fK}Y_{ref}(s) + \frac{K_f}{s(1+sT) + K_fK} D(s). \]
The characteristic polynomial is
\[ s^2 + \frac{1}{T}s + \frac{K_fK}{T} \] and the poles are the roots of this polynomial
\[ s = -\frac{1}{2T} ( 1 \pm \sqrt{1 - 4K_fKT} ). \]
Note that for high gain (\( K \) large) we get a oscillatory closed-loop system. This is a common effect of systems with proportional control.
\item Determine the final values of the output signal, i.e.
\[ \lim_{t \to \infty} y(t) \]
for the two cases
\begin{enumerate}
\item The reference signal $y_{ref}(t)$ is a unit step \( Y_{ref}(s) = \frac{1}{s}\)  and there is no disturbance $d(t)=0$.
\[  \lim_{t \to \infty} y(t) &= \lim_{s \to 0} sY(s) = \lim_{s \to 0} s\frac{K_f K}{s(1+sT) + K_fK}\frac{1}{s} = 1 \]
\item The reference signal is zero and the disturbance $d(t)$ is a unit step.
\[\lim_{t \to \infty} y(t) &= \lim_{s \to 0} sY(s) = \lim_{s \to 0} s\frac{K_f}{s(1+sT) + K_fK}\frac{1}{s} = \frac{1}{K}.\]
Note that with higher gain $K$ we get better disturbance rejection, but we are not able to completety eliminate the disturbance. This is common when only P-control is used.
\end{enumerate}
\item Final value of the control error \(e(t)\) when the reference signal is a step. We have
\begin{equation*}
\begin{split}
E(s) &= Y_{ref}(s) - Y(s) = \frac{1}{s^2} - \frac{K_fK}{s(1+sT) + K_fK} \frac{1}{s^2} = \frac{s(1+sT) + K_fK - K_f_k}{\left(s(1+sT) + K_fK\right)s^2}\\
&= \frac{1 + sT}{\left(s(1+sT) + K_fK\right)s}
\end{split}
\end{equation*}
so
\[ \lim_{t\to\infty} e(t) = \lim_{s\to 0} s \frac{1 + sT}{\left(s(1+sT) + K_fK\right)s} = \frac{1}{K_fK}. \]
\end{enumerate}
% Emacs 24.5.1 (Org mode 8.2.10)
\end{document}