4.8.20 · D3Numerical Methods

Worked examples — Iterative methods — Jacobi, Gauss-Seidel, convergence

2,457 words11 min readBack to topic

The scenario matrix

Here is every case class a Jacobi / Gauss-Seidel problem can throw at you. Each worked example below is tagged with the cell(s) it covers.

# Case class What makes it different Example
A Strictly diagonally dominant (SDD), both converge Textbook-safe, GS beats Jacobi Ex 1
B Predict speed before iterating Use as a forecast Ex 2
C Not SDD ⇒ diverges , error explodes Ex 3
D Not SDD but still converges SDD is sufficient, not necessary Ex 4
E Zero on the diagonal breaks division — permute rows Ex 5
F Jacobi converges, Gauss-Seidel diverges The "GS always wins" myth dies Ex 6
G Real-world word problem Temperatures on a rod (a tiny PDE grid) Ex 7
H Exam twist: fill a blank to force convergence Reverse-engineer diagonal dominance Ex 8

We build a decision tree first so you know which lever to pull when a matrix lands on your desk. (One acronym appears in the last box: SOR = Successive Over-Relaxation, an accelerated cousin of Gauss-Seidel — a fallback when reordering alone won't tame .)

yes

no

yes

no

less than 1

at least 1

Matrix A given

Any zero on diagonal

Swap rows to fix

Strictly diagonally dominant

Both converge - just iterate

Compute rho of T

Diverges - reorder or over-relax


Case A — SDD, both methods converge

Step 1 — write the update rules. Why? Each equation is "solve for the variable on its own diagonal."

Step 2 — Jacobi uses only OLD values. Why this step? Jacobi freezes the whole old vector, then updates everything at once.

  • : , .
  • : , .
  • : , .

Step 3 — Gauss-Seidel uses NEW inside . Why this step? By the time we compute , a better already exists — waste not.

  • : ; .
  • : ; .
  • : ; .

Verify: GS after 3 sweeps is — error . Jacobi is — error . GS is closer, as forecast. Plug into the originals: ✓, ✓.


Case B — forecast the speed from

Forecast: SDD ( both rows) so it converges; the question is how fast.

Step 1 — build . Why? The parent note proved (with the error vector defined at the top); the error's fate lives entirely in .

Step 2 — eigenvalues of . Why this step? is the per-step shrink factor. For the eigenvalues are , so has .

Step 3 — read off the rate. . Interpretation: every sweep roughly halves the length of the error. To gain one decimal digit () you need about sweeps.

Verify: ✓. — one sweep should cut error in half; that's exactly the "closing in" we saw in Ex 1's SDD systems.

Figure — Iterative methods — Jacobi, Gauss-Seidel, convergence

The figure above makes the forecast visual: with (green) the error length halves each sweep and dives to zero, while a matrix with (red, the next case) sees its error multiplied each sweep and blow up. The yellow dashed line marks the starting error size.


Case C — not SDD, it diverges

Forecast: Row 1: not dominant. Suspicion: it blows up.

Step 1 — form . Why? Same reason always — convergence is a property of , not of directly. Here so : (The off-diagonals of are and ; in the convention carries their negatives.)

Step 2 — eigenvalues. Why? We need . Characteristic equation , so .

Step 3 — verdict. . Error is multiplied by each sweep ⇒ diverges.

Step 4 — the fix. Why? Swapping rows changes which coefficient sits on the diagonal:

Verify: , ✓ diverges. After swap has , ✓ converges.


Case D — not SDD, yet it CONVERGES

Forecast: The tempting (wrong) answer: "not SDD, so diverges." Let's check , because SDD is only sufficient.

Step 1 — build . Why? SDD failed, so the shortcut is off the table; we must compute the real criterion. With , , and carries the negatives of the off-diagonals ( above, below):

Step 2 — eigenvalues. For a matrix with zero diagonal, . Here the product is , so . Thus , — a complex pair.

Step 3 — take magnitudes. Why this step? uses the absolute value of complex eigenvalues: .

Step 4 — verdict. converges, even though is not diagonally dominant. Moral: SDD is a friendly sufficient flag, never a death sentence when absent.

Verify: ✓ converges despite non-SDD.


Case E — zero on the diagonal (degenerate)

Forecast: Both methods divide by . Here — division by zero. It's undefined before it even starts.

Step 1 — spot the illegal step. Why? The update has . Stop.

Step 2 — permute rows. Why this step? Reordering equations doesn't change the solution, but moves a nonzero onto the diagonal: Now , : division legal. Bonus — it's SDD, so it also converges.

Step 3 — solve the reordered system (exact, to have a target). From row 2: . From row 1: .

Verify: Original equations: ✓ and ✓. The permuted diagonal is nonzero, so Jacobi is now well-defined.


Case F — Jacobi converges but Gauss-Seidel diverges

Forecast: Everyone "knows" GS is faster. Watch it fail.

Step 1 — Jacobi's . Why compute first? To establish the baseline. The diagonal is all 's so , and carries the negatives of all off-diagonal entries:

Step 2 — why its characteristic polynomial is . Why this step? We need . Expand . Writing it out (cofactor along the first row) the constant, , and coefficients all cancel — the trace is (kills ), the sum of principal minors is (kills ), and (kills the constant). What survives is . So all three eigenvalues are : . Jacobi converges in at most 3 steps — spectacular.

Step 3 — Gauss-Seidel's . Why? GS uses . From we read off Inverting the lower-triangular and multiplying gives This is upper-triangular, so its eigenvalues sit on the diagonal: . Hence : diverges.

Step 4 — moral. Why this matters: freshness of information is usually good but not guaranteed good. The order in which you overwrite can amplify certain error directions.

Verify: so ✓; and has diagonal eigenvalues so ✓. "Usually faster," never "always converges." (For the safe families — SPD or SDD — GS does win; this is the pathological counter-example.)


Case G — a real-world word problem (tiny PDE grid)

Forecast: Physics says heat spreads to a straight line, so the exact answer should be equally spaced: .

Figure — Iterative methods — Jacobi, Gauss-Seidel, convergence

Step 1 — recognise the structure. Why? Rearranged, the system matrix is This is a sparse tridiagonal system — exactly what iterative methods love. It is only weakly diagonally dominant (row 2 has , equality), so weak dominance alone proves nothing; we must compute to justify convergence.

Step 2 — compute to prove convergence. Why this step? This is the real WHY behind "it converges." With , For an tridiagonal matrix with on the diagonal and just off it, the eigenvalues are known exactly: for . Here , so those inner eigenvalues are . Multiply by the out front: has eigenvalues . The largest magnitude is converges (and Gauss-Seidel, being for this model matrix, is even faster).

Step 3 — Gauss-Seidel sweeps (average form, use freshest neighbour). Why this step? Each row already gives as an average, so GS is just "recompute averages left-to-right using latest values."

  • : ; ; .
  • : ; ; .
  • : ; ; .
  • : ; ; .

Step 4 — watch it march toward ; it climbs steadily each sweep, exactly as the from Step 2 promised.

Verify: Exact solution: plug : ✓, ✓, ✓. Units: all in C, endpoints and bracket every interior value ✓.


Case H — exam twist: choose a value to guarantee convergence

Forecast: Bigger diagonal = safer. There should be a threshold on .

Step 1 — write the SDD inequality per row. Why? SDD demands . Every row here has diagonal and two off-diagonal 's:

Step 2 — solve. Why this step? means or .

Step 3 — sanity-probe a value. Take : . The inner matrix has eigenvalues , so has , giving ✓ converges.

Verify: . For : ✓. For the boundary : not guaranteed to converge (borderline), confirming the strict inequality is genuinely needed.


Recall

Recall Which cell forces you to permute rows first?

Cell E — a zero on the diagonal makes undefined; swap rows to seat a nonzero on every diagonal.

Recall If SDD fails, what must you do before declaring divergence?

Compute directly (Case D): SDD is sufficient, not necessary. can still hold.

Non-SDD matrix can still converge — what decides it?
The spectral radius: converges iff , regardless of diagonal dominance.
Does Gauss-Seidel always converge faster than Jacobi?
No (Case F): there exist matrices where Jacobi converges but GS diverges. "Usually" for SPD/SDD, never "always."
Threshold on for SDD in Ex 8?
.