function t = traprule(f,a,b) % % The function t = traprule(f,a,b) % returns in t the application of the Trapezoidal Rule % to approximate the definite integral of f over [a,b]. % % Example: % t = traprule('sin',0,1) % integral of sin(x) over [0,1] % fa = feval(f,a); fb = feval(f,b); t = (b-a)*(fa + fb)/2;