2
$\begingroup$

I want to numerically integrate this equation (in python):

$\int_{0}^{\infty}{\rm d}k f(k) J_v(r k)J_v(s k) $,

where f(k) is a non-smooth function, and $J_v$ are the Bessel function of the fist kind. In practice I have to integrate

$\int_{a}^{b}{\rm d}k f(k) J_v(r k)J_v(s k) $,

with usual values for $a \sim 10^{-8}$ and $b \sim 10^{16}$, where $f(k) \rightarrow 0$ for $b \ge 10^{16}$. I wrote a code based on Levin's paper that partially solves my problem, with this method I can integrate up to 50 without much computational power. A exponential change of variables $k = 10^u$, helps me to integrate up to $\sim 10^2$.

Now, I can compute the integral for larger upper limits with more computational power but the error of the integral dramatically increase when I reach $b \sim 10^3$, pretty far for what I want to do.

I have tested this method in the case where $f(k) = k^{-p}$ and using the analytical solution of this paper and using Mathematica with the following instruction:

NIntegrate[f[k]BesselJ[v,r k]BesselJ[v, s k], {k, a, b}, Method -> {"OscillatorySelection", Method -> "LevinRule", "FourierFiniteRangeMethod" -> {"GlobalAdaptive"}}]����

Somehow Mathematica deals with the integral nicely, much better than my code.

So, my question is: what am I missing? What does Mathetica do that I don't?

Any help or ideas are really appreciated. Thanks in advance!

$\endgroup$
2
  • 1
    $\begingroup$ Might be one for mathematica.se? It might also depend on the manner in which $f(k)$ is non-smooth. $\endgroup$
    – user25199
    Commented Jul 29, 2015 at 8:14
  • 4
    $\begingroup$ I'm voting to close this question as off-topic because it belongs on mathematica.stackexchange.com $\endgroup$
    – Stopple
    Commented Jul 29, 2015 at 14:43

0