How do I properly retype my code by using trap() function?
this is the original code, I run it I got .5, but when I plug in with trap() form i got like 10 different number, how do I properly use trap() function
this is a trapezoid method integral problem
f_x=function(x)
x
a = 0 ; b = 1
n = 10
h = (b-a)/n
x=seq(a,b,h)
y = f_x(x)
first=(y[1]+2*sum(y[2:n])+y[n+1])*(h/2);
first