\documentclass{article}
\input{../macros.tex}

\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section*{Lecture 24: Markov matrices; Fourier series}

In this lecture we look at Markov matrices and Fourier series -- two applications of eigenvalues and
projections.

\subsection*{Eigenvalues of $\mb A^T$}

The eigenvalues of $\mb A$ and the eigenvalues of $\mb A^T$ are the
same:  $$(A - \lambda \mb I)^T = A^T - \lambda \mb I,$$ so property 10
of determinants tells us that $\det (\mb A - \lambda \mb I) = \det
(\mb A^T - \lambda \mb I)$.  If $\lambda$ is an eigenvalue of $\mb A$
then $\det (\mb A^T - \lambda \mb I) = 0$ and $\lambda$ is also an
eigenvalue of $\mb A^T$.

\subsection*{Markov matrices}

A matrix like:
$$\mb A = \threebythree {.1}{.01}{.3}{.2}{.99}{.3}{.7}0{.4}$$ in which
all entries are non-negative and each column adds to $1$ is
called a {\em Markov matrix}.  These requirements come from Markov
matrices' use in probability.  Squaring or raising a Markov matrix to
a power gives us another Markov matrix.

\smallskip

When dealing with systems of differential equations, eigenvectors with the eigenvalue
$0$ represented steady states.  Here we're dealing with powers of
matrices and get a steady state when $\lambda = 1$ is an eigenvalue.

The constraint that the columns add to $1$ guarantees that $1$ is an
eigenvalue.  All other eigenvalues will be less than $1$.  Remember
that (if $\mb A$ has $n$ independent eigenvectors) the solution to
$\vb u_k = \mb A^k \vb u_0$ is $\vb u_k = c_1 \lambda_1^k \vb x_1 + c_2
\lambda_2^k \vb x_2 + \cdots + c_n \lambda_n^k \vb x_n$.  If $\lambda_1 = 1$
and all others eigenvalues are less than one the system approaches the
steady state $c_1 \vb x_1$.  This is the $\vb x_1$ component of $\vb
u_0$.

Why does the fact that the columns sum to $1$ guarantee that $1$ is an eigenvalue?  If $1$ is an eigenvalue of $\mb A$, then:
$$\mb A - 1\mb I = \threebythree
{-.9}{.01}{.3}{.2}{-.01}{.3}{.7}0{-.6}$$ should be singular.  Since
we've subtracted $1$ from each diagonal entry, the sum of the entries
in each column of $\mb A - \mb I$ is zero.  But then the sum of the
rows of $\mb A - \mb I$ must be the zero row, and so $\mb A - \mb I$
is singular.  The eigenvector $\vb x_1$ is in the nullspace of $\mb A -
\mb I$ and has eigenvalue $1$.  It's not very hard to find $\vb x_1 =
\small \threebyone {.6}{33}{.7}$.

\smallskip

We're studying the equation $\vb u_{k+1} = \mb A \vb u_k$ where $\mb A$ is
a Markov matrix.  For example $u_1$ might be the population of (number
of people in) Massachusetts and $u_2$ might be the population of
California.  $\mb A$ might describe what fraction of the population
moves from state to state, or the probability of a single person
moving.  We can't have negative numbers of people, so the entries of
$\mb A$ will always be positive. We want to account for all the people
in our model, so the columns of $\mb A$ add to $1 = 100\%$.

For example:
$$\twobyonec {u_\text{Cal}}{u_\text{Mass}}_{t=k+1} =
\twobytwo {.9}{.2}{.1}{.8}
\twobyonec {u_\text{Cal}}{u_\text{Mass}}_{t=k}
$$ assumes that there's a 90\% chance that a person in California
will stay in California and only a 10\% chance that she or he will
move, while there's a 20\% percent chance that a Massachusetts
resident will move to California.  If our initial conditions are $\small \twobyonec
{u_{\text{Cal}}} {u_{\text{Mass}}}_0 = \small \twobyonec 0{1000}$, then after one move $\vb u_1 = \mb A \vb u_0$ is:
$$\twobyonec {u_{\text{Cal}}} {u_{\text{Mass}}} _1 
= \twobytwo {.9}{.2}{.1}{.8} 
\twobyonec 0{1000} = 
\twobyone {200}{800}.
$$ For the next few values of $k$, the Massachusetts population will decrease and the
California population will increase while the total population remains constant at 1000.  

To understand the long term behavior of this system we'll need the
eigenvectors and eigenvalues of $\small \twobytwo {.9}{.2}{.1}{.8}$.
We know that one eigenvalue is $\lambda_1 = 1$. Because the trace $.9+.8=1.7$
is the sum of the eigenvalues, we see that $\lambda_2 = .7$.

Next we calculate the eigenvectors:
$$\mb A - \lambda_1 \mb I = \twobytwo {-.1}{.2}{.1}{-.2}\vb x_1 = \vb
0,$$ so we choose $\vb x_1 = \twobyone 21$.  The eigenvalue $1$
corresponds to the steady state solution, and $\lambda_2 = .7 < 1$, so
the system approaches a limit in which $2/3$ of 1000 people live in
California and $1/3$ of 1000 people are in Massachusetts.  This will
be the limit from any starting vector $\vb u_0$.

To know how the population is distributed after a finite number of
steps we look for an eigenvector corresponding to $\lambda_2 = .7$:
$$\mb A - \lambda_2 \mb I = \twobytwo {.2}{.2}{.1}{.1}\vb x_1 = \vb 0,$$ so let $\vb x_2 = \small \twobyone 1{-1}$.

From what we learned about difference equations we know that:
$$\vb u_k = c_1 1^k \twobyone 21 + c_2 (.7)^k \twobyone{-1}1.$$
When $k=0$ we have:
$$\vb u_0 = \twobyone 0{1000} = c_1 \twobyone 21 + c_2 \twobyone{-1}1,$$
so $c_1 = \frac{1000}{3}$ and $c_2 = \frac{2000}{3}$.

\smallskip

In some applications Markov matrices are defined differently -- their rows
add to $1$ rather than their columns.  In this case, the
calculations are the transpose of everything we've done here.

\subsection*{Fourier series and projections}

\subsubsection*{Expansion with an orthonormal basis}

If we have an orthonormal basis $\vb q_1, \vb q_2, ..., \vb q_n$ then
we can write any vector $\vb v$ as $\vb v = x_1 \vb q_1 + x_2 \vb q_2
+ \cdots + x_n \vb q_n$, where:
$$\vb q_i^T \vb v = x_1 \vb q_i^T \vb q_1 + x_2 \vb q_i^T \vb q_2 +
\cdots + x_n \vb q_i^T \vb q_n = x_i.$$ Since $\vb q_i^T \vb q_j = 0$
unless $i=j$, this equation gives $x_i = \vb q_i^T \vb v$.

In terms of matrices, $\onebythree {\vb q_1}{\cdots}{\vb q_n}
\threebyonec  {x_1}{\vdots}{x_n} = \vb v$, or $\mb Q \vb x = \vb
v$.  So $\vb x = \mb Q^{-1} \vb v$. Because the $q_i$ form an
orthonormal basis, $\mb Q^{-1} = \mb Q^T$ and $\vb x = \mb Q^{T} \vb v$.
This is another way to see that $x_i = \vb q_i^T \vb v$.

\subsubsection*{Fourier series}

The key idea above was that the basis of vectors $\vb q_i$ was orthonormal.  Fourier
series are built on this idea.  We can describe a function $f(x)$ in
terms of trigonometric functions:
$$f(x) = a_0 + a_1 \cos x + b_1 \sin x + a_2 \cos 2x + b_2 \sin 2x +
\cdots.$$ This {\em Fourier series} is an infinite sum and the
previous example was finite, but the two are related by the fact that
the cosines and sines in the Fourier series are orthogonal.

We're now working in an infinite dimensional vector space.  The
vectors in this space are functions and the (orthogonal) basis vectors
are $1$, $\cos x$, $\sin x$, $\cos 2x$, $\sin 2x$, ...

What does ``orthogonal'' mean in this context?  How do we compute a
dot product or {\em inner product} in this vector space?  For vectors
in $\R^n$ the inner product is $\vb v^T \vb w = v_1 w_1 + v_2 w_2 +
\cdots + v_n w_n$.  Functions are described by a continuum of values
$f(x)$ rather than by a discrete collection of components $v_i$.  The
best parallel to the vector dot product is: $$f^Tg = \int_{0}^{2\pi}
f(x) g(x) \, dx.$$ We integrate from $0$ to $2 \pi$ because Fourier
series are periodic:
$$f(x) = f(x+2\pi).$$

The inner product of two basis vectors is zero, as desired.  For example,
$$\int_0^{2\pi} \sin x \cos x \, dx = \left. \frac{1}{2} (\sin x)^2
\right|_0^{2\pi} = 0.$$

\smallskip

How do we find $a_0$, $a_1$, etc. to find the coordinates or {\em
  Fourier coefficients} of a function in this space?  The constant
term $a_0$ is the average value of the function.  Because we're
working with an orthonormal basis, we can use the inner product to
find the coefficients $a_i$.
\begin{eqnarray*}
\int_0^{2 \pi} f(x) \cos x \, dx &=& 
\int_0^{2 \pi} (a_0 + a_1 \cos x + b_1 \sin x + a_2 \cos 2x +  \cdots) \cos x \, dx\\
&=&  0 + \int_0^{2 \pi} a_1 \cos^2 x  \, dx + 0 + 0 +  \cdots\\
&=& a_1 \pi.
\end{eqnarray*}
We conclude that $\displaystyle{a_1 = \frac{1}{\pi} \int_0^{2 \pi}
  f(x) \cos x \, dx}$.  We can use the same technique to find any of the values $a_i$.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}
