Eigenvectors of Real and Complex Matrices by LR and QR Triangularizations

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 24

Numer. Math.

16, t8t --204 (1970)


© by Springer-Verlag t970

Handbook Series Linear Algebra

Eigenvectors o f Real and Complex Matrices


by L R and Q R triangularizations*
Contributed by
G. PETERS and J. H. WILKINSON

1. Theoretical Background
In a recent paper [4] the triangularization of complex Hessenberg matrices
using the L R algorithm was described. Denoting the Hessenberg matrix b y H
and the final triangular matrix b y T we have

p-1H p = T, (~)

where P is the product of all the transformation matrices used in the execution
of the L R algorithm. In practice H will almost invariably have been derived
from a general complex matrix A using the procedure eomhes [3] and hence for
some nonsingular S we have
P-1S-1A SP = T. (2)

The eigenvalues of A lie along the diagonal of T and we may write t¢~----2~;
the ordering of the 2~ is, in general, of an arbitrary nature. The eigenvector x i
of T corresponding to 2~ is given by

xi~=o ( i = i + t ..... n)
x. = t (3)
- ti~xk (~i--23 ( i = i - 1 ..... t)
Xii ~ k 1

and the corresponding eigenvector of A is S P x~. If the product S P of all the


transformations is retained this provides a method of computing the eigenvectors
of A. This technique was first used on the computer ACE at the National Physical
Laboratory and provides the most efficient program known to us when the com-
plete eigensystem is required.
* Editor's Note. In this fascicle, prepublication of algorithms from the Linear
Algebra Series of the Handbook for Automatic Computation is continued. Algorithms
are published in ALGOL60 reference language as approved by the IFIP. Contributions
in this series should by styled after the most recently published ones.
t3 Numer. Math., Bd. t6
182 H a n d b o o k Series L i n e a r A l g e b r a :

Analogous procedures may be used in connexion with the Francis Q R algorithm


for real Hessenberg matrices [2, 81. A program based on this algorithm was also
used on the computer, ACE and a sophisticated version has been produced by
Parlett; more recently Dekker has produced an ALGOL procedure [I 1 for the case
when the eigenvalues are real and plans one for the complex case.
The final matrix produced by the Q R algorithm given in [53 is not, in general
strictly triangular but may contain 2 × 2 blocks on the diagonal. Each 2 × 2 block
corresponds either to a real pair of eigenvalues or a complex conjugate pair.
For a 2 × 2 block in rows and columns r and r + 1 corresponding to a real pair,
true triangular form can be established by a similarity transformation involving
a real rotation in the (r, r + t) plane. True triangular form cannot be established
for 2 × 2 blocks corresponding to complex conjugate eigenvalues without moving
into the complex field.
However, the eigenvectors can still be determined b y a simple back sub-
stitution process. For a real eigenvalue 2~ the components of the vector x i are
given by the Eqs. (3) except that corresponding to a 2 × 2 block in row/" and/" -- I
the two components x i i and xi_l, i are given by

(ti-1, i-1 -- hi) xi-1, ~+ ti-1, i xi ~ = - - ~' ti-1 k xk i,


k=i+1 '
(4)
ti, i_ 1Xj_L¢ -{- ( t j i - - ~ ) x j i = - - ~, t j , xki.
k=/+x

This is a 2 × 2 system of equations with real coefficients and right hand side.
For a complex conjugate pair we need determine only the vector corresponding
to the eigenvalue with positive imaginary part, since the other vector is merely
the complex conjugate. Taking x~ to be l + 0 i the component xi_l, ~ satisfies
the equations
(ti-1, i-1 hi) Xi-1, i -~- ti-1, i ~- 0
- -

(5)
ti, i-~ xi-~, ~+ (tii - - ~i) = 0

and may be determined using the equation with the " l a r g e r " coefficients (for
the more stable determination). The remaining components are given b y Eqs. (3)
and (4) though it should be appreciated that the diagonal coefficients are now
complex.
Again in practice the real Hessenberg form H will usually have been derived
from a full matrix, A, using one of the three procedures elmhes, dirhes or orthes.
If the product S of the transformations involved in the reduction to Hessenberg
form is derived before starting the Q R algorithm, this m a y then be multiplied
by the matrices involved in the Q R quasi-triangularization. The eigenvectors of
A can then be found from those for the quasi-triangular matrix.

2. Applicability
comlr2 may be used to find all the eigenvalues and eigenvectors of a complex
matrix A which has been reduced to Hessenberg form H by procedure comhes.
When only a few selected eigenvectors are required it is more efficient to use
comlr [41 and complex inverse iteration with the matrix H.
Eigenvectors of Real and Complex Matrices. G. Peters and J. H. Wilkinson 183

hqr2 may be used to find all the eigenvalues and eigenvectors (real and/or
complex) of a real matrix A which has been reduced to real Hessenberg form H
by procedures elmhes, dirhes or orthes. Before entering hqr2 the product of the
matrices reducing A to H must be determined using elmtrans, dirtrans or ortrans
respectively. If the latter is used then at the point in the procedure hqr2 when
the Q R reduction is complete, the orthogonal matrix X which reduces A to real
quasi-triangular form is available. This matrix is sometimes a requirement in
its own right and the procedure may be modified in the obvious way to provide
X as an output.
The recommended program for dealing with a general complex matrix A is
first to balance it using a complex variant of the procedure balance [6], then
to reduce it to a complex Hessenberg matrix H by procedure comhes [3] and then
use comIr2 to find the eigenvalues and eigenvectors of the balanced A. The
eigenvectors of the original matrix A can then be recovered by the complex
analogue of procedure balbak E6].
The recommended program for dealing with a general real matrix A is first
to balance it using procedure balance [6], then to reduce it to real Hessenberg
form by procedures elmhes, dirhes or orthes [3]. The transformation matrix is
then derived using elmtrans, dirtrans or ortrans and the eigenvalues and eigen-
vectors of the balanced A are found by entering hqr2. The eigenvectors of the
original A can then be recovered by using balbak [6].

3. Formal Parameter List


3.t. Input to procedure comtr2
n the order of the complex Hessenberg matrix H.
low, upp two integers produced by the complex analogue of balance [6J. If
balancing has not been used then set low = t, upp = n. The Hessen-
berg matrix is effectively upper-triangular as far as its rows t to
low -- t and rows upp + t to n are concerned, so that low -- 1 + n -- upp
eigenvalues are already isolated.
macheps the smallest number on the computer for which t + macheps > t.
int an n × 1 integer array produced by comhes. If the primary matrix is
already of Hessenberg form then set int Ei] = i.
hr, hi two n X n arrays, hr giving the matrix of real parts of H and hi the
matrix of imaginary parts stored in the relevant locations. The re-
maining locations of hr and hi store the real and imaginary parts of
the multipliers used in comhes. The latter procedure provides an hr
and hi in the required form. If the primary matrix is already of
Hessenberg form the remaining locations of hr and hi must be set
to zero.
Output from procedure comlr9
hr, hi the strict upper triangles of these two n × n arrays contain the com-
ponents of the eigenvectors of the triangular matrix produced b y the
L R algorithm.
wr, wi two n × t arrays giving the real and imaginary parts of the eigen-
values.
t3"
J 84 Handbook Series Linear Algebra :

wr, vi two n × n arrays giving the real and imaginary parts of un-normMized
eigenvectors of the original full matrix used as input to comhes.
exit used if more than 30 iterations are used to find any one eigen-
value.

3.2. Input to procedure elmtrans


n order of the Hessenberg matrix H.
low, upp integers produced by procedure balance if used. Otherwise low = t,
upp = n.
int an n × t integer array produced by elmhes
h an n × n array produced by elmhes containing the Hessenberg matrix
H and the multipliers used in producing it from the general matrix A.
Output from procedure elmtrans
v the n × n array defining the similarity reduction from A to H.
Input and output parameters for dirtrans are identical to those for elmtrans
though the procedures are not identical.
Input to procedure ortrans
n order of the Hessenberg matrix H.
low, upp integers produced by procedure balance if used. Otherwise low = t,
u p p = n.
d an n × t array produced by orthes giving information on the ortho-
gonal reduction from A to H.
h an n × n array produced by orthes giving the upper Hessenberg
matrix H and the remaining information on the orthogonal reduction.
Output from procedure ortrans
d the input array is destroyed by the procedure
v an n × n array defining the similarity reduction from A to H.

3.3- Input to procedure hqr9


n order of the Hessenberg matrix H.
low, upp integers produced by balance if used. Otherwise low = t, upp = n.
macheps the smallest number on the computer for which 1 +macheps > 1.
h an n × n array containing the matrix H in the relevant part.
vecs an n X n array containing the matrix defining the similarity trans-
formation from A to H. (This is produced b y elmtrans, dirtrans or
ortrans). If H is the primary matrix then vecs must be set to the
identity matrix.
Output from procedure hqr9
h the upper part of this n × n array contains the eigenvectors of the
quasi-triangular matrix produced b y the Q R algorithm.
wr, wi two n X t arrays giving the real and imaginary parts of the eigen-
values.
Eigenvectors of Real and Complex Matrices. G. Peters and J. H. Wilkinson t85

~t an n × 1 integer array giving the number of iterations for the eigen-


values. If two eigenvalues are found simultaneously as a pair, then
the number of iterations is given with a positive sign for the first
and a negative sign for the second.
UeCS an n × n array giving the unnormalized eigenvectors of the original
full matrix A (unless H was the primary matrix). If the i-th eigen-
value is real the i-th column of vecs is the corresponding real eigen-
vector. If eigenvalues i and i + t are a complex pair the columns i
and i + 1 give the real and imaginary part of the eigenvector cor-
responding to the eigenvalue with positive imaginary part.
exit used when 30 iterations fail to isolate the current eigenvalue.

4. ALGOL Programs
p r o c e d u r e comlr2 (n) data: (low, upp, macheps, in~) trans: (hr, hi)
result: (wr, wi, vr, vi) exit: (/ail);
value n, low, upp, macheps ;
integer n, low, upp ;
real macheps ;
array hr, hi, wr, wi, vr, vi ;
i n t e g e r a r r a y int;
label/ai/;
c o m m e n t Finds the eigenvalues and eigenvectors of a complex matrix which has
been reduced b y procedure comhes to upper Hessenberg form, H,
stored in the arrays hr[l:n, l : n ] and h i l t : n , t : n ] . The real and
imaginary parts of the eigenvalues are formed in the arrays wr [t :n]
and wi [t :n] respectively and the un-normalised eigenvectors are
formed as columns of the arrays vr[l :n, 1 :hi and vii1 :n, t :hi. low
and upp are two integers produced in balancing where eigenvalues
are isolated in positions t to l o w - 1 and upp + l to n. If balancing
is not used low = 1, upp = n . macheps is the relative machine pre-
cision. The procedure fails if any eigenvalue takes more than 30 itera-
tions. The procedures cdiv and csqrt are used, see [31;
begin
integer i, i, k, m, its, en ;
real sr, si, tr, ti, xr, xi, yr, yi, zr, zi, norm;
tr:=ti:=O;
for i :-----I step t until n d o
begin
f o r / : = I s t e p t until n do vrEi, j] : = viii, j] : = 0;
vr Ei, i] : = 1
end i;
for i : = upp -- 1 step - - I until low + t do
begin
i : = int Ell ;
t 86 H a n d b o o k Series Linear Algebra:

for k : = i + t step I until upp do


begin
vr [k, i] : -~ hr [k, i - - 1] ; vi [k, i] : = hi [k, i - - t ]
end k;
if i =~ i then
begin
for k : = i step t until u p p do
begin
vr [i, k] :---- vr [1", k] ; v i [ i , k] :-~ vi [/', k] ;
vr [1", k ] : -~ vi [I', k] : = 0
end k;
vr ~', i] := 1
end i :~i
end i;
for i : = 1 step I until low - - 1, upp + t step I until n do
begin
w r [i] :---- hr [i, i] ; w i [i] : = hi [i, i]
end isolated roots;
en : = upp ;
n extw :
if en < low t h e n g o t o / i n ;
its : = 0;
comment look for single small sub-diagonal e l e m e n t ;
nextit:
for k := en s t e p - - t until low + 1 do
if abs (hr [k, k - - t]) + abs (hi [k, k - - t]) --< m a c h e p s X (abs (hr [k - - t, k - - t ]) +
abs (hi [k - - i, k - - 1 ]) + abs (hr [k, k]) + abs (hi [k, k])) t h e n g o t o conS1;
k : = low;
conS1:
if k = en t h e n g o t o root;
i f its = 3 0 t h e n g o t o / a i l ;
c o m m e n t f o r m shift;
if its = 10 v its = 20 then
begin
sr : = abs (hr [en, en - - 1 ]) + abs (hr [en - - 1, en - - 2]) ;
si : = abs (hi [en, en - - t ]) + abs (hi [en - - t , en - - 2])
end
else
begin
sr : = hr [en, en] ; si : = hi [en, en] ;
x r : = hr [en - - 1, en ] × hr [en, en - - t] - - hi [en - - 1, en ] x hi [en, en - - t ] ;
x i : = hr [en - - t , en] x h i [en, en - - l ] + hi [en - - t , en] x h r [en, e n - - l ] ;
if x r 4 : O v x i 4 = O then
begin
y r : = (hr [en - - t , en - - 1 ] - - sr)/2; y i : -=- (hi [en - - 1, en - - t] - - si)/2;
c s q r t ( y r t 2 - - y i t 2 + xr, 2 X y r × y i + xi, zr, zi) ;
if y r X zr + y i × z i < 0 then
Eigenvectors of Real and Complex Matrices. G. Peters and J. H. Wilkinson 187

begin
zr:= --zr; zi:= --zi
end;
ediv (xr, xi, y r + zr, y i + zi, xr, xi) ;
sr : = sr - - xr; si : = si - - x i
end
end;
f o r i :---- low s t e p t until en d o
begin
hr[i, i] : = hr[i, i] - - s r ; h i l l , i] : = hi[i, i] - - s i
end i;
tr:=tr+sr; ti:=ti+si; its:=its+l; j:=k+t;
c o m m e n t look for two consecutive small sub-diagonal elements;
x r : = abs (hr [en - - t , en - - 1 ]) + abs (hi [en - - t , en - - t ]) ;
y r :-= abs (hr ~en, en -- t ]) + abs (hi [en, en - - 1 ]) ;
zr : = abs (hr [en, en]) + abs (hi [en, en]) ;
form:= en--I step --t until/' do
begin
y i : = y r ; y r : = abs (hr [m, m - - l ] ) + abs (hi [m, m - - 1 3 ) ;
xi : = zr ; zr : = xr ;
xr : = abs (hr [m - - t , m - - t 3 ) + abs (hi [m - - l, m - - t]);
if y r <= macheps × zr[yi × (zr -~- xr + xi) t h e n g o t o cont2
end m;
m:=k;
corn m e n t triangular decomposition H = L × R;
cont2 :
fori:----m+l stepl untilendo
begin
xr:= hr[i--l, i--t~; xi:= hi[i--l, i--1];
y r : - = hr[i, i - - 1 ] ; y i : - ~ h i , i , i - - ! ~ ;
if abs (xr) + abs (xi) < abs (yr) + abs (yi) then
begin
c o m m e n t interchange rows of hr and hi;
for i : = i -- 1 step I until n do
begin
z r : = h r [ i - - l , i]; h r [ i - - L i] : = h r [ i , i ] ; h r [ i , i ] : = z r ;
zi : - - hi [i - - t, i~; hi [i - - 1, i~ : = hi [i, i3; hi Ei, i] : = z,i
end i;
cdiv (xr, xi, y r , y i , zr, zi) ; wr [i] : = 1
end
else
begin
cdiv (yr, y i , xr, xi, zr, zi) ; wr Eli : = - - 1
end ;
hr [i, i - - 1 ] : = zr; hi [i, i - - t ] : = zi;
for ~": : i step I until n do
188 Handbook SefiesLinear Algebra:

begin
hrEi, i] : = hr~i, it --zr×hr~i--t, i] + zi × h i Ei--t, i1;
hi[i, i] : = hi[i, i] - - z r x h i [ i - - t , i] - - z i x h r [ i - - 1 , i ]
end i
end i;
comment composition R × L = H ;
for i : = m + t step J until en do
begin
xr:=hr[j,i--J]; xi:=hi[i,i--J]; hr[i,i--J~:=hi[j,i--J]:=O;
c o m m e n t interchange columns of hr, hi, vr, and vi, if necessary;
if wr [3"1> 0 t h e n
begin
for i : = J step J until i do
begin
z r : = hr[i, i - - t l ; h r [ i , i - - J ] :-~ hr[i, ?1; hr[i,i] : = zr;
zi : = hill, i - - J ] ; hill, i - - J ] := hi[i, i]; hill,/'] : = zi
end;
for i : = / o w step t until ,epp do
begin
zr : = vr[i, i - 1 ] ; vrEi, i - J ] : = vr~i, i ] ; vrEi, i] : = zr;
zi : = viii, i - l ] ; viii, i - J ] : = viEi, i]; viii, iJ : = zi
end
end interchange columns;
for i : = J step i until i do
begin
hr[i, i - - J ] : = hr[i, i - - J ] + xr×hr[i, i] -- xi ×hi[i, i];
hi[i, i - - J ] :---- hi[i, i - - t ] + xr×hi[i, i] + xi×hr[i, i]
end i;
for i : = low s t e p J until upp d o
begin
vr[i, i - - J ] : = vr[i, i - - J ] + xr×vrEi, i] -- xi×vi[i, i];
viii, i - - J ] : = vi[i, i - - t ] + x r × v i [i, i] + xi xvr[i, i]
end accumulate trans/ormations
end i;
goto nextit;
c o m m e n t a root found;
root:
wr [en~ : = hr [en, en] + tr ; wi Een] : = hi [en, en] + ti ; en : = en -- J ;
g o t o nextw ;
c o m m e n t all roots found;
/in:
norm : = 0.0;
for i : = J step t until n do
begin
norm: = norm + abs (wr [i]) + abs (wi [ij);
Eigenvectors of Real and Complex Matrices. G, Peters and J. H. Wilkinson 189

f o r / ' : = i + t step t until n do


norm : -~ norm + abs (hr [i, i]) + abs (hi [i, j])
end;
c o m m e n t Backsubstitute to find vectors of upper triangular form;
for e n : = n step --1 until 2 do
begin
xr : = wr [en~ ; xi : = wi Een] ;
for i : = e n - - 1 step -- t until I do
begin
zr : = hr [i, enj ; zi : = hi [i, en3 ;
for/:=i+l step I until e n - - t do
begin
zr : = zr + hr [i, i] × hr ~1",en ] - - h i l l , i~ ×hill', en ] ;
zi : = zi + hr [i, i] × h i [ i , en ~ + h i l l , i] × hr [l', enl
end;
y r : = xr -- wr EiJ ; y i : = xi - w i [i] ;
if y r -= o.o ^ y i = 0.0 t h e n y r : = macheps × n o r m ;
cdiv (zr, zi, yr, yi, hr [i, enl, hi [i, en])
end
e n d backsub ;
c o m m e n t multiply b y transformation matrix to give vectors of original full
matrix;
for i : = I s t e p I until l o w - - t , u p p + l s t e p t until n d o
for i : = i + 1 step t until n do
begin
vr [i, il : = hr ~i, i] ; vi [i, i] : = hi ~i, i]
e n d vectors o/isolated roots;
for j" : : n step -- t until l o w do
for i : = low step t until upp do
begin
zr := vr El, il ; zi := vi[i, i] ;
m : = if u p p < i then u p p else i - - 1 ;
for k : = low s t e p t until m d o
begin
zr : = zr + vr [i, k] × hr [k, i] -- vi [i, kJ × hi [k, i~ ;
zi : = zi + vr [i, k] × hi [k, i] + vi[i, k~ × hr [k, i~
end;
vr[i, iJ : = zr; viEi, i~ : - - zi
end
e n d comlr2 ;
procedure elmtrans (n, low, upp) data: (int, h) result: (v) ;
value n, low, u p p ;
integer n, low, u p p ;
integer a r r a y int;
a r r a y h, v;
! 90 Handbook Series Linear Algebra:

c o m m e n t form the matrix of accumulated transformations in the a r r a y v [1 :n,


t : n ] from the information left b y procedure elmhes below the upper
Hessenberg matrix, H, in the a r r a y h [1 :n, i : n] and in the integer
a r r a y int [t : n] ;
begin
integer i, j, k;
for i : = t step I until n do
begin
for j :---- 1 step t until n do v ti, i] : = 0.0;
v [i, i] : = t.0
end i;
for i : ~ upp -- 1 s t e p - - 1 until low + 1 do
begin
j : = int Eli ;
for k : = i + 1 s t e p I until upp do vEk, i] : = hEk, i - - t ] ;
if i 4: J' then
begin
for k : = i s t e p I until upp do
begin
vEi, k] := v[j, k]; vii, k] : = 0.0
end k;
v [/', i] : = 1.o
end i + i
end i
end elmlrans ;
procedure dirtrans (n, low, upp) data: (int, h) result: (v) ;
value n, low, upp ;
integer n, low, upp ;
integer a r r a y int;
a r r a y h, v;
c o m m e n t form the m a t r i x of accumulated transformations in the a r r a y v [t :n,
t : n ] from the information left b y procedure dirhes below the upper
Hessenberg matrix, H , in the a r r a y h [t :n, 1 :n] and in the integer
a r r a y int [1 : n] ;
begin
integer i, i, m; real x;
for i : = t step t until n do
begin
for/':= 1 step t until n do vEi, i] : = 0.0;
v [i, i] : = t.0
end i;
for i :---- upp s t e p -- 1 u n t i l low + t do
begin
for j :=10w + l s t e p l u n t i l i - - I do v [i, i] : = h Ei, i - - t ] ;
m : = int [i] ;
Eigenvectors of Real and Complex Matrices. G. Peters and J. H. Wilkinson 19t

if m 4= i then
for/" : = low + t step I until upp do
begin
x : = v ~ m , i ] ; v[m, i l : = v [ i , i ] ; v [ i , i ] : = x
end m ~ i
end i
end dirtrans ;
p r o c e d u r e ortrans (n, low, upp) data: (h) trans : (d) result: (v) ;
v o t u e n, low, upp ;
i n t e g e r n, low, upp ;
o r r o y h, d, v;
c o m m e n t form the m a t r i x of a c c u m u l a t e d t r a n s f o r m a t i o n s in the a r r a y v [1 :n,
t : n ] from the i n f o r m a t i o n left b y p r o c e d u r e orthes below the u p p e r
H e s s e n b e r g m a t r i x , H, in t h e a r r a y hE1 :n, 1 :n] and in the a r r a y
d [1 : nl. The c o n t e n t s of the l a t t e r are d e s t r o y e d ;
begin
integer i, i, k, m; real x, y ;
for i : = 1 step t until n do
begin
for ?':---- 1 step I until n do vEi, jj : = 0.0;
v [i, i] : = 1.0
end i;
for k : = upp--2 step --1 until low do
begin
m:=k+l; y:=h[m,k];
if y = 0.0 then goto skip ;
y : = y×d[m];
for i:---- k + 2 step I until upp d o d[il : = h[i, k];
for j : = m step I until upp do
begin
x : = 0.0;
for i : = m s t e p t u n t i l upp d o
x : = x +d[i] ×vii, i];
x:---- x/y;
for i : = m step t until upp do
v [ i , i ] : = v El, i ] + x × d Ell
end j;
skip:
end k
end ortrans ;
procedure hqr2(n, low, upp, macheps) trans: (h, vecs) result: (wr, wi, cnt)
exit: (tail) ;
v a l u e n, low, upp, macheps;
integer n, low, upp ;
recti macheps ;
192 Handbook Series Linear Algebra:

array h, vecs, wr, wi ;


integer array cnt;
label ~all;
c o m m e n t Finds the eigenvalues a n d eigenvectors of a real matrix which has
been reduced to upper Hessenberg form in the array h [I : n, t : n] with
the accumulated transformations stored in the array vecs [t :n, 1 :n].
The real and imaginary parts of the eigenvalues are formed in the
arrays wr, wiEl :n] and the eigenvectors are formed in the a r r a y
vecs [l : n, 1 : d] where only one complex vector, corresponding to the
root with positive imaginary part, is formed for a complex pair. low
and up# are two integers produced in balancing where eigenvalues
are isolated in positions t to l o w - 1 and u p p + 1 to n. If balancing
is not used low -~ 1, u p p = n. macheps is the relative machine precision.
The procedure fails if a n y eigenvalue takes more t h a n 30 iterations.
The non-local procedure cdiv is used, see [3];
begin
integer i, i, k, l, m, ha, its, en ;
real p, q, r, s, t, w, x, y, z, ra, sa, vr, vi, norm;
Boolean notlast ;
for i :-----t s t e p t until low -- t, u p p + 1 s t e p t until n do
begin
wr[i~ : = h[i, i]; w i l l ] : = 0.0; cnt[i] : = 0
end isolated roots;
en:=upp; t : = 0.0;
ne xtw :
if e n < l o w t h e n g o t o / i n ;
its:=O; na:=en--t;
c o m m e n t look for single small sub-diagonal element;
ne xtit :
for l : = en s t e p - - 1 until low + t d o
if abs (h [1, l - - t 1) ~ m a c h e p s × (abs (h El--1, t - - t 1) + a b s (h [l, lJ) ) t h e n g o t o contl ;
l : = low;
cont l :
x : = h [en, en] ; if l = en t h e n g o t o onew;
y : = h [na, naJ ; w : = h [en, na] × h Ena, en] ; if l = na t h e n g o t o twow;
if its = 30 then
begin
cnt[en] : = 31 ; g o t o ~all
end;
if its ~- 10 v its = 20 t h e n
b e g i n c o m m e n t form exceptional shift;
t:=t+x;
for i : = low step t until e n d o h [i, iJ : = h [i, i] -- x;
s : = abs(h[e, na]) + a b s ( h [ n a , en - - 2 ] ) ; x : = y : = 0.75 × s ;
w : = --0.4375 XSl'2
end;
Eigenvectors of Real and Complex Matrices. G. Peters and J. H. Wilkinson 193

its := its + l ;
comment look for two consecutive small sub-diagonal elements;
for m :----- en -- 2 step -- 1 until l do
begin
z : = h [ m , m ] ; r : = x - - z ; s:---.y--z;
p : = (r ×s --w)/h [ r n + t , m] + h [m, m + t ] ; q : = h I r a + l , m + l ] - - z - - r - - s ;
r:= h[m+2, m+t];
s : = abs (p) + abs (q) + abs (r) ; [9 : = p[s; q : = q/s; r :-~ r/s;
if m = 1 t h e n g o t o cont2;
if abs(h [m, m - - t ] ) × (abs(q) + abs(r)) <=
macheps × abs (p ) × (abs (h Era-- t, m - - t ]) + abs (z) + abs (h [m + t, m + t ]))
then goto cont2
end m;
cont2 :
for i : = m + 2 step I until en do h[i, i - - 2 ] : = 0.0;
f o r i : = m + 3 s t e p t until en d o h [ i , i - - 3 ] : = 0.0;
c o m m e n t double QR step involving rows l to en and columns m to en of the
complete array;
for k : = m step t until n a do
begin
notlast : = k 4=na ;
if k 4= m then
begin
p:=h[k,k--t]; q:=hEk+t,k--t];
r : = ifnotlast t h e n h[k + 2 , k - - l ] else O;
x : = abs(p) +abs(q) +abs(r); if x = 0 t h e n g o t o cont3;
p := Plx; q : = q/x; r : = r/x
end;
s := sqrt(tt2 +qt2 +rt2);
ifp<o then s:= --s;
if k4=m then h[k, k - - t ] : = - - s × x
e l s e i f l : ~ m t h e n h[k, k - - l ] : = --h[k, k - - t ] ;
p : = p + s ; x:----p/s; y : = q / s ; z : = r / s ; q : = q / p ; r : = r / p ;
c o r n m e n t row modification;
for i : = k step t until n do
begin
p : = h[k, i] + q × h [ k + t , j];
if notlast then
begin
p:=p+rxh[k+2, i]; h [ k + 2 , i ] : = h ~ k + 2 , i ] - - P X z
end;
h E k + t , i] : = h E k + l , i] - - p x y ; h[k, i2 : = h[k, i] - - p x x
end i;
? ' : = if k + 3 < e n then k + 3 else en;
c o m m e n t column modification;
f o r i : = t s t e p t until j d o
t 94 H a n d b o o k Series L i n e a r Algebra :

begin
p : = x × h [ i , k] + y × h [ i , k + l ] ;
if notlast then
begin
p:=p+zxh[i,k+2]; h[i,k+2]:=h[i,k+2]--p×r
end;
h [ i , k + t ] : = h [ i , k + l ] - - p × q ; h[i,k]:=hEi, k]--p
end i;
comment a c c u m u l a t e t r a n s f o r m a t i o n s ;
for i : = low s t e p t until u p p d o
begin
p : = x × vecs [i, k] + y × vecs [i, k + t ] ;
if notlast then
begin
p : = p + z × vecs [i, k + 2] ; vecs [i, k + 2] : = vecs [i, k + 2] - - p × r
end;
vecs[i, k + t ] : = vecs[i, k + t ] --p xq;
vecs [i, k] : = vecs [i, k] -- p
end;
contS :
end k;
g o t o nextit;
c o m m e n t one r o o t f o u n d ;
onew:
wr [en ] : - - h [en, en ] : = x + t ; wi [en ] : = 0.0;
cnt[en] : = its; en : = ha; g o t o nextw;
comment two roots found;
twow:
p : = (y--x)~2; q : = p ~ 2 + W ; z : = sqrt(abs(q));
x : = h [ e n , e n ] : = x + t ; h[na, n a ] : = y + t ;
cnt [en] : = -- its; cnt [na] : = its;
if q > 0 then
begin c o m m e n t real p a i r ;
z : = i f p < o . o then p - - z else p + z ;
wr [na] : = x + z ; wr [en] : = s : = x - - w / z ; wi [na] : = wi [en] : = 0.0;
x : = h [en, ha] ; r : = sqrt (x~'2 + z t 2 ) ; p : - - x/r; q : ---- z/r;
for/" : = n a s t e p 1 until n d o
begin
z : = h[na, j ] ; h[na, i] : = q x z + p x h [ e n , j];
h [en, i] : = q x h [en, i] -- p x z
end row modi]ication ;
for i := t step 1 until en do
begin
z : = h[i, na]; h[i, na] : = q x x + p × h [ i , en];
h [i, en] : = q x h [i, en] -- p x z
end column modi]ication ;
for i : = low s t e p I until u p p d o
E i g e n v e c t o r s of R e a l and Complex Matrices. G. Peters and J. H. Wilkinson t95

begin
z : = vecs [i, naJ ; vecs El, hal : = q x z + p X vecs [i, en] ;
vecs [i, enl : = q × vecs Ei, enl -- p × z
e n d accumulate
e n d pair o~ real roots
else
begin comment complex pair;
wr [na] : = wr~en~ : = x + p ; wiEna~ : = z; wiEen] : = - - z
end two roots found;
en : = en - - 2 ; g o t o nextw;

comment all roots found, now backsubstitute;


li~:
n o r m : = 0.0; k : = l ;
for i : = t step I u n t i l n do
begin
for i : = k s t e p I until n d o norm : = norm + abs (h [i, j]) ;
k:-~i
e n d norm;
comment backsubstitution;
for en:= n step - - 1 u n t i l t do
begin
p : = wr [en~ ; q : = wi [en I ; na : = en -- t ;
if q = 0.0 t h e n
b e g i n c o m m e n t real vector;
m : = en; hEen, en~ : = 1.0;
f o r i : = na step - - t u n t i l t do
begin
w:=h[i,i]--p; r : = h [ i , en];
f o r j : = m step t until na d o r : = r + h [ i , i ] × h [ j , en];
if wi [i] < 0.0 t h e n
begin
Z : ~--~- ZPJ, s : ~ - - - r
end
else
begin
m:=i;
if wi Eli = 0.0 t h e n
h [i, en~ : = - - r / ( i f ~v 4=0.0 t h e n w e l s e macheps × n o r m )
else

begin comment solve [ y :][h[i'en]en~]=I~];[h[i+t,


x:=h[i,i+ll; y:=hEi+l, iJ;
q : = (wr[iJ - - p ) t 2 + w i E i ~ 2 ;
h~i, en] : = t : = ( x x s - - z × r ) / q ;
t 96 H a n d b o o k Series L i n e a r A l g e b r a :

h [i + t, en] : = if abs (x) > abs (z) t h e n ( - - r - - w ×Olx


e l s e ( - - s - - y ×t)/z
end wi Ei] > 0.0
end wi[i] ~_ 0.0
end i
end real vector
else
if q < 0.0 then
begin comment c o m p l e x v e c t o r associated with lambda = p - - i × q ;
t?~ 2~--- h a ,
i f abs (h Een, ha]) > abs (h [na, en]) t h e n
begin
h [na, ha] : = - - (h [en, en] - - p)/h [en, na];
h [na. en] : = --q/h [en, na]
end
else cdiv(--h[na, en], 0.0, h[na, ha] - - p , q, hEna, na], h[na, en]);
h [en, na] : = t . 0 ; h [en, en] : = 0.0;
f o r i : = na -- l s t e p - - t u n t i l t d o
begin
w : = h [i, i] -- p; ra : = h [i, en] ; sa : = 0.0;
f o r 1": = m s t e p I u n t i l na d o
begin
ra : = ra + h [i, /] × h ~l",ha];
sa : = sa + h [i, ]] × h 0", en]
end;
if wi Ill < 0.0 then
begin
Z:~W; r:~-~-ra; s : = s a
end
else
begin
m:=i;
if will] = 0 . 0 then cdiv(--ra, --sa, w, q, h[i, ha], h[i, en])
else
begin c o m m e n t solve c o m p l e x e q u a t i o n s

z+qxi [h[i+t,na]+h[i+t, en]xi I.- r - s x i 1"


x:=h[i,i+t], y:=h[i+l,i];
vr : -~ (urr [i1 - - p)~2 + wi [/]t'2 - - q~'2;
vi : = (wr [/] - p ) x 2 . o x e ;
i f vr = 0.0 ^ vi = 0.0 t h e n
vr : = macheps × norm
× (abs + abs (q) + abs (,) + abs (y) + abs (,)) ;
a t i v ( x × r - - z ×ra + q×sa, x × s - - z × s a - - q × r a , vr, vi,
h [i, ha], h [i, en]);
i f abs (x) > abs (z) + abs (q) t h e n
Eigenvectors of Real and Complex Matrices. G. Peters and J. H. Wilkinson t97

begin
h [i + t , ha] : = (--ra - - w ×h[i, na] + q × h [ i , en])/x;
h [ i + l , en] :-------( - - s a - - w ×h[i, en]--q ×h[i, na])/x
end
e l s e c d i v ( - - r - - y x h [i, na], - - s - - y x h [i, en], z, q,
h [i + t, na], h [i + t, en])
end w/[i] > 0.0
end wi ~i] >=0.0
end i
end complex vector
e n d backsubstitution ;
comment vectors of i s o l a t e d roots;
for i : = t step I until l o w - - t , upp + t step t until n do
for j : = i + I step t until n do vecs [i, ]1 : = h [i, ]J ;
comment m u l t i p l y b y t r a n s f o r m a t i o n m a t r i x to give vectors of original full
matrix;
f o r ? ' : = n step - - t until low do
begin
m :-----if 1"=< upp t h e n 1" e l s e upp; l : = I' - - 1 ;
if wi [/'] < 0.0 t h e n
begin
for i : = low step I until upp do
begin
y:=z:--o.o;
for k : = low step t until m do
begin
y : = y + vecs [i, k] x h [k, l] ; z : = z + vecs [i, k] × h [k, i]
end;
vecs [i, t] : = y ; vecs [i, i~ : = z
end i
end
else
if w/~'] = 0.0 then
for i : = low step t u n t i l upp do
begin
z : = 0.0;
f o r k :---- low s t e p t u n t i l m d o
z : = z + vecs Ei, k] X h rk, ~] ;
vecs [i, i] : = z
end i
end j
end hqr2;
t4 Numer. Math., Bd t6
t 98 Handbook Series Linear Algebra :

5. Organizational and Notational Details


The L R reduction proceeds essentially as in comlr [41, but since the resulting
triangular matrix is used to find the vectors, each transformation must operate
on the full n × n matrix even when the eigenvalues could be found from a number
of Hessenberg matrices of lower order. The procedure comlr2 first finds the trans-
formation matrix S used to reduce the original general matrix to Hessenberg
form (no multiplications are required) and then updates S as each L R iteration
is performed.
The eigenvector of the triangular matrix T corresponding to hi has zero
components in position i + 1 to n. Hence when deriving the corresponding eigen-
vector P xi of A we do not need the last n - - i columns of P. Accordingly if the
vectors are found in the order Px,, .... , Px2, P x l , each can be overwritten on
the corresponding column of P.
If h i =2~ (j < i) then a zero divisor occurs when computing xji from Eq. (3)-
Such a zero divisor is replaced by macheps × norm where
norm :- E E (I ~ (t~j)[ + I~(t.)l). (6)
When the equal eigenvalues correspond to linear divisors this ensures, even when
rounding errors are taken into account, that we obtain the requisite number of
independent eigenvectors. It should be appreciated that with exact computation
the numerator of the expression for xji would also be zero.
When the equal eigenvalues correspond to a non-linear divisor, the numerator
of the expression for xi~ will be non-zero, even with exact computation. If we
were to replace the h i -- E~ by an infinitesimally small quantity we would effective-
ly obtain an infinite multiple of the eigenvector corresponding to ~j, i.e. after
normalization we would merely obtain the same vectors from $i and ~j. In practice
the solution is complicated by the fact that if rounding errors have occurred the
computed E~ and h i will not be equal; in fact since eigenvalues corresponding to
non-linear divisors are very sensitive the computed values will usually differ
quite substantially.
Corresponding to a quadratic divisor we will usually find that the computed
v~ and vi make an angle with each other of the order of magnitude of 2 -t/2 (for
a machine with a t-digit binary mantissa) and v ~ - vi will give an approximation
to a vector of second grade. Similar remarks apply for divisors of higher degree.
Two code procedures cdiv and csqrt [31 are used.
Again hqr2 follows roughly the same lines as hqr [SJ but before entry, the
matrix S of the transformation reducing the original A to Hessenberg form must
be produced using elmtrans, dirtrans or ortrans corresponding to the use of elmhes,
dirhes or orthes in the reduction. If the primary matrix is itself upper-Hessenberg
then hqr2 must be provided with the identity matrix in lieu of this transformation
matrix. As each Q R iteration is performed S is updated. After isolating a pair
of real eigenvalues in rows r and r + 1 a rotation is performed in plane (r, r + t),
the angle being chosen to make h,+l, , equal to zero.
There is an additional feature in hqr2 which should also be included in hqr.
This is designed to overcome a shortcoming in the latter. The first step of pro-
cedure hqr is to determine the three non-zero elements of the first column of
(H - - k l I ) (H --k2I ) where k1 and k S are the shifts. The formulae for these elements
Eigenvectors of Real and Complex Matrices. G. Peters and J. H. Wilkinson t99

are better transformed according to the equations

= h21 [(hnn -- h l l ) (hn-1, n - 1 - - h l l ) - - hn, n,lhn-l,n/h21 21- h i 2 ]


(7)
h~l(h~ - - ks + h ~ - - k~) = h ~ ( h ~ - - hl~ - - ( h . ~ - - h ~ ) - - ( h ~ _ l , . _ ~ - - hl~))

and since only the ratios are of interest, the factor h~l can be omitted. That
this formulation is superior to that used in hqr is evident if we consider the
tridiagonal matrix defined b y
hii=l, hi+l,i=hi, i+l=e. (8)

If e~ is smaller than macheps the old formulation gave the values e~, O, e 2 instead
of O, O, e 2. This does not harm the eigenvalues but convergence is jeopardized.
As an additional precaution after ten iterations have been performed without
locating an eigenvalue H is replaced b y H - - h . . I before starting the double-
Francis step.
Similar considerations arise when computing the vectors of the quasi-triangular
matrix T to those discussed in connexion with comlr2. Corresponding to a complex
pair of eigenvalues only one eigenvector is determined (that corresponding to the
eigenvalue with positive imaginary part) and the real and imaginary parts of the
vector are stored as two columns of the eigenvector array.

6. Discussion of Numerical Properties


As far as the L R and Q R reductions are concerned the remarks given for
comlr [4] and hqr [5] apply without modification. The computed vectors should
give very small residuals even when, as a result of sensitivity, the values and
vectors are fairly inaccurate. This is because the algorithms guarantee that each
computed vector and value is exact for a matrix which is very close to the original
matrix.
7. Test Results
The two algorithms were used on K D F (39 binary digit mantissa) to find the
eigenvalues and eigenvectors of a number of test matrices. Most of the test
matrices are of Hessenberg form so as to provide tests of comlr2 and hqr2 which
are independent of other procedures. Procedures which are not essentially different
from these have been used over a very long period at the National Physical
Laboratory, often on matrices of quite high order and have given consistently
good results.
7.1. Tests on comlr2
The matrix of Table 1 has a well-conditioned eigenvalue problem and has
simple eigenvalues; it provides a straightforward test of the algorithm. Results
obtained on other computers should agree with the quoted results to within
machine accuracy. The eigenvectors in this and later examples are normalized
for convenience. The published procedures do not include normalization because
usually the vectors will be transformed to give the vectors corresponding to the
full matrix from which the Hessenberg form was derived. The residuals cor-
responding to the normalised vectors are all less than 10 -1°.
14"
200 Handbook Series Linear Algebra:

Table I
Real part of matrix Imaginary part of matrix

Eigenvalues
Real parts Imaginary parts

+ 3.4250 6739 8201o-- 1 --2.2078 0890 0981o+0


--2.3101 41239721o+0 +2.596603066641o+0
+2.7313 9648 76210+0 +2.3407 2215 071104 0
+ 5.2362 380t 229104 0 44.2704 8368 366xo40

Eigenvectors
vI real v1 imaginary v2 real v2 imaginary

--9.5653 53779241o--t --1.015623547881o--2 +4.268728442421o--1 --1.775t 785656010--2


+t.000000000001o+0 +0.00000000000 --4.794798184651o--1 --t.85364426t921o--I
--4.307448338061o--t +3.921255974161o--I --8.025859936611o--1 +9.9797265073910--2
--1.645723779051o--1 --4.2691 85379431o--1 +t.000000000001o+0 +0.00000000000

va real v0 imaginary v4 real v4 imaginary

+1.000000000001o+0 +0.00000000000 +2.8381 76396941o--1 +1.788t 131648110--2


+4.622202950551o--1 +1.64t146134731o--1 +5.542444819081o--t --9.6903837646310--2
--2.968280886000o--I --5.6928852404710--2 +t.000000000001o+0 +0.00000000000
--4.6944732480ho--1 --4.8t71 50357081o--t +9.3t2670519671o--t --4.3236379572210--2

The m a t r i x of Table 2 has linear divisors b u t one double eigenvalue. Two


i n d e p e n d e n t eigenvectors are given corresponding to t h e double root. T h e pro-
cedure can be used with low = t, upp = 3 or w i t h low----2, upp----3 and gives
identical results for the two cases. All results were exact.

Table 2
Real part of matrix Imaginary part of matrix Eigenvalues

0 1 1+i
--I o 2+i

Eigenveaovs
vl v2 vs

t+0i 0 t+oi
O l+oi 0.5--0.5/
O 0.5+0/ O.5--O.5i
Eigenvectors of Real and Complex Matrices. G. Peters and J. H. Wilkinson 20t

T h e m a t r i x of T a b l e 3 h a s t w o pairs of q u a d r a t i c divisors. T h e e i g e n v a l u e s
h a v e a b o u t h a l f t h e figures c o r r e c t , as is to b e e x p e c t e d . T h e e i g e n v e c t o r s cor-
r e s p o n d i n g to e q u a l e i g e n v a l u e s a g r e e to a b o u t half t h e w o r d - l e n g t h . T h e dif-
ference b e t w e e n t w o s u c h v e c t o r s w h e n c o r r e s p o n d i n g l y n o r m a l i s e d is a v e c t o r
of g r a d e two, a c c u r a t e to a b o u t half t h e w o r d l e n g t h . T h i s is well i l l u s t r a t e d in
t h e t a b l e b y t h e difference g1 - - g 2, T h e m a x i m u m r e s i d u a l is 4 x 1 0 - n in s p i t e
of errors of t 0 -6 in t h e results.

Table 3
Real part of matrix Imaginary part of matrix

o o o o
1 o o o
1 o

Eigenvalues
Real parts Imaginary parts

-- 1.0000 Ol 19 39710+ 0 -- 1.0000 0037 29910+0


-- 9.9999 8806 0281o-- 1 -- 9.9999 9627 0001o-- t
-- 1.00000165 02810+0 -- 1.9I 51 4 7 7 2 8 7 2 1 0 - - 6
--9.9999 8349 7221o-- t + 1.915I 3879 5471o--6

EigBnvgclor$
v1 reM vI imaginary v2 real va imaginary

+ t.O000 00000001o + 0 + 0.0000 0000 000 + 1.0000 0000 0001o + 0 + 0.0000 0000 000
-- 4.999998t 3 5071o-- t + 4.99999403 O191o-- t -- 5.00000186 5011o-- 1 + 5.00000596 9891o-- 1
+4.t049t0157281o--7 --4.999992165231o--1 --4.104861729281o--7 --5.00000783488Io--t
-[-2.499991045231o--1 +2.499997202601o--1 +2.50000895480,o--1 +2.500002797511o--!

va real va imaginary v4 real v4 imaginary

+1.000000000001o+0 +0.00000000000 --9.999950491691o--t +5.7453936589010--6


--9.999983497221o -.1 +1.915t4240547to--6 +9.999966994461o--t --3.8302721801610--6
+ 9.9999 6699438~o-- 1 -- 3.8302 7633 40510-- 6 --9.9999 8349 7261o-- t + t.91514248 2551o-- 6
--9.999950491531o--1 +5.7454048057O10--6 +1.000000000001o+0 +0.00000000000

(vl--v~,) real (vl-vz) imaginary (vl--vz) normalised

o o o
+3'7299410--7 --1"1939701o--6 (t+i)2/3 t to six
+8.2097710--7 +,.5669651o--6 --2(i + i)/3[ decimals
- - I. 7909571o-- 6 -- 5.594911o-- 7 / J

T h e final t e s t m a t r i x is a full c o m p l e x m a t r i x a n d t h e e i g e n p r o b l e m was


solved u s i n g comhes a n d comlr2. T h e results are g i v e n in T a b l e 4. All residuals
are less t h a n 10 -1° .
202 Handbook Series Linear Algebra:

Table 4
Real part of matrix Imaginary part of matrix

I~l
2 23t1 3 2t3 ~] [i 215 241 il

Eigenvalues
Real parts Imaginary parts

+9.7836 5812 74810+0 +9.3225 1422 4801o+0


--3.37100978 50110+0 --7.7045 398695910--1
+2.2216 8234 77210+0 +1.84899335 97510+0
+ t.3656 6930 9951o+0 -- 1.4010 5359 7471o+0

Eigenvectors
vx real v1 imaginary v~ real v2 imaginary

+6.3233 77645001o--t --1.437807944621o--2 --5.06096461 9661o--t +5.8345 19625951o--1


+8.73758591 7101o--t +8.1057807821610--3 +1.000000000001o+0 +0.00000000000
+t.000000000001o+0 +0.00000000000 +5.183194839431o--1 --7.146570721961o--1
+9.437t 75883741o--1 +3.7984634803510--2 --5.534848981991o--1 +1.875633202021o--2

v3 real v3 imaginary v4 real v4 imaginary


--7.966208174241o--1 +3.049807859421o--1 --8.465987047921o--4 +7.302035512491o--I
--1.788343947451o--1 +4.29724t477401o--1 --8.7941 701579010--2 --3.879017995961o--1
--2.528143111991o--1 +3.8173404951610--2 +1.000000000001o+0 +0.00000000000
+1.000000000001o+0 +0.00000000000 --4.320893747981o--t --4.334263693411o--1

7.2. Tests on hqr2


The matrix of Table 5 has a well-conditioned eigenvalue problem and simple
eigenvalues, and again provides a straightforward test.

Table 5
Matrix Eigenvalues
Real parts Imaginary parts

+6.0779 0591 26510+ 0 +0.00000000000


1 3 -- --3.1955 2891 9251o+0 +0.00000000000
4 t + t .5588 t 150 3321o+0 +2.0015 159208310+0
0 2 + t .5.588 1150 33210+0 --2.0015 1592 0831o+o

Ei~elcve£tor$
v1 real v2 real v3 real v3 imaginary

+1.000000000001o+0 +2.119588932301o--1 +t.000000000001o+0 +0.00000000000


+7.0117351200tlo--t --9.297077444061o--t --6.654547273111o--2 --3.457149187821o--t
+5.987763536651o--t +t.000000000001o+0 --4.7651 79607261o--I +4.2O7790333151o--2
+2.358359386641o--1 --4.7669794t6561o--1 --8.432142050201o--2 +4.5261 50065931o--1
Eigenvectors of Real and Complex Matrices. G. Peters and J. H. Wilkinson 203

T h e m a t r i x of T a b l e 6 h a s a d o u b l e e i g e n v a l u e w i t h l i n e a r divisors. T w o
i n d e p e n d e n t e i g e n v e c t o r s are p r o d u c e d . I t Call b e used w i t h low = t, upp = 3 or
low = 2, upp = 3 a n d g i v e s i d e n t i c a l r e s u l t s in t h e t w o cases,

Table 6
Matrix Eigenvalues Eigenvectors

r244 2 1oo o
[01313 4 0 0.25 1.0
1 2 0 0.25 -1.0

T h e m a t r i x of T a b l e 7 has t w o pairs of q u a d r a t i c divisors, all t h e e i g e n v a l u e s


b e i n g c o m p l e x . As for t h e c o r r e s p o n d i n g e x a m p l e for comlr2, t h e e i g e n v a l u e s
h a v e a b o u t half t h e figures correct, t h e " t w o e i g e n v e c t o r s " agree to a b o u t half
w o r d l e n g t h a n d t h e d i f f e r e n c e b e t w e e n t h e m g i v e s a v e c t o r of g r a d e t w o a c c u r a t e
t o a b o u t h a l f w o r d l e n g t h . N e v e r t h e l e s s , t h e m a x i m u m r e s i d u a l is o n l y 7 × 10 -11.

Table 7
Matrix Eigenvalues
Real parts Imaginary parts

3o Oo2til +
+
+
+
4.9999 9008 4201o-- t
4.9999 9008 42010 -- 1
5.0000 0991 53810-- 1
5.0000 0991 5381o-- 1
+ 8.6602 7888 4t61o-- t
-- 8.6602 7888 4161o-- 1
+ 8.6602 2919 1341o-- 1
-- 8.6602 2919 1341o-- 1

Eiggnuectors
v1 real vI imaginary v8 real v~ imaginary

+1.000000000001o+0 +0.00000000000 --9.999950320631o--I +6.303042959751o--6


+4.999973524451o--1 --8.660250201761o--1 --4.999947049501o--1 +8.660246365621o--1
-- 5.000019831241o -- I -- 8.6602 O434 4671o -- t + 5.0000 099t 5571o-- 1 + 8.6602 29191371o -- t
--9.999950320251o--I +6,303109285371o--6 +I.000000000001o--0 +O.00000000000

T h e final t e s t is w i t h a full m a t r i x . I t w a s s o l v e d u s i n g hqr2 c o m b i n e d w i t h


elmhes, dirhes a n d orthes a n d elmtrans, dirtrans a n d ortrans r e s p e c t i v e l y a n d t h e
t h r e e sets of r e s u l t s w e r e in close a g r e e m e n t . All r e s i d u a l s w e r e less t h a n t 0 -1°.
T h e r e s u l t s are g i v e n in T a b l e 8.

Table 8
Matrix Eigenvalues

[12 !] o599821261o
1
1
3
2
--2.36630331 1691o+0
+ 1.9t 34 632t 4031o-- I
1 3 --4.17025131 203xo-- t
204 Handbook Series: Eigenvectors of Real and Complex Matrices. G. Peters et al.

Eigenvectors
v1 v~ v3 v4

+8.57984283411to--1 +3.601626395171o--I --2.950503351821o--I --1.1208317067tlo--2


+ 1.O000OO000001o+ 0 + 1.O0000000 00010+ O + 1.00000000 00010+ 0 + t .0000 0000 O001o+ 0
+7.834583918231o--1 +9.605080270971o--2 +t.063754939331o--1 --2.4113619293910--1
+7.893769113161o--t --6.249687t4tt51o--! --7.681135571601o--2 --9.588570260391o--2

A second test r u n was made b y E. M a n n of the R e c h e n c e n t r u m der Technischen


Hochschule Mtinchen a n d confirmed these results.

Acknowledgements. This work was carried out at the National Physical Laboratory.
The authors wish to t h a n k E. Mann of the Rechencentlum der Technischen Hoch-
schule Miinchen for performing test runs with earlier versions, and C. Reinsch for
suggesting substantial improvements in the published algorithms.

References

1. Dekker, T. J., Hoffman, W. : Algol 60 procedures in linear algebra. Mathematical


Centre Tracts, 23. Mathematisch Centrum Amsterdam (1968).
2. Francis, J. G. F.: The QR transformation--a unitary analogue to the L R trans-
formation. Computer Journal 4, 265-271, 332-345 (1961/62).
3. Martin, R. S., Wilkinson, J . H . : Similarity reduction of a general matrix to
Hessenberg form. Num. Math. 12, 349-368 (1968).
4. -- -- The modified L R algorithm for complex Hessenberg matrices. Num. Math.
12, 369-376 (t968),
5. -- Peters, G., Wilkinson, J. H. : The Q R algorithm for real Hessenberg matrices.
Num. Math. 14, 219-231 (t970).
6. Parlett, B. N., Reinsch, C. : Balancing a matrix for calculation of eigenvMues and
eigenvectors. Num. Math. 13, 293-304 (1969).
7. Rutishauser, H. : Solution of eigenvalue problems with the L R transformation.
NBS Applied Math. Series, No. 49 (1958).
8. Wilkinson, J. H. : The algebraic eigenvalue probtem. London: Oxford University
Press t 965.
Dr. J. H. Wilkinson
National Physical Laboratory
Division of Numerical and
Applied Mathematics
Teddington, Middlesex, Great Britain

You might also like