0
$\begingroup$

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.

$\endgroup$
3
  • 1
    $\begingroup$ 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? $\endgroup$
    – MarcoB
    Commented Jun 16, 2022 at 13:58
  • $\begingroup$ @MarcoB see my edit $\endgroup$
    – ayr
    Commented Jun 18, 2022 at 4:36
  • 1
    $\begingroup$ 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. $\endgroup$
    – MarcoB
    Commented Jun 18, 2022 at 13:16

1 Answer 1

5
$\begingroup$
Clear["Global`*"]

Use HoldForm

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

enter image description here

expr // TraditionalForm

enter image description here

expr // ReleaseHold

enter image description here

EDIT: To reverse the order of the products

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

enter image description here

expr2 // TraditionalForm

enter image description here

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

enter image description here

expr2r // TraditionalForm

enter image description here

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]) // 
      TraditionalForm

enter image description here

For subsequent operations Activate expr3r

$\endgroup$
4
  • $\begingroup$ show more, please, how to sort the terms by the order of the derivative in the final expression $\endgroup$
    – ayr
    Commented Jun 17, 2022 at 14:28
  • $\begingroup$ I don't understand your comment. Edit your question to show the output that you expect. $\endgroup$
    – Bob Hanlon
    Commented Jun 17, 2022 at 14:33
  • $\begingroup$ Are there any alternatives using the Sort or SortBy commands? $\endgroup$
    – ayr
    Commented Jun 18, 2022 at 7:24
  • $\begingroup$ 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/… $\endgroup$
    – ayr
    Commented Jun 18, 2022 at 8:30

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.