LA 101
M9 · Lab
Hands-on lab
When does a matrix amplify the errors you feed it?

Measure a matrix's condition number, test when an iterative solver converges, and watch a near-singular system amplify a perturbation in the sandbox, and predict — before you read it off the screen — that κ is exactly one for a perfectly-scaled matrix and large for a stretched one, that the Jacobi iteration converges precisely when its spectral radius ρ is below one, and that an ill-conditioned system blows a tiny input error up by a factor of κ.

Conditioning, convergence and error amplification
\begin{gathered} \kappa(A) = \sigma_{\max}/\sigma_{\min} \\[3pt] \rho(M) = \max_i|\lambda_i(M)| < 1 \\[3pt] \frac{\lVert\delta x\rVert}{\lVert x\rVert} \le \kappa(A)\,\frac{\lVert\delta b\rVert}{\lVert b\rVert} \end{gathered}

The condition number κ(A) = σmax/σmin is the ratio of the largest to the smallest singular value — the real σmax/σmin, not a shortcut from column norms. It says how much a matrix can stretch relative to how much it can squash: κ = 1 is perfectly conditioned, a huge κ is nearly singular. For the iterative solvers, Jacobi and Gauss-Seidel converge iff the spectral radius of the iteration matrix — its largest eigenvalue magnitude ρ = maxi|λi| — is below one, which strict diagonal dominance guarantees. And the two ideas meet in the error bound ‖δx‖/‖x‖ ≤ κ(A)·‖δb‖/‖b‖: the condition number is exactly the worst-case factor by which a relative input error is amplified.

1 / 10
LA 101
M9 · Lab
Set it up
A numerical sandbox

Open the sandbox. It reports a matrix's singular values and condition number, runs Jacobi and Gauss-Seidel on A x = b with a convergence verdict, and perturbs b to measure the amplification. Each step names the matrix to set, then read the κ, the spectral radius, the verdict and the amplification readouts.

Set these values
Condition: A = I = [[1,0],[0,1]] and A = diag(1,100) = [[1,0],[0,100]] Iterate: [[4,1],[1,3]] b=(1,2) vs [[1,3],[2,1]] b=(4,3) Amplify: [[1,1],[1,1.0001]] b=(2,2.0001), perturb b by 0.001

Watch the condition-number readout κ, the Jacobi spectral radius ρ and converges/diverges verdict, and the error-amplification ratio — every number you predict is printed there.

2 / 10
LA 101
M9 · Lab
Step 1 of 6
A perfectly-conditioned matrix has κ = 1

Set A = I, the identity [[1,0],[0,1]]. Both singular values are 1, so κ = σmax/σmin. Predict κ, then read the condition-number readout.

Expected

The condition number is κ = 1: the identity neither stretches nor squashes, so its largest and smallest singular values are equal. A well-conditioned matrix passes relative errors through unchanged — it is the best case there is.

3 / 10
LA 101
M9 · Lab
Step 2 of 6
A stretched matrix is ill-conditioned

Set A = diag(1, 100) = [[1,0],[0,100]] — it scales one axis by 1 and the other by 100. The singular values are σmax = 100 and σmin = 1. Predict κ = σmax/σmin, then read it.

Expected

The condition number is κ = 100: exactly σmax/σmin = 100/1, the real ratio of singular values — not a proxy from column norms, which can be off by orders of magnitude. This matrix magnifies a relative input error up to a hundredfold.

4 / 10
LA 101
M9 · Lab
Step 3 of 6
A diagonally-dominant system has small ρ

In the iterative panel set A = [[4,1],[1,3]], b = (1, 2) and run Jacobi. Its iteration matrix has spectral radius ρ = maxi|λi|. Predict roughly whether ρ is below 1, then read the spectral-radius readout.

Expected

The spectral radius is ρ ≈ 0.289 — well below 1. Because the diagonal entries dominate the off-diagonal ones, the iteration matrix has small eigenvalues, so each Jacobi sweep shrinks the error by roughly 0.289.

5 / 10
LA 101
M9 · Lab
Step 4 of 6
ρ < 1 means the iteration converges

Keep A = [[4,1],[1,3]], b = (1, 2). The convergence rule is exactly ρ < 1. Predict the verdict (1 = converges, 0 = diverges), then read it.

Expected

The verdict is 1: it converges, because ρ ≈ 0.289 < 1. Strict diagonal dominance is a sufficient condition for exactly this — the errors of successive iterates form a shrinking geometric sequence governed by ρ.

6 / 10
LA 101
M9 · Lab
Step 5 of 6
Without dominance, ρ > 1 and it diverges

Now set the non-dominant A = [[1,3],[2,1]], b = (4, 3) — the off-diagonal entries (3 and 2) exceed the diagonal ones. Predict the Jacobi spectral radius ρ, then read it.

Expected

The spectral radius is ρ ≈ 2.449 — above 1, so Jacobi diverges: the residual grows each sweep instead of shrinking. Diagonal dominance is what separates the two regimes; lose it and the same iteration that converged now runs away.

7 / 10
LA 101
M9 · Lab
Step 6 of 6
A near-singular system amplifies error by κ

In the amplification panel set the near-singular A = [[1,1],[1,1.0001]], b = (2, 2.0001), and perturb b by a relative 0.001 (0.1%). Its condition number is about 40002. Predict the amplification ratio (‖δx‖/‖x‖) / (‖δb‖/‖b‖), then read it.

Expected

The ratio is about 40002 — a 0.1% nudge to b becomes a roughly 4000% error in the solution. That factor is exactly the condition number κ, the worst-case ceiling of the bound ‖δx‖/‖x‖ ≤ κ·‖δb‖/‖b‖. This is why conditioning, not just correctness of the algorithm, decides the accuracy.

8 / 10
LA 101
M9 · Lab
Your turn
Open the sandbox

Everything above is waiting in the sandbox. Change the matrix and watch the singular values, the condition number and the unit-circle-to-ellipse image respond; run Jacobi and Gauss-Seidel and see the residual trace converge or diverge as the spectral radius crosses one; and dial the perturbation to watch a well-conditioned system shrug it off while a near-singular one blows it up.

9 / 10
LA 101
M9 · Lab
Wrap-up
What you did
  • Measured κ(I) = 1 — a perfectly-conditioned matrix
  • Measured κ(diag(1,100)) = 100, the real σmax/σmin, not a proxy
  • Read the Jacobi spectral radius ρ ≈ 0.289 for [[4,1],[1,3]]
  • Confirmed ρ < 1 gives the verdict 1 — it converges
  • Saw the non-dominant [[1,3],[2,1]] reach ρ ≈ 2.449 > 1 — it diverges
  • Watched a near-singular system amplify a 0.1% perturbation by 40002 = κ
  • Every value you predicted is the demo's own numerical arithmetic, not a picture
10 / 10