function R = minimal_surface_scherk_residual ( X, Y, a )

%*****************************************************************************80
%
%% minimal_surface_scherk_residual(): minimal surface residual for Scherk solution.
%
%  Discussion:
%
%    The equation is:
%      (1+Ux^2) Uyy - 2 Ux Uy Uxy + (1+Uy^2) Uxx = 0
%
%    The Scherk solution is:
%      U(X,Y) = log ( cos ( a * Y ) / cos ( a * X ) ) / a
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    31 May 2025
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real X, Y: the coordinates of the points.
%
%    real a: a shape parameter.
%
%  Output:
%
%    real R: the residual evaluated at the points (X,Y).
%
  [ U, Ux, Uy, Uxx, Uxy, Uyy ] = minimal_surface_scherk_exact ( X, Y, a );

  R = ( 1.0 + Ux.^2 ) .* Uyy ...
    - 2.0 * Ux .* Uxy .* Uy           ...
    + ( 1.0 + Uy.^2 ) .* Uxx;

  return
end
