\documentclass{article}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{verbatim}
\usepackage{enumerate}
\usepackage{comment}

\newtheorem{thm}{Theorem}[section]
\newtheorem{lem}[thm]{Lemma}

\newtheorem{defn}[thm]{Definition}
\newtheorem{ex}[thm]{Example}
\newtheorem{xca}[thm]{Exercise}

\newcommand{\sii} {\sigma_{-1}}

\title%[Prime Factors of an Odd Perfect Number]
    {New techniques for bounds on the total number of Prime Factors of an
     Odd Perfect Number}
\author{Kevin G. Hare
\footnote{Department of Pure Mathematics, University of Waterloo, Waterloo,
    Ontario, Canada,  N2L 3G1, kghare@math.uwaterloo.ca}}

%\email{kghare@math.uwaterloo.ca}

%\subjclass{Primary 11A25, 11Y70}

%\keywords{Perfect Numbers, Divisor function, Prime numbers}

\date{April 12, 2006}

\begin{document}
\maketitle
\thanks{Research of K.G. Hare supported, in part by NSERC of Canada.}

\begin{abstract}
Let $\sigma(n)$ denote the sum of the positive divisors of $n$.
We say that $n$ is perfect if $\sigma(n) = 2 n$.
Currently there are no known odd perfect numbers.
It is known that if an odd perfect number exists, then it must be
    of the form $N = p^\alpha \prod_{j=1}^k q_j^{2 \beta_j}$, where
    $p, q_1, \cdots, q_k$ are distinct primes and
    $p \equiv \alpha\equiv 1 \pmod{4}$.
Define the total number of prime factors of $N$ as
    $\Omega(N) := \alpha + 2 \sum_{j=1}^k \beta_j$.
Sayers showed that $\Omega(N) \geq 29$.
This was later extended by Iannucci and Sorli to show that $\Omega(N) \geq 37$.
This was extended by the author to show that $\Omega(N) \geq 47$.
Using an idea of Carl Pomerance this paper extends these results.
The current new bound is $\Omega(N) \geq 75$.
\end{abstract}

\section{Introduction}

Here and throughout, $n$ is any natural number, and $N$ is a hypothetical
    odd perfect number.
Let $\sigma(n)$ denote the sum of the positive divisors of $n$.
We say that $n$ is perfect if $\sigma(n) = 2 n$.
It is known that if $\sigma(n) = 2n $ and $n$ is even, then
    $n = 2^{k-1} (2^k-1)$ where $2^k-1$ is a Mersenne prime.
Currently there are no known odd perfect numbers.
First shown by Euler, it is well known that if
    an odd perfect number exists, then it must be
    of the form
\begin{eqnarray}
N = p^\alpha \prod_{j=1}^k q_j^{2 \beta_j},
\label{eq:odd}
\end{eqnarray} where
    $p, q_1, \cdots, q_k$ are distinct primes and
    $p \equiv \alpha\equiv 1 \pmod{4}$.

Based on (\ref{eq:odd}) we define the total number of prime factors
    of an odd perfect number as
\begin{eqnarray}
\Omega(N) := \alpha + 2 \sum_{j=1}^k \beta_j,
\label{eq:Omega}
\end{eqnarray}
and we define the total number of distinct prime factors of $N$ as
    \begin{eqnarray} \omega(N) := 1 + k. \label{eq:omega} \end{eqnarray}
A number of bounds have been derived for $\Omega(N)$.
Cohen showed that $\Omega(N) \geq 23$ \cite{Cohen82}.
Sayers showed that $\Omega(N) \geq 29$ \cite{Sayers86}.
Iannucci and Sorli showed that $\Omega(N) \geq 37$ \cite{IannucciSorli03}.
The author extended this to give $\Omega(N) \geq 47$ \cite{Hare05a}.
This paper extends this result to give

\begin{thm} If $N$ is an odd perfect number, then $\Omega(N) \geq 75$.
\label{thm:main}
\end{thm}

In proving these results, the methods of \cite{Hare05a} were modified and
    applied.
For an introduction and explanation of the algorithm we refer the
    interested reader there.

To some extent, with the modification of the algorithm given here,
    the calculation becomes a matter of book-keeping.
In \cite{Hare05a} there was a specific road-block which prevented any
    further calculation.
This is no longer the case.
With enough computational power, we could get to any number, although the
    amount of time required appears to be exponential, more than
    doubling every time we increase the bound by 4 (see Table \ref{tab:times}).
So it is just a matter of how much computer power to dedicate
    towards the problem.
The choice of 75 in the theorem was motiviated by the fact that
    it was sufficiently large to demonstrate
    the improvement in the algorithm while still remaining reasonable
    with respect to computation time.
\begin{table}
\caption{Timing results for algorithm}
\label{tab:times}
\begin{tabular}{|l|l|l|}
\hline
Result & Time to Prove result & Lines to Prove result\\
\hline
$\Omega(N) \geq 69$ &
%                      185 hours, 23 minutes 40 seconds \\
                      7 days, 17 hours, 23 minutes, 50 seconds &
%92:52:18.43 + 92:31:21.93  %%% ALTERED FOR 11
%92+1/60*52+1/60^2*18.43 + 92+1/60*31+1/60^2*21.93
%185.3945445
25,234,392 lines \\  %% ALTERED FOR 11
$\Omega(N) \geq 71$ &
%                      262 hours, 17 minutes, 58 seconds  \\
                      10 days, 22 hours, 18 minutes, 4 seconds &
%131:23:12.35 + 130:54:45.66            %% ALTERED FOR 11
%131+1/60*23+1/60^2*12.35 + 130+1/60*54+1/60^2*45.66;
% 262.2994472
37,752,127 lines \\  %% ALTERED FOR 11
$\Omega(N) \geq 73$ &
%                     409 hours, 28 minutes, 28 seconds \\
                       17 days, 1 hour, 28 minutes, 36 seconds &
%148:10:52.41 + 150:33:25.34a + 2:30:02.21 + 1:57:45.35   %% ALTERED FOR 11
%+ 51:51:06.36 + 45:08:04.90 + 4:19:32.38 + 4:57:39.10
% 409.4744445 total
56,352,999 lines \\   %% ALTERED FOR 11
$\Omega(N) \geq 75$ &
%
                       25 days, 3 hours, 17 minutes, 35 seconds &  %% ALTERED 11
% 603.290811
83,902,264 lines \\    %% ALTERED 11
%Time.out1
%455.276u 566.316s 42:12:24.80 0.6%      0+0k 0+0io 3pf+0w
%Time.out2
%1637.643u 2082.795s 152:23:21.91 0.6%   0+0k 0+0io 0pf+0w
%Time.out3
%906.597u 1191.579s 79:33:00.86 0.7%     0+0k 0+0io 0pf+0w
%Time.out4
%809.237u 1013.459s 74:05:35.76 0.6%     0+0k 0+0io 2pf+0w
%Time.out5
%927.325u 1160.900s 75:26:58.77 0.7%     0+0k 0+0io 0pf+0w
%Time.out6
%1234.393u 1549.627s 90:21:22.59 0.8%    0+0k 0+0io 5pf+0w
%Time.out7
%1172.815u 1461.271s 89:14:42.23 0.8%    0+0k 0+0io 0pf+0w

%42 + 1/60.*12+1/60.^2*24.80 +
%152 + 1/60.*23+1/60.^2*21.91+
%79 + 1/60.*33+1/60.^2*00.86 +
%74 + 1/60.*05+1/60.^2*35.76 +
%75 + 1/60.*26+1/60.^2*58.77 +
%90 + 1/60*21+1/60^2*22.59 +
%89 + 1/60*14+1/60^2*42.23;

\hline
\end{tabular}
\end{table}

%Between 69 and 71, there is an increase by a factor of about 1.414.
%Between 71 and 73, there is an increase by a factor of about 1.561.
%Between 73 and 75, there is an increase by a factor of about 1.473.
%
%Based on these numbers, we could estimate that the amount of time to compute
%    up to 101 would be over 11 years of CPU time.
%100243.3726

\section{Definitions and Notation}

For any prime $p$, by $p^a\parallel N$ we mean $p^a |N$ and $p^{a+1}\nmid N$.
By $p^a\nparallel N$ we mean either $p^{a+1}| N$ or $p^a \nmid N$.
We define the function $\sii(n)$ as
\begin{eqnarray}
\sii(n) := \sum_{d|n}d^{-1} = \frac{\sigma(n)}{n}.
\label{eq:sii}
\end{eqnarray}

A number of simple results concerning $\sii(n)$ are summarized below.
\begin{lem}
\label{lem:sii}
Let $n$ be any natural number.
Then
\begin{itemize}
\item $\sii(n)$ is a multiplicative function,
    i.e. if $(n, m) = 1$ then $\sii(n\cdot m) = \sii(n) \sii(m)$,
\item $\sii(n) > 1$ for all $n > 1$,
\item $\sii(n) = 2$ if and only if $n$ is perfect,
\item $\frac{p+1}{p} \leq \sii(p^a) < \sii(p^{a+1}) < \frac{p}{p-1}$
    for all primes $p$ and integers $a \geq 1$.
\end{itemize}
\end{lem}

There are a number of useful results concerning $\omega(N)$, the total number
    of distinct prime factors.
\begin{lem}
\label{lem:exclude}
Let $N$ be an odd perfect number.
Then
\begin{itemize}
\item $\omega(N) \geq 8$ \cite{Chein79, Hagis80}.
\item If $3 \nmid N$ then $\omega(N) \geq 11$ \cite{Hagis83, Kishore83}.
\item If $3 \nmid N$ and $5 \nmid N$ then $\omega(N) \geq 15$ \cite{Norton61}.
\item If $3 \nmid N$, $5 \nmid N$ and $7 \nmid N$ then
    $\omega(N) \geq 27$ \cite{Norton61}.
\item If $3 \nmid N$, $5 \nmid N$, $7 \nmid N$, and $11 \nmid N$,
    then $\omega(N) \geq 41$ and hence $\Omega(N) \geq 81$.
\end{itemize}
\end{lem}

The last result is probably not the tightest possible, but it is sufficient
    for our purposes.
It follows immediately by noticing that the product $\prod \frac{p_i}{p_i-1}$
    for the first 40 primes strictly greater than 11 is less than 2.
So, for our purposes it suffices to assume that $\Omega(N) \leq 73$ and
    show as a result that $3\nmid N$, $5\nmid N$, $7\nmid N$ and
    $11 \nmid N$, which gives the desired contradiction.

This last result is well known in the literature.
We use the version given in \cite{CohenSorli03}.  \nocite{Pomerance74}

\begin{lem}[Cohen, Sorli \cite{CohenSorli03}] \label{lem:Carl}
    Let
    \[N = p_1^{\alpha_1} p_2^{\alpha_2} \cdots p_k^{\alpha_k}
          q_1^{\beta_1} q_2^{\beta_2} \cdots q_r^{\beta_r} \]
    be an odd perfect number, where the $p_i$ and $q_j$ are distinct primes with
    the $p_i$ and $\alpha_i$ known.
    Define \[ S := \sii\left(p_1^{\alpha_1} \cdots p_k^{\alpha_k}\right). \]

    Then we have,
    \[ \min q_i < \frac{2 + S (r-1)}{2-S}\]
    moreover, if $r \geq 3$ we have the tighter bound
    \[ \min q_i < \frac{8 + 2 S^2 (r-1)}{4 - S^2}. \]
    Furthermore we have the lower bound
    \[ \min q_i \geq \max\left(3, \frac{S}{2 - S}\right). \]
\end{lem}

\begin{proof}
Taking $h = \sii$, $\mu = 1$, $h(\lambda) = S$ and $w = r$, this follows
    directly from equations (2.3), (4.1) and (2.4) of \cite{CohenSorli03}.
\end{proof}

\begin{ex}
Assume that
    $N = 3^2\cdot 13^4\cdot 30941 \cdot q_1^{\beta_1} \cdot q_2^{\beta_2}$
    is an odd perfect number.
Then by Lemma \ref{lem:Carl} we can assume that $3.5962 < q_1 < 8.1924$.
So in, particular we can assume that $q_1 = 5$ or $7$.
\end{ex}

\section{The Algorithm and Proof of Theorem \ref{thm:main}}%and \ref{thm:equiv}}

Suppose $N = p^{\alpha}\prod q_i^{2 \beta_i}$, as before.
To prove that $\Omega(N) \geq K$, we assume that $\Omega(N) =
    \alpha + \sum 2 \beta_i \leq K-2$ and obtain a contradiction
    for every combination of $\alpha$ and $\beta_i$.
As mentioned above, it suffices to assume that $\Omega(N) \leq 73$ and
    show as a result that $3\nmid N$, $5\nmid N$, $7\nmid N$ and
    $11 \nmid N$ to obtain our contradiction.

There are two main modifications to the algorithm in \cite{Hare05a}.
First, as opposed to doing every individual case of $[\alpha, \beta_1, \cdots
    \beta_k]$ where $\Omega(N) = \alpha + 2 \sum \beta_i$, we combine them into
    one test.
For example, if we want to prove $3 \nmid N$, where $\Omega(N) \leq 57$,
    we look at the possibilities
    $3^2\parallel N, 3^4 \parallel N, \cdots, 3^{56}\parallel N$, and recurse.
(Actually, for any power $\beta \geq 46$, we have that $3^\beta\parallel N$
    will give
    rise to a contradiction as $\omega(N) \geq 8$.)
This was done because the original method of looking at every possible
    partition of $N$ caused a large amount of duplicated effort in the
    automated proofs.
By combining these tests together we speed up the calculation, and
    significantly reduce the storage space requirements.

It should be pointed out that this modification introduced a new means of
    obtaining a contradiction,
    which in \cite{Hare05a} was taken care of in the choice of
    partitions.
This is listed as contradiction (\ref{cont:omega}) below.

The second modification to the algorithm is the use of Lemma \ref{lem:Carl}.
If the algorithm finds itself in a situation where previously it could not
    continue, because it did not know the factorization of some very
    large number, we then compute
    $\frac{2 + S (r-1)}{2-S}$ or $\frac{8 + 2 S^2 (r-1)}{4 - S^2}$
    as approriate, from Lemma \ref{lem:Carl}.
If this upper bound is reasonably small, then we run though all of the
    possibilities of $q_i$ prime less than this upper bound,
   (and greater than the lower bound),
    as a means of continuing the calculation.
Here ``small'' was defined as anything less than 100000.
This was sufficient for these calculations.
It should also be noted that the primes are checked in order.
After proving that a particular prime (say $p$) causes a contradiction,
    it is assumed that it cannot occur as a factor for the next cases
    being checked, within the same sub-branch.
(For example, with an abuse of notation, we assume $p^0 \parallel N$, and
    would arrive at contradiction (\ref{cont:xs=p}) if a factor of $p$
    occurs.)

There are five contradictions that we test for.
The first four are from the original algorithm, or the equivalent variation
    needed to combine all tests into one test.
The last contradiction is commented on above.
\begin{enumerate}
\item Excess of a given prime: \label{cont:xs=p}

    By assuming $p^k \parallel N $ we derive the contradiction that
     $p^{k+1} | N$.
    This is denoted in the output by ``xs=$p$'' where $p$ is the prime in
    question.

    For example, if we wish to show that $269 \nparallel N$ assuming
        that $3^2 \parallel N$, we first assume that $269 \parallel N$.
    Then we see that $3^3$ and $5$ must divide $N$ (the factors of
        $\sigma(269)$), which contradicts $3^2 \parallel N$.
    In this case, this would be denoted in the output by ``xs=3''.

\item Excess of the number of primes: \label{cont:xs=prime}

    We have more primes than we are allowed, given the restrictions on
    $\Omega(N)$ and the fact that only one prime can have an exponent of 1.
    This is denoted in the output by ``xs=prime''.
    Incompletely factored numbers are counted as contributing
    two primes, even though this may be too low.
    Incompletely factors numbers are known not to be perfect powers.
    Furthermore, incompletely factored numbers are checked to ensure that
    they are co-prime with each other, as well as other primes within
    the relevant branch.

    For example, if we wish to show that $26881^{14} \nparallel N$
    when $\Omega(N) \leq 19$, we would start with the
    assumption that $26881^{14} \parallel N$.
    This would imply that
    3, 5, 31, 43, 3368729516337631, 6717545999551, 5601667,
    8265157321, 18691, 145861 and 1801 must all divide $N$, as they
    are the factors of $\sigma(26881^{14})$.
    We see that the factorization of $N$ that would maximize the number of prime
        factors would be $N = 26881^{14} \cdot p_1 \cdot p_2^2 \cdot p_3^2$.
    As this has at most 3 primes unassigned, and there are 11 unassigned prime
        factors of $\sigma(26881^{14})$, we get a contradiction.

\item Partition cannot be satisfied: \label{cont:part}

    The factors that must divide $N$, along with their powers, cannot satisfy
        the partition.
    In the original algorithm there were a number of different ways that
        this contradiction could occur.
    Given that in this implementation, there are not specific exponent
        bounds assigned before starting to recurse, this can only
        occur in one way.
    This is if, of the remaining primes, one of them has to be the special
        prime (with an exponent $a \equiv 1 \pmod{4}$), and
        of all of the remaining primes, all of them are such that
        $p \not\equiv 1 \pmod{4}$.
    This is denoted in the output by ``exponent bounds exceeded''.

    For example, if we wished to show that $3^{10} \nparallel N$ when
         $\Omega(N) \leq 13$, we would start by assuming that
         $3^{10} \parallel N$.
    This implies that $23$ and $3851$ both must divide $N$, (the
         two factors of $\sigma(3^{10})$).
    At this point, as $\Omega(N) \leq 13$, we must have one of these
        two primes being the special prime to get either
        $N = 3^{10} \cdot 23 \cdot 3851^2$ or
        $N = 3^{10} \cdot 23^2 \cdot 3851$.
    But we notice that $23 \equiv 3851 \equiv 3 \pmod{4}$, hence
        we see that neither of 23 or 3851 could be the special prime,
        hence a contradiction.

\item Excess of $\sii$:

    A lower bound for $\sii(N)$ using known factors gives
    $\sii(N) > 2$.
    This is denoted in the code by ``S= number'', giving a floating
        point approximation for a lower bound of $\sii(N)$.
    (The code uses exact rational arithmetic to check the inequality.)

    For example, if we wished to show that $90089 \nparallel N$ we would
        start by assuming that $90089 \parallel N$.
    This implies that $3^2, 5, 7, 11$ and $13$ all divide $N$
        (the factors of $\sigma(90089)$).
    This implies that
        \begin{eqnarray*}
      \sii(N) &\geq & \frac{\sigma(3^2)}{3^2}\times
                         \frac{\sigma(5)}{5}\times
                         \frac{\sigma(7)}{7}\times
                         \frac{\sigma(11)}{11}\times
                         \frac{\sigma(13)}{13}\times
                         \frac{\sigma(90089)}{90089} \\
                  & \approx& 2.327298560 \\ &>& 2
        \end{eqnarray*}
        which is the desired contradiction.
    This is denoted in the output as ``S=2.327298560''.

\item $\omega$-bound exceeded. \label{cont:omega}

    Given the choices of primes and exponents made so far, it is not
        possible to satisfy Lemma \ref{lem:exclude}.

    For example, if we were trying to prove that $3^{46}\nparallel N$ where
        $\Omega(N) \leq 57$ we would start by assuming that
        $3^{46} \parallel N$.
    We notice that $\omega(N)$ is maximized by writting
        $N = 3^{46}\cdot p_1 \cdot p_2^2 \cdot p_3^2
                   \cdot p_4^2\cdot p_5^2$, and hence
        $\omega(N) \leq 7$.
    This contradicts $\omega(N) \geq 8$ from Lemma \ref{lem:exclude}.
    This is denoted as ``violate omega bound''.
\end{enumerate}

In Table \ref{tab:ex} an example of running this code is given, and
    the five possible exceptions.
These exceptions are indicated by the numbers (1) through (5) on the
    left hand side of the page.
The use of Lemma \ref{lem:Carl} is indicated with a star, $(*)$, on the
    left hand side of the page.
Minor formatting has been done to the output, to avoid lines with more
    than 80 characters.
(The output of the actual code would have put the line starting with
    ``It would be nice to know'' all on one line.)

As was done in \cite{Hare05a}, numbers were factored using the
    ifactor command in MAPLE, with the easy option specified.
If easy factors were not found, then the number was checked in a
    hints database (which currently contains over 700 completely, or
    partially factored numbers).

\begin{table}
\caption{Parts of the proof that $\Omega(N) \geq 75$}
\label{tab:ex}
%\verbatiminput{OUTPUT}
\begin{verbatim}
3^6  => 1093
  1093  => 2 547
    547^2  => 3 163 613
      163^2  => 3 7 19 67
        7^2  => 3 19
          19^2  => 3 127
(1)         67^2  => 3 7^2 31  xs=7
    ....
    547^18  => 19256021298645399074821884828797791764310604858317
      19256021298645399074821884828797791764310604858317^2  => 3
                  3081128010533825683 143739375561423904832226409
                  279078490021828554466220167808251320188667868911072727
      ....
      19256021298645399074821884828797791764310604858317^36  => c_1775
        It would be nice to know more factors of
                   sigma(19256021298645399074821884828797791764310604858317^36)
(*)     By Cohen/Sorli's argument, N has a prime factor between 3 and 18
        Trying each one in turn
        Next prime to try is 5
        5^2  => 31
        ....
(5)     17^8  => 19 307 1270657  violate omega bound
        Finished Cohen/Sorli's argument
  ....
  1093^2  => 3 398581
    398581  => 2 17 19 617
    ....
    398581^4  => 5 1866871 2703853428809791
      5  => 2 3
      ....
      5^10  => 12207031
        1866871^2  => 3 19 331 184725139
(4)       19^2  => 3 127  S=2.001549342
          ....
          19^16  => 3044803 99995282631947
            331^2  => 3 7 5233  S=2.310779791
            ...
            331^18  => 282349518620419 8080363351283173500917653281271
(3)           3044803^2  => 3 3090276117871   exponent bounds exceeded
(2)           3044803^4  => 11 631 12382686952067349629581  xs=prime
....
\end{verbatim}
\end{table}

\section{Comments and Acknowledgments}

In \cite{Hare05a} it was said that there were three numbers
    that needed to be factored, without which the algorithm in
    \cite{Hare05a} could not be continued.
Using the methods of Carl Pomerance, this problem was avoided.
At this point, the calculation was terminated not by a particular
    obstruction, but instead because 75 was esthetically pleasing.
Further, 75 was sufficiently large to demonstrate
    the improvement in the algorithm while still remaining reasonable
    with respect to computation time.
The purpose of this paper was to demonstrate a new technique to
    extend this bound, and not necessarily to extend this bound to the
    farthest extent possible.

I would like to thank Phil Carmody, Christophe Clavier, Don Leclair
    Paul Leyland, Tom Womack, Paul Zimmermann, and the people at
    {\tt http://mersenneforum.org} who helped provide factorizations
    for the numbers
    \begin{itemize}
      \item $\sigma(\sigma(547^{18})^{16})$,  a 789-digit number,
      with a factor of: \[ 1520135498523547561326750429418247. \]
      \item $\sigma(\sigma(3221^{12})^{22})$, a 927-digit number,
      with a factor of: \[ 46973400441039677515399714233826061. \]
    \end{itemize}
    which I had listed in \cite{Hare05a} as obstructions to my
    calculations.
This information was included in the hints database used by the code.

I am also indebted to Carl Pomerance for bringing a weaker form of
    Lemma \ref{lem:Carl} to my attention \cite{Pomerance74},
    and more importantly how this could be applied to
    improve the existing bound.
I would also like to thank the unknown referee for the reference
    \cite{CohenSorli03}, which replaced Lemma 2.3, as well as many other
    useful suggestions and comments.

Also, I would like to acknowledge William Lipp, the creator of
   www.oddperfect.org, for providing some additional factorizations.
(The website www.oddperfect.org is a website, which when complete, will
    co-ordinate an attack to improve the lower bound on odd perfect numbers,
    of $N \geq 10^{300}$,
    given by \cite{BrentCohenTeRiele91}.)

%\bibliographystyle{amsplain}
%\bibliography{paper}

\providecommand{\bysame}{\leavevmode\hbox to3em{\hrulefill}\thinspace}
\providecommand{\MR}{\relax\ifhmode\unskip\space\fi MR }
% \MRhref is called by the amsart/book/proc definition of \MR.
\providecommand{\MRhref}[2]{%
  \href{http://www.ams.org/mathscinet-getitem?mr=#1}{#2}
}
\providecommand{\href}[2]{#2}
\begin{thebibliography}{10}

\bibitem{BrentCohenTeRiele91}
R.~P. Brent, G.~L. Cohen, and H.~J.~J. te~Riele, \emph{Improved techniques for
  lower bounds for odd perfect numbers}, Math. Comp. \textbf{57} (1991),
  no.~196, 857--868. \MR{1094940}

\bibitem{Chein79}
E.~Z. Chein, \emph{An odd perfect number has at least 8 prime factors}, Ph.D.
  thesis, Pennsylvania State University, 1979.

\bibitem{Cohen82}
Graeme~L. Cohen, \emph{Generalised quasiperfect numbers}, Ph.D. thesis,
  University of New South Wales, 1982.

\bibitem{CohenSorli03}
Graeme~L. Cohen and Ronald~M. Sorli, \emph{On the number of distinct prime
  factors of an odd perfect number}, J. Discrete Algorithms \textbf{1} (2003),
  no.~1, 21--35, Combinatorial algorithms. \MR{2016472}

\bibitem{Hagis80}
Peter Hagis, Jr., \emph{Outline of a proof that every odd perfect number has at
  least eight prime factors}, Math. Comp. \textbf{35} (1980), no.~151,
  1027--1032. \MR{81k:10004}

\bibitem{Hagis83}
\bysame, \emph{Sketch of a proof that an odd perfect number relatively prime to
  {$3$} has at least eleven prime factors}, Math. Comp. \textbf{40} (1983),
  no.~161, 399--404. \MR{85b:11004}

\bibitem{Hare05a}
Kevin~G. Hare, \emph{More on the total number of prime factors of an odd
  perfect number}, Math. Comp. \textbf{74} (2005), no.~250, 1003--1008
  (electronic). \MR{2114661}

\bibitem{IannucciSorli03}
D.~E. Iannucci and M.~Sorli, \emph{On the total number of prime factors of an
  odd perfect number}, Math. Comp. \textbf{72} (2003), no.~244, 2077--2084.

\bibitem{Kishore83}
Masao Kishore, \emph{Odd perfect numbers not divisible by {$3$}. {II}}, Math.
  Comp. \textbf{40} (1983), no.~161, 405--411. \MR{84d:10009}

\bibitem{Norton61}
Karl~K. Norton, \emph{Remarks on the number of factors of an odd perfect
  number}, Acta Arith. \textbf{6} (1960/1961), 365--374. \MR{26 \#4950}

\bibitem{Pomerance74}
Carl Pomerance, \emph{Odd perfect numbers are divisible by at least seven
  distinct primes}, Acta Arith. \textbf{25} (1973/74), 265--300.
  \MR{0340169}

\bibitem{Sayers86}
M.~Sayers, \emph{An improved lower bound for the total number of prime factors
  of an odd perfect number}, Master's thesis, New South Wales Institute of
  Technology, 1986.

\end{thebibliography}

\end{document}


\section{Edit distance}

%-------------------------------------------------------------------------------

\begin{frame}{Edit distance}
  \textbf{Definition of edit distance}: (\textit{Levenshtein-distance})
  \begin{itemize}
    \item<2->
      Let {\color{Mittel-Blau}$x$}, {\color{Mittel-Blau}$y$} be two strings
    \item<2->
      Edit distance {\color{Mittel-Blau}$\mathrm{ED}(x, y)$} of
      {\color{Mittel-Blau}$x$} and {\color{Mittel-Blau}$y$}:\\
      The minimal number of operations to transform {\color{Mittel-Blau}$x$}
      into {\color{Mittel-Blau}$y$}
      \begin{itemize}
        \item<3->
          \texttt{Insert} a character
        \item<4->
          \texttt{Replace} a character with another
        \item<5->
          \texttt{Delete} a character
          % Die Position einer Operation ist ... siehe Beispiel ???
      \end{itemize}
  \end{itemize}
\end{frame}

%-------------------------------------------------------------------------------

\begin{frame}{Edit distance}{Example}
  \begin{columns}
    \begin{column}{0.5\linewidth}
      \begin{center}
        \begin{tabular}{c@{}c@{}c@{}c@{}cl}
          1 & 2 & 3 & 4 & 5\\
          D & O & O & F\\
          \only<2-13>{
          {} & {} & $\downarrow$ & {} & {} & \texttt{replace(1, B)}\\
          B & O & O & F}\\
          \only<3-13>{
          {} & {} & $\downarrow$ & {} & {} & \texttt{replace(2, L)}\\
          B & L & O & F}\\
          \only<4-13>{
          {} & {} & $\downarrow$ & {} & {} & \texttt{insert(4, E)}\\
          B & L & O & E & F}\\
          \only<5-13>{
          {} & {} & $\downarrow$ & {} & {} & \texttt{replace(5, D)}}\\
          B & L & O & E & D\\
          \only<6-13>{
          {} & {} & {} & {} & {} &
          $\underbrace{\hspace{7.5em}}_{\mathrm{ED} = 4}$}
        \end{tabular}
      \end{center}
    \end{column}
    \begin{column}{0.5\linewidth}
      \begin{center}
        \begin{tabular}{c@{}c@{}c@{}c@{}cl}
          \only<7-13>{
          1 & 2 & 3 & 4 & 5\\
          B & L & O & E & D\\}
          \only<9-13>{
          {} & {} & $\downarrow$ & {} & {} & \texttt{replace(5, F)}\\
          B & L & O & E & F}\\
          \only<10-13>{
          {} & {} & $\downarrow$ & {} & {} & \texttt{delete(4)}\\
          B & L & O & F}\\
          \only<11-13>{
          {} & {} & $\downarrow$ & {} & {} & \texttt{replace(2, O)}\\
          B & O & O & F}\\
          \only<12-13>{
          {} & {} & $\downarrow$ & {} & {} & \texttt{replace(1, D)}}\\
          \only<8-13>{
            D & O & O & F}\\
          \only<13-13>{
          {} & {} & {} & {} & {} &
          $\underbrace{\hspace{7.5em}}_{\mathrm{ED} = 4}$}
        \end{tabular}
      \end{center}
    \end{column}
  \end{columns}
\end{frame}

%-------------------------------------------------------------------------------

\begin{frame}{Edit distance}
  \textbf{Notation:}
  \begin{itemize}
    \item<2->
      $\varepsilon$ is the empty string
    \item<3->
      $\vert x \vert$ is the length of the string $x$ (number of characters)
    \item<5->
      $x[i..j]$ is the slice of $x$ from $i$ to $j$ where
      $1 \leq i \leq j \leq \vert x \vert$
  \end{itemize}
  \onslide<6->
  \begin{figure}[!h]
    \begin{adjustbox}{width=0.75\linewidth}
      \input{Images/Levenshtein_Distance/Slice.tikz}
    \end{adjustbox}
  \end{figure}
\end{frame}

%-------------------------------------------------------------------------------

\begin{frame}{Edit distance}
  \textbf{Trivial facts:}
  \begin{itemize}
    \item<2->
      $\mathrm{ED}(x, y) = \mathrm{ED}(y, x)$
    \item<3->
      $\mathrm{ED}(x, \epsilon) = \vert x \vert$
    \item<4->
      $\mathrm{ED}(x, y) \geq \mathrm{abs}(\vert x \vert - \vert y \vert)$
      \hfill
      $\mathrm{abs}(x) = \begin{cases}
        x & \text{if } x \geq 0\\
        -x & \text{else}
      \end{cases}$
    \item<5->
      $\mathrm{ED}(x, y) \leq \mathrm{ED}(x[1..n-1], y[1..m-1]) + 1$
      \hfill
      $n = \vert x \vert, \; m = \vert y \vert$
  \end{itemize}
\end{frame}

%-------------------------------------------------------------------------------

\begin{frame}{Edit distance}{Solving examples}
  \textbf{Solutions based on examples:}
  \begin{itemize}
    \item<2->
      From \texttt{VERIEN} to \texttt{FERIEN}?
    \item<3->
      From \texttt{MEXIKO} to \texttt{AMERIKA}?
    \item<4->
      From \texttt{AAEBEAABEAREEAEBA} to \texttt{RBEAAEEBAAAEBBAEAE}?
    \item<5->
      Searching biggest substrings can yield the solution but doesn't have to
  \end{itemize}
  \vspace{1.0em}
  \onslide<6->
  \textbf{Recursive approach:}
  \begin{itemize}
    \item<7->
      Dividing in two halves? Not a good idea:\\[0.5em]
      {\color{Mittel-Blau}$\mathrm{ED}(GRAU, RAUM) = 2$} \; but \;
      {\color{Mittel-Blau}$\mathrm{ED}(GR, RA) + \mathrm{ED}(AU, UM) = 4$}
      \\[0.5em]
    \item<8->
      Finding \enquote{smaller} sub problems?\\
      {\color{gray}Let's try it!}
  \end{itemize}
\end{frame}

%-------------------------------------------------------------------------------

\begin{frame}{Edit distance}
  \textbf{Terminology:}
  \begin{itemize}
    \item<2->
      Let {\color{Mittel-Blau}$x$}, {\color{Mittel-Blau}$y$} be two strings
    \item<3->
      Let $\sigma_1, \dots, \sigma_k$ be a sequence of $k$ operations
      where $k = \mathrm{ED}(x, y)$ for {\color{Mittel-Blau}$x \rightarrow y$}
      (transform {\color{Mittel-Blau}$x$} into {\color{Mittel-Blau}$y$})\\
      {\color{gray}(We do not know this sequence but we assume it exists)}
  \end{itemize}
\end{frame}

%-------------------------------------------------------------------------------

\begin{frame}{Edit distance}
  \textbf{Terminology:}
  \begin{itemize}
    \item<2->
      We only consider {\color{Mittel-Blau}monotonous} sequences:\\
      The positition of $\sigma_{i+1}$ is $\geq$ the position of $\sigma_i$
      where we only allow the positions to be equal on a \texttt{delete}
      operation
  \end{itemize}
  \onslide<3->
  \begin{columns}
    \begin{column}{0.5\linewidth}
      \begin{center}
        \begin{tabular}{c@{}c@{}c@{}c@{}cl}
          1 & 2 & 3 & 4 & 5\\
          D & O & O & F\\
          \only<1-1>
          {} & {} & $\downarrow$ & {} & {} &
          \texttt{replace({\color{Mittel-Blau}1}, B)}\\
          B & O & O & F\\
          \only<2-2>
          {} & {} & $\downarrow$ & {} & {} &
          \texttt{replace({\color{Mittel-Blau}2}, L)}\\
          B & L & O & F\\
          \only<3-3>
          {} & {} & $\downarrow$ & {} & {} &
          \only{insert({\color{Mittel-Blau}4}, E)}\\
          B & L & O & E & F\\
          \only<4-4>
          {} & {} & $\downarrow$ & {} & {} &
          \texttt{replace({\color{Mittel-Blau}5}, D)}\\
          B & L & O & E & D
        \end{tabular}
      \end{center}
    \end{column}
    \begin{column}{0.5\linewidth}
      \begin{center}
        \begin{tabular}{c@{}c@{}c@{}c@{}c@{}c@{}cl}
          1 & 2 & 3 & 4 & 5 & 6 & 7\\
          S & A & U & D & O & O & F\\
          {} & {} & {} & $\downarrow$ & {} & {} & {} &
          \texttt{delete({\color{Mittel-Blau}1})}\\
          A & U & D & O & O & F\\
          {} & {} & {} & $\downarrow$ & {} & {} & {} &
          \texttt{delete({\color{Mittel-Blau}1})}\\
          U & D & O & O & F\\
          {} & {} & {} & $\downarrow$ & {} & {} & {} &
          \texttt{delete({\color{Mittel-Blau}1})}\\
          D & O & O & F\\
          {} & {} & {} & $\downarrow$ & {} & {} & {} &
          \texttt{insert({\color{Mittel-Blau}4}, O)}\\
          D & O & O & O & F
        \end{tabular}
      \end{center}
    \end{column}
  \end{columns}
\end{frame}

%-------------------------------------------------------------------------------

\begin{frame}{Edit distance}
  \textbf{Terminology:}
  \begin{itemize}
    \item<2->
      \textbf{Lemma:}
      For any {\color{Mittel-Blau}$x$} and {\color{Mittel-Blau}$y$}
      with $k = \mathrm{ED}(x, y)$ exists a {\color{Mittel-Blau}monotonous}
      sequence of $k$ operations for {\color{Mittel-Blau}$x \rightarrow y$}
    \item<3->
      \textbf{Intuition:}
      The order of our sequence is not relevant\\
      (Therefore we can also sort them monotonously)
  \end{itemize}
  \onslide<4->
  \begin{columns}[T]
    \begin{column}{0.5\linewidth}
      \begin{center}
        \begin{tabular}{ccccc}
          1 & 2 & 3 & 4 & 5\\
          D & O & O & F\\
          \\
          B & L & O & E & D
        \end{tabular}
      \end{center}
    \end{column}
    \begin{column}{0.5\linewidth}
      \begin{center}
        \begin{tabular}{ccccccc}
          1 & 2 & 3 & 4 & 5 & 6 & 7\\
          S & A & U & D & O & O & F\\
          \\
          D & O & O & O & F
        \end{tabular}
      \end{center}
    \end{column}
  \end{columns}
\end{frame}

%-------------------------------------------------------------------------------

\begin{frame}{Edit distance}{Recursive approach}
  \textbf{Consider the last operation:}
  \begin{itemize}
    \item<2->
      Solve {\color{Mittel-Blau}blue} part recursively
  \end{itemize}
  \onslide<3->
  \begin{columns}[T]
    \begin{column}{0.3\linewidth}
      \begin{figure}[!h]
        \begin{center}
          \begin{tabular}{c@{}c@{}c@{}c@{}c@{}l}
            \color{Mittel-Blau}D & \color{Mittel-Blau}O & \color{Mittel-Blau}O &
            \color{Mittel-Blau}F\\
            \color{Mittel-Blau}$\downarrow$ & \color{Mittel-Blau}$\downarrow$ &
            \color{Mittel-Blau}$\downarrow$ & \color{Mittel-Blau}$\downarrow$\\
            \color{Mittel-Blau}B & \color{Mittel-Blau}L & \color{Mittel-Blau}O &
            \color{Mittel-Blau}E\\
            {} & {} & {} & {} & $\downarrow$ & \texttt{insert}\\
            B & L & O & E & D
          \end{tabular}
        \end{center}
        \caption{Case 1a}
      \end{figure}
    \end{column}
    \begin{column}{0.3\linewidth}
      \begin{figure}[!h]
        \begin{center}
          \begin{tabular}{c@{}c@{}c@{}c@{}c@{}c@{}l}
            {} & {} & \color{Mittel-Blau}D & \color{Mittel-Blau}O &
            \color{Mittel-Blau}O & \color{Mittel-Blau}F\\
            \color{Mittel-Blau}$\downarrow$ & \color{Mittel-Blau}$\downarrow$ &
            \color{Mittel-Blau}$\downarrow$ & \color{Mittel-Blau}$\downarrow$ &
            \color{Mittel-Blau}$\downarrow$ & \color{Mittel-Blau}$\downarrow$\\
            \color{Mittel-Blau}B & \color{Mittel-Blau}L & \color{Mittel-Blau}O &
            \color{Mittel-Blau}E & \color{Mittel-Blau}D & \color{Mittel-Blau}F\\
            {} & {} & {} & {} & {} & $\downarrow$ & \texttt{delete}\\
            B & L & O & E & D
          \end{tabular}
        \end{center}
        \caption{Case 1b}
      \end{figure}
    \end{column}
    \begin{column}{0.3\linewidth}
      \begin{figure}[!h]
        \begin{center}
          \begin{tabular}{c@{}c@{}c@{}c@{}c@{}l}
            {} & \color{Mittel-Blau}D & \color{Mittel-Blau}O &
            \color{Mittel-Blau}O & \color{Mittel-Blau}F\\
            \color{Mittel-Blau}$\downarrow$ & \color{Mittel-Blau}$\downarrow$ &
            \color{Mittel-Blau}$\downarrow$ & \color{Mittel-Blau}$\downarrow$ &
            \color{Mittel-Blau}$\downarrow$\\
            \color{Mittel-Blau}B & \color{Mittel-Blau}L & \color{Mittel-Blau}O &
            \color{Mittel-Blau}E & \color{Mittel-Blau}F\\
            {} & {} & {} & {} & $\downarrow$ & \texttt{replace}\\
            B & L & O & E & D
          \end{tabular}
        \end{center}
        \caption{Case 1c}
      \end{figure}
    \end{column}
  \end{columns}
\end{frame}

%-------------------------------------------------------------------------------

\begin{frame}{Edit distance}{Recursive approach}
  \textbf{Consider the last operation:}
  \begin{itemize}
    \item<2->
      Solve {\color{Mittel-Blau}blue} part recursively
  \end{itemize}
  \onslide<3->
  \begin{columns}
    \begin{column}{0.3\linewidth}
      \begin{figure}[!h]
        \begin{center}
          \begin{tabular}{c@{}c@{}c@{}c@{}c@{}c@{}c@{}l}
            \color{Mittel-Blau}W & \color{Mittel-Blau}I & \color{Mittel-Blau}N &
            \color{Mittel-Blau}T & \color{Mittel-Blau}E & \color{Mittel-Blau}R\\
            \color{Mittel-Blau}$\downarrow$ & \color{Mittel-Blau}$\downarrow$ &
            \color{Mittel-Blau}$\downarrow$ & \color{Mittel-Blau}$\downarrow$ &
            \color{Mittel-Blau}$\downarrow$ & \color{Mittel-Blau}$\downarrow$\\
            \color{Mittel-Blau}S & \color{Mittel-Blau}O & \color{Mittel-Blau}M &
            \color{Mittel-Blau}M & \color{Mittel-Blau}E & \color{Mittel-Blau}R\\
            {} & {} & {} & {} & {} & $\downarrow$ & \texttt{nothing}\\
            S & O & M & M & E & R
          \end{tabular}
        \end{center}
        \caption{Case 2}
      \end{figure}
    \end{column}
    \begin{column}{0.5\linewidth}
      \textbf{Display of solution:}
      \begin{itemize}
        \item
          Alignment
        \item
          Example:
          \begin{tabular}{cccccccc}
            \_ & \_ & \_ & B & L & O & E & D\\
            S & A & U & B & L & O & E & D
          \end{tabular}
      \end{itemize}
    \end{column}
  \end{columns}
\end{frame}

%-------------------------------------------------------------------------------

\begin{frame}{Edit distance}{Dynamic programming}
  \begin{columns}
    \begin{column}{0.65\linewidth}
      \textbf{Dynamic programming:}
      \begin{itemize}
        \item<2->
          Instances of Bellman's principle of optimality:
        \begin{itemize}
          \item<3->
            Shortest paths
          \item<4->
            Edit distance
          \end{itemize}
      \end{itemize}
    \end{column}
    \onslide<5->
    \begin{column}{0.35\linewidth}
      \begin{figure}[!h]
        \includegraphics[width=0.9\linewidth, clip, trim=10 0 10 0]%
          {Images/Levenshtein_Distance/Richard_Ernest_Bellman.jpg}
        \caption{Richard Bellman (1920 - 1984)}
      \end{figure}
    \end{column}
  \end{columns}
  \onslide<6->
  \begin{itemize}
    \item<7->
      Optimal solutions consist of optimal partial solutions
      \begin{itemize}
        \item<8->
          Shortest paths: Each partial path has to be optimal
        \item<9->
          Edit distance: Each partial alignment has to be optimal\\
          \begin{figure}[!h]
            \only<1|handout:0>{
              \begin{tabular}{cccccccccc}
                \_ & \_ & \_ & B & L & O & E & D & E & R\\
                S & A & U & B & L & O & E & D & \_ & \_
              \end{tabular}
            }%
            \only<2>{%
              \begin{tabular}{cccc|cccccc}
                \_ & \_ & \_ & B & L & O & E & D & E & R\\
                S & A & U & B & L & O & E & D & \_ & \_
              \end{tabular}
            }%
          \end{figure}
      \end{itemize}
    \item<10->
      Always solvable through dynamic programming\\
      (Caching of optimal partial solutions)
  \end{itemize}
\end{frame}

%-------------------------------------------------------------------------------

\begin{frame}{Edit distance}
  \textbf{Case analysis:}
  \begin{itemize}
    \item<2->
      We consider the last operation $\sigma_k$
      \begin{itemize}
        \item<3->
          $\sigma_1, \dots, \sigma_{k-1}$:
          {\color{Mittel-Blau}$x \rightarrow z$} and $\sigma_k$:
          {\color{Mittel-Blau}$z \rightarrow y$}\\
          Example:
          \begin{displaymath}
            x = \mathrm{DOOF}, \;
            z = \mathrm{SAUBLOEF}, \;
            y = \mathrm{SAUBLOED}
          \end{displaymath}
        \item<4->
          Let $n = \vert x \vert, \; m = \vert y \vert, \; m' = \vert z \vert$
        \item<5->
          We note $m' \in \{m - 1, m, m + 1\}$
          \hspace{1.5em}
          {\color{gray}why?}
      \end{itemize}
  \end{itemize}
\end{frame}

%-------------------------------------------------------------------------------

\begin{frame}{Edit distance}
  \textbf{Case analysis:}
  \begin{itemize}
    \item<2->
      Case 1: {\color{Mittel-Blau}$\sigma_k$} does something at the outer end:
      \begin{itemize}
        \item<3->
          Case 1a:
          {\color{Mittel-Blau}$\sigma_k = \texttt{insert}(m' + 1, y[m])$}
          \hfill
          [then {\color{Mittel-Blau}$m' = m - 1$}]
        \item<4->
          Case 1b:
          {\color{Mittel-Blau}$\sigma_k = \texttt{delete}(m')$}
          \hfill
          [then {\color{Mittel-Blau}$m' = m + 1$}]
        \item<5->
          Case 1c:
          {\color{Mittel-Blau}$\sigma_k = \texttt{replace}(m', y[m])$}
          \hfill
          [then {\color{Mittel-Blau}$m' = m$}]
      \end{itemize}
      \vspace{0.5em}
    \item<6->
      Case 2: {\color{Mittel-Blau}$\sigma_k$} does nothing at the outer end:
      \begin{itemize}
        \item<7->
          Then {\color{Mittel-Blau}$z[m'] = y[m]$} and
          {\color{Mittel-Blau}$x[n'] = z[m']$} and with that\\
          $\sigma_1, \dots, \sigma_{k-1}$:
          {\color{Mittel-Blau}$x[1..n-1] \rightarrow y[1..m-1]$} and
          {\color{Mittel-Blau}$x[n] = y[m]$}
      \end{itemize}
  \end{itemize}
\end{frame}

%-------------------------------------------------------------------------------

\begin{frame}{Edit distance}
  \textbf{Case analysis:}
  \begin{itemize}
    \item<2->
      Case 1a (\texttt{insert}):
      \hfill
      {\color{Mittel-Blau}$\sigma_1, \dots, \sigma_{k-1}$}:
      {\color{Mittel-Blau}$x\hphantom{[1..n-1]} \rightarrow y[1..m-1]$}
    \item<3->
      Case 1b (\texttt{delete}):
      \hfill
      {\color{Mittel-Blau}$\sigma_1, \dots, \sigma_{k-1}$}:
      {\color{Mittel-Blau}$x[1..n-1] \rightarrow y\hphantom{[1..m-1]}$}
    \item<4->
      Case 1c (\texttt{replace}):
      \hfill
      {\color{Mittel-Blau}$\sigma_1, \dots, \sigma_{k-1}$}:
      {\color{Mittel-Blau}$x[1..n-1] \rightarrow y[1..m-1]$}
    \item<5->
      Case 2 (\texttt{nothing}):
      \hfill
      {\color{Mittel-Blau}$\sigma_1, \dots, \sigma_{k}$}:
      {\color{Mittel-Blau}$x[1..n-1] \rightarrow y[1..m-1]$}
  \end{itemize}
  \onslide<6->
  \textbf{This results in the recursive formula:}
  \begin{itemize}
    \item<7->
      For {\color{Mittel-Blau}$\vert x \vert > 0$} and
      {\color{Mittel-Blau}$\vert y \vert > 0$} is
      {\color{Mittel-Blau}$\mathrm{ED}(x, y)$} the minimum of
      \begin{itemize}
        \item<8->
          {\color{Mittel-Blau}
            $\mathrm{ED}(x\hphantom{[1..n-1]}, y[1..m-1]) + 1$} and
        \item<9->
          {\color{Mittel-Blau}
            $\mathrm{ED}(x[1..n-1], y\hphantom{[1..m-1]}) + 1$} and
        \item<10->
          {\color{Mittel-Blau}
            $\mathrm{ED}(x[1..n-1], y[1..m-1]) + 1$} if
          {\color{Mittel-Blau}$x[n] \neq y[m]$}
        \item<11->
          {\color{Mittel-Blau}
            $\mathrm{ED}(x[1..n-1], y[1..m-1]) + 0$} if
          {\color{Mittel-Blau}$x[n] = y[m]$}
      \end{itemize}
    \item<12->
      For {\color{Mittel-Blau}$\vert x \vert = 0$} is
      {\color{Mittel-Blau}$\mathrm{ED}(x, y) = \vert y \vert$}
    \item<13->
      For {\color{Mittel-Blau}$\vert y \vert = 0$} is
      {\color{Mittel-Blau}$\mathrm{ED}(x, y) = \vert x \vert$}
  \end{itemize}
\end{frame}

%-------------------------------------------------------------------------------

\codeslide{python}{
\begin{frame}{Edit distance}{Implementation - Python}
  \lstinputlisting[
    language=Python,
    tabsize=4,
    style={python-idle-code},
    emph={edit_distance},
    emphstyle=\color{blue}
  ]{Code/EditDistance/edit_distance.py}
\end{frame}
}

%-------------------------------------------------------------------------------

\begin{frame}{Edit distance}{Runtime analysis}
  \textbf{Recursive program:}
  \begin{itemize}
    \item<2->
      The algorithm results in the following recursive formular:
      \begin{align*}
        T(n, m) &= T(n-1, m) + T(n, m-1) + T(n-1, m-1) + 1\\
        & \geq T(n-1, m-1) + T(n-1, m-1) + T(n-1, m-1)\\
        & = 3 \cdot T(n-1, m-1)
      \end{align*}
    \item<3->
      This results in {\color{Mittel-Blau}$T(n, n) \geq 3^n$}
    \item<4->[$\Rightarrow$]
      The runtime is at least {\color{Mittel-Blau}exponential}
  \end{itemize}
\end{frame}

%-------------------------------------------------------------------------------

\begin{frame}{Edit distance}
  \textbf{Dynamic programming:}
  \begin{itemize}
    \item<2->
      We create a table with all possible combination of substrings and save
      calculated entries
    \item<2->
      This results in a runtime and space consumption of
      {\color{Mittel-Blau}$O(n \cdot m)$}
  \end{itemize}
  \vspace{1em}
  \onslide<3->
  \textbf{Visualization on the next slide:}
  \begin{itemize}
    \item<4->
      Operations always refer to the last position\\
      (indices are omitted)
    \item<5->
      We also display the replaced character on a \texttt{replace} operation
      to visualize operations without costs\\
      $\Rightarrow$ \texttt{\color{Mittel-Blau}repl(\color{Mittel-Gruen}A%
        \color{Mittel-Blau}, \color{Mittel-Gruen}A\color{Mittel-Blau})}
  \end{itemize}
\end{frame}

%-------------------------------------------------------------------------------

{%
  \setbeamertemplate{headline}[default]
  \makeatletter\def\beamer@entrycode{\vspace*{-\headheight}}\makeatother
  \begin{frame}{Edit Distance}
    \begin{center}
      \begin{adjustbox}{width=0.8\linewidth}
        \def\AlgoIntro{1}\def\AlgoFinal{0}%
        \input{Images/Levenshtein_Distance/Grid.tikz}
      \end{adjustbox}
    \end{center}
  \end{frame}
}%

%-------------------------------------------------------------------------------

\begin{frame}{Edit distance}{Fast algorithm}
  \textbf{Fast algorithm:}\\
  We can determine the {\color{Mittel-Blau}edit distance} for all combination
  of partial strings from the top left to bottom right.
\end{frame}

%-------------------------------------------------------------------------------

{%
  \setbeamertemplate{headline}[default]
  \makeatletter\def\beamer@entrycode{\vspace*{-\headheight}}\makeatother
  \begin{frame}{Edit Distance}
    \begin{center}
      \begin{adjustbox}{width=0.8\linewidth}
        \def\AlgoIntro{0}\def\AlgoFinal{0}%
        \input{Images/Levenshtein_Distance/Grid.tikz}
      \end{adjustbox}
    \end{center}
  \end{frame}
}%

%-------------------------------------------------------------------------------

\begin{frame}{Edit distance}
  \textbf{How to get the sequence of operations?}
  \begin{itemize}
    \item<2->
      We save at each recursion the most efficient previous entry
      (the {\color{Mittel-Blau}highlighted arrows} in our image)
    \item<3->
      There can be {\color{Mittel-Blau}more than one} arrows to the three
      previous entries
    \item<4->
      If we follow the highlighted path from {\color{Mittel-Blau}$(n, m)$} to
      {\color{Mittel-Blau}$(1, 1)$} we get the optimum operations to transform
      {\color{Mittel-Blau}$x$} into {\color{Mittel-Blau}$y$}
      \begin{itemize}
        \item<5->
          If we can follow {\color{Mittel-Blau}more than one path} there exist
          more than one ideal {\color{Mittel-Blau}sequence}
      \end{itemize}
  \end{itemize}
\end{frame}

%-------------------------------------------------------------------------------

{%
  \setbeamertemplate{headline}[default]
  \makeatletter\def\beamer@entrycode{\vspace*{-\headheight}}\makeatother
  \begin{frame}{Edit Distance}
    \begin{center}
      \begin{adjustbox}{width=0.8\linewidth}
        \def\AlgoIntro{0}\def\AlgoFinal{1}%
        \input{Images/Levenshtein_Distance/Grid.tikz}
      \end{adjustbox}
    \end{center}
  \end{frame}
}%

%-------------------------------------------------------------------------------

\begin{frame}{Edit distance}
  \textbf{General principle:}
  \begin{itemize}
    \item<2->
      Recursive computation of $\ldots$
      \begin{itemize}
        \item[$\ldots$]
          the same reoccuring partial problems
        \item[$\ldots$]
          a limited number of partial problems
      \end{itemize}
    \item<3->
      Computation of the solutions for all partial problems
    \item<4->
      In a order that unsolved partial problems consist of already solved
      partial problems
    \item<5->
      The \enquote{path} to our solution normally gets computed while searching
      the best solution
    \item<5->
      Dijkstra algorithm is basically dynamic programming!
  \end{itemize}
\end{frame}

%-------------------------------------------------------------------------------

\begin{frame}{Edit distance}{Additional applications (I)}
  \textbf{Additional applications:}
  \begin{itemize}
    \item<2->
      \textit{Edit distance}: global alignment with $O(n^2)$ space and time
      consumption
    \item<3->
      But: Model for deletition unrealistic
      \begin{itemize}
        \item<4->
          In evolution larger pieces are more likely
        \item<5->
          \texttt{delete} operation: first gap expensive (e.g. 2),
          remainding are cheaper (e.g. 0.5)
          \begin{figure}[!h]
            \begin{tabular}{cccccccc}
              \_ & \_ & \_ & B & L & O & E & D\\
              S & A & U & B & L & O & E & D
            \end{tabular}
          \end{figure}
        \item<6->
          Solution in $O(n^3)$ time or $O(n^2)$ affine
      \end{itemize}
  \end{itemize}
\end{frame}

%-------------------------------------------------------------------------------

\begin{frame}{Edit distance}{Additional applications (II)}
  $O(n^2)$ space consumption might be problematic:\\[0.5em]
  \textbf{Hirschberg algorithm:}
  \begin{itemize}
    \item<2->
      Divide-and-conquer approach
    \item<3->
      $O(n)$ space and $O(n^2)$ time consumption
  \end{itemize}
\end{frame}

%-------------------------------------------------------------------------------

\begin{frame}{Edit distance}{Additional applications (III)}
  \begin{figure}[!h]
    \includegraphics[width=0.8\linewidth]%
      {Images/Additional_Applications/Whole_Genome_Shotgun_Sequencing.png}
  \end{figure}
  \begin{itemize}
    \item<2->
      Sequencing: $O(n^2)$ is too much
    \item<3->
      Index: suffixtree, suffixarray, burrow-wheeler-transform
  \end{itemize}
\end{frame}


%%\documentclass[handout]{beamer}
%\documentclass[aspectratio=169,13pt]{beamer}
%\input{./preamble}

\subtitle{Eigenvalue Problems}
\date{}
\begin{document}

\begin{frame}
  \titlepage
\end{frame}

\section{Eigenvalues and Eigenvectors}

\begin{frame}{Eigenvalues and Eigenvectors}

\begin{itemize}
\item A matrix $\B A$ has eigenvector-eigenvalue pair (eigenpair) $(\lambda, \B x)$ if
\lgcond{
\[ \B A \B x = \lambda \B x\]
\begin{itemize}
\item For any scalar $\alpha$, $\alpha \B x$ is also an eigenvector of $\B A$ with eigenvalue $\lambda$
\sitem Generally, an eigenvalue $\lambda$ is associated with an eigenspace $\mathcal{X} \subseteq \mathbb{C}^{n}$ such that each $\B x \in\mathcal{X}$ is an eigenvector of $\B A$ with eigenvalue $\lambda$.
\sitem The dimensionality of an eigenspace is at most the multiplicity of an eigenvalue (when less, matrix is \coloremph{defective}, otherwise matrix is \coloremph{diagonalizable}).
\end{itemize}
}
\item Each $n\times n$ matrix has up to $n$ eigenvalues, which are either real or complex
\lgcond{
\begin{itemize}
\sitem The conjugate of any complex eigenvalue of a real matrix is also an eigenvalue.
\sitem The dimensionalities of all the eigenspaces (multiplicity associated with each eigenvalue) sum up to $n$ for a diagonalizable matrix.
\sitem If the matrix is real, real eigenvalues are associated with real eigenvectors, but complex eigenvalues may not be.
\end{itemize}
}
\end{itemize}

\end{frame}

\begin{frame}[fragile]{Eigenvalue Decomposition}

\begin{itemize}
\item If a matrix $\B A$ is diagonalizable, it has an \coloremph{eigenvalue decomposition}
\lgcond{
\[\B A = \B X \B D \B X^{-1}\]
where $\B X$ are the right eigenvectors, $\B X^{-1}$ are the left eigenvectors and $\B D$ are eigenvalues
\[\B A \B X = \begin{bmatrix} \B A \B x_1 & &\cdots \B A \B x_n \end{bmatrix}= \B X \B D = \begin{bmatrix} d_{11}\B x_1 & \cdots & d_{nn} \B x_n\end{bmatrix}.\]
\begin{itemize}
\item If $\B A$ is symmetric, its right and left singular vectors are the same, and consequently are its eigenvectors.
\sitem More generally, any \coloremph{normal} matrix, $\B A^H\B A = \B A \B A^H$, has unitary eigenvectors.
\end{itemize}
}
\item $\B A$ and $\B B$ are \coloremph{similar}, if there exist $\B Z$ such that $\B A = \B Z \B B \B Z^{-1}$
\lgcond{
\begin{itemize}
\item Normal matrices are \coloremph{unitarily similar} ($\B Z^{-1}=\B Z^H$) to diagonal matrices
\sitem Symmetric real matrices are \coloremph{orthogonally similar} ($\B Z^{-1}=\B Z^T$) to real diagonal matrices
\sitem Hermitian matrices are {unitarily similar} to real diagonal matrices
\end{itemize}
}
\end{itemize}

\end{frame}

\section{Similarity}

\begin{frame}{Similarity of Matrices}

{\Large
\begin{center}
\begin{tabular}{r|c|l}
{\it matrix} & \ \ \ \ {\it similarity} \ \ \ \ & {\it reduced form} \\
\hline
SPD & \filufil{orthogonal}{} & \filufil{real positive diagonal}{} \\
\hline
real symmetric & \filufil{orthogonal}{} & \filufil{real tridiagonal}{} \\
& & \filufil{real diagonal}{} \\
\hline
Hermitian & \filufil{unitary}{} & \filufil{real diagonal}{} \\
\hline
normal & \filufil{unitary}{} & \filufil{diagonal}{} \\
\hline
real & \filufil{orthogonal}{} & \filufil{real Hessenberg}{} \\
\hline
diagonalizable & \filufil{invertible}{} & \filufil{diagonal}{} \\
\hline
arbitrary & \filufil{unitary}{} & \filufil{triangular}{} \\
& \filufil{invertible}{} & \filufil{bidiagonal}{}
\end{tabular}
\end{center}
}

\end{frame}

\begin{frame}{Canonical Forms}

\begin{itemize}
\item Any matrix is \coloremph{similar} to a bidiagonal matrix, giving its \coloremph{Jordan form}:

\lgcond{
\[\B A = \B{X}\begin{bmatrix} \B{J}_{1} & & \\ & \ddots & \\ & & \B{J}_{k} \end{bmatrix}\B{X}^{-1}, \quad \forall i, \quad \B{J}_{i} = \begin{bmatrix} \lambda_{i} & 1 &  &  \\ & \ddots & \ddots & \\ & & \ddots & 1 \\ & & & \lambda_i \end{bmatrix} \]
the Jordan form is unique modulo ordering of the diagonal \coloremph{Jordan blocks}.
}

\item Any diagonalizable matrix is  \coloremph{unitarily similar} to a triangular matrix, giving its \coloremph{Schur form}:

\lgcond{
\[\B A = \B{Q}\B{T} \B {Q}^H\]
where $\B{T}$ is upper-triangular, so the eigenvalues of $\B{A}$ is the diagonal of $\B{T}$.
Columns of $\B Q$ are the \coloremph{Schur vectors}.
}

\end{itemize}

\end{frame}

\begin{frame}{Eigenvectors from Schur Form}
\urcornerlinkinclass{inclass-tri-eig}{Calculating Eigenpairs of a Triangular Matrix}

\begin{itemize}
\item Given the eigenvectors of one matrix, we seek those of a similar matrix:

\mdcond{
Suppose that $\B{A} = \B{S}\B{B}\B{S}^{-1}$ and $\B{B}=\B{X}\B{D}\B{X}^{-1}$ where $\B{D}$ is diagonal,
\begin{itemize}
\sitem The eigenvalues of $\B{A}$ are $\{d_{11},\ldots, d_{nn}\}$
\sitem $\B{A}=\B{S}\B{B}\B{S}^{-1}=\B{S}\B{X}\B{D}\B{X}^{-1}\B{S}^{-1}$ so $\B{S}\B{X}$ are the eigenvectors of $\B{A}$
\end{itemize}

}

\item Its easy to obtain eigenvectors of triangular matrix $\B T$: % $\B T=\brmat{T}$:
%\(0=(\B T - \lambda \B I)\B x = \begin{bmatrix} \B{T}_{11} - \lambda \B I & \B{t}_{12}  \\ &   \\ & 0\end{bmatrix}\begin{bmatrix} \B{x}_1 \\ 1 \end{bmatrix} \) then deflate
%\lgcond{}

\lgcond{
\begin{itemize}
\item One eigenvector is simply the first elementary vector.
\sitem The eigenvector associated with any diagonal entry (eigenvalue $\lambda$) may be obtaining by observing that
\[\B 0 = (\B T - \lambda \B I)\B x = \begin{bmatrix} \B{U}_{11} & \B u & \B{T}_{13} \\ & 0 & \B v^T \\ & & \B U_{33}\end{bmatrix}\begin{bmatrix} -\B{U}_{11}^{-1}\B u \\ 1 \\ \B 0 \end{bmatrix},\]
so it suffices to solve $\B U_{11}\B y = -\B u$ to obtain eigenvector $\B x$.
%\sitem If $\B x$ is an are eigenvectors of $\B T_{11}$, $\begin{bmatrix} \B{X_1} \\ \B{0}\end{bmatrix}$ are eigenvectors of $\B T$.
%\sitem If $\B{Y}_2$ are eigenvectors of $\B{T}_{22}$, then $\begin{bmatrix} \B{Y}_1 \\ \B{Y}_2\end{bmatrix}$ are eigenvectors of $\B{T}$ where $\B{Y}_1 = \B{T}_{11}^{-1}\B{T}_{12}\B{T}_{22}$.
\end{itemize}

}
\smcond{}
% that correspond to an eigenvalue $\lambda=t_{nn}$:

\end{itemize}

\end{frame}

\section{Rayleigh Quotient}

\begin{frame}{Rayleigh Quotient}

\begin{itemize}
\item For any vector $\B x$, the \coloremph{Rayleigh quotient} provides an estimate for some eigenvalue of $\B A$:
\lgcond{
\[\rho_{\B A}(\B x) = \frac{\B x^H\B A \B x}{\B x^H \B x}.\]
\begin{itemize}
\item If $\B x$ is an eigenvector of $\B A$, then $\rho_{\B A}(\B x)$ is the associated eigenvalue.
\mitem Moreover, for $\B y = \B A \B x$, the Rayleigh quotient is the best possible eigenvalue estimate given $\B x$ and $\B y$, as it is the
solution to %the least squares problem
$\B x \alpha \cong \B y$.
\mitem The normal equations for this scalar-output least squares problem are
\[\B x^T \B x \alpha = \B x^T \B y \quad \Rightarrow\quad \alpha = \frac{\B x^T \B y}{\B x^T \B x} =\frac{\B x^T \B A \B x}{\B x^T \B x}.\]
\end{itemize}
}
\lgcond{}

\end{itemize}
\end{frame}

\section{Conditioning}

\begin{frame}{Perturbation Analysis of Eigenvalue Problems}

\begin{itemize}
\item Suppose we seek eigenvalues $\B D = \B X^{-1} \B A \B X$, but find those of a slightly perturbed matrix $\B D +\B{\delta D} = \B{\hat{X}}^{-1} (\B A + \B{\delta A}) \B{\hat{X}}$:

\lgcond{
Note that the eigenvalues of $\B{X}^{-1} (\B A + \B{\delta A}) \B{X} = \B{D} +\B{X}^{-1} \B{\delta A} \B{X}$ are also $\B{D} +\B{\delta D}$. So if we have perturbation to the matrix $||\B{\delta A}||_F$, its effect on the eigenvalues corresponds to a (non-diagonal/arbitrary) perturbation $\B{\delta{\hat{A}}}=\B{X}^{-1} \B{\delta A} \B{X}$ of a diagonal matrix of eigenvalues $\B D$ , with norm
\[||\B{\delta{\hat{A}}}||_F \leq ||\B{X}^{-1}||_2||\B{\delta A}||_F||\B{X}||_2=\kappa(\B X)||\B{\delta A}||_F.\] }

\vspace*{-.5cm}

\item Gershgorin's theorem allows us to bound the effect of the perturbation on the eigenvalues of a (diagonal) matrix:

{\it  Given a matrix $\boldsymbol{A}\in{\mathbb{R}^{n\times{n}}}$, let $r_{i}=\sum_{j\neq{i}}|a_{ij}|$, define the Gershgorin disks as
$$
    D_{i}=\{z\in{\mathbb{C}} : |z-a_{ii}|\leq{r_{i}} \}.
$$}

\vspace*{-.5cm}

\lgcond{
The eigenvalues $\lambda_1,\ldots,\lambda_n$ of any matrix $\boldsymbol{A}\in{\mathbb{R}^{n\times{n}}}$ are contained in the union of the Gershgorin disks,
    $
        \forall i\in \{1,\ldots, n\}, \lambda_i \in \bigcup_{j=1}^{n}{D_{j}}.
    $
}

% then the perturbed eigenvectors must satisfy
%\[(\B D + \B{\delta A}) \B{\hat{X}} = \B{\hat{X}}( \B{D} + \B{\delta D}) \]
%which for a sufficiently small perturbation implies that
%\[||\B{\delta A}\B{X}|| \approx  ||\B{X} \B{\delta D}||\]
%since $\B{X}=\B{I}$ for $\B{A}=\B{D}$, the above implies $||\B{\delta B}||\approx ||\B{\delta A}||$.
%
%%, so $\B D = \B A$ and $\B X = \B{X}^{-1} = \B I$, so that we have
%%$\B{\hat{X}}=\B{I}+\B{\delta X}$, $\B{\hat{X}}^{-1}\approx \B{I}-\B{\delta X}$, and
%%then we have that
%%
%%Conversely, we see that if a matrix has eigenvalues $\B{D} + \B{\delta D}$
%%
%%More specifically, with $\B{\delta Y} = \B{\hat X} -\B{{X}}$ we can derive
%\begin{align*}
%||\B{\delta D}|| &\approx  ||\B{\delta A}  + \B{\delta X}\B D -  \B D \B {\delta X}|| \\
%&\leq ||\B{\delta A}  + 2\B{\delta D}\B{\delta X}||
%\leq ||\B{\delta A}|| + 2 ||\B{\delta D}||||\B {\delta A}||||\B A|| = O(||\B{\delta A}||)
%\end{align*}
%}
%\lgcond{}

\end{itemize}

\end{frame}

\begin{frame}{Gershgorin Theorem Perturbation Visualization}

{

\centering

\includegraphics[width=3.5in]{diagrams/gershgorin}

}

\begin{itemize}
\item Top corresponds to Gershgorin disks on complex plane of 4-by-4 real matrix.
\item Bottom part corresponds to bounds on Gershgorin disks of $\B{X}^{-1} (\B A + \B{\delta A}) \B{X}$, which contain the eigenvalues $\B D$ of $\B A$ and the perturbed eigenvalues $\B D +\B{\delta D}$ of $\B A + \B{\delta A}$ provided that $||\B{\delta A}||$ is sufficiently small.
\end{itemize}

\end{frame}

%\begin{frame}{Gershgorin Theorem}
%
%\begin{itemize}
%\item Another way to show that the eigenvalues of a matrix are insensitive to perturbation is via Gershgorin theorem, which states that
%
%\lgcond{
% Given a matrix $\boldsymbol{A}\in{\mathbb{R}^{n\times{n}}}$, let $r_{i}=\sum_{j\neq{i}}|a_{ij}|$. We define the Gershgorin disks as
%$$
%    D_{i}=\{z\in{\mathbb{C}} : |z-a_{ii}|\leq{r_{i}} \}.
%$$
%}\lgcond{
%The eigenvalues $\lambda_1,\ldots,\lambda_n$ of any matrix $\boldsymbol{A}\in{\mathbb{R}^{n\times{n}}}$ are contained in the union of the Gershgorin disks,
%    $$
%        \forall i\in \{1,\ldots, n\}, \quad \lambda_i \in \bigcup_{j=1}^{n}{D_{j}}.
%    $$
%}
%\end{itemize}
%
%\end{frame}

\begin{frame}{Conditioning of Particular Eigenpairs}

\begin{itemize}
\item Consider the effect of a matrix perturbation on an eigenvalue $\lambda$ associated with a right eigenvector $\B x$ and a left eigenvector $\B y$, $\lambda = \B y^H \B A \B x / \B y^H \B x$

\lgcond{
For a sufficiently small perturbation $\B{\delta A}$, the eigenvalue $\lambda$ is perturbed to an eigenvalue $\hat{\lambda}$ of $\B{\hat{A}} = \B{A}+\B{\delta A}$.
The eigenvalue perturbation,
\[|\hat{\lambda}-\lambda| =  |\B y^H \B{\delta A} \B x / \B y^H \B x| \leq \frac{||\B{\delta A}||}{|\B y^H\B x|},\]
is small if $\B x$ is near-parallel to $\B y$ and large if they are near-perpendicular.
}

\item A more accurate eigenvalue approximation than Rayleigh quotient
      for a normalized perturbed eigenvector (e.g. iterative guess) $\B{\hat{x}} = \B x+\B{\delta x}$,
      can be obtain with an estimate of both eigenvectors (also  $\B{\hat{y}} = \B y+\B{\delta y}$),
%Connect the notion of the angle between left and right eigenvectors to the magnitude of off-diagonal entries in the Schur form
\lgcond{
\begin{alignat*}{2}
|\hat{\lambda}_\text{xAx} - \lambda| &\approx |\B{\delta x}^H \B{A} \B{x} + \B{x}^H \B{A} \B{\delta x}| &&\leq |\lambda| ||\B{\delta x}|| + \Big(|\lambda| |\B{y}^H\B{x}| + |1-\B{y}^H\B{x}|\cdot ||\B A||\Big)||\B{\delta x}|| \\
|\hat{\lambda}_\text{yAx} - \lambda| &\approx \left|\frac{\B{\delta y}^H \B{A} \B{x} + \B{y}^H \B{A} \B{\delta x}}{\B{y}^H\B{x}}\right| &&\leq |\lambda| \frac{||\B{\delta x}|| + ||\B{\delta y}||}{|\B{y}^H\B{x}|}
\end{alignat*}
}

\end{itemize}

\end{frame}

\section{Basic Iterative Algorithms for Extremal Eigenpairs}

\begin{frame}{Power Iteration}
\urcornerlinkdemo{04-eigenvalues}{Power iteration and its Variants}

\begin{itemize}
\item \coloremph{Power iteration} can be used to compute the largest eigenvalue of a real symmetric matrix $\B A$:
\lgcond{
\[\B x^{(i)} = \B A \B x^{(i-1)} \quad \text{(typically with normalization of $\B x^{(i)}$ at each step)}.\]
For a random $\B x^{(0)}$, power iteration converges eigenvalue of $\B A$ with largest modulus,
\(\lim_{i\to \infty} \rho_{\B A}(\B x^{(i)}) = \lambda_\text{max}(\B A).\)
If this eigenvalue has multiplicity one, power iteration converges to \coloremph{dominant eigenvector}.
}

\item %Consider a real symmetric positive definite (SPD) $\B A$, then
The error of power iteration decreases at each step by the ratio of the largest eigenvalues:

\lgcond{
%$\B A$ is SPD, so its eigenvalues are positive and eigenvectors $\B Q$ are orthonormal,
Assuming $\B A$ is diagonalizable with eigenvectors $\B U$ and $\B V^H = \B U^{-1}$,
\[\B x^{(k)} = \B A^k \B x^{(0)} = (\B U \B D \B V^{H})^k \B x^{(0)} = \B U \B D^k \B V^{H} \B x^{(0)} = \sum_{i=1}^n \B u_i\underbrace{\lambda_i^k \B v_i^H \B x^{(0)}}_{\alpha^{(i,k)}}.\]
The coefficient $\alpha^{(i,k)}$ associated with the maximum $\lambda_i$ and dominant eigenvector $\B u_i$ grows relatively, since $|\alpha^{(i,k)}/\alpha^{(j,k)}| = (|\lambda_{i}|/|\lambda_j|)^k\underbrace{|\alpha^{(i,0)}/\alpha^{(j,0)}|}_{\text{constant}}$.
}

\end{itemize}

\end{frame}

\begin{frame}{Inverse and Rayleigh Quotient Iteration}
\dblurcornerlinkinclass{inclass-eig}{Inverse Iteration with a Shift}{inclass-rayleigh}{Rayleigh Quotient Iteration}

\begin{itemize}
\item \coloremph{Inverse iteration} uses LU/QR/SVD of $\B A$ to run power iteration on $\B A^{-1}$

\lgcond{
\begin{itemize}
\item For a randomly chosen $\B x^{(0)}$, solving
\[\B A \B x^{(i)} = \B x^{(i-1)} \quad \text{(typically with normalization of $\B x^{(i)}$ at each step)}.\]
converges to $\lim_{i\to \infty} \rho_{\B A}(\B x^{(i)})=\lambda_\text{min}(\B A)$ provided there is a unique eigenvalue with minimum magnitude.
\sitem Inverse iteration on $\B A - \sigma \B I$ converges to the eigenvalue closes to $\sigma$, since all eigenvalues are shifted by $\sigma$.
\end{itemize}
}
\item \coloremph{Rayleigh quotient iteration} provides rapid convergence to an eigenpair
\lgcond{
\[(\B A-\rho_{\B A}(\B x^{(i-1)})\B I) \B x^{(i)} = \B x^{(i-1)},\]
since at each step the relative magnitude largest eigenvalue of $(\B A-\rho_{\B A}(\B x^{(i-1)})\B I)^{-1}$ grows.
Formally, it achieves cubic convergence, but requires matrix refactorization at each step.
}
\end{itemize}

\end{frame}

\section{Algorithms for Finding Many Eigenpairs}

\subsection{Deflation}

\begin{frame}{Deflation}

\begin{itemize}
\item Power, inverse, and Rayleigh-quotient iteration compute a single eigenpair, to obtain further eigenpairs, can perform \coloremph{deflation}

\lgcond{
\begin{itemize}
\sitem Given eigenvalue $\lambda_1$ and right eigenvector $\B x_1$, seek $\B v$ so that $\B B = \B A-\lambda_1 \B u \B v^T$ has eigenvalues $\lambda_2,\ldots,\lambda_n$, where
\[\B A = \B X \B D \underbrace{\B Y^T}_{\B X^{-1}} = \sum_{i=1}^n\lambda_i\B x_i\B y_i^T.\]
\sitem Ideal choice would be $\B v = \B y_1^T$, i.e. the left eigenvector associated with $\lambda_1$, as then the $n-1$ other eigenvectors of  $\B B$ would be the same as those of $\B A$.
\sitem For symmetric matrices $\B y_1 =\B x_1$, but for nonsymmetric, obtaining $\B y_1$ may require more work.
\sitem Good alternative choice for nonsymmetric is to select $\B v = \B x_1$, as then the Schur vectors are unmodified, since for $\B A = \B Q \B T \B Q^T$, with $t_{11}=\lambda_1$, $\B q_1= \B x_1$, we get
\[\B B = \B Q \B T \B Q^T -\lambda_1 \B q_1 \B q_1^T= \B Q(\B T - \lambda_1 \B Q^T\B q_1 \B q_1^T \B Q)\B Q^T= \B Q (\B T - \lambda_1 \B e_1\B e_1^T)\B Q^T.\]

\end{itemize}
}
\lgcond{}
\end{itemize}

\end{frame}

%\begin{frame}{Eigenvalues and the Field of Values}
%
%\begin{itemize}
%\item The field of values is the set of possible Rayleigh quotients of matrix $\B A$:
%
%\lgcond{
%\[W(\B A)=\{\rho_{\B A}(\B x) : \B x \in\mathbb{C}^n\}\]
%}
%
%
%\item If and only if the matrix is normal, the field of values is the convex hull of the eigenvalues:
%
%\lgcond{
%For \(\B A = \B X \B D \B X^{-1}\)
%\begin{itemize}
%\item
%all eigenvalues are in the field of values,
%$\forall i, d_{ii} \in W(\B A)$.
%\item if the matrix is normal, \(\B X ^{-1} = \B X^T\),
%\[W(\B A) = \Big\{s : s=\sum_{i=1}^n x_id_{ii}, ||\B{x}||_1\leq 1\Big\}\]
%\end{itemize}
%}
%
%\end{itemize}
%
%\end{frame}

\subsection{Reduction to Hessenberg}

\begin{frame}{Direct Matrix Reductions}
\urcornerlinkdemo{04-eigenvalues}{Householder Similarity Transforms}

\begin{itemize}
\item We can always compute an orthogonal similarity transformation to reduce a general matrix to \coloremph{upper-Hessenberg} (upper-triangular plus the first subdiagonal) matrix $\B H$, i.e. $\B A = \B Q \B H \B Q^T$:

\lgcond{
We can perform successive two-sided application of Householder reflectors
\[\B A =\begin{bmatrix} h_{11} & a_{12} & \cdots \\ a_{21} & a_{22} &  \\ \vdots & &\ddots  \end{bmatrix}  = \textcolor{darkred}{\B{Q}_1} \begin{bmatrix} h_{11} & a_{12} & \cdots \\ \textcolor{darkred}{h_{21}} & \textcolor{darkred}{t_{22}} &  \textcolor{darkred}{\cdots} \\ \textcolor{darkred}{\B{0}} & \textcolor{darkred}{\vdots} &\textcolor{darkred}{\ddots}  \end{bmatrix}  = \B{Q}_1  \begin{bmatrix} h_{11} & \textcolor{darkred}{h_{12}} & \textcolor{darkred}{\cdots} \\ h_{21} & \textcolor{darkred}{h_{22}} &  \textcolor{darkred}{\cdots} \\ \B{0} & \textcolor{darkred}{\vdots} &\textcolor{darkred}{\ddots}  \end{bmatrix}\textcolor{darkred}{\B{Q}_1^T}=\cdots\]
subsequent columns can be reduced by induction, so we can always stably reduce to upper-Hessenberg with roughly the same cost as QR.
}

\item In the symmetric case, Hessenberg form implies tridiagonal:

\lgcond{
If $\B{A}=\B{A}^T$ then $\B{H}=\B{Q}\B{A}\B{Q}^T=\B{H}^T$, and a symmetric upper-Hessenberg matrix must be tridiagonal.
}

\end{itemize}

\end{frame}

\subsection{Orthogonal Iteration}

\begin{frame}[fragile]{Simultaneous and Orthogonal Iteration}
\urcornerlinkdemoinclass{04-eigenvalues}{Orthogonal Iteration}{inclass-orthogonal-iteration}{Orthogonal Iteration}

\begin{itemize}
\item \coloremph{Simultaneous iteration} provides the main idea for computing many eigenvectors at once:

\lgcond{
\begin{itemize}
\sitem Initialize $\B X_0\in \mathbb{R}^{n \times k}$ to be random and perform
\[\B X_{i+1} = \B A \B X_i.\]
\item Observe that $\lim_{i\to \infty} \text{span}(\B X_{i}) = \mathbb{S}$ where $\mathbb{S}$ is the subspace spanned by the $k$ eigenvectors of $\B A$ with the largest eigenvalues in magnitude.
\sitem Can use this to compute the right singular vectors of matrix $\B M$ by using $\B A = \B M^T \B M$ (no need to form $\B A$, just multiply $\B X_i$ by $\B M^T$ then $\B M$).
\sitem Small number of iterations suffice to obtain reasonable low-rank approximation of $\B M$, and ultimately $\B X$ converge to singular vectors in truncated SVD.
\end{itemize}
}

\item Orthogonal iteration performs QR at each step to ensure stability

\vspace*{-.5cm}
\lgcond{
\[\B{Q}_{i+1}\B{R}_{i+1}=\B{A}\B{Q}_{i}\]
\vspace*{-.5cm}
\begin{itemize}
\item $\B{Q}_i$ has the same span as $\B X_{i}$ in orthogonal iteration.
\sitem QR has cost $O(nk^2)$ while product has cost $O(n^2k)$ per iteration.
\end{itemize}
}
\end{itemize}
\end{frame}

\subsection{QR Iteration}

\begin{frame}{QR Iteration}

\begin{itemize}
\item QR iteration reformulates orthogonal iteration for $n=k$ to reduce cost/step,

\lgcond{
\begin{itemize}
\item Orthogonal iteration computes $\B{\textcolor{darkred}{\hat{Q}}}_{i+1}\B{\textcolor{darkred}{\hat{R}}}_{i+1}=\B{A}\B{\textcolor{darkred}{\hat{Q}}}_{i}$
\sitem QR iteration computes $\B{A}_{i+1} =\B{R}_i\B{Q}_i$  at iteration $i$ %$ = \B{\textcolor{darkred}{\hat{Q}}}_{i+1}^T\B A \B{\textcolor{darkred}{\hat{Q}}}_{i+1}$
\end{itemize}

}

\item Using induction, we assume $\B{A}_{i}= \B{\textcolor{darkred}{\hat{Q}}}_{i}^T\B A \B{\textcolor{darkred}{\hat{Q}}}_{i}$ and show that QR iteration obtains $\B{A}_{i+1}= \B{\textcolor{darkred}{\hat{Q}}}_{i+1}^T\B A \B{\textcolor{darkred}{\hat{Q}}}_{i+1}$
\lgcond{
\begin{itemize}
\sitem QR iteration performs QR to obtain $\B{Q}_i\B{R}_i = \B{A}_i$
\sitem Orthogonal iteration performs QR
\[\B{\textcolor{darkred}{\hat{Q}}}_{i+1}
  \B{\textcolor{darkred}{\hat{R}}}_{i+1}
  =\B A \B{\textcolor{darkred}{\hat{Q}}}_{i}
  \underbrace{=}_{\text{inductive assumption}}
   \B{\textcolor{darkred}{\hat{Q}}}_{i}\B A_i
  =\underbrace{\B{\textcolor{darkred}{\hat{Q}}}_{i}\B{Q}_i}_{\B{\textcolor{darkred}{\hat{Q}}}_{i+1}}\underbrace{\B{R}_i}_{\B{\textcolor{darkred}{\hat{R}}}_{i+1}}\]
consequently, we can observe that $\B{R}_i = \underbrace{\B{Q}_i^T \B{\textcolor{darkred}{\hat{Q}}}_{i}^T}_{\B{\textcolor{darkred}{\hat{Q}}}_{i+1}^T} \B A \B{\textcolor{darkred}{\hat{Q}}}_{i}$
%$$ so $ \B{A} = \B{\textcolor{darkred}{\hat{Q}}}_{i+1}\B{\textcolor{darkred}{\hat{R}}}_{i+1}\B{\textcolor{darkred}{\hat{Q}}}_{i}^T$
\sitem QR iteration performs product
$\B{A}_{i+1}=\B R_i \B Q_i = \B{\textcolor{darkred}{\hat{Q}}}_{i+1}^T \B A \B{\textcolor{darkred}{\hat{Q}}}_{i+1}$
%$$ = \B{\textcolor{darkred}{\hat{R}}}_{i+1} \B{\textcolor{darkred}{\hat{Q}}}_{i}^T\B{\textcolor{darkred}{\hat{Q}}}_{i+1} = \B{R}_{i} \B{Q}_{i}$$
\end{itemize}

}
%\item Show that similarity transformations are being performed

\lgcond{}

\end{itemize}

\end{frame}

\begin{frame}{QR Iteration with Shift}
\urcornerlinkinclass{inclass-qr-iteration}{QR Iteration}

\begin{itemize}
\item QR iteration can be accelerated using shifting:
\lgcond{
\begin{align*}
\B{Q}_i\B{R}_i &= \B{A}_i - \sigma_i\B I \\
\B{A}_{i+1} &= \B{R}_i\B{Q}_i + \sigma_i\B I
\end{align*}
note that $\B{A}_{i+1}$ is similar to $\B{A}_i$, since we can reorganize the above as
\begin{align*}
\B{R}_i\B{Q}_i &= \B{Q}_i^T(\B{A}_i - \sigma_i\B I) \B{Q}_i,\\
 \B{Q}_i(\B{A}_{i+1} - \sigma_i\B I)\B Q_i^T &= \B{Q}_i\B{R}_i,
\end{align*}
and observe that $\B{R}_i\B{Q}_i$ is similar to $\B{Q}_i\B{R}_i$.
}

\sitem The shift is typically selected to accelerate convergence with respect to a particular eigenvalue:

\lgcond{
We can select the shift as the bottom right element of $\B{A}_i$, which would be the smallest eigenvalue if $\B{A}_i$ is triangular (we have converged).
Such shifting should accelerate convergence of the last column of $\B{A}_i$, once finished we should operate only on the first $n-1$ columns, and so on.
}

\end{itemize}

\end{frame}

%\begin{frame}{Hessenberg and Tridiagonal Form}
%
%\begin{itemize}
%\item Describe reduction to Hessenberg form
%
%\lgcond{
%QR provides us with a way to reduce a matrix to triangular form by an orthogonal transformation.
%For the eigenvalue problem, we wish to perform similarity transformations, which need to be applied from both sides.
%Note that if simply compute the QR factorization of the first panel of $\B A=[\B{A}_1, \B{A}_2]$, $\B{A}_1=\B{Q}\B{R}$, then $\B{Q}^T \B A\B{Q}$ is still generally dense $\B{Q}^T\B A$ has at least as many zeros as in $\B{R}$.
%However, we can use QR factorization to introduce zeros by similarity transformation via
%\[\begin{bmatrix} \B{A}_{11} & \B{A}_{12} \\ \B{A}_{21} & \B{A}_{22} \end{bmatrix} = \begin{bmatrix} \B{A}_{11} & \B{A}_{12} \\ \B{Q}\B{R} & \B{A}_{22} \end{bmatrix} =\begin{bmatrix} \B I & \\ & \B{Q} \end{bmatrix}\begin{bmatrix} \B{A}_{11} & \B{A}_{12}\B{Q} \\ \B{R} & \B{Q}^T\B{A}_{22}\B{Q} \end{bmatrix}\begin{bmatrix} \B I & \\ & \B{Q}^T\end{bmatrix}\]
%if we pick $\B{A}_{11}$ to be $1\times 1$ then doing this for each panel will yield an upper-Hessenberg result.
%}
%
%\item Describe reduction to tridiagonal form in symmetric case
%
%\lgcond{
%In the symmetric case $\B{A}_{12}\B{Q}=\B{A}_{21}^T\B{Q}=(\B{Q}^T\B{A}_{21})^T=\B{R}^T$, so we reduce to a banded (tridiagonal if $\B{A}_{11}$ is $1\times 1$) matrix.
%}
%
%\end{itemize}
%
%\end{frame}

\begin{frame}{QR Iteration Complexity}

\begin{itemize}
\item  QR iteration is accelerated by first reducing to upper-Hessenberg or tridiagonal form:

\lgcond{
Reduction to upper-Hessenberg or tridiagonal in the symmetric case, costs $O(n^3)$ operations and can be done in a similar style to Householder QR. \\
\ \\
Given an upper-Hessenberg matrix, $\B H_i=\B A_i$
\begin{itemize}
\item reduction to upper-triangular requires $n-1$ Givens rotations, if $\B G_i$ rotates the $(i+1)$th row into the $i$th to eliminate the $i$th element on the first subdiagonal,
  \(\B R_i = \B G_{1}^T\cdots \B G_{n-1}^T\B H_i\)
\mitem computation of $\B H_{i+1} = \B R \B Q$ can be done by application of the $n-1$ Givens rotations to $\B R$ from the right $\B H_{i+1} = \B R_i \B G_{n-1}\cdots \B G_{1}$.
\end{itemize}
Both cost $O(n^2)$, for $O(n^3)$ overall if QR iteration converges in $O(n)$ steps.
}

\lgcond{
Given a tridiagonal matrix, the same two general steps are required, but now each step costs $O(n)$, so overall the eigenvalues and eigenvectors of a tridiagonal matrix can be computed with $O(n^2)$ work.
}

\end{itemize}

\end{frame}

%\begin{frame}{Solving Hessenberg Nonsymmetric Eigenproblems}
%
%\begin{itemize}
%\item Eigenvalues of a Hessenberg matrix are usually computed by QR iteration:
%
%\lgcond{
%Using $\B{A}_0=\B{H}$, with a shift of $\sigma_i$ at iteration $i$ QR iteration is
%\begin{align*}
%\B{Q}_i\B{R}_i &= \B{A}_i - \sigma_i\B I \\
%\B{A}_{i+1} &= \B{R}_i\B{Q}_i + \sigma_i\B I
%\end{align*}
%
%}
%
%\item Good convergence guarantees given by Francis (Wilkinson) shift:
%
%\lgcond{
%To handle complex eigenvalues, diagonalize the bottom-right 2-by-2 block of $\B{A}_{i}$ and use the eigenvalues $\sigma_i,\bar{\sigma}_i$ as the next two shifts (also possible to reorganize and do a double-step with two shifts).
%
%}
%
%\end{itemize}
%
%\end{frame}

\section{Tridiagonal Eigenproblems}

\begin{frame}{Solving Tridiagonal Symmetric Eigenproblems}

A variety of methods exists for the tridiagonal eigenproblem:
\begin{itemize}
\item QR iteration \smcond{requires $O(1)$ QR factorizations per eigenvalue, $O(n^2)$ cost to get eigenvalues, $O(n^3)$ for eigenvectors. The last cost is not optimal.}

\item Divide and conquer
\lgcond{}
\lgcond{reduces tridiagonal $\B{T}$ by a similarity transformation to a rank-1 perturbation of identity, then computes its eigenvalues using roots of secular equation
\begin{align*}
\B{T} &= \begin{bmatrix} \B{T}_1 & t_{n/2+1,n/2}\B{e}_{n/2}\B{e}^T_{1} \\ t_{n/2+1,n/2}\B{e}_{1} \B{e}_{n/2}^T& \B{T}_2 \end{bmatrix} \\
&= \begin{bmatrix} \B{\hat{T}}_1 &  \\ & \B{\hat{T}}_2 \end{bmatrix} + t_{n/2+1,n/2}\begin{bmatrix} \B{e}_{n/2} \\ \B{e}_{1} \end{bmatrix} \begin{bmatrix} \B{e}_{n/2}^T & \B{e}_{1}^T \end{bmatrix}
= \begin{bmatrix} \B{Q}_1\B{D}_1\B{Q}_1^T &  \\ & \B{Q}_2\B{D}_2\B{Q}_2^T \end{bmatrix} + \ldots \\
&=\begin{bmatrix} \B{Q}_1 & \\ & \B{Q}_2\end{bmatrix} \bigg(\underbrace{\begin{bmatrix} \B{D}_1 &  \\ & \B{D}_2 \end{bmatrix}
+ t_{n/2+1,n/2}\begin{bmatrix} \B{Q}_{1}^T\B{e}_{n/2} \\ \B{Q}_2^T\B{e}_{1} \end{bmatrix} \begin{bmatrix} \B{e}_{n/2}^T\B{Q}_1 & \B{e}_{1}^T\B{Q}_2 \end{bmatrix}}_{\B{D}+\alpha \B{u}\B{u}^T}\bigg)\begin{bmatrix} \B{Q}_1^T & \\ & \B{Q}_2^T\end{bmatrix}
\end{align*}
}

\end{itemize}

\end{frame}

\begin{frame}[fragile]{Solving the Secular Equation for Divide and Conquer}

To solve the eigenproblem at each step, the divide and conquer method needs to diagonalize a rank-1 perturbation of a diagonal matrix
\[\B{A} = \B{D} + \alpha \B{u}\B{u}^T.\]
\lgcond{
\begin{itemize}
\item The zeros of the characteristic polynomial define the eigenvalues,
\[f(\lambda) =\text{det}(\B D + \alpha \B u \B u^T- \lambda \B I )=1+\alpha\B u^T (\B D - \lambda \B I)^{-1}\B u=1+\alpha\sum_{i=1}^n\frac{u_i^2}{d_{ii}-\lambda}=0.\]
\item This nonlinear equation can be solved efficiently by a variant of Newton's method (covered in the next chapter)
      that uses hyperbolic rather than linear extrapolations at each step.
\sitem Major alternatives to divide and conquer include spectral bisection and the MRRR algorithm.
\end{itemize}
}
\lgcond{}
\end{frame}

%\begin{frame}{Solving Tridiagonal Symmetric Eigenproblems (II)}
%
%\begin{itemize}
%\item Jacobi iteration
%\mdcond{uses two-sided Givens rotations, to introduce zeros, typically by eliminating the largest value in magnitude, requires $O(1)$ sweeps over all nonzeros, $O(n^2)$ cost to get eigenvalues, $O(n^3)$ to get eigenvectors.}
%
%\item Bisection
%\lgcond{finds a partition point using $\B L\B D\B L^T$ factorization or Sturm sequence to compute inertia (\#positive eigenvalues, \#negatives eigenvalues, \#zero eigenvalues). Sylvester's inertia theorem shows that inertia is preserved under any transformation $\B A = \B S \B B \B S^T$ where $\B S$ is an invertible matrix.
%Consequently, the diagonal $\B D$ matrix in the $\B L \B D \B L^T$ factorization has the same inertia as $\B A$.
%Computing this factorization with various shifts enables successive halving of the approximation interval.
%}
%
%\item Relatively robust representation (RRR and MRRR)
%\mdcond{leverages stability of values in $\B L\B D\B L^T$ and other techniques to compute all eigenvectors and eigenvalues in $O(n^2)$ cost.
%These factorized forms minimize sensitivity to round-off error.}
%
%\end{itemize}
%
%\end{frame}

\section{Krylov Subspace Methods}

\subsection{Krylov Subspaces}

\begin{frame}{Introduction to Krylov Subspace Methods}

\begin{itemize}
\item \coloremph{Krylov subspace methods} work with information contained in the $n\times k$ matrix
\[\B{K}_k=\begin{bmatrix} \B{x_0} & \B A\B{x_0} & \cdots & \B A^{k-1}\B{x_0}\end{bmatrix}\]

\mdcond{
We seek to best use the information from the matrix vector product results (columns of $\B{K}_k$) to solve eigenvalue problems.
}

\item The matrix $\B{K}_n^{-1}\B{A}\B{K}_n$ is a \coloremph{companion matrix} $\B C$:

\mdcond{
Letting $\B{k}^{(i)}_n = \B{A}^{i-1}\B{x}$, we observe that
%$\B{K}_n=\begin{bmatrix} \B{k}^{(1)}_n & \cdots & \B{k}^{(n)}_n\end{bmatrix}$ observe that
\[\B{A}\B{K}_n= \begin{bmatrix} \B A \B{k}^{(1)}_n & \cdots & \B A \B{k}^{(n-1)}_n& \B A \B{k}^{(n)}_n\end{bmatrix}= \begin{bmatrix} \B{k}^{(2)}_n & \cdots & \B{k}^{(n)}_n & \B{A}\B{k}^{(n)}_n\end{bmatrix},\]
therefore premultiplying by $\B{K}_m^{-1}$ transforms the first $n-1$ columns of $\B{A}\B{K}_n$ into the last $n-1$ columns of $\B{I}$,
\begin{align*}
\B{K}_n^{-1}\B{A}\B{K}_n&= \begin{bmatrix} \B{K}_n^{-1}\B{k}^{(2)}_n & \cdots & \B{K}_n^{-1}\B{k}^{(n)}_n & \B{K}_n^{-1}\B{A}\B{k}^{(n)}_n\end{bmatrix} \\
&=\begin{bmatrix} \B{e}_2 & \cdots & \B{e}_n & \B{K}_n^{-1}\B{A}\B{k}^{(n)}_n\end{bmatrix}
\end{align*}
}
\lgcond{}

\end{itemize}

\end{frame}

\begin{frame}{Krylov Subspaces}

\begin{itemize}
\item Given $\B Q_k \B R_k = \B{K}_k$, we obtain an orthonormal basis for the Krylov subspace,

\[\mathcal{K}_k(\B A, \B x_0)=\mathop{span}(\B Q_k)= \{p(\B A)\B{x}_0 : \mathop{deg}(p) < k\},\]
where $p$ is any polynomial of degree less than $k$.

\sitem The Krylov subspace includes the $k-1$ approximate dominant eigenvectors generated by $k-1$ steps of power iteration:

\lgcond{
\begin{itemize}
\item The approximation obtained from $k-1$ steps of power iteration starting from $\B{x}_0$ is given by the Rayleigh-quotient of $\B{y}=\B{A}^k\B{x}_0$.
\sitem This vector is within the Krylov subspace, $\B{y}\in\mathcal{K}_k(\B A, \B x_0)$.
\sitem Consequently, Krylov subspace methods will generally obtain strictly better approximations of the dominant eigenpair than power iteration.
\end{itemize}
}
\lgcond{}

\end{itemize}

\end{frame}

\subsection{Ritz Values and Vectors}

\begin{frame}{Krylov Subspace Methods}

\begin{itemize}
\item The $k\times k$ matrix $\B H_k = \B Q_k^T\B A \B Q_k$ minimizes $||\B A \B Q_k - \B Q_k \B H_k||_2$:

\lgcond{
The minimizer $\B X$ for the linear least squares problem $\B{Q}_k\B{X} \cong \B{A}\B{Q}_k$ is (via the normal equations) $\B{X}=\B{Q}_k^T\B{A}\B{Q}_k=\B{H}_k$.

}

\item $\B H_k$ is Hessenberg, because the companion matrix $\B C_k$ is Hessenberg:

\lgcond{
\[\B H_k = \B Q_k^T\B A \B Q_k = \B{R}_k\B{K}_k^{-1} \B{A} \B{K}_k \B{R}_k^{-1} =  \B{R}_k\B{C}_k \B{R}_k^{-1}\]
is a product of three matrices: upper-triangular $\B R_k$, upper-Hessenberg $\B C_k$ , and upper-triangular $\B R^{-1}_k$, which results in upper-Hessenberg $\B H_k$.
}

\end{itemize}

\end{frame}

\begin{frame}{Rayleigh-Ritz Procedure}

\urcornerlinkdemoinclass{04-eigenvalues}{Arnoldi vs Power Iteration}{inclass-ritz}{Computing the Maximum Ritz Value}

\begin{itemize}
\item The eigenvalues/eigenvectors of $\B{H}_k$ are the \coloremph{Ritz values/vectors}:

\mdcond{
\[\B{H}_k=\B{X}\B{D}\B{X}^{-1}\]
eigenvalue approximations based on Ritz vectors $\B{X}$ are given by $\B{Q}_k\B{X}$.
}

\item The Ritz vectors and values are the \coloremph{ideal approximations} of the actual eigenvalues and eigenvectors based on only $\B{H}_k$ and $\B{Q}_k$:

\lgcond{
Assuming $\B A$ is a symmetric matrix with positive eigenvalues, the largest Ritz value $\lambda_\text{max}(\B H_k)$ will be the maximum Rayleigh quotient of any vector in $\mathcal{K}_k=\mathop{span}(\B{Q}_k)$,
\[\max_{\B x\in \mathop{span}(\B{Q}_k)}\frac{\B{x}^T\B A \B x}{\B x^T \B x} = \max_{\B y\neq 0}\frac{\B{y}^T\B{Q}_k^T\B A \B{Q}_k \B y}{\B y^T \B y} =\max_{\B y\neq 0}\frac{\B{y}^T\B{H}_k \B y}{\B y^T \B y}=\lambda_\text{max}(\B H_k),\]
which is the best approximation to $\lambda_\text{max}(\B A) = \max_{\B x\neq 0}\frac{\B{x}^T\B{A} \B x}{\B x^T \B x}$ available in $\mathcal{K}_k$.
The quality of the approximation can also be shown to be optimal for other eigenvalues/eigenvectors.
}

\end{itemize}

\end{frame}

\subsection{Arnoldi Algorithm}

\begin{frame}{Arnoldi Iteration}

\dblurcornerlinkdemo{04-eigenvalues}{Arnoldi Iteration}{04-eigenvalues}{Arnoldi Iteration with Complex Eigenvalues}
\begin{itemize}
\item Arnoldi iteration computes $\B{H}=\B{H}_n$ directly using the recurrence $\B{q}^T_i\B{A}\B{q}_j=h_{ij}$, where $\B q_l$ is the $l$th column of $\B Q_n$:

\lgcond{
We have that
\[\B{q}^T_i\B{A}\B{q}_j=\B{q}^T_i(\B{Q}_n\B{H}_n\B{Q}_n^T)\B{q}_j = \B{e}_i^T\B{H}_n\B{e}_j=h_{ij}.\]
}

\item After each matrix-vector product, orthogonalization is done with respect to each previous vector:

\lgcond{
Given $\B{u}_j=\B{A}\B{q}_j$, compute $h_{ij}=\B{q}_i^T\B{u}_j$ for each $i\leq j$, forming a column of the $\B H$ matrix at a time.
}

\end{itemize}

\end{frame}

\subsection{Lanczos Algorithm}

\begin{frame}{Lanczos Iteration}

\urcornerlinkinclass{inclass-eig-methods-for-low-rank}{Approximation with Orthogonal Iteration and Lanczos}

\begin{itemize}
\item Lanczos iteration provides a method to reduce a symmetric matrix to a tridiagonal matrix:

\lgcond{
Arnoldi iteration on a symmetric matrix will result in an upper-Hessenberg matrix $\B H_n$ as before, except that it must also be symmetric, since
\[\B{H}_n^T=(\B{Q}_n^T\B{A}\B{Q}_n)^T = \B{Q}_n^T\B{A}^T\B{Q}_n=\B{Q}_n^T\B{A}\B{Q}_n=\B{H}_n,\]
which implies that $\B{H}_n$ must be tridiagonal.
}

\item After each matrix-vector product, it suffices to orthogonalize with respect to two previous vectors:

\lgcond{
Since $h_{ij}=0$ if $|i-j|>1$, given $\B{u}_j=\B{A}\B{q}_j$, it suffices to compute only $h_{jj}=\B{q}_j^T\B{u}_j$ and $h_{j-1,j}=h_{j,j-1}=\B{q}_{j-1}^T\B{u}_j$.
}

\end{itemize}

\end{frame}

\subsection{Computational Cost}

\begin{frame}{Cost Krylov Subspace Methods}

\begin{itemize}
\item The cost of matrix-vector multiplication when the matrix has $m$ nonzeros
\lgcond{
is $m$ multiplications and at most $m$ additions, so roughly $2m$ in total.
}

\item The cost of orthogonalization at the $k$th iteration of a Krylov subspace method is
\lgcond{
\begin{itemize}
\sitem $O(nk)$ for $k$ inner products in Arnoldi,
\sitem $O(n)$ in Lanczos, since only 2 orthogonalizations needed.
\sitem For Arnoldi with $k$-dimensional subspace, orthogonalization costs $O(nk^2)$, matrix-vector products cost $O(mk)$, so generally desire $nk<m$.
\end{itemize}
}

\end{itemize}

\end{frame}

\subsection{Restarting}

\begin{frame}{Restarting Krylov Subspace Methods}

\begin{itemize}
\item In finite precision, Lanczos generally loses orthogonality, while orthogonalization in Arnoldi can become prohibitively expensive:

\lgcond{
\begin{itemize}
\item Arnoldi cost of orthogonalization dominates if $k>m/n$.
\item In Lanczos, reorthogonalizing iterate to previous guesses can ensure orthogonality.
\item Selective orthogonalization strategies control when and with respect to what previous columns of $\B{Q}$, each new iterate $\B{u}_j=\B{A}\B{q}_j$ should be orthogonalized.
\end{itemize}

}

\item Consequently, in practice, low-dimensional Krylov subspace methods are constructed repeatedly using carefully selected new starting vectors:

\lgcond{
If we wish to find a particular eigenvector isolate some eigenspaces, restarting is beneficial
\begin{itemize}
\item can orthogonalize to previous eigenvector estimates to perform deflation,
\item can pick starting vector as Ritz vector estimate associated with desired eigenpair,
\item given new starting vector, can discard previous Krylov subspace, which helps make storing the needed parts of $\B{Q}$ possible.
\end{itemize}
}

\end{itemize}

\end{frame}
%
%\begin{frame}{Convergence of Lanczos Iteration}
%
%\begin{itemize}
%
%\item Cauchy interlacing theorem: eigenvalues of $\B{H}_k$, $\tilde{\lambda}_1\geq \cdots \geq \tilde{\lambda}_n$ with respect to eigenvalues of $\B{A}$, $\lambda_1 \geq \cdots \geq \lambda_n$ satisfy
%\[\lambda_i \leq \tilde{\lambda_i} \leq \lambda_{n-k+i}\]
%
%\lgcond{}
%
%\item Convergence to extremal eigenvalues is generally fastest
%
%\lgcond{}
%
%\end{itemize}
%
%\end{frame}

%\begin{frame}{Applications of Eigenvalue Problems: Matrix Functions}
%
%
%\begin{itemize}
%\item Given $\B{A} = \B{X} \B{D}\B{X}^{-1}$ how can we compute $\B{A}^k$?
%\lgcond{
%\begin{align*}
%\B{A}^2 &= \B{X} \B{D}\B{X}^{-1}\B{X} \B{D}\B{X}^{-1} \\
%        &= \B{X} \B{D}^2\B{X}^{-1}, \\
%\B{A}^k &= \B{X} \B{D}^k\B{X}^{-1}
%\end{align*}
%}
%\item What about $e^{\B{A}}$ ?
%     $\log(\B{A})$? generally $f(\B{A})$?
%\lgcond{
%\begin{align*}
%e^{\B{A}} &= \B I + \B A + \B A / 2! + \cdots \\
%          &= \B X ( \B I + \B D + \B D^2/2! +\cdots ) \B X^{-1} \\
%          &= \B X e^{\B D} \B X^{-1} \\
%\log (\B A) &= \B X \log (\B D) \B X^{-1} \\
%f(\B A) &= \B X f(\B D) \B X^{-1}
%\end{align*}
%}
%
%\end{itemize}
%
%
%\end{frame}
%
%\begin{frame}{Applications of Eigenvalue Problems: Differential Equations}
%
%
%\begin{itemize}
%\item Consider solutions to an ordinary differential equation of the form $\B{\frac{dx}{dt}}(t) = \B{A}\B{x}(t) +\B{f}(t)$ with $\B{x}(0)=\B{x_0}$:
%
%$$\B x(t) = e^{t\B{A}}\B{x}_0 + \int_0^t e^{(t-\tau)\B{A}}\B{f}(\tau) d\tau$$
%
%\lgcond{}
%
%\item Using $\B{A}=\B{X}\B{D}\B{X}^{-1}$ permits us to compute the solution explicitly (Jordan form also suffices if $\B{A}$ is defective):
%
%\lgcond{
%$$\B x(t) = \B X e^{t\B{D}}\B{X}^{-1}\B{x}_0 + \B{X}\int_0^t e^{(t-\tau)\B{D}}\B{X}^{-1}\B{f}(\tau) d\tau$$
%}
%
%
%\end{itemize}
%
%
%\end{frame}
%
%\begin{frame}{Differential Equations using the Generalized Eigenvalue Problem}
%
%
%\begin{itemize}
%\item Consider a more general linear differential equation of the form $\B{B}\B{\frac{dx}{dt}}(t) = \B{A}\B{x}(t) +\B{f}(t)$ with $\B{x}(0)=\B{x_0}$, which we can reduce to the usual form by premultiplying with $\B{B}^{-1}$:
%% ($\B A$ can represent stiffness matrix and $\B B$ mass matrix):
%\lgcond{
%\[\B{\frac{dx}{dt}}(t) = \B{B}^{-1}\B{A}\B{x}(t) +\B{B}^{-1}\B{f}(t)\]
%However, $\B B $ may not be invertible and $\B{B}^{-1}\B{A}$ is generally nonsymmetric even when $\B B^{-1}$ and $\B A$ are.
%}
%
%\item If we can find $\B{X}$ such that $\B{A}=\B{X}\B{D_A}\B{X}^{-1}$  and $\B{B} = \B{X}\B{D_B}\B{X}^{-1}$ we could solve this equation while preserving symmetry of $\B{A}$ and $\B{B}$:
%\lgcond{
%\begin{align*}
%\B x(t) &= e^{t\B{B}^{-1}\B{A}}\B{x}_0 + \int_0^t e^{(t-\tau)\B{B}^{-1}\B{A}}\B{f}(\tau) d\tau \\
% &= e^{t\B{X}\B{D_B}^{-1}\B{D_A}\B{X}^{-1}}\B{x}_0 + \int_0^t e^{(t-\tau)\B{X}\B{D_B}^{-1}\B{D_A}\B{X}^{-1}}\B{f}(\tau) d\tau \\
%&= \B{X}e^{t\B{D_B}^{-1}\B{D_A}}\B{X}^{-1}\B{x}_0 + \B{X} \int_0^t e^{(t-\tau)\B{D_B}^{-1}\B{D_A}}\B{X}^{-1}\B{f}(\tau) d\tau
%%\B{X}\B{D_B}\B{X}^{-1}\B{\frac{dx}{dt}}(t) &= \B{X}\B{D_A}\B{X}^{-1}\B{x}(t) +\B{f}(t) \\
%%\B{D_B}\B{D_A}^{-1}\B{y} \B{\frac{dy}{dt}}(t) &= \B{y}(t) +\B{X}^{-1}\B{f}(t), \quad \B y(t) = \B{D_A}\B{X}^{-1}\B{x}(t)
%\end{align*}
%
%}
%
%
%\end{itemize}
%
%
%\end{frame}

\section{Generalized Eigenvalue Problems}

\begin{frame}{Generalized Eigenvalue Problem}

\begin{itemize}
\item
A generalized eigenvalue problem has the form $\B A \B x = \lambda \B B \B x$,
\lgcond{
\begin{align*}
\B A \B X &= \B B \B X \B D \\
\B B^{-1} \B A &=  \B X \B D \B X^{-1}
\end{align*}
Generalized eigenvalue problems arise frequently, especially in solving partial differential equations.
}
\item
When $\B A$ and $\B B$ are symmetric and $\B B$ is SPD, we can perform Cholesky on $\B{B}$, multiply $\B{A}$ by the inverted factors, and diagonalize it:
\lgcond{
\begin{align*}
\B A \B X &= \B L \B L^T \B X \B D \\
\underbrace{\B L^{-1} \B A  \B L^{-T}}_{\B{\tilde{A}}} \underbrace{\B L^T \B X}_{\B{\tilde{X}}} &= \underbrace{\B L^T \B X}_{\B{\tilde{X}}} \B D
\end{align*}

}
\item Alternative canonical forms and methods exist that are specialized to the generalized eigenproblem.

\end{itemize}

\end{frame}

%\begin{frame}{Canonical Forms Generalized Eigenvalue Problem}
%
%
%\begin{itemize}
%\item For nonsingular $\B U, \B V$, $\B A - \lambda \B B= \B U (\B J -\lambda \B I)\B V^T$ where $\B J$ is in Jordan form
%
%\lgcond{}
%
%\item For some unitary $\B P, \B Q$, $\B A=\B P\B{T_A} \B Q^H $ and $\B B=\B P\B{T_B}\B Q^H$ where $\B{T_A}$ and $\B{T_B}$ are triangular
%
%\lgcond{}
%
%\end{itemize}
%
%
%\end{frame}
%
%
%\begin{frame}{Nonlinear Eigenvalue Problem}
%
%\begin{itemize}
%
%\item In a polynomial eigenvalue problem, we seek solutions $\lambda,\B{x}$ to
%\[\sum_{i=0}^d \lambda^i\B{A}_i\B{x} = \B 0\]
%
%\lgcond{}
%
%\item Assuming for simplicity that $\B{A}_d=\B{I}$, solutions are given by solving the matrix eigenvalue problem with the block-companion matrix
%\[\begin{bmatrix}
%  -\B{A}_{d-1}  & \cdots & -\B{A}_{0} \\
%  \B{I} &\B{0} & \cdots \\
%   &\ddots & \ddots \end{bmatrix}\]
%
%
%\end{itemize}
%
%\end{frame}

%\begin{frame}{Generalized Eigenvalue Problem}
%
%\begin{itemize}
%\item Suppose we seek eigenvalues $\B D = \B X^{-1} \B A \B X$, but find those of a slightly perturbed matrix $\B D +\B{\delta D} = \B{\hat{X}}^{-1} (\B A + \B{\delta A}) \B{\hat{X}}$:
%
%
%\lgcond{
%Note that the eigenvalues of $\B{X}^{-1} (\B A + \B{\delta A}) \B{X} = \B{D} +\B{X}^{-1} \B{\delta A} \B{X}$ are also $\B{D} +\B{\delta D}$. So if we have perturbation to the matrix $||\B{\delta A}||_F$, its effect on the eigenvalues corresponds to a (non-diagonal/arbitrary) perturbation of a diagonal matrix of eigenvalues, with norm
%\[||\B{X}^{-1}||_2||\B{\delta A}||_F||\B{X}||_2=\kappa(\B X)||\B{\delta A}||_F.\] }
%\item Thus it generally suffices to consider the effect of a (possibly larger) perturbation $\B{\delta{\hat{A}}}$ to a diagonal matrix:
%\lgcond{
% Given a matrix $\boldsymbol{A}\in{\mathbb{R}^{n\times{n}}}$, let $r_{i}=\sum_{j\neq{i}}|a_{ij}|$. We define the Gershgorin disks as
%$$
%    D_{i}=\{z\in{\mathbb{C}} : |z-a_{ii}|\leq{r_{i}} \}.
%$$
%}\lgcond{
%The eigenvalues $\lambda_1,\ldots,\lambda_n$ of any matrix $\boldsymbol{A}\in{\mathbb{R}^{n\times{n}}}$ are contained in the union of the Gershgorin disks,
%    $
%        \forall i\in \{1,\ldots, n\}, \lambda_i \in \bigcup_{j=1}^{n}{D_{j}}.
%    $
%}
%
%% then the perturbed eigenvectors must satisfy
%%\[(\B D + \B{\delta A}) \B{\hat{X}} = \B{\hat{X}}( \B{D} + \B{\delta D}) \]
%%which for a sufficiently small perturbation implies that
%%\[||\B{\delta A}\B{X}|| \approx  ||\B{X} \B{\delta D}||\]
%%since $\B{X}=\B{I}$ for $\B{A}=\B{D}$, the above implies $||\B{\delta B}||\approx ||\B{\delta A}||$.
%%
%%%, so $\B D = \B A$ and $\B X = \B{X}^{-1} = \B I$, so that we have
%%%$\B{\hat{X}}=\B{I}+\B{\delta X}$, $\B{\hat{X}}^{-1}\approx \B{I}-\B{\delta X}$, and
%%%then we have that
%%%
%%%Conversely, we see that if a matrix has eigenvalues $\B{D} + \B{\delta D}$
%%%
%%%More specifically, with $\B{\delta Y} = \B{\hat X} -\B{{X}}$ we can derive
%%\begin{align*}
%%||\B{\delta D}|| &\approx  ||\B{\delta A}  + \B{\delta X}\B D -  \B D \B {\delta X}|| \\
%%&\leq ||\B{\delta A}  + 2\B{\delta D}\B{\delta X}||
%%\leq ||\B{\delta A}|| + 2 ||\B{\delta D}||||\B {\delta A}||||\B A|| = O(||\B{\delta A}||)
%%\end{align*}
%%}
%%\lgcond{}
%
%\end{itemize}
%
%\end{frame}

%\end{document}