Iterating, instead of factorising

Smoothing a whole line at once

Solve every grid line in the strong direction exactly rather than sweeping over it, and the smoothing factor goes from 0.9993 back to 0.3340 — which is the one-dimensional answer, on a problem that is not one-dimensional. The repair replaces one ε in the closed form by a one.

Worth reading first: A direction the smoother cannot see · The error smoothing cannot reach.

A direction the smoother cannot see leaves the method at 0.9565 a cycle and locates the failure precisely: the mode that oscillates across the weak direction and is smooth along the strong one is damped by 1 − 2ωε/(1 + ε), which is 0.99867 at ε = 10⁻³, and the coarse grid cannot take it because it is not smooth.

There are two ways out and this essay is the first. It changes what the smoother inverts.

A point relaxation asks, for each unknown in turn, what value would satisfy that unknown’s own equation given the current values of its neighbours. A line relaxation asks the same question of a whole grid line at once: what values along this column would satisfy every equation on it exactly, given the current values of the columns either side. That is a tridiagonal system, it costs a constant number of operations per unknown to solve, and it inverts the direction the anisotropy made strong instead of iterating along it.

The smoothing factor goes from 0.9993 to 0.3340, which is the one-dimensional ⅓ arriving on a problem that is not one-dimensional.

Smoothing factor against anisotropy, at ω = 0.667Three curves of the smoothing factor against the anisotropy parameter on a logarithmic axis. One rises to one as the anisotropy grows; the other two coincide and stay near a third.10⁻⁴10⁻³10⁻²10⁻¹100.250.50.751anisotropy εsmoothing factor μpoint + fully-line + fullpoint + semi-y⅓, the one-dimensional answertwo routes, three curvesgap between the repairs2.2·10⁻¹⁶scan against closed form2.2·10⁻¹⁶the dashed curve lies on the solid one beneath itone repair, written two ways
Fig. 1 Three smoothing factors against the anisotropy. The rising curve is point relaxation; the flat one near a third is this essay’s repair, and the third curve — sitting exactly on top of it — is the next essay’s. Drag ω and they stay together at every weight.

What a line smoother is, written as a splitting

Every stationary method on this site is a splitting: choose a matrix M that is easy to invert, write A = M − (M − A), and iterate x ← x + ωM⁻¹(b − Ax). Jacobi takes M to be the diagonal; Gauss–Seidel takes it to be the lower triangle; the stationary essay measures the rates both of them achieve on the one-dimensional model problem against closed forms.

A y-line smoother takes M to be the entries of A that couple points within the same grid column. For the five-point operator that is the diagonal and the two vertical off-diagonals, so M is block diagonal with k tridiagonal blocks of size k, and inverting it is k tridiagonal solves. The horizontal couplings are outside M and are therefore lagged — treated as part of the right-hand side, exactly as Jacobi lags everything off the diagonal.

Written that way the cost is easy to state. A point sweep is one multiply-add per stored entry plus a division; a line sweep is the same defect computation plus a Thomas solve, which is about five operations a point. So a line sweep costs roughly three times a point sweep, and buys a smoothing factor of 0.334 where the point sweep gets 0.999. Three times the work for a component that works is not a difficult trade.

The implementation is written against the matrix rather than against the stencil — for each line it reads the within-line couplings straight out of the rows of A — and that choice does two things. It makes the same code smooth the nine-point rotated operator, which the last essay in this sequence needs. And it makes the failure on that operator a consequence of the definition rather than a separate claim: everything the rotation adds lies outside the line, so a line smoother lags it.

The symbol, and where the ε goes

The analysis is the same three lines as before with one substitution. The symbol of A at the frequency pair (θx, θy) is 4ε sin²(θx/2) + 4 sin²(θy/2). The symbol of M, for a y-line smoother, is what is left when the horizontal couplings are dropped:

2ε + 4 sin²(θy/2)

and the damping factor is 1 − ω·A/M. Take the mode that broke the point smoother — θx = π, θy → 0. There A → 4ε and M → 2ε, so the ratio is 2 and the factor is 1 − 2ω, which at ω = 2/3 is −⅓.

The ε cancelled. That is the whole repair in one line: the weak coupling still sets the size of what the smoother has to remove, and it now also sets the size of what the smoother inverts, so the two divide out and the mode is damped like any other.

The maximum over the frequencies the coarse grid cannot see comes out

μ = max( |1 − ω/(1 + ε)| , |1 − 2ω| )

against the point smoother’s max(|1 − ωε/(1+ε)|, |1 − 2ω|). One coefficient differs, and it is the ε. A scan over 128×128 frequency pairs agrees with the expression to 10⁻⁹ at six values of ε and five weights.

Two numbers fall out that the one-dimensional field never had reason to write down. The optimum is where the two branches cross:

ω* = 2(1 + ε)/(3 + 2ε),    μ* = (1 + 2ε)/(3 + 2ε)

At ε = 1 that is ω = 4/5 and μ = 3/5, which is the two-dimensional isotropic answer from the previous essay. As ε → 0 it is exactly 2/3 and ⅓ — the one-dimensional numbers, recovered on a two-dimensional problem, because in the limit the operator decouples into k independent one-dimensional problems along the columns and the line smoother solves each of them exactly.

Damping over the frequency square, ε = 0.001, y-line relaxationA square of frequency pairs shaded by how much one relaxation sweep damps each mode. The lower-left quarter, which the coarse grid represents, is outlined. A marker sits on the least-damped mode outside it.θx (frequency across x)θy0π/2π0π/2πthe coarse grid'sunder 0.2under 0.40under 0.60under 0.80under 0.95under 1.01damping per sweeptwo routessmoothing factor, scanned0.33closed form0.3330×30 frequency cellsthe marker is the mode nothing removes
Fig. 2 The frequency square under y-line relaxation at ε = 10⁻³, drawn against the same colour bands as the point smoother’s. The pale edge that broke the point smoother has gone; what is left outside the coarse grid’s quarter is damped by at least a factor of three everywhere.

The direction has to be right, and nothing checks it

Relaxing along x — the weak direction — repairs nothing. The smoothing factor is 0.9993, the same number the point smoother gets, because a line smoother in the weak direction inverts the couplings that were never the problem and lags the ones that were.

This is worth dwelling on because it is where the repair’s limitation lives. There is nothing in the code that reads the operator and decides which direction to relax along. Somebody wrote smoother: "liney", and if the anisotropy had run the other way that would have been the wrong choice, at no cost in warnings: the method converges either way, at 0.037 or at 0.967, and the residual history is the only thing that says which.

On a problem whose coefficients vary in space — which is every problem anybody builds this machinery for — no single choice is right everywhere. Alternating line relaxation, which sweeps the columns and then the rows, is the standard answer and costs twice as much; it is not measured here and it is a real omission rather than a hidden one.

The same anisotropy along each axis, ε = 0.001Six horizontal bars of convergence factor. The pairs aimed at the strong direction are short; the same methods on the same problem turned sideways are nearly full length.point · strong in y0.951point · strong in x0.956y-line · strong in y0.037y-line · strong in x0.967semi-y · strong in y0.107semi-y · strong in x0.9661.00 — no convergenceone problem, seen from two sidesy-line, aimed0.037y-line, turned sideways0.97the ratio2631×31 grid, twelve V-cyclesthe direction is in the code, not in the problem
Fig. 3 The same problem seen from two sides. The y-line smoother repairs the orientation it was aimed at, at 0.037 a cycle, and returns 0.967 on the identical problem with the axes swapped. The point smoother, having no direction in it, gives the same answer to both.

What it achieves as a method

The smoothing factor is a statement about one component. The V-cycle built on it, at ε = 10⁻³ on a 31×31 grid, converges at 0.0370 a cycle — better than the isotropic method’s 0.2016, which is worth explaining rather than celebrating.

A line solve is a stronger smoother than a point sweep in every direction, not only the strong one: it removes the whole of the error’s variation along each column exactly, so what it hands to the coarse grid is smoother than what a point smoother hands over on the isotropic problem. The cost is the factor of about three per sweep, so per unit of work the two are comparable and the anisotropic solve is not actually cheaper than the isotropic one. Reporting the cycle count without the cost per cycle would say it was.

The rate is flat in the size, which is the property the whole field is about: 0.0370, 0.0370 and 0.0371 at k = 15, 31 and 63. And it is worth noting what has not been repaired — nothing about the operator changed, the condition number is what it always was, and a Krylov method on this problem is exactly as fast or slow as it was before.

How much of that is the coarse grid, and the answer is: less and less

A convergence factor of 0.037 is better than the isotropic method achieves, and a number that good invites the question of what is producing it. The way to ask is the one the one-dimensional field used: run the same cycle with the coarse-grid correction removed, leaving three line sweeps and nothing else, and see how much is lost.

At ε = 1 the answer is decisive. The V-cycle contracts at 0.271 and the smoother alone at 0.876, so the coarse grid is doing nearly all of the work, exactly as the field’s opening essays say.

As the anisotropy grows that stops being true, and the crossover is gradual and complete:

ε V-cycle smoother alone
1 0.271 0.876
0.3 0.106 0.841
0.1 0.062 0.803
0.03 0.049 0.668
0.01 0.039 0.432
0.001 0.038 0.083

By ε = 10⁻³ the line smoother on its own converges at 0.083 a cycle, and the whole hierarchy below it improves that to 0.038. The coarse grid has stopped being the method and become a refinement.

The reason is not subtle and it is the same limit as before. As ε → 0 the operator decouples into k independent one-dimensional problems along the columns, a y-line solve solves each of them exactly, and a smoother that solves the problem is not a smoother — it is a direct method. So the impressive 0.037 is partly the anisotropy having made the problem easy for this particular smoother, and quoting it as multigrid’s achievement would be crediting the hierarchy for something the tridiagonal solve did.

The honest reading is the middle of that table. At ε between 0.03 and 0.3, both components are contributing and the V-cycle is several times better than either half, which is what a working multigrid method looks like.

V-cycle convergence factor against problem size, ε = 0.001Three flat curves of convergence factor against the number of unknowns on a logarithmic axis. At small anisotropy one sits near one and the others near a tenth.10²10².⁵10³10³.⁵00.250.50.751unknownsresidual reduction per cyclepointy-linesemi-yy-line spread, 4× in size1.1·10⁻⁴point at the largest grid0.97y-line at the largest grid0.03715×15, 31×31, 63×63 interior gridsflat in the size, whatever the anisotropy
Fig. 4 The three methods at ε = 10⁻³ across three grid sizes. The line-relaxation curve is the lowest of the three and flat; the point smoother’s is at the top and equally flat, which is the same observation as before — a broken constant rather than a growth.

The trade, in work rather than in cycles

A convergence factor compares methods only if their cycles cost the same, and these do not. It is worth doing the arithmetic once.

A point sweep on the five-point operator touches five entries a row, so it is five multiply-adds and a division: about seven operations an unknown. A line sweep computes the same defect — five multiply-adds — and then runs a Thomas solve, which for a tridiagonal system is two operations per unknown going forward and two coming back, plus the divisions: about thirteen operations an unknown in total, so roughly twice a point sweep rather than the three times a rough count suggests. The tridiagonal factorisation itself is computed once per line per sweep here; a production code would factor the lines once and reuse them, which takes the ratio nearer 1.5.

Set against that, at ε = 10⁻³ the point method needs 51 cycles to reduce the residual by a decade and the line method needs 0.7. The trade is not close, and it is not close by a factor large enough that the exact cost ratio does not matter — which is the useful form of the statement, since the ratio depends on the implementation and the factor of seventy does not.

Where the ratio would matter is the isotropic problem, and there the answer goes the other way: a line smoother’s V-cycle contracts at 0.271 against a point smoother’s 0.202, so it is both slower per cycle and more expensive per cycle. A line smoother is not a better smoother; it is a smoother aimed at a particular difficulty, and on a problem without that difficulty it is a worse trade in both currencies at once.

The blocks are solvable, which is not free

The Thomas algorithm used for each line solve does no pivoting, and a tridiagonal solve without pivoting is only safe on a matrix that does not need it. So that is asserted rather than assumed.

Every y-line block has diagonal 2ε + 2 and within-line off-diagonal magnitudes summing to at most 2, so the ratio is (2ε + 2)/2 = 1 + ε > 1 and every block is strictly diagonally dominant. The measurement runs at three parameter settings — isotropic, anisotropic and rotated — and reports the worst ratio found: 2 at ε = 1, 1.001 at ε = 10⁻³, and 2 for the rotated operator at 45°.

The 1.001 is the interesting one. The blocks are dominant by a margin that vanishes with ε, which is exactly the regime where a Thomas solve would be expected to lose accuracy, and it does not: the factorisation of a tridiagonal M-matrix has no growth, and the residual of the line solves is at rounding throughout. A margin of 1.001 is a margin.

What is asserted, and what refuses

Every smoother’s measured damping is its symbol. A grid mode is an eigenvector of the line smoother’s iteration matrix as well as the point smoother’s — a fact that stops being true the moment the operator is rotated, and is therefore checked rather than quoted. Five modes, three smoothers, agreement to 10⁻¹⁵.

The scan is the closed form, at six values of ε and five weights, to 10⁻⁹.

Line relaxation in the weak direction does nothing, asserted as a positive statement rather than as an absence: μ > 0.9 for x-line relaxation at ε = 10⁻³, reported alongside the 0.334 for y.

The line blocks are strictly diagonally dominant, at three parameter settings, with the worst margin printed.

And the claim that a point smoother copes is refused. assertThat(μ < 0.5) for point relaxation at ε = 10⁻³ is fed to rejects() and reports 0.9993.

What one weighted Jacobi sweep does to each mode, at ω = 0.67A curve of the damping factor against mode frequency, falling from one at the left through zero and towards minus one at the right. The right-hand half of the plot is shaded, and two horizontal lines mark the worst damping inside it.00.250.50.751-1-0.500.51mode frequency θ / πdamping factor per sweeppredicted±0.333measureda coarse grid seestwo routes to one factorsmoothing factor, scanned0.33smoothing factor, closed form0.33worst mode disagreement4.4·10⁻¹⁶63 interior points, one sweepthe left-hand end is what the coarse grid is for
Fig. 5 The one-dimensional damping curve this essay’s ⅓ comes back to. In one dimension the smoothing factor is ⅓ at ω = 2/3 because the two ends of the oscillatory band are equally bad there; a y-line smoother on the anisotropic problem reproduces that number exactly, because in the limit it is solving one-dimensional problems.
The Galerkin operator at level 1: nine pointsA three-by-three arrangement of discs carrying the stencil's coefficients, with the zero positions drawn small, beside a bar chart of stored entries per row at each level of the hierarchy.-0.0833-0.167-0.0833-0.1671-0.167-0.0833-0.167-0.0833R · A · P, normalised to a unit centrestored entries per rowlevel 0 · 31×314.87/rowlevel 1 · 15×158.22/rowlevel 2 · 7×77.37/rowlevel 3 · 3×35.44/rowlevel 4 · 1×11.00/rowstill a stencil, still annihilates a constantentries in an interior row9weight outside the 3×30row sum0the isotropic model problemnine, at every level below the first
Fig. 6 The coarse operator the line smoother’s V-cycle is built on — the same nine-point Galerkin operator as the isotropic method’s, since changing the smoother changes nothing about the transfers. Only one of the method’s two halves was touched.

What is left

Semi-coarsening, which is the other repair and is the next essay. It leaves the smoother alone and changes the coarse grid instead, and its smoothing factor is identical to this one’s at every ε and every ω — which the closed forms explain and which the convergence factors then contradict, by a factor of about three.

Alternating line relaxation, sweeping columns and then rows, which removes the need to know which direction is strong at the cost of doubling the smoother. It is the standard production answer to a spatially varying anisotropy and it is not measured here.

The rotated case. A line smoother cuts across a strong direction at 45°, which is a stronger statement than “it is not aligned”: the couplings the rotation adds are outside every line, so a line smoother lags all of them by construction. That is measured in the essay this sequence ends with, at 0.784 a cycle, and it is the measurement that makes the algebraic method necessary rather than merely elegant.

What links here

Computed from the collection, not written here: the essays that point at this one.

Named objects

A flat tag is an object no other essay names yet.

AnisotropyBlock jacobiDiagonal dominanceFourier modesLine relaxationSmoothing factorTridiagonal solveWeighted jacobi