function fx = p18_fx ( n, x )

%*****************************************************************************80
%
%% p18_fx() evaluates the function for problem 18.
%
%  Discussion:
%
%    This problem has as roots any point (x,y) with x or y equal to
%    zero.  The jacobian is of rank one at all roots, except at the
%    origin, where it completely vanishes.
%
%    Newton iterates can converge to the origin, or to points on
%    the X or Y axes, or can even "converge" to a point at infinity,
%    generating a sequence of ever larger points with ever smaller
%    function values.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    10 October 2020
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    integer N, the number of variables and equations.
%
%    real X(N), the evaluation point.
%
%  Output:
%
%    real FX(N), the function value.
%
  fx = zeros ( n, 1 );

  if ( x(1) ~= 0.0 )
    fx(1) = x(2)^2 * ( 1.0 - exp ( - x(1) * x(1) ) ) / x(1);
  else
    fx(1) = 0.0;
  end

  if ( x(2) ~= 0.0 )
    fx(2) = x(1) * ( 1.0 - exp ( - x(2)^2 ) ) / x(2);
  else
    fx(2) = 0.0;
  end

  return
end

