1
$\begingroup$

I am trying to define a derivative that acts on a custom function, $f$, such that when it acts, it increments one of the arguments of by 1. f is not defined; I just want to use it to keep track of derivatives. I know I could define a separate operator to do this, but this function, $f$, will be multiplied by other functions that need differentiating, so I thought it easier to define how derivatives act on f. My attempt thus far:

Derivative[1, 0, 0, 0][f[a,b,c,d]][x1, x2, x3, x4] = f[a,b,c,d]

However, when I go to evaluate this derivative, I get

Input: D[f[a,b,c,d][x1, x2, x3, x4], x1]
Output: f[a,b,c,d]^{1,0,0,0}[x1, x2, x3, x4]

whereas, I would hope to get something like:

Input: D[f[a,b,c,d][x1, x2, x3, x4], x1]
Output: f[a+1,b,c,d][x1, x2, x3, x4]

The derivative definition only works specifically for the exact syntax in the definition, and not with any other arguments apart from a,b,c,d:

Input: D[f[a,b,c,d][x1, x2, x3, x4], x1]
Output: f[a+1,b,c,d]

Any suggestions on how to obtain the second listed output?

$\endgroup$
  • $\begingroup$ Welcome to Mathematica.SE! I hope you will become a regular contributor. To get started, 1) take the introductory Tour now, 2) when you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge, 3) remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign, and 4) give help too, by answering questions in your areas of expertise. $\endgroup$ – bbgodfrey Jul 27 '15 at 21:03
  • 1
    $\begingroup$ Clear all your previous definitions, try Derivative[1, 0, 0, 0][f] = CKB[#1 + 1, #2, #3, #4] &, and report back. $\endgroup$ – J. M. is away Jul 27 '15 at 21:12
  • $\begingroup$ You're using Slot the wrong way. Also, I don't see why you expect the output to be in terms of f if you define the right-hand side to be CKB in the first line. $\endgroup$ – Jens Jul 27 '15 at 21:15
  • $\begingroup$ @Jens My mistake - CKB should be f. Edited. $\endgroup$ – Supersnaky2718 Jul 27 '15 at 21:42
  • $\begingroup$ @Guesswhoitis. Using Slot isn't necessary - since I don't fully understand how it works, I'm editing the question to functions without Slot. $\endgroup$ – Supersnaky2718 Jul 27 '15 at 21:44
2
$\begingroup$

It seems to be that all you need is SetDelayed (:=) instead of Set (=):

Derivative[1, 0, 0, 0][f][a_, b_, c_, d_] := f[a + 1, b, c, d]

Now let us evaluate some derivatives:

D[f[x, y, z, p], {x, 1}] (* with respect to that first argument *)
D[f[x, y, z, p], {y, 1}] (* with respect to any other argument *)

(*Out: 
f[1 + x, y, z, p]
Derivative[0, 1, 0, 0][f][x, y, z, p]
*)
$\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.