function value = trap ( F, A, B, N )

%*****************************************************************************80
%
% returns the N-interval composite trapezoidal rule approximation to
%   int_A^B f(x) dx
% with  f  the function associated with the function handle  F 
%
%  Reference:
%
%    Samuel Conte, Carl de Boor,
%    Elementary Numerical Analysis,
%    Third Edition,
%    SIAM, 2017,
%    ISBN: 978-1-611975-19-2.
%
  H = (B-A)/N; X = H*(1:N-1);

  value = H*(F(A)/2 + sum(F(X)) + F(B)/2);

  return
end
