function hw2 ( )

%*****************************************************************************80
%
%% hw2 makes contour plots of the solution of a Poisson problem.
%
%  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, '  Use contour plots to display Poisson equation solution.\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 );

  figure ( )
  contour ( X, Y, U )
  xlabel ( '<-- x -->' );
  ylabel ( '<-- y -->' );
  title ( 'Contour lines' );
  print ( '-dpng', 'hw2_contour_lines.png' );

  figure ( )
  contourf ( X, Y, U )
  colorbar ( );
  xlabel ( '<-- x -->' );
  ylabel ( '<-- y -->' );
  title ( 'Contour colors' );
  print ( '-dpng', 'hw2_contour_colors.png' );

  figure ( )
  surf ( X, Y, U, 'edgecolor', 'none' );
  colorbar ( );
  xlabel ( '<-- x -->' );
  ylabel ( '<-- y -->' );
  zlabel ( '<-- u(x,y) -->' );
  title ( 'Surface' );
  print ( '-dpng', 'hw2.png' );

  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
