Fundamentals / Numerical mathematics / Numerical linear algebra

Conditioning and backward error

Distinguish an inaccurate measurement from an inaccurate solve by tracing how each changes the answer to a small equilibrium problem.

From first principles

Derive the relative error in a linear solve

Suppose measured data \(b\) determine unknowns through \(Ax=b\), with \(A\) square and nonsingular. Keep the coefficients fixed and change only the measured data by \(\delta b\). Subtracting the two equations removes the unperturbed solution exactly,

\[A(x+\delta x)-Ax=\delta b,\]
\[\delta x=A^{-1}\delta b .\]

Choose a vector norm and its induced matrix norm, defined as the largest stretch of a unit vector. Applying the induced norm first to the perturbation and then to the original data gives

\[\begin{aligned} \|\delta x\| &= \|A^{-1}\delta b\| \leq \|A^{-1}\|\,\|\delta b\|,\\ \|b\| &= \|Ax\| \leq \|A\|\,\|x\|. \end{aligned}\]

For nonzero \(b\) and \(x\), combine these two inequalities to express both errors as fractions,

\[\frac{\|\delta x\|}{\|x\|}\leq\|A\|\,\|A^{-1}\|\frac{\|\delta b\|}{\|b\|}.\]

The product is the normwise condition number. It concerns the problem even when the solver is exact. For a computed solution one can instead insert its measured residual as the data perturbation. The norm bound allows the most sensitive possible orientation of that perturbation, so a particular residual can give a considerably smaller error.

Background · Condition number
\[\kappa(A)=\|A\|\|A^{-1}\|\]

For an invertible square matrix choose a compatible norm. Conditioning describes data sensitivity, while stability refers to the algorithm processing the data.

A unit circle of input perturbations and its image under diagonal scaling. Horizontal radius stays one and vertical radius shrinks to 0.12.Open full-size diagram
Which measurement error gets amplified in the inverse? The image of the unit circle under diag(1, 0.12) supplies both singular values geometrically. An error of 0.012 in the second measured component becomes 0.1 in the reconstructed input. The identical measurement error along the horizontal axis stays 0.012. The direction of the error matters alongside its magnitude.

Derivation and applications

Bound each recovered coordinate using instrument tolerances

Sensors often have different tolerances expressed in different physical units. A perturbation ball based on an overall norm discards this information. Assume \(A\) is known and invertible, and let the calibrated uncertainty of reading \(j\) be an independent interval \(|\delta b_j|\leq t_j\). Here independent means all sign combinations are admissible, without a probabilistic assumption. Writing the solution perturbation row by row gives

\[\delta x_i=\sum_j (A^{-1})_{ij}\delta b_j .\]

The triangle inequality provides an upper bound. It is also attainable for a specified coordinate: choose the perturbation signs to agree with the signs of that row. Thus the smallest symmetric enclosing interval for that coordinate is

\[\max_{|\delta b_j|\leq t_j}|\delta x_i|=\sum_j |(A^{-1})_{ij}|t_j=(|A^{-1}|t)_i .\]

One can evaluate the same quantity for a reported linear output \(z=c^Tx\) without forming the whole inverse. Solve one transposed system \(A^Tw=c\); then the output is \(w^Tb\) and its extreme uncertainty follows from the same sign argument,

\[|\delta z|_{\max}=|w|^Tt,\]
\[A^Tw=c .\]

The maximizing perturbations for different coordinates may conflict. A vector of separate coordinate bounds therefore describes an enclosing box; its corners need not be reachable simultaneously. Calibration information tying two errors to the same bias would change the admissible set and can substantially alter the bound.

Worked example

Bound a difference from two calibrated sensors

Take readings \(b_1=x_1+x_2\) and \(b_2=x_1-x_2\), with tolerances \(0.020\) and \(0.080\) in common units. Reconstructing \(x_2=(b_1-b_2)/2\) gives worst error \(0.050\), attained when the two readings move in opposite directions. For \(x_1+x_2=b_1\) the error bound is only \(0.020\). Adding the two individual coordinate bounds would yield \(0.100\) and miss their shared dependence on the data.

Second application

Choose the more effective recalibration

A second reconstruction reports \(z=0.1b_1+4b_2\), with tolerances \(0.50\) and \(0.050\). Its worst error is \(0.250\). Halving the tolerance of the first sensor reduces it to \(0.225\), while halving the second reduces it to \(0.150\). The second recalibration yields a fourfold larger reduction despite its smaller raw tolerance.

OneSimulation laboratory

Separate algebraic error from mesh error

Start from this chapter. A small residual controls solution error only through the inverse operator. Compare iterative and direct solutions on identical nodes before changing mesh size.

Compare recorded OneSimulation runs on this page. To test your own inputs, download the Python model and run the model in an activated OneSimulation environment.

A unit cube has conductivity 1 W/(m·K), uniform heating 1 W/m³ and zero temperature rise on every face. The script compares CG and a direct solver on the same trilinear finite-element mesh. Predict the effects of first refining the mesh and then relaxing only the CG tolerance. Download the Python experiment · OneSimulation linear solvers.

python linear-algebra.py
python linear-algebra.py --cells 10
python linear-algebra.py --cells 10 --rtol 0.05
Solver comparison on the heated cube. The difference uses all nodes.
Cells per axis, CG toleranceDirect peak (K)CG peak (K)Max. difference (K)
5, 10⁻¹⁰0.054830740.054830742.8 × 10⁻¹⁷
10, 10⁻¹⁰0.057089000.057089003.6 × 10⁻¹³
10, 0.050.057089000.056207828.8 × 10⁻⁴
On the ten-cell mesh, relaxing the CG tolerance increases the peak solver-to-solver difference to about 0.00088 K. The logarithmic axis resolves the many orders of magnitude.
On the ten-cell mesh, relaxing the CG tolerance increases the peak solver-to-solver difference to about 0.00088 K. The logarithmic axis resolves the many orders of magnitude.

The refined mesh includes the cube centre as a node, whereas the five-cell mesh samples the peak off-centre. The change between direct nodal maxima therefore includes a sampling effect. The final two rows use identical nodes, isolating the effect of the CG stopping test. Differences near roundoff can vary between implementations.

Change parameters · Change the laboratory inputs

Change one input at a time and compare the recalculated curves with the argument above. The browser evaluates this small model locally; the accompanying numerical values state its assumptions and reference checks. Reset restores the reference inputs, and the data can be downloaded as CSV.

Problem sheet 3 · Bound the effect of stopping a linear solve early

Read the model setup and preparatory problems

Determine which perturbations a machine can represent

A computed residual is assembled from rounded operations. To interpret a small residual we need a scale for each rounding. In a normalized binary system with \(p\) significant bits, including the leading one, positive numbers in \([2^e,2^{e+1})\) have the form \(2^e(1+k\,2^{1-p})\). Increasing the integer \(k\) by one advances by \(2^{e+1-p}\). Thus absolute spacing grows with the size of the number. At a power of two, the neighbours on the two sides even have different spacings.

Rounding to nearest incurs at most half a spacing. Dividing by the smallest magnitude \(2^e\) in that interval gives the relative bound \(u=2^{-p}\), called unit roundoff. For a normal result of suitable magnitude one can write \(\operatorname{fl}(z)=z(1+\delta)\), \(|\delta|\leq u\). In binary64, \(p=53\). The distance from one to its larger neighbour is \(2^{-52}\), twice the unit roundoff. Subnormal numbers maintain a constant absolute spacing towards zero. The uniform relative estimate above does not extend through zero or to overflows.

Suppose an instrument adds the increments \(2^{-53}\) twice to a unit baseline. The exact result is \(1+2^{-52}\). With round-to-nearest, ties-to-even, \(1+2^{-53}\) is halfway between one and its successor. The lower endpoint has even trailing significand, so it rounds to one. Adding the second increment separately hits the same tie again. Grouping the increments first produces the representable \(2^{-52}\). Adding this to one then advances one spacing. Identical mathematical data can therefore yield different rounded sums.

Now take \(1+2^{-52}\) and subtract one. The difference \(2^{-52}\) is represented exactly, even though it is tiny relative to the original numbers. Cancellation becomes damaging when nearby operands already contain error relative to their difference. Recording the precision, order of accumulation and scale of the data lets us distinguish this effect from sensitivity of the underlying linear system.

Practise on sheet 1 · Predict a dot product in a tiny floating-point system. Further reading · Heidelberg University · R. Herzog, Einführung in die Numerik · Chapter 2, §§5–6 · Zahldarstellung und Rechnerarithmetik · KIT · P. E. Bradley, Numerische Mathematik · §§1.1–1.5 · Gleitkomma-Arithmetik · RWTH Aachen · A. Reusken, Numerische Analysis I · §§2.2.1 and 2.3 · Zahlendarstellungen, Stabilität eines Algorithmus.

Two questions about a reported solution

Suppose you determine two unknown forces by balancing their components in two directions. If the directions are almost parallel, the second measurement repeats much of the first. A machine can solve both written equations very accurately while the inferred forces vary considerably from trial to trial. To understand this, separate the map from data to physical answer from the algorithm used to evaluate that map. Conditioning describes the map locally near the supplied data. Stability describes the calculation that produced an answer from those data.

Let \(A\) be a nonsingular real matrix, let \(Ax=b\) and suppose that only the right-hand side changes. Subtract \(Ax=b\) from \(A(x+\delta x)=b+\delta b\). The result \(A\delta x=\delta b\) says that \(A^{-1}\) maps the measurement disturbance into the answer. In a consistent norm,

\[\|\delta x\|\leq\|A^{-1}\|\|\delta b\|.\]

To compare percentages rather than units, use \(\|b\|\leq\|A\|\|x\|\) and divide through by \(\|x\|\). For nonzero \(b\) this gives

\[\frac{\|\delta x\|}{\|x\|}\leq\|A\|\|A^{-1}\|\frac{\|\delta b\|}{\|b\|}.\]

The product is the condition number in the specified norm. Rotating the disturbance relative to the singular vectors changes the actual amplification, so a worst-case bound alone cannot tell which measurement caused trouble.

Background · How can changing units change a condition number?

Suppose two independent instruments measure a length and a force. In chosen reference units the measurement matrix is the identity. If the first instrument reports the same length in millimetres rather than metres, its numerical output is multiplied by a thousand. Measuring input and output perturbations with unweighted Euclidean norms then produces a condition number of 1000. The physical readings have exactly the same precision as before.

Represent the instrument uncertainties by standard deviations \(s_i\), and scale each output by its own \(s_i\). Under a change of units, both the first measurement and its uncertainty acquire the factor 1000. Their ratio stays fixed. A physically meaningful sensitivity analysis also scales the unknowns when their units differ. If \(D_y,D_x\) contain the respective reference scales, the operator to examine is

\[A_{\rm scaled}=D_y^{-1} A D_x.\]

Report those scales next to a condition number. An apparently large change in conditioning can then be traced to sensor precision, physical coupling, or simply the coordinates used to report them.

Resolve the sensitive direction

Consider \(A=\left(\begin{smallmatrix}1&1\\1&1.001\end{smallmatrix}\right)\) and \(b=(2,2.001)^T\). The exact answer is \((1,1)^T\). Subtract the first measurement from the second. The difference, 0.001, is exactly 0.001 times the second unknown. If the second measurement increases by 0.0001, its inferred value increases to 1.1. The first unknown must fall to 0.9 to preserve the first measurement. Neither individual equilibrium equation looks unstable by itself. It is their near redundancy that makes the difference sensitive.

The infinity norm makes the scale explicit. The largest absolute row sum of \(A\) is 2.001. Its inverse is \(1000\left(\begin{smallmatrix}1.001&-1\\-1&1\end{smallmatrix}\right)\), whose largest row sum is 2001. The relative data change is \(0.0001/2.001\) while the relative solution change is 0.1. Multiplying the data change by the condition number gives about 0.200, a valid upper bound. Had the two measurements increased equally, their difference would have stayed fixed and the same amplification would not occur.

Ask which equations the machine solved

For a computed vector \(\hat x\), form \(r=b-A\hat x\). In exact arithmetic \(\hat x\) solves \(A\hat x=b-r\) exactly. Consequently \(\|r\|/\|b\|\) is a relative backward error when only \(b\) may change. In our example the vector \((0.9,1.1)^T\), tested against the original right-hand side, has a small residual in the second row. It is both an accurate answer to a nearby set of measurements and a poor estimate of the original forces.

If the rows carry different physical units, an unscaled residual can let one equation dominate the judgement. Scale each balance by a stated characteristic magnitude or report the residuals separately. Recompute them from the original data when possible. Feeding the same rounded intermediate quantities back into a consistency check may merely confirm the internal arithmetic. For a sensitive inverse map, improving the accuracy of the input or measuring an independent direction can accomplish more than tightening the solver tolerance.

Allow uncertainty in the coefficients

If directions as well as forces are measured, the perturbed equations are

\[(A+\delta A)(x+\delta x)=b+\delta b.\]

Keeping first-order terms gives

\[A\delta x\simeq\delta b-\delta A\,x.\]

Uncertainty in a coefficient therefore contributes an effective disturbance proportional to the magnitude of the state it multiplies. Reporting only uncertainty in the measured right-hand side can underestimate the final error.

For a scalar calibration \(a x=b\), logarithmic differentiation gives

\[\delta x/x\simeq\delta b/b-\delta a/a.\]

If both measurements are 1% too large with the same sign, their errors cancel exactly in the ratio. Opposite 1% changes give \(1.01/0.99-1\simeq2.02\%\). Componentwise measurement correlations affect typical errors even though a norm bound has to allow the worst admissible combination. In force reconstruction this is a reason to keep calibration information with the measured balances.

Compute a condition number for a particular observable

Suppose a linear solve is used only to predict \(q=c^Tx\), rather than every component of the state. Let \(A\) be fixed and nonsingular. Perturb the load by \(\delta b\); the output changes by \(c^TA^{-1}\delta b\). Solve the dual system \(A^Tz=c\). Then the exact change is \(z^T\delta b\), and Cauchy–Schwarz gives

\[|\delta q|\le\|z\|_2\|\delta b\|_2.\]

Equality is possible by choosing a load error parallel to \(z\). The absolute condition number of this observable with respect to this load norm is consequently \(\|z\|_2\). It can be much smaller than the worst amplification over all outputs.

The error model matters to the result. If each source instead has its own bounded relative uncertainty \(|\delta b_i|\le\epsilon |b_i|\), the worst change is \(\epsilon\sum_i|z_i b_i|\). The bound is attained by choosing the signs of the perturbations to make every term reinforce the same output change. For independent mean-zero source errors with covariances collected in \(\Sigma\), the variance is \(z^T\Sigma z\), generally smaller than a worst-case bound. A worst-case condition number and a statistical standard deviation answer different questions even when evaluated using exactly the same dual solution.

Which of two coupled readings can be predicted?

Take \(A=\left(\begin{smallmatrix}1&1\\1&1.02\end{smallmatrix}\right)\) and load \(b=(2,2.02)^T\). Subtracting the equations gives \(0.02x_2=0.02\), and back-substitution gives

\[x=(1,1)^T.\]

For a prediction of the sum \(q_s=x_1+x_2\), the dual vector is \(z_s=(1,0)^T\): the first equation already reports that sum. For the difference \(q_d=x_1-x_2\), subtract twice the inferred \(x_2\) from the first equation. This gives \(q_d=101b_1-100b_2\), so \(z_d=(101,-100)^T\). These two physically simple outputs depend on the same pair of source readings in strikingly different ways.

With each reading uncertain by at most 0.001 in absolute units, the sum can change by at most 0.001. The difference can change by as much as 0.201 when the errors have opposite signs. With a single common offset of 0.001 in both readings, however, the difference changes by only 0.001 because the two large terms nearly cancel. The nominal difference is zero, so relative error in that output is undefined. An absolute tolerance or a physically chosen reference amplitude provides a meaningful accuracy requirement.

A designer considering improved load cells should therefore ask whether calibration drift is shared or independent and whether the useful output is a sum or a difference. Reporting just the matrix condition number gives no way to recover either piece of information. If the coefficients of \(A\) are uncertain as well, the effective right-hand side also contains the term \(-\delta A\,x\) to first order. Its direction can be entirely different from plausible measurement errors in \(b\).

A direct numerical perturbation illustrates the worst bounded case. Increasing \(b_1\) by 0.001 and decreasing \(b_2\) by 0.001 gives \(x_2=0.90\) and \(x_1=1.101\). The output difference has changed by 0.201 exactly, demonstrating that the sign choice in the componentwise bound is achievable.

Rotate a residual without changing its norm

Let \(A=\operatorname{diag}(1,s)\) and take a unit residual \(r=(\cos\theta,\sin\theta)\). Compute the correction solving \(A e=r\). Its size depends on alignment even though the residual norm remains exactly one.

Rotate a residual without changing its norm. Horizontal axis: Angle from first left singular direction (degrees). Vertical axis: Solution error / residual norm. Data follow the figure.
For s = 0.02 the correction ranges from one to fifty. The condition number gives the largest possible amplification; a residual norm alone does not identify the direction actually excited.
Read values from the plot
Solution error / residual norm at selected values of Angle from first left singular direction (degrees).
Angle from first left singular direction (degrees)Small singular value 0.5Small singular value 0.1Small singular value 0.02
0111
451.58117.106335.362
9021050
1351.58117.106335.362
180111

Download all 361 plotted samples (CSV)

Change parameters · Rotate a residual without changing its norm

Change one input at a time and compare the recalculated curves with the argument above. The browser evaluates this small model locally; the accompanying numerical values state its assumptions and reference checks. Reset restores the reference inputs, and the data can be downloaded as CSV.

Study the full derivation

When stable eigenvalues allow large transient growth · Matrix computations and spectral accuracy

Two damped states exchange energy in only one direction. Its eigenvalues predict ultimate decay, while a short-time response can grow by a large factor. Compute the matrix exponential, its gain and a resolvent-based sensitivity check.