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 differentiate a function f[] for which I don't have a specific expression.

f[] depends on x and y and has parameters k1 and k2 in it.

x and y depend on t,and not on k1 nor k2.

So when I use the total derivation operator Dt[f, t], only x and y should be differentiated.

But how can I say Mathematica that k1 and k2 are constant, without assigning values to them?

share|improve this question

migrated from Sep 1 '12 at 17:53

This question came from our site for professional and enthusiast programmers.

How about:

Dt[f[x[t], y[t], k1, k2], t, Constants -> {k1, k2}]

(* Derivative[1][y][t]*Derivative[0, 1, 0, 0][f][x[t], y[t], k1, k2] + 
 Derivative[1][x][t]*Derivative[1, 0, 0, 0][f][x[t], y[t], k1, k2] *)
share|improve this answer


SetAttributes[{k1, k2}, Constant]
Dt[Sin[k1 x + k2 y]]
-> Cos[k1 x + k2 y] (k1 Dt[x] + k2 Dt[y])
share|improve this answer

In more general cases when k1 and k2 depend on certain variables ( they are not constants nevertheless we may assume their total derivatives vanish) we can make use of TagSet (/:) :

k1 /: Dt[k1, t] = 0;  k2 /: Dt[k2, t] = 0;
Dt[ f[ x, y, k1, k2], t]

enter image description here

Instead of playnig with TagSet, sometimes a more flexible way would be Refine ( similarly Simplify or FullSimplify) with appropriate assumptions (i.e. vanishing total derivatives), e.g. :

Refine[ Dt[ f[x, y, k1, k2], t], { Dt[k1, t] == 0, Dt[k2, t] == 0}]
share|improve this answer

Your Answer


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