Quiz: pivoting, norms and conditioning
Short questions to test your understanding of pivoting, norms and condition numbers. Try each on paper first, then open the answer.
Q1. Gaussian elimination without pivoting on \(\begin{pmatrix}10^{-20} & 1\\ 1 & 1\end{pmatrix}\mathbf x = \begin{pmatrix}1\\2\end{pmatrix}\) returns \(\mathbf x = (0, 1)\) instead of about \((1, 1)\). Is this matrix ill-conditioned?
What happens to the same system if you just swap the two equations?
No. Its condition number is about 2.6; with the rows swapped, elimination gives \((1, 1)\) to full precision. The failure is the algorithm’s: the multiplier \(10^{20}\) swamps row 2, so \(1 - 10^{20}\) and \(2 - 10^{20}\) both round to \(-10^{20}\) and the information in row 2 is lost. Elimination without pivoting is unstable.
Q2. State the rule of partial pivoting in one sentence. What does it guarantee about the multipliers?
Which entry of column \(k\) becomes the pivot?
Before eliminating column \(k\), swap rows so that the entry of largest absolute value in column \(k\), on or below the diagonal, becomes the pivot. Then every multiplier \(m = a_{ik}/a_{kk}\) has \(|m| \le 1\), so no row is scaled up and added to another, and rounding errors stay small. The swaps give \(PA = LU\).
Q3. For \(\mathbf v = (2, -6, 3)\), compute \(\|\mathbf v\|_1\), \(\|\mathbf v\|_2\) and \(\|\mathbf v\|_\infty\).
Sum of absolute values; square root of the sum of squares; largest absolute value.
\(\|\mathbf v\|_1 = 2 + 6 + 3 = 11\), \(\|\mathbf v\|_2 = \sqrt{4 + 36 + 9} = 7\), \(\|\mathbf v\|_\infty = 6\). As always, \(\|\mathbf v\|_\infty \le \|\mathbf v\|_2 \le \|\mathbf v\|_1\).
Q4. Compute \(\|A\|_1\) and \(\|A\|_\infty\) for \(A = \begin{pmatrix}1 & -3\\ 2 & 0.5\end{pmatrix}\).
1-norm: columns. \(\infty\)-norm: rows. Use absolute values.
Column sums \(|1| + |2| = 3\) and \(|-3| + |0.5| = 3.5\), so \(\|A\|_1 = 3.5\). Row sums \(1 + 3 = 4\) and \(2 + 0.5 = 2.5\), so \(\|A\|_\infty = 4\).
Q5. Two dyes with overlap \(c\) give \(A = \begin{pmatrix}1 & c\\ c & 1\end{pmatrix}\) and \(\kappa_2 = (1 + c)/(1 - c)\). What is \(\kappa\) for \(c = 0.8\)? With detector readings good to 3 significant digits, roughly how many digits of the unmixed abundances can you trust?
Digits left \(\approx\) digits in the data \(- \log_{10}\kappa\).
\(\kappa = 1.8/0.2 = 9\), \(\log_{10} 9 \approx 0.95\), so about \(3 - 1 = 2\) digits. With \(c = 0.95\) (\(\kappa = 39\)) it would be about 1.4 digits, and with \(c = 0.99\) (\(\kappa = 199\)) less than one.
Q6. True or false: “If my solver uses partial pivoting, the computed solution is accurate to about 16 digits.”
Pivoting makes the algorithm stable. Does it change the problem?
False. Partial pivoting makes the algorithm backward stable: the answer is the exact solution of a system within rounding distance of yours. The forward error can still be about \(\kappa\,\varepsilon\), so with \(\kappa = 10^{10}\) you have about 6 correct digits. And if \(\mathbf b\) comes from measurements, the error is about \(\kappa\) times the measurement error, however the system is solved.
Q7. You solve \(A\mathbf x = \mathbf b\) and find a relative residual \(\|\mathbf b - A\hat{\mathbf x}\|/\|\mathbf b\| = 10^{-16}\). kappa(A) is \(10^{12}\). How large can the relative error of \(\hat{\mathbf x}\) be? What does the small residual tell you?
Error \(\le \kappa \times\) residual.
Up to about \(10^{12} \times 10^{-16} = 10^{-4}\): only about 4 correct digits. The tiny residual says the solver worked (it is backward stable, as LU with partial pivoting should be); it does not say the answer is accurate. A small residual certifies a small error only when \(\kappa\) is small.
Q8. For the two-dye matrix with overlap 0.95, a perturbation \(\Delta\mathbf b = (0.01, -0.01)\) of \(\mathbf b = (1.95, 1.95)\) is amplified 39 times, but \(\Delta\mathbf b = (0.01, 0.01)\) is not amplified at all. Explain.
The eigenvectors of \(A\) are \((1, 1)\) (eigenvalue 1.95) and \((1, -1)\) (eigenvalue 0.05). Solving divides by the eigenvalue.
Solving \(A\mathbf x = \mathbf b\) divides each eigen-component of \(\mathbf b\) by its eigenvalue. \(\mathbf b\) and the second \(\Delta\mathbf b\) both lie along \((1, 1)\), so both are divided by 1.95 and their ratio is unchanged (factor 1). The first \(\Delta\mathbf b\) lies along \((1, -1)\) and is divided by 0.05, so it grows 1.95/0.05 = 39 times more than \(\mathbf b\) does. Anti-correlated detector errors are the dangerous ones: the detectors see the sum of the two dyes well, but their difference badly.
Q9. R gives kappa(A) \(= 39.95\) but kappa(A, exact = TRUE) \(= 39\). Which should you report, and does the difference matter?
What do you use \(\kappa\) for?
kappa(A) without exact = TRUE is a cheap estimate; exact = TRUE computes \(\sigma_{\max}/\sigma_{\min}\) from the singular values. For the digits rule (\(\log_{10} 39 = 1.59\) vs \(\log_{10} 39.95 = 1.60\)) the difference is irrelevant; the estimate is usually within a small factor. Use the exact value for small matrices if you want to quote it, the estimate (or 1/rcond(A)) for large ones. In Python, np.linalg.cond(A) is exact (2-norm).
Q10. A spectral panel has \(\kappa = 500\). The cytometer’s detectors have about 1 % noise. A colleague suggests solving the unmixing in quadruple precision to get more accurate abundances. Will it help? What would?
Where does the error in \(\hat{\mathbf x}\) come from: rounding, or the data?
No. In double precision the rounding error is at most about \(500 \times 10^{-16}\), already negligible. The error comes from the 1 % detector noise amplified by up to \(\kappa\): up to about \(500 \times 1\,\% = 500\,\%\) in the worst direction. That is the conditioning of the problem, and no arithmetic can fix it. What helps is changing the problem: dyes with more distinct spectra (smaller overlap, smaller \(\kappa\)), more detectors than dyes (least squares, Part 4), less noisy measurements, or regularisation (The SVD, rank deficiency and regularisation).
Q11. Why do spectral flow cytometry plots of unmixed data often show populations smeared out along a diagonal, including negative values, for dyes with similar spectra?
Look at the inverse of \(\begin{pmatrix}1 & 0.95\\ 0.95 & 1\end{pmatrix}\).
\(A^{-1} \approx \begin{pmatrix}10.3 & -9.7\\ -9.7 & 10.3\end{pmatrix}\): each unmixed abundance is a difference of two large multiples of the detector readings, so independent detector noise is amplified (about 14 times for 1 % noise here) and the errors of the two dyes are strongly anti-correlated, i.e. along \((1, -1)\). Cells with little of a dye then scatter to both sides of zero, including negative values. This is the noise amplification that \(\kappa\) predicts, called spillover spreading in cytometry; it is not a software bug.