function value = powell3d_f ( x, n )

%*****************************************************************************80
%
%% powell3d_f() evaluates the Powell 3D function.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    31 July 2016
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    M J D Powell,
%    An Efficient Method for Finding the Minimum of a Function of
%    Several Variables Without Calculating Derivatives,
%    Computer Journal,
%    Volume 7, Number 2, pages 155-162, 1964.
%
%  Input:
%
%    real X(N), the evaluation point.
%
%    integer N, the number of variables.
%
%  Output:
%
%    real VALUE, the function value.
%
  value = 3.0 - 1.0 / ( 1.0 + ( x(1) - x(2) ) ^ 2 ) ...
    - sin ( 0.5 * pi * x(2) * x(3) ) ...
    - exp ( - ( ( x(1) - 2.0 * x(2) + x(3) ) / x(2) ) ^ 2 );

  return
end
