Householder Transformations
Source inspiration: (Mathew 2000-2019).
Householder’s method takes a real symmetric \(n \times n\) matrix \(\mathbf{A}\) and, in exactly \(n - 2\) steps, produces a symmetric tridiagonal matrix with the same eigenvalues. Each step is an orthogonal similarity transformation \(\mathbf{A}_k = \mathbf{P}_k\mathbf{A}_{k-1}\mathbf{P}_k\) by a Householder matrix \(\mathbf{P}_k\), a reflection. Jacobi’s method also uses orthogonal similarity transformations, but each of its rotations makes only one symmetric pair of entries zero, and later rotations can make them nonzero again, so it needs many sweeps. A Householder step makes a whole column below the subdiagonal zero at once (and, by symmetry, the matching row), and later steps leave those zeros in place. The tridiagonal result is the starting point of the QR method, which then finds all the eigenvalues cheaply.
The QR method page shows the same reduction with the matrices \(\mathbf{P}_k\) written out, and its Case 2 animation shows the matrix of Example 1 below being reduced and then iterated to its eigenvalues. This page develops the reflection itself, the cheap way of applying it, and all of Mathews’ worked examples. For a matrix that is not symmetric the same steps give an upper Hessenberg matrix instead; see Hessenberg Factorization.
Householder Reflections
If \(\mathbf{X}\) and \(\mathbf{Y}\) are vectors in \(\mathbb{R}^n\) with the same norm, \(\lVert\mathbf{X}\rVert = \lVert\mathbf{Y}\rVert\), and \(\mathbf{X} \neq \mathbf{Y}\), there is an orthogonal symmetric matrix \(\mathbf{P}\) such that \(\mathbf{Y} = \mathbf{P}\mathbf{X}\), namely
\[ \mathbf{P} = \mathbf{I} - 2\mathbf{W}\mathbf{W}^{T}, \qquad \mathbf{W} = \frac{\mathbf{X} - \mathbf{Y}}{\lVert\mathbf{X} - \mathbf{Y}\rVert}. \tag{1} \]
Since \(\mathbf{P}\) is both orthogonal and symmetric, \(\mathbf{P}^{-1} = \mathbf{P}^{T} = \mathbf{P}\).
Proof. \(\mathbf{P}^{T} = \mathbf{I} - 2(\mathbf{W}\mathbf{W}^{T})^{T} = \mathbf{P}\), and because \(\mathbf{W}^{T}\mathbf{W} = 1\),
\[ \mathbf{P}^{T}\mathbf{P} = \mathbf{I} - 4\mathbf{W}\mathbf{W}^{T} + 4\mathbf{W}(\mathbf{W}^{T}\mathbf{W})\mathbf{W}^{T} = \mathbf{I}. \]
Since \(\lVert\mathbf{X}\rVert = \lVert\mathbf{Y}\rVert\), we have \(\lVert\mathbf{X} - \mathbf{Y}\rVert^2 = 2\mathbf{X}^{T}\mathbf{X} - 2\mathbf{Y}^{T}\mathbf{X} = 2(\mathbf{X} - \mathbf{Y})^{T}\mathbf{X}\), so
\[ \mathbf{P}\mathbf{X} = \mathbf{X} - 2\,\frac{(\mathbf{X} - \mathbf{Y})\,(\mathbf{X} - \mathbf{Y})^{T}\mathbf{X}}{\lVert\mathbf{X} - \mathbf{Y}\rVert^{2}} = \mathbf{X} - (\mathbf{X} - \mathbf{Y}) = \mathbf{Y}. \qquad \blacksquare \]
Geometry. \(\mathbf{P}\) leaves every vector orthogonal to \(\mathbf{W}\) unchanged and reverses \(\mathbf{W}\), so it is the mirror reflection in the hyperplane through the origin orthogonal to \(\mathbf{W}\) (in the plane, a line). That mirror contains \(\mathbf{X} + \mathbf{Y}\), because \((\mathbf{X} - \mathbf{Y})^{T}(\mathbf{X} + \mathbf{Y}) = \lVert\mathbf{X}\rVert^2 - \lVert\mathbf{Y}\rVert^2 = 0\): it bisects the angle between \(\mathbf{X}\) and \(\mathbf{Y}\), and reflecting in it carries \(\mathbf{X}\) to \(\mathbf{Y}\). Hence the name Householder reflection.
To create zeros we choose \(\mathbf{Y}\) to agree with \(\mathbf{X}\) in its first \(k\) components and to put the whole length of the rest of \(\mathbf{X}\) into component \(k + 1\).
Let \(\mathbf{X} = (x_1, \ldots, x_n)^{T}\), let \(k\) be an integer with \(1 \le k \le n - 2\), and assume \((x_{k+1}, \ldots, x_n) \neq \mathbf{0}\). Define, with \(\operatorname{sign}(0)\) taken as \(+1\),
\[ S = \operatorname{sign}(x_{k+1})\sqrt{x_{k+1}^2 + x_{k+2}^2 + \cdots + x_n^2}, \qquad R = \sqrt{2\,(x_{k+1} + S)\,S}, \tag{2} \]
\[ \mathbf{W}_k = \frac{1}{R}\,(0, \ldots, 0,\ x_{k+1} + S,\ x_{k+2}, \ldots, x_n)^{T}, \qquad \mathbf{P}_k = \mathbf{I} - 2\mathbf{W}_k\mathbf{W}_k^{T}. \tag{3} \]
Then \(\mathbf{P}_k\) is symmetric and orthogonal and
\[ \mathbf{P}_k\mathbf{X} = (x_1, \ldots, x_k,\ -S,\ 0, \ldots, 0)^{T}. \tag{4} \]
This is the theorem with \(\mathbf{Y} = (x_1, \ldots, x_k, -S, 0, \ldots, 0)^{T}\), which has the same norm as \(\mathbf{X}\) and differs from it, because \(x_{k+1}\) and \(S\) never have opposite signs, so \(\lvert x_{k+1} + S\rvert = \lvert x_{k+1}\rvert + \lvert S\rvert > 0\). Then \(\mathbf{X} - \mathbf{Y} = (0, \ldots, 0, x_{k+1} + S, x_{k+2}, \ldots, x_n)^{T}\), and its squared length is \((x_{k+1} + S)^2 + (S^2 - x_{k+1}^2) = 2(x_{k+1} + S)S = R^2\), so \(\mathbf{W}_k = (\mathbf{X} - \mathbf{Y})/R\) is the unit vector of (1). Because \(\mathbf{W}_k\) is zero in its first \(k\) components, \(\mathbf{P}_k\) has an identity block in its upper-left \(k \times k\) corner and leaves the first \(k\) components of any vector unchanged, so \(\mathbf{P}_k\mathbf{A}\) keeps the first \(k\) rows of \(\mathbf{A}\), \(\mathbf{A}\mathbf{P}_k\) keeps the first \(k\) columns, and \(\mathbf{P}_k\mathbf{A}\mathbf{P}_k\) keeps the leading \(k \times k\) block.
Notation on the QR method page. The QR method page writes the same matrix as \(\mathbf{P} = \mathbf{I} - 2\mathbf{v}\mathbf{v}^{T}/(\mathbf{v}^{T}\mathbf{v})\) with \(\mathbf{v} = \mathbf{x} - \alpha\mathbf{e}_1\) and \(\alpha = -\operatorname{sign}(x_1)\lVert\mathbf{x}\rVert\), where \(\mathbf{x}\) is the part of the column below the diagonal. The two are identical: \(\alpha = -S\), the full-length \(\mathbf{v}\) of that page (zero in its first \(k\) components) is \(R\,\mathbf{W}_k\), \(\mathbf{v}^{T}\mathbf{v} = R^2\), and the new subdiagonal entry \(\alpha\) is the \(-S\) of (4).
The sign of \(S\) is chosen equal to the sign of \(x_{k+1}\) so that \(x_{k+1} + S\) is a sum of two numbers of the same sign; then \(R^2 = 2\left(|x_{k+1}| + \lVert\mathbf{x}\rVert\right)\lVert\mathbf{x}\rVert \ge 2\lVert\mathbf{x}\rVert^2\), where \(\mathbf{x} = (x_{k+1}, \ldots, x_n)\). The opposite sign would also satisfy the theorem in exact arithmetic, but \(x_{k+1} - \operatorname{sign}(x_{k+1})\lVert\mathbf{x}\rVert\) can cancel. For \(\mathbf{x} = (1, 10^{-8})\) in double precision, \(\lVert\mathbf{x}\rVert\) rounds to exactly \(1\); the recommended sign gives \(\mathbf{v} = (2, 10^{-8})\) and \(\mathbf{P}\mathbf{x} = (-1, 0)\), while the other sign gives \(\mathbf{v} = (0, 10^{-8})\) and \(\mathbf{P}\mathbf{x} = (1, -10^{-8})\), which has not been reduced at all.
Two special cases need care in a program. If \(x_{k+1} = 0\), the sign must not be taken as \(0\); take \(+1\) (any \(\pm 1\) works, since then \((x_{k+1} + S)S = S^2 > 0\) and there is nothing to cancel). Mathews’ step subroutine uses Mathematica’s Sign, which returns \(0\) there and makes \(R = 0\), while his loop program (Example 4) tests A1[[k+1,k]] < 0 and so uses \(+1\). If \(x_{k+1} = \cdots = x_n = 0\), the column is already reduced and the step is skipped (\(\mathbf{P}_k = \mathbf{I}\)). None of Mathews’ examples meets either case.
Householder’s Method
Reduction to tridiagonal form
Start with \(\mathbf{A}_0 = \mathbf{A}\), a real symmetric \(n \times n\) matrix, and construct Householder matrices \(\mathbf{P}_1, \mathbf{P}_2, \ldots, \mathbf{P}_{n-2}\) so that
\[ \mathbf{A}_k = \mathbf{P}_k\mathbf{A}_{k-1}\mathbf{P}_k \quad \text{for } k = 1, 2, \ldots, n - 2, \tag{5} \]
where \(\mathbf{P}_k\) comes from the Corollary with \(\mathbf{X}\) equal to column \(k\) of \(\mathbf{A}_{k-1}\). Then \(\mathbf{A}_k\) has zeros below the subdiagonal in columns \(1, \ldots, k\), and \(\mathbf{H} = \mathbf{A}_{n-2}\) is a symmetric tridiagonal matrix similar to \(\mathbf{A}\). This process is called Householder’s method.
Here is the pattern for \(n = 5\), where \(\times\) stands for an entry that may be nonzero. In the first step \(\mathbf{P}_1\) has an identity block of size \(1\), so the product \(\mathbf{P}_1\mathbf{A}_0\mathbf{P}_1\) does not change \(a_{11}\), and by (4) column 1 becomes \((a_{11}, -S, 0, 0, 0)^{T}\) (row 1 likewise, by symmetry):
\[ \mathbf{P}_1 = \begin{pmatrix} 1 & 0 & 0 & 0 & 0 \\ 0 & \times & \times & \times & \times \\ 0 & \times & \times & \times & \times \\ 0 & \times & \times & \times & \times \\ 0 & \times & \times & \times & \times \end{pmatrix}, \qquad \mathbf{A}_1 = \begin{pmatrix} a_{11} & \times & 0 & 0 & 0 \\ \times & \times & \times & \times & \times \\ 0 & \times & \times & \times & \times \\ 0 & \times & \times & \times & \times \\ 0 & \times & \times & \times & \times \end{pmatrix}. \]
\(\mathbf{P}_2\) has an identity block of size \(2\), so it does not disturb the zeros already made, and it reduces column 2; \(\mathbf{P}_3\) has an identity block of size \(3\) and reduces column 3:
\[ \mathbf{A}_2 = \begin{pmatrix} \times & \times & 0 & 0 & 0 \\ \times & \times & \times & 0 & 0 \\ 0 & \times & \times & \times & \times \\ 0 & 0 & \times & \times & \times \\ 0 & 0 & \times & \times & \times \end{pmatrix}, \qquad \mathbf{A}_3 = \begin{pmatrix} \times & \times & 0 & 0 & 0 \\ \times & \times & \times & 0 & 0 \\ 0 & \times & \times & \times & 0 \\ 0 & 0 & \times & \times & \times \\ 0 & 0 & 0 & \times & \times \end{pmatrix}. \]
Three transformations reduce a \(5 \times 5\) matrix to tridiagonal form, and in general \(n - 2\) are needed. Each \(\mathbf{P}_k\) is orthogonal, so \(\mathbf{H} = \mathbf{U}^{T}\mathbf{A}\mathbf{U}\) with \(\mathbf{U} = \mathbf{P}_1\mathbf{P}_2\cdots\mathbf{P}_{n-2}\) orthogonal. \(\mathbf{H}\) therefore has the eigenvalues of \(\mathbf{A}\), the same characteristic polynomial and the same sum of squared entries; the examples below check all three. If \(\mathbf{H}\mathbf{y} = \lambda\mathbf{y}\), then \(\mathbf{A}(\mathbf{U}\mathbf{y}) = \lambda\,\mathbf{U}\mathbf{y}\), so eigenvectors of \(\mathbf{H}\) give eigenvectors of \(\mathbf{A}\).
Applying one transformation cheaply
The matrix \(\mathbf{P}_k\) is never formed in practice; the product \(\mathbf{P}\mathbf{A}\mathbf{P}\) can be computed from a few vectors.
If \(\mathbf{P} = \mathbf{I} - 2\mathbf{W}\mathbf{W}^{T}\) is a Householder matrix (\(\mathbf{W}^{T}\mathbf{W} = 1\)) and \(\mathbf{A}\) is symmetric, let
\[ \mathbf{V} = \mathbf{A}\mathbf{W}, \qquad c = \mathbf{W}^{T}\mathbf{V}, \qquad \mathbf{Q} = \mathbf{V} - c\,\mathbf{W}. \tag{6} \]
Then
\[ \mathbf{P}\mathbf{A}\mathbf{P} = \mathbf{A} - 2\mathbf{W}\mathbf{Q}^{T} - 2\mathbf{Q}\mathbf{W}^{T}. \tag{7} \]
Proof. Expanding, and using \(\mathbf{W}^{T}\mathbf{A} = (\mathbf{A}\mathbf{W})^{T} = \mathbf{V}^{T}\) because \(\mathbf{A}\) is symmetric,
\[ \mathbf{P}\mathbf{A}\mathbf{P} = \mathbf{A} - 2\mathbf{W}\mathbf{V}^{T} - 2\mathbf{V}\mathbf{W}^{T} + 4c\,\mathbf{W}\mathbf{W}^{T}, \]
and \(2\mathbf{W}\mathbf{Q}^{T} + 2\mathbf{Q}\mathbf{W}^{T} = 2\mathbf{W}\mathbf{V}^{T} + 2\mathbf{V}\mathbf{W}^{T} - 4c\,\mathbf{W}\mathbf{W}^{T}\). \(\blacksquare\)
Forming \(\mathbf{P}\mathbf{A}\mathbf{P}\) as two matrix products takes about \(2n^3\) multiplications; (6) and (7) take one matrix–vector product and two outer products, each about \(n^2\) multiplications. So each step costs a multiple of \(n^2\) operations and the whole reduction a multiple of \(n^3\) (these are general operation counts, not measured timings).
Algorithm
For \(k = 1, 2, \ldots, n - 2\), with \(\mathbf{X}\) the \(k\)th column of \(\mathbf{A}_{k-1}\):
- compute \(S\) and \(R\) from (2) and \(\mathbf{W}\) from (3);
- compute \(\mathbf{V} = \mathbf{A}_{k-1}\mathbf{W}\), \(c = \mathbf{W}^{T}\mathbf{V}\) and \(\mathbf{Q} = \mathbf{V} - c\,\mathbf{W}\);
- set \(\mathbf{A}_k = \mathbf{A}_{k-1} - 2\mathbf{W}\mathbf{Q}^{T} - 2\mathbf{Q}\mathbf{W}^{T}\).
The new entries in positions \((k+1, k)\) and \((k, k+1)\) are \(-S\); the rest of column \(k\) below them and of row \(k\) beyond them are zero. The last subdiagonal entry, in position \((n, n-1)\), is not of this form; it is whatever the last step leaves there. In floating-point arithmetic those zeros come out as rounding noise (below \(1.1 \times 10^{-15}\) in double precision in Examples 1, 3 and 4), so programs set them to zero: Mathews’ step subroutine applies Chop to each \(\mathbf{A}_k\), and his loop program assigns the zeros and the value \(-S\) directly.
Example 1 — A \(4 \times 4\) matrix by hand
Use Householder’s method to reduce the symmetric matrix
\[ \mathbf{A}_0 = \begin{pmatrix} 4 & 2 & 2 & 1 \\ 2 & -3 & 1 & 1 \\ 2 & 1 & 3 & 1 \\ 1 & 1 & 1 & 2 \end{pmatrix} \]
to symmetric tridiagonal form. Two steps are needed (\(n - 2 = 2\)). This is the matrix of Example 4 on the QR method page, which writes out \(\mathbf{P}_1\) and \(\mathbf{P}_2\) and then runs the QR iteration on the result.
Step 1 (\(k = 1\)). Column 1 is \(\mathbf{X} = (4, 2, 2, 1)^{T}\) and \(x_2 = 2 > 0\), so
\[ S = \sqrt{2^2 + 2^2 + 1^2} = 3, \qquad R = \sqrt{2(2 + 3)\,3} = \sqrt{30} \approx 5.477226, \]
\[ \mathbf{W} = \frac{1}{\sqrt{30}}(0,\ 5,\ 2,\ 1)^{T} = \left(0, \sqrt{\tfrac56}, \sqrt{\tfrac{2}{15}}, \tfrac{1}{\sqrt{30}}\right)^{T} \approx (0,\ 0.912871,\ 0.365148,\ 0.182574)^{T}. \]
Step 2. With \(\mathbf{V} = \mathbf{A}_0\mathbf{W}\),
\[ \mathbf{V} = \sqrt{30}\left(\tfrac12, -\tfrac25, \tfrac25, \tfrac{3}{10}\right)^{T}, \qquad c = \mathbf{W}^{T}\mathbf{V} = -\tfrac{9}{10}, \qquad \mathbf{Q} = \mathbf{V} + \tfrac{9}{10}\mathbf{W} = \sqrt{30}\left(\tfrac12, -\tfrac14, \tfrac{23}{50}, \tfrac{33}{100}\right)^{T}, \]
that is, \(\mathbf{V} \approx (2.738613, -2.190890, 2.190890, 1.643168)^{T}\) and \(\mathbf{Q} \approx (2.738613, -1.369306, 2.519524, 1.807484)^{T}\).
Step 3. The correction \(2\mathbf{W}\mathbf{Q}^{T}\) has rational entries, and \(2\mathbf{Q}\mathbf{W}^{T}\) is its transpose:
\[ 2\mathbf{W}\mathbf{Q}^{T} = \begin{pmatrix} 0 & 0 & 0 & 0 \\ 5 & -2.5 & 4.6 & 3.3 \\ 2 & -1 & 1.84 & 1.32 \\ 1 & -0.5 & 0.92 & 0.66 \end{pmatrix}, \qquad \mathbf{A}_1 = \mathbf{A}_0 - 2\mathbf{W}\mathbf{Q}^{T} - 2\mathbf{Q}\mathbf{W}^{T} = \begin{pmatrix} 4 & -3 & 0 & 0 \\ -3 & 2 & -\tfrac{13}{5} & -\tfrac95 \\[1mm] 0 & -\tfrac{13}{5} & -\tfrac{17}{25} & -\tfrac{31}{25} \\[1mm] 0 & -\tfrac95 & -\tfrac{31}{25} & \tfrac{17}{25} \end{pmatrix}. \]
Column 1 is now \((4, -3, 0, 0)^{T}\), as (4) predicts with \(-S = -3\).
Step 4 (\(k = 2\)). Column 2 of \(\mathbf{A}_1\) has \(x_3 = -\tfrac{13}{5} < 0\), so \(S\) is negative:
\[ S = -\sqrt{\left(\tfrac{13}{5}\right)^2 + \left(\tfrac95\right)^2} = -\sqrt{10} \approx -3.162278, \qquad R = \sqrt{2\left(-\tfrac{13}{5} - \sqrt{10}\right)\left(-\sqrt{10}\right)} = \sqrt{20 + \tfrac{26\sqrt{10}}{5}} \approx 6.036874, \]
\[ \mathbf{W} = \frac{1}{R}\left(0,\ 0,\ -\tfrac{13}{5} - \sqrt{10},\ -\tfrac95\right)^{T} \approx (0,\ 0,\ -0.954514,\ -0.298168)^{T}. \]
Step 5. \(\mathbf{V} = \mathbf{A}_1\mathbf{W} \approx (0,\ 3.018437,\ 1.018797,\ 0.980843)^{T}\), \(c = \mathbf{W}^{T}\mathbf{V} = -\tfrac{2\sqrt{10}}{5} \approx -1.264911\) and \(\mathbf{Q} = \mathbf{V} - c\,\mathbf{W} \approx (0,\ 3.018437,\ -0.188578,\ 0.603687)^{T}\). Then
\[ \boxed{\ \mathbf{H} = \mathbf{A}_2 = \mathbf{A}_1 - 2\mathbf{W}\mathbf{Q}^{T} - 2\mathbf{Q}\mathbf{W}^{T} = \begin{pmatrix} 4 & -3 & 0 & 0 \\ -3 & 2 & \sqrt{10} & 0 \\ 0 & \sqrt{10} & -\tfrac75 & -\tfrac15 \\[1mm] 0 & 0 & -\tfrac15 & \tfrac75 \end{pmatrix} \approx \begin{pmatrix} 4 & -3 & 0 & 0 \\ -3 & 2 & 3.162278 & 0 \\ 0 & 3.162278 & -1.4 & -0.2 \\ 0 & 0 & -0.2 & 1.4 \end{pmatrix}\ } \]
Every number above agrees with Mathews’ printout.
Verification.
| Invariant | \(\mathbf{A}_0\) | \(\mathbf{H}\) |
|---|---|---|
| characteristic polynomial | \((\lambda^2 - 8\lambda + 9)(\lambda^2 + 2\lambda - 6)\) | \((\lambda^2 - 8\lambda + 9)(\lambda^2 + 2\lambda - 6)\) \(\checkmark\) |
| sum of squared entries | \(62\) | \(16 + 2 \cdot 9 + 4 + 2 \cdot 10 + 2 \cdot \tfrac{49}{25} + 2 \cdot \tfrac{1}{25} = 62\) \(\checkmark\) |
Both matrices have the eigenvalues \(4 \pm \sqrt7 \approx 6.645751,\ 1.354249\) and \(-1 \pm \sqrt7 \approx 1.645751,\ -3.645751\). The QR method page finds them by iterating on \(\mathbf{H}\).
Example 2 — The same matrix with the step subroutine
Mathews next packages Steps 1–5 as a Mathematica subroutine, HouseholderStep[k]. It takes column \(k\) of \(\mathbf{A}_{k-1}\), computes \(S\) (with Mathematica’s Sign; see the caution above), \(R\), \(\mathbf{W}\), \(\mathbf{V}\), \(c\) and \(\mathbf{Q}\), forms \(\mathbf{A}_k = \mathbf{A}_{k-1} - 2\mathbf{W}\mathbf{Q}^{T} - 2\mathbf{Q}\mathbf{W}^{T}\), replaces entries that are rounding noise by zero, and prints every intermediate quantity. His Example 2 calls it for \(k = 1\) and \(k = 2\) on the matrix of Example 1, so it prints the same numbers: \(S = 3\), \(R = \sqrt{30}\), \(c = -0.9\) and \(\mathbf{A}_1\) in the first call, \(S \approx -3.162278\), \(R \approx 6.036874\), \(c \approx -1.264911\) and the matrix \(\mathbf{H}\) of Example 1 in the second. The verification of Example 1 therefore covers Example 2 too.
Example 3 — A \(5 \times 5\) matrix
Use the Householder step algorithm to reduce
\[ \mathbf{A}_0 = \begin{pmatrix} 5 & 1 & 2 & 2 & 4 \\ 1 & 1 & 2 & 1 & 0 \\ 2 & 2 & 0 & 2 & 1 \\ 2 & 1 & 2 & 1 & 2 \\ 4 & 0 & 1 & 2 & 4 \end{pmatrix} \]
to symmetric tridiagonal form (Mathews’ Exercise 3). Three steps are needed.
Step 1 (\(k = 1\), \(x_2 = 1\)). \(S = \sqrt{1 + 4 + 4 + 16} = 5\), \(R = \sqrt{2(1 + 5)\,5} = 2\sqrt{15} \approx 7.745967\) and
\[ \mathbf{W} = \frac{1}{2\sqrt{15}}(0, 6, 2, 2, 4)^{T} = \frac{\sqrt{15}}{15}(0, 3, 1, 1, 2)^{T}, \qquad \mathbf{V} = \sqrt{15}\left(1, \tfrac25, \tfrac23, \tfrac23, \tfrac{11}{15}\right)^{T}, \qquad c = 4, \]
\[ \mathbf{Q} = \mathbf{V} - 4\mathbf{W} = \sqrt{15}\left(1, -\tfrac25, \tfrac25, \tfrac25, \tfrac15\right)^{T}, \qquad \mathbf{A}_1 = \begin{pmatrix} 5 & -5 & 0 & 0 & 0 \\ -5 & 5.8 & 0.4 & -0.6 & 0.4 \\ 0 & 0.4 & -1.6 & 0.4 & -1 \\ 0 & -0.6 & 0.4 & -0.6 & 0 \\ 0 & 0.4 & -1 & 0 & 2.4 \end{pmatrix}. \]
Step 2 (\(k = 2\), \(x_3 = 0.4\)). \(S = \sqrt{0.4^2 + 0.6^2 + 0.4^2} = \tfrac{\sqrt{17}}{5} \approx 0.824621\), \(R \approx 1.421160\), \(\mathbf{W} \approx (0, 0, 0.861705, -0.422190, 0.281460)^{T}\), \(\mathbf{V} \approx (0, 0.710580, -1.829064, 0.597996, -0.186201)^{T}\), \(c \approx -1.880990\), \(\mathbf{Q} \approx (0, 0.710580, -0.208206, -0.196139, 0.343223)^{T}\) and
\[ \mathbf{A}_2 \approx \begin{pmatrix} 5 & -5 & 0 & 0 & 0 \\ -5 & 5.8 & -0.824621 & 0 & 0 \\ 0 & -0.824621 & -0.882353 & 0.562224 & -1.474311 \\ 0 & 0 & 0.562224 & -0.931233 & 0.400222 \\ 0 & 0 & -1.474311 & 0.400222 & 2.013586 \end{pmatrix}. \]
Step 3 (\(k = 3\), \(x_4 \approx 0.562224\)). \(S = \sqrt{0.562224^2 + 1.474311^2} \approx 1.577875\), \(R \approx 2.598772\), \(\mathbf{W} \approx (0, 0, 0, 0.823504, -0.567311)^{T}\), \(\mathbf{V} \approx (0, 0, 1.299386, -0.993924, -0.812744)^{T}\), \(c \approx -0.357422\), \(\mathbf{Q} \approx (0, 0, 1.299386, -0.699586, -1.015513)^{T}\) and
\[ \boxed{\ \mathbf{H} = \mathbf{A}_3 \approx \begin{pmatrix} 5 & -5 & 0 & 0 & 0 \\ -5 & 5.8 & -0.824621 & 0 & 0 \\ 0 & -0.824621 & -0.882353 & -1.577875 & 0 \\ 0 & 0 & -1.577875 & 1.373214 & 1.279015 \\ 0 & 0 & 0 & 1.279015 & -0.290861 \end{pmatrix}\ } \]
In exact form the diagonal is \(\left(5, \tfrac{29}{5}, -\tfrac{15}{17}, \tfrac{174968}{127415}, -\tfrac{436}{1499}\right)\) and the subdiagonal is \(\left(-5, -\tfrac{\sqrt{17}}{5}, -\tfrac{2\sqrt{4497}}{85}, \tfrac{465\sqrt{17}}{1499}\right)\). The first three subdiagonal entries are the values \(-S\) of Steps 1–3; the last one, in position \((5, 4)\), is what Step 3 leaves there. Mathews’ printed \(\mathbf{A}_1\), \(\mathbf{A}_2\) and \(\mathbf{H}\) (to ten significant digits) agree with these.
Verification.
| Invariant | \(\mathbf{A}_0\) | \(\mathbf{H}\) |
|---|---|---|
| characteristic polynomial | \(\lambda^5 - 11\lambda^4 + 60\lambda^2 + 3\lambda - 17\) | \(\lambda^5 - 11\lambda^4 + 60\lambda^2 + 3\lambda - 17\) \(\checkmark\) (exact) |
| sum of squared entries | \(121\) | \(121\) \(\checkmark\) (exact) |
| eigenvalues | \(10.449283,\ 2.652048,\ -2.043362,\ -0.577672,\ 0.519702\) | the same \(\checkmark\) |
The characteristic polynomial can also be found directly from \(\mathbf{A}_0\) by the Faddeev–Leverrier method.
Example 4 — A \(6 \times 6\) matrix, step by step and with loops
Reduce
\[ \mathbf{A}_0 = \begin{pmatrix} 4 & 1 & 2 & -5 & 1 & 4 \\ 1 & 2 & 0 & 4 & 5 & 3 \\ 2 & 0 & 3 & -1 & 2 & 1 \\ -5 & 4 & -1 & 1 & 5 & 2 \\ 1 & 5 & 2 & 5 & -2 & 4 \\ 4 & 3 & 1 & 2 & 4 & 1 \end{pmatrix} \]
to symmetric tridiagonal form. Mathews sets this matrix twice: in Exercise 4 with the step subroutine and in Exercise 5 with a loop program. His solution to Exercise 4 is missing from the archive, so the steps below are computed here; his printout for Exercise 5 survives and agrees with them.
Steps 1–4. Four steps are needed. At each step \(x_{k+1}\) is the entry \((k+1, k)\) of \(\mathbf{A}_{k-1}\), and the new subdiagonal entry is \(-S\):
| \(k\) | \(x_{k+1}\) | \(S\) | \(R\) | \(c\) | new entry \((k+1, k)\) |
|---|---|---|---|---|---|
| 1 | \(1\) | \(\sqrt{47} \approx 6.855655\) | \(10.378406\) | \(0.680418\) | \(-6.855655\) |
| 2 | \(-2.554759\) | \(-2.924429\) | \(5.661007\) | \(1.314259\) | \(2.924429\) |
| 3 | \(-1.852266\) | \(-4.758240\) | \(7.931503\) | \(9.892871\) | \(4.758240\) |
| 4 | \(7.198901\) | \(7.994421\) | \(15.586008\) | \(2.319391\) | \(-7.994421\) |
The intermediate matrices are
\[ \mathbf{A}_1 \approx \begin{pmatrix} 4 & -6.855655 & 0 & 0 & 0 & 0 \\ -6.855655 & -0.148936 & -2.554759 & -1.271014 & 0.254203 & -0.587704 \\ 0 & -2.554759 & 1.838438 & -1.064127 & 0.536182 & -0.935679 \\ 0 & -1.271014 & -1.064127 & 8.580394 & 7.175530 & 0.903135 \\ 0 & 0.254203 & 0.536182 & 7.175530 & -3.173428 & 1.266086 \\ 0 & -0.587704 & -0.935679 & 0.903135 & 1.266086 & -2.096469 \end{pmatrix}, \]
\[ \mathbf{A}_2 \approx \begin{pmatrix} 4 & -6.855655 & 0 & 0 & 0 & 0 \\ -6.855655 & -0.148936 & 2.924429 & 0 & 0 & 0 \\ 0 & 2.924429 & 1.268511 & -1.852266 & -4.218333 & 1.189802 \\ 0 & 0 & -1.852266 & 8.245411 & 6.103051 & 1.325829 \\ 0 & 0 & -4.218333 & 6.103051 & -2.731037 & 0.654665 \\ 0 & 0 & 1.189802 & 1.325829 & 0.654665 & -1.633949 \end{pmatrix}, \]
\[ \mathbf{A}_3 \approx \begin{pmatrix} 4 & -6.855655 & 0 & 0 & 0 & 0 \\ -6.855655 & -0.148936 & 2.924429 & 0 & 0 & 0 \\ 0 & 2.924429 & 1.268511 & 4.758240 & 0 & 0 \\ 0 & 0 & 4.758240 & 2.664909 & 7.198901 & -3.476578 \\ 0 & 0 & 0 & 7.198901 & 0.939948 & -3.248054 \\ 0 & 0 & 0 & -3.476578 & -3.248054 & 0.275569 \end{pmatrix}, \]
and the fourth step gives
\[ \boxed{\ \mathbf{H} = \mathbf{A}_4 \approx \begin{pmatrix} 4 & -6.855655 & 0 & 0 & 0 & 0 \\ -6.855655 & -0.148936 & 2.924429 & 0 & 0 & 0 \\ 0 & 2.924429 & 1.268511 & 4.758240 & 0 & 0 \\ 0 & 0 & 4.758240 & 2.664909 & -7.994421 & 0 \\ 0 & 0 & 0 & -7.994421 & 3.358187 & 1.759360 \\ 0 & 0 & 0 & 0 & 1.759360 & -2.142670 \end{pmatrix}\ } \]
The entry \(-0.148936\) is exactly \(-\tfrac{7}{47}\), and \(-6.855655 = -\sqrt{47}\); the later entries have no short closed form.
The loop program (Mathews’ Exercise 5). Mathews’ “traditional” program does the same arithmetic with explicit loops and uses the fact that once columns \(1, \ldots, k - 1\) are reduced, only row and column \(k\) and the trailing block below and to the right of them change. At step \(k\) it computes \(\mathbf{W}\), \(\mathbf{V}\), \(c\) and \(\mathbf{Q}\) only in components \(k + 1, \ldots, n\), writes \(-S\) into positions \((k+1, k)\) and \((k, k+1)\) and zeros into the rest of column and row \(k\), and updates the trailing block by \(a_{jj} \leftarrow a_{jj} - 4q_jw_j\) and \(a_{ij} = a_{ji} \leftarrow a_{ij} - 2w_iq_j - 2q_iw_j\) for \(j > i\). Reimplemented in double precision, it reproduces the step algorithm’s \(\mathbf{H}\) to within \(5.3 \times 10^{-15}\), and Mathews’ printed \(\mathbf{A}_1\), \(\mathbf{A}_2\), \(\mathbf{A}_3\) and \(\mathbf{H}\) agree with the matrices above in every printed digit (he prints ten significant digits).
Verification. In 50-digit arithmetic, the entries of \(\mathbf{H}\) outside the tridiagonal band are below \(6 \times 10^{-51}\), and
| Invariant | \(\mathbf{A}_0\) | \(\mathbf{H}\) |
|---|---|---|
| characteristic polynomial | \(\lambda^6 - 9\lambda^5 - 125\lambda^4 + 662\lambda^3 + 5036\lambda^2 - 3305\lambda - 21448\) | the same \(\checkmark\) (eigenvalues agree to \(5 \times 10^{-50}\)) |
| trace | \(9\) | \(9\) \(\checkmark\) |
| sum of squared entries | \(331\) | \(331\) \(\checkmark\) |
| eigenvalues | \(12.302275,\ 9.328149,\ -7.411262,\ -5.311125,\ 2.225498,\ -2.133536\) | the same \(\checkmark\) |
Accumulating \(\mathbf{U} = \mathbf{P}_1\mathbf{P}_2\mathbf{P}_3\mathbf{P}_4\) and multiplying the eigenvectors of \(\mathbf{H}\) by \(\mathbf{U}\) gives eigenvectors of \(\mathbf{A}_0\) with residual \(\max|\mathbf{A}_0\mathbf{X} - \mathbf{X}\boldsymbol{\Lambda}| = 4.4 \times 10^{-15}\) in double precision.
Implementation Notes
- Never form \(\mathbf{P}_k\). Store \(\mathbf{W}\) and use (6)–(7); keep \(\mathbf{W}\) (or \(\mathbf{v}\)) for each step if eigenvectors are wanted, since \(\mathbf{U}\mathbf{y} = \mathbf{P}_1(\mathbf{P}_2(\cdots\mathbf{P}_{n-2}\mathbf{y}))\) can be applied one reflection at a time.
- Work on the trailing block. As in Mathews’ loop program, step \(k\) only needs rows and columns \(k, \ldots, n\), and symmetry halves the work again.
- Choose the sign of \(S\) to match \(x_{k+1}\), use \(+1\) (never \(0\)) when \(x_{k+1} = 0\), and skip a step whose subcolumn is already zero (see the caution above).
- Set the created zeros explicitly. In floating point they come out as rounding noise (at most \(1.1 \times 10^{-15}\) in the three examples above).
- Nonsymmetric matrices. Without symmetry the left and right products no longer clear the same entries, but the same \(\mathbf{P}_k\) still make column \(k\) zero below the subdiagonal; the result is upper Hessenberg rather than tridiagonal. See Hessenberg Factorization and the QR method, whose iterations keep both forms.