Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Open In Colab Binder

Goal of the experiment

Use an interactive tool to watch, step by step, how PA=LU\mathbf{PA} = \mathbf{LU} takes shape, and understand, from the point of view of the rank-one decomposition, the cumulative meaning of A=P⊤(c0r0⊤+c1r1⊤+⋯ )\mathbf{A} = \mathbf{P}^\top(\mathbf{c}_0\mathbf{r}_0^\top + \mathbf{c}_1\mathbf{r}_1^\top + \cdots).


Part 1: Interactive Exploration

The Six Panels

PositionPanelDescription
Top leftA\mathbf{A} (original)Unchanged; the reference throughout
Top middleP\mathbf{P} (permutation)Records every row exchange; orange box = current pivot position
Top rightP⊤LU\mathbf{P}^\top\mathbf{LU} rank-one accumulationSum of the completed rank-one layers, gradually approaching A\mathbf{A}
Bottom leftL\mathbf{L} (lower triangular)The elimination multipliers ℓik\ell_{ik} are filled in entry by entry
Bottom middleU\mathbf{U} (row echelon)Reduced step by step to REF; teal dashed box = the row being eliminated
Bottom rightCurrent rank-one layerThe ckrk⊤\mathbf{c}_k \mathbf{r}_k^\top contributed in this round

Color meaning: light blue = negative, white = zero, the panel’s own light warm color = positive.

How to Use the Tool

  1. Click “▶ Decompose” to load the default matrix

  2. Step forward with the ◀ / ▶ buttons or by dragging the slider

  3. You can edit the values in the entry boxes, or click “Random” to explore different cases

  4. “Resize” switches between 3×33\times3 and 5×55\times5 (non-square matrices included)

Source

Experiment A: The Standard Case (Row Exchanges Needed)

A=(2114−60−272)\mathbf{A} = \begin{pmatrix} 2 & 1 & 1 \\\\ 4 & -6 & 0 \\\\ -2 & 7 & 2 \end{pmatrix}

Press “Next” step by step and observe how row exchanges change P\mathbf{P} and how the elimination multipliers are filled into L\mathbf{L}.

Loading...

Experiment B: A Rank-Deficient Matrix (rank⁡=2\operatorname{rank} = 2)

B=(123246012)\mathbf{B} = \begin{pmatrix} 1 & 2 & 3 \\\\ 2 & 4 & 6 \\\\ 0 & 1 & 2 \end{pmatrix}

Note that row 0 and row 1 are proportional. Observe the zero row of U\mathbf{U} after elimination, and how the rank-one accumulation stops growing after a certain step.

Loading...

Experiment C: A Non-Square Matrix (3×43 \times 4)

C=(120324171124)\mathbf{C} = \begin{pmatrix} 1 & 2 & 0 & 3 \\\\ 2 & 4 & 1 & 7 \\\\ 1 & 1 & 2 & 4 \end{pmatrix}

Note that P\mathbf{P} and L\mathbf{L} are still 3×33 \times 3; only U\mathbf{U} is 3×43 \times 4. Observe how the number of rank-one layers is related to the number of pivots of U\mathbf{U}.

Loading...

Part 2: Observation and Reflection

After completing the interactive exploration of Part 1, answer the following questions based on your observations. We suggest that you first try to answer in your own words and then run the verification code to confirm.

Question 1: The Structure of the Permutation Matrix P\mathbf{P}

In Experiment A, what kind of matrix is the final P\mathbf{P}?

(a) Run the code below and observe how many nonzero entries each row and each column of P\mathbf{P} has.

(b) Does P\mathbf{P} satisfy P⊤P=I\mathbf{P}^\top\mathbf{P} = \mathbf{I}? Verify it with the code, and explain the geometric meaning of this property.

(c) Is the result of the PLU decomposition unique? If all the leading principal minors of the matrix A\mathbf{A} are nonzero (this guarantees an LU decomposition without row exchanges; but this tool uses partial pivoting and may still exchange rows, as in Experiment A), and no row exchanges are made during the decomposition, what is P\mathbf{P}? To which decomposition does PLU then reduce?

P =
[[0. 1. 0.]
 [1. 0. 0.]
 [0. 0. 1.]]

P^T P =
[[1. 0. 0.]
 [0. 1. 0.]
 [0. 0. 1.]]
P^T P is the identity matrix: True

Nonzero entries in each column of P: [1, 1, 1]
Nonzero entries in each row of P: [1, 1, 1]

Your observations (fill in):

(a)

(b)

(c)

Question 2: The Diagonal Entries of L\mathbf{L}

(a) Run the code below and read off the diagonal entries of the final L\mathbf{L} in Experiment A. What pattern do their values follow?

(b) The elimination multiplier is ℓik=uik(k)/ukk(k)\ell_{ik} = u_{ik}^{(k)} / u_{kk}^{(k)} (the values before elimination step kk). If the pivot ukku_{kk} is very small (close to zero), what goes wrong with ℓik\ell_{ik}? This is exactly why “partial pivoting” chooses the entry of largest absolute value as the pivot; explain your understanding.

(c) For the rank-deficient matrix of Experiment B, are the diagonal entries of L\mathbf{L} all equal to 1?

L of Experiment A:
[[ 1.   0.   0. ]
 [ 0.5  1.   0. ]
 [-0.5  1.   1. ]]
Diagonal entries of L: [1. 1. 1.]

L of Experiment B (rank-deficient):
[[1.  0.  0. ]
 [0.  1.  0. ]
 [0.5 0.  1. ]]
Diagonal entries of L_B: [1. 1. 1.]

U of Experiment B:
[[2. 4. 6.]
 [0. 1. 2.]
 [0. 0. 0.]]
Pivots of U (diagonal entries): [2. 1. 0.]

Your observations (fill in):

(a)

(b)

(c)

Question 3: The Rank-One View—How Much “Information” the Decomposition Carries

Each rank-one layer ckrk⊤\mathbf{c}_k \mathbf{r}_k^\top is a matrix of rank 1.

(a) In Experiment A, after how many layers does the “rank-one accumulation” panel at the top right become identical to the original matrix A\mathbf{A}? Run the code below to compare the error layer by layer.

(b) For Experiment B (rank⁡=2\operatorname{rank} = 2), what does rank-one layer 2 (k=2k=2, if it exists) contribute? That is, how does the accumulated matrix change after layer 2 is added?

(c) Think about it: how is the number of rank-one layers related to the rank of the matrix? State your conjecture in terms of rank⁡(A)\operatorname{rank}(\mathbf{A}).

Experiment A: error of the accumulation, layer by layer, ‖accumulation - A‖∞
----------------------------------------
  error after accumulating the first 1 layers = 4.000000
  error after accumulating the first 2 layers = 1.000000
  error after accumulating the first 3 layers = 0.000000

Experiment B (rank-deficient): number of rank-one layers = 2
Error of the accumulation, layer by layer, ‖accumulation - B‖∞
----------------------------------------
  error after accumulating the first 1 layers = 2.000000
  error after accumulating the first 2 layers = 0.000000

Experiment C (3×4): number of rank-one layers = 3

Your observations (fill in):

(a)

(b)

(c) My conjecture: the number of rank-one layers = ______

Question 4: The Effect of Row Exchanges on the Decomposition

Construct a matrix with a zero diagonal entry (but invertible as a whole), and observe what happens if no row exchange is performed.

(a) For the matrix D\mathbf{D} below, apply the LU decomposition “without row exchanges” directly (set skip_pivot=True), and observe whether the first elimination step is legitimate.

(b) Decompose the same D\mathbf{D} with the standard PLU (partial pivoting) and compare the two U\mathbf{U}'s. Which one has pivots of larger absolute value? What does this mean for numerical stability?

(c) Find a matrix that is numerically “nearly singular” (determinant close to zero), and observe the last diagonal entry of its U\mathbf{U}.

Your observations (fill in):

(a)

(b)

(c)

Question 5 (Extension): Determinants and the PLU Decomposition

The PLU decomposition provides an efficient way to compute determinants:

det⁡(A)=(−1)s∏k=0n−1ukk\det(\mathbf{A}) = (-1)^s \prod_{k=0}^{n-1} u_{kk}

where A\mathbf{A} is an n×nn \times n matrix, ss is the number of row exchanges, and the ukku_{kk} are all nn diagonal entries (pivots) of U\mathbf{U}.

(a) For Experiment A, compute the number of row exchanges ss and ∏ukk\prod u_{kk}, and compare with np.linalg.det.

(b) Explain why the lower triangular matrix L\mathbf{L} (with all diagonal entries 1) has determinant 1, so that det⁡(PA)=det⁡(L)det⁡(U)=det⁡(U)\det(\mathbf{PA}) = \det(\mathbf{L})\det(\mathbf{U}) = \det(\mathbf{U}).

(c) For the rank-deficient matrix (Experiment B), what is ∏ukk\prod u_{kk}? What does this show?

Your observations (fill in):

(a)

(b)

(c)

Summary of the Experiment

After completing the observations above, try to fill in the following blanks in your own words:

ConceptYour understanding
The role of P\mathbf{P}
Why the diagonal entries of L\mathbf{L} are all 1
The numerical meaning of partial pivoting
Number of rank-one layers = rank of the matrix
The relation between det⁡(A)\det(\mathbf{A}) and the pivots

Hint: the full theoretical explanation of the questions above is in §6.3 of the textbook.