Algorithmadvanced
Sontag's universal formula
Also called Sontag's formula.
Gives an explicit stabilizing feedback from a control Lyapunov function, smooth away from the origin.
- Time
- O(n m) worst
- Space
- O(m) extra
- Where
- m = the number of inputs; n = the number of states
- Model
- Real RAM
- Properties
- deterministicexactonlineiterative
- Evidence
- Proof sketchCode in 1 languages
- Origin
- Eduardo D. Sontag, 1989
Sontag's universal formula turns a control Lyapunov function of a control-affine system into a feedback by one explicit expression in the two Lie derivatives and . The feedback makes , which is negative at every nonzero state, and it is smooth everywhere except perhaps at the origin. It is the constructive half of Artstein's theorem: Artstein proved that such a feedback exists, and the formula writes one down. The feedback is continuous at the origin exactly when has the small control property.
In plain words
Suppose you already have an energy-like measure of how far the system is from rest, and you know that at every state some input can make that measure go down. You still need a rule that picks one input at each state. This rule is a single closed formula. At each state it looks at two numbers: how fast the measure changes when you do nothing, and how strongly the input can push the measure. If doing nothing already lowers the measure, the rule applies only a small push. If doing nothing raises it, the rule pushes hard against it. The rule never divides by zero in a bad way, it changes smoothly from state to state, and it always makes the measure fall. You do not tune anything. All the design work is in the choice of the measure.
The problem
Input. Smooth maps and with , and a smooth, positive definite and proper (radially unbounded) function that is a control Lyapunov function: at every , implies . Smoothness makes locally Lipschitz wherever is smooth, so solutions exist and are unique there (see the Lipschitz condition and the Picard-Lindelöf theorem). Here is a number and is a row of numbers.
Output. A feedback with such that
- is smooth on ;
- along , for every ;
- if also has the small control property, is continuous at and the origin of the closed loop is globally asymptotically stable.
The small control property says: for every there is a such that each with has some input with and . Norms here are Euclidean.
The algorithm
SONTAG(x) ▷ f, g and ∇V are given- 1
a ← ∇V(x) · f(x) ▷ L_f V(x), a number - 2
b ← ∇V(x) g(x) ▷ L_g V(x), a row of m numbers - 3
β ← b b^T ▷ |b|^2 - 4
if β = 0 then return u = 0 - 5
s ← sqrt(a^2 + β^2); if a > 0 then φ ← (a + s)/β else φ ← β/(s - a) - 6
return u = -φ b^T
Lines L1 and L2 evaluate the two Lie derivatives at the current state. If the input has no effect on at this state (line L4), the formula returns zero; for a control Lyapunov function this happens only where the drift already lowers . Otherwise line L5 computes the scalar gain
and line L6 pushes along , the direction in which the input lowers fastest. The two branches at line L5 are equal, because . The second branch avoids the cancellation in when is negative.
The gain is the positive root of . With ,
So the closed loop lowers at least at the rate and at least at the rate . When the drift helps ( and small) the gain is , which is small. When the drift hurts () the gain is about , enough to cancel the drift twice over.
Example
The check value. Take and . Then , and . Line L5 gives , so and the closed loop is . For the same steps give , which is the LQR gain of the scalar Riccati equation . For this is .
A nonlinear system. Take
Then and . Where , for , so is a control Lyapunov function on the whole plane. The drift raises only where . Start at , where , and line L5 gives , so and . A 4th order Runge-Kutta simulation with step , with the feedback evaluated inside the right side, gives:
| 0 | 2 | 1 | -8.12311 | 2.5 |
| 0.5 | 2.03195 | 0.42643 | -0.06851 | 2.15533 |
| 1 | 1.84232 | 0.40220 | -0.03669 | 1.77796 |
| 2 | 1.23857 | 0.37134 | -0.03069 | 0.83597 |
| 4 | 0.26436 | 0.25125 | -0.10165 | 0.06651 |
| 6 | 0.03733 | 0.07237 | -0.05567 | 0.00332 |
| 8 | 0.00506 | 0.01374 | -0.01200 | 0.000107 |
| 10 | 0.00068 | 0.00229 | -0.00209 | 0.0000028 |
In the first half second the input is large, because the drift pushes up and the formula pushes down until . After that the drift lowers by itself, and the input stays small. decreases at every one of the 1000 steps. Near the origin , so and ; this is why the feedback is continuous at here.
Correctness
The full proof is in proofs/correctness.md. Its main steps:
- The derivative. With , when and when . For a control Lyapunov function both are negative at .
- Smooth away from the origin. On the open set , is the root of at which the derivative in is (or on ). The implicit function theorem makes real-analytic on . A control Lyapunov function keeps in for , so is smooth there.
- Continuity at the origin. If , and . If , the small control property gives , and then . Since , . Conversely, if is continuous at , the input itself shows the small control property.
- Global asymptotic stability. With the small control property, the closed loop is continuous, solutions are unique, and is a Lyapunov function in the sense of Lyapunov's direct method.
The tests check the check value and the scalar LQR gain, the identity and the quadratic for on 2000 random inputs with up to 3 entries, the table above within , that decreases at every step, the bound near the origin, the unbounded feedback of the pitfall below, and a closed loop for the double integrator with the LQR matrix as .
Proof: Sontag's formula makes the derivative of the control Lyapunov function negative, is smooth away from the origin, and is continuous at the origin exactly under the small control propertyfull
The system is with , , and smooth () and . is smooth, positive definite and proper (radially unbounded). For a state write
where is the Euclidean norm. is a control Lyapunov function if implies for every . has the small control property if for every there is such that every with has some with and .
The algorithm (lines L1 to L6) returns if and otherwise, where
Lemma 1: the two forms at line L5 agree
Let and . Then , so , and . Divide by : . So both branches of line L5 compute . The second form adds two nonnegative numbers when , so it has no cancellation.
Lemma 2: the closed loop derivative
For every , with ,
Proof. If , and . If , , so .
Consequence. If is a control Lyapunov function, then for every . If , . If and , the definition gives .
Lemma 3: phi is real-analytic on the set S
Let . is open, and is real-analytic on .
Proof. Put . For the roots of are , and is the larger one, so . For and , , which is zero at . So on all of . The partial derivative is . At with it equals . At with , it equals . By the real-analytic implicit function theorem, near each point of the equation has a unique real-analytic solution close to . It remains to show that this solution is itself. On , is the larger root, which is analytic there by the formula. Near a point with , Lemma 1 gives for , and this expression is also at . The expression is a quotient of analytic functions with a denominator near , so it is analytic near , and it equals there. So is real-analytic on .
Theorem 1: smooth away from the origin
If is a control Lyapunov function, then is smooth on .
Proof. Let . If , then . If , the definition gives , so again . The maps , and are smooth, and is open. On a neighborhood of , is a composition and product of smooth maps, by Lemma 3. Note that on the formula gives , which is the value that line L4 returns, so one smooth expression covers both branches.
Theorem 2: continuity at the origin
Set . Then is continuous at if and only if has the small control property.
Proof. First, . has a minimum at , so .
() Let . Take from the small control property, and take such that when ; exists because is continuous and . Let . If , . Otherwise . There are two cases.
- . By Lemma 1, with and , so and .
- . The small control property gives a with and . By the Cauchy-Schwarz inequality, . Also . So , and .
In both cases . As is arbitrary, .
() Let be continuous at , and let . Take with for . For , the input has and, by Lemma 2 and its consequence, . This is the small control property.
Theorem 3: global asymptotic stability
If is a control Lyapunov function with the small control property, the closed loop has the origin as a globally asymptotically stable equilibrium.
Proof. is continuous on by Theorems 1 and 2, and . On , is smooth, so it is locally Lipschitz there, and solutions are unique while they stay away from (Picard-Lindelöf). A solution that is at at some time stays at for : along any solution, , because it is negative for and . So for , and is positive definite. So every initial state has a unique forward solution. is proper, so the sublevel set is compact and holds the whole solution, which therefore exists for all . With positive definite and proper and for , Lyapunov's direct method gives global asymptotic stability; its proof uses only existence, uniqueness and the decrease of along solutions.
The implementation
sontag_feedback computes at line L1 and the entries of at line L2 from the given , and . sontag_gain computes at line L3, returns at line L4 when , computes at line L5 with the form of Lemma 1 that has no cancellation, and returns at line L6. Each line is a direct transcription of the definition of , so the code returns up to the rounding of floating point arithmetic.
Complexity
Count real operations and one square root at unit cost, as in the real RAM, with states and inputs.
- Line L1. A dot product of length : .
- Line L2. A row vector times an matrix: .
- Lines L3 to L6. operations and one square root.
So one evaluation costs operations plus one evaluation each of , and , which the bound does not count. The extra space is for and . A closed-loop simulation costs the number of steps times this, times 4 for the four stages of RK4.
Properties
- Explicit. No optimization, no iteration and no tuning parameter. Every design choice is in .
- Smooth away from the origin. The formula is real-analytic in on the set where or , so is as smooth as , and there.
- Continuous at the origin if and only if has the small control property.
- Depends on the scaling of V. Replacing by with changes to and changes the feedback. The decrease holds for every scaling.
- Related to optimal control. In the scalar example the formula gives the LQR gain, and Sontag (1998, Exercise 5.9.11) relates the formula with an LQ problem in general. Freeman and Kokotović (1996) show that the pointwise min-norm laws, close relatives of the formula, are optimal for meaningful costs.
Variants and improvements
- A general gain function. Sontag's paper allows with a real-analytic that is positive for and . The page uses . Other choices trade input size against the decay rate of .
- Bounded inputs. Lin and Sontag (1991) give a version for , with an extra scaling that keeps the input in the unit ball. It needs to have a decrease with bounded input, which is a stronger assumption.
- Pointwise min-norm control. Freeman and Kokotović (1996) choose at each state the input of least norm that makes for a given positive function . This is a small quadratic program with one constraint, with the same closed form as the projection in the CBF safety filter.
- Where the control Lyapunov function comes from. For a system in strict feedback form, backstepping builds and a feedback together. For a polynomial system, sum-of-squares programming can search for . For a linear system, with from the Riccati equation.
When to use it
Use it when you have a control Lyapunov function and want a feedback with no further design, for example after backstepping or when comes from a physical energy. It is also a safe fallback inside a supervisor: whatever the state, it lowers . It is not the best choice when the input is limited, because the gain grows where and is small; use the bounded version or a quadratic program with input limits there. When the performance matters more than the simplicity, an optimal control design or model predictive control with as a terminal cost uses the same better.
Pitfalls
- Cancellation at line L5. The direct form loses all digits when and . In IEEE double precision, and give exactly, and the direct form returns ; the true value is . Use the second form of line L5 when .
- No small control property. The formula is then discontinuous at the origin. For with : and , and lines L5 and L6 give , so , which is unbounded near . The closed loop is fine on its own, but the input is not. In this system no continuous feedback can do better: if is continuous, , so has the sign of near .
- V that is not a control Lyapunov function. Line L4 returns whenever , whatever is. For the double integrator , with , and , so on the line both vanish. Line L4 returns there, and every point is an equilibrium of the closed loop. Check the control Lyapunov function condition before you trust the formula.
- Sampled implementation. The proof assumes that line L6 is evaluated continuously. In the nonlinear example with the input held constant over intervals of , increases on 7 of the 1000 simulation steps, and with a hold of the first input drives to and rises from to . The state still went to the origin in these runs, but the decrease of is no longer guaranteed.
Implementations
Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.
# SPDX-License-Identifier: MIT
# Shared helper of the control pages of https://algorithm.tamnd.com/. The authors are listed in prov/.
"""Fixed step simulation for the control pages.
Conventions:
- A continuous-time system is a function f(t, x, u) that returns x' as a
flat list. x is a flat list. u is whatever the control returns (a flat
list, a scalar, or None when there is no control).
- A discrete-time system is a function F(k, x, u) that returns x_(k+1).
- The integrator is the classical 4th order Runge-Kutta method with a fixed
step dt. The input is held constant over each step.
- Time t_k = t0 + k dt is computed by multiplication, not by summation.
- The number of steps round((t1 - t0) / dt) and the hold ratio
round(hold / dt) must match the real ratios within 1e-9 (relative), or
ValueError is raised.
This file holds no controller or observer of a control page.
"""
__all__ = ["rk4_step", "simulate", "simulate_discrete", "lti"]
def _axpy(a, x, y):
return [yi + a * xi for xi, yi in zip(x, y)]
def rk4_step(f, t, x, u, dt):
"""Return x(t + dt) after one RK4 step of x' = f(t, x, u), u held constant."""
k1 = f(t, x, u)
k2 = f(t + dt / 2, _axpy(dt / 2, k1, x), u)
k3 = f(t + dt / 2, _axpy(dt / 2, k2, x), u)
k4 = f(t + dt, _axpy(dt, k3, x), u)
return [xi + dt / 6 * (a + 2 * b + 2 * c + d) for xi, a, b, c, d in zip(x, k1, k2, k3, k4)]
def _ratio(num, den, what):
r = round(num / den)
if abs(r * den - num) > 1e-9 * max(abs(num), abs(den)):
raise ValueError(what + " is not an integer multiple of dt")
return r
def simulate(f, x0, t0, t1, dt, control=None, hold=None):
"""Simulate x' = f(t, x, u) from x(t0) = x0 to t1 with RK4 and step dt.
control(t, x) gives the input. It is called at each sampling instant
t0 + j hold, and its value is held (zero-order hold) until the next
instant. hold must be an integer multiple of dt; hold = None means
hold = dt. With control = None the input is None.
Returns (ts, xs, us): ts has N + 1 times, xs the N + 1 states, and us the
N inputs, where us[k] acts on [ts[k], ts[k + 1]].
"""
if dt <= 0:
raise ValueError("dt must be positive")
n_steps = _ratio(t1 - t0, dt, "t1 - t0")
if n_steps < 0:
raise ValueError("t1 is before t0")
r = 1 if hold is None else _ratio(hold, dt, "hold")
if r < 1:
raise ValueError("hold must be at least dt")
x = list(x0)
ts = [t0]
xs = [list(x)]
us = []
u = None
for k in range(n_steps):
t = t0 + k * dt
if control is not None and k % r == 0:
u = control(t, list(x))
x = rk4_step(f, t, x, u, dt)
ts.append(t0 + (k + 1) * dt)
xs.append(x)
us.append(u)
return ts, xs, us
def simulate_discrete(F, x0, N, control=None):
"""Run x_(k+1) = F(k, x_k, u_k) for k = 0, ..., N - 1.
u_k = control(k, x_k), or None if control is None. Returns (xs, us) with
N + 1 states and N inputs. Exact if F and control are exact.
"""
x = list(x0)
xs = [list(x)]
us = []
for k in range(N):
u = control(k, list(x)) if control is not None else None
x = list(F(k, x, u))
xs.append(x)
us.append(u)
return xs, us
def lti(A, B=None):
"""Return f(t, x, u) = A x + B u for the system x' = A x + B u.
u may be a flat list, a scalar (one input) or None (zero input). B may
be None for a system with no input.
"""
def f(t, x, u):
dx = [sum(a * xi for a, xi in zip(row, x)) for row in A]
if B is None or u is None:
return dx
uu = u if isinstance(u, (list, tuple)) else [u]
return [d + sum(b * ui for b, ui in zip(row, uu)) for d, row in zip(dx, B)]
return f
def _self_test():
import math
f = lti([[-1.0]])
_, xs, _ = simulate(f, [1.0], 0.0, 1.0, 0.01)
assert abs(xs[-1][0] - math.exp(-1.0)) < 1e-9
return True
if __name__ == "__main__":
_self_test()
sontag_universal_formula.py 87 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/sontag-universal-formula/. The authors are listed in prov/B75HKW.jsonl.
"""Sontag's universal formula for a control-affine system
x' = f(x) + g(x) u, x in R^n, u in R^m,
with a known control Lyapunov function V. At a state x let
a = L_f V(x) = grad V(x) . f(x) (a number)
b = L_g V(x) = grad V(x) g(x) (a row of m numbers)
beta = |b|^2.
The feedback is u = 0 if beta = 0, and otherwise
u = -phi b^T, phi = (a + sqrt(a^2 + beta^2)) / beta.
Along the closed loop, V' = a - phi beta = -sqrt(a^2 + beta^2), which is
negative wherever a < 0 or b != 0, that is, at every x != 0 when V is a
control Lyapunov function.
When a <= 0 the numerator a + sqrt(a^2 + beta^2) cancels. The code then uses
the equal form phi = beta / (sqrt(a^2 + beta^2) - a), which has no
cancellation.
Precondition: f, g and grad V are given as functions that return lists. The
caller must make sure that V is a control Lyapunov function; the code does
not check it.
Cost: O(n m) arithmetic operations and one square root per state, plus one
evaluation each of f, g and grad V.
"""
import math
__all__ = ["sontag_gain", "sontag_feedback", "closed_loop"]
def sontag_gain(a, b):
"""Return the input u (a list of m numbers) from a = L_f V and b = L_g V.
b is a list of m numbers. The result is u = -phi b with
phi = (a + sqrt(a^2 + |b|^4)) / |b|^2, and u = 0 when b = 0.
"""
beta = sum(bj * bj for bj in b) # @line L3
if beta == 0: # @line L4
return [0.0 for _ in b] # @line L4
s = math.sqrt(a * a + beta * beta) # @line L5
if a > 0: # @line L5
phi = (a + s) / beta # @line L5
else:
phi = beta / (s - a) # @line L5
return [-phi * bj for bj in b] # @line L6
def sontag_feedback(f, g, grad_V):
"""Return the feedback k(x) of Sontag's formula.
f(x) returns the drift as a list of n numbers, g(x) returns the input
matrix as n rows of m numbers, and grad_V(x) returns the gradient of V as
a list of n numbers. k(x) returns a list of m numbers.
"""
def k(x):
p = grad_V(x)
fx = f(x)
gx = g(x)
m = len(gx[0])
a = sum(pi * fi for pi, fi in zip(p, fx)) # @line L1
b = [sum(p[i] * gx[i][j] for i in range(len(p))) for j in range(m)] # @line L2
return sontag_gain(a, b)
return k
def closed_loop(f, g, grad_V):
"""Return F(t, x, u) = f(x) + g(x) k(x) for the simulation helper.
The feedback is evaluated inside the right side, so an RK4 step sees
the continuous closed loop. The argument u is ignored.
"""
k = sontag_feedback(f, g, grad_V)
def F(t, x, u=None):
uu = k(x)
fx = f(x)
gx = g(x)
return [fx[i] + sum(gx[i][j] * uu[j] for j in range(len(uu))) for i in range(len(x))]
return F
test_sontag_universal_formula.py 160 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/sontag-universal-formula/. The authors are listed in prov/B75HKW.jsonl.
import math
import random
import ctlsim
from sontag_universal_formula import closed_loop, sontag_feedback, sontag_gain
# Simulations: classical RK4 (ctlsim), step dt = 0.01, feedback evaluated
# inside the right side. Tolerances are stated at each check.
DT = 0.01
def steps(T):
n = round(T / DT)
assert abs(n * DT - T) < 1e-12
return n
def scalar_system(c, d):
return (lambda x: [c * x[0]]), (lambda x: [[d]]), (lambda x: [x[0]])
def page_system():
def f(x):
return [-x[0] + x[0] * x[0] * x[1], 0.0]
def g(x):
return [[0.0], [1.0]]
def grad_V(x):
return [x[0], x[1]]
return f, g, grad_V
def test_check_value_scalar():
# x' = x + u, V = x^2 / 2: a = x^2, b = x, u = -(1 + sqrt 2) x.
f, g, gv = scalar_system(1.0, 1.0)
k = sontag_feedback(f, g, gv)
for x in [-3.0, -0.5, 0.25, 1.0, 7.0]:
assert abs(k([x])[0] + (1 + math.sqrt(2)) * x) < 1e-12 * max(1.0, abs(x))
assert k([0.0]) == [0.0]
# Closed loop x' = -sqrt(2) x, so x(2) = exp(-2 sqrt 2).
_, xs, _ = ctlsim.simulate(closed_loop(f, g, gv), [1.0], 0.0, 2.0, DT)
assert len(xs) == steps(2.0) + 1
assert abs(xs[-1][0] - math.exp(-2 * math.sqrt(2))) < 1e-9
def test_scalar_gain_equals_lq_gain():
# x' = c x + u with V = x^2 / 2 gives u = -(c + sqrt(c^2 + 1)) x, the
# gain of the scalar CARE with q = r = 1 (P = c + sqrt(c^2 + 1)).
rng = random.Random(11)
for _ in range(50):
c = rng.uniform(-5, 5)
x = rng.uniform(-4, 4)
if abs(x) < 1e-3:
continue
f, g, gv = scalar_system(c, 1.0)
u = sontag_feedback(f, g, gv)([x])[0]
P = c + math.sqrt(c * c + 1)
assert abs(P * P - 2 * c * P - 1) < 1e-9 * (1 + P * P)
assert abs(u + P * x) < 1e-9 * (1 + abs(P * x))
def test_derivative_identity_and_quadratic():
# a + b.u = -sqrt(a^2 + |b|^4) and beta phi^2 - 2 a phi - beta = 0.
rng = random.Random(7)
for _ in range(2000):
m = rng.randint(1, 3)
a = rng.choice([-1, 1]) * 10 ** rng.uniform(-6, 3)
b = [rng.choice([-1, 1]) * 10 ** rng.uniform(-3, 2) for _ in range(m)]
u = sontag_gain(a, b)
beta = sum(bj * bj for bj in b)
s = math.sqrt(a * a + beta * beta)
vdot = a + sum(bj * uj for bj, uj in zip(b, u))
assert abs(vdot + s) <= 1e-12 * (abs(a) + s) * 10
phi = -u[0] / b[0]
assert phi > 0
assert abs(beta * phi * phi - 2 * a * phi - beta) <= 1e-10 * (beta * phi * phi + abs(a) * phi + beta)
def test_zero_b_gives_zero_input():
assert sontag_gain(-2.0, [0.0, 0.0]) == [0.0, 0.0]
assert sontag_gain(0.0, [0.0]) == [0.0]
def test_stable_form_when_a_negative():
# The naive (a + sqrt(a^2 + beta^2)) / beta returns 0 here in floating
# point. The true value is beta / (1 + sqrt(1 + beta^2)), about 5e-9.
a, beta = -1.0, 1e-8
naive = (a + math.sqrt(a * a + beta * beta)) / beta
assert naive == 0.0
u = sontag_gain(a, [math.sqrt(beta)])
phi = -u[0] / math.sqrt(beta)
exact = beta / (1 + math.sqrt(1 + beta * beta))
assert abs(phi - exact) < 1e-12 * exact
def test_page_example_trace():
f, g, gv = page_system()
k = sontag_feedback(f, g, gv)
assert abs(k([2.0, 1.0])[0] + (4 + math.sqrt(17))) < 1e-12
_, xs, _ = ctlsim.simulate(closed_loop(f, g, gv), [2.0, 1.0], 0.0, 10.0, DT)
V = [(x[0] ** 2 + x[1] ** 2) / 2 for x in xs]
assert all(V[i + 1] < V[i] for i in range(len(V) - 1))
table = {1.0: (1.84232, 0.40220), 2.0: (1.23857, 0.37134), 4.0: (0.26436, 0.25125), 6.0: (0.03733, 0.07237)}
for T, (x1, x2) in table.items():
x = xs[steps(T)]
assert abs(x[0] - x1) < 1e-5 and abs(x[1] - x2) < 1e-5
assert math.hypot(*xs[-1]) < 3e-3
def test_small_control_property_on_page_example():
# For |x| <= 0.5, x1 x2 < 1, so a <= 0 and |k(x)| <= |b| = |x2| <= |x|.
f, g, gv = page_system()
k = sontag_feedback(f, g, gv)
rng = random.Random(3)
for _ in range(2000):
r = 0.5 * rng.random()
t = rng.uniform(0, 2 * math.pi)
x = [r * math.cos(t), r * math.sin(t)]
assert abs(k(x)[0]) <= abs(x[1]) + 1e-15
def test_no_small_control_property_gives_unbounded_feedback():
# x' = x + x^2 u, V = x^2 / 2: u = -(1 + sqrt(1 + x^8)) / x.
k = sontag_feedback(lambda x: [x[0]], lambda x: [[x[0] ** 2]], lambda x: [x[0]])
for x in [1.0, 0.1, 0.01, 1e-3]:
u = k([x])[0]
assert abs(u + (1 + math.sqrt(1 + x ** 8)) / x) < 1e-9 * abs(u)
assert abs(u) >= 2 / x * (1 - 1e-12)
def test_double_integrator_with_lq_lyapunov_function():
# V = x^T P x with the LQR solution P = [[sqrt 3, 1], [1, sqrt 3]].
r3 = math.sqrt(3)
P = [[r3, 1.0], [1.0, r3]]
def V(x):
return sum(x[i] * P[i][j] * x[j] for i in range(2) for j in range(2))
f = lambda x: [x[1], 0.0]
g = lambda x: [[0.0], [1.0]]
gv = lambda x: [2 * (P[0][0] * x[0] + P[0][1] * x[1]), 2 * (P[1][0] * x[0] + P[1][1] * x[1])]
_, xs, _ = ctlsim.simulate(closed_loop(f, g, gv), [1.0, 0.0], 0.0, 15.0, DT)
vs = [V(x) for x in xs]
assert all(vs[i + 1] < vs[i] for i in range(len(vs) - 1))
assert math.hypot(*xs[-1]) < 1e-3
def test_two_inputs():
# x' = u with u in R^2 and V = |x|^2 / 2: a = 0, b = x, u = -x.
k = sontag_feedback(lambda x: [0.0, 0.0], lambda x: [[1.0, 0.0], [0.0, 1.0]], lambda x: list(x))
rng = random.Random(5)
for _ in range(100):
x = [rng.uniform(-2, 2), rng.uniform(-2, 2)]
u = k(x)
assert abs(u[0] + x[0]) < 1e-12 and abs(u[1] + x[1]) < 1e-12
History
Artstein (1983) proved that a control-affine system with a smooth control Lyapunov function has a feedback that is smooth away from the origin, by an argument with relaxed controls that does not give a formula. Sontag (1983) characterized asymptotic controllability by a Lyapunov-like function. In 1989 Sontag gave the explicit formula, called it "universal" because it depends only on and , and proved that it is real-analytic away from the origin and continuous at it under the small control property. Lin and Sontag (1991) extended it to bounded inputs. Freeman and Kokotović (1996) showed that pointwise min-norm laws built from a control Lyapunov function are optimal for meaningful costs, which made this family of formulas part of the inverse optimal design method.
References
- Eduardo D. Sontag, A 'universal' construction of Artstein's theorem on nonlinear stabilization, Systems and Control Letters 13(2), 117-123, 1989, the formula for control-affine systems and the proof that it is analytic where L_g V is not zero or L_f V is negative
- Eduardo D. Sontag, Mathematical Control Theory, second edition, Springer, 1998, Section 5.9 (Introduction to Nonlinear Stabilization), Proposition 5.9.10 and Exercise 5.9.11; Section 5.7 for control Lyapunov functions
- Miroslav Krstić, Ioannis Kanellakopoulos and Petar Kokotović, Nonlinear and Adaptive Control Design, Wiley, 1995, Section 2.1.2, Control Lyapunov functions
- Randy A. Freeman and Petar V. Kokotović, Inverse optimality in robust stabilization, SIAM Journal on Control and Optimization 34(4), 1365-1391, 1996, robust control Lyapunov functions and the pointwise min-norm control laws
- A universal formula for stabilization with bounded controls, the version of the formula with a bound on the norm of the input
- Zvi Artstein, Stabilization with relaxed controls, Nonlinear Analysis: Theory, Methods and Applications 7(11), 1163-1173, 1983, the existence result that the formula makes explicit
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H1 sketch |
|
| Lean | L0 no Lean part |
|
| Code (python) | I0 not checked yet |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag B75HKW Edit this page History Report an error Markdown