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

Notebooks · lib/balance

Balanced truncation, or which states a model can do without

A state-space model (A, B, C) of order n can usually be replaced by one of order r much smaller than n whose input-output behavior is nearly the same. Which r states, though? Not a subset of the original ones: the right answer is almost never "drop state 7". It is a change of coordinates followed by a truncation, and the coordinates are the ones in which the two Gramians are equal and diagonal.

The diagonal they share is the Hankel singular values. They say how much each balanced state contributes to the map from past inputs to future outputs, and unlike the eigenvalues of A they do not depend on the coordinates at all. Run the model through any invertible change of variables and they come back identical, which is the first test below and the reason they are the right thing to rank states by.

Getting them without ever forming the balancing transformation, which is what makes the square-root method the one to use: factor Wc = Lc Lc^T and Wo = Lo Lo^T, take the SVD of Lo^T Lc, and its singular values are the Hankel singular values. The projections onto the leading r of them follow from the same factors. Wc Wo is never formed, so its condition number, which is the square of the one the result depends on, never enters.

The reduction has a guarantee attached: the worst-case gain of the error system is at most twice the sum of the Hankel singular values that were thrown away. This module does not compute worst-case gain, so it checks the energy of the error instead, and that the error shrinks as r grows.

Used with import balance.

Look inside this program

  • Atlas

    The program’s map: every function and which calls which.

  • There’s no recorded run of this program yet.

Shift+Enter in a cell runs it and moves to the next. Running a cell runs every cell above it too, as one program.

[1]lines 34–339