# Possible bug involving derivative of BesselI

Bug introduced in 12.0 or earlier. Fixed in 13.2 or earlier.

In Mathematica 12.0, I run the following code:

f[x_] = BesselI[0, x];
f'[x]


which returns BesselI[1, x] as expected. But if I enter

f[x_] = BesselI[0, 1.0 x];
f'[x]


I get

0.5 (BesselI[1, 1. x] + BesselI[1, 1. SystemPrivateDerivativeX[1.]])


Moreover, D[f[x],x] returns the expected result. I have tried quitting the kernel with no change. Is this a bug, or is something messed up with my installation?

• Looks like a bug when using inexact arguments and the shorten form f'[x] to me. Feb 22, 2020 at 1:22
• It works OK if you type D[f[x], x] instead of f'[x] Not sure why. could be a bug. Feb 22, 2020 at 1:24
• @Artes - I do not agree that "defining symbolic functions with approximate numbers is unreasonable." While you might not write 1.0 x, it is reasonable to expect BesselI[0, a x] where a is given an inexact value. In version 12, any inexact value for a produces the behavior shown in the OP. Feb 22, 2020 at 1:35
• Both inexact numbers and Set in definitions of special functions is just a "bad approach" even though it would be nicer if there were no such weak points. Feb 22, 2020 at 1:51
• I agree with both Bob and Artes here. Both make good points. But Mathematica should also do more type checking of its arguments. May be issue a warning that inexact number is detected with special function for example when exact is expected. I think Mathematica in general still does not do very good type checking on input to its functions. See for example, the code xzczd found in here chat.stackexchange.com/transcript/message/53557093#53557093 where LaplaceTransform[Sin[1], 1, 1] is accepted with no error and it returns 1/2 ! Feb 22, 2020 at 1:56

A fix is to give SystemPrivateDerivativeX the NHoldAll attribute (which it probably should have, since it seems to be used as a dummy indexed variable):

SetAttributes[SystemPrivateDerivativeX, NHoldAll]

f[x_] = BesselI[0, 1.0 x];
f'[x]
(*  1. BesselI[1, 1. x]  *)

• Interestingly, this also works fine if you use anonymous functions: g = BesselI[0, 1.*#] &; g'[x]. It also works fine if the 0 is anything other than 0 e.g. f[x_] := BesselI[a, 1.*x]; f'[x] /. a -> 0 Feb 24, 2020 at 1:37

Fixed in 12.1

ClearAll[f, x];
f[x_] = BesselI[0, 1.0 x];