Unit 9, lesson 49

QR, Normal Equations and Cholesky

Why forming the Gram matrix squares the condition number of a full-column-rank matrix, and how QR, normal equations, Cholesky, partial pivoting and the SVD fit different structures and ranks.

  • Video 49
  • Reliable Factorization Choices

Fitting a line to measured points is a least-squares problem, and two textbook routes solve it, the normal equations ATAx=ATbA^{\mathsf{T}}Ax = A^{\mathsf{T}}b and a QR factorization of AA. When the columns of AA are independent they give the same answer in exact arithmetic, but rounded arithmetic can separate them. The columns (1,1,1)(1, 1, 1) and (1,1+ε,1−ε)(1, 1 + \varepsilon, 1 - \varepsilon) are independent for every ε≠0\varepsilon \ne 0, yet for ε=10−4\varepsilon = 10^{-4} their Gram matrix becomes singular once its entries are rounded to six significant digits. This lesson explains that loss with the condition number of a rectangular matrix and turns it into a choice between QR, Cholesky, pivoted elimination and the SVD, made from the structure and the rank of the problem.

Key terms

Condition number of a rectangular matrix

Definition Let A∈Fm×nA \in \mathbb{F}^{m \times n}, where F\mathbb{F} is R\mathbb{R} or C\mathbb{C}, have full column rank, rank⁡A=n\operatorname{rank} A = n, which forces m≥nm \ge n. Then all p=min⁡(m,n)=np = \min(m, n) = n singular values are positive, σ1≥⋯≥σn>0\sigma_1 \ge \cdots \ge \sigma_n > 0, the square matrix A∗AA^{*}A is invertible, and the pseudoinverse is A+=(A∗A)−1A∗A^{+} = (A^{*}A)^{-1}A^{*}. It satisfies A+A=InA^{+}A = I_n, and its singular values are 1/σn≥⋯≥1/σ11/\sigma_n \ge \cdots \ge 1/\sigma_1, so ∥A+∥2=1/σn\lVert A^{+} \rVert_2 = 1/\sigma_n. The two-norm condition number of AA is

κ2(A)=∥A∥2 ∥A+∥2=σ1σn.\kappa_2(A) = \lVert A \rVert_2 \, \lVert A^{+} \rVert_2 = \frac{\sigma_1}{\sigma_n}.

For a nonsingular square matrix the pseudoinverse is A−1A^{-1}, and this is the condition number of the earlier lessons. Because m≥nm \ge n, the extreme singular values are the largest and the smallest stretch of AA, that is σ1=max⁡∥Ax∥2\sigma_1 = \max \lVert Ax \rVert_2 and σn=min⁡∥Ax∥2\sigma_n = \min \lVert Ax \rVert_2 over unit vectors xx, so κ2(A)≥1\kappa_2(A) \ge 1. For a right-hand side b=Ax≠0b = Ax \ne 0 in the column space, a change δb\delta b moves the least-squares solution by δx=A+δb\delta x = A^{+}\delta b. Since ∥δx∥2≤∥δb∥2/σn\lVert \delta x \rVert_2 \le \lVert \delta b \rVert_2 / \sigma_n and ∥b∥2≤σ1∥x∥2\lVert b \rVert_2 \le \sigma_1 \lVert x \rVert_2,

∥δx∥2∥x∥2≤κ2(A) ∥δb∥2∥b∥2.\frac{\lVert \delta x \rVert_2}{\lVert x \rVert_2} \le \kappa_2(A) \, \frac{\lVert \delta b \rVert_2}{\lVert b \rVert_2}.

For a general bb the sensitivity of the least-squares solution also depends on the angle between bb and the column space, and when AA itself is perturbed and the residual is not small it can involve κ2(A)2\kappa_2(A)^2. So κ2(A)\kappa_2(A) measures the directional scaling of AA, not every error bound for every data set. The full-column-rank hypothesis is part of the definition. Dividing by the smallest positive singular value of a rank-deficient matrix describes a different problem, and an arbitrarily small change of AA can raise its rank and make ∥A+∥2\lVert A^{+} \rVert_2 jump. Here and below a tuple such as (1,1,1)(1, 1, 1) stands for a column vector.

In plain words A tall matrix with independent columns can stretch some directions more than others. Its condition number is the ratio of the largest stretch to the smallest, and for consistent data it bounds how much a relative change in bb can be magnified in the solution.

Example Take

A=[110110],ATA=[2112].\begin{gathered} A = \begin{bmatrix} 1 & 1 \\ 0 & 1 \\ 1 & 0 \end{bmatrix}, \\[0.4em] A^{\mathsf{T}}A = \begin{bmatrix} 2 & 1 \\ 1 & 2 \end{bmatrix}. \end{gathered}

The eigenvalues of ATAA^{\mathsf{T}}A are 33 and 11, so the singular values of AA are σ1=3\sigma_1 = \sqrt{3} and σ2=1\sigma_2 = 1, and κ2(A)=3\kappa_2(A) = \sqrt{3}. The pseudoinverse is

A+=(ATA)−1AT=13[1−1212−1],\begin{aligned} A^{+} &= (A^{\mathsf{T}}A)^{-1}A^{\mathsf{T}} \\[0.4em] &= \frac{1}{3}\begin{bmatrix} 1 & -1 & 2 \\ 1 & 2 & -1 \end{bmatrix}, \end{aligned}

and multiplying gives A+A=I2A^{+}A = I_2, with ∥A+∥2=1/σ2=1\lVert A^{+} \rVert_2 = 1/\sigma_2 = 1. A change of rank behaves very differently. The matrix with columns (1,0,0)(1, 0, 0) and (0,δ,0)(0, \delta, 0) has κ2=1/δ\kappa_2 = 1/\delta for 0<δ≤10 < \delta \le 1, which grows without bound as δ→0\delta \to 0. At δ=0\delta = 0 the rank drops to 11 and the norm of the pseudoinverse falls back to 11, so an arbitrarily small change in the data moves ∥A+∥2\lVert A^{+} \rVert_2 between 11 and 1/δ1/\delta.

Conditioning of the Gram matrix

Definition Let A∈Fm×nA \in \mathbb{F}^{m \times n} have full column rank, where F\mathbb{F} is R\mathbb{R} or C\mathbb{C}, and let its columns be a1,…,ana_1, \dots, a_n. The Gram matrix A∗AA^{*}A has entries (A∗A)ij=⟨ai,aj⟩=ai∗aj(A^{*}A)_{ij} = \langle a_i, a_j \rangle = a_i^{*}a_j. It is Hermitian positive definite, since x∗A∗Ax=∥Ax∥22>0x^{*}A^{*}Ax = \lVert Ax \rVert_2^2 > 0 for x≠0x \ne 0. Its eigenvalues, which are also its singular values, are σ12≥⋯≥σn2>0\sigma_1^2 \ge \cdots \ge \sigma_n^2 > 0, and

κ2(A∗A)=κ2(A)2.\kappa_2(A^{*}A) = \kappa_2(A)^2.

For the proof take a thin SVD A=UΣV∗A = U\Sigma V^{*}, where U∈Fm×nU \in \mathbb{F}^{m \times n} has orthonormal columns, Σ=diag⁡(σ1,…,σn)\Sigma = \operatorname{diag}(\sigma_1, \dots, \sigma_n) and V∈Fn×nV \in \mathbb{F}^{n \times n} is unitary. Since U∗U=InU^{*}U = I_n,

A∗A=VΣU∗UΣV∗=VΣ2V∗,A^{*}A = V\Sigma U^{*}U\Sigma V^{*} = V\Sigma^2 V^{*},

which is a unitary diagonalization with positive diagonal entries and therefore also an SVD of A∗AA^{*}A. The ratio of its extreme singular values is σ12/σn2\sigma_1^2/\sigma_n^2. The identity is exact and concerns the matrix of the normal equations. It does not claim that every normal-equations computation loses exactly twice as many digits as a QR computation. It says that the system being solved has condition number κ2(A)2\kappa_2(A)^2, which exceeds κ2(A)\kappa_2(A) whenever κ2(A)>1\kappa_2(A) > 1, and in floating point the entries of A∗AA^{*}A are also rounded before any solve begins.

In plain words Multiplying AA on the left by its conjugate transpose squares every stretch. A condition number of 10410^4 for AA becomes 10810^8 for A∗AA^{*}A, and small features of the columns can vanish when the products are rounded.

Example Take ε=10−4\varepsilon = 10^{-4} and the columns a1=(1,1,1)a_1 = (1, 1, 1) and a2=(1,1+ε,1−ε)a_2 = (1, 1 + \varepsilon, 1 - \varepsilon). Their inner products are ⟨a1,a1⟩=3\langle a_1, a_1 \rangle = 3, ⟨a1,a2⟩=3\langle a_1, a_2 \rangle = 3 and ⟨a2,a2⟩=3+2ε2\langle a_2, a_2 \rangle = 3 + 2\varepsilon^2, so the exact Gram matrix and its determinant are

G=[3333+2×10−8],det⁡G=6×10−8>0.\begin{gathered} G = \begin{bmatrix} 3 & 3 \\ 3 & 3 + 2 \times 10^{-8} \end{bmatrix}, \\[0.4em] \det G = 6 \times 10^{-8} > 0. \end{gathered}

Now carry out one precisely stated rounding step. Compute the entries exactly, then round each one once to six significant digits. The entry 3.000000023.00000002 becomes 3.000003.00000, so every rounded entry equals 33 and the rounded Gram matrix is singular. The columns survive the same rounding, since a2a_2 is stored as (1.00000,1.00010,0.999900)(1.00000, 1.00010, 0.999900), which still differs from a1a_1. The information was lost when the small quantity 2ε22\varepsilon^2 was added to a number of size 33. In terms of conditioning, the matrix A=[a1 a2]A = [a_1 \ a_2] has κ2(A)≈2.45×104\kappa_2(A) \approx 2.45 \times 10^4, so κ2(G)≈6.0×108\kappa_2(G) \approx 6.0 \times 10^8. This isolates one mechanism with exact arithmetic and an explicit rounding rule. It is not a measured comparison of two complete solvers.

Normal equations

Definition Let A∈Fm×nA \in \mathbb{F}^{m \times n} and b∈Fmb \in \mathbb{F}^m, where F\mathbb{F} is R\mathbb{R} or C\mathbb{C}. A vector x^\hat{x} minimizes ∥Ax−b∥2\lVert Ax - b \rVert_2 if and only if the residual r^=b−Ax^\hat{r} = b - A\hat{x} is orthogonal to every column of AA, that is A∗r^=0A^{*}\hat{r} = 0, or

A∗Ax^=A∗b.A^{*}A\hat{x} = A^{*}b.

These are the normal equations. They always have a solution, because the orthogonal projection of bb onto the column space has the form Ax^A\hat{x}. If A∗r^=0A^{*}\hat{r} = 0, then for every xx the vectors r^\hat{r} and A(x^−x)A(\hat{x} - x) are orthogonal, and Pythagoras gives

∥b−Ax∥22=∥r^∥22+∥A(x^−x)∥22.\begin{aligned} \lVert b - Ax \rVert_2^2 &= \lVert \hat{r} \rVert_2^2 \\[0.4em] &\quad + \lVert A(\hat{x} - x) \rVert_2^2. \end{aligned}

So x^\hat{x} is a minimizer, and xx is another minimizer exactly when Ax=Ax^Ax = A\hat{x}, in which case xx also solves the normal equations. If AA has full column rank, then A∗AA^{*}A is Hermitian positive definite and the least-squares solution x^=(A∗A)−1A∗b=A+b\hat{x} = (A^{*}A)^{-1}A^{*}b = A^{+}b is unique. The normal equations are mathematically exact. Their numerical price is that they replace AA by a matrix with condition number κ2(A)2\kappa_2(A)^2 and round the entries of A∗AA^{*}A and A∗bA^{*}b along the way.

In plain words The best fit leaves an error that is perpendicular to everything the columns can produce. Writing that perpendicularity once for each column gives a small square system in the same unknowns.

Example Fit a line y=x1+x2ty = x_1 + x_2 t to the points (t,y)=(0,1),(1,1),(2,2)(t, y) = (0, 1), (1, 1), (2, 2). Here

A=[101112],b=[112],A = \begin{bmatrix} 1 & 0 \\ 1 & 1 \\ 1 & 2 \end{bmatrix}, \qquad b = \begin{bmatrix} 1 \\ 1 \\ 2 \end{bmatrix},

and the normal equations are

[3335][x1x2]=[45].\begin{bmatrix} 3 & 3 \\ 3 & 5 \end{bmatrix} \begin{bmatrix} x_1 \\ x_2 \end{bmatrix} = \begin{bmatrix} 4 \\ 5 \end{bmatrix}.

Subtracting the first equation from the second gives 2x2=12x_2 = 1, so x2=1/2x_2 = 1/2, and then 3x1+3/2=43x_1 + 3/2 = 4 gives x1=5/6x_1 = 5/6. The fitted values are (5/6,4/3,11/6)(5/6, 4/3, 11/6), the residual is r^=(1/6,−1/3,1/6)\hat{r} = (1/6, -1/3, 1/6) and ∥r^∥22=1/6\lVert \hat{r} \rVert_2^2 = 1/6. As a check, the two entries of ATr^A^{\mathsf{T}}\hat{r} are 1/6−1/3+1/6=01/6 - 1/3 + 1/6 = 0 and 0−1/3+2/6=00 - 1/3 + 2/6 = 0.

Cholesky solve

Definition Let M∈Fn×nM \in \mathbb{F}^{n \times n} be Hermitian positive definite, where F\mathbb{F} is R\mathbb{R} or C\mathbb{C}. For F=R\mathbb{F} = \mathbb{R} this means that MM is symmetric and xTMx>0x^{\mathsf{T}}Mx > 0 for every x≠0x \ne 0. Then there is exactly one lower triangular L∈Fn×nL \in \mathbb{F}^{n \times n} with positive real diagonal entries such that

M=LL∗.M = LL^{*}.

This is the Cholesky factorization M=R∗RM = R^{*}R of the earlier lesson, written with L=R∗L = R^{*}. A Cholesky solve of Mx=bMx = b computes LL, solves Ly=bLy = b by forward substitution and then solves L∗x=yL^{*}x = y by back substitution. The pivots are positive, so no row exchanges are needed, and the factorization takes about half the arithmetic of a general LU factorization. The hypotheses matter. If MM is Hermitian but not positive definite, no such factorization exists, and the computation reaches a step where the number under the square root is zero or negative. Cholesky fits a system whose matrix is given as positive definite. Applied to the normal equations of a least-squares problem, it solves a system with condition number κ2(A)2\kappa_2(A)^2 and inherits the loss described above, however well the triangular steps themselves behave.

In plain words A positive definite matrix splits into a triangular factor times its conjugate transpose, and a solve becomes two triangular sweeps. Use it when positive definiteness is part of the given problem, not something you created by multiplying by A∗A^{*}.

Example For the normal-equations matrix above,

L=[3032],LLT=[3335].\begin{gathered} L = \begin{bmatrix} \sqrt{3} & 0 \\ \sqrt{3} & \sqrt{2} \end{bmatrix}, \\[0.4em] LL^{\mathsf{T}} = \begin{bmatrix} 3 & 3 \\ 3 & 5 \end{bmatrix}. \end{gathered}

Forward substitution in Ly=(4,5)Ly = (4, 5) gives y1=4/3y_1 = 4/\sqrt{3} and then 4+2 y2=54 + \sqrt{2}\,y_2 = 5, so y2=1/2y_2 = 1/\sqrt{2}. Back substitution in LTx=yL^{\mathsf{T}}x = y gives 2 x2=1/2\sqrt{2}\,x_2 = 1/\sqrt{2}, so x2=1/2x_2 = 1/2, and then 3(x1+x2)=4/3\sqrt{3}(x_1 + x_2) = 4/\sqrt{3}, so x1=5/6x_1 = 5/6, the same solution as before. The factor LTL^{\mathsf{T}} is exactly the triangular factor RR with positive diagonal in the QR factorization of the final card, because ATA=RTQ1TQ1R=RTRA^{\mathsf{T}}A = R^{\mathsf{T}}Q_1^{\mathsf{T}}Q_1R = R^{\mathsf{T}}R. Both routes reach the same triangle in exact arithmetic, but QR gets there without forming ATAA^{\mathsf{T}}A.

Partial pivoting

Definition Let A∈Fn×nA \in \mathbb{F}^{n \times n} be nonsingular, where F\mathbb{F} is R\mathbb{R} or C\mathbb{C}. Gaussian elimination with partial pivoting works through the columns k=1,…,n−1k = 1, \dots, n - 1. At step kk it chooses, among the entries of column kk on or below the diagonal of the current matrix, one of largest absolute value, swaps its row into row kk, and subtracts multiples ℓik=aik/akk\ell_{ik} = a_{ik}/a_{kk} of row kk from the rows below. Because AA is nonsingular, a nonzero candidate always exists, and every multiplier satisfies ∣ℓik∣≤1\lvert \ell_{ik} \rvert \le 1. The result is

PA=LU,PA = LU,

with PP a permutation matrix, LL unit lower triangular with entries of absolute value at most 11, and UU upper triangular and nonsingular. To solve Ax=bAx = b, apply the same row swaps to bb, then solve Ly=PbLy = Pb and Ux=yUx = y. Partial pivoting controls the multipliers at each step, but it does not keep the later entries small in general. Entries can grow by a factor up to 2n−12^{n-1} relative to the largest entry of AA, and some matrices reach that factor. It also cannot repair an ill-conditioned matrix, because κ(A)\kappa(A) belongs to the problem, not to the method.

In plain words Divide by the entry of largest size available in the column, never by a tiny one when a large one sits below it. That keeps every multiplier at most 11 in size. It is a safeguard for the algorithm, not a cure for a sensitive problem.

Example Let ε=10−4\varepsilon = 10^{-4} and solve

[ε111]x=[12].\begin{bmatrix} \varepsilon & 1 \\ 1 & 1 \end{bmatrix} x = \begin{bmatrix} 1 \\ 2 \end{bmatrix}.

The exact solution is x=(10000/9999,9998/9999)≈(1.0001,0.9999)x = (10000/9999, 9998/9999) \approx (1.0001, 0.9999), and the matrix is well conditioned, with κ2≈2.62\kappa_2 \approx 2.62. Suppose every computed result is rounded to three significant digits. Without a swap the multiplier is 1/ε=1041/\varepsilon = 10^4. The new second row has 1−104=−99991 - 10^4 = -9999, stored as −1.00×104-1.00 \times 10^4, and right side 2−104=−99982 - 10^4 = -9998, also stored as −1.00×104-1.00 \times 10^4. So x2=1.00x_2 = 1.00 and then x1=(1−x2)/ε=0x_1 = (1 - x_2)/\varepsilon = 0, which is completely wrong. With the swap the pivot is 11 and the multiplier is ε=10−4\varepsilon = 10^{-4}. The new entries 1−10−41 - 10^{-4} and 1−2×10−41 - 2 \times 10^{-4} are both stored as 1.001.00, so x2=1.00x_2 = 1.00 and x1=2−1.00=1.00x_1 = 2 - 1.00 = 1.00, correct to three digits. The problem was harmless, and the damage came from the tiny pivot.

Rank-aware method choice

Definition Rank-aware method choice selects a solver from the stated task, its structure and what is known about its rank, rather than from the shortest formula. For real or complex data the standard choices are these.

  • For a general nonsingular square system Ax=bAx = b, use Gaussian elimination with partial pivoting.
  • For a square system whose matrix is given as Hermitian positive definite, use a Cholesky solve.
  • For least squares with A∈Fm×nA \in \mathbb{F}^{m \times n} of full column rank, use Householder QR. A reduced factorization A=Q1RA = Q_1R, with Q1∈Fm×nQ_1 \in \mathbb{F}^{m \times n} having orthonormal columns and R∈Fn×nR \in \mathbb{F}^{n \times n} upper triangular and nonsingular, gives the solution of Rx^=Q1∗bR\hat{x} = Q_1^{*}b by back substitution, and in exact arithmetic the minimal residual satisfies ∥b−Ax^∥22=∥b∥22−∥Q1∗b∥22\lVert b - A\hat{x} \rVert_2^2 = \lVert b \rVert_2^2 - \lVert Q_1^{*}b \rVert_2^2. In floating point this difference loses digits when the residual is small, and computing the vector b−Q1(Q1∗b)b - Q_1(Q_1^{*}b) directly is more accurate. The method works with AA itself, whose condition number is κ2(A)\kappa_2(A), and never forms A∗AA^{*}A.
  • When the rank is in doubt, use column-pivoted QR, which can help expose independent columns, or the SVD A=∑i=1pσiuivi∗A = \sum_{i=1}^{p} \sigma_i u_i v_i^{*} with p=min⁡(m,n)p = \min(m, n), together with a tolerance τ\tau set by the size of the data errors and the units. The numerical rank is the number of singular values σi>τ\sigma_i > \tau, and directions with σi≤τ\sigma_i \le \tau are dropped or regularized.

One way to drop them is the truncated SVD solution

xτ=∑σi>τui∗bσi vi.x_\tau = \sum_{\sigma_i > \tau} \frac{u_i^{*}b}{\sigma_i} \, v_i.

Even a backward stable method only returns the exact solution of a nearby problem, so its forward error still depends on the conditioning of the problem itself. No factorization recovers information that the data never resolved.

In plain words Start from what the problem gives you. Given positive definiteness, use it. Given a tall matrix of full rank, keep it and use orthogonal factors. Given doubtful rank, compare the singular values with the noise before trusting any solution.

Example For the line fit above, one reduced QR factorization has

Q1=[1/3−1/21/301/31/2],R=[3302].\begin{gathered} Q_1 = \begin{bmatrix} 1/\sqrt{3} & -1/\sqrt{2} \\ 1/\sqrt{3} & 0 \\ 1/\sqrt{3} & 1/\sqrt{2} \end{bmatrix}, \\[0.4em] R = \begin{bmatrix} \sqrt{3} & \sqrt{3} \\ 0 & \sqrt{2} \end{bmatrix}. \end{gathered}

The columns of Q1Q_1 are orthonormal and Q1R=AQ_1R = A. Then Q1Tb=(4/3,1/2)Q_1^{\mathsf{T}}b = (4/\sqrt{3}, 1/\sqrt{2}), and back substitution gives 2 x2=1/2\sqrt{2}\,x_2 = 1/\sqrt{2} and 3 x1+3 x2=4/3\sqrt{3}\,x_1 + \sqrt{3}\,x_2 = 4/\sqrt{3}, so x^=(5/6,1/2)\hat{x} = (5/6, 1/2) again. The residual formula gives 6−(16/3+1/2)=1/66 - (16/3 + 1/2) = 1/6, which matches ∥r^∥22\lVert \hat{r} \rVert_2^2. This matrix is mild, with κ2(A)=(4+10)/6≈2.92\kappa_2(A) = (4 + \sqrt{10})/\sqrt{6} \approx 2.92 and κ2(ATA)≈8.55\kappa_2(A^{\mathsf{T}}A) \approx 8.55, so both routes do well. For the nearly dependent columns of the Gram example, QR works with κ2(A)≈2.45×104\kappa_2(A) \approx 2.45 \times 10^4 while the normal equations work with about 6.0×1086.0 \times 10^8.

Check yourself

  1. A matrix A∈R100×3A \in \mathbb{R}^{100 \times 3} has full column rank and singular values 2020, 22 and 1/21/2. Find κ2(A)\kappa_2(A), the eigenvalues of ATAA^{\mathsf{T}}A and κ2(ATA)\kappa_2(A^{\mathsf{T}}A). What changes if the smallest singular value is 00 instead?
Show the answer

The condition number is κ2(A)=20/(1/2)=40\kappa_2(A) = 20/(1/2) = 40. The eigenvalues of ATAA^{\mathsf{T}}A are the squares 400400, 44 and 1/41/4, so κ2(ATA)=400/(1/4)=1600=402\kappa_2(A^{\mathsf{T}}A) = 400/(1/4) = 1600 = 40^2.

If the smallest singular value is 00, then AA has rank 22, not full column rank. The matrix ATAA^{\mathsf{T}}A is singular, the least-squares solution is not unique, and κ2(A)\kappa_2(A) in the sense of this lesson is not defined. The ratio 20/2=1020/2 = 10 of the positive singular values describes a different problem, the minimum-norm solution under the assumption that the rank is exactly 22, and it is not a substitute.

  1. Two symmetric matrices are given, MM with rows (4,2)(4, 2) and (2,3)(2, 3), and NN with rows (1,2)(1, 2) and (2,1)(2, 1). Decide which of them has a Cholesky factorization, and use it to solve that system with right-hand side (2,5)(2, 5).
Show the answer

The matrix MM has leading principal minors 44 and 12−4=812 - 4 = 8, both positive, so it is positive definite. Its factor is built column by column, with ℓ11=4=2\ell_{11} = \sqrt{4} = 2, ℓ21=2/2=1\ell_{21} = 2/2 = 1 and ℓ22=3−1=2\ell_{22} = \sqrt{3 - 1} = \sqrt{2}, so

L=[2012],LLT=[4223].\begin{gathered} L = \begin{bmatrix} 2 & 0 \\ 1 & \sqrt{2} \end{bmatrix}, \\[0.4em] LL^{\mathsf{T}} = \begin{bmatrix} 4 & 2 \\ 2 & 3 \end{bmatrix}. \end{gathered}

Forward substitution in Ly=(2,5)Ly = (2, 5) gives y1=1y_1 = 1 and 1+2 y2=51 + \sqrt{2}\,y_2 = 5, so y2=22y_2 = 2\sqrt{2}. Back substitution in LTx=yL^{\mathsf{T}}x = y gives 2 x2=22\sqrt{2}\,x_2 = 2\sqrt{2}, so x2=2x_2 = 2, and 2x1+x2=12x_1 + x_2 = 1, so x1=−1/2x_1 = -1/2. Check that M(−1/2,2)=(−2+4,−1+6)=(2,5)M(-1/2, 2) = (-2 + 4, -1 + 6) = (2, 5).

The matrix NN has determinant 1−4=−31 - 4 = -3 and eigenvalues 33 and −1-1, so it is symmetric but not positive definite. The algorithm shows the failure directly. It gives ℓ11=1\ell_{11} = 1 and ℓ21=2\ell_{21} = 2, and then needs ℓ222=1−4=−3\ell_{22}^2 = 1 - 4 = -3, which no real number satisfies. Symmetry alone is not enough, and a system with NN calls for another method, such as elimination with partial pivoting.

  1. Choose a method for each task and name the property of the data that justifies it. (a) Solve Mx=bMx = b for the nonsymmetric matrix MM with rows (1,2,1)(1, 2, 1), (4,1,0)(4, 1, 0) and (2,1,3)(2, 1, 3), and carry out the first pivot step. (b) Solve Kx=fKx = f for the exactly known matrix KK with rows (2,−1,0)(2, -1, 0), (−1,2,−1)(-1, 2, -1) and (0,−1,2)(0, -1, 2). (c) Fit y≈c0+c1ty \approx c_0 + c_1 t to five measurements taken at five different times. (d) Fit a model whose two measured columns are nearly parallel, with a noisy right-hand side.
Show the answer

(a) The matrix is not symmetric, so Cholesky does not apply, and det⁡M=−19≠0\det M = -19 \ne 0, so this is a general nonsingular system for partial pivoting. Column 11 has entries 11, 44 and 22. The largest in absolute value is 44, so rows 11 and 22 are swapped, in MM and in bb. The multipliers are 1/41/4 and 2/4=1/22/4 = 1/2, both at most 11, and the remaining rows become (0,7/4,1)(0, 7/4, 1) and (0,1/2,3)(0, 1/2, 3). The next pivot is 7/47/4, with multiplier 2/72/7.

(b) The matrix KK is symmetric with leading principal minors 22, 33 and 44, all positive, so it is positive definite and a Cholesky solve fits. Its pivots are 22, 3/23/2 and 4/34/3, and the diagonal of LL holds their square roots.

(c) The design matrix has the columns (1,…,1)(1, \dots, 1) and (t1,…,t5)(t_1, \dots, t_5). They are independent because the times differ, so the matrix has full column rank and Householder QR fits. Forming the normal equations would square the condition number. For times 1000,1001,…,10041000, 1001, \dots, 1004 the design matrix has κ2≈7.1×105\kappa_2 \approx 7.1 \times 10^5, while its Gram matrix has κ2≈5.0×1011\kappa_2 \approx 5.0 \times 10^{11}.

(d) Full rank cannot be taken for granted here. Compute the SVD, or a column-pivoted QR, and compare the small singular value with a tolerance set by the noise level and the units. If it lies below the tolerance, the data do not determine the combination of coefficients along that singular direction, and it must be dropped, as in the truncated SVD solution, or regularized. If it lies well above the tolerance, full rank is trustworthy and QR is appropriate. No method can recover a combination that the measurements never resolved.

How this lesson connects