function value = func02 ( x, ider )

%*****************************************************************************80
%
%% func02() computes the function value for the second test.
%
%  Licensing:
%
%    This code is distributed under the MIT license. 
%
%  Modified:
%
%    15 May 2023
%
%  Author:
%
%    John Burkardt
%
%  Input:
%
%    real X, the point at which the evaluation is to take place.
%
%    integer IDER, specifies what is to be evaluated:
%    0, evaluate the function.
%    1, evaluate the first derivative.
%    2, evaluate the second derivative.
%    3, evaluate the third derivative.
%
%  Output:
%
%    real value: the value of the function or derivative.
%
  if ( ider == 0 )
    value = cos ( x ) - x;
  elseif ( ider == 1 )
    value = - sin ( x ) - 1.0;
  elseif ( ider == 2 )
    value = - cos ( x );
  elseif ( ider == 3 )
    value = sin ( x );
  else
    fprintf ( 1, '\n' );
    fprintf ( 1, 'func02(): Fatal error!\n' );
    fprintf ( 1, '  Derivative of order IDER = %d requested.\n', ider );
    error ( 'func02(): Fatal error!\n' );
  end

  return
end
