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^-1 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 = x0'P x0). 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, zeta sqrt3/2); rel 1e-9: solver converges to round-offpassed

    K.0.0{"value": 1.0, "rel_tol": 1e-09}
    K.0.1{"value": 1.7320508075688772, "rel_tol": 1e-09}
    P.0.0{"value": 1.7320508075688772, "rel_tol": 1e-09}
    P.0.1{"value": 1.0, "rel_tol": 1e-09}
    P.1.1{"value": 1.7320508075688772, "rel_tol": 1e-09}
    max_pole_real_per_s-0.866025 ± 8.7e-10-0.866025lockedunder 0.01 % of the tolerance used
    min_damping_ratio0.866025 ± 8.7e-100.866025lockedunder 0.01 % of the tolerance used
    fastest_pole_rad_per_s1 ± 1e-091lockedunder 0.01 % of the tolerance used
    cost_J1.73205 ± 1.7e-091.73205lockedunder 0.01 % of the tolerance used
    riccati_residual_rel≤ 1e-124.71722e-17lockedinside the range
    cost_balance_rel≤ 1e-092.08414e-15lockedinside 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+sqrt(a^2+b^2 q/r))/b^2 = 2.97036, K = bP/r, pole -sqrt(a^2+b^2 q/r) = -sqrt(11.2); rel 1e-9passed

    P.0.0{"value": 2.9703556145201677, "rel_tol": 1e-09}
    K.0.0{"value": 1.7822133687121007, "rel_tol": 1e-09}
    max_pole_real_per_s-3.34664 ± 3.3e-09-3.34664lockedunder 0.01 % of the tolerance used
    open_loop_max_real_per_s2 ± 2e-092lockedunder 0.01 % of the tolerance used
    riccati_residual_rel≤ 1e-121.11851e-16lockedinside the range
    stable= truetruelockedexact match
    open_loop_stable= falsefalselockedexact match
  3. r0003undamped oscillator w0=2 (A=[[0,1],[-4,0]]), Q=diag(9,1), R=1, hand-solved ARE: p12 = -w0^2+sqrt(w0^4+q1) = 1, p22 = sqrt(q2+2 p12) = sqrt3, p11 = p22 (w0^2+p12) = 5 sqrt3, wn = sqrt5, zeta = sqrt(3/20); rel 1e-9passed

    P.0.0{"value": 8.660254037844386, "rel_tol": 1e-09}
    P.0.1{"value": 1.0, "rel_tol": 1e-09}
    P.1.1{"value": 1.7320508075688772, "rel_tol": 1e-09}
    K.0.0{"value": 1.0, "rel_tol": 1e-09}
    K.0.1{"value": 1.7320508075688772, "rel_tol": 1e-09}
    min_damping_ratio0.387298 ± 3.9e-100.387298lockedunder 0.01 % of the tolerance used
    fastest_pole_rad_per_s2.23607 ± 2.2e-092.23607lockedunder 0.01 % of the tolerance used
    max_pole_real_per_s-0.866025 ± 8.7e-10-0.866025lockedunder 0.01 % of the tolerance used
    riccati_residual_rel≤ 1e-122.09475e-17lockedinside the range
    design_ok= truetruelockedexact match
  4. r0004two decoupled scalar plants, two inputs, R=diag(1,0.5) times rho=2: scalar closed forms P11 = 2(1+sqrt1.5), P22 = sqrt7-2, off-diagonals 0 (abs 1e-12), poles -sqrt1.5 and -sqrt7; rel 1e-9passed

    P.0.0{"value": 4.449489742783178, "rel_tol": 1e-09}
    P.1.1{"value": 0.6457513110645907, "rel_tol": 1e-09}
    P.0.1{"value": 0.0, "abs_tol": 1e-12}
    K.0.0{"value": 2.224744871391589, "rel_tol": 1e-09}
    K.1.1{"value": 0.6457513110645907, "rel_tol": 1e-09}
    K.0.1{"value": 0.0, "abs_tol": 1e-12}
    max_pole_real_per_s-1.22474 ± 1.2e-09-1.22474lockedunder 0.01 % of the tolerance used
    fastest_pole_rad_per_s2.64575 ± 2.6e-092.64575lockedunder 0.01 % of the tolerance used
    n_inputs= 22lockedexact match
    riccati_residual_rel≤ 1e-121.98819e-17lockedinside 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, zeta sqrt(3/20), wn sqrt5); x0 = H e1 so cost x0'Px0 = sqrt3; rel 1e-9passed

    P.0.0{"value": 4.464101615137754, "rel_tol": 1e-09}
    P.1.1{"value": 2.4641016151377544, "rel_tol": 1e-09}
    P.0.2{"value": -1.7320508075688772, "rel_tol": 1e-09}
    max_pole_real_per_s-0.866025 ± 8.7e-10-0.866025lockedunder 0.01 % of the tolerance used
    min_damping_ratio0.387298 ± 3.9e-100.387298lockedunder 0.01 % of the tolerance used
    fastest_pole_rad_per_s2.23607 ± 2.2e-092.23607lockedunder 0.01 % of the tolerance used
    cost_J1.73205 ± 1.7e-091.73205lockedunder 0.01 % of the tolerance used
    controllability_rank= 44lockedexact match
    riccati_residual_rel≤ 1e-121.26866e-16lockedinside the range
    cost_balance_rel≤ 1e-091.03511e-14lockedinside 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^-1B'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 x0: x0'P x0.
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