function x_new = jacobi1 ( n, a, b, x )

%*****************************************************************************80
%
%% jacobi1() carries out one step of the Jacobi iteration.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    25 June 2011
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer N, the number of equations.
%
%    real A(N,N), the matrix.
%
%    real B(N), the right hand side.
%
%    real X(N), the estimated solution.
%
%  Output:
%
%    real X_NEW(N), the improved estimate of the solution.
%
  x_new = zeros ( n, 1 );

  for i = 1 : n
    x_new(i) = b(i);
    for j = 1 : n
      if ( j ~= i )
        x_new(i) = x_new(i) - a(i,j) * x(j);
      end
    end
    x_new(i) = x_new(i) / a(i,i);
  end

  return
end

