Foundations 4: From Equations to Efficient Code

Back to regularizeNd series home

Previous: Foundations 3: Normalization and Residuals

Prerequisites: Foundations 1: Fidelity Equations, Foundations 2: Smoothness and Least Squares, and Foundations 3: Normalization and Residuals.

Learning goals

NoteSource and attribution

This page is adapted from “RegularizeData2D, the Excel Spreadsheet Function for Regularizing 2D Data – Part 1 of 2” by Peter Goldstein, published February 13, 2013 on Math for Mere Mortals (under the username kintaar): https://mathformeremortals.wordpress.com/2013/02/13/regularizedata2d-the-excel-spreadsheet-function-for-regularizing-2d-data-part-1-of-2/ (Goldstein 2013a).

This page is an independent implementation and modernization of that article’s ideas for regularizeNd, not a transcription. Its text, equations, examples, numbers, and figures were written and computed for this site.

Equations on paper, zeros in memory

Foundations 1–3 wrote the fit as one least-squares problem,

\[ \min_z\ \|Az-b\|_2^2, \qquad A=\begin{bmatrix}A_f\\ L\end{bmatrix},\qquad b=\begin{bmatrix}y\\ 0\end{bmatrix}, \]

with \(N_f\) fidelity rows (one per sample), \(N_s=N-2\) smoothness rows, and \(N\) columns (one per output-grid node). On paper, \(A\) is a rectangle of \((N_f+N-2)\times N\) numbers, and the normal matrix \(A^TA\) is a square of \(N\times N\) numbers.

Almost all of those numbers are zero. A fidelity row with linear interpolation touches only the two nodes that bracket its sample. A smoothness row touches only three neighbouring nodes. Neither count depends on \(N\). So as the grid grows, each row stays just as short while the matrix gets wider, and the fraction of entries that are nonzero shrinks toward zero.

Code that stores and multiplies those zeros does work that cannot change the answer. Efficient code stores only the nonzeros, keeps track of where they are, and never creates a matrix whose zeros it would then have to fill in. The rest of this page applies that rule to assembly, storage, and solving.

addpath('fixtures');
r = regularizeNdFoundationsFixtures(Verbose=false);
fx = r.oneD;
x = fx.x;  y = fx.y;  g = fx.grid;  s = fx.smoothness;
nF = numel(x);  N = numel(g);

Assembling the blocks from triplets

A sparse matrix is fully described by three vectors of equal length: a row index \(i_k\), a column index \(j_k\), and a value \(v_k\) for each stored entry. These are called triplets. MATLAB’s sparse(i, j, v, nRows, nCols) turns them into a sparse matrix. Two of its rules matter here: a zero value is not stored, and values that share the same \((i,j)\) pair are added together.

Assembly therefore never needs a dense matrix. Each equation contributes a short, fixed number of triplets, and they can all be computed at once from the samples and the grid.

Fidelity rows. Sample \(i\) in interval \([g_j, g_{j+1}]\) at local fraction \(t_i\) (Foundations 1) contributes two triplets, \((i,\ j,\ 1-t_i)\) and \((i,\ j+1,\ t_i)\). That makes \(2N_f=10\) triplets for the fixture.

lowerNode = @(g) discretize(x, g);                  % g(j) <= x < g(j+1)
frac = @(g, j) (x - g(j)) ./ (g(j+1) - g(j));       % position inside the interval
fidelityTriplets = @(g) deal(repmat((1:nF)', 1, 2), lowerNode(g) + [0 1], ...
    [1 - frac(g, lowerNode(g)), frac(g, lowerNode(g))]);

[iF, jF, vF] = fidelityTriplets(g);
disp(table(reshape(iF', [], 1), reshape(jF', [], 1), reshape(vF', [], 1), ...
    VariableNames=["row i", "column j", "value v"]))

Af = sparse(iF, jF, vF, nF, N);
assert(isequal(Af, fx.system.fidelity))
fprintf('%d fidelity triplets, %d stored nonzeros\n', numel(vF), nnz(Af))
    row i    column j    value v
    _____    ________    _______
      1         1         0.65  
      1         2         0.35  
      2         2            1  
      2         3            0  
      3         2          0.2  
      3         3          0.8  
      4         4          0.6  
      4         5          0.4  
      5         5         0.35  
      5         6         0.65  
10 fidelity triplets, 9 stored nonzeros

The triplet \((2,\ 3,\ 0)\) belongs to sample 2, which sits exactly on node 2. sparse drops its zero value, so \(A_f\) stores 9 nonzeros.

Smoothness rows. Interior node \(j+1\) contributes the three triplets \((j,\ j,\ w_1)\), \((j,\ j+1,\ w_2)\), \((j,\ j+2,\ w_3)\), where \(w_1, w_2, w_3\) are the three-point second-derivative weights of Foundations 2 already multiplied by the scale \(s\sqrt{N_f/N_s}\,(g_N-g_1)^2\). For the fixture that is \(3N_s=12\) triplets, all nonzero.

stencil = @(hL, hR) [2./(hL.*(hL + hR)), -2./(hL.*hR), 2./(hR.*(hL + hR))];
smoothnessTriplets = @(g) deal(repmat((1:numel(g)-2)', 1, 3), (1:numel(g)-2)' + (0:2), ...
    s * sqrt(nF/(numel(g)-2)) * (g(end) - g(1))^2 * stencil(diff(g(1:end-1)), diff(g(2:end))));

[iL, jL, vL] = smoothnessTriplets(g);
L = sparse(iL, jL, vL, N-2, N);
assert(max(abs(L - fx.system.regularization), [], 'all') < 1e-14)
fprintf('%d smoothness triplets, %d stored nonzeros\n', numel(vL), nnz(L))

A = [Af; L];
b = [y; zeros(N-2, 1)];
assert(max(abs(A - fx.system.system), [], 'all') < 1e-14)
12 smoothness triplets, 12 stored nonzeros

Both blocks are built the same way: compute the row, column, and value arrays, then make one sparse call. No loop over rows and no dense intermediate is needed. Figure 1 shows the result. In the stacked \(A\), every row is a short run of adjacent columns. In \(A^TA\), every nonzero lies within two places of the diagonal.

blue = [0 0.447 0.741];  orange = [0.85 0.325 0.098];  gray = [0.5 0.5 0.5];
close all
figure('Position', [100 100 900 420])
tiledlayout(1, 2)

nexttile
[iA, jA] = find(A);
isFid = iA <= nF;
plot(jA(isFid), iA(isFid), 's', 'MarkerSize', 13, 'MarkerFaceColor', blue, ...
    'MarkerEdgeColor', 'k', 'DisplayName', 'fidelity-row nonzero')
hold on
plot(jA(~isFid), iA(~isFid), 's', 'MarkerSize', 13, 'MarkerFaceColor', orange, ...
    'MarkerEdgeColor', 'k', 'DisplayName', 'smoothness-row nonzero')
yline(nF + 0.5, '--', 'Color', gray, 'HandleVisibility', 'off')
axis ij equal; grid on
xlim([0.5 N+0.5]); ylim([0.5 size(A, 1)+0.5]); xticks(1:N); yticks(1:size(A, 1))
xlabel('column (grid node)'); ylabel('row (equation)')
title(sprintf('Stacked A: %d of %d entries nonzero', nnz(A), numel(A)))
legend('Location', 'southoutside')

nexttile
AtA = A' * A;
[iN, jN] = find(AtA);
fromFid = full(Af' * Af);
fromFid = fromFid(sub2ind([N N], iN, jN)) ~= 0;
plot(jN(fromFid), iN(fromFid), 's', 'MarkerSize', 13, 'MarkerFaceColor', blue, ...
    'MarkerEdgeColor', 'k', 'DisplayName', 'from smoothness and fidelity rows')
hold on
plot(jN(~fromFid), iN(~fromFid), 's', 'MarkerSize', 13, 'MarkerFaceColor', orange, ...
    'MarkerEdgeColor', 'k', 'DisplayName', 'from smoothness rows only')
axis ij equal; grid on
xlim([0.5 N+0.5]); ylim([0.5 N+0.5]); xticks(1:N); yticks(1:N)
xlabel('column (grid node)'); ylabel('row (grid node)')
title(sprintf('A''A: %d of %d entries nonzero', nnz(AtA), numel(AtA)))
legend('Location', 'southoutside')
Figure 1: Sparsity patterns for the six-node fixture. Left: the stacked matrix A, with fidelity rows above the dashed line and smoothness rows below it. Right: the normal matrix A’A. Every nonzero of A’A comes from the smoothness rows; the fidelity rows add to a subset of them.

Counting storage

The counts in Figure 1 follow from the row structure, so they can be predicted for any grid. Let \(k\) be the number of samples that sit exactly on a node; each of those rows stores one weight instead of two.

Quantity Formula Why
Entries of dense \(A\) \((N_f+N-2)\,N\) rows times columns
Nonzeros of \(A\) \((2N_f-k)+3(N-2)\) two per fidelity row (one if on a node), three per smoothness row
Entries of dense \(A^TA\) \(N^2\)
Nonzeros of \(A^TA\) \(N+2(N-1)+2(N-2)=5N-6\) the main diagonal and two diagonals on each side, all filled

The last row needs a word of explanation. Entry \((p,q)\) of \(A^TA\) is \(\sum_r A_{rp}A_{rq}\), which is nonzero only if some row of \(A\) touches both node \(p\) and node \(q\). Every row touches at most three consecutive nodes, so \(|p-q|\le 2\). Conversely, the smoothness rows cover every consecutive triple of nodes, so every position in that band is reached. Exact cancellation could in principle remove an entry, but it does not happen here.

To see how the counts scale, the fixture refines every interval of the six-node grid into 2000 equal pieces, giving 10,001 nodes with the same five samples. The refined spacing is \(1/2000\) on the unit intervals and \(1/4000\) on the two half-width intervals. Every sample lies a whole number of refined steps from the start of its interval, so all five samples land on nodes and \(k=5\).

f = 2000;
pieces = arrayfun(@(p) linspace(g(p), g(p+1), f + 1)', 1:N-1, UniformOutput=false);
gFine = unique(vertcat(pieces{:}));
NFine = numel(gFine);

[iF2, jF2, vF2] = fidelityTriplets(gFine);
[iL2, jL2, vL2] = smoothnessTriplets(gFine);
AFine = sparse([iF2(:); nF + iL2(:)], [jF2(:); jL2(:)], [vF2(:); vL2(:)], nF + NFine - 2, NFine);
AtAFine = AFine' * AFine;

onNode = @(g) nnz(ismember(x, g));
predicted = @(n, k) [(nF + n - 2)*n, (2*nF - k) + 3*(n - 2), n^2, 5*n - 6];
counts = [N,     numel(A),     nnz(A),     numel(AtA),     nnz(AtA);
          NFine, numel(AFine), nnz(AFine), numel(AtAFine), nnz(AtAFine)];
format long g
disp(array2table(counts, VariableNames=["nodes", "dense A", "nnz(A)", "dense A'A", "nnz(A'A)"]))

fixtureCounts = [[fx.storage.nodes]', [fx.storage.stackedDenseEntries]', [fx.storage.stackedNonzeros]', ...
                 [fx.storage.normalDenseEntries]', [fx.storage.normalNonzeros]'];
assert(isequal(counts, fixtureCounts))
assert(isequal(counts(1, 2:end), predicted(N, onNode(g))))
assert(isequal(counts(2, 2:end), predicted(NFine, onNode(gFine))))
    nodes     dense A     nnz(A)    dense A'A    nnz(A'A)
    _____    _________    ______    _________    ________
        6           54       21            36        24  
    10001    100050004    30002     100020001     49999  
Nodes Stacked \(A\): dense entries Stacked \(A\): nonzeros \(A^TA\): dense entries \(A^TA\): nonzeros
6 54 21 36 24
10,001 100,050,004 30,002 100,020,001 49,999

The page’s own assembly reproduces the fixture’s counts, and both rows match the formulas with \(k=1\) and \(k=5\). On the coarse grid, sparsity saves little. On the fine grid, \(A\) is 99.97% zeros and \(A^TA\) is 99.95% zeros.

In bytes, at 8 bytes per double, a dense \(A\) on the fine grid would occupy 800,400,032 bytes and a dense \(A^TA\) 800,160,008 bytes, about 800 MB each. MATLAB’s sparse format keeps each stored value (8 bytes) with its row index (8 bytes), plus one 8-byte pointer per column and one more at the end, so it costs about 16 bytes per nonzero rather than 8.

denseBytes = 8 * [numel(AFine), numel(AtAFine)]
info = whos('AFine', 'AtAFine');
sparseBytes = [info.bytes]
assert(isequal(sparseBytes, 16*[nzmax(AFine), nzmax(AtAFine)] + 8*(NFine + 1)))
slots = [nzmax(AFine), nnz(AFine), numel(vF2) + numel(vL2)]
denseBytes = 1×2 double
   800400032   800160008
sparseBytes = 1×2 double
      560128      880000
slots = 1×3 double
       30007       30002       30007

whos reports 560,128 bytes for the sparse \(A\) and 880,000 bytes for the sparse \(A^TA\): under a megabyte each, compared with about 800 MB dense. For \(A^TA\) that is exactly \(16\cdot 49{,}999+8\cdot 10{,}002\). For \(A\) it is \(16\cdot 30{,}007+8\cdot 10{,}002\): sparse sized its storage for all 30,007 triplets it received, five of which were the zero weights of on-node samples that it then dropped.

The zeros waste work as well as memory. Computed entry by entry as dot products of columns, a dense \(A^TA\) costs \((N_f+N-2)\,N^2\) multiply-adds. A row with \(c\) nonzeros, however, can only contribute \(c^2\) products to \(A^TA\), so a sparse product needs only \(\sum_r c_r^2\) of them. That is 53 instead of 324 for the fixture, and 89,996 instead of about \(1.0006\times10^{12}\) on the fine grid.

rowProducts = @(A) full(sum(sum(A ~= 0, 2).^2));
multiplyAdds = [size(A, 1)*N^2,          rowProducts(A);
                size(AFine, 1)*NFine^2,  rowProducts(AFine)];
disp(array2table([[N; NFine], multiplyAdds], VariableNames=["nodes", "dense product", "sparse product"]))
format short
    nodes    dense product    sparse product
    _____    _____________    ______________
        6              324           53     
    10001    1000600090004        89996     

The band of \(A^TA\)

\(A^TA\) has bandwidth 2: every nonzero is at most two places from the diagonal, so the matrix is pentadiagonal. On this page, bandwidth \(p\) always means that largest distance \(|i-j|\) from the diagonal; some texts call the same quantity the half-bandwidth. \(A^TA\) is also symmetric and, because \(A\) has full column rank (Foundations 2), positive definite. That makes it a candidate for a Cholesky factorization \(A^TA=R^TR\), with \(R\) upper triangular.

A standard result for banded matrices is that the Cholesky factor of a symmetric positive definite matrix with bandwidth \(p\) has the same bandwidth: elimination creates no nonzeros outside the band (Golub and Van Loan 2013, sec. 4.3). Here \(p=2\), so \(R\) has at most three nonzeros per row. For the six-node matrix that is \(3N-3=15\) nonzeros, and on the 10,001-node grid it is 30,000.

The inverse behaves completely differently. Each entry of \((A^TA)^{-1}\) tells how a change in the right-hand side at one node moves the solution at another node. Because the band links every node to its neighbours in a single chain, every node influences every other, and in general no entry of the inverse is zero. The cell below computes the inverse of two small normal matrices only to count its nonzeros. Nothing on this page, or in regularizeNd, uses an inverse to solve.

[iN, jN] = find(AtA);
bandwidthAtA = max(abs(iN - jN))
R = chol(AtA);                        % upper-triangular Cholesky factor, no reordering
[iR, jR] = find(R);
bandwidthR = max(jR - iR)
assert(bandwidthAtA == fx.projection.bandwidth && bandwidthR == fx.projection.choleskyUpperBandwidth)
assert(norm(R'*R - AtA, 'fro') < 1e-12)

RFine = chol(AtAFine);
nnzFactor = [nnz(R), nnz(RFine)]

% Diagnostic of fill only: count the nonzeros of the inverse. Never solve with it.
nnzInverse6 = nnz(inv(full(AtA)))
pieces = arrayfun(@(p) linspace(g(p), g(p+1), 17)', 1:N-1, UniformOutput=false);
g81 = unique(vertcat(pieces{:}));
[iF3, jF3, vF3] = fidelityTriplets(g81);
[iL3, jL3, vL3] = smoothnessTriplets(g81);
A81 = sparse([iF3(:); nF + iL3(:)], [jF3(:); jL3(:)], [vF3(:); vL3(:)], nF + numel(g81) - 2, numel(g81));
nnzInverse81 = [nnz(inv(full(A81' * A81))), numel(g81)^2]
bandwidthAtA = 2
bandwidthR = 2
nnzFactor = 1×2 double
          15       30000
nnzInverse6 = 36
nnzInverse81 = 1×2 double
        6561        6561
figure('Position', [100 100 1000 380])
tiledlayout(1, 3)
patterns = {AtA, R, inv(full(AtA))};
names = ["normal matrix A'A", "Cholesky factor R", "inverse (diagnostic only)"];
colors = [blue; blue; orange];
for p = 1:3
    nexttile
    [ip, jp] = find(patterns{p});
    plot(jp, ip, 's', 'MarkerSize', 12, 'MarkerFaceColor', colors(p, :), ...
        'MarkerEdgeColor', 'k', 'DisplayName', 'nonzero entry')
    axis ij equal; grid on
    xlim([0.5 N+0.5]); ylim([0.5 N+0.5]); xticks(1:N); yticks(1:N)
    xlabel('column'); ylabel('row')
    title(sprintf('%s: %d nonzeros', names(p), nnz(patterns{p})))
    legend('Location', 'southoutside')
end
Figure 2: Nonzero patterns for the six-node fixture. The normal matrix A’A is pentadiagonal (left). Its Cholesky factor R keeps the band (middle). Its inverse, computed here only to show its pattern, has no zero entries at all (right).

The inverse of the six-node normal matrix has all 36 entries nonzero. On the 81-node grid (16 pieces per interval) all 6,561 entries are nonzero as well, while the Cholesky factor of that matrix keeps its band.

Factor and solve; do not invert

On paper the solution of the normal equations is written \(z=(A^TA)^{-1}A^Tb\). That formula says what \(z\) is, not how to compute it. A program should solve the system with a factorization instead, for three reasons.

  • Fill. A banded factor needs storage proportional to \(N\): 30,000 nonzeros on the 10,001-node grid. The inverse is dense, so it needs \(N^2\) entries: 100,020,001 numbers, about 800 MB, for a matrix whose own sparse form fits in under a megabyte.
  • Work. These are standard textbook operation counts (Golub and Van Loan 2013), stated here as counts, not timings. A dense Cholesky factorization of an \(n\times n\) matrix costs about \(n^3/3\) flops, and forming a dense inverse costs more, on the order of \(n^3\). A band Cholesky with bandwidth \(p\) costs about \(n(p^2+3p)\) flops, linear in \(n\), and the two triangular solves that follow cost on the order of \(np\). For \(n=10{,}001\) and \(p=2\) that is about \(3.3\times10^{11}\) flops for dense Cholesky alone, against about 100,010 for the band version.
  • Accuracy. A factorization gives a backward stable solve, but of the problem it is handed. Cholesky is backward stable for the system \(A^TAz=A^Tb\): the computed \(z\) exactly solves a slightly perturbed version of that system (Higham 2002, ch. 10). QR on \(A\) is backward stable for the least-squares problem itself: the computed \(z\) exactly minimizes \(\|(A+\Delta A)z-(b+\Delta b)\|_2\) for small \(\Delta A\) and \(\Delta b\) (Higham 2002, ch. 20). Multiplying by a computed inverse is not backward stable in general and can leave a larger residual (Higham 2002, sec. 14.1).

MATLAB’s backslash operator follows this rule. It inspects the matrix and solves with a factorization suited to it; for a sparse rectangular matrix that is a QR factorization. Neither route below forms an inverse.

rhs = A' * b;                         % equals Af'*y: the smoothness rows have zero right-hand side
zNormal = AtA \ rhs;                  % normal equations, sparse factorization
zQR = A \ b;                          % least squares on A directly, sparse QR

assert(max(abs(zNormal - fx.system.solution)) < 1e-12)
assert(max(abs(zQR - fx.system.solution)) < 1e-12)
table(g, zNormal, zQR, VariableNames=["node g", "(A'A)\(A'b)", "A\b"])
ans = 6×3 table
node g (A'A)\(A'b) A\b
0 0.9508 0.9508
1 1.2046 1.2046
2 0.6536 0.6536
2.5000 0.8810 0.8810
3 0.9258 0.9258
4 -0.0477 -0.0477

Both agree with the fixture’s solution to round-off. Which route is safer on a harder problem depends on conditioning, which Foundations 5 measures.

Forming \(A^TA\): product or accumulation

\(A^TA\) does not have to come from a matrix product. Each row of \(A\) adds its own small contribution to \(A^TA\) and to \(A^Tb\), so the normal equations can be accumulated row by row without ever storing \(A\). Foundations 5 traces that accumulation.

Connection to regularizeNd

regularizeNdMatrices builds both blocks with exactly the pattern above: arrays of row indices, column indices, and weights, passed to one sparse call per block. The excerpts below come from the 'linear' branch and the smoothness loop at upstream revision ef77fd0 (abridged; comments added):

% Fidelity block: one row per sample, 2^nDimensions weights per row.
Afidelity = sparse(repmat((1:nScatteredPoints)',1,N_POINTS_PER_DIMENSION^nDimensions), ...
    xWeightIndex, weight, nScatteredPoints, nTotalGridPoints);

% Smoothness block for one axis: three weights per row.
Lreg{iDimension} = sparse(repmat((1:nSmoothnessEquations(iDimension))',1,3), ...
    [index1, index2, index3], ...
    smoothness(iDimension)*smoothnessScale*axisScale*secondDerivativeWeights(...), ...
    nSmoothnessEquations(iDimension), nTotalGridPoints);

The row-index argument is a matrix with one row per equation, the column indices xWeightIndex and [index1, index2, index3] have the same shape, and the weights line up with them, just as iF, jF, and vF do on this page. regularizeNd then stacks the blocks, frees the separate copies, and solves (abridged; comments added):

A = vertcat(Afidelity, Lreg{:});
clear(getname(Afidelity), getname(Lreg));

switch solver
  case '\'
    yGrid = A\[y;sparse(nTotalSmoothnessEquations,1)];
  case 'normal'   % the default
    yGrid = (A'*A)\(A'*[y;sparse(nTotalSmoothnessEquations,1)]);
  % 'pcg', 'symmlq', and 'lsqr' are iterative alternatives
end

The default 'normal' solver is a sparse product followed by backslash on the sparse normal matrix: the AtA \ rhs route above. The '\' solver is backslash on \(A\), the QR route. The package is not run on this page; the fixture script reproduces these matrices and solutions, and its recorded package cross-check agreed to within \(8.88\times10^{-16}\). For which solver to choose, and when, see Solving in the deep dive.

How this differs from the original

  • No stacked matrix. The original is an Excel VBA function, and it never builds \(A\). It loops over the samples and the interior nodes and adds each row’s contribution straight into \(A^TA\) and \(A^Tb\) (Goldstein 2013b). regularizeNd instead assembles a sparse \(A\) and lets MATLAB compute A'*A as a sparse product. The two give the same matrix, as Foundations 5 checks.
  • Band storage instead of general sparse storage. The original stores the normal matrix compactly as \(N\) rows of five numbers, one column per diagonal, so each entry’s position is implied by where it sits. MATLAB’s general sparse format stores a row index with every value, at roughly twice the bytes per nonzero, but accepts any pattern.
  • Its own solver. The original solves with a hand-written Gaussian elimination and back-substitution specialized to five bands. regularizeNd hands the system to MATLAB’s backslash, which factors it without an inverse, and also offers QR on \(A\) and the iterative solvers pcg, symmlq, and lsqr. The original article also explains why it moved away from the explicit inverse that its earlier spreadsheet relied on.
  • Why the five-band solver does not generalize. The fixed band is a property of 1D input. With 2D input the bandwidth grows with the grid stride, the distance in the node numbering between neighbours along the slower axis. In the 4-by-3 surface fixture of Foundations 6–7, the normal matrix has bandwidth 8 in the fixture’s node order, where the 4-node axis varies fastest. regularizeNd reduces the stride by ordering the axes smallest-first, which puts the 3-node axis first and gives bandwidth 6. Either way the band widens with the grid, so regularizeNd relies on general sparse factorization rather than a five-band routine.
  • Terminology and scope. The original calls one input and one output “2D data”; this site calls it 1D input. This page leaves out the original’s spreadsheet interface and its timing code, and makes no timing claims; every comparison above is a count.

With the blocks assembled sparse and the solve done by factorization, what remains is to see what each row actually adds to the normal equations. The next page traces one fidelity row and one smoothness row into \(A_f^TA_f\), \(L^TL\), and \(A_f^Ty\), and solves the system step by step.

Next

Back to regularizeNd series home

Previous: Foundations 3: Normalization and Residuals

Next: Foundations 5: Projecting and Solving the 1D System

References

Goldstein, Peter. 2013a. “RegularizeData2D, the Excel Spreadsheet Function for Regularizing 2D Data – Part 1 of 2.” Math for Mere Mortals. https://mathformeremortals.wordpress.com/2013/02/13/regularizedata2d-the-excel-spreadsheet-function-for-regularizing-2d-data-part-1-of-2/.
———. 2013b. “RegularizeData2D, the Excel Spreadsheet Function for Regularizing 2D Data – Part 2 of 2.” Math for Mere Mortals. https://mathformeremortals.wordpress.com/2013/02/17/regularizedata2d-the-excel-spreadsheet-function-for-regularizing-2d-data-part-2-of-2/.
Golub, Gene H., and Charles F. Van Loan. 2013. Matrix Computations. 4th ed. Baltimore: Johns Hopkins University Press.
Higham, Nicholas J. 2002. Accuracy and Stability of Numerical Algorithms. 2nd ed. Philadelphia: Society for Industrial and Applied Mathematics. https://doi.org/10.1137/1.9780898718027.