function value = trap_int ( a, b, fvec ) % % function value = trap_int ( a, b, fvec ) % % Return the value of the trapezoidal approximation to the % integral from A to B of F(X). % % FVEC is presumed to contain the value of F at equally % spaced points from A to B. % n = length ( fvec ); s = sum ( fvec ) - 0.5 * ( fvec(1) + fvec(n) ) value = ( b - a ) * s