# Integration of Modified Bessel K function

1. Analytic result Integrate[x BesselK[0, x], {x, 0, x0}] gives the result of -1 - x0 BesselK[1, x0], for positive x0. If Let x0 = 0.001, result = -2.
2. Numerical integration NIntegrate[x BesselK[0, x], {x, 0, 0.001}],the result is 3.76184*10^-6

One would expect the result should be > 0. Thus, the numerical result seems to be right. Is the analytic result wrong?

• "...for positive x0" implies you should use the option Assumptions -> x0 > 0 in Integrate. – Michael E2 Aug 8 '17 at 3:36

M11 seems inconsistent.

$Assumptions =. Integrate[x BesselK[0, x], {x, 0, x0}] ConditionalExpression[-x0 Subscript[K, 1](x0)-1,Re(x0)>0\[And]Im(x0)==0] Simplify[%, x0 > 0] -x0 BesselK[1, x0] - 1  Compare with $Assumptions = x0 > 0

Integrate[x BesselK[0, x], {x, 0, x0}]

1 - x0 BesselK[1, x0]


However, M8 just works.

• 10.1 has this bug too. FWIW you only need to specify the assumption that x0 is real to get the correct conditional expression. – george2079 Nov 6 '17 at 22:52

If

Integrate[x BesselK[0, x], x]
(* -x BesselK[1, x] *)

Limit[-x BesselK[1, x], x -> 0]
(* -1 *)


then Integrate[x BesselK[0, x], {x, 0, x0}] = -x0 BesselK[1, x0] - (-1) and

(-x BesselK[1, x] /. x -> 1/1000) - (-1) // N
(* 3.76184*10^-6 *)


Integrate[x BesselK[0, x], {x, 0, x0}]

• However, Assuming[x0 > 0, Integrate[x BesselK[0, x], {x, 0, x0}]] /. x0 -> 0.001` works as expected. – Bob Hanlon Jun 8 '17 at 18:33