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

