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$$
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$$
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
kfrom0to some upper bound with an increment sizedk.5- for each value of
kadd tototalthe valuef(k).6- At the end of the
forloop, compare the result with the analytical solution to make sure your work is correct.