Lab 2.3

Testing LU Decomposition

Focus
low rank → LU → check
Notebook
Ch2-3 Test LU-Decomposition.ipynb

Lab goal

See what SciPy returns, why Q = P.T gives Q @ A = L @ U, and where rank deficiency appears.

Lecture-note concepts
  • Rank of a product
  • Rectangular LU
  • Permutation matrix
  • Residual

Code extensionThe full notebook generates random 10×11 matrices, repeats the test ten times, and plots the collected results.

Key ideas

Terms you will use

Rank boundA = X Y ⇒ rank(A) ≤ 2

A product with a two-dimensional middle space cannot have rank larger than two.

Pivoted LUA = P L U ⇔ Q A = L U

SciPy returns A = P L U. Setting Q = P.T gives the course form Q A = L U.

Residual‖Q A − L U‖

The residual compresses the reconstruction difference into one nonnegative number.

Lab 2.3 · Guided example

Test LU once, with reproducible numbers

The notebook’s repeated random experiment is reduced to one deterministic 3×4 matrix so the rank and reconstruction are visible without a histogram.

Select a line to see its action, array shape, and concrete operation.

Simplified fromCh2-3 Test LU-Decomposition.ipynbThe full source repeats this test with larger unseeded random matrices.

Line 1: import numpy as np
L01 / 12Create two narrow factors
Predict

X has two columns and Y has two rows.

Before

Build rank into the example

We will multiply a 3×2 matrix by a 2×4 matrix, forcing the result through a two-dimensional middle space.

(3×2)(2×4) → 3×4 with rank at most 2
After
?

Reveal to compare.

Continue in Python

Run the complete notebook in Colab

Run the original code and change the inputs.