[Paper Review] Automatic differentiation of Sylvester, Lyapunov, and algebraic Riccati equations
This paper derives forward and reverse-mode automatic differentiation rules for solutions to Sylvester, Lyapunov, and algebraic Riccati equations—fundamental matrix equations in control theory. The authors demonstrate their utility by solving an inverse linear-quadratic regulator (LQR) problem, where the state cost matrix Q is recovered from observed trajectories using gradient-based optimization through the discrete-time algebraic Riccati equation (DARE).
Sylvester, Lyapunov, and algebraic Riccati equations are the bread and butter of control theorists. They are used to compute infinite-horizon Gramians, solve optimal control problems in continuous or discrete time, and design observers. While popular numerical computing frameworks (e.g., scipy) provide efficient solvers for these equations, these solvers are still largely missing from most automatic differentiation libraries. Here, we derive the forward and reverse-mode derivatives of the solutions to all three types of equations, and showcase their application on an inverse control problem.
Motivation & Objective
- To close a gap in automatic differentiation (AD) libraries by providing differentiable solvers for key matrix equations used in control theory.
- To enable gradient-based optimization in inverse control problems where system parameters such as the state cost matrix Q must be inferred from observed trajectories.
- To extend the applicability of AD frameworks to complex control-theoretic equations that are widely used but previously unsupported in most AD libraries.
- To provide a foundation for integrating these derivatives into popular AD libraries like PyTorch, JAX, and TensorFlow by deriving rigorous forward and reverse-mode rules.
- To demonstrate the practical utility of the derived derivatives through a concrete inverse LQR application with synthetic data.
Proposed method
- Derives forward-mode derivatives by taking the differential of the matrix equations and solving a new, related Sylvester/Lyapunov/Riccati equation for the tangent matrix.
- Derives reverse-mode adjoints using a Lagrangian formulation with dual variables (Lagrange multipliers), leading to adjoint equations that mirror the original matrix equations.
- For the discrete-time algebraic Riccati equation (DARE), derives adjoints for the system matrices A, B, and cost matrices Q, R, using the implicit function theorem and symmetry constraints.
- Implements the derived rules in Owl, an OCaml-based numerical library with full AD support, and validates them numerically.
- Applies the derived gradients to an inverse LQR problem by minimizing a loss between observed and predicted state trajectories using L-BFGS optimization.
- Uses the DARE solution as a differentiable layer in a neural network-like optimization loop to recover the unknown Q matrix from synthetic data.
Experimental results
Research questions
- RQ1Can automatic differentiation be systematically applied to solutions of Sylvester, Lyapunov, and algebraic Riccati equations, which are central to control theory?
- RQ2What are the correct forward and reverse-mode derivatives for the solutions of these matrix equations under standard spectral conditions (e.g., no common eigenvalues)?
- RQ3Can these derivatives be effectively used to solve inverse control problems, such as inferring the state cost matrix Q in LQR from observed trajectories?
- RQ4How accurate is parameter recovery in inverse LQR when gradients are backpropagated through the DARE solution using the derived rules?
- RQ5To what extent can these differentiable solvers be integrated into existing AD frameworks like PyTorch or JAX to extend their functionality in control and systems theory?
Key findings
- The paper derives closed-form forward and reverse-mode derivatives for continuous and discrete-time Sylvester, Lyapunov, and algebraic Riccati equations, with conditions on spectral properties ensuring uniqueness.
- The reverse-mode adjoints for the DARE are derived as symmetric matrices, and the adjoint equations are shown to be equivalent to a modified DARE with a symmetric right-hand side.
- In the inverse LQR experiment, the method successfully recovered the true Q matrix (1,0;0,0) from 30 synthetic trajectories of length 30 using L-BFGS optimization.
- After 7 optimization iterations, the loss function ℓ(𝐐̂) converged, and the norm of the estimated 𝐐̂ approached the true Q, demonstrating effective parameter recovery.
- The derived derivatives are numerically validated and implemented in Owl, with the authors providing open-source code for reproducibility.
- The work enables gradient-based inference in control systems, such as learning cost functions from behavior, and fills a critical gap in AD libraries that previously lacked support for these equations.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.