# Small question about the output form of the derivative

I have an expression:

D[D[Subscript[T, 1][x[t], y[t], x'[t]] + Subscript[T, 2][x[t], y[t], y'[t]], x'[t]], t]


The result is:

$$y'(t) T_1{}^{(0,1,1)}\left(x(t),y(t),x'(t)\right)+x'(t) T_1{}^{(1,0,1)}\left(x(t),y(t),x'(t)\right)+x''(t) T_1{}^{(0,0,2)}\left(x(t),y(t),x'(t)\right)$$

I need to make it so that when differentiating with respect to time, variables $$x'(t)$$ and $$y'(t)$$ are not taken out of brackets.

• What do you mean by "not be taken out of brackets"? Can you give a simpler example reproducing your problem, and include your desired output? Jun 16 at 13:58
• @MarcoB see my edit
– dtn
Jun 18 at 4:36
• You changed the questions completely so now the answers no longer match your question. That's not cool. I've reverted your edits so the question and answer match. Please ask a new different question on the new topic of sorting the order of the derivatives. Jun 18 at 13:16

Clear["Global*"]

(expr = HoldForm[
D[D[Subscript[T, 1][x[t], y[t], x'[t]] +
Subscript[T, 2][x[t], y[t], y'[t]], x'[t]], t]])


expr // TraditionalForm


expr // ReleaseHold


EDIT: To reverse the order of the products

expr2 = HoldForm[D[D[f[x[t], y''[t], z''[t], x'[t]], x'[t]], t]]


expr2 // TraditionalForm


expr2r = (expr2 // ReleaseHold) /. Times[a_, b_] :> HoldForm[Times[b, a]]


expr2r // TraditionalForm


EDIT 2: For the revised question

expr3 = Derivative[2][x][t]*
Derivative[0, 0, 2, 0, 0][f][x[t], y[t], Derivative[1][x][t],
Derivative[2][y][t], Derivative[3][z][t]] +
Derivative[3][y][t]*
Derivative[0, 0, 1, 1, 0][f][x[t], y[t], Derivative[1][x][t],
Derivative[2][y][t], Derivative[3][z][t]] +
Derivative[1][y][t]*
Derivative[0, 1, 1, 0, 0][f][x[t], y[t], Derivative[1][x][t],
Derivative[2][y][t], Derivative[3][z][t]] +
Derivative[1, 0, 0, 0, 0][f][x[t], y[t], Derivative[1][x][t],
Derivative[2][y][t], Derivative[3][z][t]] +
Derivative[4][z][t]*
Derivative[0, 0, 1, 0, 1][f][x[t], y[t], Derivative[1][x][t],
Derivative[2][y][t], Derivative[3][z][t]] +
Derivative[1][x][t]*
Derivative[1, 0, 1, 0, 0][f][x[t], y[t], Derivative[1][x][t],
Derivative[2][y][t], Derivative[3][z][t]];

(expr3r = expr3 /. Plus :> Inactive[Plus] /.
Inactive[Plus][a__, b_, c_] :> Inactive[Plus][a, c, b]) //


For subsequent operations Activate expr3r

• show more, please, how to sort the terms by the order of the derivative in the final expression
– dtn
Jun 17 at 14:28
• I don't understand your comment. Edit your question to show the output that you expect. Jun 17 at 14:33
• Are there any alternatives using the Sort or SortBy commands?
– dtn
Jun 18 at 7:24
• Look at my code please. Did I choose the right path? For example, I use: eqn = y[t] + f[z[t], y[t]] y''[t] + b[y[t]] y'''[t] + y'[t] == 0 format = Inactive[Plus] @@ Reverse[List @@ (Collect[#, {x_[t], Derivative[_][x_][t]}])] & format@eqn[[1]] == 0` I get this from here; mathematica.stackexchange.com/questions/265681/…
– dtn
Jun 18 at 8:30