Skip to main content
6 of 6
replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/

There are many possible variants of Assumptions here, including

AbsoluteTiming[Integrate[k^n SphericalBesselJ[l, R*k], {k, 0, ∞}, 
    Assumptions -> {l > 0, R > 0, n ∈ Reals}]]
(* {4.00979075897103, ConditionalExpression[
    (2^(-1 + n)*Sqrt[Pi]*R^(-1 - n)*Gamma[(1 + l + n)/2])/Gamma[(2 + l - n)/2], 
    n < 1 && l + n > -1]} *)

or

AbsoluteTiming[Integrate[k^n SphericalBesselJ[l, R*k], {k, 0, ∞}, 
    Assumptions -> {l > 0, R > 0, -1 - l < n < 1}]]
(* {11.002235487576527, 
    (2^(-1 + n)*Sqrt[Pi]*R^(-1 - n)*Gamma[(1 + l + n)/2])/Gamma[(2 + l - n)/2]} *)

or

AbsoluteTiming[Integrate[k^n SphericalBesselJ[l, R*k], {k, 0, ∞}, 
    Assumptions -> {l > 0, R > 0, (n | l) ∈ Integers}]]
(* {4.107987620241559, ConditionalExpression[
    (2^(-1 + n)*Sqrt[Pi]*R^(-1 - n)*Gamma[(1 + l + n)/2])/Gamma[(2 + l - n)/2], 
    n <= 0 && l + n >= 0]} *)

All works sometimes and not others. The latter two seem faster and more reliable, however.

Addendum

A work-around is to run the same Integrate two or three times in succession. I have posted a question about this strange behavior, in the hope of gaining more insight.

Solution

From comments made on the question referenced above, it has become apparent that Integrate times out after 60 seconds when attempting to do many of the integrals above when called the first time. The solution is to give it more time. For instance,

TimeConstrained[
    Integrate[k^n SphericalBesselJ[l, R*k], {k, 0, ∞}, 
        Assumptions -> {l > 0, R > 0, n ∈ Integers}], 120] // AbsoluteTiming

returns with the correct answer after about 70 seconds.

bbgodfrey
  • 62.1k
  • 18
  • 92
  • 160