Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

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 do the following integration:

Ld = 2;
a1 = 0.3;
a2 = 1;    

potd[R_, z_] =
      -Integrate[(0.5/(2*a1)*Exp[-(Abs[z1]/a1)] + 
          BesselK[0, a/Ld]*a*
            Sqrt[(z - z1)^2 + (a + R)^2] + 
             Sqrt[(z - z1)^2 + (a - R)^2])], {a, 0, Infinity}, 
          GenerateConditions -> False], {z1, -Infinity, Infinity}, 
        GenerateConditions -> False];

then I evaluate the result for different pairs of R, z.

Mathematica complains that

NIntegrate::inumr: The integrand a ArcSin[(2 a)/(Sqrt[Power[<<2>>]+Power[<<2>>]]+Sqrt[Power[<<2>>]+Power[<<2>>]])] BesselK[0,a/2] has evaluated to non-numerical values for all sampling points in the region with boundaries {{∞,0}}. >>

The point is that there is no NIntegrate: what does it mean?

I upload the function from my notebook so you can see that I am not using a NIntegrate.


share|improve this question
Have you tried it with a1 = 3/10? It might help to indicate specific R, z that give the message. – Michael E2 Jul 30 '14 at 10:55
@MichaelE2 that error shows up before I use any number. – mattiav27 Jul 30 '14 at 11:33
Under some circumstances, which I cannot explain in this case, Mathematica will use numerical methods in symbolic calculations. In this case, it seems to have to do with having approximate numeric coefficients, 0.5 and a1. If they are changed to exact numbers 1/2 and 1/3, the NIntegrate messages do not appear. (FWIW, M tries to evaluate NIntegrate[a ArcSin[(2 a)/(Sqrt[(a - R)^2 + (z - z1)^2] + Sqrt[(a + R)^2 + (z - z1)^2])] BesselK[0, a/2], {a, 0, ∞}, WorkingPrecision -> 30.9546, AccuracyGoal -> ∞, PrecisionGoal -> 20.9546], which is foolish because R and z are symbols.) – Michael E2 Jul 30 '14 at 16:06
@MichaelE2 thanks for the clarification ;) – mattiav27 Jul 30 '14 at 17:47
up vote 2 down vote accepted

I think I solved this problem.

The error message was due to the fact that Mathematica cannot perform the internal integration, so I split the two integrations and used NIntegrate instead of the symbolic integration:

p[z1_?NumericQ, R_?NumericQ, z_?NumericQ] := 
   BesselK[0, x/Ld]*x*
     Sqrt[(z1)^2 + (x + 7.6)^2] + Sqrt[(z1)^2 + (x - 7.6)^2])], {x, 0,
potd[R_?NumericQ, z_?NumericQ] := 
  NIntegrate[(0.5/(2*a1)*Exp[-(Abs[z1]/a1)] + 
      0.5/(2*a2)*Exp[-(Abs[z1]/a2)])*p[z1, R, z], {z1, -Infinity, 
potd[7.6, 0]

with the result


Still: I don't undersand the previous error since I wasn't using numeric integration, but now it works...

share|improve this answer

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.