5

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:

a*qdot*Cos[q]. 

Is there a way to do this?

Kuba
  • 136,707
  • 13
  • 279
  • 740
auzn
  • 225
  • 1
  • 5

1 Answers1

8

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] *)
Ian
  • 1,285
  • 10
  • 17