0% found this document useful (0 votes)
75 views11 pages

Matrixeqs Lyapunov

The document discusses numerical methods for solving the Lyapunov equation, including a naive approach with complexity O(n^6) and the more efficient Bartels-Stewart algorithm with complexity O(n^3). The Bartels-Stewart algorithm uses a Schur decomposition to triangularize the equation, then solves blocks recursively with back substitution.

Uploaded by

mari_eu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
75 views11 pages

Matrixeqs Lyapunov

The document discusses numerical methods for solving the Lyapunov equation, including a naive approach with complexity O(n^6) and the more efficient Bartels-Stewart algorithm with complexity O(n^3). The Bartels-Stewart algorithm uses a Schur decomposition to triangularize the equation, then solves blocks recursively with back substitution.

Uploaded by

mari_eu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Lecture notes in numerical linear algebra

Lyapunov equation

x5 Methods for the Lyapunov equation


Preliminary version 2014-10-22

This chapter is about numerical methods for a particular type of


equation expressed as a matrix equality.
Definition 5.0.1 Consider two square matrices A, W Rnn . The problem to find a square matrix X Rnn such that
AX + XA T = W

(5.1)

is called the Lyapunov equation.


Different algorithms are suitable for different situations, depending
on the properties of A and W. For dense A, the Bartels-Stewart algorithm is one of the most efficient approaches. The Bartels-Stewart
algorithm is derived in Section 5.2. For sparse A and if W is of lowrank, Krylov-type methods may be more efficient (Section 5.3).
The Lyapunov equation appears in a wide variety of fields. Some
applications are given in Section 5.4 and in the exercises.

x5.1

A naive approach
The equation (5.1) is a linear system of equations, expressed in a
somewhat unusual form. We will now see that (5.1) can be reformulated as a linear system of equations in standard form, by using
techniques called vectorization and Kronecker products. If B Rnm
with columns (b1 , . . . , bm ) = B, the vectorization operation is defined
as the stacking of the columns into a vector,

b1
.
nm

vec( B) :=
.. R .
bm

In the field of systems and control the


equation (5.1) is sometimes called the
continuous-time Lyapunov equation,
for disambiguation with a different
matrix equation called the discrete-time
Lyapunov equation.

Traditionally driven by certain problems in system and control, the Lyapunov equation now appears in very
large number of fields. The developments and improvements of numerical
methods have (and continues to be)
recognized as important in numerical
linear algebra.

In matlab the vec-operation


can be computed with
b=reshape(B,prod(size(B)),1)

For two matrices A Rnm and B R jk , the Kronecker product ()


is defined as

a11 B a1m B
.
..
njmk
..

AB =
.
.
. R
..
an1 B anm B
Lecture notes - Elias Jarlebring - Autumn 2014
1

version:2014-10-22

Lecture notes in numerical linear algebra


Lyapunov equation
With this notation we can derive a very useful identity. For matrices
A, B, X of matching size, we have
vec( AXB) = ( B T A) vec( X )

(5.2)

By vectorizing the Lyapunov equation (5.1) we have


vec( AX + XA T )

= vec(W )

( I A + A I ) vec( X ) = vec(W )

(5.3)

Apply (5.2) twice, once with A = I and


once with B = I.

The equation (5.3) is a linear system of equations on the standard


matrix-times-vector form. The connection between (5.1) and (5.3) is
useful, mostly for theoretical purposes. For instance, we can easily
characterize the existance and uniqueness of a solution.
Theorem 5.1.1 (Existance and uniqueness of solution) Let i , i =
1, . . . , n be the eigenvalues of A.
(i) The equation (5.1) has a unique solution X Rnn if and only if
i 6= j , for all i, j = 1, . . . , n.
The real part of the eigenvalues of a
strictly stable matrix have negative real
part.

(ii) In particular, if A is strictly stable (that is i C , for all i =


1, . . . , n), then (5.1) has a unique solution.
Proof This is an exercise.

A naive computational approach based on (5.3)


It is tempting to approach the problem of solving the Lyapunov
equation (5.1) by applying a generic method for linear systems of
equations Bz = w to (5.3),
vec( X ) = ( I A + A I )1 vec(W ).

(5.4)

Suppose for simplicity that we have a numerical method that can


solve a linear system of equations with N with O( N 3 ) operations
(such as a primitive implementation of Gaussian elimination). Since
(5.3) is a linear system with N = n2 , the computational complexity of
such an approach is
tnaive (n) = O(n6 ).
(5.5)

A generic method for linear systems


applied to (5.3), will have high computational complexity.

Some gains in complexity are feasable by using more advanced versions of Gaussian elimination to solve (5.3), or exploiting sparsity in
I A + A I. These improved variants will not be computationally competitive for large n in comparison to the algorithms in the
following sections.
Although this approach is not competitive for large n, it can be
useful for small n, and (as we shall see below) as a component in a
numerical method for large n.
Lecture notes - Elias Jarlebring - Autumn 2014
2

version:2014-10-22

Lecture notes in numerical linear algebra


Lyapunov equation

x5.2

Bartels-Stewart algorithm
From previous lectures we know that there are efficient algorithms
that can compute the Schur decomposition of a matrix. It turns out
that this can be used as a precomputation such that we obtain a triangular Lyapunov equation. The resulting equation can be efficiently
solved in direct way with a finite number of operations, by using a
type of substitution.
Recall that all real matrices have a real square Schur decomposition: There exists matrices Q and T such that

The Bartels-Stewart algorithm, initially


presented for slightly more general
problems in [1] and is one of the leading methods for dense Lyapunov
equations. It is implemented in matlab
in the command lyap.

A = QTQ T ,
where Q is an orthogonal matrix and T Rnn a block-triangular
matrix, where

T11 T1,r

..
..

T=
(5.6)
.
.

Tr,r
and Tjj Rn j n j , n j {1, 2}, j = 1, . . . , r and rj=1 nr = n.
We multiply the Lyapunov equation (5.1) from the right and left
with Q and Q T respectively,
Q T WQ

= Q T AXQ + Q T XAQ =

(5.7a)

= Q T AQQ T XQ + Q T XQQ T AQ =

(5.7b)

= TY + YT

Use QQ T = I.

(5.7c)

where Y = Q T XQ. We introduce matrices and corresponding blocks


such that
!
!
!
C11 C12
Z11 Z12
R11 R12
T
Q WQ =
,Y =
, T=
, (5.8)
C21 C22
Z21 Z22
0
R22
where the blocks are such that Z22 , C22 , Trr = R22 Rnr nr (the
size of the last block of T). This triangularized problem can now be
solved with (what we call) backward substitution, similar to backward substitution in Gaussian elimination. By separating the four
blocks in the equation (5.7), we have four equations
C11

T
T
R11 Z11 + R12 Z21 + Z11 R11
+ Z12 R12

R11 Z12 + R12 Z22 +

C21

R22 Z21 +

C22

R22 Z22 +

T
Z21 R11
+
T
Z22 R22 .

C12

T
Z12 R22
T
Z22 R12

(5.9a)
(5.9b)

General idea: Solve (5.9b)-(5.9d) explicitly. Insert the solution into (5.9a)
and repeat the process for the smaller
equation which is a Lyapunov equation
with unknown Z11 R(nnr )(nnr ) .

(5.9c)
(5.9d)

Due to the choice of block sizes, the last equation of size nr nr ,


which can be solved explicitly since nr {1, 2}:
Lecture notes - Elias Jarlebring - Autumn 2014
3

version:2014-10-22

Lecture notes in numerical linear algebra


Lyapunov equation
If nr = 1, the equation (5.9d) is scalar and we obviously have
Z22 =

C22
.
2R22

(5.10)

If nr = 2 we can still solve (5.9d) cheaply since it is a 2 2 Lyapunov equation. For instance, we can use the naive approach (5.4),
i.e.,
vec( Z22 ) = ( I R22 + R22 I )1 vec(C22 ).
(5.11)

The eigenvalues of R22 are eigenvalues


of A. Therefore the small Lyapunov
equation (5.9d) has a unique solution if
(5.1) has a unique solution.

Insert the now known matrix Z22 into (5.9b) and transposed (5.9c),
yields
C 12 := C12 R12 Z22
T
T
C 21 := C21
R12 Z22

T
R11 Z12 + Z12 R22

(5.12a)

T
R11 Z21

(5.12b)

T T
Z21
R22 .

The equations (5.12) have a particular structure that can be used to


directly compute the solutions Z12 and Z21 . An explicit procedure for
the construction of the solution (5.12) is given by the following result.
Lemma 5.2.1 Consider two matrices C, D partitioned in blocks of size
n1 n p , n2 n p , . . ., n p1 n p according to

X1
D1
.
.
N nr
N n p

X=
, D=
.. R
.. R
X p 1
D p 1
p 1

where Cj , D j Rn j n p and N = j=1 n j . Let U Rnn be a block


triangular matrix partitioned as X and D. For any R22 Rn p n p , we that
if X satisfies the equation
T
D = UX + XR22
,

(5.13)

The block triangular matrix U is

U11
U1,p1

..
..

U=
.

.
U p1,p1
where Ui,j Rni n j .

then X j , p 1, p 2, . . . , 1 satisfy
T
Ujj X j + X j R22
= D j

(5.14)

j := D j p1 Uji Xi .
where D
i = j +1
Similar to the approach we used to compute Z22 , X j can expressed
and computed explicitly from a small linear system
j)
vec( X j ) = ( I Tjj + R22 I )1 vec(W

(5.15)

By solving (5.15) for j = p 1, . . . , 1, for both equations (5.12)a and


(5.12)b we obtain solutions Z12 and Z21 . Insertion of (the now known
solutions) Z12 , Z21 and Z22 into (5.9a) gives a new Lyapunov equation
of size n n p and the process can be repeated for the smaller matrix.
Lecture notes - Elias Jarlebring - Autumn 2014
4

version:2014-10-22

Lecture notes in numerical linear algebra


Lyapunov equation
Algorithm 1: The Bartels-Stewart algorithm for the Lyapunov
equation
1

2
3
4
5
6

Compute the real Schur decompositon [Q,T]=schur(A) and


establish n1 , . . . , nr , T11 , T1r , . . . , Trr with partitioning according to
(5.6)
Set C = Q T WQ.
Set m = n.
for k=r,. . . ,1 do
Set m = m nk
Partition the matrix C with C11 , C12 , C21 , C22 according to (5.8),
with C22 Rnk nk .
Set R22 = Tkk , and

R11 =

8
9
10

11
12
13
14
15
16

T11

T1,k1

..
,
.

Tk1,k1

..
.

R12

T1,k
.

=
..
Tk1,k

Solve (5.9d) for Z22 Rnk nk using (5.11) or (5.10).


Compute C 12 , C 21 using (5.12)a and (5.12)b
Solve (5.12)a and (5.12)b for Z12 Rmnk and Z21 Rnk m
using equation (5.14) and (5.15) with p = k.
Store Y (1 : m, m + (1 : nk )) = Z12
Store Y (m + (1 : nk ), 1 : m) = Z21
Store Y (m + (1 : nk ), m + (1 : nk)) = Z22
T .
Set C := C11 R12 Z21 Z12 R12
end
Return solution X = QYQ T .

Complexity of Bartels-Stewart algorithm


Earlier in the course we learned that the QR-algorithm could be
tuned to perform well. In practice the total complexity is usually
roughly estimated by O(n3 ). Since the other parts of the algorithm
(see exercise) has complexity O(n3 ), the total complexity of BartelsStewart algorithm is
tBartelsStewart (n) = O(n3 ).
This is a tremendous improvement in comparison to the naive approach (5.5), estimated by O(n6 ).

Lecture notes - Elias Jarlebring - Autumn 2014


5

version:2014-10-22

Lecture notes in numerical linear algebra


Lyapunov equation

x5.3

Krylov-method for Lyapunov equation (KPIK - Krylov-plus-invertedKrylov)


See paper by V. Simoncini [2] about large-scale sparse Lyapunov
equations.

x5.4

Applications
The research and developments on numerical methods for Lyapunov
equations was initially driven by applications in the field of systems
and control. There are now applications appearing in many completely different fields. Some specific applications are listed below.
The so-called infinite-time gramian of contious time linear dynamical system is the solution to a Lyapunov equation. Gramians can be
used
to study stability, controllability and observability;
to compute the H2 -norm which is important in for instance controller design;
to compute bounds and characterisations of transient effects;
to design an optimal control; and
to compute a reduced order model with balanced truncation.
The Lyapunov equation also appears as a part in numerical methods for stability radius, and in the study of robust stability of large
sparse time-delay systems.
A discretization of Helmholtz equation u = f on a square
domain with homogeneous boundary conditions using finite difference with uniform grid, leads to a linear system of equations
( Dxx I + I Dxx )u = b. This is a vectorized Lyapunov equation.
It can consequently be solved efficiently with, e.g., Bartels-Stewart
method. A Lyapunov equation approach can be useful for more
advanced discretizations of more complicated PDEs, by using a Lyapunov equation solver in the preconditioning.
There are also applications in numerical methods for matrix functions, tensor approximation problems (used for instance in computational methods for the electronic Schrdinger equation), . . . .
* KTH Mechanics department use Lyapunov equations: ftp://www2.mech.kth.se/pub/shervin/review.pdf
* Kressner/Tobler approach

x5.5

Other matrix equations


Generalized Lyapunov equation
Lecture notes - Elias Jarlebring - Autumn 2014
6

version:2014-10-22

Lecture notes in numerical linear algebra


Lyapunov equation
Discrete-time Lyapunov equation
Sylvester equation
Ricatti equation (solved with Lyapunov iteration)
Delay lyapunov equation
Henrik Sandbergs time-dependent

x5.6

Other methods and further liturature


* Hammerlings method (good in combination with model order
reduction) [S. J. Hammarling. Numerical solution of the stable, nonnegative definite Lyapunov equation., IMA Journal of Numerical
Analysis , 2(3):303-323, 1982.], improved by Sorensen
* Vandereyckens low-rank geometric approach has been awarded
the Householder prize and other awards.
* Hierarchical methods
* Benner
* Simoncini summary: http://www.dm.unibo.it/~simoncin/matrixeq.pdf

Appearance of matrix equation in other courses at KTH


FEL3500 - Introduction to Model Order Reduction (Dept. Automatic control)
EL2620 - Nonlinear Control

Lecture notes - Elias Jarlebring - Autumn 2014


7

version:2014-10-22

Lecture notes in numerical linear algebra


Lyapunov equation

x5.7

Exercises
1. Implement the naive approach as well as the Bartels-Stewart
method based on the skeleton code on the course web page. Compare the methods by using simulations for random matrices. Illustrate (with figure) the dependence of the computation time on n.
What is the observed complexity?
2. Prove (5.2).
3. Show that
vec(uv T ) = v u.
for any u, v Rn .
4. Consider the problem
A=

0
1

!
a
, W=
0

1
2

!
2
.
1

For which values of a does the Lyapunov equation have a unique


solution?
5. Prove the following identity: Any matrices A, B, C, D of compatible size satisfy

( A B)(C D ) = ( AC ) ( BD ).
6. Prove Theorem 5.1.1.
Hint: Use previous exercise to first show that if v j , vi are two eigenvectors of A, then v j vi is an eigenvector of I A + A I.

Hint for a short proof: Let


{ Ai }, { Bj }, {Ck }, { D` } form bases
of the matrix spaces associated with
A, B, C, D. A function f ( A, B, C, D )
which is linear in all parameters is
f ( A, B, C, D ) 0, if f ( Ai , Bj , Ck , D` ) = 0
for all combinations of basis vectors.

7. Prove Lemma 5.2.1.


8. Derive the computational complexity of computing X1 , . . . , X p1
with Lemma 5.2.1. You may here assume that n1 = = n p = 2.
9. Show that if A and W are symmetric, then a solution X to (5.1) is
symmetric, if (5.1) has a unique solution.
10. Derive a more efficient algorithm for the case when A and W are
symmetric, by first showing that (5.12)a and (5.12)b have the same
solution. Illustrate that it works and that it is more efficient using
the code from exercise 1. (More difficult optional: Also use that T
in the Schur decomposition of A is a diagonal matrix.)
11. Consider the following dynamical system
x (t)

y(t)

= c T x ( t ),

Ax (t) + bu(t)

In systems and control, this is called


a single-input single-output (SISO)
dynamical system.

where b, c Rn . Suppose A is stable, i.e., ( A) C .


Lecture notes - Elias Jarlebring - Autumn 2014
8

version:2014-10-22

Lecture notes in numerical linear algebra


Lyapunov equation
a) The observability gramian of this system is defined as
Pc (t) :=

Z t
0

exp( A T t)cc T exp( At) dt

and the observability gramian


Po (t) :=

Z t
0

exp( At)bb T exp( A T t) dt.

Show that the limits


Po (t)

Po, Rnn as t

Pc (t)

Pc, Rnn as t

exist and satisfy certain Lyapunov equations.


b) The so-called H2 -norm of the dynamical system is defined as
s
Z
1
|c T (iI A)1 b|2 ds.
k k H2 : =
2
Show that

1
y(t)2 dt
2 0
c) Show that the H2 norm can be computed from either controllability or observability gramian by showing

kk2H2 =

kk2H2

The H2 is a measure of sensitivity of


the system, and can be used when
designing control systems which should
be insensitive to additive white-noise.

= c T Po, c

(5.16a)

(5.16b)

= b Pc, b

In the matlab control toolbox, in particular in the function norm(sys,2),


a Lyapunov equation is solved with
Bartels-Stewart algorithm. The H2 norm is subsequently computed directly from the relation (5.16).

12. Consider the partial differential-equation


u + g( x, y)u
u( x, y)

f ( x, y) for ( x, y)

= 0 for ( x, y) ,

where = [0, 1] [0, 1].


(a) Derive the (second order) finite-difference discretization for
the grid xi = hi, i = 1, . . . , m, y j = hj, j = 1, . . . , m and
h = 1/(m + 1). Derive matrices Dxx , G, F Rnn such that the
discretization can be expressed as
Dxx U + UDxx + G U = F,

(5.17)

Here denotes the Hadamard product,


also known as the direct or elementwise product, in matlab .*

for Ui,j u( xi , y j ).
(b) Derive explicit expression for the eigenvalues of I Dxx +
Dxx I in the limit m , and show that I Dxx + Dxx I is
nonsingular in the limit.
(Optional: The eigenvalues have closed forms also for finite m.
Compute these and show that I Dxx + Dxx I is non-singular
for any m.)
Lecture notes - Elias Jarlebring - Autumn 2014
9

version:2014-10-22

Lecture notes in numerical linear algebra


Lyapunov equation
q
(c) Let g( x, y) = ( x 12 )2 + (y 12 )2 and f ( x, y) = | x y|.
Solve the problem in the following ways, and report computation time as a function of system size:
For = 0, solve the sparse linear system corresponding to
the vectorization of (5.17) with the matlab command \

Use only sparse matrices and do not


store any matrices as full matrices. Use
spdiags and see help spdiags.

Compare with solving (5.17) with the matlab command lyap


also with = 0.
For = 1, solve the sparse linear system corresponding to
the vectorization of (5.17) with the matlab command \.
For = 1, apply GMRES to solve the sparse linear system
corresponding to the vectorization of (5.17) (use matlab command gmres)
For = 1, apply GMRES to solve, by using lyap as a left
preconditioner.
For = 0.1, apply GMRES to solve, by using lyap as a left
preconditioner.
(d) Explain the performance of the preconditioned GMRES in the
previous sub-problem using the theory developed earlier in
the course, preferably in terms explicit bounds involving the
analytic expressions for the eigenvalues (in the limit or for finite
n).

This exercise has many solutions.

Might be helpful: From theory of Frchet derivates of matrix functions


we know that for sufficiently small k Ek, we have

( A E)1 = A1 A1 EA1 + O(k Ek2 ).


(e) Suppose all elements of G are zero except Gm/4,m/2 = 1/h and
assume m 4Z. Solve the equation efficiently using lyap (or
your implementation of Bartels-Stewart). This problem can and
should here be solved without using gmres or similar. Compare
with a naive approach.
Hint: Consider the problem as rank-one modification and read about
the Sherman-Morrison-Woodbury formula.

This choice of G corresponds to the


regularization of dirac impulse in the
point ( x, y) = ( 41 , 21 ).

13. An exercise with KPIK will be added here at a later stage.

Project suggestions
Graduate level projects related to Lyapunov equations:
Alternating Direction Implicit (ADI)
Bartels-Stewart algorithm for the Sylvester equation
Balancing and balanced trunctation: Use the Lyapunov equation
for model order reduction
Lecture notes - Elias Jarlebring - Autumn 2014
10

version:2014-10-22

Lecture notes in numerical linear algebra


Lyapunov equation
Efficient algorithm for the discrete-time Lyapunov equation
Complex Bartels-Stewart algorithm, derive algorithm based on the
complex Schur decomposition..

x5.8

References
[1] R. Bartels and G. W. Stewart. Solution of the matrix equation
AX + XB = C. Comm A.C.M., 15(9):820826, 1972.
[2] V. Simoncini. A new iterative method for solving large-scale
Lyapunov matrix equations. SIAM J. Sci. Comput., 29(3):1268
1288, 2007.

Lecture notes - Elias Jarlebring - Autumn 2014


11

version:2014-10-22

You might also like