function exercise4 ( )

%*****************************************************************************80
%
%% exercise4 uses poisson_solver to solve the tiny Poisson problem.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    16 July 2020
%
%  Author:
%
%    John Burkardt
%
  fprintf ( 1, '\n' );
  fprintf ( 1, 'exercise4:\n' );
  fprintf ( 1, '  Use poisson_solver() to solve the tiny Poisson problem.\n' );

  a = 0.0;
  b = 3.0;
  c = 0.0;
  d = 2.0;
  nx = 4;
  ny = 3;
%
%  Notice that data is now returned as TABLES (matrices).
%
  [ X, Y, U ] = poisson_solver ( a, b, c, d, nx, ny, @f, @g );
%
%  Tabulate the solution.
%
  fprintf ( 1, ' k   i   j    x       y       u       exact\n' );
  k = 0;  
  for j = 1 : ny
    fprintf ( 1, '\n' );
    for i = 1 : nx
      k = k + 1;
      fprintf ( 1, '%2d  %2d  %2d  %6.2f  %6.2f  %6.2f  %6.2f\n', ...
                      k,   i,   j, X(i,j), Y(i,j), U(i,j), g(X(i,j),Y(i,j)) );
    end
  end

  return
end
function value = f ( x, y )

%*****************************************************************************80
%
  value = - 2.0 * y;
  return
end

function value = g ( x, y )

%*****************************************************************************80
%
  value = x.^2 .* y;
  return
end
