Professional Documents
Culture Documents
Eigenvectors of Real and Complex Matrices by LR and QR Triangularizations
Eigenvectors of Real and Complex Matrices by LR and QR Triangularizations
Eigenvectors of Real and Complex Matrices by LR and QR Triangularizations
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
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].
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.
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:
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
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:
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;
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 :
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.
Table I
Real part of matrix Imaginary part of matrix
Eigenvalues
Real parts Imaginary parts
Eigenvectors
vI real v1 imaginary v2 real v2 imaginary
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
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--!
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
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
Eigenvectors
vx real v1 imaginary v~ real v2 imaginary
Table 5
Matrix Eigenvalues
Real parts Imaginary parts
Ei~elcve£tor$
v1 real v2 real v3 real v3 imaginary
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
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
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
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