Invntr
Source

All instruments

lqr

Continuous-time linear-quadratic regulator for a small state-space plant x' = Ax + Bu (up to 8 states, tested to 6): stabilising Riccati solution P (Hamiltonian matrix sign + Newton-Kleinman), gain K = R⁻¹ B'P, closed-loop poles with damping, Riccati residual, and the response to an initial state with an exact cost balance (cost paid + x_end'P x_end = x₀'P x₀).

Writes out/response.csv, out/poles.csv, out/gain.csv.

Field
Dynamics and control
Version
0.1.0
Runs as
Compiled (Rust)
Typical run
0.05 s

Compiled from source: run sh packs/install.sh once before admitting it.

Known answers it must pass

Admission replaylqr 0.1.0 · files ce47b01036e1…cf3c
  1. r0001double integrator Q=I R=1, closed form K=[1, sqrt3], P=[[sqrt3,1],[1,sqrt3]], poles -sqrt3/2 ± j/2 (wn 1, ζ sqrt3/2); rel 10⁻⁹: solver converges to round-offpassed

    K.0.0= 1, within 1.000000 × 10⁻⁹ relativereading not recorded on this page
    K.0.1= 1.732051, within 1.000000 × 10⁻⁹ relativereading not recorded on this page
    P.0.0= 1.732051, within 1.000000 × 10⁻⁹ relativereading not recorded on this page
    P.0.1= 1, within 1.000000 × 10⁻⁹ relativereading not recorded on this page
    P.1.1= 1.732051, within 1.000000 × 10⁻⁹ relativereading not recorded on this page
    max_pole_real_per_s-0.866025 ± 8.7 × 10⁻¹⁰-0.866025lockedunder 0.01 % of the tolerance used
    min_damping_ratio0.866025 ± 8.7 × 10⁻¹⁰0.866025lockedunder 0.01 % of the tolerance used
    fastest_pole_rad_per_s1 ± 10⁻⁹1lockedunder 0.01 % of the tolerance used
    cost_J1.73205 ± 1.7 × 10⁻⁹1.73205lockedunder 0.01 % of the tolerance used
    riccati_residual_rel≤ 10⁻¹²4.71722 × 10⁻¹⁷lockedinside the range
    cost_balance_rel≤ 10⁻⁹2.08414 × 10⁻¹⁵lockedinside the range
    stable= truetruelockedexact match
    design_ok= truetruelockedexact match
  2. r0002scalar unstable plant a=2 b=3 q=4 r=5, closed form P = r(a+√(a²+b² q/r))/b² = 2.97036, K = bP/r, pole -√(a²+b² q/r) = -√(11.2); rel 10⁻⁹passed

    P.0.0= 2.970356, within 1.000000 × 10⁻⁹ relativereading not recorded on this page
    K.0.0= 1.782213, within 1.000000 × 10⁻⁹ relativereading not recorded on this page
    max_pole_real_per_s-3.34664 ± 3.3 × 10⁻⁹-3.34664lockedunder 0.01 % of the tolerance used
    open_loop_max_real_per_s2 ± 2 × 10⁻⁹2lockedunder 0.01 % of the tolerance used
    riccati_residual_rel≤ 10⁻¹²1.11851 × 10⁻¹⁶lockedinside the range
    stable= truetruelockedexact match
    open_loop_stable= falsefalselockedexact match
  3. r0003undamped oscillator w₀=2 (A=[[0,1],[-4,0]]), Q=diag(9,1), R=1, hand-solved ARE: p12 = -w₀²+√(w₀⁴+q₁) = 1, p22 = √(q₂+2 p12) = sqrt3, p11 = p22 (w₀²+p12) = 5 sqrt3, wn = sqrt5, ζ = √(3/20); rel 10⁻⁹passed

    P.0.0= 8.660254, within 1.000000 × 10⁻⁹ relativereading not recorded on this page
    P.0.1= 1, within 1.000000 × 10⁻⁹ relativereading not recorded on this page
    P.1.1= 1.732051, within 1.000000 × 10⁻⁹ relativereading not recorded on this page
    K.0.0= 1, within 1.000000 × 10⁻⁹ relativereading not recorded on this page
    K.0.1= 1.732051, within 1.000000 × 10⁻⁹ relativereading not recorded on this page
    min_damping_ratio0.387298 ± 3.9 × 10⁻¹⁰0.387298lockedunder 0.01 % of the tolerance used
    fastest_pole_rad_per_s2.23607 ± 2.2 × 10⁻⁹2.23607lockedunder 0.01 % of the tolerance used
    max_pole_real_per_s-0.866025 ± 8.7 × 10⁻¹⁰-0.866025lockedunder 0.01 % of the tolerance used
    riccati_residual_rel≤ 10⁻¹²2.09475 × 10⁻¹⁷lockedinside the range
    design_ok= truetruelockedexact match
  4. r0004two decoupled scalar plants, two inputs, R=diag(1,0.5) times ρ=2: scalar closed forms P11 = 2(1+sqrt1.5), P22 = sqrt7-2, off-diagonals 0 (abs 10⁻¹²), poles -sqrt1.5 and -sqrt7; rel 10⁻⁹passed

    P.0.0= 4.44949, within 1.000000 × 10⁻⁹ relativereading not recorded on this page
    P.1.1= 0.645751, within 1.000000 × 10⁻⁹ relativereading not recorded on this page
    P.0.1= 0, within 1.000000 × 10⁻¹²reading not recorded on this page
    K.0.0= 2.224745, within 1.000000 × 10⁻⁹ relativereading not recorded on this page
    K.1.1= 0.645751, within 1.000000 × 10⁻⁹ relativereading not recorded on this page
    K.0.1= 0, within 1.000000 × 10⁻¹²reading not recorded on this page
    max_pole_real_per_s-1.22474 ± 1.2 × 10⁻⁹-1.22474lockedunder 0.01 % of the tolerance used
    fastest_pole_rad_per_s2.64575 ± 2.6 × 10⁻⁹2.64575lockedunder 0.01 % of the tolerance used
    n_inputs= 22lockedexact match
    riccati_residual_rel≤ 10⁻¹²1.98819 × 10⁻¹⁷lockedinside the range
  5. r00054-state coupled plant = Hadamard rotation H(DI + oscillator)H of the two closed forms above: P' = H P H gives P11 = 2sqrt3+1, P22 = 2sqrt3-1, P13 = -sqrt3; poles invariant (-sqrt3/2, ζ √(3/20), wn sqrt5); x₀ = H e₁ so cost x₀'Px0 = sqrt3; rel 10⁻⁹passed

    P.0.0= 4.464102, within 1.000000 × 10⁻⁹ relativereading not recorded on this page
    P.1.1= 2.464102, within 1.000000 × 10⁻⁹ relativereading not recorded on this page
    P.0.2= -1.732051, within 1.000000 × 10⁻⁹ relativereading not recorded on this page
    max_pole_real_per_s-0.866025 ± 8.7 × 10⁻¹⁰-0.866025lockedunder 0.01 % of the tolerance used
    min_damping_ratio0.387298 ± 3.9 × 10⁻¹⁰0.387298lockedunder 0.01 % of the tolerance used
    fastest_pole_rad_per_s2.23607 ± 2.2 × 10⁻⁹2.23607lockedunder 0.01 % of the tolerance used
    cost_J1.73205 ± 1.7 × 10⁻⁹1.73205lockedunder 0.01 % of the tolerance used
    controllability_rank= 44lockedexact match
    riccati_residual_rel≤ 10⁻¹²1.26866 × 10⁻¹⁶lockedinside the range
    cost_balance_rel≤ 10⁻⁹1.03511 × 10⁻¹⁴lockedinside the range
    design_ok= truetruelockedexact match
5 of 5 cases passed · sandbox macos-seatbeltrecorded from the kernel in a fresh lab

Each line is one reading the kernel checked. The bright band is the tolerance; the needle is the value the instrument actually returned when it was admitted. A needle near the centre line used little of its tolerance.

Inputs

NameUnitDefaultMeaning
A1State matrix, n x n rows (n ≤ 8). Entries in the plant's own state units per second; time is in seconds.
B1Input matrix, n rows by m columns; a flat list of n numbers for a single input.
Q1State weight, symmetric positive semi-definite n x n, or a list of n diagonal weights. Left out: identity.
R1Input weight, symmetric positive definite m x m, or a list of m diagonal weights. Left out: identity.
rho11.0Multiplies R (effort price); raise it for gentler control.
x01Initial state for the response, one number per state. Left out: [1, 0, ..., 0].
t_end_ss0.0Response length; 0 means eight time constants of the slowest closed-loop pole.
n_steps1400Samples in the response (exact transition matrix, so steps only set the resolution).

Readings

NameUnitMeaning
n_states1
n_inputs1
K1Gain, m rows by n columns, u = -K x (units: input per state).
P1Stabilising solution of A'P + PA - PBR⁻¹B'P + Q = 0 (units of cost per state squared).
polesClosed-loop poles, slowest first.
open_loop_polesEigenvalues of A, slowest first.
open_loop_stable1
open_loop_max_real_per_s1/s
max_pole_real_per_s1/s
min_damping_ratio1
fastest_pole_rad_per_srad/s
slowest_time_constant_ss
settling_time_ssFour slowest time constants (2 % band).
riccati_residual_rel1|A'P + PA - PGP + Q| over the size of its terms (Frobenius).
kleinman_steps1
P_min_eig1
pole_error_rel1First-order pole error estimate from an independent complex determinant, relative to |Acl|.
controllability_rank1
controllable1
cost_J1Optimal cost from x₀: x₀'P x₀.
cost_paid1Cost accumulated over the response (Van Loan Gramian, independent of P).
cost_left1x_end'P x_end.
cost_balance_rel1|cost_J - cost_paid - cost_left| / cost_J.
peak_control_abs1
peak_control_max1
x_end1
t_end_ss
dt_ss
n_steps1
rho1
stable1
design_ok1
warnings1

Try the call

Change a value and the command updates. Nothing runs here; paste it into your terminal or give it to your agent.

Terminal
MCP call