function uxx = laplacian_interval ( u, x )

%*****************************************************************************80
%
%% laplacian_interval() approximates the laplacian on an interval.
%
%  Discussion:
%
%    The domain is represented by nx equally spaced points.
%
%    The laplacian is computed for the interior points, but a value
%    of 0 is returned for the first and last points.
%
%    It is up to the user to decide whether to reset l(1) and l(nx)
%    to nonzero values.
%
%  Modified:
%
%    30 June 2020
%
%  Input:
%
%    real u(nx): the values of a function on an equally spaced grid of points.
%
%    real x(nx): the node coordinates.
%
%  Output:
%
%    real uxx(nx): the estimate for the laplacian.
%
  x = x(:);
  u = u(:);

  nx = length ( u );

  uxl = ( u(2:nx-1) - u(1:nx-2) ) ./ ( x(2:nx-1) - x(1:nx-2) );
  uxr = ( u(3:nx)   - u(2:nx-1) ) ./ ( x(3:nx)   - x(2:nx-1) );

  uxx = 2.0 * ( uxr(1:nx-2) - uxl(1:nx-2) ) ./ ( x(3:nx) - x(1:nx-2) );
%
%  Pad the result with initial and final 0.
%
  uxx = [ 0.0; uxx;  0.0 ];

  return
end

