\documentclass[12pt]{article}

\usepackage{amsmath,amssymb,amsthm}

\usepackage{xcolor}
\usepackage{empheq}

%\usepackage[textheight=8.5in, margin=1.6in]{geometry}
\usepackage[total={6in,8in}]{geometry}

\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\tikzstyle{ball} = [circle,shading=ball, ball color=black,
    minimum size=1mm,inner sep=1.3pt]
%\usetikzlibrary{arrows.meta}
%\tikzset{>={Latex[length=2mm,width=1.5mm]}}
\usetikzlibrary{decorations.markings}

\usepackage{graphicx}

\usepackage{needspace}  % <-- to prevent bad pagebreak over environment titles
% Use:  \Needspace{3\baselineskip} before opening an environment

\usepackage{enumitem}
\setlist[enumerate]{leftmargin=*}

%\usepackage[colorlinks=true,citecolor=black,linkcolor=black,urlcolor=blue]{hyperref}

\newcommand{\N}{\mathbb{N}}
\newcommand{\Z}{\mathbb{Z}}
\newcommand{\Q}{\mathbb{Q}}
\newcommand{\R}{\mathbb{R}}
\newcommand{\C}{\mathbb{C}}
\newcommand{\sn}{\mathfrak{S}}
\newcommand{\ve}{\varepsilon}
\newcommand{\ips}[2]{\langle{#1}, {#2}\rangle}
\DeclareMathOperator{\tr}{tr}
\DeclareMathOperator{\Span}{\mathrm{Span}}
\DeclareMathOperator{\rk}{\mathrm{rank}}
\DeclareMathOperator{\trace}{\mathrm{tr}}
\DeclareMathOperator{\im}{\mathrm{im}}
\DeclareMathOperator{\Sym}{\mathrm{Sym}}
\DeclareMathOperator{\Hom}{\mathrm{Hom}}
\DeclareMathOperator{\diag}{\mathrm{diag}}
\DeclareMathOperator{\glb}{\mathrm{glb}}
\DeclareMathOperator{\lub}{\mathrm{lub}}

\parskip = 0.05in
\parindent = 0.0in

%\pagestyle{empty}

\begin{document}
\centerline{Math 322 lecture for Friday, Week 12}
\bigskip

\centerline{\sc hamiltonian systems}
\medskip

Let~$E\subseteq\R^{2n}$ be an open subset, and let~$H\colon E\to\R$ be a function
in~$C^2(E)$, i.e., a function whose second partials exist and are continuous.
We will write~$H=H(x,y)$ where~$x,y\in\R^n$.  The system
\begin{align*}
  x'=(x_{1}',\ldots,x_{n}')&=H_{y}:=\frac{\partial H}{\partial y}=\left( \frac{\partial H}{\partial
  y_1},\dots, \frac{\partial H}{\partial y_n} \right)\\[10pt]
  y'=(y_{1}',\ldots,y_{n}')&=-H_{x}:=-\frac{\partial H}{\partial x}=-\left( \frac{\partial H}{\partial
  x_1},\dots, \frac{\partial H}{\partial x_n} \right),
\end{align*}
is called a {\em Hamiltonian system} with~$n$ degrees of freedom.  The
function~$H$ is called the {\em Hamiltonian}  or {\em total energy} of the
system.
\medskip

\textbf{Theorem 1.} (Conservation of energy.) For a Hamiltonian system, the total energy~$H$ is
constant along trajectories.
\begin{proof}
 Consider a solution
 trajectory~$\gamma(t)=(x(t),y(t))$ in~$\R^{2n}$.  By the chain rule,
 \begin{align*}
   \frac{d}{dt}H(\gamma(t))
   &= \nabla H\cdot\gamma'\\[10pt]
   &= \frac{\partial H}{\partial x}\cdot x'+\frac{\partial H}{\partial y}\cdot y'\\[10pt]
   &= \frac{\partial H}{\partial x}\cdot\frac{\partial H}{\partial y}
   -\frac{\partial H}{\partial y}\cdot\frac{\partial H}{\partial x}\\[10pt]
   &= 0.
 \end{align*}
\end{proof}

This result means that the solutions lie on level sets for~$H$.
\medskip

\textbf{Example.} Let~$H(x,y):=y\sin(x)$, and consider the Hamiltonian system with
one degree of freedom
\begin{align*}
  x' &= H_y = \sin(x)\\
  y' &= -H_x = -y\cos(x),
\end{align*}
where the~$x$ and~$y$ subscripts on~$H$ denote partial derivatives.
We find the critical points:
\[
  x'=y'=0\quad\Rightarrow\quad \sin(x)=y\cos(x)=0\quad\Rightarrow\quad
  x=n\pi\ \text{and}\ y=0,
\]
for~$n\in\Z$.  Letting~$f(x,y)=(\sin(x),-y\cos(x))$, the linearizations at these
critical points are
\begin{align*}
  \left(\begin{array}{c}
      x'\\y'
  \end{array} \right)
  =
  Df(n\pi,0)
  \left(\begin{array}{c}
      x\\y
  \end{array} \right)
  &= 
  \left(\begin{array}{cc}
      \cos(x)&0\\
      y\sin(x)&-\cos(x)
  \end{array} \right)\bigg|_{(n\pi,0)}
  \left(\begin{array}{c}
      x\\y
  \end{array} \right)\\[10pt]
  &= 
  (-1)^n
  \left(\begin{array}{cc}
      1&0\\
      0&-1
  \end{array} \right)
  \left(\begin{array}{c}
      x\\y
  \end{array} \right).
\end{align*}
Therefore, the critical points are all topological saddles.  Here are pictures
of the flow of the system, a contour plot of~$H$ (which shows the level sets),
  and a graph of~$H$:
  \begin{center}
    \begin{tikzpicture}
      \node at (0,0) 
      {
	\includegraphics[height=1.5in]{12fri1.png}
      };
      \node at (5,0) 
      {
	\includegraphics[height=1.5in]{12fri2.png}
      };
      \node at (10,0) 
      {
	\includegraphics[height=1.5in]{12fri3.png}
      };
    \end{tikzpicture}
  \end{center}
\medskip

{\bf Critical points.} The critical points of a Hamiltonian system~$x'=H_{x}$,
$y'=H_{y}$ occur where where all of the partials of~$H$ vanish, i.e., at the
critical points for the function~$H$.  These are the points where the graph
of~$H$,
\[
  \mathrm{graph}(H):= \left\{ (x,y,H(x,y))\subset\R^{2n+1}:(x,y)\in E \right\},
\]
has a ``horizontal tangent space'', i.e., where the tangent space is given by
setting the last coordinate equal to zero.  (To parametrize the tangent space,
  imagine the Jacobian of~$(x,y)\to (x,y,H(x,y))$.  It is the~$2n\times2n$
  identity matrix with an appended row consisting of the partials
of~$H$. The columns of this matrix span the tangent space.)
\medskip

At a critical point~$p$, the geometry of~$H$ is determined by its second
partials (if these don't also vanish).
For the purpose of determining this geometry, by translation, we may
assume~$p=0$, the origin, and~$H(0)=0$.
Then the second-order Taylor polynomial for~$H$ will be
\[
  Q(x,y) = \frac{1}{2}\frac{\partial^2 H}{\partial x_1^2}(0)x_1^2
  +\frac{\partial^2 H}{\partial x_1\partial x_2}(0)x_1x_2+
  \dots
  +
  \frac{1}{2}\frac{\partial^2 H}{\partial y_n^2}(0)y_n^2.
\]
By completing squares and making a linear change of coordinates  (or appealing
to the spectral theorem for real symmetric matrices), we can transform~$Q$ into
a function of the form:
\[
  \widetilde{Q} = v_1^2+\dots+v_k^2-v_{k+1}^2-\dots-v_{r}^2
\]
where the new coordinates are~$v_1,\dots,v_r,\dots,v_{2n}$.
The number of pluses and minuses turns out to not depend on the choice of change
of coordinates and is the crucial geometric information.
\medskip

{\bf Example.} In our earlier example,~$H(x,y)=y\sin(x)$, the critical points
were found to be~$(n\pi,0)$ for~$n\in\Z$.  To compute the second-order Taylor
polynomial at each of these points, we first compute
\[
  H_{xx}=-y\sin(x),\quad H_{xy}=\cos(x),\quad H_{yy}=0.
\]
So the second-order approximation of~$H$ is
\begin{align*}
  T(x,y) 
  &= 
  H(n\pi,0)+\frac{1}{2}H_{xx}(n\pi,0)(x-n\pi)^2+H_{xy}(n\pi,0)(x-n\pi)y+\frac{1}{2}H_{yy}(n\pi,0)y^2\\[5pt]
  &= (-1)^n(x-n\pi)y.
\end{align*}
Letting
\[
  u := \frac{1}{2}\left( y+(x-n\pi)
  \right)\quad\text{and}\quad v:=\frac{1}{2}(y-(x-n\pi)), 
\]
we get
\[
  u-v = x-n\pi\quad\text{and}\quad u+v=y.
\]
Using this change of coordinates, the Taylor polynomial becomes
\[
  \tilde{T}:= (-1)^n(u-v)(u+v)=\pm(u^2-v^2),
\]
and the graph of~$\tilde{T}$ is a saddle.
\medskip

\textbf{Corollary.} Let~$p\in\R^{2n}$.  Suppose there is a solution~$\gamma(t)=(x(t),y(t))$
such that~$\gamma(0)\neq p$ but such that~$\gamma(t)\to p\in\R^{2n}$
as either~$t\to\infty$ or~$t\to-\infty$.
Then~$p$ is not a strict minimum or maximum of~$H$.
\begin{proof}
 Suppose~$\lim_{t\to\infty}\gamma(t)=p$. 
 Using Theorem~1, we know that~$H(\gamma(t))$ is
 constant. Therefore, for all~$t$, we have $H(\gamma(0))=H(\gamma(t))$.  Taking
 the limit at~$t\to\infty$ and using the fact that~$H$ is continuous, we get
 \[
   H(\gamma(0))=\lim_{t\to\infty}H(\gamma(t))=H(\lim_{t\to\infty}\gamma(t))=H(p).
 \]
 Thus, in any neighborhood of~$p$, there is a path along which~$H$ is constant
 with value~$H(p)$.  A similar argument holds in the case~$\gamma(t)\to p$
 as~$t\to-\infty$.
\end{proof}

\textbf{Theorem 2.} Consider a Hamiltonian system with one degree of freedom
and total energy function~$H(x,y)$.  Suppose that~$H$ is analytic (i.e., it can
be written as a convergent power series at every point in its domain).  Then
every nondegenerate critical point of the system (points where the linearization
has two nonzero eigenvalues) is either a topological saddle or a center.  It's a
topological saddle if and only if its a saddle for~$H$ and it's a center if and
only if it's a strict local minimum or maximum for~$H$.
\begin{proof}
 We classified possible nongenerate critical points earlier in the
 semester.  The above corollary rules out all possibilities except for those
 listed above.  In detail, the linearization of
 \begin{align*}
   x' &= H_{y}\\
   y'&= -H_{x}.
 \end{align*}
 is
 \[
   \left(\begin{array}{c}
   x' \\ y'
   \end{array}\right)
   =
   \underbrace{\left(\begin{array}{rr}
	       H_{yx} & H_{yy} \\
	       -H_{xx} & -H_{xy}
	       \end{array}\right)}_{A}
   \left(\begin{array}{c}
   x \\ y
   \end{array}\right).
 \]
 The trace of~$A$, i.e., the sum of its eigenvalues is~$\tau=\tr(A)=0$, and the determinant
 of~$A$, i.e., the product of its eigenvalues
 is~$\delta=\det(A)=H_{xx}H_{yy}-H_{yx}^{2}$.  Recall our earlier analysis of
 linear systems in $\R^{2}$:

\begin{center}
  \begin{tikzpicture}
    \draw (-5,0)--(5,0);
    \draw (0,0)--(0,5);
    \node at (5.3,0) {$\tau$};
    \node at (0,5.4) {$\delta$};
    \node at (1.25,3.0) {unstable};
    \node at (1.25,2.5) {focus};
    \node at (-1.25,3.0) {stable};
    \node at (-1.25,2.5) {focus};
    \node at (-3.75,1.8) {stable};
    \node at (-3.75,1.3) {node};
    \node at (3.75,1.8) {unstable};
    \node at (3.75,1.3) {node};
    \node at (0,-1) {saddle};
    \node at (0,0) {degenerate};
    \node at (-3,0) {degenerate};
    \node at (3,0) {degenerate};
    \node[rotate=90] at (-0.04,1.2) {center};
    \begin{scope}[xshift=-3.43cm, yshift=-4.6mm]
  \begin{axis}[ 
      %title style={at={(0.5,0)},anchor=north,yshift=-30},
      %title={Graph of~$f(x)=x^2$ and its tangent line at~$x=3$.},
      axis lines*=middle,
      axis equal image,
      ticks=none,
      xmin=-5,
      xmax=5,
      %ymin=-0.2,
      ymax=6.5
    ]
    %\fill[blue] (axis cs: 1,1) circle (2pt);  
    %\fill[draw=black,fill=white] (axis cs:1,0) circle (2pt);  
    \addplot[domain=-5:5,thick, blue] {x*x/4};
  \end{axis}
  \end{scope}
  \end{tikzpicture}
\end{center}
In our case, $\tau=0$, and we see that if $\delta(A)<0$, the linearized system
is a saddle.  By Hartman-Grobman, the critical point in the original system is
then a (topological) saddle.  In the case~$\det(A)>0$, the linearized system is
a center.  As presented earlier in the course, that means that the critical
point in the original system is either a center or a focus.  However, the
corollary to conservation of energy, proved above, rules out the latter case: by
the second derivative test, if $\det(A)>0$, then~$H$ has a strict local maximum
or minimum.  So the critical point cannot be a focus.
\end{proof}
\medskip

\textbf{Newtonian system with one degree of freedom.} Consider the equation
\[
  x''=f(x)
\]
where~$f\in C^1(I)$ for some open interval~$I$.  We can think of~$x''$ as the
acceleration of a particle of mass~$1$ moving along a line under a force given
by~$f$.  We can change this into a planar first-order system with the
substitution~$y=x'$:
\begin{align*}
 x' &= y\\
 y' &=  f(x).
\end{align*}
To see that this is a Hamiltonian system, we need to find a function~$H(x,y)$
such that~$H_y=y$ and~$H_x=-f(x)$.  Integrating the first equation with respect
to~$y$ gives
\[
  H(x,y) = \frac{1}{2}y^2+U(x),
\]
for some function~$U$.  Taking the partial with respect to~$x$ then gives
\[
  H_x(x,y)=\frac{d}{dx}U(x)=-f(x),
\]
and hence,
\[
  U(x)=-\int_{x_0}^xf(s)\,ds.
\]
We call
\[
  T(y):=\frac{1}{2}y^2=\frac{1}{2}\left( x' \right)^2
\]
the {\em kinetic energy} and~$U(x)$ the {\em potential energy}, and we see the
total energy is the sum of the two:
\[
  H(x,y)=T(y)+U(x).
\]
\medskip

\textbf{Theorem 3.} The critical points of this Newtonian system lie on
the~$x$-axis.  The point~$(x_0,0)$ is a critical point iff~$x_0$ is a
critical point of the function~$U(x)$, i.e., iff~$U'(x_0)=0$.  Suppose
that~$H$ is analytic.  Then,
\begin{enumerate}
  \item If $x_0$ is a strict local maximum for~$U$, then~$(x_0,0)$ is a saddle for
    the system.
  \item If $x_0$ is a strict local minimum for~$U$, then~$(x_0,0)$ is a center for
    the system.
  \item If $x_0$ is a horizontal inflection point for~$U$ (which means its
    first nonzero derivative at~$x_0$ of positive order is of an odd order), then~$(x_0,0)$ is a cusp (i.e.,
    two hyperbolic sectors and two separatrices).
\end{enumerate}
\begin{proof}
 Exercise.
\end{proof}
\medskip

\textbf{Example.} Consider the case of the undamped pendulum:
\[
  x''=-\sin(x).
\]
The corresponding first-order planar system is
\begin{align*}
  x' &= y\\
  y' &= -\sin(x).
\end{align*}
The potential energy function is
\[
  U(x)= \int_{0}^x\sin(s)\,ds=1-\cos(x).
\]
On the next page, we have pictures of both the potential energy and the phase
portrait.  Try to see how they reflect Theorem~3. Also note the physical meaning
of the phase portrait.  The~$x$-axis shows the motion of the pendulum.
The~$y$-coordinate gives the velocity.  The critical points are~$n\pi$
for~$n\in\Z$ and occur
when the pendulum is balanced vertically or hanging straight down.  If the velocity is high enough, the
pendulum is continuously spinning around in a circle.
\begin{center}
  \begin{tikzpicture}
    \node at (0.1,0)
    {
      \includegraphics[height=1.125in]{12fri4.png}
    };
    \node at (0,-2) {Graph of~$U(x)$.};
    \node at (0,-7)
    {
      \includegraphics[height=3in]{12fri5.png}
    };
    \node at (0,-11.5) {Phase portrait.};
    \node at (0,-17)
    {
      \includegraphics[height=3in]{12fri6.png}
    };
    \node at (0,-21.5) {Graph of~$H$.};
  \end{tikzpicture}
\end{center}
\end{document}
