Subtracting a projection in finite precision
Let \(A\) be a real \(m\)-by-\(n\) matrix, with \(m\ge n\) and independent columns. The first unit vector is \(q_1=a_1/\|a_1\|_2\). To construct another, classical Gram–Schmidt computes all coefficients \(r_{ij}=q_i^Ta_j\) against the original column before subtracting the sum. Modified Gram–Schmidt instead updates a running residual \(v\) after each projection, computing the next coefficient from that residual.
In exact arithmetic the two formulas agree by orthogonality. In floating point, a component along an earlier \(q_i\) can survive subtraction. Dividing by the norm of a nearly cancelled column amplifies that component. For the three columns of the matrix with first row \((1,1,1)\) and lower block \(\delta I_3\), the difference of two original columns has size proportional to \(\delta\). Computing both of the third column's coefficients before either subtraction carries the error of previously computed directions into both coefficients. Sequential projection removes some of that contamination. A second pass projects the surviving residual again. Monitor both \(\|A-QR\|/\|A\|\) and \(\|I-Q^TQ\|\). A small first diagnostic alone permits poor orthogonality.
Why a reflector gives a backward-error result
Given nonzero \(x\), set \(v=x+\operatorname{sign}(x_1)\|x\|e_1\), using positive sign at zero. Then \(H=I-2vv^T/(v^Tv)\) is orthogonal and \(Hx\) has only its first entry nonzero. The sign ensures the construction of \(v_1\) adds magnitudes. Assume normal-range floating-point arithmetic with unit roundoff \(u\) and \(mu\ll1\). A length-\(m\) dot product has absolute error bounded by \(\gamma_m |v|^T|x|\), with \(\gamma_m=mu/(1-mu)\), by multiplying the factors \(1+\delta_i\), \(|\delta_i|\le u\), along the sum. Cauchy–Schwarz bounds this by \(\gamma_m\|v\|\|x\|\).
Apply a stored, normalised reflector as a dot product and an axpy. Each column incurs a perturbation of order \(mu\) times its norm, including normalisation error. The exact reflector for the stored direction has norm one. Pull each local error backwards through the preceding exact orthogonal transformations and add. In Frobenius norm this yields
where \(C\) accommodates the implementation's fixed number of elementary operations. This explains the nature of the bound without claiming an implementation-independent sharp constant. A tiny singular value may still have large relative uncertainty under this absolute perturbation.
Turn a rectangular matrix into a bidiagonal one
Apply a left reflector to column 1 and a right reflector to row 1, starting its operation in column 2. Repeat on the trailing block. Each transformation preserves earlier zeros. This yields \(A=UBV^T\) with orthogonal factors and upper bidiagonal \(B\). As a concrete first step take rows \((3,0),(4,5),(0,12)\). Multiplying the first two rows by the rotation with rows \((3/5,4/5),(-4/5,3/5)\) leaves rows \((5,4),(0,3),(0,12)\). A second left rotation combines \(3,12\), giving diagonal entries \(5,\sqrt{153}\) and superdiagonal \(4\). Two columns make the right step trivial here. A third column would require eliminating the new first row's tail.
For a bidiagonal matrix one can carry out shifted QR on \(B^TB\) implicitly. If the first diagonal and off-diagonal entries of that tridiagonal matrix are \(a,b\), select a right rotation from \((a-\mu,b)\). Applying it to \(B\) introduces a subdiagonal entry. A left rotation eliminates that entry and moves the disturbance to the next column pair. Repeat to the bottom and accumulate both sets of rotations. Vanishing superdiagonals split independent blocks. This obtains singular values without explicitly storing an already rounded Gram matrix. For two almost parallel sensor columns \((1,\delta,0)^T,(1,-\delta,0)^T\) the singular values are \(\sqrt2,\sqrt2|\delta|\). The entries \(1\pm\delta^2\) of the Gram matrix can round to the same number.
OneSimulation experiment · Resolve the smaller singular value
Change the separation grid. Which lost singular value can a direct SVD still measure?
Download the executable notebook · Python source
Adjust the experiment in the browser. Move the selected separation across the loss threshold and switch between binary32 and binary64 arithmetic. The Gram estimate evaluates the rounded difference \((1+\delta^2)-(1-\delta^2)\); the stable comparison uses the exact orthogonality of the two nonzero rows. It is an analytic benchmark, while the notebook below runs the rectangular SVD and OneSimulation eigenvalue solver. Locate the threshold near \(\delta\sim\sqrt{u}\), then explain why changing arithmetic precision cannot recover information already lost in noisy measurements.
"""Measure loss of the weaker of two almost parallel sensor directions."""
import matplotlib.pyplot as plt
import numpy as np
from onesim.numerics.linear.matrices.dense_linear_algebra import symmetric_eigenvalues
separations = np.logspace(-12, -2, 31)
direct, normal = [], []
for delta in separations:
matrix = np.array([[1.0, 1.0], [delta, -delta], [0.0, 0.0]])
reference = np.sqrt(2.0) * delta
direct.append(np.linalg.svd(matrix, compute_uv=False)[-1] / reference)
smallest = symmetric_eigenvalues(matrix.T @ matrix)[0]
normal.append(np.sqrt(max(smallest, 0.0)) / reference)
assert np.allclose(direct, 1.0)
assert normal[0] == 0.0
print(f"At delta={separations[0]:.0e}: direct/reference={direct[0]:.3f}, Gram/reference={normal[0]:.3f}")
fig, ax = plt.subplots(figsize=(7, 4), layout="constrained")
ax.semilogx(separations, direct, label="Direct rectangular SVD")
ax.semilogx(separations, normal, "o-", ms=3, label="Eigenvalues of the Gram matrix")
ax.set(xlabel="Separation of sensor directions, δ", ylabel="Estimated / exact small singular value")
ax.legend()
fig.savefig("numerics-small-singular-value.png", dpi=170)
Output from the reference run
At delta=1e-12: direct/reference=1.000, Gram/reference=0.000

Tutorial on orientation and detectability
Reconstruct the product for the bidiagonal example
Work through the solution
The trace of \(B^TB\) is \(25+16+153=194\), equal to the sum of squares of the six input entries. Its determinant is \(25(153)=3825\). Trace and determinant determine the two squared singular values independently.
Predict a failure threshold and compare two noise sources
Work through the solution
When \(\delta^2\) is of order \(u\), rounding an explicitly formed Gram matrix threatens its weaker eigenvalue. Perturbations in the original data of norm \(10^{-5}\) already permit errors of that size in singular values by the variational characterisation. A stable algorithm cannot certify a sensor separation much smaller than instrument uncertainty.