function value = goldstein_price_f ( m, n, x )

%*****************************************************************************80
%
%% GOLDSTEIN_PRICE_F returns the function in the goldstein_price problem.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    25 January 2016
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Sashwati Ray, PSV Nataraj,
%    An efficient algorithm for range computation of polynomials using the
%    Bernstein form,
%    Journal of Global Optimization,
%    Volume 45, 2009, pages 403-426.
%
%  Parameters:
%
%    Input, integer M, the number of variables.
%
%    Input, integer N, the number of points.
%
%    Input, real X(M,N), the points.
%
%    Output, real VALUE(N), the value of the function at X.
%
  g = ( ...
    1.0E+00 + ( x(1,1:n) + x(2,1:n) + 1.0E+00 ) .^2 ...
    .* ( 19.0E+00 - 14.0E+00 * x(1,1:n) + 3.0E+00 * x(1,1:n) .^2 ...
    - 14.0E+00 * x(2,1:n) + 6.0E+00 * x(1,1:n) .* x(2,1:n) ...
    + 3.0E+00 * x(2,1:n) .^ 2 ) );

  h = ( ...
    30.0E+00 + ( 2.0E+00 * x(1,1:n) - 3.0E+00 * x(2,1:n) ) .^2 ...
    .* ( 18.0E+00 - 32.0E+00 * x(1,1:n) + 12.0E+00 * x(1,1:n) .^2 ...
    + 48.0E+00 * x(2,1:n) - 36.0E+00 * x(1,1:n) .* x(2,1:n) ...
    + 27.0E+00 * x(2,1:n) .^ 2 ) );

  value(1:n) = ( g .* h )';

  return
end


