Bessel Integration in matlab I was trying to do integral in matlab with below equation. Could anyone help me please to do with Riemann sum approach in matlab? Thanks in advance!!
$$\int_0^\infty{{e}}^{-{k^2}/{4}} J_0(k)k{d} k$$
 A: No need for Riemann sums. By the very definition of $J_0$,
$$ \int_{0}^{+\infty} e^{-x^2/4}xJ_0(x)\,dx = \sum_{n\geq 0}\frac{(-1)^n}{4^n n!^2}\underbrace{\int_{0}^{+\infty} x^{2n+1} e^{-x^2/4}\,dx}_{2\cdot 4^n\cdot n!}=2\sum_{n\geq 0}\frac{(-1)^n}{n!}=\color{red}{\frac{2}{e}}. $$
A: There is a closed form (compact form) solution to this integration in the Table of Integrals 7E, Eq 6.631.1 as $$\int_0^{\infty}x^{\mu}e^{-\alpha x^2}\,J_v(\beta\,x)\,dx = \frac{\Gamma\left(\frac{1}{2}v+\frac{1}{2}\mu+\frac{1}{2}\right)}{\beta\,\alpha^{\frac{1}{2}\mu}\Gamma\left(v+1\right)}\exp\left(-\frac{\beta^2}{8\alpha}\right)\,M_{\frac{1}{2}\mu,\,\frac{1}{2}v}\left(\frac{\beta^2}{4\alpha}\right)$$
where $\Gamma(.)$ is the Gamma function, and $M_{\mu,v}(.)$ is the Whittaker function.
If you still want to do numerically
1- define the function $$f(k)=ke^{-k^2/4}J_0(k)$$.
2- Define the step size, e.g., dk = 0.01.
3- Initialize a variable total = 0.
4- loop over k from 0 to some upper bound with an increment size dk.
5- for each value of k add to total the value f(k).
6- At the end of the for loop, compare the result with the analytical solution to make sure your work is correct. 
