Chapter 9: Lyapunov Analysis
Optimal control provides a powerful framework for formulating control problems using the language of optimization. But solving optimal control problems for nonlinear systems is hard! In many cases, we don't really care about finding the optimal controller, but would be satisfied with any controller that is guaranteed to accomplish the specified task. In many cases, we still formulate these problems using computational tools from optimization, and in this chapter we'll learn about tools that can provide guaranteed control solutions for systems that are beyond the complexity for which we can find the optimal feedback.
There are many excellent books on Lyapunov analysis; for instance [1] is an excellent and very readable reference and [2] can provide a rigorous treatment. In this chapter I will summarize (without proof) some of the key theorems from Lyapunov analysis, but then will also introduce a number of numerical algorithms... many of which are new enough that they have not yet appeared in any mainstream textbooks.
Lyapunov Functions
Let's start with our favorite simple example.
Example: Stability of the Damped Pendulum
Recall that the equations of motion of the damped simple pendulum are given by
which I've written with the damping on the right-hand side to remind us that it is an external torque that we've modeled.These equations represent a simple second-order differential equation; in chapter 2 we discussed at some length what was known about the solutions to this differential equation--in practice we do not have a closed-form solution for as a function of the initial conditions. Since we couldn't provide a solution analytically, in chapter 2 we resorted to a graphical analysis, and confirmed the intuition that there are fixed points in the system (at for every integer ) and that the fixed points at are asymptotically stable with a large basin of attraction. The graphical analysis gave us this intuition, but can we actually prove this stability property? In a way that might also work for much more complicated systems?
One route forward was from looking at the total system energy (kinetic
- potential), which we can write down:
Recall that the contours of this energy function are the orbits of the undamped pendulum.
A natural route to proving the stability of the downward fixed points is by arguing that energy (almost always) decreases for the damped pendulum () and so the system will eventually come to rest at the minimum energy, , which happens at . Let's make that argument slightly more precise.
Evaluating the time derivative of the energy reveals
So we know that energy will never increase, that energy is bounded, and that it obtains it's minima at the downward (stable) fixed points. Moreover, we now know that energy is strictly decreasing whenever . We're getting close.In order to show that the system converges asymptotically to some fixed point, we need one more observation. For non-fixed-point states with , we have , but only for an instant. A moment later, we'll have some non-zero velocity once again, and again start dissipating energy. All together, these arguments are sufficient to demonstrate that a fixed point as . We'll make this argument more general and more precise below.
This is an important example. It demonstrated that we could use a relatively simple function -- the total system energy -- to describe something about the long-term dynamics of the pendulum even though the actual trajectories of the system are (analytically) very complex. It also demonstrated one of the subtleties of using an energy-like function that is non-increasing (instead of strictly decreasing) to prove asymptotic stability.
Lyapunov functions generalize this notion of an energy function to more general systems, which might not be stable in the sense of some mechanical energy. If I can find any positive function, call it , that gets smaller over time as the system evolves, then I can potentially use to make a statement about the long-term behavior of the system. is called a Lyapunov function.
Recall that we defined three separate notions for stability of a fixed-point of a nonlinear system: stability i.s.L., asymptotic stability, and exponential stability. We can use Lyapunov functions to demonstrate each of these, in turn.
Theorem: Lyapunov's Direct Method (for local stability)
Given a system , with continuous, and for some region around the origin (specifically an open subset of containing the origin), if I can produce a scalar, continuously-differentiable function , such that \begin{gather*} V(\bx) > 0, \forall \bx \in {\cal D} \setminus {0} \quad V(0) = 0, \text{ and} \ \dot{V}(\bx) = \pd{V}{\bx} f(\bx) \le 0, \forall \bx \in {\cal D} \setminus {0} \quad \dot{V}(0) = 0, \end{gather*} then the origin is stable in the sense of Lyapunov (i.s.L.). [Note: the notation represents the set with the elements of removed.]
If, additionally, we have
then the origin is (locally) asymptotically stable. And if we havefor some then the origin is (locally) exponentially stable.
Note that for the sequel we will use the notation to denote a positive-definite function, meaning that and for all . We can use "positive definite in " if this applies . Similarly, we'll use for positive semi-definite, for negative-definite functions, etc.
The intuition here is exactly the same as for the energy argument we made in the pendulum example: since is always zero or negative, the value of will only get smaller (or stay the same) as time progresses. Inside the subset , for every -ball, I can choose a such that $|x(0)|^2 < \delta \Rightarrow |x(t)|^2 < \epsilon, \forall t$ by choosing sufficiently small so that the sublevel set of for the largest value that takes in the ball is completely contained in the ball. Since the value of can only get smaller (or stay constant) in time, this gives stability i.s.L.. If is strictly negative away from the origin, then it must eventually get to the origin (asymptotic stability). The exponential condition is implied by the fact that $\forall t>0, V(\bx(t)) \le V(\bx(0)) e^{-\alpha t}.$
Notice that the system analyzed above, , did not have any control inputs. Lyapunov analysis is used to study either the passive dynamics of a system or the dynamics of a closed-loop system (e.g. the plant and controller connected in a feedback loop). We will see generalizations of the Lyapunov function ideas to input-output systems later in the text.
Global Stability
The notion of a fixed point being stable i.s.L. is inherently a local notion of stability (defined with and balls around the origin), but the notions of asymptotic and exponential stability can be applied globally. The Lyapunov theorems work for this case, too, with only minor modification.
Theorem: Lyapunov analysis for global stability
Given a system , with continuous, if I can produce a scalar, continuously-differentiable function , such that \begin{gather*} V(\bx) \succ 0, \ \dot{V}(\bx) = \pd{V}{\bx} f(\bx) \prec 0, \text{ and} \ V(\bx) \rightarrow \infty \text{ whenever } ||\bx||\rightarrow \infty,\end{gather*} then the origin is globally asymptotically stable (G.A.S.).
If additionally we have that
for some , then the origin is globally exponentially stable.
The new condition, on the behavior as is known as "radially unbounded", and is required to make sure that trajectories cannot diverge to infinity even as decreases; it is only required for global stability analysis. This radially unbounded condition is sufficient but is not necessary; other conditions can potentially be invoked to guarantee that the system avoids this pathology. More essential is that the resulting trajectory is bounded for all .
LaSalle's Invariance Principle
Perhaps you noticed the disconnect between the statement above and the argument that we made for the stability of the pendulum. In the pendulum example, using the mechanical energy resulted in a Lyapunov function time derivative that was only negative semi-definite, but we eventually argued that the fixed points were asymptotically stable. That took a little extra work, involving an argument about the fact that the fixed points were the only place that the system could stay with ; every other state with was only transient. We can formalize this idea for the more general Lyapunov function statements--it is known as LaSalle's Theorem.
Theorem: LaSalle's Theorem
Given a system with continuous. If we can produce a scalar function with continuous derivatives for which we have
and as , then will converge to the largest invariant set where $\dot{V}(\bx) = 0$.
To be clear, an invariant set, , of the dynamical system is a set for which $\bx(0)\in{\cal G} \Rightarrow \forall t>0, \bx(t) \in {\cal G}$. In other words, once you enter the set you never leave. The "largest invariant set" with need not be connected; in fact for the pendulum example each fixed point is an invariant set with , so the largest invariant set is the union of all the fixed points of the system. There are also variants of LaSalle's Theorem which work over a region. For example, the total energy of the pendulum does not actually satisfy the radially-unbounded condition (the energy is finite as ), but observing that is bounded for all initial conditions is sufficient to invoke a variant of LaSalle's theorem [2, §4.2].
Finding a Lyapunov function which is more difficult than finding one that has . LaSalle's theorem gives us the ability to make a statement about asymptotic stability even in this case. In the pendulum example, every state with had , but only the fixed points are in the largest invariant set.
Example: Swing-up for the Cart-Pole System
Recall the example of using partial-feedback linearization to generate a swing-up controller for the cart-pole system. We first examined the dynamics of the pole (pendulum) only, by writing it's energy:
desired energy, , and the difference We were able to show that our proposed controller producedwhere is a positive gain that we get to choose. And we said that was good!Now we have the tools to understand that really we have a Lyapunov function
and what we have shown is that . By LaSalle, we can only argue that the closed-loop system will converge to the largest invariant set, which here is the entire homoclinic orbit: . We have to switch to the LQR controller in order to stabilize the upright.▶ Embedded content: https://underactuated.mit.edu/data/cartpole_swingup_V.html
Lyapunov function:
▶ Embedded content: https://underactuated.mit.edu/data/cartpole_swingup_Vdot.html
Time-derivative of the Lyapunov function:
As you can see from the plots, ends up being a quite non-trivial function! We'll develop the computational tools for verifying the Lyapunov/LaSalle conditions for systems of this complexity in the upcoming sections.
Relationship to the Hamilton-Jacobi-Bellman equations
At this point, you might be wondering if there is any relationship between Lyapunov functions and the cost-to-go functions that we discussed in the context of dynamic programming. After all, the cost-to-go functions also captured a great deal about the long-term dynamics of the system in a scalar function. We can see the connection if we re-examine the HJB equation
Lyapunov functions for estimating regions of attraction
There is another very important connection between Lyapunov functions and the concept of an invariant set: any sublevel set of a Lyapunov function is also an invariant set. This gives us the ability to use sublevel sets of a Lyapunov function as approximations of the region of attraction for nonlinear systems. For a locally attractive fixed point, , the region of attraction to is the largest set for which $\bx(0) \in {\cal D} \Rightarrow \lim_{t\rightarrow \infty} \bx(t) = \bx^*.$ Regions of attraction are always open, connected, and invariant sets (with boundaries ).
Theorem: Lyapunov invariant set and region of attraction theorem
Given a system with continuous, if we can find a scalar function and a bounded sublevel set
on whichthen is an invariant set. By LaSalle, will converge to the largest invariant subset of ${\cal G}$ on which . If in , then the origin is locally asymptotically stable and furthermore the set is inside the region of attraction of this fixed point. Alternatively, if in and is the only invariant subset of where , then the origin is asymptotically stable and the set is inside the region of attraction of this fixed point.
Example: Region of attraction for a one-dimensional system
Consider the first-order, one-dimensional system $\dot{x} = -x + x^3.$ We can quickly understand this system using our tools for graphical analysis.
In the vicinity of the origin, looks like , and as we move away it looks increasingly like . There is a stable fixed point at the origin and unstable fixed points at . In fact, we can deduce visually that the region of attraction to the stable fixed point at the origin is . Let's see if we can demonstrate this with a Lyapunov argument.
First, let us linearize the dynamics about the origin and use the Lyapunov equation for linear systems to find a candidate . Since the linearization is , if we take , then we find is the positive definite solution to the algebraic Lyapunov equation (\ref{eq:algebraic_lyapunov}). Proceeding with
we haveThis function is zero at the origin, negative for , and positive for . Therefore we can conclude that the sublevel set is invariant and the set is inside the region of attraction of the nonlinear system. In fact, this estimate is tight.
Robustness analysis using "common Lyapunov functions"
While we will defer most discussions on robustness analysis until later in the notes, the idea of a common Lyapunov function, which we introduced briefly for linear systems in the example above, can be readily extended to nonlinear systems and region of attraction analysis. Imagine that you have a model of a dynamical system but that you are uncertain about some of the parameters. For example, you have a model of a quadrotor, and are fairly confident about the mass and lengths (both of which are easy to measure), but are not confident about the moment of inertia. One approach to robustness analysis is to define a bounded uncertainty, which could take the form of
In standard Lyapunov analysis, we are searching for a function that goes downhill for all to make statements about the long-term dynamics of the system. In common Lyapunov analysis, we can make many similar statements about the long-term dynamics of an uncertain system if we can find a single Lyapunov function that goes downhill for all possible values of . If we can find such a function, then we can use it to make statements with all of the variations we've discussed (local, regional, or global; in the sense of Lyapunov, asymptotic, or exponential).
Example: A one-dimensional system with gain uncertainty
Let's consider the same one-dimensional example used above, but add an uncertain parameter into the dynamics. In particular, consider the system:
Plotting the graph of the one-dimensional dynamics for a few values of , we can see that the fixed point at the origin is still stable, but the robust region of attraction to this fixed point (shaded in blue below) is smaller than the region of attraction for the system with .
Taking the same Lyapunov candidate as above, , we have
This function is zero at the origin, and negative for all whenever , orTherefore, we can conclude that is inside the robust region of attraction of the uncertain system.
Not all forms of uncertainty are as simple to deal with as the gain uncertainty in that example. For many forms of uncertainty, we might not even know the location of the fixed points of the uncertain system. In this case, we can often still use common Lyapunov functions to give some guarantees about the system, such as guarantees of robust set invariance. For instance, if you have uncertain parameters on a quadrotor model, you might be ok with the quadrotor stabilizing to a pitch of $0.01$ radians, but you would like to guarantee that it definitely does not flip over and crash into the ground.
Example: A one-dimensional system with additive uncertainty
Now consider the system:
Plotting the graph of the one-dimensional dynamics for a few values of , this time we can see that the fixed point is not necessarily at the origin; the location of the fixed point moves depending on the value of . But we should be able to guarantee that the uncertain system will stay near the origin if it starts near the origin, using an invariant set argument.
Taking the same Lyapunov candidate as above, , we have
This Lyapunov function allows us to easily verify, for instance, that is a robust invariant set, because whenever , we haveTherefore can never start at less than one-third and cross over to greater than one-third. To see this, see thatNote that not all sublevel sets of this invariant set are invariant. For instance $V < \frac{1}{32}$ does not satisfy this condition, and by visual inspection we can see that it is in fact not robustly invariant.
Barrier functions
Lyapunov functions are used to certify stability or to establish invariance of a region. But the same conditions can be used to certify that the state of a dynamical system will not visit some region of state space. This can be useful for e.g. verifying that your autonomous car will not crash or, perhaps, that your walking robot will not fall down. When used this way, we call the associated functions, , "barrier functions".
Theorem: Barrier functions
Given a continuously-differentiable dynamical system described by , if I can find a function such that , then the system will never visit states with $\mathcal{B}(\bx(t)) > \mathcal{B}(\bx(0)).$ In particular, if we ensure that in "failure" regions of state space, we have , then the level-set can serve as a barrier certifying that trajectories starting with initial conditions with $\mathcal{B}(\bx) < 0$ will never enter the failure set.
Natural extensions exist for certifying these conditions over a region, considering piecewise-polynomial dynamics, worse-case robustness, etc.
Lyapunov analysis with convex optimization
One of the primary limitations in Lyapunov analysis as I have presented it so far is that it is potentially very difficult to come up with suitable Lyapunov function candidates for interesting systems, especially for underactuated systems. ("Underactuated" is almost synonymous with "interesting" in my vocabulary.) Even if somebody were to give me a Lyapunov candidate for a general nonlinear system, the Lyapunov conditions can be difficult to check -- for instance, how would I check that is strictly negative for all except the origin if is some arbitrarily complicated nonlinear function over a vector ?
In this section, we'll look at some computational approaches to verifying the Lyapunov conditions, and even to searching for (the coefficients of) the Lyapunov functions themselves.
If you're imagining numerical algorithms to check the Lyapunov conditions for complicated Lyapunov functions and complicated dynamics, the first thought is probably that we can evaluate and at a large number of sample points and check whether is positive and is negative. This does work, and could potentially be combined with some smoothness or regularity assumptions to generalize beyond the sample points. But in many cases we will be able to do better -- providing optimization algorithms that will rigorously check these conditions for all without dense sampling; these will also give us additional leverage in formulating the search for Lyapunov functions.
Linear systems
The Lyapunov conditions we've explored above take a particularly nice form for linear systems.
Theorem: Lyapunov analysis for stable linear systems
Imagine you have a linear system, , and can find a Lyapunov function
which also satisfiesThen the origin is globally exponentially stable.
Note that the radially-unbounded condition is satisfied by ${\bf P} \succ 0$, and that the derivative condition is equivalent to the matrix condition
For stable linear systems the existence of a quadratic Lyapunov function is actually a necessary (as well as sufficient) condition. Furthermore, if is stable, then a Lyapunov function can always be found by finding the positive-definite solution to the matrix Lyapunov equation \begin{equation}{\bf PA} + {\bf A}^T{\bf P} = - {\bf Q},\label{eq:algebraic_lyapunov} \end{equation} for any ${\bf Q}={\bf Q}^T\succ 0$.
This is a very powerful result - for nonlinear systems it will be potentially difficult to find a Lyapunov function, but for linear systems it is straightforward. In fact, this result is often used to propose candidate Lyapunov functions for nonlinear systems, e.g., by linearizing the equations and solving a local linear Lyapunov function which should be valid in the vicinity of a fixed point.
Lyapunov analysis for linear systems has an extremely important connection to convex optimization. In particular, we could have also formulated the Lyapunov conditions for linear systems above using semi-definite programming (SDP). Semidefinite programming is a subset of convex optimization -- an extremely important class of problems for which we can produce efficient algorithms that are guaranteed find the global optima solution (up to a numerical tolerance and barring any numerical difficulties).
If you don't know much about convex optimization or want a quick refresher, please take a few minutes to read the optimization preliminaries in the appendix. The main requirement for this section is to appreciate that it is possible to formulate efficient optimization problems where the constraints include specifying that one or more matrices are positive semi-definite (PSD). These matrices must be formed from a linear combination of the decision variables. For a trivial example, the optimization
The value in this is immediate for linear systems. For example, we can formulate the search for a Lyapunov function for the linear system by using the parameters to populate a symmetric matrix and then write the SDP: \begin{equation} \find_{\bf p} \quad \subjto \quad {\bf P} \succeq 0, \quad {\bf PA} + {\bf A}^T {\bf P} \preceq 0.\label{eq:lyap} \end{equation} Note that you would probably never use that particular formulation, since there specialized algorithms for solving the simple Lyapunov equation which are more efficient and more numerically stable. But the SDP formulation does provide something new -- it will give us our first example of robustness analysis. In particular, we can now easily formulate the search for a "common Lyapunov function" for uncertain linear systems.
Example: Common Lyapunov analysis for linear systems
Suppose you have a system governed by the equations $\dot\bx = {\bf A}\bx$, where the matrix is unknown, but its uncertain elements can be bounded. There are a number of ways to write down this uncertainty set; let us choose to write this by describing as the convex combination of a number of known matrices,
This is just one way to specify the uncertainty; geometrically it is describing a polygon of uncertain parameters (in the space of elements of with each as one of the vertices in the polygon.
Now we can formulate the search for a common Lyapunov function using
The solver will then return a matrix which satisfies all of the constraints, or return saying "problem is infeasible". It can easily be verified that if satisfies the Lyapunov condition at all of the vertices, then it satisfies the condition for every in the set:since , . Note that, unlike the simple Lyapunov equation for a known linear system, this condition being satisfied is a sufficient but not a necessary condition -- it is possible that the set of uncertain matrices is robustly stable, but that this stability cannot be demonstrated with a common quadratic Lyapunov function.You can try this example for yourself in Drake.
As always, make sure that you open up the code and take a look.
Note that the argument above does not actually make use of the that assumption can be safely removed. So really, our common Lyapunov function, when found, has certified the convex cone with the matrices as the extreme rays. This is not surprising, since if we have any linear system/Lyapunov quadratic form pair , then also confirms that is stable for any $\beta > 0.$ Multiplying a system matrix by a scalar will not change the sign of its eigenvalues.
There are many small variants of this result that are potentially of interest. For instance, a very similar set of conditions can certify "mean-square stability" for linear systems with multiplicative noise (see e.g. [3], § 9.1.1).
This example is very important because it establishes a connection between Lyapunov functions and (convex) optimization. But so far we've only demonstrated this connection for linear systems where the PSD matrices provide a magical recipe for establishing the positivity of the (quadratic) functions for all . Is there any hope of extending this type of analysis to more general nonlinear systems? Surprisingly, it turns out that there is.
Global analysis for polynomial systems
Sums of squares (SOS) optimization provides a natural generalization of the SDP formulation to nonlinear systems. In SDP, we were allowed to write constraints of the form, . In sums of squares optimization, we generalize this to writing constraints of the form " is SOS", where is a polynomial with coefficients . Let's examine this in the specific context of Lyapunov functions.
In linear systems, we searched over $V(\bx) = \bx^T {\bf P} \bx, {\bf P} \succeq 0.$ In the nonlinear generalization, we search over
This suggests that it may be possible to generalize the optimization approach using SDP to search for Lyapunov functions for linear systems to searching for Lyapunov functions for nonlinear systems: $\dot\bx = \bf{f}(\bx),$ where is a vector-valued polynomial function. Importantly, if is polynomial, and is polynomial, then is also polynomial.
If we parameterize a fixed-degree Lyapunov candidate as a polynomial with unknown coefficients, e.g.,
If we wish to demonstrate (global) asymptotic stability, then we can write the constraint as
Example: Verifying a Lyapunov candidate via SOS
This example is example 7.2 from [4]. Consider the nonlinear system: \begin{align*} \dot{x}_0 =& -x_0 - 2x_1^2 \ \dot{x}_1 =& -x_1 - x_0 x_1 - 2x_1^3,\end{align*} and the fixed Lyapunov function , test if is negative definite.
The numerical solution can be written in a few lines of code, and is a convex optimization.
Example: Searching for a Lyapunov function via SOS
Verifying a candidate Lyapunov function is all well and good, but the real excitement starts when we use optimization to find the Lyapunov function. In the following code, we parameterize as the polynomial containing all monomials up to degree 2, with the coefficients as decision variables:
We will set the scaling (arbitrarily) to avoid numerical issues by setting , $V([1,0]) = 1$. Then we write: \begin{align*} \find_{\bc} \ \ \subjto \ \ & V\text{ is sos, } \ & -\dot{V} \text{ is sos.}\end{align*} Up to numerical convergence tolerance, it discovers the same coefficients that we chose above (zeroing out the unnecessary terms).
Example: Cart-pole swingup (again)
In the cart-pole swingup example, we took
This is clearly a sum of squares. Furthermore, we showed thatwhich is also a sum of squares. So the proposal of using sums-of-squares optimization is not so different, actually, than the recipes that nonlinear control theorists have been using (on pen and paper) for years.The SOS approach, as presented so far, could take only the nonlinear basis, for the candidate Lyapunov function, the degree of that Lyapunov function, and the closed-loop nonlinear dynamics; it would recover the parameters of a Lyapunov function and a certificate demonstrating the and are SOS. In this case, I would need a basis vector that includes many more monomials: $[1, \dot\theta, \cos\theta, ..., \dot\theta^3, ... ]^T.$ You might have noticed that I did something sneaky in here. The dynamics of the cart-pole are not simply polynomial in ; there are trigonometric terms in there. Setting up the equality constraints in an optimization requires more complicated term matching when trigonometric functions are involved, but the recipe still works. We will discuss this in more detail below.
It is important to remember that there are a handful of gaps which make the existence of this solution a sufficient condition (to guarantee that is a Lyapunov function for ) instead of a necessary one. First, there is no guarantee that a stable polynomial system can be verified using a polynomial Lyapunov function (of any degree), and in fact there are known counter-examples [5]; here we are only searching over a fixed-degree polynomial. Second, even if a polynomial Lyapunov function does exist, there is a gap between the SOS polynomials and the positive polynomials[6, §3.1].
Despite these caveats, I have found this formulation to be surprisingly effective in practice. Intuitively, I think that this is because there is relatively a lot of flexibility in the Lyapunov conditions -- if you can find one function which is a Lyapunov function for the system, then there are also many "nearby" functions which will satisfy the same constraints. This is the fundamental benefit of changing the equality in the HJB into an inequality in Lyapunov analysis.
Region of attraction estimation for polynomial systems
Now we have arrived at the tool that I believe can be a work-horse for many serious robotics applications. Most of our robots are not actually globally stable. That's not because they are robots -- if you push me hard enough, I will fall down, too! Asking for global stability is too much, but we can instead certify that our closed-loop systems behave well over a sufficiently large region of state space (and potentially for a range of possible parameters or disturbances). One of the simplest versions of this is estimating the region of attraction to a fixed point.
Sums-of-squares optimization effectively gives us an oracle which we can ask: is this polynomial positive for all ? To use this for regional analysis, we have to figure out how to modify our questions to the oracle so that the oracle will say "yes" or "no" when we ask if a function is positive over a certain region which is a subset of . That trick is called the S-procedure. It is closely related to the Lagrange multipliers from constrained optimization, and has deep connections to "Positivstellensatz" from algebraic geometry.
The S-procedure
Consider a scalar polynomial, , and a semi-algebraic set . The term "semi-algebraic set" just means the set is defined by polynomial inequalities (here ). If I can find a polynomial "multiplier", , such that
We can also handle equality constraints with only a minor modification -- we no longer require the multiplier to be positive. If I can find a polynomial "multiplier", , such that
Basic region of attraction formulation
The S-procedure gives us the tool we need to evaluate positivity only over a region of state space, which is precisely what we need to certify the Lyapunov conditions for a region-of-attraction analysis. Let us start with a positive-definite polynomial Lyapunov candidate, , then we can write the Lyapunov conditions:
I think it's easiest to see the details in an example.
Example: Region of attraction for the one-dimensional cubic system
Let's return to our example from above:
and try to use SOS optimization to demonstrate that the region of attraction of the fixed point at the origin is , using the Lyapunov candidateFirst, define the multiplier polynomial,
Then define the optimization \begin{align*} \find_{\bf c} \quad & \ \subjto \quad& - \dot{V}(x) + \lambda(x) (V(x)-1) \sos \ & \lambda(x) \sos \end{align*} You can try these examples for yourself in Drake.
In this example, we only verified that the one-sublevel set of the pre-specified Lyapunov candidate is negative (certifying the ROA that we already understood). More generally, we can replace the 1-sublevel set with any constant value . It is tempting to try to make a decision variable that we could optimize, but this would make the optimization problem non-convex because we would have terms like , , which are bilinear in the decision variables. We need the sums-of-squares constraints to be only linear in the decision variables.
Fortunately, because the problem is convex with fixed (and therefore can be solved reliably), and is just a scalar, we can perform a simple line search on to find the largest value for which the convex optimization returns a feasible solution. This will be our estimate for the region of attraction.
There are a number of variations to this basic formulation; I will describe a few of them below. There are also important ideas like rescaling and degree-matching that can have a dramatic effect on the numerics of the problem, and potentially make them much better for the solvers. But you do not need to master them all in order to use the tools effectively.
The equality-constrained formulation
Here is one important variation for finding the level set of a candidate region of attraction, which turns an inequality in the S-procedure into an equality. This formulation is jointly convex in and , so one can optimize them in a single convex optimization. It appeared informally in an example in [4], and was discussed a bit more in [7].
Under the assumption that the Hessian of is negative-definite at the origin (which is easily checked), we can write \begin{align*} \max_{\rho, \lambda(\bx)} & \quad \rho \ \subjto & \quad (\bx^T\bx)^d (V(\bx) - \rho) + \lambda^T(\bx) \dot{V}(\bx) \text{ is SOS},\end{align*} with a fixed positive integer. As you can see, no longer multiplies the coefficient of . But why does this certify a region of attraction?
You can read the sums-of-squares constraint as certifying the implication that whenever , we have that either $V(\bx) \ge \rho$ OR . Multiplying by some multiple of is just a clever way to handle the "or " case, which is necessary since we expect . This implication is sufficient to prove that whenever , since and are smooth polynomials; we examine this claim in full detail in one of the exercises.
Using the S-procedure with equalities instead of inequalities has the immediate advantage of removing the SOS constraint on But there is a more subtle, and likely more important advantage -- we have more mathematical tools for dealing with algebraic varieties (defined by equality constraints) than for the semi-algebraic sets (defined by inequality constraints). For an important example of how this can be used to dramatically simplify the SOS programs, see for instance [7] which uses sampling on the variety to provide an exact certification (for all ) on the quotient ring, completely removing the need for the Lagrange multiplier terms.
Example: Maximizing the ROA for the cubic polynomial system
Let's return again to our example from above:
and try to use SOS optimization, this time to maximize the sub-level set of our Lyapunov candidate in order to certify the largest ROA that we can using these tools.Again, we define the multiplier polynomial, , but this time we won't require it to be sums-of-squares (here it's a "free" polynomial). Then define the optimization \begin{align*} \max_{\rho} \quad & \ \subjto \quad& x^2 (V(x)-\rho) - \lambda(x)\dot{V}(x) \sos. \end{align*} What degree should we choose for here? Note that has degree 2, so has degree 4, and also has degree 4, so it's possible that even a zero-degree (just a constant) can be sufficient here. Our numerical experiments confirm that this is indeed the case:
Searching for
The machinery so far has used optimization to find the largest region of attraction that can be certified given a candidate Lyapunov function. This is not necessarily a bad assumption. For most stable fixed points, we can certify the local stability with a linear analysis, and this linear analysis gives us a candidate quadratic Lyapunov function that can be used for nonlinear analysis over a region. Practically speaking, when we solve an LQR problem, the cost-to-go from LQR is a good candidate Lyapunov function for the nonlinear system. If we are simply analyzing an existing system, then we can obtain this candidate by solving a Lyapunov equation (Eq \ref{eq:algebraic_lyapunov}).
Recall that there are cases when the stability of the linearization is not informative about the stability of the nonlinear system (if the linearization has only non-negative eigenvalues instead of strictly negative). Can we use our nonlinear tools to certify a region of attraction for these systems, even when the linearization doesn't yield a candidate Lyapunov function? Or perhaps we can certify a larger volume of state space by optimizing our original Lyapunov candidate to maximize the volume of the verified region for the nonlinear system, potentially even considering Lyapunov functions with degree greater than two (the linear analysis will only give quadratic candidates)? Yes. We can use sums-of-squares optimization in those cases, too!
To accomplish this, we'll combine the ideas from our global stability analysis (where we could search for ) with these new tools for regional analysis (where so far we had to fix ). Make a polynomial (of some fixed degree) with the coefficients as decision variables. First we will need to add constraints to ensure that
Unfortunately, the derivative constraint is now nonconvex (bilinear) in the decision variables, since we are searching for both the coefficients of and , and they are multiplied together. The equality-constrained formulation has the same bilinearity, since the coefficients of also appear in . Here we have to resort to some weaker form of optimization. In practice, we have had good practical success (see, for instance [8, 9]) using bilinear alternations:
- Fix and solve for and : \begin{align*} \max_{\rho, \lambda(\bx)} & \quad \rho \ \subjto & \quad (\bx^T\bx)^d (V(\bx) - \rho) + \lambda^T(\bx) \dot{V}(\bx) \text{ is SOS},\end{align*} with a fixed, positive integer. Update Dividing the SOS constraint by shows that this rescaled , with the same , satisfies the constraint in step 2 with the level set . So step 2 is always feasible, and its solution is at least as good (in its objective) as the current .
- Fix and solve for : \begin{align*} \min_{{\bf P}} & \quad \tr({\bf P}) \ \subjto & \quad (\bx^T\bx)^d (V(\bx) - 1) + \lambda^T(\bx) \dot{V}(\bx) \text{ is SOS}, \ & \quad {\bf P} \succeq 0. \end{align*} with the same fixed, positive integer.
These alternations require a feasible initial , which we typically get from solving the quadratic Lyapunov equation or LQR. We often prefer to do those optimizations in the equality-constrained formulation, because we have stronger tools for dealing with that equality constraint [7], but the basic formulation with line search can be used, too, and in some problems can be numerically more robust.
Where did the objective come from? A typical choice for the objective of the alternations is to maximize the volume of the certified region -- for quadratic Lyapunov functions described in our standard quadratic form, , this volume is proportional to Minimizing this volume is a convex optimization[10, §8.4.1], but maximizing the volume is, in general, not. We tend to use a heuristic like minimizing as a surrogate for the true objective [11, §6.3.2], where $\hat{\bf P}$ is the from a previous alternation of the algorithm (or the identity matrix that I've written above), which is a linearization of the true objective[12]. For higher-degree Lyapunov functions, typically we (approximately) maximize the volume of a contained ellipse,
Barring numerical issues, this algorithm is guaranteed to have recursive feasibility and tends to converge in just a few alternations, but there is no guarantee that it finds the optimal solution.
Example: Searching for Lyapunov functions
Example: Estimated regions of attraction need not be convex regions (in state space)
Although we are using convex optimization to find regions of attraction, this does not imply that the regions we are certifying need to be convex. To demonstrate that, let's make a system with a known, non-convex region of attraction. We'll do this by taking some interesting potential function, is SOS, and setting the dynamics to be
which has as the region of attraction.Slightly more general is to write
where ${\bf R}(\theta) = \begin{bmatrix} \cos\theta & \sin\theta \ -\sin\theta & \cos\theta\end{bmatrix}$ is the 2D rotation matrix, and is a constant parameter (not a decision variable nor indeterminate), which still has the same region of attraction.Searching for Lyapunov functions of only degree 2 (quadratics) will, of course, limit our certified regions to convex regions. But if we increase the degree of the Lyapunov function to degree 4, then we can tighten our inner approximation, and indeed certify non-convex regions. While we can use the Lyapunov method for linear systems to initialize quadratic Lyapunov functions, the ability to search for the parameters of the Lyapunov functions really shines when the Lyapunov candidates are higher degree (such as the quartic we use here).
Convex outer approximations
All of our region of attraction approximations so far have been "inner approximations" -- the certified region is guaranteed to be contained within the true region of attraction for the system. This is what we want if we are to give some guarantee of stability. As we increase the degree of our polynomial and multipliers, we expect that the estimated regions of attraction will converge on the true regions.
It turns out that if we instead consider outer approximations, which converge on the true ROA from the other side, we can write formulations that enable searching for the Lyapunov function directly as a convex optimization. As we will see below, this approach also allows one to write convex formulations for controller design. These methods have been explored in a very nice line of work by Henrion and Korda (e.g. [13]), using the method of moments from [14] also called "occupation measures". Their treatment emphasizes infinite-dimensional linear programs and heirarchies of LMI relaxations; these are just dual formulations to the SOS optimizations that we've been writing here. I find the SOS form more clear, so will stick to it here. Some of the occupation measure papers include the dual formulation of the infinite-dimension linear program which will look quite similar; my coauthors and I typically call out the sums-of-squares version in our papers on the topic (e.g. [15]).
To find an outer approximation, instead of solving for a Lyapunov function that certifies convergence to the origin, we instead search for a Lyapunov-like "barrier certificate", Like a Lyapunov function, we'd like ; this time we'll ask for this to be true everywhere (or at least in some set that is sufficiently larger than the ROA of interest). Then we will set . If we can find such a function, then certainly any state for which is outside of the region of attraction of the fixed point -- since cannot increase it can never reach the origin which has The superlevel set ${ \bx | \mathcal{B}(\bx) \ge 0}$ is an outer approximation of the true region of attraction:
In order to find the smallest such outer approximation (given a fixed degree polynomial), we choose an objective that tries to "push-down" on the value of . We typically accomplish this by introducing another polynomial function with the requirements that
Example: Outer approximation for the cubic polynomial
Let's revisit my favorite scalar dynamical system, $\dot{x} = -x + x^3,$ which has a region of attraction for the fixed point at zero of This time, we'll estimate the ROA using the outer approximation. We can accomplish this with the following program: \begin{align*} \min_{\mathcal{B}(x), W(x)} \quad & \int_{-2}^2 W(x)dx, \ \subjto \quad & -\dot{\mathcal{B}}(x) & \text{is SOS}, \ & W(x) &\text{ is SOS}, \ & W(x) - \mathcal{B}(x) - 1.0 & \text{ is SOS}, \ & \mathcal{B}(0)= 0.1.\end{align*} To make the problem a little numerically better, you'll see in the code that I've asked for to be strictly negative definite, and I've chosen to only include even-degree monomials in and . Plotting the solution reveals:
As you can see, the superlevel set, is a tight outer-approximation of the true region of attraction. In the limit of increasing the degrees of the polynomials to infinity, we would expect that would converge to the indicator function that is one inside the region of attraction, and zero outside (we are quite far from that here, but nevertheless have a tight approximation from ).
Go ahead and try adjusting some of these decisions. For example, if you set , then you can increase the degree of to get tighter and tighter approximations.
Regions of attraction codes in Drake
In Drake, we have packaged most of the work in setting up
and solving the sums-of-squares optimization for regions of attraction
into a single method RegionOfAttraction(system, context, options), which aims to implement the best methods described in
this chapter.
Example: RegionOfAttraction for the cubic polynomial
Using the
RegionOfAttractionmethod, many of the notebooks above can be reduced to just a few lines:python
x = Variable("x") sys = SymbolicVectorSystem(state=[x], dynamics=[-x+x**3]) context = sys.CreateDefaultContext() V = RegionOfAttraction(sys, context)
>
> Remember that although we have tried to make it convenient to call
> these functions, they are not a black box. I highly recommend
> opening up the code implementing the `RegionOfAttraction`
> method and understanding how it works (even if you don't love C++,
> the `MathematicalProgram` modeling language in Drake makes
> these formulations pretty readable). There are lots of different
> options / formulations, and numerous numerical recipes to improve the
> numerics of the optimization problem.
In order to develop our intuition for these tools, it is helpful to
understand how "tight" the inner approximation can be for each choice
of the fixed degree of the Lyapunov function / Lagrange multipliers.
I've included below a few of my favorite examples of nonlinear systems
which use some clever construction to have *known* regions of
attraction.
> **Example: Region of attraction for the time-reversed Van der Pol oscillator**
>
> We will study the Van der Pol oscillator in more detail when we
> study limit cycles. For now, it suffices to know that the dynamics
> are polynomial, and that the stable limit cycle of the system when
> simulated forward in time produces a known (via numerical
> integration) boundary for the region of attraction of the fixed point
> at the origin when we simulate the system *backwards* in
> time.
>
> I've provided an example here for solving this problem with the
> `RegionOfAttraction` in Drake, but we will also work you
> through writing the sums-of-squares problem yourself in the [exercises](#van_der_pol_roa).
> **Example: Regions of attraction and LQR**
>
> So far we have only considered verifying regions of attraction for
> systems of the form (e.g. with no control
> input); the implication has been that one should design a feedback
> controller first and then analyze the stability of the closed-loop
> dynamics. But some control design techniques produce artifacts that
> can be useful for this verification. Often jointly designing a
> controller and certificate can be more tractable than trying to
> certify an arbitrary controller.
>
> One nice example of this that we've already seen is the linear
> quadratic regulator. Even when it is applied to (the linearization
> of) nonlinear systems, it still produces a quadratic cost-to-go
> function which can be immediately used as
> a candidate Lyapunov function for the nonlinear system.
>
> To demonstrate this...
### Robustness analysis using the S-procedure
### Piecewise-polynomial systems
> **Example: Closed-loop dynamics with input saturations**
### Rigid-body dynamics are (rational) polynomial
We've been talking a lot in this chapter about numerical methods for
polynomial systems. But even our simple pendulum has a in
the dynamics. Have I been wasting your time? Must we just resort to
polynomial approximations of the non-polynomial equations? It turns out
that our polynomial tools can perform exact analysis of the manipulation
equation for almost all<sup>†</sup>
> <sup>†</sup>the most notable
> exception to this is if your robot has helical/screw joints (see
> [[18](#Wampler11)]).
of our robots. We just have to do a
little more work to reveal that structure.
Let us first observe that rigid-body kinematics are polynomial (except
the helical joint). This is fundamental -- the very nature of a "rigid
body" assumption is that Euclidean distance is preserved between points on
the body; if and are two points on a body, then the
kinematics enforce that is constant -- these are
polynomial constraints. Of course, we commonly write the kinematics in a
minimal coordinates using and . But because of
rigid body assumption, these terms only appear in the simplest forms, and
we can simply make new variables ,
and add the constraint that For a more thorough
discussion see, for instance, [[18](#Wampler11)] and
[[19](#Sommese05)]. Since the potential energy of a multi-body system
is simply an accumulation of weight times the vertical position for all of
the points on the body, the potential energy is polynomial.
If configurations (positions) of our robots can be described by
polynomials, then velocities can as well: forward kinematics $\bp_i =
f(\bq)$ implies that
which is polynomial in . Since the kinetic energy of
our robot is given by the accumulation of the kinetic energy of all the
mass, the kinetic energy is
polynomial, too (even when we write it with inertial matrices and angular
velocities).
Finally, the [equations of motion](/u/477d16be07f5bbea) can be
obtained by taking derivatives of the Lagrangian (kinetic minus
potential). These derivatives are still polynomial!
> **Example: Global stability of the simple pendulum
> via SOS**
>
> We opened this chapter using our intuition about energy to discuss
> stability on the simple pendulum. Now we'll replace that intuition with
> convex optimization (because it will also work for more difficult
> systems where our intuition fails).
>
> Let's change coordinates from to $\bx =
[s,c,\dot\theta]^t$, where and $c \equiv
\cos\theta$. Then we can write the pendulum dynamics as
>
> Now let's parameterize a Lyapunov candidate as
> the polynomial with unknown coefficients which contains all monomials
> up to degree 2: Now we'll
> formulate the feasibility problem: In fact, this is asking too much
> -- really only needs to be negative when . We can
> accomplish this with the S-procedure, and instead write (Recall that is another
> polynomial with free coefficients which the optimization can use to
> make terms arbitrarily more positive when .) Finally,
> for style points, in the code example in [Drake](http://drake.mit.edu) we ask for
> exponential stability:
>
> As always, make sure that you open up the code and take a look. The
> result is a Lyapunov function that looks familiar (visualized as a
> contour plot here):
>
> 
>
> Aha! Not only does the optimization finds us coefficients for the
> Lyapunov function which satisfy our Lyapunov conditions, but the result
> looks a lot like mechanical energy. In fact, the result is a little
> better than energy... there are some small extra terms added which prove
> exponential stability without having to invoke LaSalle's Theorem.
The one-degree-of-freedom pendulum did allow us to gloss over one
important detail: while the manipulator equations $\bM(\bq) \ddot{\bq} +
\bC(\bq, \dot\bq)\dot{\bq} = ...$ are polynomial, in order to solve for
we actually have to multiply both sides by . This,
unfortunately, is *not* a polynomial operation, so in fact the final
dynamics of the multibody systems are *rational* polynomial. Not
only that, but evaluating symbolically is not advised -- the
equations get very complicated very fast. But we can actually write the
Lyapunov conditions using the dynamics in implicit form, e.g. by writing
and asking it to satisfy the Lyapunov conditions
everywhere that is
satisfied, using the S-procedure.
#### Linear feedback and quadratic forms
There are a few things that *do* break this clean polynomial
view of the world. Rotary springs, for instance, if modeled as $\tau =
k (\theta_0 - \theta)$ will mean that appears alongside
and , and the relationship between
and is sadly *not polynomial*. As we have presented
it so far, even linear feedback from LQR actually looks like a linear
spring.
Looking more closely, though, there is a natural alternative.
Consider the mechanical energy of the simple pendulum , $E =
\frac{1}{2}ml^2 \dot\theta^2 + mgl(1- \cos\theta),$ where we've taken
the potential energy so that ). Observe that using half-angle
formulas we can write this as a quadratic form: The term $2
\sin(\frac{\theta}{2})$ has slope one at . This isn't
unique to the pendulum, $2\sin^2(\frac{\theta}{2})$ is a natural choice
for a Lyapunov candidate in the trigonometric coordinates that is
periodic in $2\pi.$ In the case of LQR applied to the linearization of
a nonlinear mechanical system, one could replace with $-2 k
\sin(\frac{\theta}{2})$; after all their linearization is the same.
> **Example: Regions of attraction for LQR of trigonometric systems**
#### Alternatives for obtaining polynomial equations
In practice, you can also Taylor approximate any smooth nonlinear
function using polynomials. This can be an effective strategy in
practice, because you can limit the degrees of the polynomial, and
because in many cases it is possible to provide conservative bounds on
the errors due to the approximation.
One final technique that is worth knowing about
is a change of coordinates, often referred to as the [stereographic projection](https://en.wikipedia.org/wiki/Stereographic_projection), that provides a coordinate system in which
we can replace and with polynomials:

*The stereographic projection.*
By projecting onto the line, and using similar triangles, we find that
Solving for and
reveals where $\frac{\partial
p}{\partial \theta}$ can be used in the chain rule to derive the
dynamics . Although the equations are rational, they share
the denominator $1+p^2$ and can be treated efficiently in mass-matrix
form. Compared to the simple substitution of and
, this is a minimal representation (scalar to scalar, no
required); unfortunately it does have a singularity at
, so likely cannot be used for global analysis.
### Verifying dynamics in implicit form
Typically we write our differential equations in the form $\dot\bx =
{\bf f}(\bx, \bu).$ But let us consider for a moment the case where the
dynamics are given in the form This
form is strictly more general because I can always write ${\bf
g}(\bx, \bu, \dot\bx) = f(\bx \bu) - \dot\bx$, but importantly here I can
also write the bottom rows of as $\bM(\bq)\ddot\bq +
\bC(\bq,\dot\bq)\dot\bq - \btau_g - \bB \bu$. This form can also
represent [differential
algebraic equations (DAEs)](https://en.wikipedia.org/wiki/Differential-algebraic_system_of_equations) which are more general than ODEs;
could even include algebraic constraints like . Most
importantly, for manipulators, can be polynomial, even if ${\bf
f}$ would have been rational. [Drake](http://drake.mit.edu) provides access to
continuous-time dynamics in implicit form via the [`CalcImplicitTimeDerivativesResidual`](https://drake.mit.edu/doxygen_cxx/classdrake_1_1systems_1_1_system.html#a2bb4c1e3572a8009863b5a342fcb5c49)
method.
We typically write a linear system in implicit form as Systems in this form are particularly
interesting when is singular, and are known as descriptor
systems, semistate systems, generalized state-space systems or just
singular systems (c.f. [[20](#Mehrmann91)]). Just like our standard
approach to linearization, we can potentially obtain the matrices ${\bf
E}, \bA, \bB$ from a first-order Taylor approximation of the nonlinear
equations in When it comes to Lyapunov
analysis, linear systems are often analyzed using the so-called
"generalized Lyapunov equation".
> **Theorem: Lyapunov analysis for implicit linear systems**
>
> Given a linear system in the form the
> origin is asymptotically stable if there exists a matrix such
> that Furthermore, if such a exists,
> then we can obtain one by solving the *generalized Lyapunov
> equation*: for any [[21](#Stykel02), Ch 4].
This can be verified by taking as the Lyapunov function. A corresponding approach can be used
(e.g. via sums-of-squares) for implicit nonlinear systems like our
manipulator equations where can be written in
the form
Alternatively, we can check the Lyapunov conditions, $\dot{V}(\bx) \le
0$, directly on a system in its implicit form, .
Simply define a new function $Q(\bx, \bz) = \frac{\partial
V(\bx)}{\partial \bx} \bz.$ If we can show $Q(\bx, \bz) \le 0, \forall
\bx,\bz \in \{ \bx, \bz | \bg(\bx,\bz) = 0 \}$ using SOS, then we have
verified that , albeit at the non-trivial cost of
adding indeterminates and an additional S-procedure.
To combine the trigonometric substitutions with the implicit form for
a simple second-order system (where the number of positions is equal to
the number of velocities), we use to represent the implicit
and convert \begin{gather*} V(\bq, \dot\bq) \Rightarrow
V({\bf s}, {\bf c}, \dot\bq) \\ {\bf g}(\bq, \dot\bq, {\bf z})
\Rightarrow {\bf g}({\bf s}, {\bf c}, \dot\bq, {\bf z}), \end{gather*}
and write the Lyapunov conditions using $\dot{V} = \sum_i \pd{V}{s_i} c_i
\dot{q}_i - \sum_i \pd{V}{c_i}s_i \dot{q}_i + \pd{V}{\dot\bq} \bz.$ The
most common case for the number of positions is not equal to the number
of velocities is when we deal with 3D rotations represented by unit
quaternions; this case can be handled using the implicit form, too (we
use the implicit form to relate to the velocities and verify
the Lyapunov conditions only on the manifold defined by the quaternion
unit norm constraint).
## Finite-time Reachability
So far we have used Lyapunov analysis to analyze *stability*, which
is fundamentally a description of the system's behavior as time goes to
infinity. But Lyapunov analysis can also be used to analyze the
finite-time behavior of nonlinear systems. We will see a number of
applications of this finite-time analysis over the next few chapters. It
can be applied even to unstable systems, or systems that are stable to a
limit cycle instead of a fixed-point. It can also be applied to systems
that are only defined over a finite interval of time, as might be the case
if we are executing a planned trajectory with a bounded duration.
### Time-varying dynamics and Lyapunov functions
Before focusing on the finite time, let us first realize that the
basic (infinite-time) Lyapunov analysis can also be applied to
time-varying systems: We can analyze the
stability (local, regional, or global) of this system with very little
change. If we find \begin{gather*}V(\bx) \succ 0, \\
\forall t,\forall \bx \ne 0, \quad \dot{V}(t, \bx) = \pd{V}{\bx}f(t,\bx) < 0, \quad
\dot{V}(t, 0) = 0, \end{gather*} then all of our previous
statement still hold. In our SOS formulations, is simply one more
indeterminate.
Similarly, even for a time-invariant system, it is also possible to
define a time-varying Lyapunov function, and establish local,
regional, or global stability using the almost the same conditions:
\begin{gather*}\forall t, \forall \bx \ne 0, \quad V(t, \bx) > 0, \quad V(t, 0) = 0, \\
\forall t, \forall \bx \ne 0, \quad \dot{V}(t, \bx) = \pd{V}{\bx}f(\bx) + \pd{V}{t} < 0,
\quad \dot{V}(t, 0) = 0. \end{gather*}
These two ideas each stand on their own, but they very often go
together, as time-varying dynamics are perhaps the best motivator for
studying a time-varying Lyapunov function. Afterall, we do know that a
stable time-invariant system must have a time-invariant Lyapunov function
that demonstrates this stability (from the "converse Lyapunov function"
theorems). But we do not know apriori how to represent this function; as
an example, remember we know that there are stable polynomial systems
that cannot be verified with a polynomial Lyapunov function. For global
stability analysis, the time-varying Lyapunov analysis does not add
modeling power: since the conditions must be satisfied for all , we
could have just set to a constant and used the time-invariant
function. But there may be cases where a time-varying analysis could
afford a different analysis for the regional or local stability cases. We
will see a good example of this when we study limit cycles.
### Finite-time reachability
Finite-time reachability analysis is an important concept for control
design and verification, where we seek to understand the behavior of a
system over only a finite time interval, . It is almost
always a region-based analysis, and attempts to make a statement of the
form: where are
regions of state space. More generally, we might like to understand the
time-varying reachable set
*Reachability analysis* can be done forward in time: we choose
and try to find the *smallest* region
for which we can make the statement hold.
would be called the *forward-reachable set* (FRS),
and can be very useful for certifying e.g. a motion plan. For instance,
you might like to prove that your UAV does not crash into a tree in the
next 5 seconds. In this case might be take to be a point
representing the current state of the vehicle, or a region representing
an outer-approximation of the current state if the state in uncertain. In
this context, we would call a forward-reachable set. In
this use case, we would typically choose any approximations in our
Lyapunov analysis to certify that an estimate of the reachable region is
also an outer-approximation: $\mathcal{X}_2 \subseteq
\hat{\mathcal{X}}_2.$
Reachability analysis can also be done backward in time: we choose
and try to *maximize* the region for
which the statement can be shown to hold. Now is called
the *backward-reachable set* (BRS), and for robustness we typically
try to certify that our estimates are an inner-approximation,
The region-of-attraction
analysis we studied above can be viewed as a special case of this, with
taken to be the fixed-point, and $t_1 =
-\infty$. But finite-time BRS also have an important role to play, for
instance when we are composing multiple controllers in order to achieve a
more complicated task, which we will study soon.
### Reachability via Lyapunov functions
Lyapunov functions can be used to certify finite-time reachability,
even for continuous-time systems. The basic recipe is to certify the
Lyapunov conditions over a (potentially time-varying) invariant set. Once
again, we typically represent this as a (time-varying) level set of the
Lyapunov function containing the origin, where
is now a positive scalar function of time. Since we already
have time as a decision variable, we can easily accommodate time-varying
dynamics and Lyapunov functions, as well, so: \begin{align*} \forall
t\in[t_1, t_2], \quad \forall \bx, \qquad& V(t,\bx) > 0, \quad& V(t, 0) =
0 \\ \forall t \in [t_1, t_2], \quad \forall \bx \in \{\bx | V(t,\bx) =
\rho(t)\}, \qquad& \dot{V}(t, x) \le \dot\rho(t).\end{align*} Note that
finite-time reachability is about proving invariance of the set, not
stability, and the condition need only be certified at the
boundary of the level set. If is decreasing at the boundary, then
trajectories can never leave. One can certainly ask for more -- we may
want to show that the system is converging towards ,
perhaps even at some rate -- but only invariance is required to certify
reachability.
Again, for polynomial systems and dynamics, sums-of-squares
optimization is a powerful tool for certifying these properties
numerically, and optimizing the volume of the estimated regions. Having
taken as an indeterminate, we can use the S-procedure again to
certify the conditions
Like in the case for region of attraction, we have many formulations.
We can certify an existing Lyapunov candidate, , and just try
to maximize/minimize . Or we can search for the parameters of
, too. Again, we can initialize that search using the
time-varying version of the Lyapunov equation, or the solutions to a
time-varying LQR Riccati equation.
In practice, we often certify the Lyapunov conditions over at
only a finite set of samples . I don't actually have
anything against sampling in one dimension; there are no issues with
scaling to higher dimensions, and one can make practical rigorous
statement about bounding the sampling error. And in these systems,
adding into all of the equation otherwise can dramatically increase
the degree of the polynomials required for the SOS certificates. All of
this was written up nicely in [[22](#Tobenkin10b)], and robust
variants of it were developed in [[9](#Majumdar16a)].
## Control design
Throughout this chapter, we've developed some very powerful tools for
reasoning about stability of a closed-loop system (with the
controller already specified). I hope you've been asking yourself -- can I
use these tools to design better controllers? Of course the answer is
"yes!". In this section, I'll discuss the control approaches that are the
most direct consequences of the convex optimization approaches to Lyapunov
functions. Another very natural idea is to use these tools in the content
of a feedback motion planning algorithm, which is the subject of an [upcoming chapter](/u/cd1b46e5619d10d1).
### Control design via alternations
For linear optimal control, we found controllers of the form, $\bu =
-\bK \bx.$ The natural generalization of this to polynomial analysis
will be to look for controllers of the form , where
is a polynomial vector. (For mechanical systems like the
pendulum above, we might make polynomial in and .)
#### Global stability
If we apply this control directly to the Lyapunov conditions for
global analysis with control-affine dynamics, we quickly see the
problem. We have and as a result if we are trying to
search for the parameters of and simultaneously, the decision
variables multiply and the problem will be non-convex.
One very natural strategy is to use alternations. The idea is
simple, we will fix and optimize , then fix and optimize
and repeat until convergence. This approach has roots in the
famous "DK iterations" for robust control (e.g.
[[23](#Lind94)]).
For this approach, it is important to start with an initial feasible
or . For example, one can think of locally stabilizing a
nonlinear system with LQR, and then searching for a linear control law
(or even a higher-order polynomial control law) that achieves a larger
basin of attraction. But note that once we move from global stability
to region of attraction optimization, we now need to alternate between
three sets of variables: where
was the multiplier polynomial for the S-procedure. We
took exactly this approach in [[24](#Majumdar13)]. In that paper,
we showed that alternations could increase the certified region of
attraction for the Acrobot.
The alternation approach takes advantage of a structured convex
optimization in each step of the alternations, but it is still only a
local approach to solving the non-convex joint optimization. It is
subject to local minima. The primary advantage is that, barring
numerical issues, we expect recursive feasibility (once we have a
controller and Lyapunov function that achieves stability, even with a
small region of attraction, we will not lose it) and monotonic
improvement on the objective. It is also possible to attempt to
optimize these objectives more directly with other non-convex
optimization procedures (like stochastic gradient descent, or
sequential quadratic programming [[7](#Shen20)]), but strict
feasibility is harder to guarantee. Oftentimes the Lyapunov conditions
are just evaluated at samples, or along sample trajectories. However,
once we "learn" a Lyapunov candidate even by approximate methods, we
may once again attempt to rigorously certify the Lyapunov conditions
using just a single convex optimization step the with controller
fixed.
#### Maximizing the region of attraction
An extension of this approach can be used to design controllers that
are certified only over a region of attraction, but this requires some
additional care. We can write the search for the
maximal region of attraction as: \begin{align*} \max_{\rho, {\bf
K}(\bx), V(\bx), \lambda(\bx)}& \qquad \rho \\ \subjto \quad
& V(\bx),~\lambda(\bx) \text{ are SOS,} \\ & -\pd{V}{\bx} ({\bf
f}_{1}(\bx) + {\bf f}_{2}(\bx){\bf K}(\bx)) + \lambda(\bx)( V(\bx) -
\rho) \text{ is SOS,} \\ & V({\bf 0}) = 0, \quad V({\bf 1}) = 1.
\end{align*} The last line yields linear constraints which simply fixes
the scaling of
Once again, we find that this optimization is bilinear in the
decision variables. But the conditions are linear in and
for fixed , and are linear in for fixed
and . In principle, we could use bilinear
alternations, but [[24](#Majumdar13)] recommended a three-way
alternation approach in order to include a step which explicitly
optimizes with an objective of maximizing
Starting with an initial guess for we can repeat the following
alternations:
1. Fix and , and solve a feasibility problem for
and \begin{align*}
\textbf{find}_{\lambda(\bx), {\bf K}(\bx)}& \\ \subjto \qquad&
-\pd{V}{\bx} ({\bf f}_{1}(\bx) + {\bf f}_{2}(\bx){\bf K}(x)) +
\lambda(\bx)( V(\bx) - \rho) \text{ is SOS.} \end{align*}
2. Fix and and maximize searching
over \begin{align*} \max_{\rho, {\bf K}(\bx)}\qquad &
\rho \\ \subjto \qquad & \lambda(\bx) \text{ is SOS} \\ &
-\pd{V}{\bx} ({\bf f}_{1}(\bx) + {\bf f}_{2}(\bx){\bf K}(x)) +
\lambda(\bx)( V(\bx) - \rho) \text{ is SOS.} \end{align*}
3. Fix and and maximize
searching over \begin{align*} \max_{\rho,
V(\bx)}\qquad & \rho \\ \subjto \qquad & V(\bx) \text{ is SOS} \\ &
-\pd{V}{\bx} ({\bf f}_{1}(\bx) + {\bf f}_{2}(\bx){\bf K}(x)) +
\lambda(\bx)( V(\bx) - \rho) \text{ is SOS,} \\ & V({\bf 0}) = 0,
\quad V({\bf 1}) = 1. \end{align*}
### State feedback for linear systems
There is a clever reparameterization of the original problem that can
make the co-design of Lyapunov functions and stabilizing controllers
jointly convex in some cases.
Let's re-examine the Lyapunov conditions for linear systems from Eq.
\ref{eq:lyap}, but now add in a linear state feedback ,
resulting in the closed-loop dynamics
One can show that the set of all stabilizing can be characterized
by the following two matrix inequalities [[3](#Boyd94)]: Unfortunately, these inequalities are *bilinear* in the
decision variables, and , and therefore non-convex. It
turns out that we can turn these into *linear* matrix inequalities
(LMIs) through a simple change of coordinates, $\bQ = {\bf P}^{-1}, {\bf
Y} = \bK{\bf P}^{-1}$, resulting in Furthermore, given
matrices and , there exists a matrix such that $(\bA +
\bB\bK)$ is stable if and only if there exist matrices and ${\bf
Y}$ which satisfy this (strict) linear matrix inequality.
For global stability, there is a nice extension of this using sums of
squares [[25](#Prajna04b)]
to the case of where is a vector of monomials with ${\bf
m}(\bx)=0$ iff , and the elements of and ${\bf
f}_2$ are polynomial. The search is over polynomial feedback controllers
of the form
### <a id="control-lyapunov"></a>Control-Lyapunov Functions
Another core idea connecting Lyapunov analysis with control design is
the "[control-Lyapunov
function](https://en.wikipedia.org/wiki/Control-Lyapunov_function)". Given a system , a
control-Lyapunov function is a positive-definite function for which
In words, for all , there exists a control input that would
allow the to decrease. Once again, we adorn this basic property with
extra conditions (e.g. radially unbounded, or satisfied over a control-
invariant set) in order to construct global or regional stability
statements. What is important to understand is that we can design
control-Lyapunov functions without explicitly parametrizing the
controller; often the control action is not even determined until
execution time by finding a particular that goes downhill.
Our sums-of-squares toolkit is well-suited for addressing questions
with the quantifier over indeterminates. Working with the
quantifier is much more difficult; we don't have an
S-procedure-like solution for it. Interestingly, there is one approach
that we've discussed above that effectively turns the into a
-- that is the outer approximation approach to region of
attraction analysis.
In the outer-approximation, we produce a barrier certificate to find
the set of states where the controller cannot go (for any ). Our
barrier certificate now has the form Certainly,
is now an outer-approximation of the true "backward-reachable set" (BRS)
of the fixed point [[13](#Henrion14), [26](#Korda13)]. Again
[[15](#Posa17)]
has some nice examples of this written directly in sums-of-squares
form.
Now here is where it gets a little frustrating. Certainly, sublevel
sets of are control-invariant (via the proper choice
of ). But we do not (cannot) expect that the entire estimated
region (the 0-superlevel set) can be rendered invariant. The estimated
region is an *outer* approximation of the backward reachable set.
[[27](#Majumdar13b)] gave a recipe for extracting a polynomial
control law from the BRS; an inner approximation of this control law can
be obtained via the original SOS region of attraction tools. This is
unfortunatley suboptimal/conservative. Although we would like to
certify the control-Lyapunov conditions directly in an inner
approximation, the quantifier remains as an obstacle.
### Approximate dynamic programming with SOS
We have [already established](#HJB) the most important
connection between the HJB conditions and the Lyapunov conditions:
The HJB involves solving a complex PDE; by changing this to
an inequality, we relax the problem and make it amenable to convex
optimization.
#### Upper and lower bounds on cost-to-go
Asking for is sufficient for proving
stability. But we can also use this idea to provide rigorous
certificates as upper or lower bounds of the cost-to-go. Given a
control-dynamical system , and a fixed
controller we can find a function :
- $\forall
\bx, \dot{V}^\pi(\bx) \le -\ell(\bx,\pi(\bx))$ to provide an **upper
bound**, or
- $\forall \bx, \dot{V}^\pi(\bx) \ge
-\ell(\bx,\pi(\bx))$ to provide an **lower bound**.
To see
this, take the integral of both sides along any *solution*
trajectory, . For the upper-bound we get
\begin{gather*} \int_0^\infty \dot{V}^\pi(\bx) dt = V^\pi(\bx(\infty))
- V^\pi(\bx(0)) \le \int_0^\infty -\ell(\bx(t),\pi(\bx(t)))
dt.\end{gather*} Assuming , we have
The upper bound is the one that we would want to use in a
certification procedure -- it provides a *guarantee* that the
total cost achieved by the system started in is less than
. But it turns out that the lower bound is much better for
control design. This is because we can write Therefore, without having to specify apriori a controller, if we
can find a function such that $\forall \bx, \forall \bu,
\dot{V}(\bx, \bu) \ge -\ell(\bx,\bu)$, then we have a lower-bound on
the *optimal* cost-to-go.
You should take a minute to convince yourself that, unfortunately,
the same trick does not work for the upper-bound. Again, we would need
as the quantifier on instead of .
#### Linear Programming Dynamic Programming
In the dynamic programming chapter, we introduced the [linear programming approach to dynamic
programming](/u/fdba470e9277f024#lp-dp). This was exactly using the idea of pushing up on a
lower bound on the cost-to-go. In the case of a discrete state, then
this lower bound will be tight (and we obtain the true cost-to-go
function); in the case of linear function approximators, then we hope
for a tight lower bound.
#### Sums-of-Squares Dynamic Programming
The linear programming approach works natively in discrete (or
sampled) time/state/action settings. Sums-of-squares provides the a
beautiful extension to continuous time/state/actions.
In the simple case, let us assume that and
are polynomials (this assumption is discussed at length
in the Lyapunov chapter). We can search for a polynomial
which satisfies the HJB inequality using the following *convex* optimization:
\begin{align*} \max_\alpha & \int_{\bf X} \hat{J}_\alpha(\bx) d\bx \\
\subjto \quad & \ell(\bx,\bu) + \pd{\hat{J}_\alpha}{\bx} f(\bx,\bu)
\text{ is SOS }(\forall \bx, \forall \bu) \\ & \hat{J}_\alpha({\bf 0})
= 0. \end{align*} Since is polynomial, the
integral objective (over a bounded domain of interest) can be computed
exactly, and is still linear in the coefficients . As in the
linear programming approach, here the SOS constraint ensures that
is a *lower* bound on the cost to go, and the objective
"pushes up" on this lower bound. As we increase the degree of the
polynomial representing , we expect better and better
approximations of the true cost-to-go.
> **Example: Cubic polynomial optimal control**
>
> Consider a system with (scalar) dynamics: and the running cost I've provided code that optimizes the cost-to-go over the
> interval
>
> 
> **Example: Pendulum swing-up**
>
> We can use this approach to design an approximation to the optimal
> controller for the (torque-limited) swing-up of the pendulum!
> **Example: Cart-pole swing-up**
>
> This final example is adapted from [[28](#Yang23)]. Even the lower-bound controller can effectively swing-up the cart-pole system!
I've only provided simple implementations above; their effectiveness
is limited by the poor numerics of using polynomials with exceedingly
high degree ( is a very small number around and a very
large number around ). We should be able to improve the
numerics dramatically by choosing more intelligent polynomial bases. I
personally think this method has a lot of offer and it would be very
interesting to see how far it could go with mature implementations.
## Alternative computational approaches
### Sampling Quotient-Ring Sum-of-Squares
[[7](#Shen20)]
### "Satisfiability modulo theories" (SMT)
[Satisiability
modulo theories (SMT)](https://en.wikipedia.org/wiki/Satisfiability_modulo_theories). [dReal](https://dreal.github.io/) is available in [Drake](http://drake.mit.edu).
### Mixed-integer programming (MIP) formulations
### Continuation methods
## Neural Lyapunov functions
Details coming soon. For some recent work with a fairly extensive
bibliography, see [[29](#Dai21)].
## Contraction metrics
## Other variations and extensions
The analog of Lyapunov functions for stochastic verification are
super-martingales [[30](#Steinhardt11a)]. We will discuss that more in
the stochastic and robust control chapter.
## Exercises
> **Exercise 1 (Valid Lyapunov Function for Global Stability)**
>
> For the system \begin{align*} \dot x_1
&=-\frac{6x_1}{(1+x_1^2)^2}+2x_2, \\ \dot x_2
&=-\frac{2(x_1+x_2)}{(1+x_1^2)^2}, \end{align*} you are given the
> positive definite function
> (plotted [here](https://www.geogebra.org/calculator/ynqgesf9))
> and told that, for this system, is negative definite over
> the entire space. Is a valid Lyapunov function to prove global
> asymptotic stability of the origin for the system described by the
> equations above? Motivate your answer.
> **Exercise 2 (Invariant Sets and Regions of Attraction)**
>
> You are given a dynamical system , with
> continuous, which has a fixed point at the origin. Let be a ball
> of (finite) radius centered at the origin: $B_r = \{ \bx : \| \bx
\| \leq r \}$. Assume you found a continuously-differentiable scalar
> function such that: , for all $\bx \neq
0$ in , and for all in .
> Determine whether the following statements are true or false. Briefly
> justify your answer.
>
> 1. is an invariant set for the given system, i.e.: if the
> initial state lies in , then will belong to
> for all .
> 2. is a subset of the ROA of the fixed point , i.e.: if
> lies in , then $\lim_{t \rightarrow \infty} \bx(t) =
0$.
> **Exercise 3 (Are Lyapunov Functions Unique?)**
>
> If and are valid Lyapunov functions that prove
> global asymptotic stability of the origin, does necessarily
> equal ? Justify your response.
> **Exercise 4 (Proving Global Asymptotic Stability)**
>
> Consider the system given by \begin{align*} \dot x_1 &= x_2 - x_1^3, \\
\dot x_2 &= - x_1 - x_2^3. \end{align*} Show that the Lyapunov function
> proves global asymptotic stability of the origin
> for this system.
> **Exercise 5 (Lyapunov Instability Theorem and Barrier functions)**
>
> Suppose that we are given a dynamical system with
> continuous , and that there exists a scalar continuously-differentiable
> function such that:
> \begin{align*}
&\forall \bx, V(\bx)\leq 0: \; \dot V (\bx) \leq 0,\\
&\exists \bx_0: \; V(\bx_0) < V(0) = 0.
\end{align*}
>
> 1. Show that the trajectory with and
> does not converge to $0$.
> 2. With that in mind, can be globally
> asymptotically stable to $0$?
> 3. Can be stable ISL to $0$?
> 4. Consider the set .
> Suppose that our system starts at where
> .
> Can there be a time , such that ?
> Explain why serves as a Barrier function to set .
> **Exercise 6 (Converse Lyapunov Theorem for global exponential stability)**
>
> Suppose that we are given a dynamical system with
> continuous that is globally exponentially stable to -- i.e.,
> there exist positive constants and , such that for any initial
> condition and time :
> .
> Define according to:
>
> In this exercise, we will show that is a Lyapunov function
> that proves global exponential stability of as in
> Theorem 9.2, i.e., that is positive definite, radially
> unbounded, and that , such that
> .
>
> 1. Show that is positive definite.
> 2. Explain why is radially unbounded.
> An intuitive explanation is sufficient here.
> 3. Compute . Hint: notice that by definition, we have:
>
> where is trajectory with .
> 4. Find , such that
> .
> Hint: use the definition of global asymptotic stability.
> 5. What is the intuition for the defined above?
> Where have we already seen it before?
> 6. Suppose you have a dynamical system .
> Why can't you "simply" compute (analytically or numerically)
> as above to check for global asymptotic stability?
> **Exercise 7 (Gradient Flow in Euclidean Space)**
>
> We can use Lyapunov analysis to analyze the behavior of optimization
> algorithms like gradient descent. Consider an objective function
> , and we want to minimize
> . The gradient flow is a continuous-time analog of gradient
> descent and is defined as .
>
> 1. Show that the objective function is a Lyapunov
> function of the gradient flow where is a unique minimizer.
> 2. We can use Lyapunov to argue that an optimization problem will
> converge to a global optimum, even if it is non-convex. Suppose that
> the Lyapunov function , has negative definite . Show
> that the objective function has a unique minimizer at the
> origin.
> 3. Consider the objective function in the figure below. Could this be
> a valid Lyapunov function for showing global asymptotic stability?
>
> 
>
>
> *Lyapunov function candidate for asymptotic
> stability.*
>
> 4. Consider the objective function $\ell(x) =
x_1^4-8x_1^3+18x_1^2+x_2^2$ with . Find the largest
> such that is a valid region of
> attraction for the origin.
> **Exercise 8 (Control-Lyapunov Function for a Wheeled Robot)**
>
> In this exercise, we examine the idea of a [control-Lyapunov function](#control-lyapunov)
> to drive a wheeled robot, implementing the controller proposed in
> [[31](#Aicardi95)].
>
> Similar to [this previous
> example](/u/3751ed00605fff72#wheeled-robot), we use a kinematic model of the robot. We represent with
> and its Cartesian position and with its orientation.
> The controls are the linear and angular velocities. The
> equations of motion read \begin{align*} \dot z_1 &= u_1 \cos z_3, \\ \dot
z_2 &= u_1 \sin z_3, \\ \dot z_3 &= u_2.\end{align*} The goal is to
> design a feedback law that drives the robot to the origin
> from any initial condition. As pointed out in
> [[31](#Aicardi95)], this problem becomes dramatically easier if we
> analyze it in polar coordinates. As depicted below, we let be the
> radial and the angular coordinate of the robot, and we define $x_3 =
x_2 - z_3$. Analyzing the figure, basic kinematic considerations lead to
> \begin{align*} \dot x_1 &= u_1 \cos x_3, \\ \dot x_2 &= - \frac{u_1 \sin
x_3}{x_1}, \\ \dot x_3 &= - \frac{u_1 \sin x_3}{x_1} -
u_2.\end{align*}
>
> 
>
>
> *Wheeled robot with Cartesian and polar
> coordinate system.*
>
> 1. For the candidate Lyapunov function $V(\bx) = V_1(x_1) + V_2(x_2,
x_3)$, with and $V_2(x_2, x_3) =
\frac{1}{2}(x_2^2 + x_3^2)$, compute the time derivatives $\dot V_1
(\bx, u_1)$ and .
> 2. Show that the choice \begin{align*} u_1 &= \pi_1(\bx) = - x_1 \cos
x_3, \\ u_2 &= \pi_2(\bx) = x_3 + \frac{(x_2 + x_3) \cos x_3 \sin
x_3}{x_3}, \end{align*} makes and
> for all . (Technically speaking,
> is not defined for . In this case, we let
> assume its limiting value , ensuring
> continuity of the feedback law.)
> 3. Explain why Lyapunov's direct method does not allow us to establish
> asymptotic stability of the closed-loop system.
> 4. Substitute the control law in the equations of
> motion, and derive the closed-loop dynamics $\dot \bx = f(\bx,
\pi(\bx))$. Use LaSalle's theorem to show (global) asymptotic stability
> of the closed-loop system.
> 5. In
> we set up a simulation environment for you to try the controller we
> just derived. Type the control law from point (b) in the dedicated
> cell, and use the notebook plot to check your work.
> **Exercise 9 (SOS Polynomials in Lyapunov Analysis)**
>
> 1. For each of the following polynomials, using
> ,
> find whether they (1) admit a sum of squares formulation, and (2) are
> positive semi-definite functions:
> 1.
> 2.
> 3. $f_3(x, y, z; \lambda) = z^6 + x^2y^2(x^2 + y^2 - 3\lambda
z^2)$, where $0 < \lambda \le 1$.
> 2. If a fixed point of our dynamical system does not admit a SOS
> Lyapunov function, what can we conclude about its stability?
> 3. If the optimal cost-to-go for a given dynamical system is not
> representable as sum of squares, can there still exist a SOS Lyapunov
> function? If no, explain why; otherwise, give an example of such a
> system.
> <a id="van_der_pol_roa"></a>
>
> **Exercise 10 (ROA Estimation for the Time-Reversed Van
> der Pol Oscillator)**
>
> In this exercise you will use SOS optimization to approximate the ROA
> of the time-reversed Van der Pol oscillator (a variation of the [classical Van
> der Pol oscillator](https://en.wikipedia.org/wiki/Van_der_Pol_oscillator) which evolves backwards in time). In
> , you are asked to test the following SOS formulations.
>
> 1. The one from [the example above](#roa_cubic_system),
> augmented with a line search that maximizes the area of the ROA.
> 2. A single-shot SOS program that can directly maximize the area of
> the ROA, without any line search.
> 3. An improved version of the previous, where less SOS constraints are
> imposed in the optimization problem.
> **Exercise 11 (Lyapunov Analysis for Robustness of Pendulum Swing-up
> Controllers)**
>
> In this problem, we examine the robustness of the swing-up controller
> designed for the pendulum in [this example](/u/01a3b4fab3db95df#pendulum-energy-shaping) using Lyapunov
> analysis. We consider an undamped pendulum in part (a)-(d), and one with
> damping ratio in (e). Assume (1) we can measure and
> perfectly (2) the pendulum does not start and will
> not stay at the downright position at any time.
>
> 1. Suppose we have perfect measurements of mass , length , and
> the gravitational constant . Show
> that the fixed point is attractive using LaSalle's Theorem and the
> scalar function .
> 2. The swing-up controller is robust with respect to mass measurement.
> Suppose the mass measurement is incorrect . Show that the
> controller can still complete the swing-up task, i.e., the fixed point
> is still attractive.
> 3. Consider the case where both mass and length measurements are
> incorrect, and . Is the fixed point still
> attractive? If not, identify conditions $m_i, l_i, \dot{\theta},
\theta, \widetilde{E}$ could satisfy such that .
> 4. Suppose in addition to uncertaint mass and length, the
> gravitational constant is also uncertain, . Suppose the
> pendulum's small-oscillation period can be
> measured precisely, and the estimated values of length and
> gravitational constant satisfy . Show
> that the controller can still complete the swing-up task, i.e., the
> fixed point is still attractive.
> 5. Suppose we have accurate measurements of mass and length, but now
> the pendulum is damped, i.e., , and we have incorrect
> estimates of the damping ratio . Using a swing-up
> controller , show
> that cannot be used as a Lyapunov
> function to certify attractivity.
## References
1. <a id="Slotine90"></a>
Jean-Jacques E. Slotine and Weiping Li,
"Applied Nonlinear Control", Prentice Hall
, October, 1990.
2. <a id="Khalil01"></a>
Hassan K. Khalil,
"Nonlinear Systems", Prentice Hall
, December, 2001.
3. <a id="Boyd94"></a>
S. Boyd and L. El Ghaoui and E. Feron and V. Balakrishnan,
"Linear Matrix Inequalities in System and Control Theory", SIAM
, 1994.
4. <a id="Parrilo00"></a>
Pablo A. Parrilo,
"Structured Semidefinite Programs and Semialgebraic Geometry Methods in Robustness and Optimization",
PhD thesis, California Institute of Technology, May 18, 2000.
5. <a id="Ahmadi11a"></a>
Amir Ali Ahmadi and Miroslav Krstic and Pablo A. Parrilo,
"A Globally Asymptotically Stable Polynomial Vector Field with no Polynomial Lyapunov Function",
Proceedings of the Conference on Decision and Control , 2011.
6. <a id="Blekherman13"></a>
Grigoriy Blekherman and Pablo A Parrilo and Rekha R Thomas,
"Semidefinite optimization and convex algebraic geometry", SIAM
, vol. 13, 2013.
7. <a id="Shen20"></a>
Shen Shen and Russ Tedrake,
"Sampling Quotient-Ring Sum-of-Squares Programs for Scalable Verification of Nonlinear Systems",
Proceedings of the 2020 59th IEEE Conference on Decision and Control (CDC) , 2020.
[ [link](http://groups.csail.mit.edu/robotics-center/public_papers/Shen20.pdf) ]
8. <a id="Tedrake10"></a>
Russ Tedrake and Ian R. Manchester and Mark M. Tobenkin and John W. Roberts,
"LQR-Trees: Feedback Motion Planning via Sums of Squares Verification",
International Journal of Robotics Research, vol. 29, pp. 1038--1052, July, 2010.
[ [link](http://dx.doi.org/10.1177/0278364910369189) ]
9. <a id="Majumdar16a"></a>
Anirudha Majumdar,
"Funnel Libraries for Real-Time Robust Feedback Motion Planning",
PhD thesis, Massachusetts Institute of Technology, Jun, 2016.
[ [link](http://groups.csail.mit.edu/robotics-center/public_papers/Majumdar16a.pdf) ]
10. <a id="Boyd04a"></a>
Stephen Boyd and Lieven Vandenberghe,
"Convex Optimization", Cambridge University Press
, 2004.
11. <a id="Posa17a"></a>
Michael Posa,
"Optimization for Control and Planning of Multi-contact Dynamic Motion",
PhD thesis, Massachusetts Institute of Technology, Jun, 2017.
[ [link](http://groups.csail.mit.edu/robotics-center/public_papers/Posa17a.pdf) ]
12. <a id="Fazel03"></a>
Maryam Fazel and Haitham Hindi and Stephen P Boyd,
"Log-det heuristic for matrix rank minimization with applications to Hankel and Euclidean distance matrices",
American Control Conference, 2003. Proceedings of the 2003 , vol. 3, pp. 2156--2162, 2003.
13. <a id="Henrion14"></a>
Didier Henrion and Milan Korda,
"Convex computation of the region of attraction of polynomial control systems",
IEEE Transactions on Automatic Control, vol. 59, no. 2, pp. 297-312, 2014.
14. <a id="Lasserre10"></a>
Jean Bernard Lasserre,
"Moments, Positive Polynomials and Their Applications", World Scientific
, vol. 1, 2010.
15. <a id="Posa17"></a>
Michael Posa and Twan Koolen and Russ Tedrake,
"Balancing and Step Recovery Capturability via Sums-of-Squares Optimization",
Robotics: Science and Systems, 2017.
[ [link](http://groups.csail.mit.edu/robotics-center/public_papers/Posa17.pdf) ]
16. <a id="Folland01"></a>
Gerald B Folland,
"How to integrate a polynomial over a sphere",
The American Mathematical Monthly, vol. 108, no. 5, pp. 446--448, 2001.
17. <a id="Henrion09"></a>
D. Henrion and J.B. Lasserre and C. Savorgnan,
"Approximate volume and integration for basic semialgebraic sets",
SIAM Review, vol. 51, no. 4, pp. 722--743, 2009.
18. <a id="Wampler11"></a>
Charles W. Wampler and Andrew J. Sommese,
"Numerical algebraic geometry and algebraic kinematics",
Acta Numerica, vol. 20, pp. 469-567, 2011.
19. <a id="Sommese05"></a>
A.J. Sommese and C.W. Wampler,
"The Numerical solution of systems of polynomials arising in engineering and science", World Scientific Pub Co Inc
, 2005.
20. <a id="Mehrmann91"></a>
Volker Mehrmann,
"The autonomous linear quadratic control problem: theory and numerical solution", Springer
, no. 163, 1991.
21. <a id="Stykel02"></a>
Tatjana Stykel,
"Analysis and numerical solution of generalized Lyapunov equations",
Institut für Mathematik, Technische Universität, Berlin, 2002.
22. <a id="Tobenkin10b"></a>
Mark M. Tobenkin and Ian R. Manchester and Russ Tedrake,
"Invariant Funnels around Trajectories using Sum-of-Squares Programming",
Proceedings of the 18th IFAC World Congress, extended version available online: arXiv:1010.3013 [math.DS], 2011.
[ [link](http://arxiv.org/abs/1010.3013) ]
23. <a id="Lind94"></a>
R. Lind and G.J. Balas and A. Packard,
"Evaluating D-K iteration for control design",
American Control Conference, 1994 , vol. 3, pp. 2792 - 2797 vol.3, 29 June-1 July, 1994.
24. <a id="Majumdar13"></a>
Anirudha Majumdar and Amir Ali Ahmadi and Russ Tedrake,
"Control Design along Trajectories with Sums of Squares Programming",
Proceedings of the 2013 IEEE International Conference on Robotics and Automation (ICRA), pp. 4054-4061, 2013.
[ [link](http://groups.csail.mit.edu/robotics-center/public_papers/majumdar13.pdf) ]
25. <a id="Prajna04b"></a>
Stephen Prajna and Antonis Papachristodoulou and Fen Wu,
"Nonlinear Control Synthesis by Sum of Squares Optimization: A Lyapunov-based Approach",
Proceedings of the ASCC 2004 , 2004.
26. <a id="Korda13"></a>
Milan Korda and Didier Henrion and Colin N Jones,
"Controller design and region of attraction estimation for nonlinear dynamical systems",
The 19th World Congress of the International Federation of Automatic Control (IFAC), 2014.
27. <a id="Majumdar13b"></a>
Anirudha Majumdar and Ram Vasudevan and Mark M. Tobenkin and Russ Tedrake,
"Convex Optimization of Nonlinear Feedback Controllers via Occupation Measures",
Proceedings of Robotics: Science and Systems (RSS) , 2013.
[ [link](http://groups.csail.mit.edu/robotics-center/public_papers/Majumdar13b.pdf) ]
28. <a id="Yang23"></a>
Lujie Yang and Hongkai Dai and Alexandre Amice and Russ Tedrake,
"Suboptimal Controller Synthesis for Cart-Poles and Quadrotors via Sums-of-Squares",
In preparation , 2023.
29. <a id="Dai21"></a>
Hongkai Dai and Benoit Landry and Lujie Yang and Marco Pavone and Russ Tedrake,
"Lyapunov-stable neural-network control",
Robotics: Science and Systems , 2021.
[ [link](http://groups.csail.mit.edu/robotics-center/public_papers/Dai21.pdf) ]
30. <a id="Steinhardt11a"></a>
Jacob Steinhardt and Russ Tedrake,
"Finite-time Regional Verification of Stochastic Nonlinear Systems",
International Journal of Robotics Research, vol. 31, no. 7, pp. 901-923, June, 2012.
[ [link](http://ijr.sagepub.com/content/31/7/901.abstract) ]
31. <a id="Aicardi95"></a>
Michele Aicardi and Giuseppe Casalino and Antonio Bicchi and Aldo Balestrino,
"Closed loop steering of unicycle like vehicles via Lyapunov techniques",
IEEE Robotics & Automation Magazine, vol. 2, no. 1, pp. 27--35, 1995.