5
$\begingroup$

Here is a function f that takes a variable number of arguments:

f = Times[##]*Log[1 - Times[##]] &

I now want to functionally take the derivative:

Derivative[1,0,0][f]

I expect:

(*  Log[1 - #1 #2 #3] #2 #3 - (#1 #2^2 #3^2)/(1 - #1 #2 #3) & *)

Instead I get the zero function:

(*  0 &  *)

I want to act like how it does on built-in variable functions like Power or Times:

Derivative[1, 0, 0][Power]
(*  #1^(-1 + #2^#3) #2^#3 & *)

Derivative[1, 0, 0][Times]
(*  #2 #3 & *)

How do I elegantly take the derivative of a pure function?


Motivation: I want to define the Derivative of another user-defined function in terms of f, like this:

Derivative[args__Integer][userFunction] := Derivative[args][f]
$\endgroup$
4
$\begingroup$

I'm not sure about your motivation, but the following definition seems to do what you need: BlankNullSequence (BlankSequence will work too)

f[x___] := Times[x]*Log[1 - Times[x]];
Derivative[1, 0, 0][f]

(*Log[1 - #1 #2 #3] #2 #3 - (#1 #2^2 #3^2)/(1 - #1 #2 #3) &*)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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