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?


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] *)


SetAttributes[{k1, k2}, Constant]
Dt[Sin[k1 x + k2 y]]
-> Cos[k1 x + k2 y] (k1 Dt[x] + k2 Dt[y])

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}]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy