9
$\begingroup$

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. System`Private`DerivativeX[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?

$\endgroup$
8
  • 2
    $\begingroup$ Looks like a bug when using inexact arguments and the shorten form f'[x] to me. $\endgroup$
    – Bob Hanlon
    Commented Feb 22, 2020 at 1:22
  • $\begingroup$ It works OK if you type D[f[x], x] instead of f'[x] Not sure why. could be a bug. $\endgroup$
    – Nasser
    Commented Feb 22, 2020 at 1:24
  • 4
    $\begingroup$ @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. $\endgroup$
    – Bob Hanlon
    Commented Feb 22, 2020 at 1:35
  • 4
    $\begingroup$ 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. $\endgroup$
    – Artes
    Commented Feb 22, 2020 at 1:51
  • 2
    $\begingroup$ 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 ! $\endgroup$
    – Nasser
    Commented Feb 22, 2020 at 1:56

2 Answers 2

6
$\begingroup$

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

SetAttributes[System`Private`DerivativeX, NHoldAll]

f[x_] = BesselI[0, 1.0 x];
f'[x]
(*  1. BesselI[1, 1. x]  *)
$\endgroup$
1
  • 1
    $\begingroup$ 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 $\endgroup$
    – b3m2a1
    Commented Feb 24, 2020 at 1:37
5
$\begingroup$

Fixed in 12.1

Mathematica graphics

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

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.