Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to evaluate this integral numerically: $$ \int_0^{\infty } m \exp (-m) J_1(m){}^2 \, dm $$ Everything is OK when only the integration method is specified:

NIntegrate[-m Exp[-m] BesselJ[1, m]^2, {m, 0, Infinity}, Method -> "ClenshawCurtisRule"]

but when I specify the WorkingPrecision, the integral remains unevaluated:

NIntegrate[-m Exp[-m] BesselJ[1, m]^2, {m, 0, Infinity}, Method -> "ClenshawCurtisRule",
  WorkingPrecision -> 10]

What is wrong with this code?

I am using Mathematica v9.0.1


This bug is still present in version

share|improve this question
You can make it easier for others to check your code when you copy it straight from the Mathematica cell (copy as plain text) and paste it in your question with an indentation of 4 spaces. – Thies Heidecke Apr 29 '13 at 8:57
@ThiesHeidecke Codes are replaced with plain text. – M6299 Apr 29 '13 at 9:20
up vote 5 down vote accepted

This is a bug. As a workaround for this specific integral you could use a symbolic solution:

Integrate[-m*Exp[-m]*BesselJ[1, m]^2, {m, 0, Infinity}]

(* (-3*EllipticE[-4] + 5*EllipticK[-4])/(5*Pi) *)
share|improve this answer

"LevinRule" should work splendidly here, I think:

NIntegrate[-m Exp[-m] BesselJ[1, m]^2, {m, 0, Infinity}, 
           Method -> "LevinRule", WorkingPrecision -> 20]

ruebenko's answer has given a closed form for this particular definite integral. Personally, I prefer it when the parameters of the elliptic integrals are within $[0,1)$, so I apply the imaginary modulus transformations here to yield

N[(EllipticK[4/5] - 3 EllipticE[4/5])/(Sqrt[5] π), 20]
share|improve this answer
yes of course, good point. Using a different method is certainly an option. – user21 Apr 29 '13 at 12:03
This bug is apparently not present in version 7 so I added a version-9 tag; can you determine if this is in version 8? – Mr.Wizard Apr 30 '13 at 11:29
@Mr. Wizard, Yes, it's busted in version 8. – J. M. Apr 30 '13 at 11:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.