function tot = bessel(x,m,tol)
% Approximation to J_m(x) to a given tolerance
tot = (x/2).^m/factorial(m);
term = tot;
k = 1;
while (max(abs(term)) >= tol)
    term = term.*(-(x/2).^2/(k*(k+m)));
    tot = tot + term;
    k = k + 1;
end 
end

