I want to have an estimation, that my solution has an error, let's say less than 1e-8.
Usually, I stop the Gauss-Seidel algorithm, when the residual is "small enough" and this is already the problem. How do I know when the residual is small enough, because even when the residual is small, the solution may still have too much error. So this is no good method.
What do you use as stopping criterion?
On another website (math-linux.com) I found a stopping criterion: $$ \|r\|/\|b\|\leq \epsilon $$ But again, what theory is behind that?
This, by the way, is the code I used in my last project, just for information, how I did it:
void relax(double epsilon, vector<double> &x, SparseMatrix &A, const vector<double> &f) {
int maxIter = 100;
int iter = 0;
double residual = 1.0;
double minResidual 0.000001; //I also tried 1e-14;
while (iter < maxIter && residual >= minResidual) {
for (int i = 0; i < A.dim; ++i) {
double ls = A.lineScalar(i, x);
x[i] = (1.0/A(i,i)) * (f[i] - ls);
}
vector<double> temp = A.multiply(x);
residual = L2(temp - f);
}
}