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.

By 9 min read

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.

A certificate for every initial state

Change the candidate, keep the same system

Follow x′ = −x + 4y and y′ = −2y. Both candidates are positive away from the origin. Their derivatives along the flow behave differently. State coordinates, time, and V are dimensionless.

1.00
1.00
Step 0 of 120 · t = 0.00

Global certificate: V = x² + 4y² is positive definite and radially unbounded. Its derivative is −2(x − 2y)² − 8y², strictly negative away from the origin. The origin is globally asymptotically stable. This conclusion holds for every initial state.

At the inspected point, V is decreasing. A negative derivative at one point is not a global proof; the certificate above checks its sign at every state.

Current x
1.0000
Current y
1.0000
Current V
5.0000
Current V derivative
-10.0000
Inspected time
0.00

Does the trajectory stay inside the initial level?

State trajectory and initial Lyapunov level contourBoth axes have the same scale in dimensionless state coordinates. Blue shows the exact trajectory sampled from time zero to six. The open blue ring marks the initial state; the filled blue square marks the inspected state. The amber dashed ellipse is V equal to its initial value, 5.0000. At the origin, this contour is a single point. Bounds follow the initial state and remain fixed when changing the candidate or inspected time.-3-30033yx
Blue curve: trajectory. Open ring: start. Filled square: inspected state. Amber dashed contour: V = V(0). The small cross marks the origin. Equal axis scales preserve the circle or ellipse shape.

Track the selected candidate along the trajectory

Selected Lyapunov candidate against timeBlue shows x squared plus four y squared along the exact trajectory. Amber dashed marks its initial value. The vertical dotted line and blue square mark the inspected time. Time and candidate values are dimensionless. The vertical scale follows the selected candidate and initial state.02.755.5036VTime t
Blue curve: V(t). Amber dashed line: V(0). The vertical guide selects a time; it does not alter the trajectory. Candidate values use their own vertical scale.

The curves sample the analytic solution every 0.05 time units for six time units. There is no numerical integration step. Displayed values round to four decimals; a rounded zero does not mean the state has reached the origin. The algebraic certificate applies for all future times.

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 neighborhoodConclusion
V(0) = 0, V > 0 elsewhere, V̇ ≤ 0The origin is stable.
The same conditions, with V̇ < 0 away from zeroThe origin is locally asymptotically stable.
The strict conditions hold on all of ℝⁿ, and V is radially unboundedThe 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

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.