clear all
n = 30
%pi = 4*atan(1.0);

x = 5.12
exact = besselj(0,x);

a = 0;
b = 2*pi;
h = (b-a)/n;
approx = 0;

for j = 1:n
    t = a + h*(j-1);
    f = exp(i*x*cos(t));
    approx = approx + h*f;
end

exact
approx = approx/2/pi
error = (approx - exact)