Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to define a variable q which is a function of t. And I want to define another variable qdot = dq/dt.

Then what I want to archive is that if I have a function f = a*Sin[q], and when I take the derivative df = D[f,t], Mathematica returns:


Is there a way to do this?

share|improve this question
Try using Dt[] instead of D[] – Dr. belisarius Aug 20 '13 at 18:58
You mean like this: f[t_] := a*Sin[q[t]]; D[f[t], t] gives a Cos[q[t]] q'[t] !Mathematica graphics – Nasser Aug 20 '13 at 19:13
@belisarius The problem with Dt[] is that the constant in my function also got differentiated. – auzn Aug 22 '13 at 4:14
@Nasser I tried your suggestion and it gives me a good result. I can even define q'[t_]:=qdot[t], so D[f[t],t] gives Cos[q[t]]qdot[t] – auzn Aug 22 '13 at 14:17
@Nasser If this works for the OP, please consider posting an answer:) – Kuba Sep 23 '13 at 23:51

The total derivative Dt will give you an answer assuming every symbol has a derivative, unlike the partial derivative D. To protect your constant, you can give it the attribute Constant.

SetAttributes[a, Constant]
f = a Sin[q];
Dt[f, t]
(* a Cos[q] Dt[q, t] *)
share|improve this answer
Nice experiment – Dr. belisarius Jun 6 '15 at 1:12
Yes, definitely a worthwhile effort. I shall endeavor to do the same, my good sir! (+1) – MarcoB Jun 9 '15 at 21:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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