explainer
Lyapunov stability: prove convergence with a function
Build a Lyapunov function, check its derivative, and prove convergence. See why a failed candidate can coexist with a stable system.
What you will learn
- Calculate the derivative of a candidate function along the system dynamics.
- Check positivity, decreasing value, and the domain of a stability claim.
- Prove global asymptotic stability for a two-state system.
- Explain why a failed candidate does not prove instability.
- Distinguish a sampled trajectory from a proof covering every initial state.
Before you start
Lyapunov stability means that a small enough initial disturbance stays small for all future time. Lyapunov's direct method can establish that property by checking a scalar function of the state. With stronger conditions, the same method also proves convergence to an equilibrium.
Starting from (1, 1), the system below briefly moves farther from the origin. Every trajectory still converges to it. You will check two candidate functions on that same system. One fails the stability test; the other supplies a proof.
Check stability through a scalar function
For a state z that follows ż = f(z), choose a scalar V(z). Think of V as a measure of departure from the target equilibrium. It may resemble stored energy without having energy's physical units.
The chain rule gives its rate of change along the system's motion:
V̇(z) = ∇V(z)ᵀ f(z)
This derivative uses the actual vector field f. A positive V alone says nothing about whether the system moves toward or away from the target.
The ODE stability lesson defines stability and attraction separately. Here the task is to construct a function that certifies both, with every assumption visible.
Keep one coupled system
Use a normalized state z = [x, y]ᵀ and normalized time t. All three are dimensionless. The equations contain no external input:
ẋ = −x + 4y
ẏ = −2y
The origin is an equilibrium: setting x = y = 0 makes both derivatives zero. The coupling 4y can push x upward while y decays. These linear equations have a unique solution for every initial state and all future time.
This is a teaching model. It can represent two coupled error coordinates after normalization; it does not describe a measured robot or include actuator limits and disturbances.
Try squared distance first
Start with squared Euclidean distance, V₁ = x² + y². It equals zero only at the origin and is positive everywhere else. Its derivative is:
V̇₁ = 2x(−x + 4y) + 2y(−2y)
V̇₁ = −2x² + 8xy − 4y²
At (x, y) = (1, 1), V₁ = 2 and V̇₁ = +2. Squared distance initially increases. This candidate fails the requirement that V never increase throughout the domain.
That failure does not establish instability. It rules out this particular function as a certificate on the whole plane. Even restricting attention to a small neighborhood cannot rescue V₁: at any nonzero point (a, a), V̇₁ = 2a² is positive.
Build a function that proves convergence
Try the family V = x² + c y², where c is positive. The derivative becomes −2x² + 8xy − 4c y². Completing the square shows which weights work:
V̇ = −2(x − 2y)² − (4c − 8)y²
Any c > 2 makes this derivative strictly negative away from the origin. Choose c = 4. The new candidate is:
V₂ = x² + 4y²
V̇₂ = −2(x − 2y)² − 8y²
Check each part of the certificate:
- Positive definite: V₂(0, 0) = 0, and V₂ > 0 at every other state.
- Strict decrease: both terms of V̇₂ are nonpositive. They vanish together only when y = 0 and x − 2y = 0, which forces x = 0.
- Global scope: the inequalities hold everywhere. Also V₂ ≥ x² + y², so V₂ grows without bound as the state norm grows. This property is called radial unboundedness.
Together with the smooth dynamics, these conditions prove that the origin is globally asymptotically stable. Small disturbances stay small, and every finite initial state converges to the origin as t increases without bound. At (1, 1), the new values are V₂ = 5 and V̇₂ = −10.
Read the certificate as an ellipse
A sublevel set contains all states with V₂ at or below a chosen value. Starting from (1, 1) gives the set x² + 4y² ≤ 5. Its boundary is an ellipse with horizontal radius √5 and vertical radius √5/2.
Since V₂ cannot increase, this trajectory stays inside that ellipse. The ellipse is an invariant bound on the motion. Its shape allows the ordinary distance to grow for a while without leaving the set.
For any initial state z₀, the same argument gives:
‖z(t)‖² ≤ V₂(z(t)) ≤ V₂(z₀) ≤ 4‖z₀‖²
‖z(t)‖ ≤ 2‖z₀‖
For any allowed distance ε > 0, starting with ‖z₀‖ < ε/2 keeps ‖z(t)‖ < ε forever. This is a concrete Lyapunov stability argument. The bound alone does not show convergence; the strict derivative condition supplies that stronger conclusion.
Compare the two candidates
Switch between the candidates while keeping the initial state fixed. The physical trajectory stays the same. The contour and V history change because you changed the measuring function.
From (1, 1), inspect t = 0.50. The state is approximately (1.561136, 0.367879). V₁ has risen from 2 to 2.572479, while V₂ has fallen from 5 to 2.978485.
The curves use the exact solution, sampled every 0.05 normalized time units:
y(t) = y₀ exp(−2t)
x(t) = x₀ exp(−t) + 4y₀[exp(−t) − exp(−2t)]
Both coordinates tend to zero. This gives an independent check on the conclusion. The certificate above does not require solving these equations, and a finite plot alone would not prove the all-time claim.
State the theorem and its limits
For an autonomous system ż = f(z) with f(0) = 0, assume f is locally Lipschitz and V is continuously differentiable on a neighborhood of zero. Lyapunov's direct method uses these conditions:
| Conditions on that neighborhood | Conclusion |
|---|---|
| V(0) = 0, V > 0 elsewhere, V̇ ≤ 0 | The origin is stable. |
| The same conditions, with V̇ < 0 away from zero | The origin is locally asymptotically stable. |
| The strict conditions hold on all of ℝⁿ, and V is radially unbounded | The origin is globally asymptotically stable. |
Radial unboundedness keeps sublevel sets bounded. Russ Tedrake's Lyapunov analysis notes explain the local/global distinction and extensions when V̇ is only nonpositive.
A useful boundary case is pure rotation: ẋ = −y, ẏ = x. Here V = x² + y² has V̇ = 0 everywhere. Each nonzero trajectory circles the origin at a fixed distance: stable, with no attraction.
A nonpositive derivative can still support convergence after further analysis. LaSalle's invariance principle examines the trajectories that can remain in the set where V̇ = 0. In the rotation example, whole circles remain there, so convergence to the origin does not follow.
Keep the claim tied to the model and domain you checked. A certificate for ideal continuous dynamics does not automatically cover a sampled controller, force saturation, or unmodeled disturbances. Those changes alter the equations used to calculate V̇.
Connect the proof to the Lyapunov equation
For a continuous linear system ż = Az and a symmetric matrix P, write V = zᵀPz. Differentiating gives V̇ = zᵀ(AᵀP + PA)z. The continuous-time Lyapunov equation names the relation:
AᵀP + PA = −Q
If P and Q are positive definite, this gives a quadratic certificate of global asymptotic stability. For a Hurwitz A, whose eigenvalues all have negative real parts, every positive-definite Q gives a unique positive-definite solution P. Stephen Boyd's linear quadratic Lyapunov lecture develops these results.
In this example, the matrices are:
A = [[−1, 4], [0, −2]]
P = [[1, 0], [0, 4]]
Q = [[2, −4], [−4, 16]]
Q is symmetric, its first diagonal entry is 2, and its determinant is 16. These positive leading principal minors establish positive definiteness. The expression −zᵀQz gives exactly the derivative already checked by completing the square.
If feedback sets u = −Kz, apply this test to A − BK, the closed-loop state matrix. The LQR lesson connects a quadratic function to remaining control cost; stability criteria uses characteristic polynomials and feedback margins to answer other stability questions.
Reproduce the calculation in Python
Download the standalone Python example. Save it as lyapunov.py and run it from that folder. It uses the Python standard library:
python3 lyapunov.py --check
python3 lyapunov.py
The script checks the derivative identities, the exact motion, and the two candidates. It prints values at t = 0, 0.5, 1, 2, and 6 for the default state (1, 1). For example, at t = 1 the state is approximately (1.298056, 0.135335), with V₁ = 1.703265 and V₂ = 1.758212.
Numerical checks can catch implementation errors and exhibit a failed inequality. The completed-square argument proves strict decrease for every nonzero state, including points between the samples.
Check another state and another system
Try the boundary weight c = 2. The derivative becomes −2(x − 2y)². Which part of the strict-decrease proof fails?
Check the zero-derivative set
The derivative vanishes on the whole line x = 2y. The strict negative-definiteness test is inconclusive there. The system remains globally asymptotically stable, as the c = 4 certificate already proves. With c = 2, an additional invariance argument can also establish convergence: a nonzero point on x = 2y immediately leaves that line because the derivative of x − 2y equals 6y there.
Change the system to ẋ = x, ẏ = −2y. Test the same weighted function. Then solve the motion from (1, 0) to decide whether the equilibrium is stable.
Check the changed system
Now V̇₂ = 2x² − 16y². The previous proof no longer applies. Along y = 0, x(t) = x₀ exp(t); any nonzero initial x, however small, eventually leaves a fixed neighborhood. This trajectory argument establishes instability. A failed candidate alone did not establish it.
Sources and further study
- Russ Tedrake, Underactuated Robotics: Lyapunov Analysis, for the direct method, regional and global claims, and invariant sets.
- Stephen Boyd, EE363: Linear quadratic Lyapunov theory, for matrix certificates and the continuous-time Lyapunov equation.
For a feedback design that chooses its state weights through an objective, continue with linear quadratic regulation.
For a two-input application, multivariable control builds an error-state certificate and compares convergence with unwanted motion in another output.