function exercise5 ( )

%*****************************************************************************80
%
%% exercise5 reports the RMS norm of the approximation error.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    16 July 2020
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'exercise5:\n' );
  fprintf ( 1, '  Report the RMS error in solving a Poisson problem.\n' );

  a = 0.0;
  b = 1.0;
  c = 1.0;
  d = 3.0;
  nx = 11;
  ny = 21;
%
%  Notice that data is now returned as TABLES (matrices).
%
  [ X, Y, U ] = poisson_solver ( a, b, c, d, nx, ny, @f, @g );
%
%  Print the error norm.
%
  E = U - g ( X, Y );
  enorm = rms ( reshape ( E, nx*ny, 1 ) );
  fprintf ( 1, '  nx = %d, ny = %d, rms error norm = %g\n', nx, ny, enorm );

  return
end

function value = f ( x, y )

%*****************************************************************************80
%
  value = pi^2 * ( x.^2 + y.^2 ) .* sin ( pi * x .* y );
  return
end

function value = g ( x, y )

%*****************************************************************************80
%
  value = sin ( pi * x .* y );
  return
end
