Notebook for 2023-02-10
Block Gaussian elimination
The main topic for this lecture was thinking about Gaussian elimination in a blockwise fashion. In particular, we considered solving block 2-by-2 linear systems with matrices of the form
$$A = \begin{bmatrix} B & V \\ W^T & C \end{bmatrix}$$
A particular instance of this is solving the linear system
$$\begin{bmatrix} B & V \\ W^T & -I \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix} = \begin{bmatrix} d \\ 0 \end{bmatrix}$$
In terms of two block equations, this is
$$\begin{aligned} Bx + Vy &= d \\ W^T x - y &= 0 \end{aligned}$$
and substituting $y = W^T x$ (from the latter equation) into the former equation gives
$$(B + VW^T)x = d$$
Going the other way, we can eliminate the $x$ variables to get an equation just in $y$:
$$(-I-W^T B^{-1} V) y = -W^T B^{-1} d$$
and then substitute into $Bx = d-Vy$ to solve the system.
Let's go ahead and illustrate how to use this to solve $(B + VW^T) x = d$ given a solver for systems with $B$.
solve_bordered (generic function with 1 method)
test_solve_bordered (generic function with 1 method)
2.802295651434949e-15
Iterative refinement
The trick of forming a bordered system is interesting in part because it allows us to take advantage of a fast solver for one system (from an existing factorization, for example) in order to solve a slightly modified system. But there's a cost! Even if the modified system is well-conditioned, poor conditioning in the reference problem (the $B$ matrix) can lead to quite bad results.
test_sensitive_bordered (generic function with 1 method)
0.15406594322491596
A technique in the notes (but not discussed in lecture) can be used to partly fix up this bad behavior. When we have a somewhat sloppy solver like the one here, but we're able to compute a good residual (and the problem we're solving is not terribly ill conditioned) sometimes a few steps of iterative refinement can make a big difference.
test_itref (generic function with 1 method)
0.0270347
1.23315e-5
1.84368e-8
4.94402e-11
1.20103e-13
Sensitivity
We also spent a little time in this lecture talking about the sensitivity of linear systems to perturbations. In particular, we differentiated the equation
$$Ax = b$$
which, using variational notation, gave us
$$(\delta A) x + A (\delta x) = \delta b$$
In addition to being useful for error analysis, this formula is actually something you can use computationally, as we illustrate below.
test_perturbed (generic function with 1 method)
5.359429109831612e-8