so I have to make a numerical integrator using a few methods, just made a left Riemann sum calculator but I seem to be missing something
my code seems to be more accurate when I multiply my y array by dx in the for loop, but should I be multiplying dx at each iteration or at the very end?
also is it just my code or does Riemann sum require a lot of iteration to be accurate?
% code
clear;clc;x1 = 1; x2 = 3;f=@(x) 2*x.^5 - 3*x.^2 - 5;c=1;n=500;dx=(x2-x1)/n;for i=0:dx:n-1 y(c)=dx*f(1+i*dx); c=c+1;s=sum(y)*dxz=integral(f,x1,x2) end
Best Answer