In any
iterative solver, there are many stopping (termination) methods to stop iteration
loop because the solver is not going to iterate forever.

Iteration loop
will stop in the following cases:

§
Solution is obtained: It is a waste of time and
resources to iterate further after the solution is known.

§
Maximum number of iterations reached with no
solution obtained: you
tell the solver previously to iterate for 1000 times – for example- that if the
solution is not obtained within those iterations then stop iteration loop and
output a message “Convergence is not
obtained” or “ No solution found”

§
Maximum iteration time elapsed with no
solution obtained: in
this case you tell the solver to stop iteration after a certain time is elapsed
(say 1 minute) if the solution is not obtained. In this case also, messages “Convergence
is not obtained” or “No solution found” can be displayed.

So …, how
to check if the current value of the variable x is the solution or not? There
are two methods I’ve implemented (maybe there are another methods, I don’t
know):

§
Absolute residual error: you tell the solver if the error
of the residual is less than or equal certain value (say 0.001, which is the
reasonable error for you), then the current value of the variable x is the
solution.