Experimenting with Hilbert matrix
The following experiment shows that the Hilbert matrix A of size 10 is very sensitive to changes in b. The condition number
of the matrix is 1.6x10^13. The solution to Ax=b changes a lot when b changes from [1 1 1 1 1 1 1 1 1 1]' by a small amount.
» format long
» for i=1:10
for j=1:10
A(i,j)=1/(i+j-1);
end
end
% This defines the Hilbert matrix of size 10.
» cond(A)
ans =
1.602533632202711e+013
% This shows that the matrix has a large condition number 16025336322027.11, more than 16
trillion.
» b=ones(10,1);
» A\b
ans =
1.0e+006 *
-0.00000999563844
0.00098962226204
-0.02375193941951
0.24016661264454
-1.26090953729814
3.78281563674004
-6.72513649280694
6.99974868636912
-3.93741561223132
0.92360301627563
% Recall that ones(10,1) means the 10x1 column vector consisting of 1's. The command A\b tells Matlab to solve Ax=b. The solution is x1=-9.99563844, x2=989.62226204,
, etc.
» b=[1 1 1 1.1 1 1.2 0.9 0.92 .8 1.1 ]'
b =
1.00000000000000
1.00000000000000
1.00000000000000
1.10000000000000
1.00000000000000
1.20000000000000
0.90000000000000
0.92000000000000
0.80000000000000
1.10000000000000
» A\b
ans =
1.0e+011 *
-0.00002549120031
0.00219657069024
-0.04670921198724
0.42418723371259
-2.02187301254720
5.55543605610408
-9.11167390811971
8.80322945370647
-4.62080309845867
1.01605313866939
% We changed b slightly from [1 1 1 1 1 1 ...]' and solve Ax=b. The result is x1=-2549120.031,
x2=219657069.024, .... which is very much different from the solution above. I tested below another
b slightly different from [1 1 1 1 1 ...]. The result is again very much different.
» b=[1.001 0.999 1.002 0.981 1.002 0.978 .980 1.002 1 0.991]';
» A\b
ans =
1.0e+010 *
-0.00000460189437
0.00043353979203
-0.00978756996277
0.09278406450263
-0.45675557344773
1.28693129265434
-2.15356084533401
2.11508672274315
-1.12546640162162
0.25034436600482