function fx = helical_valley_fx ( x )

%*****************************************************************************80
%
%% helical_valley_fx() evaluates the helical valley function.
%
%  Discussion:
%
%    If we don't guarantee that X and FX are column vectors,
%    unpleasant disasters occur.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    10 October 2020
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real X(N), the evaluation point.
%
%  Output:
%
%    real FX(N), the function value.
%
  x = x(:);

  n = size ( x, 1 );

  fx = zeros ( n, 1 );

  if ( 0.0 < x(1) )
    temp = atan ( x(2) / x(1) ) / ( 2.0 * pi );
  elseif (x(1) < 0.0 )
    temp = atan ( x(2) / x(1) ) / ( 2.0 * pi ) + 0.5;
  else
    temp = 0.25 * sign ( x(2) );
  end

  fx(1) = 10.0 * ( x(3) - 10.0 * temp );
  fx(2) = 10.0 * ( sqrt ( x(1)^2 + x(2)^2 ) - 1.0 );
  fx(3) = x(3);

  return
end

