This site is version 0.0.1. Most of the code on this site is drafted by an agent and needs review. I apologize for the AI-speak, we are working on rewriting it!
viv-lang.org

vp.control.care

The stabilizing solution X of A^T X + X A - X B R^-1 B^T X + Q = 0, as scipy.linalg.solve_continuous_are(A, B, Q, R).

Part of the distribution vipyr; it runs from a checkout of the repository. Planned on PyPI as pip install vipyr.

Signature

vp.control.care(A, B, Q, R)

Parameters

A : ndarray[float64], required
Range: rank 2, square.
B : ndarray[float64], required
Range: rank 2.
Q : ndarray[float64], required
Range: rank 2, square.
R : ndarray[float64], required
Range: rank 2, square.

Returns

A frozen CareResult. Iterating it gives the fields below in order; it also has params, tests, log and check().

X : ndarray[float64]

Raises

vipyr.ParameterError
A ValueError: an argument outside its range, choices, rank or shape, or one of a group given without the rest; its .param names the argument.
TypeError
An argument of the wrong type, or an unknown keyword.
vipyr.VivBuildError
An ImportError: no C compiler, or the program's C does not build.

Examples

import numpy as np
import vipyr as vp
A = np.array([[0.0, 1.0], [0.0, 0.0]]); B = np.array([[0.0], [1.0]])
r = vp.control.care(A=A, B=B, Q=np.eye(2), R=np.eye(1))
X = r.X
print(np.abs(A.T @ X + X @ A - X @ B @ B.T @ X + np.eye(2)).max() < 1e-13)
assert r.check()
True

Each example ran as written when these pages were generated, and the output shown is what it printed.

Checked against

Reference
scipy.linalg.solve_continuous_are(A, B, Q, R)
Compared by
relative residual of A^T X + X A - X B R^-1 B^T X + Q, scaled by 2|A||X| + |X|^2 |B R^-1 B^T| + |Q| (lib/are's are_residual_rel); the difference from SciPy's X is reported against a looser tolerance
Tolerance
residual 10−13, vs_reference 10−8
Why that tolerance
lib/are holds the relative residual under 4 × 10−15 on its test systems; X itself depends on the problem's conditioning, so agreement with SciPy is a weaker claim

Credits

  • The Schur, Riccati and Lyapunov solvers use algorithms after SLICOT; no SLICOT code is copied.

Source