function value = helix_f ( x, n )

%*****************************************************************************80
%
%% HELIX_F evaluates the Helix function.
%
%  Discussion:
%
%    The function is the sum of the squares of three functions.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    31 July 2016
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input, real X(N), the evaluation point.
%
%    Input, integer N, the number of variables.
%
%    Output, real VALUE, the function value.
%
  r = norm ( x );

  if ( 0.0 <= x(1) )
    theta = 0.5 * atan2 ( x(2), x(1) ) / pi;
  elseif ( x(1) < 0.0 )
    theta = 0.5 * ( atan2 ( x(2), x(1) ) + pi ) / pi;
  end

  fx1 = 10.0 * ( x(3) - 10.0 * theta );
  fx2 = 10.0 * ( r - 1.0 );
  fx3 = x(3);

  value = fx1 ^ 2 + fx2 ^ 2 + fx3 ^ 2;

  return
end
