%trapezoidal rule
f=input('enter the function f(x):');
x0=input('enter the value of intial limit x0=');
xn= input('enter value of final limit xn=');
N=input('enter the total number of subintervals N=');
h=(xn-x0)/N;
area=0;
while(x0<xn)
area=area+(h/2)*(f(x0)+f(x0+h));
x0=x0+h;
end
fprintf('area by trapezoidal rule=%f\n',area);
To embed this project on your website, copy the following code and paste it into your website's HTML: