A = [
0.473 -0.115 0;
0.731 -0.391 0.267;
0 -0.782 0.979;
];
perturb = zeros(size(A));
perturb(3, 3) = - 10^-14;
fprintf(' part a)\n');
fprintf('platform eps (ie `u`) => %d\n\n', eps);
[A2, flag, pivots, cond] = Factor(A);
%assert(flag == 0, 'can not factor');
fprintf('flag => %i\n', flag);
fprintf('partially factored A =>\n');
disp(A2);
fprintf('condition number => %d\n', cond);
fprintf('the smallest pivot is not close to the platform eps\n');
fprintf('the condition number is really large\n');
fprintf('perturbing `A_{3,3}`:\n');
A = A + perturb;
[A3, flag, pivots, cond] = Factor(A);
assert(flag == 0, 'can not factor perturbed A');
fprintf('A factored =>\n');
disp(A);
fprintf('condition number => %d (still fairly large)\n', cond);
fprintf('\n part b) =>\n');
fprintf('solving for `z` =>\n');
b = [
0.084;
0.357;
0.833;
];
zb = Solve(A3, pivots, b);
disp(zb);
fprintf('\n part c) =>\n');
fprintf('solving for `z` =>\n');
b = [
0.566;
0.404;
0.178;
];
zc = Solve(A3, pivots, b);
disp(zc);
fprintf('\n part d) =>\n');
fprintf('for part b => r = b - A * z =\n');
r = b - A * zb;
disp(r);
n = norm(r);
disp(n);
fprintf('for part c => r = b - A * z =\n');
r = b - A * zc;
disp(r);
n = norm(r);
disp(n);
Exercise2_16
part a)
platform eps (ie `u`) => 2.220446e-16
flag => 3
partially factored A =>
7.310000000000000e-01 -3.910000000000000e-01 2.670000000000000e-01
-6.470588235294118e-01 -7.820000000000000e-01 9.790000000000000e-01
0 1.764705882352941e-01 0
condition number => 1.797693e+308
the smallest pivot is not close to the platform eps
the condition number is really large
perturbing `A_{3,3}`:
A factored =>
4.730000000000000e-01 -1.150000000000000e-01 0
7.310000000000000e-01 -3.910000000000000e-01 2.670000000000000e-01
0 -7.820000000000000e-01 9.789999999999900e-01
condition number => 1799373260817256 (still fairly large)
part b) =>
solving for `z` =>
-7.663944938440499e-02
-1.045656170076726e+00
1.562500000000000e-02
part c) =>
solving for `z` =>
-5.757337690530235e+13
-2.368018024018137e+14
-1.891511843495608e+14
part d) =>
for part b => r = b - A * z =
4.820000000000000e-01
4.700000000000004e-02
-6.550000000000000e-01
8.145906947663961e-01
for part c => r = b - A * z =
3.499999999999948e-03
-2.249999999999974e-03
-9.500000000000008e-03
1.037123425634575e-02
diary off