I was (pleasantly) surprised that when a D
erivative is taken of a symbolic function for which the last few arguments are Rule
s, a Derivative
object is returned with just the right number of arguments to ignore the Rule
s:
D[f[x,y,a->b],x] // InputForm
(* Derivative[0,1][f][x,y,a->b] *)
(* NOT: Derivative[0,1,0][f][x,y,a->b] *)
This makes sense since the Rule
s could represents options to the function f
.
Question: Has this behavior of D
and Derivative
been with Mathematica since v1?
But, then there is a strange behavior when D
is taken of a function in which a Rule
appears in a middle argument:
D[f[x,a->b,y],x]
(* (0 -> 0) Derivative[0, 1, 0][f][x, a -> b, y] + Derivative[1, 0, 0][f][x, a -> b, y] *)
D[f[x,a->b,y],y]
(* Derivative[0, 0, 1][f][x, a -> b, y] + (0 -> 0)*Derivative[0, 1, 0][f][x, a -> b, y] *)
Question: what is the interpretation of this output? In particular, what is the meaning of the term proportional to 0 -> 0
?
D
threads overRule
: e.g.D[x -> x, x]
evaluates to1 -> 1
. So it looks like the behavior you're seeing is a chain rule: for some reasonD
sees theRule
as a function ofx
, and so applies the chain rule. TheD
then threads overa -> b
, yielding0 -> 0
sincea
andb
are independent ofx
. $\endgroup$