control.lyap

control.lyap(A, Q, C=None, E=None, method=None)[source]

Solves the continuous-time Lyapunov equation.

X = lyap(A, Q) solves

A X + X A^T + Q = 0

where A and Q are square matrices of the same dimension. Q must be symmetric.

X = lyap(A, Q, C) solves the Sylvester equation

A X + X Q + C = 0

where A and Q are square matrices.

X = lyap(A, Q, None, E) solves the generalized continuous-time Lyapunov equation

A X E^T + E X A^T + Q = 0

where Q is a symmetric matrix and A, Q and E are square matrices of the same dimension.

Parameters:
A, Q2D array_like

Input matrices for the Lyapunov or Sylvestor equation.

C2D array_like, optional

If present, solve the Sylvester equation.

E2D array_like, optional

If present, solve the generalized Lyapunov equation.

methodstr, optional

Set the method used for computing the result. Current methods are ‘slycot’ and ‘scipy’. If set to None (default), try ‘slycot’ first and then ‘scipy’.

Returns:
X2D array

Solution to the Lyapunov or Sylvester equation.

Notes

For the generalized Lyapunov equation, method=’slycot’ uses the SLICOT routine SG03AD, based on the generalized Schur method of Penzl [1], which factors the matrix pencil without inverting E. With method=’scipy’, the equation is transformed to a standard Lyapunov equation by inverting E, which requires E to be nonsingular and loses accuracy when E is ill-conditioned (a UserWarning is then issued). The generalized Lyapunov problem is itself ill-conditioned (about cond(E)**2) when E is, so method=’slycot’, though it does not invert E, is not measurably more accurate in that case. Both methods require E nonsingular; a truly singular (descriptor) E is not currently handled by either.

References

[1]

Penzl, T., “Numerical solution of generalized Lyapunov equations”, Advances in Computational Mathematics, 8:33-48, 1998.