Remark on “Algorithm 506: HQR3 and EXCHNG: Fortran Subroutines for Calculating and Ordering the Eigenvalues of a Real Upper Hessenberg Matrix”

An uncorrected version of HQR3 will yield a division by zero in line HQR 1060 of [2] as a result of the test in (1). In checking for a zero subdiagonal element, the criterion is the sum of the magnitudes of the two diagonals. As the example shows, when both diagonals are zero, the .LT. test fails for an exactly zero subdiagonal element. Without correction (2), when exchanging two upper real roots with a lower 2 × 2 block, only the bottom root is tested and exchanged, leaving the possibility of misordering of the top root. The example above also demonstrates this problem. Without correction (3), the program would give the wrong diagonals in an unusual case where part of a matrix was being triangularized and the routine failed to converge. Correction (4) is necessary when the superdiagonal element is zero between two real roots, leaving the possibility that the maximum of (P,Q) is P ffi 0 for Q negative. (If (P,Q) are both zero, no exchange is required and the program properly returns.)