\documentclass{beamer}

%\usetheme[lionbackground]{Regler}
%\usetheme[lioncorner]{Regler}
\usetheme[liontopcorner]{Regler}
%\usetheme[lionheader]{Regler}

\usepackage[utf8]{inputenc}
\usepackage{fourier}

\begin{document} 
\title{Nonlinear Control and Servo Systems\\\ Lecture 2}
\author{Anders Robertsson}
\institute{Dept. of Automatic Control\\Lund Institute of Technology}
\frame{\titlepage} 

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

\begin{frame}
  \frametitle{Today's Goal}
    To be able to
    \begin{itemize}\slshape
    \item prove local and global stability of an equilibrium point
      through Lyapunov's method \pause
    \item show stability of a set (for example, a limit cycle) through
      invariant set theorems
    \end{itemize}
\end{frame}
% ----------------------------------------------------------------------


\begin{frame}
  \frametitle{Material}
  \begin{itemize}
  \item Slotine and Li: Chapter~3
  \item Lecture notes
  \end{itemize}
\end{frame}

% ----------------------------------------------------------------------
\begin{frame}
  \frametitle{\large Alexandr Mihailovich Lyapunov (1857--1918)}
  
  \begin{center}
    \includegraphics[height=0.4\textheight]{lyapunov_stamp}
  \end{center}
  \pause
  \begin{block}{Master thesis}
    ``On the stability of ellipsoidal forms of equilibrium of \\
    rotating fluids,'' St. Petersburg University, 1884.
  \end{block}
  \pause
  \begin{block}{Doctoral thesis}
    ``The general problem of the stability of motion,'' 1892.
  \end{block}
\end{frame}
% ----------------------------------------------------------------------

\begin{frame}
  \frametitle{Lyapunov's idea}
  % Lyapunov formalized the idea:

  \begin{center}
    \textbf{\emph{If the total energy is dissipated, the system must be
        stable.}}
  \end{center}
  \pause
  \begin{block}{Main benefit}
    By looking at an energy-like function (a so called Lyapunov
    function), we might conclude that a system is stable or
    asymptotically stable \textbf{without solving} the nonlinear
    differential equation.
  \end{block}
  \pause \medskip
  \begin{block}{Main question} How to find a Lyapunov function?
  \end{block}
\end{frame}

% ----------------------------------------------------------------------
\begin{frame}
  \frametitle{A Motivating Example}
  
  \begin{center} 
%    \psfrag{x}[][]{$x$} \psfrag{m}[][]{$m$}
    \includegraphics[width=0.4\hsize]{figures/mass-damper}
  \end{center}

  \vspace*{-6mm}
  \begin{equation*}
    m\ddot{x}=-\underbrace{b\dot{x}\vert\dot{x}\vert}_{\text{damping}}
    -\underbrace{k_0x-k_1x^3}_{\text{spring}},\qquad b,k_0,k_1>0 
  \end{equation*}

  The energy can be shown to be
  \begin{gather*}
    V(x,\dot{x})=m\dot{x}^2/2+k_0x^2/2+k_1x^4/4>0, \qquad V(0,0)=0\\
    % 
    \frac{d}{dt}{V}(x,\dot{x})=m\dot{x}\ddot{x}+k_0x\dot{x}+k_1x^3\dot{x}
    =-b\vert\dot{x}\vert^3<0, \quad \dot{x}\neq 0
  \end{gather*}

\end{frame}
% ----------------------------------------------------------------------


\begin{frame}
  \frametitle{Stability Definitions}

   An equilibrium point $x=0$ of $\dot{x}=f(x)$ is

   \textbf{locally stable}, if for every $R>0$ there exists $r>0$, such
  that
  \begin{equation*}
     \Vert x(0)\Vert<r \quad\Rightarrow\quad \Vert x(t)\Vert<R,
     \quad t\geq 0
   \end{equation*}
   \pause
   \textbf{locally asymptotically stable}, if locally stable and
   \begin{equation*}
     \Vert x(0)\Vert<r \quad\Rightarrow\quad \lim_{t\rightarrow\infty}x(t)=0
   \end{equation*}
   \pause
   \textbf{globally asymptotically stable}, if asymptotically stable
   for all $x(0)\in\mathbf{R}^n$.
\end{frame}
%%%%----------------------------------------------------------------------
\begin{frame}
\frametitle{Lyapunov Theorem for Local Stability}

\textbf{Theorem} 
Let $\dot{x}=f(x)$, $f(0)=0$, and $0\in\Omega\subset\mathbf{R}^n$.
Assume that $V:\Omega\rightarrow\mathbf{R}$ is a $C^1$ function. If 
\begin{itemize}
\item $V(0)=0$
\item $V(x)>0$, for all $x\in\Omega$, $x\neq 0$
\item $\frac{d}{dt}{V}(x)\leq 0$ along all trajectories in $\Omega$
\end{itemize}
then $x=0$ is locally stable. Furthermore, if also
\begin{itemize}
\item $\frac{d}{dt}{V}(x)<0$ for all $x\in\Omega$, $x\neq 0$
\end{itemize}
then $x=0$ is locally asymptotically stable.
\vfill
Proof: see p.~62.
\end{frame} 
% ----------------------------------------------------------------------
\begin{frame}
%
\frametitle{\large Lyapunov Functions ($\approx$ Energy Functions)}

A \emph{Lyapunov function} fulfills $V(x_0)=0$, $V(x)>0$ for $x\in\Omega$,
$x\neq x_0$, and
\begin{equation*}
\dot{V}(x)=\frac{d}{dt}V(x)=\frac{dV}{dx}\dot{x}=\frac{dV}{dx}f(x)\leq 0
\end{equation*}
\medskip
\begin{minipage}{0.49\hsize}
  \begin{center} 
  %\psfrag{v}[l][][0.8]{$V=\hbox{constant}$}
  \includegraphics[width=0.27\hsize]{figures/lyap} 
  \end{center}
\end{minipage}
\begin{minipage}{0.49\hsize}
  \begin{center} 
  %\psfrag{x1}[][]{$x_1$}
  %\psfrag{x2}[][]{$x_2$}
  %\psfrag{V}[][]{$V$}
  \includegraphics[width=0.75\hsize]{figures/lyap_ex} 
  \end{center}
\end{minipage}
\end{frame}
\end{document}
% ----------------------------------------------------------------------
\frame{
%
\frametitle{2 min exercise---Pendulum}

Show that the origin is locally stable for a mathematical pendulum.
\begin{equation*}
  \dot{x}_1=x_2, \quad \dot{x}_2=-\frac{g}{\ell}\sin x_1
\end{equation*}
Use as a Lyapunov function candidate
\begin{equation*}
V(x)=(1-\cos x_1)g\ell+\ell^2x_2^2/2
\end{equation*}
  \begin{center} 
  \psfrag{x1}[][]{$x_1$}
  \psfrag{x2}[][]{$x_2$}
  \includegraphics[width=0.5\hsize]{figures/pend_lyap.ps} 
  \end{center}
} % \end{slide}
% ----------------------------------------------------------------------
%   
%  \frame{
%  \frametitle{Example---Pendulum}
%  \begin{itemize}
%  \item $V(0)=0$
%  \item $V(x)>0$ for $-2\pi<x_1<2\pi$ and $(x_1,x_2)\neq 0$
%  \item 
%  $$
%  \dot{V}(x)=\frac{g}{\ell}\dot{x}_1\sin x_1+x_2\dot{x}_2=0,
%  \qquad\text{for all $x$}
%  $$
%  \end{itemize}
%  Hence, $x=0$ is locally stable. 
%   
%  $x=0$ is not asymptotically stable, because
%  $\dot{V}(x)=0$ for all $x$. 
%  } % \end{slide}
% ----------------------------------------------------------------------
\frame{
%
\frametitle{Lyapunov Theorem for Global Stability}

\textbf{Theorem} 
Let $\dot{x}=f(x)$ and $f(0)=0$.
Assume that $V:\mathbf{R}^n\rightarrow\mathbf{R}$ is a $C^1$ function. If 
\begin{itemize}
\item $V(0)=0$
\item $V(x)>0$, for all $x\neq 0$
\item $\dot{V}(x)< 0$ for all $x\neq 0$
\item $V(x)\rightarrow\infty$ as $\Vert x\Vert\rightarrow\infty$
\end{itemize}
then $x=0$ is globally asymptotically stable.
} % \end{slide}
% ----------------------------------------------------------------------
\frame{
%
\frametitle{Radial Unboundedness is Necessary}

If the condition $V(x)\rightarrow\infty$ as $\Vert
x\Vert\rightarrow\infty$ is not fulfilled, then global stability
cannot be guaranteed. 

\textbf{Example} Assume $V(x)=x_1^2/(1+x_1^2)+x_2^2$
is a Lyapunov function for a system. Can have $\Vert x\Vert\rightarrow\infty$
even if $\dot{V}(x)<0$. 

\medskip
\centerline{Contour plot $V(x)=C$:}
\begin{center}
  \psfrag{x1}[][]{$x_1$}
  \psfrag{x2}[][]{$x_2$}
\includegraphics[width=0.4\hsize]{figures/count_cont.ps} 
\end{center}
} % \end{slide}
% ----------------------------------------------------------------------
\frame{
%
\frametitle{Positive Definite Matrices}

A matrix $M$ is \textbf{positive definite} if $x^TMx>0$ for all $x\neq
0$.\\
 It is \textbf{positive semidefinite} if $x^TMx\geq 0$ for
all $x$.  

A symmetric matrix $M=M^T$ is positive definite if and only if its
eigenvalues $\lambda_i>0$. (\emph{semidefinite} $\Leftrightarrow$
$\lambda_i\geq 0$) 

Note that if $M=M^T$ is positive definite, then the Lyapunov function
candidate $V(x)=x^TMx$ fulfills $V(0)=0$ and $V(x)>0$ for all $x\neq
0$. 
} % \end{slide}
% ----------------------------------------------------------------------
\frame{
%
\frametitle{More matrix results}

A symmetric matrix $M=M^T$ satisfies the inequalities 
$$
 \lambda_{\min}(M)\Vert x\Vert^2\enskip  \leq \enskip x^TMx \enskip
\leq \enskip \lambda_{\max}(M)\Vert x\Vert^2
$$

(To show it, use the factorization $M=U\Lambda U^*$, where $U$ is a
unitary matrix, $\Vert
Ux\Vert=\Vert x\Vert$, $U^*$ is complex conjugate transpose, and
$\Lambda=\text{diag}(\lambda_1,\dots,\lambda_n)$.)

For any matrix $M$ one also has
\[
\Vert Mx \Vert \enskip \leq \enskip \lambda^{1/2}_{\max}(M^TM) \Vert x \Vert
\]
% Horn & Johnsson p 176
} % \end{slide}
% ----------------------------------------------------------------------
\frame{
%
\frametitle{Lyapunov Function for Linear System}

\textbf{Theorem} 
The eigenvalues $\lambda_i$ of $A$ satisfy
$\text{Re} \,\lambda_i<0$ if and only if: for every positive definite
$Q=Q^T$ there exists a positive definite $P=P^T$ such that
$$
PA+A^TP=-Q
$$
\emph{Proof of \underline{$\exists Q,P \Rightarrow \text{Re} \,\lambda_i(A)<0$}:}
Consider $\dot{x}=Ax$ and the Lyapunov function
candidate $V(x)=x^TPx$. 
$$
\dot{V}(x)=x^TP\dot{x}+\dot{x}^TPx=x^T(PA+A^TP)x=-x^TQx<0, \quad
\forall x\neq 0
$$
$$
\Rightarrow\quad \dot{x}=Ax \quad\text{asymptotically
  stable}\quad\Longleftrightarrow\qquad \text{Re}\, \lambda_i<0
$$
\emph{Proof of \underline{$\text{Re}\,
    \lambda_i(A)<0 \Rightarrow \exists Q,P$:}}
Choose $P=\int_0^{\infty}e^{A^Tt}Qe^{At}dt$
} % \end{slide}
% ----------------------------------------------------------------------
\frame{
%
\frametitle{Lyapunov's Linearization Method}

Recall from Lecture~2:

\textbf{Theorem}
Consider 
$$
\dot{x}=f(x)
$$
Assume that $x=0$ is an equilibrium point and that
$$
\dot{x}=Ax+g(x)
$$
is a linearization. 
\begin{itemize}
\item[(1)] If $\text{Re}\,\lambda_i(A)<0$ for all $i$, then $x=0$ is locally
  asymptotically stable. 
\item[(2)] If there exists $i$ such that $\lambda_i(A)>0$, 
then $x=0$ is unstable.
\end{itemize}
} % \end{slide}
% ----------------------------------------------------------------------
\frame{
%
\frametitle{Proof of (1) in Lyapunov's Linearization Method}

Lyapunov function candidate $V(x)=x^TPx$. $V(0)=0$, $V(x)>0$ for
$x\neq 0$, and
\begin{align*}
\dot{V}(x)&=x^TPf(x)+f^T(x)Px\\
&=x^TP[Ax+g(x)]+[x^TA+g^T(x)]Px\\
&=x^T(PA+A^TP)x+2x^TPg(x)=-x^TQx+2x^TPg(x)
\end{align*}
$$
x^TQx\geq\lambda_{\min}(Q)\Vert x\Vert^2
$$
and for all $\gamma>0$ there exists $r>0$ such that
$$
\Vert g(x)\Vert<\gamma\Vert x\Vert, \qquad \forall\Vert x\Vert<r
$$
Thus, choosing $\gamma$ sufficiently small gives
$$
\dot{V}(x)\leq-\big(\lambda_{\min}(Q)-2\gamma\lambda_{\max}(P)\big)\Vert x\Vert^2<0
$$ 
} % \end{slide}
% ----------------------------------------------------------------------
\frame{
%
\frametitle{Invariant Sets}


\textbf{Definition} A set $M$ is called \textbf{invariant} if for 
the system
$$
\dot{x}=f(x),
$$
$x(0)\in M$ implies that $x(t)\in M$ for all  $t\geq 0$.

\medskip
\begin{center}
  \psfrag{x0}[][]{$x(0)$}
  \psfrag{xt}[][]{$x(t)$}
  \psfrag{M}[][]{$M$}
\includegraphics[width=0.5\hsize]{figures/invariant_set.eps} 
\end{center}
} % \end{slide}
% ----------------------------------------------------------------------
\frame{
%
\frametitle{Invariant Set Theorem}

\textbf{Theorem} Let $\Omega\in\mathbf{R}^n$ be a bounded and closed set 
that is invariant with respect to
$$
\dot{x}=f(x).
$$
Let $V:\mathbf{R}^n\rightarrow\mathbf{R}$ be a radially unbounded
$C^1$ function such that 
$\dot{V}(x)\leq 0$ for $x\in\Omega$. Let $E$ be the set of points
in $\Omega$ where $\dot{V}(x)=0$. If $M$ is the largest invariant set in
$E$, then every solution with $x(0)\in\Omega$ approaches $M$ as 
$t\rightarrow\infty$ (proof on p.~73)

\begin{center}
  \psfrag{Om}[][]{$\Omega$}
  \psfrag{E}[][]{$E$}
  \psfrag{M}[][]{$M$}
\includegraphics[width=0.4\hsize]{figures/lyap_invariant.eps} 
\end{center}
} % \end{slide}
%----------------------------------------------------------------------
\frame{
%
\frametitle{Example---Stable Limit Cycle}

Show that $M=\{x:\,\Vert x\Vert= 1\}$ is a globally stable limit cycle for
\begin{align*}
  \dot{x}_1&=x_1-x_2-x_1(x_1^2+x_2^2)\\
  \dot{x}_2&=x_1+x_2-x_2(x_1^2+x_2^2)
\end{align*}

Let $V(x)=(x_1^2+x_2^2-1)^2$. 
\begin{align*}
\frac{dV}{dt}&=2(x_1^2+x_2^2-1)\frac{d}{dt}(x_1^2+x_2^2-1)\\
&=-2(x_1^2+x_2^2-1)^2(x_1^2+x_2^2)\leq 0\quad\text{for } x\in\Omega\\
\end{align*}
$\Omega=\{0<\Vert x\Vert\leq R\}$ is invariant for $R=1$.
} % \end{slide}
%----------------------------------------------------------------------
\frame{
%
\frametitle{Example---Stable Limit Cycle}

\begin{equation*}
E=\{x\in\Omega:\,\dot{V}(x)=0\}=\{x:\,\Vert x\Vert= 1\}
\end{equation*}
$M=E$ is an invariant set, because
\begin{equation*}
\frac{d}{dt}V=-2(x_1^2+x_2^2-1)(x_1^2+x_2^2)=0\quad\text{for
  } x\in M
\end{equation*}

We have shown that $M$ is a stable limit cycle (globally stable in 
$R-\{0\}$)
  \begin{center} 
  \includegraphics[height=0.3\hsize]{figures/guck.eps} 
  \end{center}

} % \end{slide}
% ----------------------------------------------------------------------
\frame{
%
\frametitle{A Motivating Example (cont'd)}

$$
m\ddot{x}=-b\dot{x}\vert\dot{x}\vert-k_0x-k_1x^3
$$
$$
V(x,\dot{x})=(2m\dot{x}^2+2k_0x^2+k_1x^4)/4>0, \qquad V(0,0)=0
$$
$\dot{V}(x,\dot{x})=-b\vert\dot{x}\vert^3$ gives 
$E=\{(x,\dot{x}):\,\dot{x}=0\}$.

Assume there exists $(\bar{x},\dot{\bar{x}})\in M$ such that 
$\bar{x}(t_0)\neq 0$. Then
$$
m\ddot{\bar{x}}(t_0)=-k_0\bar{x}(t_0)-k_1\bar{x}^3(t_0)\neq 0
$$
so $\dot{\bar{x}}(t_0+)\neq 0$ so the trajectory will immediately
leave $M$. A contradiction to that $M$ is invariant.  

Hence, $M=\{(0,0)\}$ so the origin is asymptotically stable.
} % \end{slide}

%----------------------------------------------------------------------
\frame{
%
\frametitle{Adaptive Noise Cancellation by Lyapunov Design}

  \begin{center} 
  \psfrag{u}[][]{$u$}
  \psfrag{g1}[][][1.4]{$\frac{b}{s+a}$}
  \psfrag{g2}[][][1.4]{$\frac{\widehat b}{s+\widehat a}$}
  \psfrag{x}[][]{$x$}
  \psfrag{xh}[][]{$\widehat x$}
  \psfrag{xt}[][]{$\widetilde x$}
  \psfrag{+}[][]{$+$}
  \psfrag{-}[][]{$-$}
  \includegraphics[width=0.4\hsize]{figures/noise.eps} 
  \end{center}
\begin{align*}
\dot x +a x &= bu\\
\dot{\widehat x} + \widehat a \widehat x &= \widehat b u
\end{align*}
Introduce $\widetilde x = x-\widehat x, \enskip\widetilde a =
a-\widehat a, \enskip \widetilde b = b-\widehat b$.

Want to design adaptation law so that $\widetilde x\to 0$
} % \end{slide}

\frame{
Let us try the Lyapunov function
\begin{align*}
V&=\frac{1}{2}(\widetilde x^2+\gamma_a\widetilde a^2+\gamma_b\widetilde
b^2)\\
\dot V &= \widetilde x \dot{\widetilde x} + \gamma_a \widetilde a
\dot{\widetilde a} + \gamma_b \widetilde b
\dot{\widetilde b} = \\
&=\widetilde x(-a\widetilde x-\widetilde a \widehat x + \widetilde b
u) + \gamma_a \widetilde a
\dot{\widetilde a} + \gamma_b \widetilde b
\dot{\widetilde b} = -a \widetilde x^2 
\end{align*}
where the last equality follows if we choose
\begin{align*}
\dot{\widetilde a} = -\dot{\widehat a} = \frac{1}{\gamma_a} \widetilde{x} \widehat x \qquad
\dot{\widetilde b} = -\dot{\widehat b} = -\frac{1}{\gamma_b} \widetilde{x} u 
\end{align*}
Invariant set: $\widetilde x =0$.

This proves that $\widetilde x \to 0$. 

(The parameters $\widetilde a$ and $\widetilde b$
do not necessarily converge:  $u\equiv 0$.) 

\fbox{Demonstration if time permits}
} % \end{slide}
%%------------------------------
\frame{
\frametitle{Results}
  \begin{center} 
  \psfrag{p1}[][][1.3]{$\hat{a}$}
  \psfrag{p2}[][][1.3]{$\hat{b}$}
  \includegraphics[width=0.7\hsize]{musik/parameters.eps} \\
     Estimation of parameters starts at t=10 s.      
  \end{center}
} % \end{slide}

%----------------------------------------------------------------------
\frame{
\frametitle{Results}
  \begin{center} 
  \psfrag{x-xhat}[][][1.3]{$x-\hat{x}$}
  \includegraphics[width=0.6\hsize,angle=0]{musik/adap.ps} \\
  \includegraphics[width=0.3\hsize]{musik/xt.eps} 
  \end{center}
  \begin{center}
    \begin{small}
     Estimation of parameters starts at t=10 s.      
    \end{small}
  \end{center}
} % \end{slide}

%----------------------------------------------------------------------
\frame{
%
\frametitle{Next Lecture}

\begin{itemize}
\item Stability analysis using input-output (frequency) methods
\end{itemize}
 
\vfill
} % \end{slide}
%----------------------------------------------------------------------
\end{document}


