hi there,
ive done some more investigations using different inversion techniques as an experiment. firstly, it looks like i was too hasty in my accusation of a bug in free42 and Whuy was right in this respect. what started it, is that inverting the matrix,
3 1 2
1 1e-040 1e-040
2 1e-040 -1e-040
gave the exact correct answer in my code when using lu decomposition then backsubstitution. however, examples using numbers less far out than 10^40 wind up with worse answers. this leads me to think that the result was a fluke. here’s what i get with the above under different inversion algorithms (all use 1eee754 doubles):
original matrix:
3 1 2
1 1e-040 1e-040
2 1e-040 -1e-040
LU Inverse Matrix:
-2e-040 3 -1
3 -4e+040 2e+040
-1 2e+040 -1e+040
SVD Inverse Matrix:
2.77555756156289e-017 0.2 0.4
0.2 -0.12 -0.24
0.4 -0.24 -0.48
Gauss Inverse Matrix:
0 0 0.5
0 0 -0.5
0.5 0.5 -0.75
as you can see, the lu inverse is spot on but the other methods, like svd (which is sometimes better) are way off. i now think this is a fluke and your code is different because its different and i just got lucky.
taking 10^-40 down to 10^-10, say, i get a different picture:
original matrix:
3 1 2
1 1e-010 1e-010
2 1e-010 -1e-010
LU Inverse Matrix:
-2.0000000012e-010 3.0000000018 -1.0000000006
3.0000000018 -40000000027 20000000009
-1.0000000006 20000000009 -10000000003
SVD Inverse Matrix:
-1.99999246971831e-010 2.99999065204657 -0.999995325723285
2.99998375179818 -39999820941.8902 19999910466.4451
-0.999991875599092 19999910466.4451 -9999955231.72258
Gauss Inverse Matrix:
-2.00000016548074e-010 3 -0.9999999997
3 -39999996690.3854 19999998340.6927
-0.9999999997 19999998340.6927 -9999999168.84636
now the lu isn’t spot on anymore and the others are still worse. trying again, in range at 10^-5
original matrix:
3 1 2
1 1e-005 1e-005
2 1e-005 -1e-005
LU Inverse Matrix:
-2.00012000720043e-005 3.00018001080065 -1.00006000360022
3.00018001080065 -400027.001620097 200009.000540032
-1.00006000360022 200009.000540032 -100003.000180011
SVD Inverse Matrix:
-2.00012000714772e-005 3.00018001076159 -1.00006000358069
3.00018001074169 -400027.001613791 200009.000536879
-1.00006000357074 200009.00053688 -100003.000178434
Gauss Inverse Matrix:
-2.00012000719087e-005 3.00018001078885 -1.00006000359432
3.00018001078885 -400027.001617928 200009.000538948
-1.00006000359432 200009.000538948 -100003.000179468
we’re seeing about 9 correct digits for lud & svd. so the picture is more like what you'd expect, except that 10^-40 just happend to work for lud :-)