function a = hilbert_perturbed_matrix ( n )

%*****************************************************************************80
%
%% hilbert_perturbed_matrix() returns the HILBERT_PERTURBED matrix.
%
%  Formula:
%
%    if ( I == 1 )
%      A(I,J) = ( N - 1 ) * ( N + 1 ) / N^2
%    else
%      A(I,J) = 1 / ( I + J - 1 )
%
%  Example:
%
%    N = 5
%
%    24/25 1/2 1/3 1/4 1/5
%    1/2   1/3 1/4 1/5 1/6
%    1/3   1/4 1/5 1/6 1/7
%    1/4   1/5 1/6 1/7 1/8
%    1/5   1/6 1/7 1/8 1/9
%
%  Square Properties:
%
%    A is singular.
%
%    A is identical to the Hilbert matrix except in the (1,1) position,
%    where the difference is 1/N^2.
%
%    A is symmetric: A' = A.
%
%    Because A is symmetric, it is normal.
%
%    Because A is normal, it is diagonalizable.
%
%    A is not diagonally dominant.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    29 November 2019
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer N: the number of rows and columns.
%
%  Output:
%
%    real A(N,N): the matrix.
%
  m = n;
  a = zeros ( m, n );

  for i = 1 : m
    for j = 1 : n
      a(i,j) = 1.0 / ( i + j - 1 );
    end
  end

  a(1,1) = ( n + 1 ) * ( n - 1 ) / n^2;

  return
end
