ProjekinAja. Robotics Stage 3 · Dynamics Control Lesson 3.5
● Stage 3 · Lesson 3.5

Stability: Lyapunov Theory and Phase Portraits

Asserting "the system is stable" without a proof is not engineering — Lyapunov's method gives you the proof in closed form.

⏱ ~22 min read 🧮 Control theory 📐 Stage 3 core

🎯 By the end you'll understand

What Lyapunov, asymptotic, and exponential stability mean and why the differences matter. How to construct a Lyapunov function and what it must satisfy. LaSalle's invariance principle for systems where V̇ = 0 on a set — not just a point. How to read a phase portrait of a second-order system. Why the physical energy of a PD-controlled arm qualifies as a Lyapunov function. And why a controller that is Lyapunov-stable for the nominal plant can go unstable when model parameters drift.

KEY INSIGHTStability is a property you prove, not a property you observe

You cannot declare a robot controller stable because it worked in the lab for three hours. You can declare it stable because you found a function whose value only decreases along every trajectory of the system.

Every controller in this stage — PID, feedforward, LQR — claims to stabilize the robot. But a claim is not an argument. Stability is a mathematical property of the closed-loop system, and it can be certified only by producing a proof. Lyapunov's method is the workhorse for that proof in robotics: it replaces eigenvalue analysis (which only works for linear systems) with an energy-like argument that applies to nonlinear dynamics, time-varying systems, and systems with state constraints.

🔑 The physical picture

Imagine filling a bowl of water. The water level represents the "energy" of your system — a quantity that can only go down over time if the dynamics are dissipative. Lyapunov's insight: if you can find any such bowl-shaped function V(x) ≥ 0 that decreases along every trajectory (V̇ ≤ 0), you have proven that trajectories cannot escape to infinity, regardless of the nonlinearity. You do not need to know where the trajectory goes; you only need to know the function's slope is negative. That is the entire method.

CORE CONCEPTThree flavours of stability — and why you need to know which one you have

Stability is not one concept. The three standard definitions apply to the equilibrium x* = 0 (shift coordinates so the desired state is the origin):

Type Informal meaning Formal condition Sufficient for robotics?
Lyapunov stable (stable in the sense of Lyapunov) Trajectories starting near origin stay near origin; no guarantee they reach it ∀ε>0 ∃δ>0: ‖x(0)‖<δ ⟹ ‖x(t)‖<ε ∀t≥0 Usually not — the error stays small but never goes to zero
Asymptotically stable Lyapunov stable AND trajectories converge to origin as t → ∞ Lyapunov stable + ‖x(t)‖ → 0 as t → ∞ Yes for setpoint control; settling may be slow
Exponentially stable Asymptotically stable with a guaranteed convergence rate ‖x(t)‖ ≤ c · e-αt‖x(0)‖, c,α>0 Yes — implies predictable settling time

The distinction is load-bearing. An undamped pendulum released from a small angle is Lyapunov stable — it oscillates forever but never blows up. It is not asymptotically stable — it never reaches equilibrium. A PD-controlled robot arm with sufficient damping is asymptotically stable. Add model-based feedforward and you can get exponential stability with a certifiable settling time. The choice determines what you can promise to a customer or a safety regulator.

💡 Local vs. global

All three types can be local (holds for some neighborhood of x*) or global (holds for all x ∈ ℝⁿ). A PD controller on a revolute joint is only locally asymptotically stable — if you start more than 180° away from the target, the system may converge to the wrong equilibrium. Proving global asymptotic stability for a nonlinear system requires finding a radially unbounded Lyapunov function (one that goes to infinity as ‖x‖ → ∞). That is substantially harder, and often not possible.

DEFINITIONPositive definite functions: what the "bowl" must satisfy

A scalar function V : ℝⁿ → ℝ is a Lyapunov function candidate if it satisfies three conditions everywhere in some neighborhood of the origin (or globally):

1

V(x) > 0 for all x ≠ 0, and V(0) = 0

The function must be strictly positive away from the equilibrium and zero at it. This is the "bowl" condition. Example: V(x₁, x₂) = x₁² + x₂² is positive definite. V(x₁, x₂) = x₁² is not (it is zero for all x₁ = 0, regardless of x₂).

2

V is continuously differentiable

We need to compute V̇ along trajectories, so V must have a well-defined gradient everywhere in the domain. Quadratic forms like V = xᵀ P x (P symmetric positive definite) always satisfy this. Physical energy functions (½mṽ² + ½kq²) do too.

3

V̇(x) = ∇V · f(x) ≤ 0 along trajectories

The time derivative of V along the system's flow ẋ = f(x) must be non-positive. If V̇ < 0 strictly (negative definite), you have asymptotic stability. If only V̇ ≤ 0 (negative semi-definite), you need LaSalle's principle to determine convergence. This is the condition that transforms a candidate into a certificate.

The hard part is not checking the conditions — it is finding V in the first place. There is no systematic algorithm for general nonlinear systems. In robotics the most productive approaches are: (1) physical energy (kinetic + potential), (2) quadratic forms V = eᵀ P e for linear or linearized systems where P solves a Lyapunov equation, and (3) sum-of-squares (SOS) programming for polynomial dynamics. Physical intuition usually leads to the fastest candidate.

📖 Lyapunov's theorem (stability certificate)

If there exists a continuously differentiable positive definite function V in some domain D containing the origin such that V̇(x) ≤ 0 for all x ∈ D, then the origin is Lyapunov stable. If additionally V̇(x) < 0 for all x ≠ 0, the origin is asymptotically stable. If D = ℝⁿ and V is radially unbounded (V → ∞ as ‖x‖ → ∞), the origin is globally asymptotically stable.

HOW IT WORKSLyapunov analysis for a PD-controlled pendulum

Consider a pendulum with angle θ, moment of inertia J, damping b, and gravity g·L·sin(θ). A PD controller applies torque τ = −Kp·θ − Kd·θ̇. The closed-loop equation of motion is:

J·θ̈ + (b + Kd)·θ̇ + (g·L·sin(θ) + Kp·θ) = 0

This is nonlinear because of the sin(θ) term. We cannot use eigenvalues directly. Can we find a Lyapunov function? Try the total energy plus a cross-term that couples position and velocity:

V(θ, θ̇) = ½·J·θ̇² + g·L·(1 − cos θ) + ½·Kp·θ²

This is the kinetic energy plus gravitational potential (shifted so V(0,0)=0) plus an elastic term from the proportional gain. Is it positive definite near θ=0? Yes — near the origin, 1−cos(θ) ≈ θ²/2 > 0, so all three terms are non-negative and vanish only at (0,0).

Now compute V̇ along trajectories. Using ẋ = f(x) and the chain rule:

V̇ = J·θ̇·θ̈ + g·L·sin(θ)·θ̇ + Kp·θ·θ̇

Substitute J·θ̈ = −(b+Kd)·θ̇ − g·L·sin(θ) − Kp·θ from the equation of motion:

V̇ = [−(b+Kd)·θ̇ − g·L·sin(θ) − Kp·θ]·θ̇ + g·L·sin(θ)·θ̇ + Kp·θ·θ̇
V̇ = −(b+Kd)·θ̇²

Everything cancels except the damping term! V̇ = −(b+Kd)·θ̇² ≤ 0, since (b+Kd) > 0 when the PD damping coefficient Kd and natural damping b are both positive. The system is Lyapunov stable. But V̇ = 0 whenever θ̇ = 0 — not just at the origin. We need LaSalle's principle to go further.

🔑 The cancellation is not a coincidence

The gravity and proportional terms cancelled exactly because V was built from the system's physical energy. This is the intuition behind energy-based Lyapunov functions in robotics: when the controller shapes the potential energy of the closed-loop system (exactly what Kp does), the Lyapunov analysis reduces to checking whether there is net dissipation. That is the core of passivity-based control, and it scales to full robot arm dynamics in later stages.

CORE CONCEPTPhase portraits: visualizing stability without solving the ODE

A phase portrait plots the vector field ẋ = f(x) in state space for second-order systems. Each point (x₁, x₂) has an arrow showing the direction and magnitude of the state derivative. Trajectories follow the flow of those arrows. The portrait reveals equilibria, limit cycles, regions of attraction, and whether a proposed Lyapunov level curve is actually crossed inward by trajectories.

Stable spiral (AS) x₁ x₂ V̇ < 0: inward x* Saddle (unstable) x₁ x₂ stable manifold unstable manifold V̇ > 0 outward Lyapunov level curves (dashed ellipses) are crossed inward — proven stable Level curves crossed outward on unstable manifold — cannot be a Lyapunov fcn
Left: a stable spiral with Lyapunov level curves (dashed ellipses). Every trajectory crosses the curves inward — V̇ < 0 — proving asymptotic stability. Right: a saddle point. Along the unstable manifold, trajectories cross any proposed level curve outward, disqualifying any symmetric positive definite candidate as a Lyapunov function for this equilibrium.

Reading a phase portrait for stability: find an equilibrium point (where the vector field is zero). If all nearby trajectories spiral toward it, it is asymptotically stable. If some flow away, it is unstable. The level curves of a proposed V must be crossed inward everywhere to certify stability. This visual check complements the algebra — if the level curves are not closed (egg-shaped, not open), the function is a plausible candidate; if trajectories pierce them outward somewhere, the candidate fails.

SEE ITPhase portrait painter

Select a vector field from the menu. Drop a Lyapunov candidate from the preset list. The widget paints the vector field and the level curves of V. Click anywhere on the canvas to drop an initial condition — the trajectory integrates forward in time and you see whether it crosses level curves inward (Lyapunov certificate holds) or outward (candidate fails). The region of attraction is shaded.

⚙ Interactive · Phase portrait painter

Worst choice: picking the underdamped system with a Lyapunov candidate that has V̇ = 0 on a line — see what LaSalle's principle is for.

Vector field
Lyapunov candidate V
Damping / gain
Trajectory V level curves Region of attraction Diverging trajectory

Click the canvas to place initial conditions. Try placing the same IC with different Lyapunov candidates and observe when the level-curve crossing test passes or fails.

CORE CONCEPTLaSalle's invariance principle: when V̇ ≤ 0 is not enough

The Lyapunov theorem requires V̇ < 0 (strictly negative definite) for asymptotic stability. But the pendulum analysis produced V̇ = −(b+Kd)·θ̇², which is zero whenever θ̇ = 0 — not just at the equilibrium. Strictly, this only certifies Lyapunov stability. To conclude asymptotic stability we need LaSalle's invariance principle.

📖 LaSalle's invariance principle (informal)

Let V be a continuously differentiable positive definite function with V̇ ≤ 0. Define E = {x : V̇(x) = 0} — the set where V stops decreasing. Let M be the largest positively invariant set contained in E (the largest set such that any trajectory starting in M stays in M forever). Then every bounded trajectory converges to M as t → ∞.

For the PD pendulum: E = {(θ, θ̇) : θ̇ = 0} — the θ-axis. Is there an invariant set inside E other than the origin? If θ̇ = 0 and θ̇ must remain 0 (for the trajectory to stay in E), then θ̈ = 0 too. From the equation of motion: 0 = −(b+Kd)·0 − g·L·sin(θ) − Kp·θ = −g·L·sin(θ) − Kp·θ. This equation is satisfied only at θ = 0 (for θ in a neighborhood of 0, since sin(θ)/θ → 1). Therefore M = {0}, and LaSalle concludes the system is asymptotically stable — even though V̇ was only negative semi-definite.

LaSalle's principle is especially important in robotics because many physical Lyapunov functions naturally give V̇ = −damping · velocity², which is zero on the zero-velocity manifold. The principle lets you extract asymptotic stability from what looks like an insufficient condition.

💡 LaSalle requires invariance, not just the set E

A subtle error: concluding convergence to E rather than to M. The Van der Pol oscillator has V̇ = 0 on the axis too, but trajectories don't converge to the origin — they converge to a limit cycle. The limit cycle is the largest invariant set inside the "E" of that system. LaSalle's principle is telling you the truth; you have to find M correctly. If you misidentify M as just "where V̇ = 0," you will draw wrong stability conclusions.

FOLLOWBOTEnergy as Lyapunov function for FollowBot's arm

FollowBot's 6-DOF arm has its full dynamics model derived earlier in Stage 3. For a single joint (joint i) under PD control with setpoint q*ᵢ, define the error eᵢ = qᵢ − q*ᵢ. The equation of motion (ignoring coupling terms for the single-joint analysis) is:

Mᵢᵢ(q)·ëᵢ + bᵢ·ėᵢ = −Kp·eᵢ − Kd·ėᵢ + τ_gravity(q)

With gravity compensation (a feedforward term that cancels τ_gravity(q) exactly), the closed-loop reduces to:

Mᵢᵢ·ëᵢ + (bᵢ + Kd)·ėᵢ + Kp·eᵢ = 0

This is a second-order linear system with positive coefficients. Choose the error-energy Lyapunov function:

V(e, ė) = ½·Mᵢᵢ·ėᵢ² + ½·Kp·eᵢ²

V̇ = Mᵢᵢ·ëᵢ·ėᵢ + Kp·eᵢ·ėᵢ = [−(bᵢ+Kd)·ėᵢ − Kp·eᵢ]·ėᵢ + Kp·eᵢ·ėᵢ = −(bᵢ+Kd)·ėᵢ² ≤ 0.

LaSalle's principle then certifies asymptotic stability at (eᵢ, ėᵢ) = (0, 0). This is the formal proof that the gravity-compensated PD controller drives joint i to its setpoint.

For the full arm with all 6 joints and coupling terms, the analysis extends using the full robot inertia matrix M(q). Define:

V(e, ė) = ½·ėᵀ M(q) ė + ½·eᵀ Kp e

where Kp is the diagonal proportional gain matrix. The coupling terms in the Coriolis and centrifugal matrix C(q, q̇) are handled by the skew-symmetry property of [Ṁ − 2C]: for robot manipulators, ėᵀ [Ṁ(q) − 2C(q,q̇)] ė = 0, which makes the coupling terms vanish in V̇. The result: with gravity compensation and positive Kp, Kd, the full 6-DOF arm is asymptotically stable at any setpoint.

🔑 FollowBot milestone context

With this proof in hand, the claim "the PD velocity controller drives FollowBot's arm to the handoff pose" now has a mathematical certificate. The settling-time spec from Lesson 3.4 (Ziegler-Nichols tuning) can be cross-checked: if the closed-loop poles (for the linearized system) are at σ ± jω, then the settling time is approximately 4/σ (for ζ < 1, underdamped case). The Lyapunov analysis guarantees convergence; the pole locations set the rate. The figure-eight trajectory tracking from the milestone involves time-varying setpoints — that requires input-to-state stability (ISS), which extends this framework to tracking errors rather than setpoint errors.

lyapunov_monitor.pyrclpy · real-time V monitor for FollowBot's arm joint
import rclpy
from rclpy.node import Node
from sensor_msgs.msg import JointState
import numpy as np

class LyapunovMonitor(Node):
    # Publishes the Lyapunov function value for joint 0 in real time.
    # V = 0.5*M*dq_dt**2 + 0.5*Kp*e**2  (error-energy form)
    def __init__(self):
        super().__init__('lyapunov_monitor')
        self.Mii   = 0.42   # inertia for joint 0 [kg·m²] from URDF
        self.Kp    = 80.0   # proportional gain [N·m/rad]
        self.q_star = 0.0  # setpoint [rad]
        self.create_subscription(JointState, '/joint_states', self.cb, 10)

    def cb(self, msg):
        if not msg.position or not msg.velocity: return
        q   = msg.position[0]
        dq  = msg.velocity[0]
        e   = q - self.q_star
        V   = 0.5 * self.Mii * dq**2 + 0.5 * self.Kp * e**2
        self.get_logger().info(ff'V={V:.4f}  e={e:.4f} rad  dq={dq:.4f} rad/s')
        # V must be monotonically decreasing. If it ever increases
        # significantly, gravity compensation may have drifted.

def main():
    rclpy.init()
    rclpy.spin(LyapunovMonitor())
    rclpy.shutdown()

This node logs V at every joint state update. In a correctly tuned system, V should be monotonically non-increasing. If V increases between consecutive timesteps (accounting for measurement noise), it is a signal that the gravity compensation model has drifted — the "nominal plant" the analysis was done for no longer matches the real hardware. That is precisely the failure mode we turn to next.

WEAKNESSWhere this bites

✗ Lyapunov stability does not survive model parameter drift

The gravity-compensated PD controller's stability proof assumes the gravity term τ_gravity(q) is computed exactly. In practice, the robot's payload changes (FollowBot's arm picks up objects), links are not rigid, and friction coefficients are estimated. A 20% error in the inertia matrix can shift closed-loop poles into the right half-plane — the system that was proven asymptotically stable becomes unstable. Lyapunov analysis certifies stability for the nominal closed-loop system. Robust stability (stability for all plants in a parameterized uncertainty set) requires a different framework — either H∞ analysis, Lyapunov with parameter-dependent Lyapunov functions, or the structured singular value μ. Do not cite a Lyapunov proof as robustness evidence without stating the uncertainty bounds under which it holds.

✗ Finding a Lyapunov function does not mean the system is in the region of attraction

A Lyapunov proof of local asymptotic stability certifies a neighborhood of the origin. The size of that neighborhood (the region of attraction) is the largest level set {x : V(x) ≤ c} that fits inside the domain D where V̇ < 0. If you start the robot outside this region — for example, placing a joint at 150° when the provably stable neighborhood extends only to ±45° — the Lyapunov proof says nothing. The robot may converge to a different equilibrium (another link stop), oscillate, or diverge. Practitioners often underestimate this: "we proved stability" without checking whether the intended initial conditions are inside the certified region.

✗ Misapplying LaSalle: confusing E with M

LaSalle's principle guarantees convergence to the largest invariant set M inside E = {V̇ = 0}, not to E itself. For the PD arm, E is the zero-velocity manifold and M = {origin} — the conclusion is correct. But for systems with limit cycles (Van der Pol) or multiple equilibria, E can contain invariant sets other than the origin. If you stop the analysis at "V̇ ≤ 0 → converges to E" and E is large, you will overstate the stability result. Always find M explicitly, not just E. In practice, this means verifying that no non-trivial trajectory can remain in E forever — the argument performed above for the pendulum (θ̇ = 0 ⟹ θ̈ = 0 ⟹ θ = 0).

KEY INSIGHTHow it connects

Lyapunov theory sits at the mathematical core of modern control. LQR (Lesson 3.7) is derived by minimizing a cost function that acts as a Lyapunov function for the optimal closed-loop. Model Predictive Control (Lesson 3.8) uses Lyapunov descent as a terminal constraint to certify recursive feasibility. Passivity-based control for full robot dynamics (an advanced topic beyond Stage 3) is an extension of the energy-based Lyapunov argument introduced here. Every time you see a controller gain matrix and a claim of stability, ask: what is the Lyapunov function, and what is the certified region of attraction?

GLOSSARYKey terms

Lyapunov stability (stable in the sense of Lyapunov)
An equilibrium is Lyapunov stable if trajectories starting sufficiently close to it remain close for all time. Does not imply convergence to the equilibrium — an undamped oscillator is Lyapunov stable but not asymptotically stable.
Asymptotic stability
Lyapunov stability plus convergence: trajectories not only stay bounded but also converge to the equilibrium as t → ∞. The standard requirement for setpoint control in robotics.
Exponential stability
Asymptotic stability with a guaranteed exponential convergence rate ‖x(t)‖ ≤ c·e⁻ᵅᵗ‖x(0)‖. Implies predictable settling time; can be certified by showing V̇ ≤ −αV for some α > 0.
Lyapunov function
A continuously differentiable positive definite scalar function V(x) whose time derivative along system trajectories is non-positive (V̇ ≤ 0). Its existence certifies stability; strict negativity (V̇ < 0) certifies asymptotic stability.
Positive definite function
A function V : ℝⁿ → ℝ satisfying V(0) = 0 and V(x) > 0 for all x ≠ 0. The bowl-shaped property that makes V a valid Lyapunov candidate.
LaSalle's invariance principle
Extends Lyapunov analysis to cases where V̇ is only negative semi-definite (V̇ ≤ 0). Guarantees convergence to the largest positively invariant set M contained in E = {x : V̇(x) = 0}. Critical for robot arm PD control where V̇ = 0 on the zero-velocity manifold.
Phase portrait
A plot of the vector field ẋ = f(x) in state space for a second-order system. Equilibria appear as fixed points; stable equilibria attract nearby trajectories; saddles have stable and unstable manifolds. Level curves of a Lyapunov candidate overlaid on the portrait give a visual check of the V̇ ≤ 0 condition.
Region of attraction
The set of initial conditions from which trajectories converge to a stable equilibrium. Inner-estimated by the largest sub-level set {x : V(x) ≤ c} contained inside the domain where V̇ ≤ 0. Outside this region, local stability proofs give no guarantees.

ACTIVE RECALLCheck your understanding

Answer in your own words first, then reveal.

1An undamped harmonic oscillator ẍ + x = 0 has trajectories that circle the origin forever. Is this system Lyapunov stable, asymptotically stable, or neither? Explain why.›

It is Lyapunov stable but not asymptotically stable. The energy function V = ½ẋ² + ½x² is positive definite and V̇ = ẋẍ + xẋ = ẋ(−x) + xẋ = 0 everywhere — the energy is conserved. Trajectories starting close to the origin (small initial energy) stay on a small ellipse, so they remain close — this is Lyapunov stability. But they never converge to (0,0); they orbit forever. Asymptotic stability requires convergence, which requires energy dissipation. Without damping, there is none.

2Why can't you just use the Lyapunov stability theorem (V̇ < 0 strictly) to conclude asymptotic stability for the PD-controlled pendulum, and what does LaSalle's principle add?›

The energy-based Lyapunov analysis produces V̇ = −(b+Kd)·θ̇², which is zero whenever θ̇ = 0 (everywhere on the θ-axis, not just at the origin). Because V̇ is only negative semi-definite, the basic Lyapunov theorem can conclude only Lyapunov stability — trajectories stay near the origin but might not converge. LaSalle's principle fills the gap: define E = {θ̇ = 0}. Ask: can a trajectory stay in E forever (i.e., is E positively invariant)? If θ̇ = 0 must persist, then θ̈ = 0 too. From the equation of motion, θ̈ = 0 and θ̇ = 0 together force θ = 0 (near the origin). So the largest invariant set in E is just {0}, and LaSalle concludes that all bounded trajectories converge to {0} — asymptotic stability.

3FollowBot's arm picks up a 1 kg payload it wasn't modeled for. The gravity-compensation term in the controller now systematically underestimates gravity by 20%. Does the Lyapunov stability proof still hold? What breaks first?›

No — the proof breaks. The Lyapunov analysis was done for the nominal plant where gravity compensation cancels τ_gravity exactly. With a 20% underestimate, the closed-loop equation gains a disturbance term d(q) = 0.2·τ_gravity(q). The V̇ calculation now has an extra term V̇ = −(b+Kd)·ėᵢ² + d(q)·ėᵢ, which may be positive for some states. The system can still converge to a non-zero steady-state error (where d(q) = Kp·eᵢ), meaning the equilibrium shifts away from zero. This is not a stability failure in the linear sense — it is a biased equilibrium — but the proof that the origin is asymptotically stable is no longer valid for the real plant. The Lyapunov monitor node from the lesson would show V increasing in early transients, flagging the model mismatch before behavior degrades.

4A colleague proposes V(x₁, x₂) = x₁² as a Lyapunov function for a 2D system. What is wrong with this candidate before you even compute V̇?›

It is not positive definite. V(0, x₂) = 0 for any value of x₂ — the function is zero along the entire x₂-axis, not just at the origin. A Lyapunov function must satisfy V(x) > 0 for all x ≠ 0, which x₁² fails for all points of the form (0, x₂) with x₂ ≠ 0. Geometrically, the "level curves" are pairs of vertical lines (x₁ = ±c), which are not closed curves — they are not bowls. This means the function provides no containment: a trajectory can move along the x₂-axis with increasing x₂ while V remains zero, potentially escaping to infinity while V never increases. The candidate must be rejected on positive definiteness grounds before computing V̇.

Next: Bode plots and robustness margins — the frequency-domain complement to Lyapunov →