function skeleton2 ( )

%*****************************************************************************80
%
%% skeleton2 estimates the Laplacian on a 2D periodic domain.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    28 June 2020
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'skeleton2\n' );
  fprintf ( 1, '  Estimate the Laplacian on a 2D periodic region.\n' );
  fprintf ( 1, '\n' );
  fprintf ( 1, '  nx  ny  || error ||\n' );
  fprintf ( 1, '\n' );

  for n = [ 7, 13, 25, 49 ]

    nx = n;
    xmin = 0.0;
    xmax = 2.0;
    x = linspace ( xmin, xmax, nx );
    dx = ( xmax - xmin ) / ( nx - 1 );

    ny = n;
    ymin = -1.0;
    ymax =  1.0;
    y = linspace ( ymin, ymax, ny );
    dy = ( ymax - ymin ) / ( ny - 1 );
%
%  Create periodic grid [ XP, YP ], by reducing nx and ny and removing last points.
%
    nxp = nx - 1;
    nyp = ny - 1;
    xp = x(1:nxp);
    yp = y(1:nyp);
    [ XP, YP ] = ndgrid ( xp, yp );
%
%  Compute function and exact Laplacian.
%
    UP = sin ( 2.0 * pi * XP ) .* sin ( 2.0 * pi * YP );
    UXXP = - 8.0 * pi^2 * sin ( 2.0 * pi * XP ) .* sin ( 2.0 * pi * YP );
%
%  Compute discrete Laplacian and compare.
%
    LP = laplacian5_torus ( UP, dx, dy );
    diff = rms_norm ( UXXP - LP );
    fprintf ( 1, '  %2d  %2d  %g\n', nx, ny, diff );

  end

  return
end
function L = laplacian5_torus ( A, dx, dy )

%*****************************************************************************80
%
%% laplacian5_torus uses a 5 point Laplacian stencil on a torus.
%
%  Modified:
%
%    28 June 2020
%
  [ nxp, nyp ] = size ( A );
  L = zeros ( nxp, nyp );

  for j = 1 : nyp
    for i = 1 : nxp
      L(i,j) = ?
    end
  end

  return
end

