function value=trapezoidal_rule(f,a,b,n) value=0; h=(b-a)/n; for i=1:1:n-1 value=value+f(a+i*h); end value=(b-a)/(2*n)*(f(a)+2*value+f(b));