Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Further factorisations: pivoted QR, RQ, Hessenberg, real Schur, LDLᵀ and polar

ProblemFactorise a matrix into structured pieces: with column pivoting, , (Hessenberg), (real Schur), for symmetric indefinite , (polar); and compute principal angles between subspaces and general matrix functions
Devised byAlston Householder (1958), reflections; Peter Businger and Gene Golub (1965), column pivoting; James Bunch and Linda Kaufman (1977), symmetric indefinite pivoting; Issai Schur (1909); Beresford Parlett (1976), the Schur-Parlett recurrence; Camille Jordan (1875) and Åke Björck and Gene Golub (1973), principal angles; Léon Autonne (1902), the polar decomposition
AccuracyAgrees with SciPy (LAPACK) entry by entry to relative, factor for factor and pivot for pivot
CostQR, RQ: operations, plus as much again to form ; Hessenberg: , plus for ; real Schur: about ; : ; polar and angles: one or two SVDs; funm: a Schur form and
Read firstQR factorisation, Symmetric and general eigensolvers, The singular value decomposition
APIqr, rq, hessenberg, schur_real, ldl, polar, subspace_angles, funm

Overview

The earlier entries of this chapter use these factorisations internally: Householder QR for least squares, the Hessenberg and Schur forms inside the eigensolvers, the SVD for ranks and pseudoinverses. This entry exposes them, with SciPy’s interfaces and conventions:

  • QR with column pivoting, , chooses at each step the column of largest remaining norm. The diagonal of then decreases, and a gap in it reveals the numerical rank more cheaply than the SVD.
  • RQ, with upper triangular, is QR applied from the other side. It appears in camera calibration, where a projection matrix splits into intrinsic (triangular) and rotation factors, and in generalised eigenvalue algorithms.
  • The Hessenberg form , zero below the first subdiagonal, is the first stage of every dense eigenvalue computation. It also makes cheap for many shifts , as in frequency responses: per shift instead of .
  • The real Schur form keeps real matrices real. is block upper triangular, with a block for each complex conjugate pair of eigenvalues.
  • The Bunch-Kaufman factorisation is to symmetric indefinite matrices what Cholesky is to definite ones. It costs half as much as LU and preserves symmetry, and its and pivots keep it stable where a plain would divide by small or zero diagonal entries.
  • The polar decomposition is the matrix analogue of : is the orthogonal matrix nearest to , and is a symmetric positive semi-definite “stretch”.
  • Principal angles measure how far apart two subspaces are. funm evaluates any analytic function of a matrix.

Where it is used

These less famous factorisations are the building blocks of the main algorithms.

  • Pivoted QR. Rank-revealing least squares, and choosing the most informative columns (variables or sensors).
  • Hessenberg and Schur forms. Intermediate steps of the eigenvalue algorithm, and the way matrix functions are evaluated.
  • LDL and polar decompositions. Solving symmetric indefinite systems that arise in optimisation; the polar decomposition separates a deformation into a rotation and a stretch in continuum mechanics and robotics.

History

Alston Householder (1958) introduced the reflections that bear his name, and they replaced Gram-Schmidt and Givens rotations in most dense codes. Peter Businger and Gene Golub (1965) added column pivoting to make QR reveal rank. Issai Schur (1909) proved that every square matrix is unitarily similar to a triangular one, and the real quasi-triangular variant became the output of Francis’s QR algorithm (1961) in EISPACK (1974) and LAPACK (1992). LAPACK’s lanv2 (1990s) fixed a standard form for the blocks, so that results are reproducible.

For symmetric indefinite systems, James Bunch and Beresford Parlett (1971) showed that pivots make symmetric elimination stable. Bunch and Linda Kaufman (1977) found a strategy that examines only two columns per step, with growth factor bounded by , and it is what LAPACK’s sytrf uses. Léon Autonne (1902) stated the polar decomposition for matrices. Camille Jordan (1875) defined principal angles, and Åke Björck and Gene Golub (1973) gave the SVD algorithm that computes them. Beresford Parlett (1976) derived the recurrence for on a triangular that funm uses, and Philip Davies and Nicholas Higham (2003) blocked it for close eigenvalues.

The idea

Householder reflectors and LAPACK’s sign convention

A Householder reflector maps a vector onto . For real data, is symmetric and orthogonal with , and . The sign is a choice: taking with the sign opposite to avoids cancellation when forming . LAPACK’s larfg makes this choice, normalises , and for complex data makes real, using a non-Hermitian with complex :

Every factorisation built from such reflectors is unique once these choices are fixed. The library makes exactly LAPACK’s choices, so its and agree with SciPy’s entry by entry, not just up to the signs of columns. For a complex matrix, even the last step, which has nothing left to eliminate, still reflects, so as to make the last diagonal entry of (or subdiagonal entry of ) real.

QR with column pivoting

At step , the column of the trailing submatrix with the largest norm is swapped into position before the reflector is computed. The norms are not recomputed from scratch: removing the first entry of each column updates them, . When cancellation has eaten most of a norm’s digits, the norm is recomputed (LAPACK’s test: when the updated norm has fallen below times its last computed value). The pivoting gives . For a matrix of rank , drops to the level of rounding errors at .

RQ

RQ processes rows from the bottom. The last row is reflected onto its last entry, by a reflector applied from the right; then the row above onto its next-to-last entry, and so on. After steps, , so with . For a complex matrix the reflector acts on the conjugated row, as in LAPACK’s gerq2.

The Hessenberg form

Reflector zeros column below the subdiagonal. Because it is applied on both sides, , the zeros already made are not destroyed, so the similarity preserves eigenvalues. reflectors (one more for complex data) reach upper Hessenberg form, . A matrix that is the identity plus a low-rank term, for example, has a Hessenberg form with zero subdiagonal entries early on. The remaining reflectors are then determined by rounding errors, and two correct implementations may differ there.

The real Schur form and its standard 2 × 2 blocks

For a real matrix, the QR algorithm with double shifts converges to a quasi-triangular with blocks (real eigenvalues) and blocks (complex pairs). A block can be rotated into infinitely many shapes, so LAPACK fixes one with lanv2. A rotation makes the two diagonal entries equal, and then the off-diagonal entries have opposite signs, so that the eigenvalues are

If the block’s eigenvalues turn out to be real, the same routine triangularises it instead. The library standardises the blocks of its Schur form with a port of lanv2, updating the rest of and with the same rotation.

Bunch-Kaufman pivoting

Symmetric Gaussian elimination, with diagonal, fails on , and is unstable whenever a pivot is small. Row exchanges would destroy the symmetry. Bunch and Kaufman allow blocks in instead, and choose at each step between three options, with . Let be the largest off-diagonal entry in column , in row , and the largest off-diagonal entry in row and column . Then:

  • if , or : a pivot ;
  • else if : swap into position and take a pivot;
  • else: swap into position , and take the pivot .

This value of balances the element growth of two steps against one step. The cost stays at , half that of LU. SciPy returns with its rows permuted back to the original order, so that holds directly, together with the permutation perm that makes L[perm] triangular. The library does the same.

Polar decomposition and principal angles

From the SVD : and (or for ). is the nearest matrix with orthonormal columns to , in both the Frobenius and spectral norms. That is the solution of the orthogonal Procrustes problem.

The principal angles between the column spaces of and have cosines equal to the singular values of , for orthonormal bases , . Cosines near 1 lose the small angles: cannot resolve . So, as Knyazev and Argentati (2002) recommend, angles whose cosine exceeds are computed from their sines instead, the singular values of .

Matrix functions by Schur-Parlett

If is a complex Schur form, then , and is upper triangular with . Since commutes with , equating the entries of gives the rest, one superdiagonal at a time:

Close eigenvalues make the denominators small, and the error grows like . funm returns that estimate, as SciPy’s does. For , and , the dedicated expm, sqrtm and logm are more accurate.

Algorithm

QR with column pivoting (LAPACK’s laqp2): with column norms , for :

  1. Swap the column of largest (the first, on ties) into position .
  2. Compute the reflector for column below the diagonal (larfg), and apply to the remaining columns.
  3. Downdate . Recompute from the column when this has lost more than half of the digits since it was last computed.

is formed by applying the reflectors to the identity in reverse order.

Bunch-Kaufman (sytf2, lower triangle): for , choose a or pivot as above. Swap rows and columns in the trailing submatrix, and eliminate: , with . Then advance by the block size. Record the interchanges as LAPACK does (positive for pivots, negative for ), and unpack them into , and perm as SciPy does.

Real Schur form: reduce to Hessenberg form, run the double-shift QR algorithm, and standardise each block with lanv2’s rotation, applied to the rows and columns of beyond the block and to .

Implementation

The reflector:

/// LAPACK's `larfg`: the reflector `H = I − τ v vᴴ`, `v = (1, x̂)`, with `Hᴴ (α, x) = (β, 0)` and
/// `β = −sign(Re α) ‖(α, x)‖` real. Overwrites `x` with `x̂` and returns `(β, τ)`; `τ = 0` (no
/// reflection) when `x = 0` and `α` is real.
fn larfg<T: Scalar>(alpha: T, x: &mut [T]) -> (T, T) {
    let xnorm = x.iter().map(|v| v.abs_sqr()).sum::<f64>().sqrt();
    if xnorm == 0.0 && alpha.im() == 0.0 {
        return (alpha, T::zero());
    }
    let norm = (alpha.abs_sqr() + xnorm * xnorm).sqrt();
    let beta = T::from_real(if alpha.re() >= 0.0 { -norm } else { norm });
    let tau = (beta - alpha) / beta;
    let scale = T::one() / (alpha - beta);
    x.iter_mut().for_each(|v| *v *= scale);
    (beta, tau)
}

QR with optional pivoting, and RQ:

/// The QR factorisation `A P = Q R` (SciPy's `qr`, with `pivoting` its `pivoting=True`): `Q` has
/// orthonormal columns, `R` is upper triangular (trapezoidal), and with pivoting the columns are
/// chosen in order of largest remaining norm, so that `|R₁₁| ≥ |R₂₂| ≥ …`, which reveals the rank.
pub fn qr<T: Scalar, S: Data<Elem = T>>(a: &ArrayBase<S, Ix2>, mode: QrMode, pivoting: bool) -> Result<QrFactors<T>> {
    let a = check_finite(a)?;
    let (m, n) = a.dim();
    let k = m.min(n);
    let (f, taus, permutation) = householder_qr(a, pivoting);
    let qcols = if mode == QrMode::Full { m } else { k };
    // Q = H₁ H₂ ⋯ H_k applied to the first columns of the identity (LAPACK's orgqr).
    let mut q = zeros::<T>(m, qcols);
    for j in 0..qcols.min(m) {
        q[(j, j)] = T::one();
    }
    for i in (0..k).rev() {
        let mut v = vec![T::one()];
        v.extend((i + 1..m).map(|r| f[(r, i)]));
        reflect_left(&mut q, &v, taus[i], i, 0..qcols);
    }
    let rrows = if mode == QrMode::Full { m } else { k };
    let r = Array2::from_shape_fn((rrows, n), |(i, j)| if j >= i { f[(i, j)] } else { T::zero() });
    Ok(QrFactors { q, r, permutation })
}
/// The RQ factorisation `A = R Q` (SciPy's `rq`, LAPACK's `gerq2`): `R` upper triangular
/// (trapezoidal, aligned to the right), `Q` with orthonormal rows. Each step reflects a row,
/// from the last upwards, onto its own last allowed column. Returns `(R, Q)`.
pub fn rq<T: Scalar, S: Data<Elem = T>>(a: &ArrayBase<S, Ix2>, mode: QrMode) -> Result<(Array2<T>, Array2<T>)> {
    let mut a = check_finite(a)?;
    let (m, n) = a.dim();
    let k = m.min(n);
    let mut reflectors: Vec<(Vec<T>, T)> = Vec::with_capacity(k);
    for i in (0..k).rev() {
        let (r, c) = (m - k + i, n - k + i);
        // The conjugated row segment is reflected onto its last entry.
        let alpha = a[(r, c)].conj();
        let mut x: Vec<T> = (0..c).map(|j| a[(r, j)].conj()).collect();
        let (beta, tau) = larfg(alpha, &mut x);
        let mut v = x.clone();
        v.push(T::one());
        // A[0..r, 0..=c] ← A[0..r, 0..=c] H.
        reflect_right(&mut a, &v, tau, 0..r, 0);
        a[(r, c)] = beta;
        for j in 0..c {
            a[(r, j)] = T::zero();
        }
        reflectors.push((v, tau));
    }
    reflectors.reverse(); // reflectors[i] is H(i), acting on columns 0..=n−k+i
    // Q = H(1)ᴴ H(2)ᴴ ⋯ H(k)ᴴ as an n × n matrix (LAPACK's orgrq).
    let mut q = eye::<T>(n);
    for (v, tau) in &reflectors {
        reflect_right(&mut q, v, tau.conj(), 0..n, 0);
    }
    // R occupies the last min(m, n) "diagonals": R[i, j] = 0 for j < i + n − m.
    let r_full = Array2::from_shape_fn((m, n), |(i, j)| if j as isize >= i as isize + n as isize - m as isize { a[(i, j)] } else { T::zero() });
    if mode == QrMode::Economic && m <= n {
        return Ok((r_full.slice(s![.., n - m..]).to_owned(), q.slice(s![n - m.., ..]).to_owned()));
    }
    Ok((r_full, q))
}

The standard form of a block:

/// LAPACK's `lanv2`: the rotation `[c −s; s c]` that brings a real 2 × 2 block to standard form,
/// `[a b; c d] = R [a' b'; c' d'] Rᵀ`, where the new block is upper triangular when its eigenvalues
/// are real, and otherwise has `a' = d'` and `b' c' < 0`. Returns `(a', b', c', d', cs, sn)`.
fn lanv2(mut a: f64, mut b: f64, mut c: f64, mut d: f64) -> (f64, f64, f64, f64, f64, f64) {
    let eps = f64::EPSILON;
    let sign = |x: f64, y: f64| if y >= 0.0 { x.abs() } else { -x.abs() };
    let (mut cs, mut sn);
    if c == 0.0 {
        cs = 1.0;
        sn = 0.0;
    } else if b == 0.0 {
        cs = 0.0;
        sn = 1.0;
        std::mem::swap(&mut a, &mut d);
        b = -c;
        c = 0.0;
    } else if a - d == 0.0 && b.signum() != c.signum() {
        cs = 1.0;
        sn = 0.0;
    } else {
        let temp = a - d;
        let mut p = 0.5 * temp;
        let bcmax = b.abs().max(c.abs());
        let bcmis = b.abs().min(c.abs()) * b.signum() * c.signum();
        let scale = p.abs().max(bcmax);
        let mut z = p / scale * p + bcmax / scale * bcmis;
        if z >= 4.0 * eps {
            // Real eigenvalues: make the block upper triangular.
            z = p + sign(scale.sqrt() * z.sqrt(), p);
            a = d + z;
            d -= bcmax / z * bcmis;
            let tau = c.hypot(z);
            cs = z / tau;
            sn = c / tau;
            b -= c;
            c = 0.0;
        } else {
            // Complex or nearly equal real eigenvalues: equalise the diagonal.
            let sigma = b + c;
            let tau = sigma.hypot(temp);
            cs = (0.5 * (1.0 + sigma.abs() / tau)).sqrt();
            sn = -(p / (tau * cs)) * sign(1.0, sigma);
            let (aa, bb, cc, dd) = (a * cs + b * sn, -a * sn + b * cs, c * cs + d * sn, -c * sn + d * cs);
            a = aa * cs + cc * sn;
            b = bb * cs + dd * sn;
            c = -aa * sn + cc * cs;
            d = -bb * sn + dd * cs;
            let temp = 0.5 * (a + d);
            a = temp;
            d = temp;
            if c != 0.0 {
                if b != 0.0 {
                    if b.signum() == c.signum() {
                        // Real eigenvalues after all: triangularise.
                        let sab = b.abs().sqrt();
                        let sac = c.abs().sqrt();
                        p = sign(sab * sac, c);
                        let tau = 1.0 / (b + c).abs().sqrt();
                        a = temp + p;
                        d = temp - p;
                        b -= c;
                        c = 0.0;
                        let (cs1, sn1) = (sab * tau, sac * tau);
                        let t = cs * cs1 - sn * sn1;
                        sn = cs * sn1 + sn * cs1;
                        cs = t;
                    }
                } else {
                    b = -c;
                    c = 0.0;
                    let t = cs;
                    cs = -sn;
                    sn = t;
                }
            }
        }
    }
    (a, b, c, d, cs, sn)
}

Principal angles and the Schur-Parlett recurrence:

/// The principal angles between the column spaces of `A` and `B` (SciPy's `subspace_angles`),
/// largest first. With orthonormal bases `Q_A`, `Q_B`, the cosines are the singular values of
/// `Q_Aᴴ Q_B`; angles whose cosine exceeds `1/√2` are taken instead from the sines, the singular
/// values of `Q_B − Q_A Q_Aᴴ Q_B`, which keeps small angles accurate (Knyazev and Argentati, 2002).
pub fn subspace_angles<T: Scalar, S: Data<Elem = T>, S2: Data<Elem = T>>(a: &ArrayBase<S, Ix2>, b: &ArrayBase<S2, Ix2>) -> Result<Array1<f64>> {
    if a.nrows() != b.nrows() {
        return Err(LinalgError::Shape(format!("A and B must have the same number of rows, got {} and {}", a.nrows(), b.nrows())));
    }
    let qa = orth(a, None)?;
    let qb = orth(b, None)?;
    let qa_h_qb = matmul(&adjoint(&qa), &qb);
    let (_, sigma, _) = qa_h_qb.svd(false, false)?;
    let residual = if qa.ncols() >= qb.ncols() {
        let p = matmul(&qa, &qa_h_qb);
        Array2::from_shape_fn(qb.dim(), |(i, j)| qb[(i, j)] - p[(i, j)])
    } else {
        let p = matmul(&qb, &adjoint(&qa_h_qb));
        Array2::from_shape_fn(qa.dim(), |(i, j)| qa[(i, j)] - p[(i, j)])
    };
    let use_sines = sigma.iter().any(|s| s * s >= 0.5);
    let mu_arcsin: Vec<f64> = if use_sines {
        let (_, sv, _) = residual.svd(false, false)?;
        sv.iter().map(|v| v.clamp(-1.0, 1.0).asin()).collect()
    } else {
        Vec::new()
    };
    let len = sigma.len();
    Ok(Array1::from_shape_fn(len, |i| {
        if sigma[i] * sigma[i] >= 0.5 { mu_arcsin.get(i).copied().unwrap_or(0.0) } else { sigma[len - 1 - i].clamp(-1.0, 1.0).acos() }
    }))
}
/// `f(A)` for a scalar function `f` (SciPy's `funm`), by the Schur-Parlett method: with the complex
/// Schur form `A = Z T Zᴴ`, `F = f(T)` is upper triangular with `F_ii = f(T_ii)`, and the
/// commutation `T F = F T` determines the rest, superdiagonal by superdiagonal:
/// `F_ij = (T_ij (F_jj − F_ii) + Σ_{i<k<j} (T_ik F_kj − F_ik T_kj)) / (T_jj − T_ii)`.
/// Returns `(Z F Zᴴ, error estimate)`; the estimate is large when eigenvalues nearly coincide,
/// where this recurrence divides by small differences.
pub fn funm<T: Scalar, S: Data<Elem = T>>(a: &ArrayBase<S, Ix2>, f: impl Fn(C) -> C) -> Result<(Array2<C>, f64)> {
    let (t, z) = schur_complex(a)?;
    let n = t.nrows();
    let mut fm = Array2::<C>::zeros((n, n));
    for i in 0..n {
        fm[(i, i)] = f(t[(i, i)]);
    }
    let mut minden = if n > 0 { t[(0, 0)].norm() } else { 0.0 };
    for p in 1..n {
        for i in 0..n - p {
            let j = i + p;
            let mut s = t[(i, j)] * (fm[(j, j)] - fm[(i, i)]);
            for k in i + 1..j {
                s += t[(i, k)] * fm[(k, j)] - fm[(i, k)] * t[(k, j)];
            }
            let den = t[(j, j)] - t[(i, i)];
            if den != C::new(0.0, 0.0) {
                s /= den;
            }
            fm[(i, j)] = s;
            minden = minden.min(den.norm());
        }
    }
    let zh = z.t().mapv(|v| v.conj());
    let result = z.dot(&fm).dot(&zh);
    let tol = f64::EPSILON;
    let minden = if minden == 0.0 { tol } else { minden };
    // ‖triu(T, 1)‖₁, the largest column sum of the strictly upper part.
    let upper_norm = (0..n).map(|j| (0..j).map(|i| t[(i, j)].norm()).sum::<f64>()).fold(0.0, f64::max);
    let mut err = 1f64.min(tol.max(tol / minden * upper_norm));
    if result.iter().any(|v| !v.re.is_finite() || !v.im.is_finite()) {
        err = f64::INFINITY;
    }
    Ok((result, err))
}
  • All the functions take real or complex matrices, except schur_real, which is for real ones. The complex Schur form is schur_complex.
  • The Bunch-Kaufman code (ldl in crates/linalg/src/factorizations.rs) has the lower and upper variants, Hermitian and complex symmetric. Pivot sizes are compared with for complex entries, as LAPACK does.
  • The routines are unblocked, as LAPACK is for matrices up to a few dozen columns, where it gives the same results as its blocked code. For large matrices LAPACK’s blocked versions are faster, and differ in rounding.
  • qr returns the permutation as a list. Column of is column permutation[j] of .

In practice

The references are from SciPy 1.17.1, written by book/generator/data/make_decomp_refs.py. The test matrices are built from a formula, , in real and complex, tall, square and wide shapes:

Table 7.14. Further factorisations against SciPy.

functiontest matriceslargest difference from SciPy (relative to the largest entry)
qr (full and economic)square, tall, wide and complex matrices4e-15
qr with column pivotingthe same; permutations identical4e-15
rq (full and economic)the same6e-15
polar (right and left)the same6e-15
all four, a 6 × 6 matrix of rank 3the parts determined by the matrix: R, P, the first 3 pivots and columns of Q1e-15
hessenberg6 × 6 real, 5 × 5 complex, 30 × 30 real8e-13
schur_real: eigenvalues of the blocks6 × 6 and 30 × 30 real3e-14
schur_real: ‖Z T Zᵀ − A‖ / max |A|the same (2 × 2 blocks standardised)3e-15
ldl (lower and upper)definite, indefinite, zero-diagonal, Hermitian and complex symmetric; 13 2 × 2 pivots6e-16
subspace_angles (relative)real and complex subspaces2e-15
subspace_angles, angles near 10⁻⁷ (relative)a slightly perturbed subspace1e-8
funmexp, sin and x³ of a 6 × 6 real matrix; exp of a 5 × 5 complex one8e-15

Every factor agrees with SciPy’s to rounding error. That includes the pivot sequences of QR and of Bunch-Kaufman, whose tests use 13 pivots. For a rank-deficient matrix, the columns of beyond the rank, and the order in which the remaining columns are pivoted, depend on rounding errors of size , and they differ between any two implementations. The comparison is restricted there to what the matrix determines: in QR, in the polar decomposition, and the leading pivots. The Schur forms are compared by their eigenvalues and by reconstruction, since the order of the eigenvalues along the diagonal depends on the course of the QR iteration. The angles near agree to relative, which is the accuracy to which the data determine them.

A first test matrix built from alone showed what can go wrong. That formula has rank 2, so with added every Hessenberg form had zero subdiagonal entries after two steps, and every RQ of a tall matrix was degenerate. The two libraries agreed on the reconstruction but not on the factors. The factors were not unique, so neither was wrong.

Strengths

  • Identical conventions to SciPy and LAPACK, including signs, pivots and the standard form of Schur blocks, so results can be compared, or ported, entry by entry.
  • Real and complex matrices, and both triangles for ldl.
  • Small principal angles accurate to relative precision, from the sines.

Weaknesses

  • Unblocked algorithms: for matrices with hundreds of rows, LAPACK’s blocked versions are several times faster.
  • funm divides by eigenvalue differences, so it fails for close or repeated eigenvalues (the error estimate says so). The block Schur-Parlett algorithm of Davies and Higham is not implemented.
  • schur_real has no option to sort the eigenvalues (SciPy’s sort), and there is no QZ for pencils yet.

Exercises

  1. Show that with and from larfg satisfies , and that is unitary. When is it Hermitian?
  2. Factorise by Bunch-Kaufman. Why does with diagonal fail?
  3. Show that the eigenvalues of are , and hence complex when .
  4. Use pivoted QR to find the rank of the rank-3 matrix of the test table. How large is ?
  5. Show that in the polar decomposition minimises over matrices with orthonormal columns.
  6. Compute the principal angles between the planes and in , for . What would the cosine formula alone give?
Hints and answers
  1. , and with this is . Then , and , which leaves . Unitarity: reduces to , which holds for these and . is Hermitian when is real, in particular for all real data.
  2. The diagonal is zero, so the first pivot would be zero. Bunch-Kaufman finds , and , so it takes the whole matrix as one block: , .
  3. The characteristic polynomial is .
  4. , and : the rank is 3. The pivots beyond the rank depend on these rounding-level norms.
  5. . With , , with equality for .
  6. The angles are 0 (along the axis) and . The cosine of the second is , which rounds to 1, so the cosine formula gives 0. The sine formula gives to full precision.

Further reading

  • G. H. Golub and C. F. Van Loan, Matrix Computations, 4th ed., Johns Hopkins University Press, 2013: chapters 4 (symmetric indefinite systems), 5 (QR with pivoting), 6 (principal angles), 7 (Hessenberg and Schur forms) and 9 (Schur-Parlett).
  • P. Businger and G. H. Golub, “Linear least squares solutions by Householder transformations”, Numerische Mathematik 7 (1965) 269–276.
  • J. R. Bunch and L. Kaufman, “Some stable methods for calculating inertia and solving symmetric linear systems”, Mathematics of Computation 31 (1977) 163–179.
  • B. N. Parlett, “A recurrence among the elements of functions of triangular matrices”, Linear Algebra and its Applications 14 (1976) 117–121.
  • Å. Björck and G. H. Golub, “Numerical methods for computing angles between linear subspaces”, Mathematics of Computation 27 (1973) 579–594.
  • A. V. Knyazev and M. E. Argentati, “Principal angles between subspaces in an A-based scalar product”, SIAM Journal on Scientific Computing 23 (2002) 2008–2040.
  • N. J. Higham, Functions of Matrices: Theory and Computation, SIAM, 2008: chapter 8 (the polar decomposition) and chapter 9 (Schur-Parlett).
  • P. I. Davies and N. J. Higham, “A Schur-Parlett algorithm for computing matrix functions”, SIAM Journal on Matrix Analysis and Applications 25 (2003) 464–485.
  • E. Anderson et al., LAPACK Users’ Guide, 3rd ed., SIAM, 1999.