Algorithm 800: Fortran 77 Subroutines for Computing the Eigenvalues of Hamiltonian Matrices I: The Square-Reduced Method PETER BENNER Universität Bremen RALPH BYERS University of Kansas and ERIC BARTH Kalamazoo College
This article describes LAPACK-based Fortran 77 subroutines for the reduction of a Hamiltonian matrix to square-reduced form and the approximation of all its eigenvalues using the implicit version of Van Loan’s method. The transformation of the Hamiltonian matrix to a square-reduced form transforms a Hamiltonian eigenvalue problem of order 2n to a Hessenberg eigenvalue problem of order n . The eigenvalues of the Hamiltonian matrix are the square roots of those of the Hessenberg matrix. Symplectic scaling and norm scaling are provided, which, in some cases, improve the accuracy of the computed eigenvalues. We demonstrate the performance of the subroutines for several examples and show how they can be used to solve some control-theoretic problems. Categories and Subject Descriptors: D.3.2 [Programming Languages]: Language Classifications—Fortran 77; F.2.1 [Analysis of Algorithms and Problem Complexity]: Numerical Algorithms and Problems—Computations on matrices; G.1.3 [Numerical Analysis]: Numeri-
Some of this work was completed while Peter Benner was with the Fakultät für Mathematik, TU Chemnitz-Zwickau, 09107 Chemnitz (FRG). Support was received from Deutsche Forschungsgemeinschaft, research grant Me 790/7-1 Singuläre Steuerungsprobleme. Ralph Byers was partially supported by National Science Foundation awards CCR-9404425, DMS-9205538, DMS-9628626, CCR-9732671, and by the NSF EPSCoR/K*STAR program through the Center for Advanced Scientific Computing. Eric Barth’s part of the work was completed while he was with the University of Kansas. Partial support was received from the Kansas Institute for Theoretical and Computational Science. Authors’ addresses: P. Benner, Zentrum für Technomathematik, Fachbereich 3—Mathematik und Informatik, Universität Bremen, 28334 Bremen, FRG; email:
[email protected]; R. Byers, Department of Mathematics, University of Kansas, 405 Snow Hall, Lawrence, KS 66045; email:
[email protected].; E. Barth, Department of Mathematics, Kalamazoo College, 1200 Academy Street, Kalamazoo, MI 49006; email:
[email protected]. Permission to make digital / hard copy of part or all of this work for personal or classroom use is granted without fee provided that the copies are not made or distributed for profit or commercial advantage, the copyright notice, the title of the publication, and its date appear, and notice is given that copying is by permission of the ACM, Inc. To copy otherwise, to republish, to post on servers, or to redistribute to lists, requires prior specific permission and / or a fee. © 2000 ACM 0098-3500/00/0300 –0049 $5.00 ACM Transactions on Mathematical Software, Vol. 26, No. 1, March 2000, Pages 49 –77.
50
•
P. Benner et al.
cal Linear Algebra—Eigenvalues and eigenvectors (direct and iterative methods); G.4 [Mathematics of Computing]: Mathematical Software—Algorithm design and analysis; Certification and testing; Documentation; Efficiency; Reliability and robustness General Terms: Algorithms, Documentation, Performance Additional Key Words and Phrases: Algebraic Riccati equation, eigenvalues, Hamiltonian matrix, skew-Hamiltonian matrix, (square-reduced) Hamiltonian matrix
1. INTRODUCTION This article describes LAPACK-based Fortran 77 subroutines for the reduction of a Hamiltonian matrix to square-reduced form and the approximation of all its eigenvalues using the implicit version of Van Loan’s method [Van Loan 1984]. Many applications in linear quadratic and * ` -control theory require the computation of the eigenvalues of Hamiltonian matrices
H5
F
A G Q 2AT
G
(1)
where A, G, Q [ R n3n and G , Q are symmetric. These include the computation of the * ` -norm of transfer matrices (e.g., see Doyle et al. [1989], Boyd et al. [1989], Boyd and Balakrishnan [1990], Bruinsma and Steinbuch [1990], and Sreedhar et al. [1995b] and the references given therein) and the problem of calculating the stability radius of a matrix [Byers 1988; Sreedhar et al. 1995a]. Hamiltonian matrices are also closely related to continuous-time algebraic Riccati equations (CARE) of the form
0 5 Q 1 ATX 1 XA 2 XGX
(2)
with A, G, Q as in (1) and X [ R n3n is a symmetric solution matrix. Often, a stabilizing solution X of (2) is required in the sense that all the eigenvalues of A 2 GX are in the open left-half plane. If such a solution exists, these eigenvalues are exactly the stable eigenvalues (i.e., those with negative real part) of the Hamiltonian matrix H in (1). If the Hamiltonian matrix H has no eigenvalue with zero real part, then there exists an n -dimensional H -invariant subspace corresponding to the n stable eigenvalues of H which is called the stable invariant subspace of H . If this subspace is spanned by the columns of @ V T , W T # T , V, W [ R n3n , and V is invertible, then a stabilizing solution X of (2) is given by X 5 2WV 21 . For a detailed discussion of the relations of Hamiltonian matrices and continuous-time algebraic Riccati equations as well as properties of solutions of the CARE (2) we refer to Lancaster and Rodman [1995]. Knowledge of approximations to the eigenvalues of the corresponding Hamiltonian matrix is crucial for some numerical methods for the CARE (2), e.g., for the multishift QR-like methods proposed in Ammar et al. [1993], Ammar and Mehrmann [1991], and Raines and Watkins [1994] and ACM Transactions on Mathematical Software, Vol. 26, No. 1, March 2000.
Algorithm 800: Computing the Eigenvalues of Hamiltonian Matrices I
•
51
the algorithm presented in Patel et al. [1994]. As suggested in Sima [1992], they can significantly improve the convergence of the SR algorithm [BunseGerstner and Mehrmann 1986] when employed as shifts. Van Loan’s method uses the square-reduced form of a Hamiltonian matrix which will be introduced in Section 2. Square-reduced Hamiltonian matrices are used by themselves in the CARE solution methods given in Xu [1993] and Xu and Lu [1995]. A Hamiltonian matrix is defined by the property HJ 5 ~ HJ ! T where
J5
F
0 In 2In 0
G
[ R2n32n.
(3)
It is easy to see that ~ HJ ! 5 ~ HJ ! T if and only if H is in the form of (1). The eigenvalues of a Hamiltonian matrix can be computed using the QR algorithm for general matrices [Golub and Van Loan 1989]. The Hamiltonian structure of (1), however, can be exploited to reduce memory requirements and arithmetic operations and/or to improve accuracy. Symplectic similarity transformations preserve Hamiltonian structure. A matrix S [ R 2n32n is symplectic if S T JS 5 J with J as in (3). To preserve numerical stability, it is desirable that similarity transformations be orthogonal as well as symplectic. So far, no algorithm has been found that computes the eigenvalues of a general Hamiltonian matrix by using only orthogonal symplectic similarity transformations. For the special case that rank G 5 1 or rank Q 5 1 , a Hamiltonian QR algorithm was presented in Byers [1986]. A structure-preserving QR-like algorithm using SR decompositions has been presented in Bunse-Gerstner and Mehrmann [1986], BunseGerstner et al. [1989], and Sima [1992]. However, this algorithm suffers from numerical instabilities because it uses symplectic similarity transformations that cannot be guaranteed to be bounded in norm. Recently, an orthogonal symplectic method for computing the eigenvalues of a Hamiltonian matrix has been proposed [Benner et al. 1998]. This method is also based on the square-reduced form of a Hamiltonian matrix but uses nonsimilarity transformations and does not compute this form explicitly. The method is numerically backward stable at the price of a higher computational cost and higher workspace requirements compared to Van Loan’s method. The implementation of this method will be described in the upcoming companion to the work [Benner et al. 2000]. The obstacle to the general use of the Hamiltonian QR algorithm as presented in Byers [1986] is the difficulty in reducing a general Hamiltonian matrix to a Hessenberg-like matrix with Hamiltonian structure which is then preserved during the QR iteration. A Hamiltonian matrix H is said to be in Hamiltonian Hessenberg form if
H5
F
A G Q 2AT
G
5
,
ACM Transactions on Mathematical Software, Vol. 26, No. 1, March 2000.
52
•
P. Benner et al.
i.e., if A is upper Hessenberg, G is symmetric, and Q is a diagonal matrix with a nonzero entry only in its last diagonal element. In Byers [1986] it is shown that this form can be preserved under a Hamiltonian QR iteration. Ammar and Mehrmann [1991] prove that the first column of an orthogonal matrix that reduces a general Hamiltonian matrix to a Hamiltonian Hessenberg matrix must satisfy a homogeneous system of n quadratic equations. This fact casts doubt on the existence of a mathematically finite procedure for reducing a Hamiltonian matrix to Hamiltonian Hessenberg form. The method proposed by Van Loan [1984] uses the properties of the square of a Hamiltonian matrix. A squared Hamiltonian matrix can be reduced to a 2 3 2 block triangular matrix with Hessenberg blocks on the diagonal. It is possible to do the reduction by structure-preserving orthogonal, symplectic similarity transformations. So, the eigenvalues of the squared Hamiltonian matrix are computed by a strongly backward-stable method.1 As the structure is fully exploited, only about three quarters of the work space and one third of the computational cost of the general nonsymmetric QR algorithm are required. Unfortunately, by taking the square roots of the eigenvalues of the squared Hamiltonian matrix a loss of accuracy of O ~ « ! is possible for tiny eigenvalues (if any). (Here, « denotes the machine precision.) In Van Loan [1984], it is shown that the eigenvalues computed by this method are exact eigenvalues of a Hamiltonian matrix H 1 E where i E i # O ~ « !i H i . We use the following notation. Let A [ R n3n . By s ~ A ! we denote the set of eigenvalues or spectrum of a matrix A . The spectral norm of a matrix is
Î
Î
Î
i Ai2 5 max $?l? : l [ s~ATA!%, and the Frobenius norm of A is
ÎO n
i AiF 5
a2ij.
i, j51
Î
The notation C 2 , ıR , and C 1 , respectively, where ı 5 21 , corresponds to the partitioning of the complex plane into the open left-half plane, the imaginary axis, and the open right-half plane, respectively. The identity matrix of order n is denoted by I n , and the k th unit vector is denoted e k . We use the colon notation to specify submatrices. (This notation is also used in Golub and Van Loan [1989].) For example, A k:,, p:q denotes the submatrix of A defined by its entries a ij , k # i # , , p # j # q .
1
A numerical algorithm is called (numerically) backward stable if the computed solution is the exact solution for slightly perturbed initial data. It is said to be strongly backward stable if it is backward stable and the perturbations have the same structure as the initial data [Bunch 1987].
ACM Transactions on Mathematical Software, Vol. 26, No. 1, March 2000.
Algorithm 800: Computing the Eigenvalues of Hamiltonian Matrices I
•
53
In the next section we review Van Loan’s square-reduced method. In Section 3 we introduce some scaling strategies which can in some cases improve the accuracy of the computed eigenvalues and describe the details of the implementation. Numerical examples demonstrating the performance of the method are presented in Section 4. In Section 5 we also demonstrate how to use our subroutines for solving two problems from control theory: the distance-to-instability problem and computing the * ` -norm of a transfer matrix. Conclusions are drawn in Section 6. 2. VAN LOAN’S SQUARE-REDUCED METHOD 2.1 Algebraic Properties of Hamiltonian and Symplectic Matrices First we review some well-known results about Hamiltonian and symplectic matrices which form the basis for Van Loan’s method. These results can be found in Van Loan [1984], so we omit the proofs. The spectrum of a Hamiltonian matrix has the following property. PROPOSITION 1. Let l [ s ~ H ! where H [ R 2n32n is a Hamiltonian matrix. If l [ R or l [ ıR , then 2 l [ s ~ H ! . If l 5 m 1 ı n [ C and m Þ 0 , n Þ 0 , then 2 l , l# , 2 l# [ s ~ H ! . It follows that the spectrum of a Hamiltonian matrix can be written as
s ~ H ! 5 $ l 1, . . . , l n, 2 l 1, . . . , 2 l n% ,
(4)
where Re~ l i ! $ 0 , i 5 1, . . . , n . The algorithms implemented here make extensive use of matrices that are both symplectic and orthogonal. Orthogonal symplectic matrices are essentially products of two kinds of elementary orthogonal symplectic matrices: symplectic Givens and symplectic Householder matrices2 [Paige and Van Loan 1981]. These two matrix types can be defined as follows. Let P 5 P ~ v ! 5 I n 2 2 ~ vv T / v T v ! , v [ R n , be a Householder matrix; then a symplectic Householder matrix is given by
P s~ v ! 5
F
G
P~v! 0 . 0 P~v!
A Givens rotation matrix is symplectic, if the rotation is performed in planes k , n 1 k , 1 # k # n . A symplectic Givens matrix is thus defined by
Gs~k, c, s! 5
F
G
C 2S , S C
2 Note that this notation is somewhat misleading: whereas a symplectic Givens matrix is also a Givens rotation matrix in the classical sense, a symplectic Householder matrix is not a standard Householder matrix but the direct sum of two n 3 n Householder matrices.
ACM Transactions on Mathematical Software, Vol. 26, No. 1, March 2000.
54
•
P. Benner et al.
where c, s [ R , c 2 1 s 2 5 1 , and C 5 I n 1 ~ c 2 1 ! e k e Tk , S 5 se k e Tk . The following proposition shows that the structure of 2n 3 2n orthogonal symplectic matrices permits them to be represented as a pair of n 3 n matrices. This can cut both the arithmetic costs and storage for accumulating orthogonal symplectic matrices in half. PROPOSITION 2 [PAIGE AND VAN LOAN 1981]. An orthogonal matrix U [ R 2n32n is also symplectic if and only if it takes the form
U5
F
U1 U2 2U2 U1
G
where U i [ R n3n , i 5 1, 2 . 2.2 Algorithms Using the well-known abilities of Householder reflections and Givens rotations to annihilate a specific part of a vector and Proposition 2, the following condensed form of 2n 3 2n matrices is derived in Paige and Van Loan [1981]. THEOREM 3. If L [ R 2n32n , then there exists an orthogonal symplectic matrix U [ R 2n32n such that
L˜ 5 U TLU 5
F
L˜11 L˜12 L˜21 L˜22
G
5
,
(5)
˜ 11 is an upper Hessenberg matrix and L ˜ 21 is an upper triangular i.e., L matrix. We refer to (5) as Paige/Van Loan form or PVL form. Now consider the square of a Hamiltonian matrix H as in (1),
K :5 H 2 5
F
A2 1 GQ AG 2 GAT QA 2 ATQ ~A2 1 GQ!T
G F 5:
G
K1 K2 . K3 K T1
Since the lower left and the upper right block of K are obviously skewsymmetric, their diagonal is zero. Squared Hamiltonian matrices are skew-Hamiltonian, i.e., satisfy ~ HJ ! T 5 2 ~ HJ ! . It is easy to see that the structure of skew-Hamiltonian matrices is also preserved by symplectic similarity transformations. Hence, if S [ R 2n32n is a symplectic matrix and H is Hamiltonian, then S 21 H 2 S is also a skew-Hamiltonian matrix. Therefore, using Theorem 3, the PVL form of a skew-Hamiltonian matrix K 5 H 2 is
˜ 5 U TKU 5 K
F
˜1 K ˜2 K ˜ T1 0 K
G
5
ACM Transactions on Mathematical Software, Vol. 26, No. 1, March 2000.
.
(6)
Algorithm 800: Computing the Eigenvalues of Hamiltonian Matrices I
•
55
The eigenvalues of K can thus be computed by computing the eigenvalues ˜ 1 . If s ~ K ˜ 1 ! 5 $ m 1 , . . . , m n % , then s ~ K ! 5 $ m 1 , m 1 , . . . , m n , m n % . of K Hence, according to (4), s ~ H ! can be obtained by taking the positive and ˜ 1 such that l i negative square roots of the computed eigenvalues m i of K
5
Î
Î
m i and 2 l i 5 2 m i for i 5 1, . . . , n . This gives rise to the following algorithm. Algorithm 4: Square-Reduced Method—Explicit Version.
F
G
A G [ R 2n32n . Q 2A T Output: s ~ H ! 5 $ l 1 , . . . , l 2n % , an orthogonal symplectic Matrix U such that U T H 2 U has the form (6). A 2 1 GQ AG 2 GA T . (1) Compute K 5 H 2 5 T QA 2 A Q ~ A 2 1 GQ ! T (2) Compute the PVL form of K as described in Paige and Van Loan [1981], i.e., determine U [ R 2n32n orthogonal and symplectic such that Input: A Hamiltonian matrix H 5
F
U TKU 5
F
G
˜1 K ˜2 K ˜ T1 0 K
G
5
.
˜ 1 ! 5 $ m 1 . . . , m n % using the Hessenberg QR algorithm. (3) Compute s ~ K (4) Set l i 5 m i , l n1i 5 2 m i for i 5 1, . . . , n. END
Î
Î
If the algorithm is used to approximate the eigenvalues of H only, it is not necessary to accumulate the similarity transformations. This is the case, for instance, in some * ` -control applications [Boyd and Balakrishnan 1990; Boyd et al. 1989; Bruinsma and Steinbuch 1990; Doyle et al. 1989; Sreedhar et al. 1995b] or the distance-to-instability problem [Byers 1988; Sreedhar et al. 1995a]. If, for any reason, the Hamiltonian matrix cannot be overwritten by K , the algorithm requires an additional workspace of size 2n 2 1 O ~ n ! . This is the case when the eigenvalues of the Hamiltonian matrix are used as shifts in CARE solution methods as in Ammar et al. [1993], Ammar and Mehrmann [1991], Raines and Watkins [1994], Patel et al. [1994], and Sima [1992], since the original Hamiltonian matrix (or a similar Hamiltonian matrix) is needed in following steps of the algorithm. This additional workspace can be avoided using the implicit version of the algorithm as given in Van Loan [1984]. That is, the orthogonal symplectic matrix U from Step (2) of Algorithm 4 is computed without explicitly forming K and is applied to the original Hamiltonian matrix H using
U TKU 5 ~U THU !2. ACM Transactions on Mathematical Software, Vol. 26, No. 1, March 2000.
56
•
P. Benner et al.
The Hamiltonian matrix U T HU obtained in this way is said to be in square-reduced form. In other words, a square-reduced Hamiltonian matrix H satisfies
H2 5 as in (6). Since U T HU is a Hamiltonian matrix similar to H , the abovementioned algorithms can proceed with U T HU instead of H and thus need no additional workspace to save the original Hamiltonian matrix. Using this approach, it is necessary to accumulate the orthogonal symplectic similarity transformations. The workspace and computational cost for this can essentially be halved using Proposition 2. The skew-Hamiltonian Schur form of the skew-Hamiltonian matrix K 5 H 2 used in the CARE solution methods proposed in Xu [1993] and Xu and Lu [1995] can be computed by a small modification of Algorithm 4. ˜ 1 (Step (3) of Algorithm 4), we Applying the Hessenberg QR algorithm to K
˜ [ R n3n such that T 1 5 V ˜ TK ˜ 1 V is in real obtain an orthogonal matrix V Schur form. By Proposition 3, the block diagonal matrix V5
F G ˜ 0 V ˜ 0 V
is orthogonal and symplectic. The skew-Hamiltonian Schur form is given by
ˆ 5 V TU TKUV 5 K
F
G
T1 T2 . 0 TT1
It is also possible to avoid explicitly squaring the Hamiltonian matrix H in Algorithm 4. This leads to the following implicit version. Note that the same orthogonal symplectic transformations as in Step (2) of Algorithm 4 (computing the PVL form) are computed. Here, they are applied to H rather than to K 5 H 2 . Algorithm 5: Square-Reduced Method—Implicit Version. Input: A Hamiltonian matrix U T HU 5 onal symplectic matrix
U5
F
F
A Q
G 2A T
G
[ R 2n32n and an orthog-
G
U1 U2 . 2U2 U1
Output: s ~ H ! , an orthogonal symplectic matrix U such that U T HU is square-reduced. H is overwritten by its square-reduced form U T HU . ACM Transactions on Mathematical Software, Vol. 26, No. 1, March 2000.
Algorithm 800: Computing the Eigenvalues of Hamiltonian Matrices I
•
57
(1) FOR k 5 1, . . . , n 2 1 (a) IF k # n 2 2 THEN w 4 ~ QA 2 A T Q ! k11:n, k Compute a Householder reflection P such that Pw 5 6 i w i 2 e 1 . Update the Hamiltonian matrix via A 4 PAP, G 4 PGP, Q 4 PQP. Accumulate the reflection (if required) via U 1 4 U 1 P, U 2 4 U 2 P. END IF (b) x 4 ~ A 2 1 GQ ! k11, k , y 4 ~ QA 2 A T Q ! k11, k . Compute a symplectic Givens rotation defined by c, s [ R such that c s x 6 x2 1 y2 5 2s c y 0 and C 5 I n 1 ~ c 2 1 ! e k e Tk , S 5 se k e Tk . Update the Hamiltonian matrix via A 4 CAC 1 SQC 1 CGS 2 SA T S , G 4 CGC 2 SA T C 2 CAS 2 SQS , Q 4 CQC 2 SAC 2 SGS 2 CA T S . Accumulate the rotation (if required) via U 1 4 U 1 C 1 U 2 S, U 2 4 U 2C 2 U 1S . (c) IF k # n 2 2 THEN w 4 ~ A 2 1 GQ ! k11:n, k Compute a Householder reflection P such that Pw 5 6 i w i 2 e 1 . Update the Hamiltonian matrix via A 4 PAP, G 4 PGP, Q 4 PQP. Accumulate the reflection (if required) via U 1 4 U 1 P, U 2 4 U 2 P. END IF END FOR (2) W 4 A 2 1 GQ. (3) Compute s ~ W ! 5 $ m 1 , . . . , m n % by Hessenberg QR iteration. (4) l i 4 m i , i 5 1, . . . , n ; set s ~ H ! 5 $ l 1 , . . . , l n , 2 l 1 , . . . , 2 l n % . END
F
GF G F
Î
G
Î
The algorithm as stated above needs the following work space.
2n2 1 n n
for the Hamiltonian matrix H, 2
2n2 5n2 1 n
for w and W, for the orthogonal symplectic transformation matrix U. total
The workspace for U is of course not required if only the eigenvalues of the Hamiltonian matrix H are to be computed. As it is obvious from this formulation of the implicit algorithm, the symplectic Householder and Givens transformation matrices need not be computed explicitly. Updating and accumulating are straightforward and ACM Transactions on Mathematical Software, Vol. 26, No. 1, March 2000.
58
P. Benner et al.
•
use well-known techniques, e.g., Golub and Van Loan [1989] and Wilkinson [1965]. Using flop3 counts and estimates from Golub and Van Loan [1989], we get the following estimate for the computational cost of Algorithm 5:
4n3 3n2 1 O~n! 16n3 1 O~n2!
flops for implicitly computing the columns of H 2, flops for generating Householder reflections and Givens rotations, flops for updating the Hamiltonian matrix,
8n 1 O~n !
flops for accumulating the orthogonal symplectic transformations,
2n3 1 O~n2!
flops for forming W 5 A2 1 GQ,
3
2
~20/3!n3 1 O~n2! n
~110/3!n3 1 O~n2!
flops for the Hamiltonian QR iteration, flops for the square roots in Step (4). flops total
As for the work space, the computational cost for accumulating the similarity transformations can be saved if only eigenvalues are required. Thus, computing only the eigenvalues of the Hamiltonian matrix requires about 29n 3 flops which is a little more than one third of the computational cost of about 80n 3 flops for the QR algorithm as given, for example, in Golub and Van Loan [1989] applied to the 2n 3 2n Hamiltonian matrix H . (This flop count includes 80n 3 / 3 flops for Hessenberg reduction plus approximately 160n 3 / 3 flops for the Hessenberg QR iteration.) 2.3 Accuracy Another important issue is the accuracy of the computed eigenvalues. Let l [ s ~ H ! , and let l˜ be the analogue computed by either Algorithm 4 or Algorithm 5. Then, Van Loan [1984] proves that
l˜ [ s~H 1 E!, where E [ R 2n32n satisfies
Î
i E i 2 # c « i H i 2. Here c is a small constant, and « denotes the machine precision.
3 Following Golub and Van Loan [1989], we define each floating-point arithmetic operation together with the associated integer indexing as a flop.
ACM Transactions on Mathematical Software, Vol. 26, No. 1, March 2000.
Algorithm 800: Computing the Eigenvalues of Hamiltonian Matrices I
•
59
Remark 6. The perturbation E can be considered as a structured perturbation; that is, if the algorithm is implemented carefully, E is a Hamiltonian matrix. The following result for a simple eigenvalue computed by Algorithm 4 or 5 is derived in Van Loan [1984]
?l 2 l˜ ? ' min
H
«i H i22 s~l!?l?
,
Ϋi H i s~l!
2
J
5«
i H i2 s~l!
3 min
H
i H i2 1 , ?l? «
Î
J
(7)
where s ~ l ! , the reciprocal condition number of l , is the cosine of the acute angle between the left and right eigenvectors of H corresponding to l . The estimate (7) can be interpreted using the standard estimate for eigenvalues l QR computed by the Hessenberg QR iteration [Wilkinson 1965],
?l 2 lQR? ' «
i H i2 s~l!
,
as follows: —If i H i 2 / l ' 1 , then l˜ is as accurate as l QR ,
—If i H i 2 / ? l ? .. 1 , then the error in l˜ can be up to 1 than the error in l QR .
/ Ϋ
times larger
Thus, if relatively small eigenvalues of a Hamiltonian matrix are required with high accuracy, it is not advisable to use Van Loan’s method to compute the eigenvalues. However, if the approximate eigenvalues are used, for example, as shifts, the highest possible accuracy is not required. In the multishift and related algorithms [Ammar and Mehrmann 1991; Ammar et al. 1993; Raines and Watkins 1994], more accurate eigenvalues can be obtained during the iteration. Sometimes, accurate shifts may even lead to forward instability; see Parlett and Le [1993]. For a discussion of the problem of eigenvalues close to the imaginary axis (including “small” eigenvalues) see Section 3.2. 3. IMPLEMENTATION For our implementation, we chose the implicit version of the algorithm in order to avoid the need of explicitly computing the square of the Hamiltonian matrix. Moreover, the Hamiltonian matrix is transformed to a similar Hamiltonian matrix which can then further be used, e.g., in CARE solution algorithms. This avoids saving a copy of the original Hamiltonian matrix. The subroutine DHASRD implements the first step of Algorithm 5, i.e., computes the square-reduced Hamiltonian and, if required, the orthogonal symplectic transformation matrix. The subroutine DHAEVS performs Steps (2)–(4) of Algorithm 5 using the output from DHASRD. We chose to ACM Transactions on Mathematical Software, Vol. 26, No. 1, March 2000.
60
•
P. Benner et al.
separate these steps in order to make it possible to use the square-reduced Hamiltonian matrix itself. We also supply an easy-to-use driver DHAEVD that calculates the eigenvalues of a Hamiltonian matrix using DHASRD and DHAEVS. The implementation and documentation of all subroutines follow the standards proposed for the Subroutine Library in Control Theory SLICOT.4 This standard is based on the documentation style of LAPACK [Anderson et al. 1995]. We will now describe some implementation details and how the subroutines are used. The subroutines require DOUBLE PRECISION versions of the BLAS (levels 1, 2, 3) [Dongarra et al. 1988; 1990; Lawson et al. 1979] and LAPACK [Anderson et al. 1995]. With fl ~ + ! we will denote the result of the floating-point operation “+ ” in finite arithmetic. 3.1 Scaling It is sometimes possible to use scaling or balancing to improve the accuracy of computed eigenvalues. There are several possibilities for scaling in Algorithms 4 and 5. Since balancing as proposed in Parlett and Reinsch [1969] destroys the Hamiltonian structure, we have to look for balancing strategies involving only symplectic similarity transformations. Balancing via diagonal matrices and preserving the Hamiltonian structure lead necessarily to matrices of the form
Ds 5
F
D 0 0 D21
G
(8)
where D is diagonal. We propose three simple, semiheuristic strategies for choosing the diagonal scaling matrix D , symplectic scaling, norm scaling, and Hessenberg scaling. 3.1.1 Symplectic Scaling. Symplectic scaling is a two-part strategy. First a diagonal matrix D 5 D A is chosen to equilibrate the norms of the rows and columns of D 21 A AD A [Parlett and Reinsch 1969]. This transformation can be computed, e.g., by the LAPACK [Anderson et al. 1995] subroutine DGEBAL. This similarity transformation of A is extended to a similarity transformation on the Hamiltonian matrix H by a symplectic, diagonal ˜ matrix D s as in (8). The effect of this is that the rows and columns of A
:5 D 21 A AD A have approximately the same 1-norm which often has also the effect of reducing the 1-norm of A . Thus, if this diagonal scaling yields a reduction of the norm of A (say, by a factor g , 1 ), we can hope to improve ˜ 2 ! , since [Golub and Van Loan 1989] the accuracy for fl ~ A ˜ 2! 2 A ˜ 2i1 # n«iA ˜ i21 1 O~«2! 5 n«gi Ai21 1 O~«2! , n«i Ai21 1 O~«2!. i fl~A
4 SLICOT Implementation and Documentation Standards 2.1. See http://www.win.tue.nl/wgs/ reports.html.
ACM Transactions on Mathematical Software, Vol. 26, No. 1, March 2000.
Algorithm 800: Computing the Eigenvalues of Hamiltonian Matrices I
•
61
The second part of the symplectic scaling strategy is a scaling strategy used for improving the accuracy of solution methods for the CARE (2). Here, the diagonal matrix D in (8) is chosen as D r 5 I n r . This scaling strategy results in a Hamiltonian matrix
/Î
˜ :5 H
F
A
˜ G
˜ 2A Q
T
G F :5
Dr21 0 0 Dr
GF
GF
A G Q 2AT
Dr 0 0 D21 r
G
(9)
˜ 5 r G and Q ˜ 5 Q / r . It was observed in Petkov et al. [1987] that where G scaling H such that i A i 5 i G i 5 i Q i is optimal in the sense that it minimizes the error bounds for the numerical solution of the CARE (2). Unfortunately, it is generally not possible to achieve this optimal scaling via (9). Noting ˜ i1 # i Ai1 1 max $ iG ˜ i 1, i Q ˜ i1 % iH
(10)
and recalling that the error of the computed eigenvalues depends upon i H i 2 we choose r to minimize the bound in (10). This is achieved by r 5 ˜ i1 5 iQ ˜ i 1 [Gardiner 1997]. i Q i 1 y i G i 1 , such that i G Both ideas can be combined, since the second scaling strategy will not affect D 21 A AD A . We will refer to this two-step scaling as symplectic scaling, since the scaling is performed by a similarity transformation with a symplectic matrix. The resulting Hamiltonian matrix is
Î
˜ 5 H where r 5
Îi D
A
3
21 D21 rD21 A ADA A GDA 1 DAQDA 2DAATD21 A r
4
21 QD A i 1 y i D 21 A GD A i 1 .
3.1.2 Norm Scaling. Norm scaling is the strategy proposed in Kenney et al. [1989] and Pandey [1993] for stabilizing the Schur vector method for the solution of CAREs (2). Consider the CARE
05Q1
S D 1
t
T
A ~tX! 1 ~tX!
S D 1
t
A 2 ~tX!
S D 1
t2
G ~tX!.
The corresponding Hamiltonian matrix is
ˆ 5 H
F
ˆ A
ˆ G ˆT Q 2A
G
ˆ 5 A / t, G ˆ 5 G / t 2 , and l [ s ~ H ! if and only if lˆ 5 l / t [ s ~ H ˆ !. where A This strategy is equivalent to scaling the Hamiltonian matrix H by the real scalar 1 / t and then performing a symplectic similarity transformation ACM Transactions on Mathematical Software, Vol. 26, No. 1, March 2000.
62
•
P. Benner et al.
Î
ˆ instead of H in Algorithm 5, we with D s from (8) where D 5 t I n . Using H obtain [Golub and Van Loan 1989] 1 ˆ2 1 G ˆ Q! 2 ~A ˆ2 1 G ˆ Q! i1 # n« ~i Ai21 1 iGi1iQi1! 1 O~«2!, ifl~A t2 1 ˆ 2A ˆ TQ! 2 ~QA ˆ 2A ˆ TQ! i1 # 2n« i Ai1iQi1 1 O~«2!. ifl~QA t
(11)
(12)
The choice t 5 max$i A i 1 , i G i 1 , i Q i 1 % reduces the absolute errors given above to O ~ n« ! and O ~ n« i H i 1 ! , respectively. We bound t by one from below in order not to increase the absolute errors (11) and (12). 3.1.3 Hessenberg Scaling. In Step (3) of Algorithm 5, the usual balancing as proposed in Parlett and Reinsch [1969] of a matrix can be applied to W using LAPACK subroutine DGEBAL. This type of scaling will be called Hessenberg scaling, since it is applied to the upper left Hessenberg block of the squared Hamiltonian matrix. 3.2 Eigenvalues on or Close to the Imaginary Axis An important issue in many applications of the Hamiltonian eigenproblem concerns eigenvalues on or close to the imaginary axis. Algorithms for the computation of the * ` -norm of transfer matrices [Boyd and Balakrishnan 1990; Boyd et al. 1989; Bruinsma and Steinbuch 1990; Doyle et al. 1989; Sreedhar et al. 1995b] or the stability radius of real and complex matrices [Byers 1988; Sreedhar et al. 1995a] have to decide whether there are eigenvalues on the imaginary axis or not. Knowledge of the spectrum of H also gives information about the solution of the CARE (2). THEOREM 7. Let H be a Hamiltonian matrix as in (1), and assume there exist full-rank factorizations G 5 BB T , Q 5 C T C . If ~ A, B ! is stabilizable, i.e., rank @ A 2 l I n , B # 5 n for all l [ C 1 ø ıR , and ~ A, C ! is detectable, i.e., ~ A T , C T ! is stabilizable, then (a) Re ~ l ! Þ 0 for all l [ s ~ H ! . (b) The CARE (2) has a unique symmetric positive semidefinite stabilizing ˆ. solution X
ˆ ! 5 $ 2 l 1, . . . , 2 l n% . (c) If s ~ H ! is as in (4), then s ~ A 2 GX Clearly, if the Hamiltonian matrix corresponding to the CARE has eigenvalues on the imaginary axis, then no stabilizing solution can exist. On the other hand, if all Jordan blocks corresponding to eigenvalues on the imaginary axis have even size, then a real n -dimensional H -invariant ACM Transactions on Mathematical Software, Vol. 26, No. 1, March 2000.
Algorithm 800: Computing the Eigenvalues of Hamiltonian Matrices I
•
63
Lagrangian5 subspace corresponding to eigenvalues l , Re ~ l ! # 0 , exists ˜ of the and under additional assumptions, an almost stabilizing solution X 2 ˜ ! , C ø ıR . For a discussion of CARE can be computed, i.e., s ~ A 2 GX the relation of the spectra of Hamiltonian matrices to the existence and uniqueness of solutions of the CARE we refer to Lancaster and Rodman [1995]. CARE solution methods that require an a priori knowledge of the spectrum of H can, therefore, use this information to decide if a solution of (2) exists before trying to compute it. This is the case, for example, for the multishift and related algorithms [Ammar and Mehrmann 1991; Ammar et al. 1993; Patel et al. 1994; Raines and Watkins 1994]. DHABL/DHASRD/DHAEVS is well suited to testing whether a Hamiltonian matrix has eigenvalues on the imaginary axis. Because the computed eigenvalues are eigenvalues of a perturbed Hamiltonian matrix, the computed eigenvalues appear in 6 pairs as in (4). In particular, imaginary axis eigenvalues that are simple and sufficiently isolated will remain on the imaginary axis despite rounding errors. However, multiple or nearly multiple imaginary axis eigenvalues are possible and typical in stability radius and H ` -norm calculations. Rounding errors can perturb multiple and nearly multiple eigenvalues off of the imaginary axis. A typical test would be to consider a computed eigenvalue l˜ to have zero real part if
?Re ~l˜ !? # tol 3 ?l˜ ?
Î
where tol is a user-defined tolerance. A conservative choice of tol is « where « is the unit round. This tolerance is motivated by the following fact: suppose we have computed an eigenvalue of H 2 of magnitude « i H i 2 . Since rounding errors can perturb eigenvalues by at least « i H i 2 , it is problematical to determine whether or not the corresponding exact, unperturbed eigenvalue lies on the negative real axis. Taking its square root can result in a computed eigenvalue of H with real part of size up to « i H i . Conversely, if the Hamiltonian matrix has an exact eigenvalue with magnitude O ~ « ! , then the corresponding eigenvalue of H 2 has magnitude O ~ « ! . Rounding errors could perturb this small eigenvalue of H 2 onto the negative real axis making it appear as if H had an eigenvalue on the imaginary axis. In Section 5 we will give an example how this can be used when computing the stability radius of a real matrix or the * ` -norm of a transfer matrix.
Î
Î
An n -dimensional subspace 9 , R 2n is called Lagrangian if x T Jy 5 0 for all x, y [ 9 and J as in (3). 5
ACM Transactions on Mathematical Software, Vol. 26, No. 1, March 2000.
64
•
P. Benner et al.
3.3 Usage The subroutine DHASRD computes the square-reduced form of a Hamilto˜ is the Hamiltonian matrix returned by DHASRD, nian matrix, i.e., if H then (in exact arithmetic)
˜25 H
F
K1 K2 0 K T1
G
5
.
The subroutine is called as follows:
CALL DHASRD~COMPU, N, A, LDA, QG, LDQG, U, LDU, RWORK, IERR! A complete description of input and output arguments is given in the prologue in the DHASRD source code. The Hamiltonian matrix (1) is provided by its blocks A , G , and Q . The block A is stored in the twodimensional array A. The lower triangular part of the symmetric matrix Q and the upper triangular part of the symmetric matrix G are packed together in the n 3 ~ n 1 1 ! array QG. If required (as defined by COMPU), the orthogonal symplectic transformations are accumulated in a matrix U . The output argument U is a twodimensional array that contains the first n rows of this matrix. By Proposition 2, the first n rows completely define the 2n 3 2n orthogonal symplectic matrix U . The subroutine DHAEVS uses the output of DHASRD and computes the eigenvalues of the Hamiltonian matrix. The calling sequence is
CALL DHAEVS~JOBSCL, N, A, LDA, QG, LDQG, WR, WI, RWORK, IERR! A complete description of input and output arguments is given in the prologue in the DHAEVS source code. Briefly, A and QG are the arrays computed by DHASRD. The eigenvalues of the Hamiltonian matrix are returned in WR (real parts) and WI (imaginary parts). If the mode parameter JOBSCL is set to S, then DHAEVS will do Hessenberg scaling as described in Section 3.1. The subroutine DHAEVD is an easy-to-use driver that calls DHASRD and DHAEVS to calculate the eigenvalues of a Hamiltonian matrix. The calling sequence is
CALL DHAEVD~N, A, LDA, QG, LDQG, WR, WI, RWORK, IERR! A complete description of input and output arguments is given in the prologue in the source code of DHAEVD. To make this program as easy to use as possible, there are no mode parameters. DHAEVD uses Hessenberg scaling. The symplectic orthogonal similarity transformation is not accumulated. As with DHASRD and DHABL, the Hamiltonian matrix (1) is provided by its blocks A , G , and Q . The block A is stored in the twoACM Transactions on Mathematical Software, Vol. 26, No. 1, March 2000.
Algorithm 800: Computing the Eigenvalues of Hamiltonian Matrices I Table I.
•
65
Required BLAS and LAPACK Subroutines
SUBROUTINES CALLED BY DHAEVS BLAS: LAPACK: Miscellaneous:
DCOPY, DGEMM, DSYMV. DGEBAL, DHSEQR, DLACPY, LSAME. DCROOT (which calls LAPACK DLAPY2)
SUBROUTINES CALLED BY DHASRD BLAS: LAPACK:
DAXPY, DCOPY, DDOT, DGEMV, DROT, DSYMV, DSYR2. DLARFG, DLARFX, DLARTG, LSAME.
SUBROUTINES CALLED BY DHABL BLAS: LAPACK:
DRSCL. DGEBAL, DLABAD, DLAMCH, DLANGE, DLANSY, DLASCL, LSAME.
dimensional array A. The lower triangular part of the symmetric matrix Q and the upper triangular part of the symmetric matrix G are packed together in the n 3 ~ n 1 1 ! array QG. The symplectic and norm scaling strategies are implemented in subroutine DHABL with calling sequence
CALL DHABL~JOBSCL, N, A, LDA, QG, LDQG, D, RWORK, IERR! A complete description of input and output arguments is given in the prologue in the DHABL source code. When the mode parameter JOBSCL is set to “A”, DHABL performs symplectic scaling. When the mode parameter JOBSCL is set to “B”, DHABL performs norm scaling. (Hessenberg scaling is performed by subroutine DHAEVS.) 3.4 Subroutine Organization The basis for the subroutines DHASRD and DHAEVS are the BLAS and LAPACK [Anderson et al. 1995; Dongarra et al. 1988; Lawson et al. 1979]. Table I shows the functions and subroutines required from these subroutine libraries. The easy-to-use driver DHAEVD calls DHASRD and DHAEVS. Besides the BLAS and LAPACK routines, DHAEVS calls a short routine named DCROOT to compute the square root of a complex number using real arithmetic. The root is chosen such that the real part is nonnegative. This subroutine was adapted from the EISPACK [Smith et al. 1976] subroutine CSROOT. 4. NUMERICAL EXAMPLES We tested our subroutines for all Hamiltonian matrices from the benchmark collection for continuous-time algebraic Riccati equations [Benner et ACM Transactions on Mathematical Software, Vol. 26, No. 1, March 2000.
66
•
P. Benner et al. Table II.
Notation for the Scaling Strategies Discussed in Section 3.1
DHABL(A)/DHASRD/DHAEVS(S) DHABL(B)/DHASRD/DHAEVS(S) DHASRD/DHAEVS(S) DHASRD/DHAEVS
Symplectic Scaling and Hessenberg scaling Norm Scaling and Hessenberg scaling Hessenberg scaling alone No scaling
al. 1995], the examples given in Van Loan [1984], and some randomly generated examples. Here we present some selected experiments. The numerical tests reported here used IEEE double-precision arithmetic with machine epsilon « ' 2.2204 3 10 216 . The programs were compiled and run on a Sun Microsystems Ultra-1-200E computer, using version 4.2 of the Sun f77 compiler with the -dalign -fsimple51 -libmil -xlic_lib 5sunperf compiler flags. The last flag instructs the compiler to use LAPACK subroutines and tuned BLAS from the Sun performance library version 1.2. We also run several tests on Hewlett-Packard workstations and PCs running LINUX. The effects of rounding are similar to those reported below. Variations in execution time between the various platforms appear to be due to differing CPUs. In the following tests, when exact eigenvalues are unavailable, we will assess the computed eigenvalues in the following backward error sense. Suppose l˜ is an approximate eigenvalue of a matrix H . Define s l˜ to be the smallest singular value of H 2 l˜ I , i.e., s l˜ 5 s min$~ H 2 l˜ I !% . It is well known that s l˜ is the 2–norm of the perturbation matrix E of smallest 2-norm for which l˜ is an exact eigenvalue of H 1 E . In other words,
sl˜ 5 min $i Eil˜ [ s~H 2 l˜ I !%. Thus, s l˜ is the magnitude of the “backward error” in l˜ as an approximate eigenvalue of H . In particular, the smaller s l˜ , the better is l˜ as an approximate eigenvalue of H . In this section we will denote the various scaling strategies discussed in Section 3.1 as shown in Table II. We compared our subroutines with the LAPACK driver routine DGEEVX for computing the eigenvalues of a general real matrix using the QR algorithm. In all calls to DGEEVX, we used (nonsymplectic) diagonal scaling and permutations (BALANC5‘B’) to improve the conditioning of eigenvalues. Although rounding errors prevent LAPACK subroutine DGEEVX from preserving the Hamiltonian eigenvalue plus-minus pairs, the tables below report only the computed eigenvalues with nonnegative real part. Example 1 [Van Loan 1984, Ex. 2].
Let
A 5 diag ~1, 1022, 1024, 1026, 1028!.
ACM Transactions on Mathematical Software, Vol. 26, No. 1, March 2000.
Algorithm 800: Computing the Eigenvalues of Hamiltonian Matrices I Table III.
•
67
Example 1, Absolute Errors |l 2 l˜ | DHASRD DHAEVS
l 1 10 22 10 24 10 26 10 28
5.0 3.5 1.4 2.0
DGEEVX
1.0 5.0 2.6 8.4 4.7
0 z 10 215 z 10 214 z 10 211 z 10 29
z z z z z
10 215 10 217 10 218 10 218 10 217
Then a Hamiltonian matrix H is obtained by
H 5 UT
F
G
A 0 U, 0 2AT
where U [ R 2n32n is an orthogonal symplectic matrix randomly generated by five symplectic rotations and five reflectors. Thus, s ~ H ! 5 $ 61, 610 22 , 610 24 , 610 26 , 610 28 % . For this example all the selected scale parameters equal one, and hence all the scaling strategies produced the same results. Table III shows the absolute errors in the eigenvalue approximations computed by DHASRD/ DHAEVS and DGEEVX. Here, the loss of accuracy of order i H i 2 / ? l ? for Van Loan’s method is obvious. DGEEVX computes all eigenvalues to full accuracy. Repeating the computations for several randomly chosen matrices U , the results for DHASRD/DHAEVS varied by about one order of magnitude for the smaller eigenvalues. (This is the reason for the slightly different results reported in Benner et al. [1998].) Example 2 [Van Loan 1984].
A5
3
The Frank matrix A [ R n3n is defined by
n n21 n22 ... n21 n21 n22 ... 0 n22 n22 ... ·· 0 0 n23 · · · ·· · · · ·· ·· · · · · 0 0 ...
... ... ... ·· · ·· · 0
2 2 2 · · ·· · · 2 1
4
1 1 1 · · . ·· · · 1 1
All its eigenvalues are real and positive. The smaller eigenvalues are ill-conditioned. A Hamiltonian matrix having the same eigenvalues as the Frank matrix together with their negative counterparts is generated as in Example 1 by
H 5 UT
F
G
A 0 U, 0 2AT
ACM Transactions on Mathematical Software, Vol. 26, No. 1, March 2000.
68
•
P. Benner et al. Table IV.
l ' 0.031028 0.049508 0.081228 0.14365 0.28475 0.64351 1.5540 3.5119 6.9615 12.311 20.199 32.229
DHABL(A) DHASRD DHAEVS(S)
9.1 5.2 2.6 6.0 7.4 1.5 5.2 1.6 5.0 7.7 7.0 1.0
z z z z z z z z z z z z
214
10 10 214 10 214 10 215 10 215 10 214 10 215 10 215 10 216 10 215 10 215 10 214
Example 2, Backward Errors s l˜ 5 s min~ H 2 l˜ I ! DHABL(B) DHASRD DHAEVS(S)
5.5 3.5 1.9 9.6 3.6 8.9 1.3 3.8 4.1 2.0 5.5 1.5
z z z z z z z z z z z z
211
10 10 211 10 211 10 212 10 212 10 213 10 213 10 214 10 214 10 214 10 216 10 214
DHASRD DHAEVS(S)
2.8 1.8 7.9 1.4 1.0 1.5 7.5 3.7 5.3 3.1 3.6 4.9
z z z z z z z z z z z z
214
10 10 214 10 215 10 215 10 214 10 214 10 215 10 216 10 215 10 215 10 215 10 215
DHASRD DHAEVS
6.1 3.3 1.4 1.9 7.9 1.4 7.7 3.7 1.3 4.7 6.0 2.8
z z z z z z z z z z z z
DGEEVX
214
10 10 214 10 214 10 215 10 215 10 214 10 215 10 216 10 215 10 215 10 215 10 215
1.8 2.1 1.8 1.6 1.7 1.5 6.5 3.2 7.2 1.1 6.8 2.0
z z z z z z z z z z z z
10 215 10 215 10 215 10 215 10 215 10 215 10 215 10 215 10 215 10 214 10 215 10 215
where U [ R 2n32n is an orthogonal symplectic matrix randomly generated by n symplectic rotations and n reflectors. Exact eigenvalues are not known, and some eigenvalues are ill-conditioned. So, Table IV lists the backward errors s l˜ 5 s min~ H 2 l˜ I ! . The table demonstrates that, at least in this case, norm scaling DHABL(B)/ DHASRD/DHAEVS(S) is not as effective as the other scaling strategies. Example 3 [Benner et al. 1995].
A5
F
G
3 1 , G5 4 2
F
Let
G
1 1 , Q5 1 1
F
G
211 25 . 25 22
The spectrum of
H5
F
A G Q 2AT
G
is {6ı} with algebraic multiplicity two and geometric multiplicity one. The computed eigenvalues are listed in Table V. The different scaling strategies for DHAEVS result in different perturbations of the eigenvalues. The QR algorithm as implemented in DGEEVX does not preserve Hamiltonian structure. Its computed eigenvalues do not appear in plus-minus pairs as the exact eigenvalues do. Eigenvalues computed through the square-reduced method remain in plus-minus pairs. Example 4 [Benner et al. 1995, Ex. 6; Davison and Gesing 1978]. This example comes from a control problem for a J-100 jet engine as a special case of a multivariable servomechanism problem. The corresponding linear time-invariant system is described by ACM Transactions on Mathematical Software, Vol. 26, No. 1, March 2000.
Algorithm 800: Computing the Eigenvalues of Hamiltonian Matrices I Table V.
33.3 20.0 20.0 20.0
Computed Eigenvalues
DHABL(A) DHASRD DHAEVS(S)
0.187133296480218 z 10 27 61.000000000000000ı 20.187133296480218 z 10 27 61.000000000000000ı
DHABL(B) DHASRD DHAEVS(S)
60.999999971617234ı 61.000000028382765ı
DHASRD DHAEVS(S)
60.999999968884276ı 61.000000031115725ı
DHASRD DHAEVS(S)
60.999999968884276ı 61.000000031115725ı
DGEEVX
0.589883505930366 z 10 28 61.000000028925357ı 20.589883537155389 z 10 28 60.999999971074641ı
Table VI.
69
Example 3, Computed Eigenvalues
Subroutines
l 5
•
Example 4, Absolute Errors for Exact Eigenvalues 33.3, 20, 20, 20 DHABL(A) DHASRD DHAEVS(S)
1.7 2.2 1.6 2.7
z z z z
210
10 10 210 10 210 10 210
DHABL(B) DHASRD DHAEVS(S)
1.2 4.3 2.6 2.6
z z z z
29
10 10 212 10 213 10 213
x˙~t! 5 Ax~t! 1 Bu~t! y~t! 5 Cx~t!
DHASRD DHAEVS(S)
3.3 4.3 3.5 3.5
z z z z
212
10 10 212 10 210 10 210
DHASRD DHAEVS
2.8 9.1 3.5 3.5
z z z z
212
10 10 213 10 210 10 210
DGEEVX
0 0 0 0
for t . 0, x~0! 5 x0, for t $ 0,
where the state vector x contains the state of the jet engine, the actuators, and the sensors. The system matrices A [ R 30330 , B [ R 3033 , and C [ R 5330 appear in Benner et al. [1995] and Davison and Gesing [1978]. The Hamiltonian matrix is
H5
F
G
A BBT . CTC 2AT
We know the exact values of only four of the eigenvalues of H : 33.3 and a triple eigenvalue at 20 . DGEEVX computed these four eigenvalues without error. (It returned 33.3 correctly rounded to the precision of the arithmetic.) Table VI lists absolute errors for these four known eigenvalues. The table shows that norm scaling improved the accuracy of the triple eigenvalue 20 . Table VII lists the values of s l˜ for the two largest magnitude and two smallest magnitude computed eigenvalues. In this example the norm of the ACM Transactions on Mathematical Software, Vol. 26, No. 1, March 2000.
70
•
Table VII.
l ' 0.18240 0.64303 187.64 577.04
P. Benner et al. Example 4, Backward Errors s l˜ 5 s min~ H 2 l˜ I ! for Computed Eigenvalues l˜ DHABL(A) DHASRD DHAEVS(S)
DHABL(B) DHASRD DHAEVS(S)
212
4.6 z 10 6.1 z 10 28 0 8.3 z 10 214
1.8 3.4 1.9 6.4
z z z z
DHASRD DHAEVS(S)
215
10 10 24 10 213 10 214
1.5 6.6 2.0 1.3
z z z z
DHASRD DHAEVS
210
10 10 210 10 213 10 212
1.5 6.6 2.2 1.5
z z z z
DGEEVX
210
10 10 210 10 213 10 212
6.2 2.5 1.6 2.6
z z z z
10 217 10 215 10 214 10 214
Hamiltonian matrix is relatively large compared to the eigenvalues. The largest magnitude eigenvalue is approximately 577 but i H i ' 10 8 . The table clearly demonstrates the O « backward error in the smallest eigenvalues computed through DHASRD. In this example, norm scaling significantly increased the accuracy of the eigenvalue pair 6 l of smallest magnitude, but at the same time, it also significantly decreased the accuracy of the eigenvalue pair of second smallest magnitude.
Î
Example 5 [Benner et al. 1995, Ex. 15; Laub 1979, Ex. 5; Van Loan 1984, Ex. 1]. The Hamiltonian matrix in this problem comes from the position and velocity control problem for a string of N high-speed vehicles and is given by
A5
3
A11 0 · · ·
A12 A22 ·· ·
0 ... A23 0 ... ·· ·· ·· · · · 0 AN22, N22 AN22, N21 0
0
...
AN21, N21 0
F G
0
where
Ak, k 5
F
G
21 0 , 1 # k # N 2 1, 1 0
and
Ak, k11 5
F
G
0 0 , 1 # k # N 2 2. 21 0
The off-diagonal blocks are given by
G 5 diag ~1, 0, 1, 0, . . . , 1, 0, 1!, ACM Transactions on Mathematical Software, Vol. 26, No. 1, March 2000.
0 0 · · · 0 0 1 21
4
Algorithm 800: Computing the Eigenvalues of Hamiltonian Matrices I Table VIII.
71
•
Example 5, CPU Seconds of Execution Time for DHABL/DHASRD/DHAEVS and DGEEVX
N ~ n 5 2N 2 1 ! DHABL(A)/DHASRD/DHAEVS(S) DHABL(B)/DHASRD/DHAEVS(S) DHASRD/DHAEVS(S) DHASRD/DHAEVS DGEEVX
25
50
75
100
200
0.045 0.043 0.042 0.042 0.19
0.29 0.29 0.28 0.28 1.2
0.90 0.90 0.88 0.88 4.4
2.0 2.0 2.0 1.9 10
17 17 17 17 84
Q 5 diag ~0, 10, 0, 10, . . . , 0, 10, 0!. The Hamiltonian matrix is
H5
F
A G Q 2AT
G
[ R2n32n
with n 5 2N 2 1 . All the eigenvalues are relatively well conditioned, and i H i 2 / ? l ? 5 O ~ 1 ! for all l [ s ~ H ! . In Table VIII we give the CPU times used by DHABL/DHASRD/DHAEVS and by DGEEVX on the SUN Ultra-1-200E. The table shows that for increasing N , the CPU time used by DHAEVS tends to be very roughly 20% of that of DGEEVX. This is faster than the 36% predicted by flop counts and seems to be due to the handling of multiplications with zeros in the SUN CPU. Execution times on a LINUX-PC with an AMD K6 200MHz CPU are in accordance with the flop counts. Example 6. We tested our subroutines for randomly generated Hamiltonian matrices with entries distributed uniformly in the interval @ 21, 1 # . Since the eigenvalue distribution for these examples usually behaves nicely, the eigenvalues computed by DHASRD/DHAEVS are as accurate as for DGEEVX even without scaling. We give the CPU times for 2n 3 2n examples for n varying from 25 to 200 . For each value of n , we recorded the CPU seconds of execution time required to solve 100 randomly generated Hamiltonian eigenvalue problems. Table IX lists the mean CPU seconds of execution time measured on the SUN Ultra-1-200E. The table shows that for these Hamiltonian matrices, DHASRD/DHAEVS uses about 41% of the execution time of DGEEVX. This is slightly more than the 36% predicted by flop counts. This is probably because our implementation of DHASRD does not take as much advantage of the level 3 BLAS as does DGEEVX. Besides the faster computation of the eigenvalues, DHAEVS returns the right pairing of the eigenvalues as 6 l i , i 5 1, . . . , n . Since DGEEVX treats a Hamiltonian matrix like an arbitrary nonsymmetric matrix, small perturbations can and do cause computed eigenvalues with small real parts to cross the imaginary axis. For example, the number of stable eigenvalues returned by DGEEVX for the n 5 100 case varied from a minimum of 94 to a maximum of 104 . Similar variations were observed for all values of n . ACM Transactions on Mathematical Software, Vol. 26, No. 1, March 2000.
72
P. Benner et al.
•
Table IX.
Example 6, Average CPU Seconds of Execution Times for DHASRD/DHAEVS (without scaling) and DGEEVX Across 100 Trials
n DHASRD/DHAEVS DGEEVX
25
50
75
100
125
150
175
200
0.014 0.032
0.083 0.20
0.26 0.67
0.59 1.4
1.1 2.8
2.0 4.8
3.1 7.7
4.6 11
5. APPLICATIONS In this section, we demonstrate the application of of DHABL/DHASRD/ DHAEVS to two problems in computational control theory: calculation of the stability radius and calculation of the * ` -norm of a transfer function. Example 7 (The Stability Radius of a Matrix [Byers 1988]). Given a stable matrix A [ R n3n (i.e., s ~ A ! , C 2 ), it is often important to know how near A is to an unstable matrix: i.e., what is the smallest norm perturbation E [ C n3n for which A 1 E is unstable? The distance of A to the unstable matrices can be measured by
b~A! 5 min $i Ei : s~A 1 E! ù ıR Þ À%. In Byers [1988], a bisection method for measuring b ~ A ! is presented which is based on the following observation: THEOREM 8 [BYERS 1988].
If a $ 0 , then the Hamiltonian matrix
H 5 H~a! 5
F
A 2aIn aIn 2AT
G
has an eigenvalue on the imaginary axis if and only if a $ b ~ A ! . The following algorithm estimates b ~ A ! within a factor of 10 or indicates that b ~ A ! is less than a small tolerance Algorithm BISEC. Input: A [ R n3n and a tolerance tol . 0 . Output: d , g [ R satisfying either g / 10 # d # b ~ A ! # g or 0 # b ~ A ! # g # 10 tol . Set d 5 0 and g 5 i A 1 A T i F / 2 . WHILE g . 10 max$ tol, d % DO Set a 5 g max$ tol, d % IF s ~ H ~ a !! ù i R Þ À THEN set g 5 a ELSE set d 5 a END IF END WHILE END
Î
ACM Transactions on Mathematical Software, Vol. 26, No. 1, March 2000.
Algorithm 800: Computing the Eigenvalues of Hamiltonian Matrices I
73
•
Table X. Example 7, d, g, and CPU Seconds of Execution Time DHABLA(A)/DHASRD/DHAEVS(S)
v 21
10 10 23 10 25 10 27 10 29
d
g 22
1.84 z 10 5.82 z 10 24 3.27 z 10 26 1.84 z 10 28 0.0
1.03 3.27 1.84 1.03 3.27
z z z z z
DGEEVX
d
CPU Time 21
10 10 23 10 25 10 27 10 29
2.6 2.5 2.5 2.5 2.5
g 22
1.84 z 10 5.82 z 10 24 3.27 z 10 26 1.84 z 10 28 0.0
1.03 3.27 1.84 1.03 3.27
z z z z z
CPU Time 21
10 10 23 10 25 10 27 10 29
4.9 5.0 5.1 5.1 5.1
Note that i A 1 A T i F / 2 is a simple upper bound for b ~ A ! . If tol 5 10 2p i A 1 A T i F / 2 , then at most log2 p bisection steps will be needed. We used Algorithm BISEC with p 5 12 such that at most four bisection steps were required. The eigenvalues of H ~ a ! were computed using DHABL(A)/ DHASRD/DHAEVS(S) (symplectic scaling) and DGEEVX. A computed eigenvalue l˜ was considered to be purely imaginary if
Re ~l˜ ! , 10«i H~a!iF?l˜ ? 5: toll.
(13)
Let
S
A 5 U T diag 100, 99, . . . , 3,
F
v 1 21 v
GD
U
where U 5 I n 2 2 ~ uu T / u T u ! and u 5 @ 1, 2, . . . , 100 # T . Thus, b ~ A ! 5 min$ 3, v % . We computed the upper and lower bounds for b ~ A ! , i.e., d and g , once by BISEC using DHABL(A)/DHASRD/DHAEVS(S) and once by BISEC using DGEEVX. Table X shows the computed values for d and g as well as the required CPU times on a SUN Ultra-1-200E for several values of v . The table shows that DHABL(A)/DHASRD/DHAEVS(S) is about twice as fast as DGEEVX. In view of (13) it is not surprising that both DHABL(A)/ DHASRD/DHAEVS(S) and DGEEVX obtained the same bounds for b ~ A ! . Example 8 (* ` -Norm of a Transfer Matrix). The computation of the * ` -norm i G i * ` of a transfer matrix
G~s! :5 C~sI 2 A!21B 1 D 5:
F
A B C D
G
where A [ R n3n is stable, B [ R n3m , and C [ R p3n , and D [ R p3m , play a central role in * ` -control problems (e.g., see Francis [1987] and Doyle et al. [1989]). Here,
iGi*` 5 sup $ iG~ıs!i2 : s [ R %. ACM Transactions on Mathematical Software, Vol. 26, No. 1, March 2000.
74
•
P. Benner et al.
Let a [ R such that a . s max~ D ! where s max~ D ! denotes the largest singular value of D , and define
F~a! 5 A 1 B~a2I 2 DTD!21DTC, R~a! 5
1
a2
B~a2I 2 DTD!21BT,
Q~a! 5 2CT~I 1 D~a2I 2 DTD!21DT!C, H~a! 5
F
G
F~a! R~a! . Q~a! 2F~a!T
Obviously, H ~ a ! is Hamiltonian. It is shown in Doyle et al. [1989] and Lancaster and Rodman [1995] that if i D i , a , then i G i * ` , a if and only if s ~ H ~ a !! ù i R 5 À . This result indicates that an upper and lower bound for i G i * ` can be computed via Algorithm BISEC of Example 7. To get closer bounds, we also have to modify the stopping criterion in Algorithm BISEC. To obtain an interval with g # k d , the stopping criterion is modified to g # kmax$ tol, d % . A similar bisection method was proposed in Boyd et al. [1989]. The initial search interval @ d , g # may be chosen to be @ s max~ D ! , g ub # where g ub is the upper bound proposed in Boyd et al. [1989], i.e.,
Î
gub 5 smax~D!12 n z trace ~WcWo!, and W c , W o are the solutions of the controllability and observability Lyapunov equations
AWc 1 Wc AT 1 BBT 5 0, ATWo 1 Wo A 1 CTC 5 0. As an example we computed upper and lower bounds for the state-space system given in Example 4 with D 5 0 . For this example, i G i * ` ' 2275.03 . The decision if H ~ a ! has eigenvalues on the imaginary axis was based on the eigenvalues computed by DHAEVS analogous to Example 7. Using k 5 1.001 (i.e., a relative accuracy of 0.1%), we obtained 2273.2 # i G i * ` # 2275.1 after 15 iterations. In Boyd and Balakrishnan [1990], a quadratically convergent algorithm for the computation of the * ` -norm is given. It requires the computation of all the purely imaginary eigenvalues of H ~ a ! at each iteration step. These purely imaginary eigenvalues may conveniently be calculated DHABL/ DHASRD/DHAEVS. ACM Transactions on Mathematical Software, Vol. 26, No. 1, March 2000.
Algorithm 800: Computing the Eigenvalues of Hamiltonian Matrices I
•
75
In addition to the above examples, DHABL/DHASRD/DHAEVS may be used to obtain the shifts for the multishift algorithm and other algorithms to solve algebraic Riccati equations [Ammar et al. 1993; Patel et al. 1994; Raines and Watkins 1994; Sima 1992]. 5. CONCLUSIONS We have presented Fortran 77 subroutines that transform Hamiltonian matrices to square-reduced form and approximate its eigenvalues as described in Byers [1983] and Van Loan [1984]. Numerical experiments on computers with conventional architecture confirm the theoretical expectation that these subroutines do less than half the work and finish in less than half the time of the QR algorithm as implemented in LAPACK [Anderson et al. 1995]. Rounding error analysis and numerical experiments also confirm the observation in Byers [1983] and Van Loan [1984] that eigenvalues of larger magnitude are computed as accurately as their condition numbers suggest, but that tiny eigenvalues may be perturbed by a square root of the unit round. Of the three scaling strategies tested here, norm scaling did not prove to be as effective as symplectic scaling and Hessenberg scaling. Although scaling sometimes improves accuracy, an error of order of the square root of machine precision cannot always be avoided. ACKNOWLEDGMENTS
We thank the referees for helpful comments improving the readability of the manuscript and the functionality as well as modularity of the implemented subroutines. REFERENCES AMMAR, G. AND MEHRMANN, V. 1991. On Hamiltonian and symplectic Hessenberg forms. Linear Alg. Appl. 149, 55–72. AMMAR, G., BENNER, P., AND MEHRMANN, V. 1993. A multishift algorithm for the numerical solution of algebraic Riccati equations. Electr. Trans. Num. Anal. 1, 33– 48. ANDERSON, E., BAI, Z., BISCHOF, C., DEMMEL, J., DONGARRA, J., DUCROZ, J., GREENBAUM, A., HAMMARLING, S., MCKENNEY, A., OSTROUCHOV, S., AND SORENSEN, D. 1995. LAPACK Users’ Guide. 2nd ed. SIAM, Philadelphia, PA. BENNER, P., BYERS, R., MEHRMANN, V., AND XU, H. 2000. Fortran 77 subroutines for computing the eigenvalues of Hamiltonian matrices II. In preparation. BENNER, P., LAUB, A., AND MEHRMANN, V. 1995. A collection of benchmark examples for the numerical solution of algebraic Riccati equations I: Continuous-time case. Tech. Rep. SPC 95_22. Fakultät für Mathematik, TU Chemnitz-Zwickau, Chemnitz, Germany. Available via http://www.tu-chemnitz.de/sfb393/spc95pr.html. BENNER, P., MEHRMANN, V., AND XU, H. 1998. A numerically stable, structure preserving method for computing the eigenvalues of real Hamiltonian or symplectic pencils. Numer. Math. 78, 329 –358. BOYD, S. AND BALAKRISHNAN, V. 1990. A regularity result for the singular values of a transfer matrix and a quadratically convergent algorithm for computing its L ` -norm. Syst. Control Lett. 15, 1 (July), 1–7. ACM Transactions on Mathematical Software, Vol. 26, No. 1, March 2000.
76
•
P. Benner et al.
BOYD, S., BALAKRISHNAN, V., AND KABAMBA, P. 1989. A bisection method for computing the * ` norm of a transfer matrix and related problems. Math. Control Syst. 2, 207–219. BRUINSMA, N. A. AND STEINBUCH, M. 1990. A fast algorithm to computer the * ` -norm of a transfer function matrix. Syst. Control Lett. 14, 4 (Apr. 1990), 287–293. BUNCH, J. 1987. The weak and strong stability of algorithms in numerical algebra. Linear Alg. Appl. 88, 49 – 66. BUNSE-GERSTNER, A. AND MEHRMANN, V. 1986. A symplectic QR-like algorithm for the solution of the real algebraic Riccati equation. IEEE Trans. Automat. Contr. AC-31, 12 (Dec.), 1104 –1113. BUNSE-GERSTNER, A., MEHRMANN, V., AND WATKINS, D. 1989. An SR algorithm for Hamiltonian matrices based on Gaussian elimination. Meth. Oper. Res. 58, 339 –358. BYERS, R. 1983. Hamiltonian and symplectic algorithms for the algebraic Riccati equation. Ph.D. Dissertation. Department of Computer Science, Cornell University, Ithaca, NY. BYERS, R. 1986. A Hamiltonian QR algorithm. SIAM J. Sci. Stat. Comput. 7, 1 (Jan. 1986), 212–229. BYERS, R. 1988. A bisection method for measuring the distance of a stable to unstable matrices. SIAM J. Sci. Stat. Comput. 9, 5, 875– 881. DAVISON, E. AND GESING, W. 1978. The systematic design of control systems for the multivariable servomechanism problem. In Alternatives for Linear Multivariable Control, M. Sain, J. Peczkowsky, and J. Melsa, Eds. Alternatives for Linear Multivariable Control, Chicago, IL. DONGARRA, J. J., DU CROZ, J. J., HAMMARLING, S., AND DUFF, I. S. 1990. A set of level 3 basic linear algebra subprograms. ACM Trans. Math. Softw. 16, 1 (Mar. 1990), 1–17. DONGARRA, J. J., DU CROZ, J., HAMMARLING, S., AND HANSON, R. J. 1988. An extended set of FORTRAN Basic Linear Algebra Subprograms. ACM Trans. Math. Softw. 14, 1 (Mar. 1988), 1–17. DOYLE, J., GLOVER, K., KHARGONEKAR, P. P., AND FRANCIS, B. A. 1989. State-space solutions to standard H 2 and H ` control problems. IEEE Trans. Automat. Contr. 34, 8, 831– 847. FRANCIS, B. 1987. A course in * ` control theory. Springer Lecture Notes in Computer Science, vol. 88. Springer-Verlag, Vienna, Austria. GARDINER, J. D. 1997. A stabilized matrix sign function algorithm for solving algebraic Riccati equations. SIAM J. Sci. Comput. 18, 5, 1393–1411. GOLUB, G. AND VAN LOAN, C. F. 1989. Matrix Computations. 2nd ed. Johns Hopkins University Press, Baltimore, MD. KENNEY, C., LAUB, A. J., AND WETTE, M. 1989. A stability-enhancing scaling procedure for Schur-Riccati solvers. Syst. Control Lett. 12, 3 (Apr. 1989), 241–250. LANCASTER, P. AND RODMAN, L. 1995. The Algebraic Riccati Equation. Oxford University Press, Oxford, UK. LAUB, A. 1979. A Schur method for solving algebraic Riccati equations. IEEE Trans. Automat. Contr. AC-24, 6 (Dec.), 913–921. LAWSON, C. L., HANSON, R. J., KINCAID, D. R., AND KROGH, F. T. 1979. Basic linear algebra subprograms for Fortran usage. ACM Trans. Math. Softw. 5, 3, 308 –323. PAIGE, C. AND VAN LOAN, C. 1976. A Schur decomposition for Hamiltonian matrices. Linear Alg. Appl. 14, 11–32. PANDEY, P. 1993. On scaling an algebraic Ricatti equation. In Proceedings of the American Control Conference (San Francisco, CA, June), 1583–1587. PARLETT, B. N. AND LE, J. 1993. Forward instability of tridiagonal QR. SIAM J. Matrix Anal. Appl. 14, 1 (Jan. 1993), 279 –316. PARLETT, B. AND REINSCH, C. 1969. Balancing a matrix for calculation of eigenvalues and eigenvectors. Numer. Math. 13, 296 –304. PATEL, R. V., LIN, Z., AND MISRA, P. 1994. Computation of stable invariant subspaces of Hamiltonian matrices. SIAM J. Matrix Anal. Appl. 15, 1 (Jan. 1994), 284 –298. PETKOV, P., CHRISTOV, N. D., AND KONSTANTINOV, M. M. 1987. On the numerical properties of the Schur approach for solving the matrix Riccati equation. Syst. Control Lett. 9, 3 (Sept. 1, 1987), 197–201. ACM Transactions on Mathematical Software, Vol. 26, No. 1, March 2000.
Algorithm 800: Computing the Eigenvalues of Hamiltonian Matrices I
•
77
RAINES, A. AND WATKINS, D. 1994. A class of Hamiltonian-symplectic methods for solving the algebraic Riccati equation. Linear Alg. Appl. 205/206, 1045–1060. SIMA, V. 1992. Algorithm GRICSR: Solving continuous-time algebraic Ricatti equations using Gaussian symplectic transformations. Stud. Inf. Control 1, 1, 237–254. SMITH, B. T., BOYLE, J. M., DONGARRA, J. J., GARBOW, B. S., IKEBE, Y., KLEMA, V. C., AND MOLER, C. B. 1976. Matrix Eigensystem Routines: EISPACK Guide. 2nd Springer Lecture Notes in Computer Science, vol. 6. Springer-Verlag, New York, NY. SREEDHAR, J., VAN DOOREN, P., AND TITS, A. 1995a. A fast algorithm to compute the real structured stability radius. In Stability Theory. Proceedings of the Hurwitz Centenary Conference (Ticino, May 21–26), Birkhäuser, Basel, 219 –230. Int. Ser. Numer. Math. 121. SREEDHAR, J., VAN DOOREN, P., AND TITS, A. 1995b. A level-set idea to compute the real Hurwitz-stability radius. In Proceedings of the 34th IEEE Conference on Decision and Control (New Orleans, LA, Dec. 13–15), IEEE Press, Piscataway, NJ, WA05. VAN LOAN, C. 1984. A symplectic method for approximating all the eigenvalues of a Hamiltonian matrix. Linear Alg. Appl. 61, 233–251. WILKINSON, J. H., Ed. 1988. The Algebraic Eigenvalue Problem. Oxford University Press, Inc., New York, NY. XU, H. 1993. Solving algebraic Riccati equations via Skew-Hamiltonian matrices. Ph.D. Dissertation. Institute of Mathematics, Fudan University, Shanghai, People’s Republic of China. XU, H. AND LU, L. 1995. Properties of a quadratic matrix equation and the solution of the continuous-time algebraic Riccati equation. Linear Alg. Appl. 222, 127–145. Received: August 1996;
revised: September 1998;
accepted: November 1999
ACM Transactions on Mathematical Software, Vol. 26, No. 1, March 2000.