function lu = laplacian_pp ( u, dx )

%*****************************************************************************80
%
%% laplacian_pp() applies the laplacian data when both boundaries are periodic.
%
%  Discussion:
%
%    The array U has NX entries.
%
%    The values in U correspond to X locations with spacing DX.
%
%    The first and last values of U should be equal, since the periodic
%    condition applies.
%
%    At node 1:
%
%      uxx = ( u(nx-1) - 2 u(1) + u(2) ) / dx^2
%
%    At node 2 <= i <= n-1:
%
%      uxx = ( u(i-1) - 2 u(i) + u(i+1) ) / dx^2
%
%    At node nx:
%
%      uxx = ( u(nx-1) - 2 u(nx) + u(2) ) / dx^2
%     
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    20 December 2020
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real u(nx), the value at each point.
%
%    real dx, the spacing between points.
%
%  Output:
%
%    real lu(nx), the Laplacian evaluated at each point.
%
  [ xmin, xmax, nx, dx, c, t0 ] = wave_parameters ( );

  lu = zeros ( 1, nx );

  lu(1)      = u(nx-1)   - 2.0 * u(1)      + u(2);
  lu(2:nx-1) = u(1:nx-2) - 2.0 * u(2:nx-1) + u(3:nx);
  lu(  nx)   = u(nx-1)   - 2.0 * u(1)      + u(2);

  lu = lu / dx^2;

  return
end

