LA 101
M7 · Lab
Hands-on lab
Take a matrix apart, keep only what matters

Decompose an image matrix with the SVD and read its singular values in the sandbox, and predict — before the screen tells you — how many σi are non-zero, how much energy the top k capture, and how the rank-k reconstruction error falls as k rises.

The singular value decomposition
A = U\Sigma V^{\top} = \sum_{i=1}^{r}\sigma_i\, u_i v_i^{\top}

The singular value decomposition A = UΣV⊤ writes any matrix as a sum of rank-one layers σi ui vi⊤ ordered by how much they matter. The number of non-zero σi is the rank; the energy the top k capture is (Σi≤k σi2) / (Σi σi2); and by the Eckart–Young theorem, keeping the top k layers is the best possible rank-k approximation in Frobenius norm.

1 / 7
LA 101
M7 · Lab
Set it up
One decomposition

Open the sandbox. Choose the image “Rank 5 by construction” and leave the defaults (size 64×64, no noise, seed 1). Each step names the rank k to set; read the singular-value spectrum, the explained-energy readout and the measured reconstruction error.

Set these values
Image = Rank 5 by construction size = 64x64 noise = 0 seed = 1 Read: sigma_1..sigma_l explained energy at k ||A - A_k||_F / ||A||_F

Watch the singular-value bar chart, the “energy kept” percentage and the measured error printed above the reconstruction — every number you predict is on screen.

2 / 7
LA 101
M7 · Lab
Step 1 of 3
The rank is the count of non-zero σi

Decompose the image and look at the singular-value spectrum. Predict how many σi are genuinely non-zero — that count is the matrix rank — then read the numerical rank off the chart.

Expected

Exactly 5 singular values are non-zero and the rest sit at the floating-point floor: the numerical rank is 5, which is why this image is called “rank 5 by construction”.

3 / 7
LA 101
M7 · Lab
Step 2 of 3
Energy captured by the top k

Set k = 3 and read the “energy kept” readout — the fraction (Σi≤3 σi2) / (Σi σi2). Predict whether three of five layers already capture most of the energy.

Expected

The top 3 of the 5 layers already capture 0.9939 of the energy — over 99%. The singular values fall off so fast that the first few layers carry almost everything.

4 / 7
LA 101
M7 · Lab
Step 3 of 3
Reconstruction error falls, then vanishes

Set k = 4 and read the measured relative error ||A - Ak||F / ||A||F. Then push k to 5 and predict what happens to the error.

Expected

At k = 4 the relative error is 0.0528 — about 5% still missing because one non-zero layer is dropped. At k = 5 the error falls to the floating-point floor: rank 5 reproduces the matrix exactly.

5 / 7
LA 101
M7 · Lab
Your turn
Open the sandbox

Everything above is waiting in the sandbox. Pick any image, drag the size, noise and rank k sliders, and watch the singular-value spectrum, the explained energy, the rank-one layers and the measured reconstruction error all update at once.

6 / 7
LA 101
M7 · Lab
Wrap-up
What you did
  • Read a matrix's rank as the count of non-zero singular values, 5
  • Saw the top 3 layers capture 0.9939 of the energy — over 99%
  • Measured the rank-4 error at 0.0528, then watched it vanish at rank 5 — exact recovery
  • Every value you predicted is the demo's own SVD arithmetic, not a picture
7 / 7