# Defining arbitrary order derivatives function [duplicate]

I have a function $\phi(t)$ and I want to define a function $\phi D(t,r):=\phi^{(r)}(t)$, in other words evaluate the $r$'th derivative of $\phi$ at $t$. The naive code that I have is:

phiD[t_, r_] = D[phi[t], {t, r}]

which doesn't work, because Mathematica doesn't know to evaluate the $r$ part first and then the $t$ part. What's the easiest way to implement this?

• I don't understand what the problem is that you face. If you dart, say, with phi[t_] := Sin[t]^5 Cos[t]^3, then phiD[t_, r_] = D[phi[t], {t, r}] returns essentially D[Cos[t]^3*Sin[t]^5, {t, r}]. And then phiD[t, 6] will give the correct 6th derivative as a function of t; you may then replace t with any particular numeric value. May 19 '14 at 19:58
• @murray: If you put in 'phiD[1,6]' you will get an error that '1' is not a valid variable. I am using Mathematica 9. May 19 '14 at 20:03
• @Artes: In the answers to the linked question, I don't see $s$ being substituted for a number anywhere. For example in the accepted answer, there's still the free variable $s$ that was differentiated in. Perhaps I'm misunderstanding something? May 19 '14 at 20:05
• @Artes: Derivative seems to work! Thanks! May 19 '14 at 20:09
• Yes, that's exactly as to be expected: if you put in a constant for the variable t in phiD[t_, r_] = D[phi[t], {t, r}], you're asking to take the tth derivative of a constant rather than of a function depending on a variable. And you're solution provided as an Answer certainly avoids that. I just wasn't clear what the original problem was. May 20 '14 at 0:42

phiD[t_,r_]=Derivative[r][phi][t]