There’s a huge qualitative difference between algorithms whose error bounds scale as the condition number squared (Cholesky and presumably sweep — anything that uses the normal equations) and algorithms scale as the condition number (QR and SVD). It’s not just a matter of “between”.
Second, I’m really confused by your test data. For, example, if I take the Pontius data
y = [0.11019, 0.21956, 0.32949, 0.43899, 0.54803, 0.65694, 0.76562, 0.87487, 0.98292, 1.09146, 1.20001, 1.30822, 1.41599, 1.52399, 1.63194, 1.73947, 1.84646, 1.95392, 2.06128, 2.16844, 0.11052, 0.22018, 0.32939, 0.43886, 0.54798, 0.65739, 0.76596, 0.87474, 0.983, 1.0915, 1.20004, 1.30818, 1.41613, 1.52408, 1.63159, 1.73965, 1.84696, 1.95445, 2.06177, 2.16829]
x = [150000, 300000, 450000, 600000, 750000, 900000, 1050000, 1200000, 1350000, 1500000, 1650000, 1800000, 1950000, 2100000, 2250000, 2400000, 2550000, 2700000, 2850000, 3000000, 150000, 300000, 450000, 600000, 750000, 900000, 1050000, 1200000, 1350000, 1500000, 1650000, 1800000, 1950000, 2100000, 2250000, 2400000, 2550000, 2700000, 2850000, 3000000]
and form the matrix A = [x x.^2]
corresponding to the model y ~ x + x^2
, then condition number is:
julia> cond(A)
9.535160793307362e6
which doesn’t appear to correspond closely to any of the numbers in the “conds” column of your table, so I’m not sure what you are showing? Second, if I compute the “exact” least-square result A \ y
in BigFloat
with 4096-bit precision (> 1000 decimal digits, which should be plenty!), then I get:
julia> setprecision(4096);
julia> Float64.(BigFloat.(A) \ parse.(BigFloat, string.(y)))
2-element Vector{Float64}:
7.329344756900174e-7
-3.398031528901493e-15
whereas the “correct” results you are comparing against in your script are [7.32059160401003e-7, -3.16081871345029e-15]
, which seem to be extremely inaccurate in comparison. Am I misunderstanding the problem you are solving?
Condition numbers only give you an upper bound on the amplification of forward error from the backward error. There are other coefficients that appear in the backward error (for a given algorithm), and there are also the specifics of the roundoff errors from a particular set of data. So no, the condition number alone doesn’t tell you the error, but the dependence on the condition number is still a big factor.