\documentclass[main.tex]{subfiles}
\begin{document}

\section*{Fri Nov 15 2019}

We want to study the behaviour of light and particles in a Schwarzschild background, for \(r > 2 GM\). The metric is:
%
\begin{align}
  \dd{s^2} = - \qty(1 - \frac{2GM}{r}) \dd{t^2}
  + \qty(1 - \frac{2GM}{r})^{-1} \dd{r^2}
  + r^2 \dd{\Omega^2}
\,.
\end{align}

In general, the motion of light is nonradial.
The metric is independent of time: our Killing vector field is \(\xi^{\alpha } = (1, \vec{0} )\), so \(p \cdot \xi = \const\).

From QM we know that \(f_A = E_A / h\), where \(E_A\) is the energy measured by \(A\).

The 4-velocity of \(A\) has spatial components equal to zero, since \(A\) does not move.
Its norm must be  \(u^{\mu } u_{\mu } = -1\), therefore \(u^{\mu }_A = (1/ \sqrt{1 - 2GM / r_A}, \vec{0})\), or \(u^{\alpha}_A = (1, \vec{0}) / \sqrt{1 - 2GM / r_A} = \xi^{\alpha } / \sqrt{1 - 2GM/r_A}\).

For Bob, we have the exact same thing, except \(A \rightarrow B\).

So, for \(i = A, B\):
%
\begin{align}
  f_i = u_{\mu }^{(i)} p^{\mu }_{ \text{photon}} = - \qty(1 - \frac{2GM}{r_i})^{-1/2} \frac{p _{\text{photon}} \cdot \xi }{h}
\,,
\end{align}
%
since both of the 4-velocities are proportional to the Killing (unit) vector field, with \emph{different proportionality constants}.
The last part is exactly the same since the light moves along a geodesic: so their ratio is given by
%
\begin{align}
  \frac{f_B}{f_A} = \sqrt{\frac{1-2GM /r_A}{1-2GM/r_B}}
\,,
\end{align}
%
or
%
\begin{align}
  f _{\text{obs}} = f _{\text{emit}} \frac{\sqrt{1 - \frac{2GM}{r _{\text{emit}}}}}{\sqrt{1 - \frac{2GM}{r _{\text{obs}}}}}
\,.
\end{align}

Let us consider the nonrelativistic approximation: \(r_A = R + h\), while \(r_B = R\), where \(R = R _{\text{earth}}\).
If we Taylor expand (with \(2GM \ll R\)), we get:
%
\begin{align}
  f _{\text{obs}} = f _{\text{emit}} \qty(1 - \frac{GM}{r _{\text{emit}}} + \frac{GM}{r _{\text{obs}}})
\,,
\end{align}
%
and then we expand in \(h/R\): we get
%
\begin{align}
    f _{\text{obs}} = f _{\text{emit}} \qty(1 - \frac{GM}{R} \qty(1 - \frac{h}{R}) + \frac{GM}{R})
    = f _{\text{emit}} \qty(1 + \frac{GM}{R^2} h)
    = f _{\text{emit}} \qty(1 + g h)
  \,,
\end{align}
%
if we want more precision then we can keep more orders.

\subsubsection{Classical orbits}

Kepler's laws are \emph{wrong}! We will show this.

In classical circular orbits, for a planet with mass \(m=1\), we have the gravitational force \(GM/r^2\) equalling \(v^2/r\), or with respect to the angular momentum \(l = vr\):
%
\begin{align}
  \frac{GM}{r^2} = \frac{l^2}{r^3}
\,,
\end{align}
%
so we get \(r = l^2/GM\). The energy is given by
%
\begin{align}
  \frac{v^2}{2} - \frac{GM}{r} = E
\,,
\end{align}
%
and if we want to write these with respect to the velocity vector in polar coordinates, \(v_r = \dv*{v}{t}\) and \(v_\theta = r \dv*{\theta }{t}\) we have
%
\begin{align}
  v^2 = \qty(\dv{r}{t})^2 + r^2 \qty(\dv{\theta }{t})^2
\,,
\end{align}
%
while the angular momentum in general is \(\vec{L} = \vec{r} \times \vec{v}\), whose modulus is \(l = \abs{\vec{L}} = r v_{\theta } = r^2 \dv*{\theta }{t}\).
Therefore, \(v_{\theta } = l/r\). So, the velocity is
%
\begin{align}
  v^2= \qty(\dv{r}{t})^2 + \frac{l^2}{r^2}
\,.
\end{align}

Then, the equation for the radial motion of the planet is
%
\begin{align}
  \frac{1}{2} \qty(\dv{r}{t})^2 - \frac{GM}{r} + \frac{l^2}{2r^2} = E
\,,
\end{align}
%
which for large \(r\) tends to 0 from below, while for small \(r\) tends to \(+ \infty\).

The circular orbit is the one which corresponds to the bottom of the potential.

\subsubsection{Relativistic Schwarzschild orbits}

Planets \emph{do not} actually orbit in true ellipses, but this is not actually the case even in Newtonian mechanics, since there are other objects in the universe.
The orbit of Mercury was expected to precede by \(532''\) every \SI{100}{yr}, but people observed an additional \(43''\) every \SI{100}{yr}.
We will compute this.

For semplicity, we will say that in our spherical coordinates Mercury will always have \(\theta = \pi /2\).
The 4-velocity of the planet will be
%
\begin{align}
  u^{\alpha } = \qty(\dv{t}{\tau }, \dv{r}{\tau }, 0, \dv{\varphi }{\tau })
\,,
\end{align}
%
and we have two immediate Killing vectors: \(\xi^{\alpha }_t= (1, \vec{0} )\) and \(\xi^{\alpha }_\varphi = (0,0,0, 1)\) since the metric is independent of \(t\) and \(\varphi\).

We call \(e = - \xi_t \cdot u = (1 - 2GM/r) \dv{t}{\tau }\).

The other Killing vector is \(l = \xi_\varphi \cdot u  =  r^2 \sin^2 \theta \dv*{\varphi }{\tau }\), but \(\theta = \pi /2\) so \(l = r^2 \dv*{\varphi }{\tau }\).

Now we want to impose the condition \(-1 = u \cdot u\):
%
\begin{subequations}
\begin{align}
  -1 &=
  - \qty(1 - \frac{2GM}{r}) \qty(\dv[]{t}{\tau })^2
  + \qty(1 - \frac{2GM}{r})^{-1} \qty(\dv[]{r}{\tau })^2
  + r^2 \sin^2 \theta \qty(\dv{\varphi }{\tau })^2  \\
  &=
  - \qty(1 - \frac{2GM}{r}) \qty(\frac{e}{1 - \frac{2GM}{r}})^2
  + \qty(1 - \frac{2GM}{r})^{-1} \qty(\dv[]{r}{\tau })^2
  + r^2 \sin^2 \theta \qty(\frac{l^2}{r^2})^2  \\
  0&= - e^2 + \qty(\dv{r}{\tau })^2
  + \qty(\frac{l^2}{r^2}+1) \qty(1 - \frac{2GM}{r})
\,,
\end{align}
\end{subequations}
%
so
%
\begin{subequations}
\begin{align}
  e^2-1 &= \qty(\dv{r}{\tau })^2 + \qty(\frac{l^2}{r^2} +1)
  \qty(1 - \frac{2GM}{r}) - 1 \\
  E &=  \frac{1}{2} \qty(\dv{r}{\tau })^2
  + V _{\text{eff}}
\,,
\end{align}
\end{subequations}
%
where
%
\begin{align}
  V_{\text{eff}} = - \frac{GM}{r} + \frac{l^2}{2 r^2} - \frac{GMl^2}{r^3}
\,,
\end{align}
%
and
%
\begin{align}
  E = \frac{e^2-1}{2}
\,,
\end{align}
%
so the GR effects are exactly contained in that last term \(GMl^2r^{-3}\). This is very small: we consider it as a perturbation.
The potential can also be written, suggestively, as
%
\begin{align}
V _{\text{eff}} = - \frac{GM}{r} + \frac{l^2}{2r^2} \qty(1 - \frac{2GM}{r})
\,,
\end{align}
%

Are there circular orbits in this case?

This \(r^{-3}\) term means that for \(r \rightarrow 0\) the effective potential goes to \(- \infty\).

In general we'd expect two stationary points: one which is closer and unstable, and one which is further and stable.

If we differentiate \(\dv*{V _{\text{eff}}}{r}= 0\) we get:
%
\begin{align}
  GM r^2 - l^2 r + 3GM l^2 = 0
\,,
\end{align}
%
and we consider the positive solution:
%
\begin{align}
  r= \frac{l^2 \pm \sqrt{l^4 - 12 G^2M^2l^2}}{2GM}
\,,
\end{align}
%
and we take the plus sign since we want the orbit which is further out.
%
\begin{align}
  r = \frac{l^2}{2GM} \qty(1 + \sqrt{1 - 12 \frac{G^2M^2}{l^2}})
\,,
\end{align}
%
which is the formula for the stable circular orbit.
Expanding for small relativistic corrections we get
%
\begin{align}
  r _{\text{classical}} = \frac{l^2}{2GM} \qty(1+1-6 \frac{G^2M^2}{l^2}) = \frac{l^2}{GM} - 3GM
\,,
\end{align}
%
which is the Newtonian orbit \(r = l^2/GM\) with a correction.

Where is the boundary at which the solution disappears? it is where the square root vanishes:
%
\begin{align}
  l^2 = 12 G^2 M^2
\,,
\end{align}
%
or \(l = GM \sqrt{12}\). Solutions exist as long as the angular momentum is greater than \(GM \sqrt{12}\).

\begin{figure}[H]
\centering
\includegraphics[width=\textwidth]{figures/fixed_L_orbits.pdf}
\caption{Allowed orbits at fixed \(L\). The unstable (lower) branch approaches \(r = 3GM\) asymptotically, the stable (upper) branch allows for arbitrarily large radii.}
\label{fig:fixed_L_orbits.pdf}
\end{figure}

For \(l _{\text{min}}\) we have \(r _{\text{min}} = 6 GM\).
This is called the ISCO: \emph{innermost stable circular orbit}: it is \(3\) times the Schwazschild radius \(2GM\).

\subsubsection{Orbital precession}

Now, we consider elliptical orbits.

The idea is: the angle between two consecutive perihelions is \(2\pi + \delta \varphi _{\text{precession}}\).

In order to find the orbits, we want a relation between different coordinates during the orbit: we will use the equations
%
\begin{subequations}
\begin{align}
  l &= r^2 \dv[]{\varphi }{\tau }  \\
  \frac{1}{2}\qty(\dv{r}{\tau })^2 - \frac{GM}{r} + \frac{l^2}{2r^2} - \frac{GMl^2}{r^3} &= E
\,,
\end{align}
\end{subequations}
%
so \(\dv{}{\tau } = \frac{l}{r^2} \dv{}{\varphi }\). Then:
%
\begin{align}
  \frac{l^2}{2 r^2} \qty(\dv{r}{\varphi })^2 - \frac{GM}{r} + \frac{l^2}{2r^2} - \frac{GMl^2}{r^3} = E
\,,
\end{align}
%
and it is convenient to solve for \(u = r^{-1}\): we get
%
\begin{align}
  \dv[]{r}{\varphi } = - \frac{1}{u^2} \dv{u }{\varphi }
\,,
\end{align}
%
so
%
\begin{subequations}
\begin{align}
  \frac{l^2}{2} u^{4} \frac{1}{ u^{4 }} \qty(\dv{u}{\varphi })^2 - GMu + \frac{l^2u^2}{2} - GMl^2u^3 &= E \\
  \frac{1}{2}\qty(\dv{u}{\varphi })^2 - \frac{GM}{l} u + \frac{u^2}{2} - GMu^3 &= \frac{E}{l^2}
\,,
\end{align}
\end{subequations}
%
and we want to remove \(E\) so we differentiate with respect to \(\varphi \):
%
\begin{align}
  \dv{u }{\varphi } \dv[2]{u}{\varphi } - \frac{GM}{l^2} \dv{u}{\varphi } + u \dv[]{u}{\varphi } - 3GM u^2 \dv{u}{\varphi } = 0
\,,
\end{align}
%
and the orbit is monotonic so \(\dv{u}{\varphi } \neq 0\):
%
\begin{align}
  \dv[2]{u}{\varphi } + u = \frac{GM}{l^2} + 3GMu^2
\,,
\end{align}
%
where the term from \(GR\) is precisely \(3GMu^2\), the rest is fully Newtonian.

This can be solved exactly with respect to complicated elliptic function, but we do it in a simpler way: a nearly circular orbit: \(u = u_c (1+w(\varphi ))\), where \(w \ll 1\).

To the order \(w^{0}\): \(u_c = \frac{GM}{l^2} + 3GM u_c^{2}\), since it is a circular orbit (\(u_c\) is a constant!)

To first order in \(w\), instead, we get:
%
\begin{align}
  u_c \dv[2]{w}{\varphi } + u_c(1+w) = \frac{GM}{l^2} + 3GMu_c^2 (1+2w)
\,,
\end{align}
%
since \(w \ll 1\). But the terms without \(w\) simplify: they satisfy the zeroth order equation. So, we are left with
%
\begin{align}
  \dv[2]{w}{\varphi }  = (6GMu_c-1) w
\,,
\end{align}
%
which is in the form \(\ddot{w} + \omega^2 w =0\), since \(u_c < 1/(6GM)\). If we look at unstable orbits with radii smaller than \(6GM\), then this is exponentially diverging.

\end{document}


% NB: use pdflatex to compile NOT pdftex.  Also make sure youngtab is
% there...

% converting eps graphics to pdf with ps2pdf generates way too much
% whitespace in the resulting pdf, so crop with pdfcrop
% cf. http://www.cora.nwra.com/~stockwel/rgspages/pdftips/pdftips.shtml

\documentclass[10pt,aspectratio=169,dvipsnames]{beamer}
\usetheme[color/block=transparent]{metropolis}

\usepackage[absolute,overlay]{textpos}
\usepackage{booktabs}
\usepackage[utf8]{inputenc}

\usepackage[scale=2]{ccicons}

\usepackage[official]{eurosym}

%use this to add space between rows
\newcommand{\ra}[1]{\renewcommand{\arraystretch}{#1}}

\setbeamerfont{alerted text}{series=\bfseries}
\setbeamercolor{alerted text}{fg=Mahogany}
\setbeamercolor{background canvas}{bg=white}

\newcommand{\R}{\mathbb{R}}

\def\l{\lambda}
\def\m{\mu}
\def\d{\partial}
\def\cL{\mathcal{L}}
\def\co2{CO${}_2$}

% for sources http://tex.stackexchange.com/questions/48473/best-way-to-give-sources-of-images-used-in-a-beamer-presentation

\setbeamercolor{framesource}{fg=gray}
\setbeamerfont{framesource}{size=\tiny}

\newcommand{\source}[1]{\begin{textblock*}{5cm}(10.5cm,8.35cm)
    \begin{beamercolorbox}[ht=0.5cm,right]{framesource}
        \usebeamerfont{framesource}\usebeamercolor[fg]{framesource} Source: {#1}
    \end{beamercolorbox}
\end{textblock*}}

\usepackage{hyperref}

%\usepackage[pdftex]{graphicx}

\graphicspath{{graphics/}}

\DeclareGraphicsExtensions{.pdf,.jpeg,.png,.jpg}

\def\goat#1{{\scriptsize\color{green}{[#1]}}}

\newcommand{\ubar}[1]{\text{\b{$#1$}}}

\let\olditem\item
\renewcommand{\item}{%
\olditem\vspace{5pt}}

\title{Energy System Modelling\\ Summer Semester 2020, Lecture 14}
%\subtitle{---}
\author{
  {\bf Dr. Tom Brown}, \href{mailto:tom.brown@kit.edu}{tom.brown@kit.edu}, \url{https://nworbmot.org/}\\
  \emph{Karlsruhe Institute of Technology (KIT), Institute for Automation and Applied Informatics (IAI)}
}

\date{}

\titlegraphic{
  \vspace{0cm}
  \hspace{10cm}
    \includegraphics[trim=0 0cm 0 0cm,height=1.8cm,clip=true]{kit.png}

\vspace{5.1cm}

  {\footnotesize

  Unless otherwise stated, graphics and text are Copyright \copyright Tom Brown, 2020.
  Graphics and text for which no other attribution are given are licensed under a
  \href{https://creativecommons.org/licenses/by/4.0/}{Creative Commons
  Attribution 4.0 International Licence}. \ccby}
}

\begin{document}

\maketitle

\begin{frame}

  \frametitle{Table of Contents}
  \setbeamertemplate{section in toc}[sections numbered]
  \tableofcontents[hideallsubsections]
\end{frame}

\section{Idea of Principal Component Analysis (PCA)}

\begin{frame}
  \frametitle{The idea of Principal Component Analysis (PCA)}

    \begin{columns}[T]
    \begin{column}{7.5cm}

      Suppose we have a set of time series $x_i(t)$ for $i=1,\dots N$ whose means $\langle \cdot \rangle$ are centred at the origin $\langle x_i(t) \rangle = 0$ for all $i$.

      \vspace{.2cm}

      \alert{Principal Component Analysis (PCA)} is a tool to find the directions in the $N$-dimensional $x_i$ space which cause the biggest variance.

      \vspace{.2cm}

      We change to a new (orthonormal) basis $\rho^k_i$ ($k=1,\dots N$) in $N$-dimensional $x_i$ space where the first basis vector $\rho^1$ is in the direction of highest variance, the second $\rho^2$ in the next highest, etc.

      \vspace{.2cm}

      We can then use this for \alert{dimensional reduction} and ignore directions with low variance.
    \end{column}
    \begin{column}{6.5cm}

        \vspace{.3cm}
        %https://www.forum-csr.net/News/7186/Marktwirtschaftparadox.html
        \includegraphics[trim=0 0cm 0 0cm,width=7cm,clip=true]{price-residual_load-1806.png}

    \end{column}
    \end{columns}

    \source{\url{https://energy-charts.de/}}

\end{frame}

\begin{frame}
  \frametitle{Procedure 1/2}

  \begin{itemize}
  \item Calculate the \alert{covariance matrix}:
    \begin{equation*}
      \Sigma_{ij} = \langle x_i(t) x_j(t) \rangle -\langle x_i(t) \rangle \langle x_j (t) \rangle = \langle x_i(t) x_j(t) \rangle
    \end{equation*}
    remembering that we've arranged $\langle x_i(t) \rangle = 0$. NB: The covariance matrix is \alert{symmetric} ($\Rightarrow$ $N$ orthogonal eigenvectors) and \alert{positive semi-definite} ($\Rightarrow$ eigenvalues $\l_k \geq 0$).

    The diagonal entries $\Sigma_{ii}$ give the variance of each $x_i(t)$.

  \item Find the \alert{eigenvectors} $\rho^k_i$ and \alert{eigenvalues} $\lambda_k$ for $k=1,\dots N$ of the \alert{normalised covariance matrix} $\frac{\Sigma}{\textrm{tr}(\Sigma)}$
    \begin{equation*}
      \frac{1}{\textrm{tr}(\Sigma)}\sum_j \Sigma_{ij} \rho^k_j = \lambda_k \rho^k_i
    \end{equation*}
    The normalization is chosen such that $\sum_{k=1}^N \lambda_k = \textrm{tr} \left(\frac{\Sigma}{\textrm{tr}(\Sigma)}\right) = 1$.
  \end{itemize}

\end{frame}

\begin{frame}
  \frametitle{Procedure 2/2}

  \begin{itemize}
      \item Order the eigenvectors $\rho^k_i$ and eigenvalues $\lambda_k$ from highest $\lambda_k$ to lowest. The value $\lambda_k$ represents the share of the variance of $x_i(t)$ associated with the $k$th component $\rho^k_i$.
    \item We can discard components with low variance, e.g. only keep the first $K$ \alert{principal components} such that $\sum_{k=1}^K\lambda_k \geq  0.95$, i.e. that represent 95\% of the variance.
  \end{itemize}

  Note that the $\rho^k_i$ is an orthogonal matrix  that defines a new basis for the $N$-dimensional space such that the projections of $x_i(t)$ onto this new basis are uncorrelated with variance $\propto\lambda_k$.

  Orthogonal means the matrix multiplied by its transpose gives the identity matrix $\mathbb{I}$:
  \begin{equation*}
    \sum_i \rho^k_i \rho^l_i = \mathbb{I}_{kl} = \left\{\begin{array}{lr} 0 \text{ if } k \neq l \\ 1  \text{ if } k = l \end{array} \right.
  \end{equation*}
  If we now project $x_i(t)$ onto the $\rho^k_i$, $x_i(t) = \sum_k a_k(t) \rho^k_i$, show that $a_k(t) = \sum_i  \rho^k_i x_i(t)$ and now
  \begin{equation*}
    \langle a_k(t) a_l(t) \rangle = \sum_{i,j}\rho^k_i \rho^l_j \langle x_i(t) x_j(t) \rangle  = \sum_{i,j}\rho^k_i    \Sigma_{ij} \rho^l_j =  \sum_{i}\rho^k_i \textrm{tr}(\Sigma) \lambda_l \rho^l_i = \textrm{tr}(\Sigma) \lambda_k \mathbb{I}_{kl}
  \end{equation*}

\end{frame}

\begin{frame}
  \frametitle{PCA as optimisation problem}
  We can also represent this procedure as an optimisation problem.

  We define the projection of $x_i(t)$ onto some unit vector $\rho^1_i$ ($\rho^1 \cdot \rho^1 =1$):
  \begin{equation*}
    a_1(t) = x(t) \cdot \rho^1
  \end{equation*}
  We choose the $\rho^1$ such that the variance of $a_1(t)$:
  \begin{equation*}
    \langle a_1(t)^2 \rangle = \langle (x(t) \cdot \rho^1)^2 \rangle
  \end{equation*}
  is maximised. This is an optimisation problem!
  \begin{equation*}
    \max_{\{\rho_i^1\}} \sum_{i,j} \left\langle x_i(t)x_j(t) \rho^1_i  \rho^1_j \right\rangle
  \end{equation*}
  such that
  \begin{equation*}
    \sum_i \rho^1_i \rho^1_i = 1 \hspace{.5cm} \leftrightarrow \lambda_1
  \end{equation*}

\end{frame}

\begin{frame}
  \frametitle{PCA as optimisation problem}

  KKT gives us from stationarity
  \begin{equation*}
    0 = \frac{\d \mathcal{L}}{\d \rho^1_i} = \frac{\d f}{\d \rho^1_i} - \lambda_1 \frac{\d g_1}{\d \rho^1_i} = 2\sum_j \rho^1_j \left\langle x_i(t)x_j(t) \right\rangle - 2\lambda_1 \rho^1_i
  \end{equation*}
  This is nothing other than the eigenvalue equation for the covariance matrix $\Sigma_{ij} = \left\langle x_i(t)x_j(t) \right\rangle$!

  Now consider the remainder defined by
  \begin{equation*}
    \delta_i(t) = x_i(t) - a_1(t) \rho^1_i
  \end{equation*}

  Now let's find a second unit vector $\rho^2_i$ which is orthogonal to $\rho^1_i$ and points in the direction of greatest variance of the remainder $\delta_i(t)$
  \begin{equation*}
    \max_{\{\rho_i^2\}} \sum_{i,j} \left\langle (\delta_i (t) \cdot \rho^2)^2 \right\rangle =     \max_{\{\rho_i^2\}} \sum_{i,j} \left\langle (x_i (t) \cdot \rho^2)^2 \right\rangle
  \end{equation*}
  where we've used the fact that $\rho^1 \cdot \rho^2 = 0$. Repeating optimisation, we get another eigenvalue-eigenvector pair. Repeat until we have all eigenvalues and eigenvectors.

\end{frame}

\section{Application to Power System}

\begin{frame}
  \frametitle{Application to power injections for highly renewable European system}

    \begin{columns}[T]
      \begin{column}{7.5cm}

        We're now going to apply PCA to the solved dispatch and network flows for a highly renewable European power system.

        \vspace{.2cm}

        First we apply PCA to the power injections $p_i(t) = \sum_s g_{i,s}(t) - d_i(t)$ (generation minus demand). We compute the power injection covariance matrix:
        \begin{equation*}
          \Sigma^p_{ij} = \langle p_i(t) p_j(t) \rangle -\langle p_i(t) \rangle \langle p_j (t) \rangle
        \end{equation*}
        NB: $i,j$ run over the $N$ different network nodes.

        \vspace{.2cm}

        Next we find the eigenvectors and eigenvalues $\lambda_k^p$ that represent the principal components.

    \end{column}
    \begin{column}{7cm}

      Average power injection $\langle p_i(t) \rangle$ at each node:
        \vspace{.1cm}
        %https://www.forum-csr.net/News/7186/Marktwirtschaftparadox.html
        \includegraphics[trim=0 0cm 0 0cm,width=7.5cm,clip=true]{pca-pi_mean.png}

    \end{column}
  \end{columns}

    \source{\href{https://arxiv.org/abs/1807.07771}{Hofmann et al, 2018}}
\end{frame}

\begin{frame}
  \frametitle{Power injection components}

  The first 3 principal components represent the major axes of weather variations (1st is coastal wind production, 2nd is North-South seasonal pattern, 3rd is East-West load and solar daily pattern - check by Fourier transforming projection onto components):

  \vspace{.2cm}
  \centering
  \includegraphics[trim=0 0cm 0 0cm,width=14cm,clip=true]{pca-pi_components.png}

  \source{\href{https://arxiv.org/abs/1807.07771}{Hofmann et al, 2018}}
\end{frame}

\begin{frame}
  \frametitle{Application to resulting power flows}

    \begin{columns}[T]
      \begin{column}{7.5cm}

        Next we apply PCA to the resulting power flows $f_\ell$, related via the Power Transfer Distribution Factors
        \begin{equation*}
          f_\ell = \sum_i H_{\ell i} p_i
        \end{equation*}
        (we use the notation $H =  K^t L^{-1}$ for the PTDF to make things easier later).

        \vspace{.2cm}

        We compute the power flow covariance matrix:
        \begin{equation*}
          \Sigma^f_{\ell m} = \langle f_\ell(t) f_m(t) \rangle -\langle f_\ell(t) \rangle \langle f_m (t) \rangle
        \end{equation*}
        NB: $\ell,m$ run over the $L$ different network lines.

        \vspace{.2cm}

        Next we find the eigenvectors and eigenvalues $\lambda_n^f$ that represent the principal components.

    \end{column}
    \begin{column}{7cm}

      Average power flow $\langle f_\ell(t) \rangle$ at each line:
        \vspace{.3cm}
        %https://www.forum-csr.net/News/7186/Marktwirtschaftparadox.html
        \includegraphics[trim=0 0cm 0 0cm,width=7.5cm,clip=true]{pca-fl_mean.png}

    \end{column}
  \end{columns}

    \source{\href{https://arxiv.org/abs/1807.07771}{Hofmann et al, 2018}}

\end{frame}

\begin{frame}
  \frametitle{Power flow components}

  The first 3 principal components represent the major flow (1st is flow to North-West, 2nd to North-East and 3rd shows multiple directions). Note that the first three make up a \alert{much larger share of the variance} than for the power injection case.

  \vspace{.2cm}
  \centering
  \includegraphics[trim=0 0cm 0 0cm,width=14cm,clip=true]{pca-fl_components.png}

  \source{\href{https://arxiv.org/abs/1807.07771}{Hofmann et al, 2018}}
\end{frame}

\begin{frame}
  \frametitle{Number of relevant components}

  \begin{itemize}
  \item How many principal components $K$ do we need to represent 95\% of the total variance?
    \begin{equation*}
      \sum_{k=1}^K \lambda_k \geq  0.95
    \end{equation*}
  \item How does this number depend on the spatial resolution, i.e. the number of network nodes $N$ used to represent the European grid?
  \end{itemize}
  \vspace{.2cm}
  \centering
  \includegraphics[trim=0 0cm 0 0cm,width=14cm,clip=true]{pca-p_v_f.png}

  \source{\href{https://arxiv.org/abs/1807.07771}{Hofmann et al, 2018}}
\end{frame}

\begin{frame}
  \frametitle{Number of relevant components}

  \centering
  \includegraphics[trim=0 0cm 0 0cm,width=14cm,clip=true]{pca-p_v_f.png}

  \raggedright
  This graph is odd for (at least) 3 reasons:
  \begin{itemize}
  \item Why does the number of components required for the power injection rise then saturate at several hundred nodes? (Answer: correlation length)
  \item Why are so few components required to represent the power flow?
    \item Why doesn't the number of components change for the power flow?
  \end{itemize}

  \source{\href{https://arxiv.org/abs/1807.07771}{Hofmann et al, 2018}}
\end{frame}

\begin{frame}
  \frametitle{Relation of injection to flow covariance matrix}

  We have the following equations:
  \begin{align*}
    f_\ell & = \sum_i H_{\ell i} p_i \\
    \Sigma^p_{ij} & = \langle p_i(t) p_j(t) \rangle -\langle p_i(t) \rangle \langle p_j (t) \rangle \\
          \Sigma^f_{\ell m} & = \langle f_\ell(t) f_m(t) \rangle -\langle f_\ell(t) \rangle \langle f_m (t) \rangle
  \end{align*}
  So how are the flow covariance $\Sigma^f_{\ell m}$ and injection covariance $\Sigma^p_{ij}$ matrices related?

  \pause
  \begin{equation*}
     \Sigma^f = H\Sigma^p H^t
  \end{equation*}
\end{frame}

\begin{frame}
  \frametitle{Relation of injection to flow covariance matrix}
  Now consider another $N\times N$ matrix $M$ defined by
  \begin{equation*}
    M = \Sigma^p H^tH
  \end{equation*}
  Note that the first term $\Sigma^p$ comes from the injection
  pattern, whereas the second part $H^tH$ is entirely determined by
  the topology of the network (built from $K$ and $L$).

  If $\nu^k$ is an eigenvector of $M$ with eigenvalue $\eta_k$, $M\nu^k = \eta_k \nu^k$, show that $H\nu^k$ is an eigenvector of $\Sigma^f$ with eigenvalue $\eta_k$.
  \pause
  \begin{equation*}
    \Sigma^f H\nu^k = H \Sigma^p H^t H \nu^k = H M \nu^k = \eta_k H\nu^k
  \end{equation*}

  So to analyse the principal components of the flow, it suffices to study the eigenvectors of matrix $M$.

  It turns out that if the first few eigenvectors of $H^t H$ and
  $\Sigma^p$ with the strongest eigenvalues strongly overlap, then they magnify each other to the
  exclusion of other eigenvectors.

  This is what happens for $M$ (and by extension $\Sigma^p$): the eigenvectors of $H^tH$ magnify only the first few principal components of $\Sigma^p$, which then dominate $\Sigma^f$.

\end{frame}

\begin{frame}
  \frametitle{Network topology reinforces power injection pattern to magnify flow pattern}

  \centering
  \includegraphics[trim=0 0cm 0 0cm,width=14cm,clip=true]{pca_magnification.png}

\end{frame}

\begin{frame}
  \frametitle{Network Topology reinforces flow pattern}

  To find out more, see our paper:

  Fabian Hofmann, Mirko Schäfer, Tom Brown, Jonas Hörsch, Stefan Schramm, Martin Greiner, ``Principal Flow Patterns across renewable electricity networks,'' EPL, 2018, \href{https://arxiv.org/abs/1807.07771}{\bf\color{blue}\underline{link}}

\end{frame}
\end{document}


\section{Algorithms}
	In this section we will present our aproach to tackle the speaker recognition problem.

    An utterance of a user is collected during enrollment procedure.
    Further processing of the utterance follows following steps:
    \subsection{VAD}
        Signals must be first filtered to rule out the silence part, otherwise the
        training might be seriously biased. Therefore \textbf{Voice Activity Detection} must
        be first performed.

        An observation found is that, the corpus provided is nearly noise-free.
        Therefore we use a simple energy-based approach
        to remove the silence part, by simply remove the frames that the average
        energy is below 0.01 times the average energy of the whole utterance.

        This energy-based method is found to work well on database, but not
        on GUI.
        We use LTSD(Long-Term Spectral Divergence) \cite{ltsd1}
        algorithm on GUI, as well as noise reduction technique from SOX\cite{sox} to gain better result in real-life application.

        LTSD algorithm splits a utterance into overlapped frames, and give scores for each frame on
        the probability that there is voice activity in this frame. This probability will be accumulated
        to extract all the intervals with voice activity. A picture depicting the principle of LTSD is as followed:

        \begin{figure}[H]
          \centering
          \includegraphics[width=0.6\textwidth]{img/ltsd.png}
        \end{figure}
		Since this is not our primary-task, we shall not expand details here. For further
		information on how these works, please consult original paper.

        \input{feature}
        \input{model}


\section{Other rules}

\subsection{Conditional rules}
\label{sec-cond}

Conditional rules allow us to introduce and eliminate the conditional wffs
{\wffif} and conditional terms {\termif}.

\begin{bnf}
	{\wffif}  \sep {\bf wffif} {\wff}$_1$ {\bf then} {\wff}$_2$ {\bf else}
				   {\wff}$_3$ \\
	{\termif} \sep {\bf trmif} {\wff} {\bf then} {\term}$_1$ {\bf else}
				   {\term}$_2$
\end{bnf}

Note that the {\termif} construct is not first order.
However, it can easily be shown that {\termif} can be defined as a conservative
extension of first order logic using an induction on the length of deductions.

\renewcommand{\arraystretch}{0.5}
\[
\begin{array}{|c|c||c|c|} \hline
\multicolumn{2}{|c||}{\mbox{\bf Introduction rules}} &
\multicolumn{2}{c|}{\mbox{\bf Elimination rules}} \\ \hline
\begin{array}{l}
\\ \\ \\ \\ \\
\mbox{{\em wif}} \  I
\end{array}
&
\begin{array}{cc}
\\ \\
\begin{array}{c}
{[A]}\\
\vdots\\
B
\end{array}
\ \ \
\begin{array}{c}
{[\neg A]}\\
\vdots\\
C
\end{array}
\\
\hline\\
\begin{array}{c}
\mbox{{\em wffif}} \ A \ \mbox{{\em then}} \ B \ \mbox{{\em else}} \ C
\end{array}
\end{array}
&
\begin{array}{l}
\\ \\ \\ \\ \\
\mbox{{\em wif}} \  E
\end{array}
&
\begin{array}{cc}
\\ \\
\begin{array}{c}
\\ \\ \\ \\
A
\end{array}
\ \ \
\begin{array}{c}
\\ \\ \\ \\
\mbox{{\em wffif}} \ A \ \mbox{{\em then}} \ B \ \mbox{{\em else}} \ C
\end{array}
\\
\hline\\
\begin{array}{c}
B
\end{array}
\end{array}
%\fraz{\Gamma \vdash A \ \ \Delta \vdash \mbox{{\em wffif}} \ A \ \mbox{{\em then}} \ B \
%\mbox{{\em else}} \ C}
%     {\Gamma,\Delta \vdash B}
\\ %\hline
& &
\begin{array}{l}
\\ \\ \\ \\ \\
\mbox{{\em wif}} \  E_{\neg}
\end{array}
&
\begin{array}{cc}
\\ \\
\begin{array}{c}
\\ \\ \\ \\
\neg A
\end{array}
\ \ \
\begin{array}{c}
\\ \\ \\ \\
\mbox{{\em wffif}} \ A \ \mbox{{\em then}} \ B \ \mbox{{\em else}} \ C
\end{array}
\\
\hline\\
\begin{array}{c}
C
\end{array}
\end{array}
\\ %\hline
\begin{array}{l}
\\ \\ \\ \\ \\
\mbox{{\em tif}} \  I
\end{array}
&
\begin{array}{cc}
\\ \\
\begin{array}{c}
{[A]}\\
\vdots\\
B(t_1)
\end{array}
\ \ \
\begin{array}{c}
{[\neg A]}\\
\vdots\\
B(t_2)
\end{array}
\\
\hline\\
\begin{array}{c}
B(\mbox{{\em termif}} \ A \ \mbox{{\em then}} \ t_1 \ \mbox{{\em else}} \ t_2)
\end{array}
\end{array}
&
\begin{array}{l}
\\ \\ \\ \\ \\
\mbox{{\em tif}} \  E
\end{array}
&
\begin{array}{cc}
\\ \\
\begin{array}{c}
\\ \\ \\ \\
A
\end{array}
\ \ \
\begin{array}{c}
\\ \\ \\ \\
B(\mbox{{\em termif}} \ A \ \mbox{{\em then}} \ t_1 \ \mbox{{\em else}} \ t_2)
\end{array}
\\
\hline\\
\begin{array}{c}
B(t_1)
\end{array}
\end{array}
\\ %\hline
& &
\begin{array}{l}
\\ \\ \\ \\ \\
\mbox{{\em tif}} \  E_{\neg}
\end{array}
&
\begin{array}{cc}
\\ \\
\begin{array}{c}
\\ \\ \\ \\
\neg A
\end{array}
\begin{array}{c}
\\ \\ \\ \\
B(\mbox{{\em termif}} \ A \ \mbox{{\em then}} \ t_1 \ \mbox{{\em else}} \ t_2)
\end{array}
\\
\hline\\
\begin{array}{c}
B(t_2)
\end{array}
\end{array}
\\
& & & \\ \hline
\end{array}
\]
\renewcommand{\arraystretch}{1}

\subsection{Structural rules}

Structural rules are useful when performing theorem proving.


\vspace{-.1em}
\subsection{Dependent Types and Co-Constructors}
\p{To see why the metaconstructor problem
determines how extensively Dependent Types are
supported in a type system, consider a variation
on the range \ZeroToOneHundred{} type.
In lieu of a fixed range, consider a procedure
taking a (variable) \Tvar{}-range \rRan{} and a number \xSym{}
\i{which must be in that range}.  Here \xSym{}
\q{depends} on \rRan{} \mdash{} its \i{type} is \rRan{}
seen as its own \TVOneToVTwo{} type \mdash{} so
\xSym{} can vary among many
range-types, only being fixed at runtime.  Defining a
\i{type} for procedures meeting those
\i{specifications} is a classic problem of
Dependent Type theory.
}
\p{Using the \rRan{}-type as before, the type of \fFun{}'s second parameter
would then be \Tvar{} restricted to the \rRan{} interval, but here
\rRan{} is not fixed in \fFun{}'s declaration but rather passed in to
\fFun{} as a parameter.  Unless we know \i{a priori} that only
a specific set of \rRan{}s in the first parameter will ever be encountered,
the compiler has to be prepared for \xSym{} being assigned any one
of many different range types, depending on the \fFun{}'s first argument.
In particular, the compiler cannot know ahead of time which
constructor to call for \xSym{}.  More precisely, it is impossible
for the compiler to have \i{separate} constructors for millions
of possible range types.  Instead, the compiler must either
\q{create} a constructor \q{on the fly} or else have
some generic constructor which services many range-types,
but then requires extra information to establish
\i{which} range is desired.
}
\p{Assuming we use co-constructors to wrap constructors,
these two options for compiler writers correspond to
the choice of \i{either} creating ad-hoc co-constructors
\i{or} designing co-constructors as a
compound data structure.  We could certainly write a function that takes a range and a value and
ensures that the value fits the range \mdash{} perhaps by throwing an
exception if not, or mapping the value to the range's closest point.
Such a function would provide common functionality for a family of
constructors each associated with a given range.  But a function (\cfFun{}, say)
providing \q{common functionality} for value constructors is not necessarily
itself a value constructor.\footnote{Here I say \q{value constructor} to clarify that I am not
commenting on \i{type constructors}, which derive specialized
types from generic ones.
}
To treat such a function as a
\i{real} value constructor we would have to add contextual modifiers:
\cfFun{} is a value constructor for range-type \rRan{} in the
presence of a \Tvar{}-pair to specify \rRan{} at runtime.
The co-constructor for a range type \TrRan{} is accordingly the
\q{common functionality} base function \i{plus} \Tvar{}'s
passed to it \mdash{} some sort of \Cfr{} compound data structure,
again by analogy to \inc{} and
\addOne{} (see footnote \ref{fofgplausible}, above).  Here again, though,
the co-constructor is a temporary data structure,
created on-the-fly to model the desired value constructor
for an \xSym{} whose type (and therefore whose constructor)
is not known until runtime.  I contend, on examples like
these, that Dependant Typing for a type system \TyS{} is thus logically
equivalent to the possibility of \TyS{} co-constructors
being temporary values.
}
\p{But value constructors (and by extension co-constructors)
are not just any function-value: they have a privileged
status \visavis{} types, and may be invoked whenever an appropriately-typed
value is used.  Many constructors are called behind-the-scenes:
in \Cpp{}, the standard function-call mechanism is
\q{pass by value}, wherein values are \i{copied} when passed
between procedures; but any copy can potentially
invoke a so-called \q{copy constructor}.  Indeed, programmers
use certain constructors as \q{hooks} to silently
insert logic into normal program flow (usually this is
to make complex types behave like built-in-types from
client code's point of view).  Allowing large type families (like one type
for each \int{} or each two-number range \rRan{} \mdash{} similar to \q{inductive typing} as
discussed by Edwin Brady in the context of the Idris language
\cite[p. 12]{EdwinBradyImpl}) \mdash{} could easily conflict with
user-defined constructor overrides: users (meaning, in this context,
library developers) would need not only to write their own
(e.g., copy) constructors, but to hook into a complex
run-time mechanism for creating constructors ad-hoc as temporary values.
Conversely, forcing co-constructors to be
addressable prohibits \q{large} type families \mdash{} like types indexed
over other (non-enumerative) types
(see e.g. \cite[p. 4]{BernardyEtAl}) \mdash{} at least as \i{actual} types.
This apparently precludes full-fledged Dependent Types, since
dependent-typed values invariably require in general some extra
contextual data \mdash{} not just a function-pointer \mdash{} to designate the
desired value constructor at the point where a value,
attributed to the relevant dependent type,
is needed.  It may be infeasible to add the requisite contextual
information at every point where a dependent-typed value has to be constructed
\mdash{} unless, perhaps, a description of the context can be packaged and
carried around with the value, sharing the value's lifetime.
}
\p{As I will now review, this analysis in the realm of
Dependent Types carries over into \i{typestate},
which is another mechanism intended to model
coding requirements via type-checkable specifications.
}


\documentclass{article}
\title{Automata}
\author{Jeroen F. J. Laros}
\date{August 6, 2004}
\usepackage{../graphs/graphs}
\usepackage{amsfonts, amssymb, amsthm}
\frenchspacing
\setlength{\parindent}{0pt}
\begin{document}

\renewcommand{\qedsymbol}{$\blacksquare$}
\newcommand{\bs}{\begin{small}}
\newcommand{\es}{\end{small}}
\newcommand{\bS}{\begin{tiny}}
\newcommand{\eS}{\end{tiny}}
\newcommand{\monoit}[1]{\texttt{\textit{#1}}}

\newtheorem{theorem}{Theorem}[subsection]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{corollary}[theorem]{Corollary}

\theoremstyle{definition}
\newtheorem{example}[theorem]{Example}
\newtheorem{definition}[theorem]{Definition}
\newtheorem{remark}[theorem]{Remark}

\maketitle

\section{Introduction}
Automatic sequences are connected in a fundamental way with substitutions of
\emph{constant length}.

\begin{definition}[Finite automaton] \label{def:finite_automaton}
A finite automaton is a 5-tuple $A = \{\mathcal{S}, \Delta, \delta, I, F\}$
in which:
\begin{itemize}
\item $\mathcal{S}$ is the finite set of states.
\item $\Delta$ is the finite alphabet of labels.
\item $\delta \subseteq \mathcal{S} \times \Delta \times \mathcal{S}$ is the
      collection of transitions.
\item $I \subseteq \mathcal{S}$ is the collection of initial states.
\item $F \subseteq \mathcal{S}$ is the collection of final states.
\end{itemize}
\end{definition}

A finite automaton is represented as a directed graph with a set of vertices
$\mathcal{S}$ called \emph{states}, a set of edges $\delta$ called
\emph{transitions}
and specially marked subsets of states $I$ and $F$, being the initial and final
states.

For our purposes, we will restrict ourselves to automata that have
$F = \mathcal{S}$ as the set of final states, so we will leave notion $F$
out unless stated otherwise. The states in $I$ are marked with a $\Uparrow$.

\begin{definition}[Finiteness] \label{def:finiteness}
An automaton is called \emph{finite} if $\mathcal{S}$ is finite.
\end{definition}

\begin{definition}[Determinism] \label{def:determinism}
An automaton is called \emph{deterministic} if the following two conditions
hold:
\begin{itemize}
\item $\exists (p \in I) \forall (q  \in \mathcal{S})
\{q = p \lor q \notin I\}$
\item $\forall (p \in \mathcal{S}) \forall (a \in \Delta)
\forall (q \in \mathcal{S}) \forall (r \in \mathcal{S})
\{(p, a, q) \in \delta \land (p, a, r) \in \delta \Rightarrow q = r\}$.
\end{itemize}
\end{definition}

In other words:
\begin{itemize}
\item There must be one and only one initial state.
\item There can be no two branches with the same label coming from the same
  state.
\end{itemize}
% Picture of non-deterministic automaton. {{{1
\begin{graph}(0, 3)(-4, -1.5)
  \graphnodecolour{1}
  \graphnodesize{1}
  \roundnode{s1}(-2, 0) \nodetext{s1}(0, 0){$a$}
  \roundnode{s2}(0, 0) \nodetext{s2}(0, 0){$b$}

  \dirloopedge{s1}{50}(-1, 0) \freetext(-3.6, 0){0}
  \diredge{s1}{s2} \edgetext{s1}{s2}{0}

  \freetext(-2, -0.7){$\Uparrow$}
  \freetext(-2.5, -1.2){non-deterministic}
\end{graph}
%}}}1
% Picture of deterministic automaton. {{{1
\begin{graph}(0, 3)(-9, -1.5)
  \graphnodecolour{1}
  \graphnodesize{1}
  \roundnode{s1}(-2, 0) \nodetext{s1}(0, 0){$a$}
  \roundnode{s2}(0, 0) \nodetext{s2}(0, 0){$b$}

  \dirloopedge{s1}{50}(-1, 0) \freetext(-3.6, 0){0}
  \diredge{s1}{s2} \edgetext{s1}{s2}{1}

  \freetext(-2, -0.7){$\Uparrow$}
  \freetext(-2.5, -1.2){deterministic}
\end{graph}
%}}}1

\begin{definition}[Completeness] \label{def:completeness}
An automaton is \emph{complete} (or total) if the following condition holds:
\begin{itemize}
\item $\forall (p \in \mathcal{S}) \forall (a \in \Delta)
\exists (q \in \mathcal{S}) \{(p, a, q) \in \delta\}$
\end{itemize}
\end{definition}

In other words: Each state must have $|\Delta|$ outgoing branches.

% Picture of non-complete automaton. {{{1
\begin{graph}(0, 3)(-4, -1.5)
  \graphnodecolour{1}
  \graphnodesize{1}
  \roundnode{s1}(-2, 0) \nodetext{s1}(0, 0){$a$}
  \roundnode{s2}(0, 0) \nodetext{s2}(0, 0){$b$}

  \dirloopedge{s1}{50}(-1, 0) \freetext(-3.6, 0){0}
  \diredge{s1}{s2} \edgetext{s1}{s2}{1}

  \freetext(-2, -0.7){$\Uparrow$}
  \freetext(-2.5, -1.2){non-complete}
\end{graph}
%}}}1
% Picture of complete automaton. {{{1
\begin{graph}(0, 3)(-9, -1.5)
  \graphnodecolour{1}
  \graphnodesize{1}
  \roundnode{s1}(-2, 0) \nodetext{s1}(0, 0){$a$}
  \roundnode{s2}(0, 0) \nodetext{s2}(0, 0){$b$}

  \dirloopedge{s1}{50}(-1, 0) \freetext(-3.6, 0){0}
  \dirloopedge{s2}{50}(1, 0) \freetext(1.6, 0){0,1}
  \diredge{s1}{s2} \edgetext{s1}{s2}{1}

  \freetext(-2, -0.7){$\Uparrow$}
  \freetext(-2.5, -1.2){complete}
\end{graph}
%}}}1

\section{$k$-automata}
The $k$-automaton (not a 2-tape automaton or transducer, as stated in
\cite{Fogg} page 12, but rather a Moore automaton) is a finite,
deterministic and complete automaton with $|\Delta| = k$, expanded with an
output function or exit map.

So a $k$-automaton is an automaton with states $\mathcal{S}$. Each state has
$k$ outgoing branches, labeled $0, \ldots, k - 1$. Furthermore, there is only
one initial state. Each state also has an output function. For $k$-automata
we use the following notation.

\begin{definition}[$k$-automaton] \label{def:k-automaton}
For $k \in \mathbb{N} \ge 2$ denote by
\begin{itemize}
\item $\mathcal{S}$: A finite set of states. There is a unique
      $\iota \in \mathcal{S}$ called the initial state.
\item $\Delta$: $k$ labels indicated by integers from 0 to $k - 1$.
\item $\mathcal{L}$: The input language, in this case always $\Delta^*$.
\item $\sigma: S \to S^k$: The substitution such that
      $\sigma(a) = \sigma_0(a) \sigma_1(a) \ldots \sigma_{k - 1}(a)$ indicates
      the endpoints of the transitions starting from $a$ with labels
      $0, 1, \ldots, k - 1$, respectively.
\item $Y$: The output alphabet. We usually take $Y = \mathcal{S}$.
\item $\varphi$: A function from $\mathcal{S}$ to $Y$ called the exit map. We
      usually take $\varphi =$ Id.
\end{itemize}
\end{definition}

\begin{remark} \label{rem:output}
Normally, an automaton accepts a string if it is in
a final state after having read the complete input. In this case, the final
state results (via $\varphi$) in an output.
\end{remark}

\begin{remark} \label{rem:generate_accept}
Note that we use automata to generate a sequence, not to recognize one as is
usual in computer science. Further on we shall prove that most of the generated
sequences can not be recognized by finite automata.
\end{remark}

\begin{example} \label{ex:ab_star}
\begin{eqnarray*}
&&k = 2\\
&&\mathcal{S} = \{a, b\}, \iota \in \mathcal{S} = \{a\}\\
&&\Delta = \{0, 1\}\\
&&\sigma:\{a, b\} \to \{a, b\}^*, \sigma(a) \to ab,
\sigma(b) \to ab\\
&&Y = \{a, b\}\\
&&\varphi: \varphi(a) \to a, \varphi(b) \to b
\end{eqnarray*}
The automaton is given by the directed graph

% Picture of mod-2 automaton. {{{1
\begin{graph}(0, 3)(-4, -1.5)
  \graphnodecolour{1}
  \graphnodesize{1}
  \roundnode{s1}(-2, 0) \nodetext{s1}(0, 0){$a$}
  \roundnode{s2}(0, 0)  \nodetext{s2}(0, 0){$b$}

  \dirloopedge{s1}{50}(-1, 0) \freetext(-3.6, 0){0}
  \dirbow{s1}{s2}{.2} \bowtext{s1}{s2}{.2}{1}
  \dirbow{s2}{s1}{.2} \bowtext{s2}{s1}{.2}{0}
  \dirloopedge{s2}{50}(1, 0) \freetext(1.6, 0){1}

  \freetext(-2, -0.7){$\Uparrow$}
\end{graph}\\
%}}}1
The substitution $\sigma$ (of constant length 2) has only one fixed point;\\
\\
\monoit{u = ababababababababababababababababababababababababab\ldots}
$= (ab)^\mathbb{N}$.\\
\\
If we take the base 2 expansion of an integer (let us say the decimal
number 22) and feed it to the automaton above, the automaton receives the
digits 10110 and will be in state $a$ when it starts.\\
After reading the first digit, it will be in state $b$, after reading the
second one the automaton will be in state $a$. The table below shows the path
taken:\\
\\
\begin{tabular}{c|c|c|l}
state & transition & next state & tail\\
\hline
$i=a$ & 1 & $b$ & 0110\\
$b$   & 0 & $a$ & 110\\
$a$   & 1 & $b$ & 10\\
$b$   & 1 & $b$ & 0\\
$b$   & 0 & $a$ &\\
$a$   &   &   &
\end{tabular}\\
\\
It will be clear that this automaton will always reach state $a$ if the last
digit is 0 and state $b$ if it is 1, so it maps any integer $n$ to $a$ if and
only if $n \mathrm{\ mod\ } 2 = 0$ and to $b$ if and only if
$n \mathrm{\ mod\ } 2 = 1$.

Thus if we feed the binary sequence 0, 1, 10, 11, 100, \ldots of non-negative
integers to the automaton, we will get the sequence $u$.
\end{example}

Example \ref{ex:ab_star} shows a duality between automata and words invariant
under substitutions. We shall study this duality in the sequel.

\subsection{Direct reading}
\begin{definition}[Letter-to-letter projection] \label{def:letter-to-letter}
Consider a map from a finite alphabet $\mathcal{A}$ to an other finite alphabet
$\mathcal{B}$. This map extends in a natural way (by concatenation) to a map
from $\mathcal{A}^* \cup \mathcal{A}^\mathbb{N}$ to
$\mathcal{B}^* \cup \mathcal{B}^\mathbb{N}$.
\end{definition}

\begin{definition}[Direct reading] \label{def:direct_reading}
A sequence $u = (u_n)_{n \in \mathbb{N}}$ with values in $Y$ is $k$-automatic
in direct reading if it can be generated by a $k$-automaton as follows: For
$n = 0, 1, \ldots$
\begin{itemize}
\item let $\sum_{i=0}^j n_i k^i (n_j \neq 0)$ be the base $k$ expansion of an
      integer $n$.
\item initialize the automaton and feed it with the sequence
      $n_j, \ldots, n_ 1, n_0$, note that the most significant digit is read
      first.
\item put $u_n = \varphi(a(n))$, if the automaton is in state $a(n)$ after all
      letters have been read.
\end{itemize}
\end{definition}

\begin{theorem} \label{thm:direct_reading}
A sequence $u$ is $k$-automatic in direct reading if and only if $u$ is the
image of a letter-to-letter projection of a fixed point of a substitution of
constant length $k$.
\end{theorem}

\begin{proof}
$\Leftarrow$ Let $u$ be a fixed point of a substitution $\sigma$ of length
$k$ over the alphabet $\mathcal{A}$. We construct a $k$-automaton in direct
reading. Let $\mathcal{S = A}$. We make a transition from $a$ to $b$ labeled
$i$ if $b$ occurs in $\sigma(a)$ at position $i + 1$. Take
$\iota \in \mathcal{S} = u_0$ as the initial state. Take $\varphi =$ Id.
Let $\sum_{i = 0}^t n_i k^i$ be the $k$-adic expansion of $n$. We start from
$u(0)$, then go to the $(n_t + 1)$--th letter of $\sigma(u(0))$, denoted by
$a_1$, then go to the $(n_{t - 1} + 1)$--th letter of $\sigma(a_1)$, which is
also the $(kn_t + n_{t - 1} + 1)$--th letter of $\sigma^2(u(0))$, and so on.
After $t$ steps we arrive at the $(n + 1)$--th letter of
$\sigma^{t + 1}(u_0)$, which is $u(n)$. We have constructed an automaton that
generates the sequence $u$ in direct reading. If $v$ is the image of a
letter-to-letter projection $\varphi: \mathcal{A} \to \mathcal{B}$ of the
fixed point $u = (u(n))_{n \in \mathbb{N}} \in \mathcal{A}^\mathbb{N}$ of a
substitution $\sigma$ of constant length $k$ defined on the alphabet
$\mathcal{A}$. Then $v$ is generated by the same automaton that generated $u$,
but with the projection $\varphi$ as output function.

$\Rightarrow$ Let $u$ be a sequence generated by a $k$-automaton in direct
reading. Let $\mathcal{S}$ be the set of states of the automaton and let
$f_0, \ldots, f_{k - 1}$ be the transition maps (hence
$f_i: \mathcal{S \to S}$ maps state $j$ to the state which is reached by
following transition $i$ from state $j$ for every $j \in \mathcal{S}$). Define
the substitution of constant length $\sigma = f_0 \dots f_{k - 1}$ over
$\mathcal{S}$. Let $v$ be the fixed point of $\sigma$ beginning with the
initial state $\iota$. It is easily checked that the sequence $u$ is the image
by the output function $\varphi$ of the fixed point $v$.
\end{proof}

\begin{remark}
When using direct reading we map the initial state $\iota$ onto itself with
label 0 by default. This is a direct consequence of the existence of the fixed
point of a substitution.
\end{remark}

\begin{example}[The Cantor sequence]
The Cantor sequence is defined as the invariant word under the substitution:
$\sigma: \sigma(a) \to aba, \sigma(b) \to bbb$. With $a$ as the
initial letter, it gives the following fixed point.\\
\\
\monoit{u = ababbbababbbbbbbbbababbbababbbbbbbbbbbbbbbbbbbbbbbbbb\ldots}\\
\\
The following automaton is associated with this
substitution.

% Picture of cantor automaton. {{{1
\begin{graph}(0, 3)(-4, -1.5)
  \graphnodecolour{1}
  \graphnodesize{1}
  \roundnode{s1}(-2, 0) \nodetext{s1}(0, 0){$a$}
  \roundnode{s2}(0, 0)  \nodetext{s2}(0, 0){$b$}

  \dirloopedge{s1}{50}(-1, 0) \freetext(-3.6, 0){0,2}
  \diredge{s1}{s2} \edgetext{s1}{s2}{1}
  \dirloopedge{s2}{50}(1, 0) \freetext(1.6, 0){0,1,2}

  \freetext(-2, -0.7){$\Uparrow$}
\end{graph}
%}}}1

Let us denote the set of integers $n$ such that the $(n + 1)$--th letter of the
Cantor sequence is $a$ by $\mathbb{C}_a$.The automaton above suggests that
$\mathbb{C}_a$ is given by
\begin{displaymath}
  \mathbb{C}_a = \Big\{n \in \mathbb{N}; n = \sum_{i \ge 0} n_i3^i,
  \mathrm{\ with\ } \forall(i \ge 0): n_i \in \{0, 2\}\Big\}.
\end{displaymath}
The following argument shows that this is true. Let
$n = \sum_{i = 0}^t n_i 3^i$ with $n_i \in \{0, 1, 2\}$ for all $i$. Consider
the mapping $\tau: \{0, 1, \ldots, t\} \to \{a, b\}$ with
$\tau(j) = u(\sum_{i = 0}^j n_i 3^i)$. By definition of $\sigma$ we have
$\tau(j + 1) = a$ if and only if $\tau(j) = a$ and $n_{j + 1} \in \{0, 2\}$.

Compare the Cantor fractal with the Cantor word:

% Picture of the Cantor set. {{{1
\ \\
\verb#   0      0.1       0.2      1  |   0     0.1         0.2     1#\\
\verb#---------------------------------------------------------------#\\
\verb#   ===========================  |               #\monoit{a}\\
\verb#   =========         =========  |      #\monoit{a} { } { } { } { } { } { }\monoit{b} { } { } { } { } { } { }\monoit{a}\\
\verb#   ===   ===         ===   ===  |   #\monoit{a { }b { }a { }b { }b { }b { }a { }b { }a}\\
\verb#   = =   = =         = =   = =  |  #\monoit{ababbbababbbbbbbbbababbbaba}
%}}}1
\end{example}

\subsection{Reverse reading}
\begin{definition}[$k$-kernel] \label{def:k-kernel}
Let $N_k(u)$ be the set of subsequences of the sequence
$(u(n))_{n \in \mathbb{N}}$ defined by:
\begin{displaymath}
N_k(u) = \{(u(k^ln + r))_{n \in \mathbb{N}}; l \ge 0; 0 \le r \le k^l - 1\}.
\end{displaymath}
\end{definition}

\begin{example} \label{ex:k-kernel}
The kernel of the Cantor sequence is given by\\
\\
\monoit{ababbbababbbbbbbbbababbbababbbbbbbbbbbbbb\ldots}
$(l = 0) \Rightarrow u(3^0 n + 0)_{n \in \mathbb{N}}$,\\
\monoit{bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\ldots}
$(l = 1) \Rightarrow u(3^1 n + 1)_{n \in \mathbb{N}}$.\\
\end{example}

\begin{definition}[Reverse reading] \label{def:reverse_reading}
This definition is analogue to Definition \ref{def:direct_reading}, but it
feeds the sequence $n_0, n_1, \ldots, n_j$ to the automaton.
\end{definition}

\begin{theorem} \label{thm:reverse_reading}
A sequence $u \in \mathcal{A}^\mathbb{N}$ is $k$-automatic in reverse reading
if and only if the $k$-kernel $N_k(u)$ of the sequence $u$ is finite.
\end{theorem}

\begin{proof}
$\Leftarrow$ Suppose the $k$-kernel of a sequence $u$ is finite. Let
$\overline{a}_1, \ldots, \overline{a}_d$ be the sequences of $N_k(u)$. Take
$\mathcal{S} = \{a_1, \ldots, a_d\}$ as the finite set of $d$ states in
bijection with $N_k(u)$ with $a_1$ as initial state. For any integer
$r \in \{0, \ldots, k - 1\}$, define the map $r : \mathcal{S} \to \mathcal{S}$
by associating the state corresponding with
$(\overline{a}_i(kn + r))_{n \in \mathbb{N}}$ to $a_i$. Let
$n = \sum_{i = 0}^j n_i k^i$ be the base $k$ expansion of an integer $n$, with
$n_j \ne 0$. We define the map $n$ from
$\mathcal{S}$ to $\mathcal{S}$ by $n(a_i) = n_j(n_{j - 1}( \ldots (n_0(a_i))))$
if $n \ne 0$, otherwise the map 0 is the identity. It follows by induction that
$r(a_i)$ is in bijection with $(u(k^{j + 1} n + r))_{n \in \mathbb{N}}$.
Hence if $r(a_1) = s(a_1)$ then $u_r = u_s$, the first terms of the
two corresponding subsequences. Now we define the output
function $\varphi$ by $\varphi(a_i) = u_r$ if
$r(a_1) = a_i$. Therefore the sequence $u$ is generated by the automaton
in reverse reading.

$\Rightarrow$ Suppose $A$ is a finite $k$-automaton with initial state $\iota$
which generates $u$. The subsequence $(u(k^ln + r))_{n \ge 0}$, where
$l \ge 0$ and $0 \le r < k^l$, is generated by $A$ with the initial state
$\overline{r}(\iota)$, where $\overline{r}$ is the word of $l$ letters
obtained by concatenating in front of the base $k$ expansion of $r$ as many
zeros as necessary. Because $A$ has a finite number of states, there is only a
finite set of subsequences.
\end{proof}

The proof of Theorem \ref{thm:reverse_reading} gives a method for constructing
a $k$-automaton in reverse reading corresponding to a given sequence $u$ if $u$
is $k$-automatic in reverse reading. Take the $k$-kernel of $u$ and let
$\mathcal{S}$ be in bijection with the sequences in the kernel. Now add
transitions from state $a$ to state $b$ labeled $r$
($r \in \{0, 1, \ldots, k - 1\}$) if the sequence associated with $b$ is the
subsequence $(\overline{a}(kn + r))_{n \in \mathbb{N}}$. Make $a_0$ the initial
state and make all states that have incoming transitions (starting from that
initial state) final states.

\begin{example} \label{ex:reverse_reading}
The fixed point of the substitution $a \to ab$, $b \to ab$,
which is $abababab\ldots$ has as 2-kernel\\
\\
\monoit{ababababababababababababababababababa\ldots}
$= (ab)^\mathbb{N} = (u(2^0 n + 0))_{n \in \mathbb{N}}$,\\
\monoit{aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\ldots}
$= a^\mathbb{N} = (u(2^1 n + 0))_{n \in \mathbb{N}}$,\\
\monoit{bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\ldots}
$= b^\mathbb{N} = (u(2^1 n + 1))_{n \in \mathbb{N}}$.\\
\end{example}

By taking $l = 0$, we find $(2^0 n + 0)_{n \in \mathbb{N}}$. For $l = 1$ we
obtain two sequences: $(2^1 n + 0)_{n \in \mathbb{N}}$ and
$(2^1 n + 1)_{n \in \mathbb{N}}$. This is the complete $k$-kernel, because all
step sizes are of the form $k^l$. So taking larger step sizes will only yield
the second or third sequence.

% Picture of mod-2 automaton in reverse reading. {{{1
\begin{graph}(0, 3)(-4, -1)
  \graphnodecolour{1}
  \graphnodesize{1}
  \roundnode{s1}(-1, 0) \nodetext{s1}(0, 0){$\iota$}
  \roundnode{s2}(-2, 1.5)
    \nodetext{s2}(0, -0.22){\circle{0.8}} \nodetext{s2}(0, 0){$a$}
  \roundnode{s3}(0, 1.5)
    \nodetext{s3}(0, -0.22){\circle{0.8}} \nodetext{s3}(0, 0){$b$}

  \diredge{s1}{s2} \edgetext{s1}{s2}{0}
  \diredge{s1}{s3} \edgetext{s1}{s3}{1}
  \dirloopedge{s2}{50}(-1, 0) \freetext(-3.6, 1.5){0,1}
  \dirloopedge{s3}{50}(1, 0) \freetext(1.6, 1.5){0,1}

  \freetext(-1, -0.7){$\Uparrow$}
\end{graph}
%}}}1
% Picture of mod-2 automaton in direct reading again. {{{1
\begin{graph}(0, 3)(-10, -2)
  \graphnodecolour{1}
  \graphnodesize{1}
  \roundnode{s1}(-2, 0) \nodetext{s1}(0, 0){$a$}
  \roundnode{s2}(0, 0)  \nodetext{s2}(0, 0){$b$}

  \dirloopedge{s1}{50}(-1, 0) \freetext(-3.6, 0){0}
  \dirbow{s1}{s2}{.2} \bowtext{s1}{s2}{.2}{1}
  \dirbow{s2}{s1}{.2} \bowtext{s2}{s1}{.2}{0}
  \dirloopedge{s2}{50}(1, 0) \freetext(1.6, 0){1}

  \freetext(-2, -0.7){$\Uparrow$}
\end{graph}
%}}}1

The left figure is the automaton that generates $u$ in reverse reading. Note
that $\iota$ is not a final state, hence $\mathcal{S} \ne \mathcal{A}$. The
final states are marked with an internal circle.

The right figure is the automaton that generates $u$ in direct reading. Hence
the generating automata can be essentially different.

\subsection{Equivalence between direct- and reverse reading}
\begin{theorem} \label{thm:direct_is_reverse}
A sequence is $k$-automatic in direct reading if and only if it is
$k$-automatic in reverse reading.
\end{theorem}

\begin{proof}
Theorem \ref{thm:direct_reading} states that a $k$-automaton in direct reading
is in bijection with a substitution of constant length. Theorem
\ref{thm:reverse_reading} states that a $k$-automaton in reverse reading is in
bijection with a finite $k$-kernel.

It remains to prove that a substitution of constant length results in a finite
$k$-kernel.

$\Rightarrow$ Define $\sigma_i(a) : \mathcal{A \to A}$, which associates the
letter $a$ with the $i + 1$-th letter of its image in $\sigma$. We have
$\sigma_i(u(n)) = u(kn + i)$, for any integer $n$ and for any
$i \in \{0, \ldots, k - 1\}$. Let $l \ge 0$, $0 \le r \le k^l - 1$. Write
$r =  \sum_{i = 0}^{l - 1} r_i k^i$, where $0 \le r_i \le k - 1$. We thus have
$u(k^l n + r) = \sigma_{r_0}(\sigma_{r_1}( \ldots (\sigma_{r_{l - 1}}(u(n)))))$.
There are at most $|\mathcal{A}|^{|\mathcal{A}|}$ of these maps, so the
$k$-kernel is finite.

$\Leftarrow$ Suppose the $k$-kernel $N_k(u)$ of the sequence $u$ is finite.
Let $\overline{a}_1, \ldots, \overline{a}_d$ be the sequences in $N_k(u)$. Let
$U = (U(n))_{n \in \mathbb{N}}$ be the sequence with values in $\mathcal{A}^d$
defined by $U(n) = (\overline{a}_1(n), \ldots, \overline{a}_d(n))$. We
construct a substitution $\sigma$ of constant length $k$ defined on
$\mathcal{A}^d$ with $U$ as a fixed point. As $N_k(u)$ is stable by the maps
$\mathcal{A}_r$, where
$\mathcal{A}_r(v(n))_{n \in \mathbb{N}} = (v(kn + r))_{n \in \mathbb{N}}$, then
for any $0 \le r \le k - 1$, $U(kn + r) = U(km + r)$, if $U(n) = U(m)$. We
define for $0 \le r \le k - 1$, $\sigma_r : \mathcal{A}^d \to \mathcal{A}^d$,
$U(n) \to U(nk +r)$ if there exists and $n$ such that
$(a_1, \ldots, a_r) = U(n)$ and otherwise
$(a_1, \ldots, a_r) \to (0, \ldots, 0)$. Hence the sequence $U$ is the fixed
point of the substitution of constant length
$\sigma: a \to \sigma_0(a) \ldots \sigma_{k - 1}(a)$ and the sequence $u$ is
the image of $U$ by the projection of the first coordinate of $\mathcal{A}^d$
to $\mathcal{A}$.
\end{proof}

\begin{definition}
Because of Theorem \ref{thm:direct_is_reverse} we can define $k$-automaticity
as one of the following equivalences
\begin{itemize}
\item $k$-automaton in direct reading.
\item $k$-automaton in reverse reading.
\item a finite $k$-kernel.
\item the fixed point of a substitution of constant length.
\end{itemize}
\end{definition}

\begin{corollary} \label{cor:homomorphism}
If we take a $k$-automatic sequence and apply some homomorphism to it, it will
remain $k$-automatic.
\end{corollary}

\begin{proof}
This is a direct result of Theorem \ref{thm:direct_reading} and Theorem
\ref{thm:direct_is_reverse}.
\end{proof}

\begin{example}\label{ex:homomorphism}\end{example}
% Picture of mod-2 automaton with exit map. {{{1
\begin{graph}(0, 3)(-4, -1.5)
  \graphnodecolour{1}
  \graphnodesize{1}
  \roundnode{s1}(-2, 0) \nodetext{s1}(0, 0){$a$/0}
  \roundnode{s2}(0, 0)  \nodetext{s2}(0, 0){$b$/1}

  \dirloopedge{s1}{50}(-1, 0) \freetext(-3.6, 0){0}
  \dirbow{s1}{s2}{.2} \bowtext{s1}{s2}{.2}{1}
  \dirbow{s2}{s1}{.2} \bowtext{s2}{s1}{.2}{0}
  \dirloopedge{s2}{50}(1, 0) \freetext(1.6, 0){1}

  \freetext(-2, -0.7){$\Uparrow$}
\end{graph}
%}}}1

This automaton has an output alphabet $Y$ different from $\mathcal{S}$. We
have $Y = \{0, 1\}$ and we do not use Id$_{\{a, b\}}$ as the exit map, but
$\varphi(a) \to 0, \varphi(b) \to 1$. This is denoted by
$a/0, b/1$ in the automaton.

\section{Examples}
\subsection{The Prouhet-Thue-Morse sequence}
Let us look at the following substitution: $\sigma: \sigma(a) \to ab$,
$\sigma(b) \to ba$. With $a$ as the initial letter, it gives the
following fixed point:\\
\\
\monoit{u = abbabaabbaababbabaababbaabbabaabbaababbaabbabaababbab\ldots}\\
\\
The following 2-automaton is associated with this substitution:\\
% Picture of Prouhet-Thue-Morse automaton. {{{1
\begin{graph}(0, 3)(-4, -1.5)
  \graphnodecolour{1}
  \graphnodesize{1}
  \roundnode{s1}(-2, 0) \nodetext{s1}(0, 0){$a$}
  \roundnode{s2}(0, 0)  \nodetext{s2}(0, 0){$b$}

  \dirloopedge{s1}{50}(-1, 0) \freetext(-3.6, 0){0}
  \dirbow{s1}{s2}{.2} \bowtext{s1}{s2}{.2}{1}
  \dirbow{s2}{s1}{.2} \bowtext{s2}{s1}{.2}{1}
  \dirloopedge{s2}{50}(1, 0) \freetext(1.6, 0){0}

  \freetext(-2, -0.7){$\Uparrow$}
\end{graph}
%}}}1

Note that the final state is $a$ when the number of ones in the input word
is even, and $b$ otherwise. Hence this automaton generates $u$ both in direct
and in reverse reading.

The automaton above induces the following partitions of $\mathbb{N}$;
\begin{eqnarray*}
\mathbb{N}_a &=& \{0, 3, 5, 6, 9, 10, 12, 15, \ldots\}\\
\mathbb{N}_b &=& \{1, 2, 4, 7, 8, 11, 13, 14, \ldots\}.
\end{eqnarray*}
Let us define $S_2(n)$ as the sum of the dyadic digits:
\begin{displaymath}
S_2(n) = \sum_{i \ge 0}n_i,\mathrm{\ if\ }
n = \sum_{i \ge 0}n_i2^i, n_i \in \{0, 1\}.
\end{displaymath}
It is obvious from the automaton that the sets $\mathbb{N}_a$ and
$\mathbb{N}_b$ are defined by
\begin{eqnarray*}
x \in \mathbb{N}_a \Leftrightarrow S_2(n) \mathrm{\ is\ even},
x \in \mathbb{N}_b \Leftrightarrow S_2(n) \mathrm{\ is\ odd}.
\end{eqnarray*}

The 2-kernel of this sequence is\\
\\
\monoit{abbabaabbaababbabaababbaabbabaabbaababbaabbab\ldots} $(l = 0)$,\\
\monoit{baababbaabbabaababbabaabbaababbaabbabaabbaaba\ldots} $(l = 1, r = 1)$.\\
\\
So the 2-kernel consists of both fixed points.

\subsection{The Rudin-Shapiro sequence}
Define $u(n) = (-1)^{r_n}$, where $r_n$ is the number of occurrences of
consecutive `11' in the binary representation of $n$. It does not matter if we
apply direct or reverse reading. The corresponding automaton is given by

% Picture of Rudin-Shapiro automaton. {{{1
\begin{graph}(0, 3)(-4, -1.5)
  \graphnodecolour{1}
  \graphnodesize{1}
  \roundnode{s1}(-2, 0) \nodetext{s1}(0, 0){\bs$a$/+1\es}
  \roundnode{s2}(0, 0)  \nodetext{s2}(0, 0){\bs$b$/+1\es}
  \roundnode{s3}(2, 0)  \nodetext{s3}(0, 0){\bs$c$/-1\es}
  \roundnode{s4}(4, 0)  \nodetext{s4}(0, 0){\bs$d$/-1\es}

  \dirloopedge{s1}{50}(-1, 0) \freetext(-3.6, 0){0}
  \dirbow{s1}{s2}{0.2} \bowtext{s1}{s2}{0.2}{1}
  \dirbow{s2}{s1}{0.2} \bowtext{s2}{s1}{0.2}{0}
  \dirbow{s2}{s3}{0.2} \bowtext{s2}{s3}{0.2}{1}
  \dirbow{s3}{s4}{0.2} \bowtext{s3}{s4}{0.2}{0}
  \dirbow{s3}{s2}{0.2} \bowtext{s3}{s2}{0.2}{1}
  \dirloopedge{s4}{50}(1, 0) \freetext(5.6, 0){0}
  \dirbow{s4}{s3}{0.2} \bowtext{s4}{s3}{0.2}{1}

  \freetext(-2, -0.7){$\Uparrow$}
\end{graph}
%}}}1

Thus the Rudin-Shapiro sequence is the invariant word under the substitution
$a \to ab, b \to ac, c \to db, d \to dc$
starting with $a$ and with the indicated output function.

\subsection{The Baum-Sweet sequence}
The Baum-Sweet sequence $(u_n)_{n \in \mathbb{N}}$ with values in the alphabet
$\{0, 1\}$ is defined by:

\vbox{\begin{eqnarray*}
u_n &=& 0 \mathrm{\ if\ the\ dyadic\ development\ of\ } n
          \mathrm{\ contains\ at\ least\ one\ odd\ string\ of\ 0's},\\
    &=& 1 \mathrm{\ if\ not.}
\end{eqnarray*}}
Obviously the automaton does not depend on the way of reading. It is given by

% Picture of Baum-Sweet automaton. {{{1
\begin{graph}(0, 4)(-4, -1.5)
  \graphnodecolour{1}
  \graphnodesize{1}
  \roundnode{s1}(-2, 0) \nodetext{s1}(0, 0){$a$/1}
  \roundnode{s2}(0, 0)  \nodetext{s2}(0, 0){$b$/1}
  \roundnode{s3}(2, 0)  \nodetext{s3}(0, 0){$c$/0}
  \roundnode{s4}(4, 0)  \nodetext{s4}(0, 0){$d$/0}

  \dirloopedge{s1}{50}(-1, 0) \freetext(-3.6, 0){0}
  \diredge{s1}{s2} \edgetext{s1}{s2}{1}
  \dirbow{s2}{s3}{0.2} \bowtext{s2}{s3}{0.2}{0}
  \dirloopedge{s2}{50}(0, 1) \freetext(0, 1.6){1}
  \dirbow{s3}{s2}{0.2} \bowtext{s3}{s2}{0.2}{0}
  \diredge{s3}{s4} \edgetext{s3}{s4}{1}
  \dirloopedge{s4}{50}(1, 0) \freetext(5.6, 0){0,1}

  \freetext(-2, -0.7){$\Uparrow$}
\end{graph}
%}}}1

It will be clear that the automaton above generates the sequence when we use
$\varphi(a) = \varphi(b) = 1$ and $\varphi(c) = \varphi(d) = 0$.

The automaton corresponds to the substitution $\sigma$ given by
$\sigma(a) \to ab, \sigma(b) \to cb$,
$\sigma(c) \to bd, \sigma(d) \to dd$.

\subsection{A divisibility automaton}
Given two integers $k$ and $d$ greater or equal to two, can an automaton
decide only from its $k$-adic development whether any $n \in \mathbb{N}$ is
divisible by $d$? Let $\mathcal{S} = \{0, 1, \ldots, d - 1\}$ and let $u$ be the
periodic sequence:
\begin{displaymath}
  u = 01\ldots(d - 1)01\ldots(d - 1)\ldots
\end{displaymath}
We need to construct a $k$-automaton that generates $u$. To do this we need to
find a substitution $\sigma$ of constant length $k$ such that $u$ is the fixed
point of $\sigma$. We can do that by cutting $u$ in words of length $k$ and
rewriting $u$ as
$u = \sigma(0)\sigma(1)\ldots\sigma(d - 1)\sigma(0)\sigma(1)\ldots\sigma(d - 1)\ldots$

For the case $k = 2, d = 5$, the substitution looks as follows:

\vbox{\begin{eqnarray*}
  \sigma(0) &\to& 01\\
  \sigma(1) &\to& 23\\
  \sigma(2) &\to& 40\\
  \sigma(3) &\to& 12\\
  \sigma(4) &\to& 34
\end{eqnarray*}}
This gives the following automaton:\\
% Picture of mod-5 automaton. {{{1
\begin{graph}(0, 3)(-4, -0.5)
  \graphnodecolour{1}
  \graphnodesize{1}
  \roundnode{s1}(-2, 0) \nodetext{s1}(0, 0){$0$}
  \roundnode{s2}(-1, 1.5) \nodetext{s2}(0, 0){$1$}
  \roundnode{s3}(0, 0) \nodetext{s3}(0, 0){$2$}
  \roundnode{s4}(1, 1.5) \nodetext{s4}(0, 0){$3$}
  \roundnode{s5}(2, 0) \nodetext{s5}(0, 0){$4$}

  \dirloopedge{s1}{50}(-1, 0) \freetext(-3.6, 0){0}
  \diredge{s1}{s2} \edgetext{s1}{s2}{1}
  \diredge{s2}{s3} \edgetext{s2}{s3}{0}
  \dirbow{s2}{s4}{0.2} \bowtext{s2}{s4}{0.2}{1}
  \diredge{s3}{s5} \edgetext{s3}{s5}{0}
  \diredge{s3}{s1} \edgetext{s3}{s1}{1}
  \dirbow{s4}{s2}{0.2} \bowtext{s4}{s2}{0.2}{0}
  \diredge{s4}{s3} \edgetext{s4}{s3}{1}
  \diredge{s5}{s4} \edgetext{s5}{s4}{0}
  \dirloopedge{s5}{50}(1, 0) \freetext(3.6, 0){1}

  \freetext(-2, -0.7){$\Uparrow$}
\end{graph}\\
%}}}1
\\
Thus $n = (n_t n_{t - 1} \ldots n_0)_2$ is divisible by 5 if and only if 0 is
the final state after the consecutive transitions $n_t, n_{t - 1}, \ldots n_0$.
Moreover, if $j$ is the final state, then $j$ is the rest of $n$ after dividing
by 5.

\section{General automata}
\subsection{Regular languages}
\begin{definition}[Regular language] \label{def:regular_language}
A language $\mathcal{L}$ is called \emph{regular} if there exists a finite
automaton that accepts $\mathcal{L}$.
\end{definition}

Note that we do not talk about $k$-automata, but about automata in general.

\begin{lemma}[The pumping lemma for regular languages] \label{lem:pumping}
Let $\mathcal{L}$ be an infinite regular language. Then there exists an
$n \in \mathbb{N}, n \ge 1$, such that for all $z \in \mathcal{L}$, if
$|z| > n$ there are words $r, s, t$ such that
\begin{itemize}
\item $z = rst$
\item $s \ne \epsilon$
\item $|rs| \le n$
\item $r s^i t \in \mathcal{L}$ for all $i \in \mathbb{N}$
\end{itemize}
\end{lemma}

\begin{proof}
Let $A = (\mathcal{S}, \Delta, \delta, I, F)$ be a finite automaton which
accepts $\mathcal{L}$. Let $K = \mathcal{L}(A)$, let $n = |\mathcal{S}|$, and
let trans be a sequence of transitions. $\mathcal{S} \ne \epsilon$ because
$\mathcal{L}$ is infinite, and therefore $n \ge 1$.

Consider $z \in K$ with $m = |z| > n$. If such a word does not exist, we are
finished. We look at the path $\pi$ in $A$ corresponding with $z$, say
$\pi = (q_0, a_1, q_1)(q_1, a_2, q_2)$ $\ldots(q_{m - 1}, a_m, q_m)$ with
$q_0 \in I$ and $q_m \in F$, so $z = \mathrm{trans}(\pi) = a_1a_2\ldots a_m$.
Because $m > n$, there exist $k$ and $j$ with $0 \le k < j \le n$ and
$q_k = q_j$. We now split the path into three parts; $\pi = \pi_1 \pi_2 \pi_3$,
with
\begin{eqnarray*}
  \pi_1 &=& (q_0, a_1, q_1) \ldots (q_{k - 1}, a_k, q_k),\\
  \pi_2 &=& (q_k, a_{k + 1}, q_{k + 1}) \ldots (q_{j - 1}, a_j, q_j),\\
  \pi_3 &=& (q_j, a_{j + 1}, q_{j + 1}) \ldots (q_{m - 1}, a_m, q_m).
\end{eqnarray*}
Let $r = \mathrm{trans}(\pi_1), s = \mathrm{trans}(\pi_2),
     t = \mathrm{trans}(\pi_3)$

Because $\pi_2$ is a cycle in the automaton, from $q_k$ to $q_j = q_k$, there
exists for all $i \in \mathbb{N}$ a path $\pi_1 \pi_2^i \pi_3$ from $q_0$ to
$q_m$. So $\mathrm{trans}(\pi_1 \pi_2^i \pi_3) \in K$. Because trans is a
homomorphism, we can say:  $\mathrm{trans}(\pi_1 \pi_2^i \pi_3) =
\mathrm{trans}(\pi_1) \mathrm{trans}(\pi_2)^i \mathrm{trans}(\pi_3) = r s^i t$.
So $r s^i t \in K$ for all $i \in \mathbb{N}$.

Note that $|s| = |\mathrm{trans}(\pi_2)| = j - k > 0$, so $s \ne \epsilon$,
and that $|rs| = |\mathrm{trans}(\pi_1 \pi_2)| = j \le n$.
\end{proof}

% Picture of general automaton. {{{1
\begin{graph}(0, 3)(-4, -1.5)
  \graphnodecolour{1}
  \graphnodesize{1}
  \roundnode{s1}(-2, 0) \nodetext{s1}(0, 0){\bs$q_0$\es}
  \roundnode{s2}(0, 0) \nodetext{s2}(0, 0){\bS$q_k=q_j$\eS}
  \roundnode{s3}(2, 0)
    \nodetext{s3}(0, -0.22){\circle{0.8}} \nodetext{s3}(0, 0){\bs$q_m$\es}

  \diredge{s1}{s2} \edgetext{s1}{s2}{$r$}
  \dirloopedge{s2}{50}(0, 1) \freetext(0, 1.6){$s$}
  \diredge{s2}{s3} \edgetext{s2}{s3}{$t$}

  \freetext(-2, -0.7){$\Uparrow$}
\end{graph}
%}}}1

\begin{remark}
In a similar way, but by choosing $j$ maximal and $k$ minimal, we may prove
the statement with the condition $|rs| \le n$ replaced with $|rt| \le n$.
\end{remark}

We can use the pumping lemma to prove that a certain language is not regular.

\begin{example} \label{ex:pumping}
$\mathcal{L} = \{0^m1^m | m \in \mathbb{N}\}$ is not regular.
\end{example}

\begin{proof}
Suppose $\mathcal{L}$ is regular. We can then find a number $n \ge 1$ that
conforms to the pumping lemma. Consider the word $z = 0^n 1^n$. We see that
$z \in \mathcal{L}$ and $|z| = 2n > n$. So we can write $z = r s t$ with
$|r s| \le n$ and $s \ne \epsilon$. Hence $rs$ consists of only zeros, so
$s = 0^k$ for a certain $k$. Now take $i = 0$. According to the pumping lemma
$r s^0 t = r t \in \mathcal{L}$, but $r t = 0^{n - k} 1^n$ with $n - k < n$, so
$rt \notin \mathcal{L}$. This is a contradiction, so our assumption was false
and $\mathcal{L}$ is not regular.
\end{proof}

\begin{theorem} \label{thm:not_regular}
If $\mathcal{L}(u)$ is regular and $u$ is minimal, then $u$ is periodic with
period $|s|$.
\end{theorem}

\begin{proof}
Suppose $\mathcal{L}(u)$ is regular. Let $z \in \mathcal{L}$. By Theorem
\ref{lem:pumping}, we can write $z = r s t$ such that $r s^i t \in \mathcal{L}$
for every $i$. We have $|r s^i t|_1 = |r|_1 + i|s|_1 + |t|_1$. It follows that
$|s| |r s^i t|_1 - |s|_1 |r s^i t| = |s| |r|_1 + |s| |t|_1 - |r| |s|_1 -
|t| |s|_1$ is independent of $i$. Hence $\lim_{i \to \infty}
\frac{|r s^i t|_1}{|r s^i t|} - \frac{|s|_1}{|s|} = 0$. Since $r s^i t$ would
be a subword of $u$ for every $i$ and $u$ is minimal, it would follow from
Proposition 5.1.10 \cite{Fogg} page 105 that the frequency of 1 in $u$ is
$\frac{|s|_1}{|s|} \in \mathbb{Q}$.
\end{proof}

\begin{corollary} \label{cor:ptm_not_regular}
The language $\mathcal{L}(u)$ defined by the Prouhet-Thue-Morse sequence $u$ is
not regular.
\end{corollary}

\begin{proof}
By Proposition 5.1.2 \cite{Fogg} page 102, $u$ is minimal and not periodic.
Theorem \ref{thm:not_regular} states that those sequences are not regular.
\end{proof}

\begin{corollary} \label{cor:sturmian_not_regular}
If $u$ is a Sturmian sequence, then $\mathcal{L}(u)$ is not regular.
\end{corollary}

\begin{proof}
By Theorem 6.1.8 \cite{Fogg} a Sturmian sequence is minimal and by Theorem
Proposition 6.1.10 \cite{Fogg} the frequency of 1 is irrational. Theorem
\ref{thm:not_regular} states that those sequences are not regular.
\end{proof}

\subsection{The Fibonacci sequence}
We consider substitutions of non-constant length. They will result in
non-complete automata, and therefore will only accept a subset of $\Delta^*$.\\
\\
The Fibonacci sequence is $u$ is the fixed point of the substitution
$\sigma: \sigma(a) \to ab, \sigma(b) \to a$, hence\\
\\
\monoit{u = abaababaabaababaababaabaababaabaababaababaabaababaaba\ldots}\\
\\
The 2-kernel of this sequence contains the words:\\
\\
\monoit{abaababaabaababaababaabaababaabaababaababaabaababaaba\ldots}\\
\\
\monoit{aabbaabbaaabaaabaaabbaabbaaabaaabaaabba\ldots}\\
\monoit{baaabaaabbaabbaabbaaabaaabbaabbaabbaaab\ldots}\\
\\
\monoit{ababaaaaaabababababa\ldots}\\
\monoit{ababababababaaaaaaba\ldots}\\
\monoit{bababababaaaabababab\ldots}\\
\monoit{aaaabababababababaaa\ldots}\\
\monoit{}\\
\\
This suggests that the 2-kernel of this sequence is infinite. Its cardinality
certainly exceeds $|\mathcal{A}|^{|\mathcal{A}|}$,
so the sequence is not 2-automatic and because this is the smallest
substitution that generates the sequence, it is not $k$-automatic at all. The
associated automaton is\\
% Picture of Fibonacci automaton. {{{1
\begin{graph}(0, 3)(-4, -1.5)
  \graphnodecolour{1}
  \graphnodesize{1}
  \roundnode{s1}(-2, 0) \nodetext{s1}(0, 0){$a$}
  \roundnode{s2}(0, 0)  \nodetext{s2}(0, 0){$b$}

  \dirloopedge{s1}{50}(-1, 0) \freetext(-3.6, 0){0}
  \dirbow{s1}{s2}{.2} \bowtext{s1}{s2}{.2}{1}
  \dirbow{s2}{s1}{.2} \bowtext{s2}{s1}{.2}{0}

  \freetext(-2, -0.7){$\Uparrow$}
\end{graph}\\
%}}}1
Note that this is almost the same automaton that generates $(ab)^{\mathbb{N}}$,
and that it only lacks one branch. We immediately see that this is not a
$k$-automaton, for it is not total. Moreover, if we feed this automaton with
the base 2 expansion of $n \in \mathbb{N}$, it will halt (or crash) when
we feed it a string which has two consecutive ones as a substring (another
reason to conclude that this substitution is not $k$-automatic). However, our
intuition is right, the automaton generates the Fibonacci sequence, but since
it is not a $k$-automaton, we can not feed it with the base 2 expansion of all
the nonnegative integers. In this particular case we know which expansion to
take, viz. the Fibonacci expansion of the nonnegative integers; in general this
is not known.

\begin{definition}[Zeckendorf expansion]
Let $(F_n)_{n \in \mathbb{N}}$ be the sequence of integers defined by $F_0 = 1,
F_1 = 2$ and for any integer $n > 1, F_{n + 1} = F_{n - 1} + F_n$.

If $n = \sum_{i = 0}^k n_i F_i$ with $n_k = 1, n_i \in \{0, 1\}$ and
$\forall (i < k): n_i n_{i + 1} = 0$, we say that
Fib$(n) = n_k n_{k - 1} \ldots n_0 \in \{0, 1\}^{k + 1}$ is the
\emph{Zeckendorf expansion} or \emph{Fibonacci representation} of the integer
$n$.
\end{definition}

This gives the expansions\\ \vbox{
\begin{verbatim}
  0 = 0
  1 = 1
  2 = 10
  3 = 100
  4 = 101
  5 = 1000
   ...
\end{verbatim}}

\begin{theorem} \label{thm:fibonacci_numbersystem}
Every nonnegative integer $n$ can be written in a unique way as
$n = \sum_{i \ge 0} n_i F_i$ with $n_i \in \{0, 1\}$ and
$\forall (i \ge 0): n_i n_{i + 1} = 0$
\end{theorem}

\begin{proof} By induction over $n$.\\
It is true for $n = 0$. Suppose it holds for $n < F_k$. If
$F_k \le n < F_{k + 1}$ then by $F_{k + 1} = F_k + F_{k - 1}$ we have
$n - F_k < F_{k - 1}$. Because we can write $n - F_k$ by our hypothesis as
$n - F_k = \sum_{i = 0}^{k - 2} n_i F_i$ with $n_i n_{i - 1} = 0$ for
$i = 1, \ldots, k - 2$, we can write $n = F_k + \sum_{i = 0}^{k - 2} n_i F_i$
such that there are no two consecutive ones.\\
\\
It remains to prove that the Fibonacci representation is unique.\\
Let $n \in \mathbb{N}$ be the smallest number for which there is more than one
representation. Choose $k$ such that $F_k \le n < F_{k + 1}$ and write
$n = n_k n_{k - 1} \ldots n_0$ (the standard representation) and
$n = n'_l n'_{l - 1} \ldots n'_0$ (another representation satisfying
$n'_i n'_{i - 1} = 0$ for $i = 1, \ldots, k - 2$). Then $n_k = 1$ and $l \le k$.
If $n_k = n'_k$ then $n - F_k$ would have two distinct representations as well.
Hence $n'_k = 0$.
The maximum number of length $k - 1$ we can represent is
$F_{k - 1} + F_{k - 3} + F_{k - 5} + \ldots$, which is equal to $F_k - 1$ and
therefore smaller than $n$.
\end{proof}

Since this system can be used to enumerate $n \in \mathbb{N}$ and it has the
property that no two ones succeed each other, this is the mapping we are
looking for.\\
Put
\begin{eqnarray*}
  \mathbb{N}_a &=& \{n \in \mathbb{N}, \mathrm{Fib}(n) \in \{0, 1\}^* 0\} =
                   \{0, 2, 3, 5, 7, 8, 10, 11, 13, 15, \ldots\}\\
  \mathbb{N}_b &=& \{n \in \mathbb{N}, \mathrm{Fib}(n) \in \{0, 1\}^* 1\} =
                   \{1, 4, 6, 9, 12, 14, 17, 19, 22, 25, \ldots\}
\end{eqnarray*}
\\
Consider the first few substitutions of $\sigma$,\\
\\
$\sigma^0(a) =$ \monoit{a}\\
$\sigma^1(a) =$ \monoit{ab}\\
$\sigma^2(a) =$ \monoit{aba}\\
$\sigma^3(a) =$ \monoit{abaab}\\
$\sigma^4(a) =$ \monoit{abaababa}

\begin{theorem} \label{thm:fibonacci_fixedpoint}
$\sigma^n = \sigma^{n - 1} \sigma^{n - 2}, n \in \mathbb{N}, n \ge 2$
\end{theorem}

\begin{proof} By induction over $n$. Initial step:
$\sigma^2 = aba = \sigma^1 \sigma^0$.\\
Induction step: We have
$\sigma^{n + 1} = \sigma(\sigma^n) = \sigma(\sigma^{n - 1} \sigma^{n - 2}) =
\sigma(\sigma^{n - 1}) \sigma(\sigma^{n - 2}) = \sigma^n \sigma^{n - 1}$.
\end{proof}

We write in column $j$ the Fibonacci expansion of $j$ from above to below.\\
\\
\monoit{a b a ab aba abaab \ldots}\\
\verb#0 1 1 11 111 11111#\\
\verb#    0 00 000 00000#\\
\verb#      01 001 00011#\\
\verb#         010 00100#\\
\verb#             01001#\\
\\
We see that the Fibonacci expansions of the integers $n$ with
$F_k \le n < F_{k + 1}$ are all of length $k$. We deduce from the definition of
the Fibonacci expansion strings that end with a 0 can be extended in two ways:
$\ldots 0 \to \ldots 00, \ldots 01$, and strings that end with a 1 can only be
extended in one way: $\ldots 1 \to \ldots 10$.

\begin{thebibliography}{XX}
\bibitem{Fogg} Fogg, N. Pytheas. Substitutions is Dynamics, Arithmetics and
               Combinatorics, Springer Verlag, 2002.
\end{thebibliography}
\end{document}


\documentclass[12pt]{report}
%\usepackage[pdftex]{hyperref}
\usepackage{amsmath} % advanced math
\usepackage{amssymb}
\usepackage{ulem}
\usepackage{graphicx,color}
%\usepackage{subfigure}
\usepackage{verbatim} % multi-line comments
\usepackage[backref, colorlinks=false, pdftitle={20110125},
pdfauthor={Ben Payne, Alexey Yamilov}, pdfsubject={meeting},
pdfkeywords={localization, gain, transmission, random, media}]{hyperref}
%\usepackage{hyperref} % hyper links
%I'd like to use "backpageref" instead of linking back to section numbers
\setlength{\topmargin}{-.5in}
\setlength{\textheight}{9in}
\setlength{\oddsidemargin}{0in}
\setlength{\textwidth}{6.5in}
\newcounter{fignum}
\newcommand{\fignum}{\stepcounter{fignum}\arabic{fignum}}
\begin{document}
\section{Gaussian and SI}
\begin{tabular}{c c | c c}
Gaussian (``CGS'') & & SI & \\
cm, gram, second & & m, kg, second &\\\hline
&&&\\
$\vec{\nabla} \times \vec{E} = -\frac{1}{c} \frac{\partial \vec{B}}{\partial t}$ & $\vec{\nabla} \times \vec{H} = \frac{1}{c} \frac{\partial \vec{D}}{\partial t} + \frac{4\pi}{c}\vec{J}$ & $\vec{\nabla} \times \vec{E} = -\frac{1}{c} \frac{\partial \vec{B}}{\partial t}$ & $\vec{\nabla} \times \vec{H} = \frac{\partial \vec{D}}{\partial t} + \vec{J}$ \\
&&&\\
$\vec{\nabla} \cdot \vec{D} = 4 \pi \rho $ & $\vec{\nabla} \cdot \vec{B}=0$ & $\vec{\nabla} \cdot \vec{D} = \rho $ & $\vec{\nabla} \cdot \vec{B}=0$ \\
&&&\\\hline
&&&\\
$\vec{F} = q \left(\vec{E} + \frac{1}{c}\vec{v}\times \vec{B}\right)$ & & $\vec{F} = q \left(\vec{E} + \vec{v}\times \vec{B}\right)$ & \\
&&&\\\hline
&&&\\
$\vec{D} \equiv \vec{E} + 4\pi \vec{P}$ & $\vec{H} \equiv \vec{B}-4\pi \vec{\mu}$ & $\vec{D} \equiv \epsilon_0\ \vec{E} + \vec{P}$ & $ \vec{H} = \frac{1}{\mu_0} \vec{B} - \vec{\mu}$ \\
\end{tabular}

\ \\

Conversion factors between Gaussian, SI. Usage: $X_{Gaussian} = k_X X_{SI}$

\ \\
\begin{tabular}{c c c}
$k_{\vec{D}} = \sqrt{4\pi/\epsilon_0}$ & $k_{\vec{H}} = \sqrt{4 \pi \mu_0}$ & $k_{\rho} = k_{\vec{J}} = k_{\vec{P}} = 1/\sqrt{4 \pi \epsilon_0}$\\
&& \\
$k_{\vec{E}} = \sqrt{4 \pi \epsilon_0}$ & $k_{\vec{B}} = \sqrt{4 \pi /\mu_0}$ & $k_{\mu} = \sqrt{\mu_0/(4 \pi)}$ \\
\end{tabular}

\ \\

For dimensions, $k_{length} = 100$. $k_{mass}=1000$.
\ \\

\begin{equation}
 \epsilon_0 \mu_0 = \frac{1}{c^2}
\end{equation}
\begin{equation}
 \mu_0 = 4 \pi \cdot 10^{-7}
\end{equation}

\section{basics}
\begin{equation}
 E = h\ f = \frac{h\ c}{\lambda}
\end{equation}
\begin{equation}
 F = -G \frac{m_1\ m_2}{r^2}
\end{equation}
Explain the following momentum relation physically
\begin{equation}
 p = \hbar k =mv
\end{equation}
Explain the following relation between flux and velocity physically
\begin{equation}
 \vec{J} = n \vec{v}
\end{equation}
\begin{equation}
 KE = \frac{1}{2} m v^2 \quad \quad \quad PE = mgh
\end{equation}

\end{document}