function testIntegral(dx)
% Calls integral for y(x)=cos(x) and compares the result with the
% analytic result dy(x)/dx=sin(x)
% Jose M Soler. Sept.2011

x = 0 : dx : 2*pi;
y = cos(x);

inty = integral(x,y);

figure(1)
plot(x,inty, x,sin(x),'o')
xlabel('x'), ylabel('Integral[y(x)]')
legend('numerical','analytic')
set(gca,'FontSize',15)
grid on

figure(2)
plot(x,inty-sin(x))
xlabel('x'), ylabel('Error')
set(gca,'FontSize',15)
grid on

end % function testIntegral
