function a = borderband_matrix ( n )

%*****************************************************************************80
%
%% borderband_matrix returns the BORDERBAND matrix.
%
%  Formula:
%
%    If ( I = J )
%      A(I,I) = 1
%    else if ( I = N )
%      A(N,J) = 2^(1-J)
%    else if ( J = N )
%      A(I,N) = 2^(1-I)
%    else
%      A(I,J) = 0
%
%  Example:
%
%    N = 5
%
%     1  0   0   0   1
%     0  1   0   0  1/2
%     0  0   1   0  1/4
%     0  0   0   1  1/8
%     1 1/2 1/4 1/8  1
%
%  Properties:
%
%    A is symmetric: A' = A.
%
%    Because it is symmetric, it is normal: A*A' = A'*A.
%
%    Because it is normal, it is diagonalizable.
%
%    A is not positive definite.
%
%    A is border-banded.
%
%    for ( 3 <= N ) A has N-2 eigenvalues of 1.
%
%    for ( 3 <= N ) A has one negative eigenvalue.
%
%    A is not diagonally dominant.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    28 September 2007
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer N, the order of A.
%
%  Output:
%
%    real A(N,N), the matrix.
%
  a = zeros ( n, n );

  for i = 1 : n

    for j = 1 : n

      if ( i == j )
        a(i,j) = 1.0;
      elseif ( j == n )
        a(i,j) = 2.0^(1-i);
      elseif ( i == n )
        a(i,j) = 2.0^(1-j);
      else
        a(i,j) = 0.0;
      end

    end

  end

  return
end
