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.


  • $\begingroup$ Have you tried it with a1 = 3/10? It might help to indicate specific R, z that give the message. $\endgroup$
    – Michael E2
    Jul 30, 2014 at 10:55
  • $\begingroup$ @MichaelE2 that error shows up before I use any number. $\endgroup$
    – mattiav27
    Jul 30, 2014 at 11:33
  • 2
    $\begingroup$ 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.) $\endgroup$
    – Michael E2
    Jul 30, 2014 at 16:06
  • $\begingroup$ @MichaelE2 thanks for the clarification ;) $\endgroup$
    – mattiav27
    Jul 30, 2014 at 17:47

1 Answer 1


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...


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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