function [ u, ux, uy, uxx, uxy, uyy ] = poisson_2d_exact ( x, y )

%*****************************************************************************80
%
%% poisson_2d_exact() evaluates an exact solution of the Poisson equation.
%
%  Discussion:
%
%    The equation is:
%      - Uxx - Uyy = 0
%
%    The domain is the unit square:
%      Omega = 0 <= x, y <= 1
%
%    The solution is:
%      U(X,Y) = 2 * ( 1 + Y ) / ( ( 3 + X )^2 + ( 1 + Y )^2 )
%
%    The boundary conditions are determined by evaluating the exact
%    solution U(X,Y).
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    05 June 2025
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real X, Y: the coordinates of the points.
%
%  Output:
%
%    real U, Ux, Uy, Uxx, Uxy, Uyy: the solution and first and second
%    partial derivatives evaluated at the points (X,Y).
%
  u = 2.0 * ( 1.0 + y ) ./ ( ( 3.0 + x ).^2 + ( 1.0 + y ).^2 );
  ux = ( - 2 * x - 6 ) .* ( 2 * y + 2 ) ./ ( ( x + 3 ).^2 + ( y + 1 ).^2 ).^2;
  uy = ( - 2 * y - 2 ) .* ( 2 * y + 2 ) ...
    ./ ( ( x + 3 ).^2 + ( y + 1 ).^2 ).^2 + 2 ./ ( ( x + 3 ).^2 + ( y + 1 ).^2 );
  uxx = 4 * ( y + 1 ) .* ( 4 * ( x + 3 ).^2 ...
    ./ ( ( x + 3 ).^2 + ( y + 1 ).^2 ) - 1 ) ...
    ./ ( ( x + 3 ).^2 + ( y + 1 ).^2 ).^2;
  uxy = 4 * ( x + 3 ).* ( 4 * ( y + 1 ).^2 ...
    ./ ( ( x + 3 ).^2 + ( y + 1 ).^2 ) - 1 ) ...
    ./ ( ( x + 3 ).^2 + ( y + 1 ).^2 ).^2;
  uyy = 4 * ( y + 1 ) .* ( 4 * ( y + 1 ) .^2 ...
    ./ ( ( x + 3 ).^2 + ( y + 1 ).^2 ) - 3 ) ...
    ./ ( ( x + 3 ).^2 + ( y + 1 ).^2 ).^2;

  return
end

