Question: writing program of Trapzium Rule's mistakes

The Question was like this:

Using this program as a basis, write a procedure  so that Maple performs a trapezium rule approximation of

the integral of f(x) when you enter the command TrapRule(f(x), N, a, b) where N is the number of intervals and a and b are the lower and upper bounds of the integral.

I saw a example and change a little bit to write this program:

with(Student[Calculus1]): ApproximateInt(f(x),x=a..b,method=trapezoid,partition=N,output=sum);

1/2*(b-a)/N*Sum(f(a+1*(b-a)/N)+f(a+(i+1)*(b-1)/N),i=0..N-1,x=a..b);

TrapRule:=proc(f,N,a,b) local val; val:=evalf((1/2)*(b-a)*(Sum(f(a+1*(b-a)/N)+f(a+(i+1)*(b-a)/N,i=0..N-1))/N end proc:

The problem is, after I type: TrapRule(exp(x),4,-3,1); it appears 0.5e^x(-3)+e^x(-2)+e^x*(-1)+1+0.5e^x

the x which I expect should be equal to a+i(b-a)/N, however now It becomes f=exp(x) ,not f(x)=exp(x)

Please help

Please Wait...