% FILE antonEV.tex

% AR6 Chapter 6, AR7 Chapter 7
\section{Eigenvalues, Eigenvectors ([J] Chpt3)}
%Material in this chapter is treated in \cite{J} Chapter 3.

\subsection{Eigenvalues and Eigenvectors}
\headq{Definition.} Let $A$ be an $n\times n$ matrix,
$\b x\in \DoubleR^n$ with $\b x\ne \b 0$, and $\lambda$ a number such that
  $$ A \b x = \lambda \b x .$$
Then \b x is called an {\em eigenvector} and $\lambda$ is the {\em eigenvalue}
corresponding to \b x (or $\lambda$ is called an {\em eigenvalue} and \b x
is the {\em eigenvector} corresponding to $\lambda$).\\
The polynomial $\det(\lambda I-A)$ is called the
{\it characteristic polynomial} of $A$, and
the equation $\det(\lambda I-A) = 0 $
is called the {\it characteristic equation} of $A$.

From 
[AR6] Theorem 6.1.1, [AR7] Theorem 7.1.2
we have that the eigenvalues of $A$ satisfy the
characteristic equation of $A$.
Thus, if a matrix has rational number entries, its eigenvalues will,
in general, be algebraic numbers. 
For discussion of how Maple treats algebraic numbers,
using {\tt RootOf} expressions,
see \cite{J} \S3.1,\cite{M92}.

Eigenvalues and eigenvectors have many uses, some of which we will see
in later sections. We will begin with relevant Maple functions.
Maple has a set of linear algebra functions that allow you to determine, 
in those circumstances when it can be done in exact closed form solutions, 
the eigenvalues and eigenvectors of a square matrix. 
Here is a demonstration of this
using some numerical matrices.\index{eigenvals}

\label{eg4}
\begin{maple}
# AR6 Section 6.1 Example 2 p269
> with(linalg,matrix,eigenvals):
> A2:= matrix([ [ 3, 2], [-1, 0] ]):         A:=A2:
> eigenvals(A2);
                                     1, 2
# AR6 Section 6.1 Example 3 p269; AR7 Section 7.1 p358
> A3:= matrix([ [-2,-1], [ 5, 2] ]):
> eigenvals(A3);
                                     I, - I
> B:= matrix([ [0,-1], [1, 0] ]):
> eigenvals(B);
                                     I, - I
\end{maple}
Notice that $A=A_2$ has only real eigenvalues and 
$A_3$ and $B$ have two imaginary eigenvalues and no real eigenvalues. 
These are the solutions to the characteristic polynomial in each
case.

\smallskip
\headq{EXERCISE.} \label{student} Find the eigenvalues 
  of the following 
  three symmetric tridiagonal matrices:
\begin{verbatim}
  C1:= matrix([[1,1,0],[1,0,1],[0,1,1]]);
  C2:= matrix([[0,1,0],[1,0,1],[0,1,0]]);          
  C3:= matrix([[1,1,0],[1,0,1],[0,1,0]]);
\end{verbatim}
\smallskip

\headq{Notes.}
\begin{enumerate}
\item \cite{AR} usually only discusses ``real vector spaces'' where the word
  ``number'' means ``real number''. However, when looking at
  eigenvalues and eigenvectors it is often important to look at complex
  vector spaces, where ``number'' now means ``complex number''.
  Maple's functions work the same when entries are complex as when entries
  are real (Maple uses {\tt I} to denote the imaginary number $\sqrt{-1}$).

\item Algebraic numbers are inevitably associated with exact solutions
  of polynomials, and hence of exact eigenvalue calculations.
  To avoid digression from the main theme of dealing with linear
  algebra we merely refer to \cite{M92} for a treatment,
  along with the Maple manuals and on-line help as and when you
  need it.
\goodbreak

\item Cardan's formula for solving cubics can give lengthy answers. In the case
  of {\tt C3}, all the solutions are real, but the number {\tt I} occurs in the
  answer. As stated earlier, exact solutions are sometimes both correct and
  confusing -- or horrible to look at -- whereas reasonably accurate
  floating-point numerical approximations can be easily comprehended. So try
  \begin{verbatim} 
  evalf(Eigenvals(C3));
  \end{verbatim} 
\end{enumerate}
\par\noindent
{\tt Eigenvals} is not in the linalg package.

% AR 6.1.1
\ifodd\ARed\setcounter{theorem}{1}\else\setcounter{theorem}{0}\fi
\begin{theorem} If $A$ is an $n\times n$ matrix, then the following are
  equivalent:
  \begin{enumerate}\item[]
  \begin{enumerate}
  \item $\lambda$ is an eigenvalue of $A$.
  \item The system of equations $(\lambda I-A)\b x = \b 0$ has a non-trivial
    solution.
  \item There is a non-zero vector $\b x$
    ($\b x\in \DoubleR^n$ when $A$ and $\lambda$ are real) such that
    $A\b x=\lambda\b x$.
  \item $\lambda$ is a solution of the characteristic equation
    $\det(\lambda I-A)=0$.
  \end{enumerate}
  \end{enumerate}
\end{theorem}

Maple also has 
{\tt eigenvects}\index{eigenvects}
(and 
{\tt charpoly}\index{charpoly}) functions.
However, to begin with 
we will find the eigenvectors using the functions you have learnt
in the earlier part of this document, and hence revising these.
\smallskip

%\begin{theorem} 
%\headq{\bf THEOREM }
\theoremNN{\it 
The eigenvectors corresponding to a given
  eigenvalue $\lambda$ of a matrix $A$ are the non-zero vectors of the
  {\em eigenspace} $W_\lambda = {\rm nullSpace}(A-\lambda I)$.
} %\end{theorem}
\theoremNNEnd

In the above example, you know that the eigenvalues of $A=A_2$ are 1 and 2.
Thus, you are looking for the nullSpace of the matrices  $(A-I)$ and
$(A-2I)$, where $I$ is the identity matrix.
\label{eg4.2}
\begin{maple}
# Continuing the preceding example:
> with(linalg,diag,nullspace):
> A:= A2:       Id:= diag(1,1):     W1:= nullspace( evalm(A - Id) );
                              W1 := {[ -1, 1 ]}

> W_2:= nullspace( evalm(A - 2*Id) );
                             W_2 := {[ -2, 1 ]}

# For example,  W1  is a basis for  nullSpace(A-Id),
# and hence a set of eigenvectors.
# To CHECK that this set of vectors satisfies the equation  A x = x,  find
evalm(A &* W1[1]);   # The product of A with the first (and only) vector in W1.
                                  [ -1, 1 ]

# You should CHECK the other eigenvectors for yourself.
\end{maple}

\medskip\headq{EXERCISE.} Find the eigenvectors of the matrices $C1$, $C2$, $C3$
  on page~\pageref{student}.
%\goodbreak

\medskip
\headq{Note.} Prior to Maple V, the command {\tt nullspace(A)} or
  {\tt linsolve(A,b)} assumed that the entries of $A$ and $b$ were
  rational numbers, or similar. It did not want to deal with numbers like
  $\sqrt{2}$. Thus it was a harder problem to find the eigenvectors of the
  matrix $C2$ above.  If you have an early version of Maple, then one way is
  to find the rowspace of $C2-\lambda Id$ which is two dimensional.
  Then find a vector orthogonal to this with {\tt crossprod}. 

\medskip
\headq{Optional.} As well as the determinant, another useful function associated
with a matrix is the sum of its diagonal elements (called its {\em trace}).
If $A$ is an $n\times n$ matrix then
  $${\rm trace}\,(A) = \sum_{i=1}^n a_{ii} = a_{11} + a_{22} +\cdots + a_{nn}.$$

\noindent Maple has a command 
{\tt trace}\index{trace}
to find this.

\goodbreak
%\smallskip
%\setcounter{theorem}{16}
%\begin{theorem} 
%\headq{\bf THEOREM }
\theoremNN{\it 
Let $A$ be an $n\times n$ matrix with eigenvalues
  $\rowi{\lambda}{n}$. Then
  \begin{enumerate}\item[]
    \begin{enumerate}
    \item $\det(A)$ is the product
     $\lambda_1\times \lambda_2\times\cdots \lambda_n$ of the eigenvalues.
    \item ${\rm trace}\,(A)$ is the sum
     $\lambda_1 + \lambda_2 + \cdots \lambda_n$ of the eigenvalues.
    \end{enumerate}
  \end{enumerate}
} %\end{theorem}
\theoremNNEnd

See \cite{AR} Exercises 15 to 19, % AR6 p275.
\ChEV\ \S1.

\subsection{Diagonalization}

\headq{Definition.} An $n\times n$ matrix $A$ is {\em diagonalizable} if
there is an invertible matrix $P$ such that $P^{-1} A P$ is a diagonal matrix.
\medskip
\headq{Definition.} $n\times n$ matrices $A$ and $D$ are said to be
{\em similar} if
there is an invertible matrix $P$ such that $P^{-1} A P=D$.
\medskip

\setcounter{theorem}{0}
\begin{theorem}
  If $A$ is an $n\times n$ matrix,
  then the following are equivalent:
  \begin{enumerate}\item[]
    \begin{enumerate}
    \item $A$ is diagonalizable.
    \item $A$ has $n$ linearly independent eigenvectors.
%    \item $\DoubleR^n$ has a basis consisting of eigenvectors of $A$.
%    \item $A$ is similar to a diagonal matrix.
    \end{enumerate}
  \end{enumerate}
\end{theorem}


The basic idea in the proof that (b) implies (a) is as follows.
Suppose the $n\times n$ matrix $A$ has $n$ linearly
independent eigenvectors $\rowi{\b v}{n}$ with associated eigenvalues
  $\rowi{\lambda}{n}$.  If $P$ is the matrix whose
  $i$'th column is $\b v_i$, then $P$ is invertible and
a calculation shows that
    $$ P^{-1} A P =\Lambda = \pmatrix{\lambda_1& & & \cr & \lambda_2 & & \cr
                                      & & \ddots & \cr & & & \lambda_n \cr }.$$
\smallskip

\headq{COROLLARY.} {\it If $A$, $\Lambda$ and $P$ are as above, then\qquad
  $P \Lambda P^{-1} = A$.}
\medskip

\headq{Note.} At this point, it may be helpful to 
  remark that we will see 
  that the matrix $P$ above is the transition matrix from the standard
  basis to the basis $\{\rowi{\b v}{n}\}$, and $A$, $\Lambda$ are the matrices
  of a function (relative to the standard basis and $\{\rowi{\b v}{n}\}$
  respectively).
  This, and a vector space interpretation of similarity is given 
  at the end of the next chapter of
  \cite{AR}. % AR6 \S7.6.

\begin{maple}
# Example 5 - AR6 Section 6.1 p271; Section 7.1 p359
> with(linalg,matrix,eigenvals,eigenvects,augment,equal,inverse,diag):
> A:= matrix([ [0,0,-2],
               [1,2, 1],
               [1,0, 3] ]):
> evects:= eigenvects(A);

  evects := [1, 1, {[ -2, 1, 1 ]}], [2, 2, {[ 0, 1, 0 ], [ -1, 0, 1 ]}]

# The eigenvectors are the elements of the sets  evects[1][3] and evects[2][3]:
> if (nops(evects[1][3])=1) then
  evals:= evects[1][1], evects[2][1], evects[2][1] :
  P:=augment( evects[1][3][1], evects[2][3][1], evects[2][3][2] );
else
  evals:= evects[1][1], evects[1][1], evects[2][1] :
  P:=augment( evects[1][3][1], evects[1][3][2], evects[2][3][1] );
fi;
                                  [ -2  0  -1 ]
                                  [           ]
                             P := [  1  1   0 ]
                                  [           ]
                                  [  1  0   1 ]
\end{maple}
\goodbreak
\begin{maple}
> equal( evalm( inverse(P)&*A&*P ), diag(evals) );
                                      true

# Not all matrices are diagonalizable.  For Example 
> B:= matrix([ [a,1], [0,a] ]):
> evals:= eigenvals(B);        # eigenvects will not work on this matrix
                                 evals := a, a

> nullspace( B-a*diag(1,1) );
                                   {[ 1, 0 ]}

# Since the dimension of this eigenspace is only 1,   B is not diagonalizable.
\end{maple}

% AR 6.2.2
%\setcounter{theorem}{1}
\begin{theorem} If $\rowi{\b v}{k}$ are eigenvectors of
 $A$ %be an $n\times n$ matrix.\quad
 corresponding to distinct eigenvalues $\rowi{\lambda}{k}$
% of $A$ are {\em distinct},
  then %their associated eigenvectors are linearly independent.\quad
$\{\rowi{\b v}{k}\}$ is a linearly independent set.
\end{theorem}

% AR 6.2.3
%\setcounter{theorem}{1}
\begin{theorem} If an $n\times n$ matrix $A$ has $n$ distinct eigenvalues,
then $A$ is diagonalizable. 
 % If the eigenvalues $\rowi{\lambda}{k}$ of $A$ are {\em distinct},
 % then their associated eigenvectors are linearly independent.\quad
  %In particular, if $A$ has $n$ real distinct eigenvalues,
 % then $A$ is diagonalizable.
\end{theorem}
Thus the matrix $A_2$ in Example 2 of [AR] Section \ChEV.1 
(see page~\pageref{eg4} of these notes) is diagonalizable.

\smallskip
\headq{Note:} Example 1 of [AR] Section \ChEV.2 (above) shows that the converse
of Theorem \ChEV.2.3 is not true.
\medskip

%\setcounter{theorem}{33}
%\begin{theorem} 
%\headq{THEOREM } 
\theoremNN{\it 
Suppose $A$ is an $n\times n$ matrix, and
    $$ P^{-1} A P =\Lambda = \pmatrix{\lambda_1& & & \cr & \lambda_2 & & \cr
                                    & & \ddots & \cr & & & \lambda_n \cr }.
                   \qquad\qquad {\rm Then}\quad
      \Lambda^k = \pmatrix{\lambda_1^k& & & \cr & \lambda_2^k & & \cr
                                    & & \ddots & \cr & & & \lambda_n^k \cr }$$

  and\quad $A^k = P\Lambda^k P^{-1}$\quad for any positive integer $k$.\newline
  If all the eigenvalues $\rowi{\lambda}{n}$ are non-zero, this is also true
  for negative values of $k$.
} %\end{theorem}
\theoremNNEnd

\subsection{Orthogonal Diagonalization; Symmetric Matrices}

% AR 6.3.1
\setcounter{theorem}{0}
\begin{theorem} If $A$ is an $n\times n$ real matrix, then the
following are equivalent.
\begin{enumerate}\item[]
  \begin{enumerate}
  \item $A$ is orthogonally diagonalizable.
  \item $A$ has an orthonormal set of $n$ eigenvectors.    
  \item $A$ is symmetric.
  \end{enumerate}
\end{enumerate}
\end{theorem}
%\goodbreak

\headq{Note:} The proof of this theorem uses not only the {\em idea} of complex
eigenvalues and eigenvectors 
but also a complex
{\em inner product} $\b u.\b v = \b u^T\bar{\b v}$ for $\DoubleC^n$, where
$\bar{\b v}$ is the complex conjugate of \b v.  
Maple's {\tt dotprod} function uses this when 
its arguments are complex vectors, although it has a more general function 
{\tt innerprod}\index{innerprod}
used with real vectors and matrices.

\begin{maple}
> with(linalg):
> u:= vector([I,1+I]):            v:= vector([-2*I,1+I]):
> simplify(dotprod(u,v));
                                       0

> innerprod(u,v);
                                    2 + 2 I
\end{maple}

% AR 6.3.2
\setcounter{theorem}{1}
\begin{theorem} If $A$ is a real symmetric matrix, then eigenvectors 
  from different eigenspaces are orthogonal.
\end{theorem}

% AR 6.3.3
\begin{theorem} \ 
\begin{enumerate}\item[]
   \begin{enumerate}
%   \newline
   \item The characteristic equation of a real symmetric matrix $A$
      has only real roots.
   \item If an eigenvalue $\lambda$ of a real symmetric matrix $A$ 
      is repeated $k$ times as a root of the characteristic equation,
      then the eigenspace corresponding 
      to the eigenvalue $\lambda$ is $k$-dimensional.
   \end{enumerate}
\end{enumerate}
\end{theorem}
\medskip

Recall the definition that a square matrix $Q$ is
said to be {\it orthogonal} if $Q^T Q= I$.
Then we have the following.
\smallskip
          
%\setcounter{theorem}{44}
%\begin{theorem} 
%\headq{THEOREM } 
\theoremNN{\it
Let $A$ be an $n\times n$ real symmetric matrix. Then 
  $A$ has $n$ orthonormal eigenvectors, and so can be expressed as
    $$ A = Q \Lambda Q^T $$
  where $Q$ is orthogonal and $\Lambda$ is a diagonal matrix with the
  eigenvalues of $A$ on the diagonal.
} %\end{theorem}
\theoremNNEnd

%\goodbreak
\noindent Finding the matrix $Q$ in the last theorem depends on both
Theorems AR {\ChEV}.3.1 and {\ChEV}.3.2, and also on the Gram-Schmidt process.
This is illustrated in the following.
\begin{maple}
# AR6 Section 6.3 Example 2 p288; AR7 Section 7.3 Example 1 p377
> with(linalg,matrix,eigenvals,eigenvects,dotprod,
          GramSchmidt,norm,augment,orthog,diag,equal):
# Find an orthogonal matrix Q which diagonalizes the matrix A where
> A:= matrix([ [4, 2, 2],
               [2, 4, 2],
               [2, 2, 4] ]):
# Use the same ideas as in an earlier example:
> evects:= eigenvects(A);

 evects := [2, 2, {[ -1, 1, 0 ], [ -1, 0, 1 ]}], [8, 1, {[ 1, 1, 1 ]}]

> if (nops(evects[1][3])=1) then
  evals:= evects[1][1], evects[2][1], evects[2][1] :
  u1:= evects[1][3][1]: u2:= evects[2][3][1]: u3:= evects[2][3][2]:
else
  evals:= evects[2][1], evects[1][1], evects[1][1] :
  u1:= evects[2][3][1]: u2:= evects[1][3][1]: u3:= evects[1][3][2]:
fi;
> print( dotprod(u1,u2), dotprod(u1,u3), dotprod(u2,u3) );
                                    0, 0, 1
# Since  u2, u3  are not orthogonal, use Gram-Schmidt:
> v1:= evalm( u1/norm(u1,2) ):          GS:= GramSchmidt( [u2,u3] ):
> v2:= evalm( GS[1]/norm(GS[1],2) ):    v3:= evalm( GS[2]/norm(GS[2],2) ):
> Q:= augment( v1,v2,v3 );
                    [      1/2         1/2         1/2  1/2 ]
                    [ 1/3 3     - 1/2 2     - 1/6 3    2    ]
                    [                                       ]
                    [      1/2        1/2          1/2  1/2 ]
               Q := [ 1/3 3      1/2 2      - 1/6 3    2    ]
                    [                                       ]
                    [      1/2                    1/2  1/2  ]
                    [ 1/3 3          0       1/3 3    2     ]

> orthog(Q);
                                      true
> equal( evalm( transpose(Q)&*A&*Q ), diag(evals) );
                                      true
\end{maple}
\goodbreak

\subsection*{Rotations and Reflections}
Although these are not dealt with extensively in [AR], they do appear
as examples of linear transformations used in Computer Aided Design.
We have that
$$ Q(\theta) = \pmatrix{\cos (\theta)&-\sin (\theta)\cr
                        \sin (\theta)&\cos (\theta)\cr}$$
is the matrix of a rotation of $\DoubleR^2$ through an angle of $\theta$.
We also have that
$$
\pmatrix{\cos(\theta)&-\sin(\theta)&0\cr\sin(\theta)&\cos(\theta)&0\cr0&0&1\cr},
\qquad
\pmatrix{\cos(\theta)&0&-\sin(\theta)\cr0&1&0\cr\sin(\theta)&0&\cos(\theta)\cr},
\qquad
\pmatrix{1&0&0\cr0&\cos(\theta)&-\sin(\theta)\cr0&\sin(\theta)&\cos(\theta)\cr}
$$
are the matrices of rotations through an angle of $\theta$ in the
$xy$, $xz$ and $yz$ planes of $\DoubleR^3$ respectively (i.e. rotations about
axes orthogonal to those planes).
See [AR7] Example 7 Section 6.5 p349.
\medskip

%\headq{THEOREM } 
\theoremNN{\em The matrix $Q$ induced by any rotation through an angle
  of $\theta$ in $\DoubleR^3$ is similar to each of the above three matrices.}
\theoremNNEnd

\headq{COROLLARY.} {\em Let $Q$ be the matrix induced by a rotation in
 $\DoubleR^3$. Then
  \begin{enumerate}\item[]
    \begin{enumerate}
    \item $Q$ is orthogonal and $\det(Q)=1$;
    \item $\lambda=1$ is an eigenvalue of $Q$,\quad and the associated
      eigenspace is the axis of $Q$\newline
      (i.e. is orthogonal to the plane of the rotation);
    \item ${\rm trace}\,(Q)=1+2\cos(\theta)$,\quad and so the angle of the
      rotation is given by
       $$\cos(\theta) = ({\rm trace}\,(Q)-1)/2. $$
    \end{enumerate}
  \end{enumerate}}
\smallskip

%\headq{THEOREM } 
\theoremNN{\em Let $Q$ be an orthogonal $3\times 3$ matrix.\quad Then
  $\det(Q)=\pm 1$.\newline
  If $\det(Q)=1$, then $Q$ is the matrix induced by a rotation,
  and if $\det(Q)= -1$, then
  \begin{enumerate}\item[]
    \begin{enumerate}
    \item $\lambda=-1$ is an eigenvalue of $Q$, and $Q$ reflects any associated
      eigenvector in the plane $P$ orthogonal to it;
    \item $Q$ is the matrix induced by a linear transformation which either
      fixes every point of $P$ or is a rotation in $P$ through an angle
      $\theta$ where
       $$\cos(\theta) = ({\rm trace}\,(Q)+1)/2. $$
    \end{enumerate}
  \end{enumerate}}
\theoremNNEnd

\begin{maple}
> with(linalg):
# Show that Q reflects vectors orthogonal to some plane where
> Q:= matrix([ [4/9,-7/9,-4/9],
>              [1/9,-4/9, 8/9],
>              [8/9, 4/9, 1/9] ]):
> print( orthog(Q), det(Q) );
                                    true, -1

# Thus  Q reflects vectors orthogonal to a plane  P  where
> u:= nullspace( Q+diag(1,1,1) )[1]:   # u is an eigenvector associated with -1
> P:= dotprod( u,vector([x,y,z]) ) = 0;
                          P := - 1/2 x - 3/2 y + z = 0

# It also rotates the plane  P  through an angle  theta  where
> cos_theta:= (trace(Q)+1)/2;
                                cos_theta := 5/9
\end{maple}

\headq{EXERCISES.} 
\begin{enumerate}
  \item Show that the product and inverses of rotations are rotations.
  \item Show that the inverse of a reflection is a reflection.
  \item Show that the product of reflections through two intersecting planes is
    a rotation.
  \item Let $\b u\in\DoubleR^3$ with $\Vert \b u\Vert=1$.  Show that
  $I-2\b u\b u^T$ is a reflection in the plane orthogonal to \b u.
\end{enumerate}

\subsection*{An application: small oscillations of mechanical systems}

Here we treat an application
of eigenvalues of symmetric matrices determining the principal frequencies of
oscillation of a frictionless vibrating system.
% (See also mechanics texts, such as Synge and Griffiths.)
%, \cite{SG}
The example could be posed in terms of LC
circuits but here we pose it in mechanical terms.
The basic problem involves $n$ particles,
equally spaced on a stretched string.
After setting $n$, the matrix is
\begin{maple}
> A.n := band([-1,2,1],n);
\end{maple}
It turns out that there is a formula for the
{\tt eigenvals} and {\tt eigenvects} for general $n$. Later we will
illustrate that Maple might, with a bit of effort,
be arranged to check these. However, here is
an easier beginning to this problem,
from which you can learn something of both the
capabilities and limitations of Computer Algebra systems.
\smallskip

\par\noindent{\bf
EXERCISE.} Consider a light stretched string held at its ends,
$x=0$ and $x=L$, and on which are
placed  $n$ masses.
The masses are fixed at equal distances apart.
The position of the $j$-th mass
is denoted by $x_j$.
The motion of the $j$-th mass, $1\leq j\leq n$, is given by
$$ m_j  {{d^2 x_j}\over{dt^2}} = x_{j-1} - 2 x_j +x_{j+1}  ,$$
with
$x_0 = 0$          and             $x_{n+1} = L$ .
The fundamental frequencies of oscillations of the system
are related to the eigenvalues $\lambda$,
$A u = \lambda u $,
of a symmetric tridiagonal $n$ by $n$ matrix $A$.

(a) When the masses are equal the matrix $A$
can be taken to have -1s on the sub and on the
super- diagonal, and the diagonal entries are all the same,
and we can take them all to be 2
say. Then $A=${\tt A.n}.
\par\noindent
(i) (Optional.)
Why doesn't it matter for the eigenvectors what constant is taken for
the
diagonal entry?
\par\noindent
(ii) For $n=3$ first, and then for $n=7$,
use Maple to find the eigenvalues and eigenvectors of $A$.
\par\noindent
(iii) Find the smallest $n$ for which Maple's {\tt eigenvals} function
is
unable to find the eigenvalues.   \newline
(Remark for (iii).
Recall that there is a formula for solving polynomials of degree
less than or equal to 4, after which there is no general formula.
There is special structure to the
characteristic equation here,
and it turns out that an expression for the eigenvalues can be
found for the general $n$ case with equal masses.
This is not the case if the masses are not
equal.)

(Remark for (a).
For matrices which are considerably larger than say $n=7$,
and which aren't
so special that there is a special formula for the eigenvalues,
floating-point numerical
computations are necessary.
Although these are possible from Maple V - see below - using an
appropriate procedure from a suitable library,
such as NAG or Numerical Recipes - or a package like MatLab-,
would be more appropriate for large matrices than using Maple.)
%Fisher Chapter 8
%\cite[Chapter 8]{Fi}
%illustrates what calls to the NAG library
%look like for problems like this.
\smallskip

(b) Suppose that some related vibrating system
were to lead to the eigenvalue problem
$A u = \lambda u$,
for a symmetric tridiagonal $n$ by $n$ matrix $A$
with -1s on the sub and on the super- diagonal.
The diagonal entries  aii
are parameters which are rather analogous to the masses $m_i$  in the
masses-on-a-string example.
In both problems there are then $n$ parameters involved in
determining the eigenvalues. In both problems,
when the parameters are equal the calculations
are those of part (a).
There are engineering circumstances when one might want to design a
vibrational system so that its resonant frequencies are in certain
places.
(One application is as
follows. Consider an apparatus to measure vibrations associated with
earthquakes or blasting.
There might be something which has its own natural frequencies
which one is concerned to
protect.
Then the measuring device might be designed to have
a resonant frequency near it.)

\par\noindent
(i) When $n=3$ and the measuring device is
symmetric about the middle mass we may take
$a_{11}=2=a_{33}$  and $a_{22} =a$.
Use Maple to find the eigenvalues and eigenvectors of this matrix
$A(a)$, and how they depend on the parameter $a$.
What are the eigenvalues and eigenvectors
when $a=1$?

\par\noindent
(ii) If there were more parameters,  or if $n$ were much larger,
would you expect Maple to be as
useful? Explain your answer.

\medskip

Start for the solution to part (a).
The Maple code for finding the {\tt eigenvals} is
\begin{maple}
> with(linalg,band,eigenvals):
> for  n from 2 to 8 do  A.n:=band([-1,2,-1],n): eigenvals(A.n); od;
\end{maple}

Start for the solution to part (b).
When $a=1$ Maple can easily find the {\tt eigenvals} and
{\tt eigenvects}. The {\tt eigenvals} are 0, 2, 3,
and there are eigenvectors for all these with every entry
rational.

\medskip

As stated above, Maple V can be used for float approximations to
{\tt Eigenvals}, etc. (using an implementation of the
$QR$-algorithm for approximating eigenvalues and eigenvectors).
Here is an example.

%
% TIDY THE Maple MESS BELOW
%

\begin{maple}
with(linalg,eigenvals,eigenvects,band,charmat,kernel,scalarmul,norm):
n:=3:
A.n:=band([-1,2,-1],n);  
# Eigenvals and their eigenvectors can be found numerically 
readlib(forget): forget(Eigenvals):
evalf(Eigenvals(A3,vec3));
print(vec3);
# eigenvals and their eigenvects can sometimes be found exactly 
evects:=eigenvects(A.n); 
# Maple has no real problem with the algebraic numbers here 
x:='x': solve(x^2 - 4*x +2 =0, x); # for n=3
tidy:= g -> op(map(op,g)); 
evecta:=[tidy([allvalues(evects[1][3])]),tidy([allvalues(evects[2][3])])]; 
evectf:=map(evalf,evecta); 
nmze:= vec -> scalarmul(vec,1/norm(vec,2)); 
evectnf:=map(nmze,evectf); 
# compare the two approaches: they agree 
print(vec3); 
# Another way to get eigenvects exactly without so many allvalues is 
charmat(A3,2+sqrt(2)); # for n=3
kernel(");
\end{maple}

% ADD THE CAUTION ABOUT readlib(forget) STUFF

Using just the first and last two lines of the above,
we could get approximate numerical values
for those $n$ which we could not solve exactly
in the $n$-masses on a string example which we
treated earlier.

\medskip

Example, continued. We now consider the case of general $n$.

%# Synge and Griffith S17.3 p500
\begin{maple}
########################################################################
# n-masses with equal springs joining them.
#
# p501 xkj is the k-th element of j-th eigenvector
n:='n': xkj:= sin(k*j*Pi/(n+1)); # really *sqrt(2/(n+1)) to normalise
# let A=band([-1,2,-1],n) and show xj is an eigenvector:
# find corresponding eigenvalue.
Ax:=expand(-subs(k=i-1,xkj) +2*subs(k=i,xkj) - subs(k=i+1,xkj));
#                        i j Pi         j Pi            i j Pi
#               - 2 sin(--------) cos(-------) + 2 sin(--------)
#                         n + 1        n + 1             n + 1
#
evalj:=factor(Ax)/subs(k=i,xkj);
#                                       j Pi
#                             - 2 cos(-------) + 2
#                                      n + 1
#
# To fix n and plot out the eigenvectors use
# nPts:=7; for jp from 1 to nPts do  # if all 8 eigenvects wanted
np:= 7: jp:=4:
ptlist:=[0,0]:
for kp from 1 to nPts do
  ptlist:=[op(ptlist),kp,subs(n=nPts,k=kp,j=jp,xkj)]:
  od:
ptlist:=[op(ptlist),nPts+1,0]:
plot(ptlist,style=LINE);
\end{maple}

\medskip

\par\noindent{\bf
EXERCISE.} The $n$ by $n$ symmetric tridiagonal band matrix $B$,
with -1s  on the sub- and on the
super-diagonal, and 2s on the diagonal
except at the $(1,1)$ and $(n,n)$ where the entry is 1, also
arises in engineering mechanics.                  \newline
(a) Check that you can see that the eigenvector
with every component being 1  corresponds to
the eigenvalue $\lambda=0$.                       \newline
(b) Longer, optional. See if you can deduce a general formula
for the eigenvalues of $B$. 
Maple cannot yet do this directly in a single command.
You may need to experiment at small fixed values of $n$ (using Maple's
band and {\tt eigenvals} functions) before guessing, and later
verifying,
the solution at general $n$.

Here is one place where matrices like $B$ arise.
Consider a railway train, with train and wagons
of equal weight, $n$ of these in total.
These are linked, and oscillations occur.
(They do on the
very long iron-ore trains in the Hammersley Ranges, West Australia,
and if they get too big, it
is bad - heavily-laden wagons leave the track.)
The problem for small oscillations leads to the problem of
finding the eigenvalues of matrix $B$.

\vfill
\eject


