You solve a non-singular system of 1,000 linear equations with 1,000 unknowns. Your code uses the Gauss-Jordan algorithm with partial pivoting using double precision numbers and arithmetics. Why would the 2-norm of the residual of your solution not be zero?
You solve a non-singular system of 1,000 linear equations with 1,000 unknowns. Your code uses the Gauss-Jordan

Program: a system of linear equations A*x=b.
Method: calls Gauss-J elimination (with scaled pivoting).
Implicit none:
integer, parameter : n=3;
double exactness a(n, n), b(n), x(n)
integer l, m;
(1) Matrix A :
- input (a(1,l), l=1,3) [ 0.0, 1.0, 2.0 ]
- input (a(2,l), l=1,3) [ 2.0, 1.0, 4.0 ]
- input (a(3,l), l=1,3) [ 2.0, 4.0, 6.0 ]
(2) Matrix b :
input (b(l), l=1,3) [ 4.0, 3.0, 7.0 ]
Print could be a header and therefore the initial equations:
w (*, 100)
do l = 1, n;
w (*, 101)
(a(l, m),m = 1,n), b(l);
end do
decision Gauss-J_2(a, b, x, n) :
Print matrix A and vector b when the cancellation :
w (*, 102)
do l = 1, n;
w (*, 101)
(a(l, m),m = 1, n), b(m);
end do
print solutions :
w (*, 103)
w (*, 101) (x(l),l=1, n)
100 format (' Gauss-J elimination with scaling and pivoting ' & ' Matrix A and vector b').
101 format (3f6.3).
102 format (' Matrix A and vector b when elimination').
103 format (' Solutions x(n)').
end.
end subprogram Gauss-J_2
Subroutine gauss_2(a, b, x, n).
Step by step
Solved in 3 steps









