Open hughkf opened 8 years ago
@hughkf The simplest way to do this is to have a logical OR in your exit condition, your algorithm should exit if the two norm of the difference xkp1-xk < epsilon, OR k > N (maximum number of iterations allowed)
Thanks, @mvelegar !
Reopening since this may be useful to other students.
In exercise 3.7, we are supposed to first plot the difference r(k) = b − A*x(k) after k iterations of jacobi_step (this question applies to Gauss-Seidel as well), for k between 1 and some large number, call it N. First, what number N should we use?
I wrote a loop that does the equivalent of jacobi_iteration, but stops after k iterations. Then the question asks "What happens to these plots when you decrease epsilon to 1e−20?" Since we are using k as an exit condition, how can we also use epsilon as an exit condition? In other words, we didn't use epsilon at all in our code to make our plots, so how would we adjust epsilon in that code?