function y=besintJ0(x) %----------------------------------------------------------------------- % Approximate the Bessel's function of the first kind of order zero % via the following integral definition. % J0(x) = (1/pi)*integral (from 0 to pi) of cos(x*sin(q))*dq % Programming Note: % For large values of x, apply the asymptotic approximation formula. % J0(x)=sqrt(2/pi/x)*cos(x-pi/4), for x>25 % Instructor: Nam Sun Wang %----------------------------------------------------------------------- global xx % pi = 3.141593 already defined in Matlab % Pass x into the integrand through "common" xx = x; % Call an integration routine to do the grunt work. % y = 1/pi * quad8('bintegra', 0, pi); ... old y = 1/pi * quadl('bintegra', 0, pi);