Practice implementing and analyzing direct methods for linear systems.
Q5.1: Triangular Solves¶
(a) Solve by back substitution: $$
$$
(b) Solve by forward substitution: $$
$$
Q5.2: Gaussian Elimination¶
Solve the following system using Gaussian elimination (show all steps):
Q5.3: LU Decomposition¶
(a) Find the LU decomposition of:
(b) Use your decomposition to solve .
(c) Solve (same LU, different RHS).
Q5.4: Flop Counting¶
(a) Verify that back substitution requires exactly flops.
(b) Verify that Gaussian elimination requires flops.
(c) For , how many times faster is solving with a precomputed LU versus fresh Gaussian elimination?
Q5.5: Pivoting¶
Consider: $$
$$
(a) Why does Gaussian elimination without pivoting fail?
(b) Apply Gaussian elimination with partial pivoting.
(c) Write out the decomposition.
Q5.6: Implementation¶
Implement the following in Python:
(a) Back substitution for upper triangular systems.
(b) LU decomposition without pivoting.
(c) LU decomposition with partial pivoting.
Test on random matrices and compare with scipy.linalg.lu.
Q5.7: Stability Investigation¶
(a) Create a matrix where pivoting makes a significant difference. Solve the system with and without pivoting and compare errors.
(b) Investigate the Hilbert matrix: compare the computed solution to the exact solution for increasing matrix sizes.
Self-Assessment Questions¶
Test your understanding with these conceptual questions:
Complexity: How many flops does Gaussian elimination require for an matrix?
LU Advantage: If you need to solve for 100 different vectors, is it better to use Gaussian elimination 100 times or compute LU once?
Pivoting: Why does dividing by small numbers cause problems in floating point arithmetic?
Back Substitution: Why is back substitution rather than ?