In my program, there are many functions relying on spatial coordinates: x, y, and z, which are also functions of time t, i.e., composite function. I need to differentiate some functions for example f:

    D[f[x[t], y[t], z[t]], t]

But because those coordinates appear so frequently, when I write x[t] instead of x my program becomes lengthy and lacks readability. So, how can I declare those coordinates as functions of time t at the start to tell Mathematica that the differentiation is relative to t, so I can use x, y , and z, afterwards as an abbreviation.

  • 1
    $\begingroup$ You can use Dt as in Dt[f[x, y, z], t]. $\endgroup$ Feb 17, 2013 at 9:59
  • $\begingroup$ Thanks, I tried Dt[x^2, t], and Mma returns 2xDt[x, t]. whereas I need 2xx' $\endgroup$
    – novice
    Feb 17, 2013 at 12:08
  • $\begingroup$ The difference between Dt[x, t] and x' is : I can assign value to x', but I cannot assign value to Dt[x, t]. $\endgroup$
    – novice
    Feb 17, 2013 at 12:39
  • $\begingroup$ @user5463 No, you cannot assign a value to x'. It only seems you do it. Please read this answer of mine where I explain the details. $\endgroup$
    – halirutan
    Feb 17, 2013 at 12:47
  • $\begingroup$ Thanks halirutan, I have a little problem with the result of differentiation when i'm using Runge–Kutta method. For example, D[x[t]^2, t] returns 2x[t]*x'[t], i have to replace x'[t] with dx by hand so that I can assign value to dx, is there a convenient way to handle it automatically? $\endgroup$
    – novice
    Feb 17, 2013 at 14:41

2 Answers 2


No one stops you from creating a variable holding your Sequence of x[t], y[t] and z[t]! So an easy short cut is

vars = Sequence[x[t], y[t], z[t]];
D[f[vars], t]

When you need to access the single variables, you could go another way and use the formal characters which have some advantages as described in this answer

x = \[FormalX][t];
y = \[FormalY][t];
z = \[FormalZ][t];
D[f[x, y, z], t]

Your added comment suggest you want to replace the derivatives with symbols like dx etc. Maybe this does what you want:

ClearAll[x, y, z]

SetOptions[D, NonConstants -> {x, y, z}];

x /: D[x, t, NonConstants -> {x, y, z}] := dx;
y /: D[y, t, NonConstants -> {x, y, z}] := dy;
z /: D[z, t, NonConstants -> {x, y, z}] := dz;

D[f[x, y, z], t]

dz*Derivative[0, 0, 1][f][x, y, z] + dy*Derivative[0, 1, 0][f][ x, y, z] + dx*Derivative[1, 0, 0][f][x, y, z]

To check that this does exactly what you said in the comments to your question:

D[x^2, t]

2 dx x

  • $\begingroup$ Thanks Jens! That's what i want. $\endgroup$
    – novice
    Feb 18, 2013 at 1:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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