function basis_lagrange ( a, b, n )

%
%% Plot Lagrange basis functions.
%
%  Input:
%
%    real a, b: the left and right interval endpoints
%
%    integer n: the number of Lagrange basis functions.
%
  if ( n == 1 )
    x_data= ( a + b ) / 2.0;
  else
    x_data = linspace ( a, b, n );
  end
  y_data = ones ( n, 1 );
  
  x = linspace ( a, b, 101 );

  clf ( );
  hold ( 'on' )
  for i = 1 : n
    y = ell ( i, x_data, x );
    plot ( x, y, 'linewidth', 3 );
  end
  plot ( x_data, y_data, 'r.', 'markersize', 25 );
  hold ( 'off' );
  
  grid ( 'on' );
  title ( 'Lagrange basis functions' );

  print ( '-dpng', 'basis_lagrange.png' );

  return
end

