function jacobi_test02 ( )

%*****************************************************************************80
%
%% jacobi_test02() tests jacobi3().
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    09 February 2020
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'jacobi_test02:\n' );
  fprintf ( 1, '  jacobi3() uses Jacobi iteration to solve a linear system.\n' );

  it_num = 10;
  n = 3;

  x_exact = ( 1 : n )'
  A = dif2_matrix ( n );
  b = A * x_exact;
  x = zeros ( n, 1 );  

  fprintf ( 1, '\n' );
  fprintf ( 1, '  it    (x1,x2,x3)                      |dx|        |r|       |e|\n' );
  fprintf ( 1, '\n' );
  for it = 0 : it_num
    if ( it == 0 )
      x_new = zeros ( n, 1 );
      dx = 0.0;
    else
      x_new = jacobi3 ( n, A, b, x );
      dx = x_new - x;
    end
    r = b - A * x_new;
    e = x_exact - x_new;
    x = x_new;
    fprintf ( 1, '%2d  (%8.4f, %8.4f, %8.4f)  %10.2g  %10.2g  %10.2g\n', ...
      it, x(1:3), norm ( dx ), norm ( r ), norm ( e ) );
  end 

  return
end
