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=PQ = P.T gives Q@A=L@UQ \mathbin{\mathtt{@}} A = L \mathbin{\mathtt{@}} 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=XY⇒rank⁡(A)≤2A = X Y \Rightarrow \operatorname{rank}(A) \le 2

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

Pivoted LUA=PLU⟺QA=LUA = P L U \Longleftrightarrow Q A = L U

SciPy returns A=PLUA = P L U. Setting Q=PQ = P.T gives the course form QA=LUQ A = L U.

Residual∥QA−LU∥\Vert Q A - L U\Vert

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.ipynb ↗The 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.