TransWikia.com

Partial differentiation second order

Mathematica Asked on July 27, 2021

I have some rules for differentiation:

myD[-a_, o_] := -myD[a, o];
myD[a_, -o_] := -myD[a, o];
myD[a_ + n_, o_] := myD[a, o] + myD[n, o];
myD[a_ b_, o_] := b myD[a, o] + a myD[b, o];
myD[myD[a_, b__], c__] := myD[a, b, c]
Format[HoldPattern@myD[a_, b__]] := TraditionalForm@HoldForm@D[a, b]
$Assumptions = 
 x [Element] Matrices[{2*M, 2*M}, Reals, Antisymmetric[{1, 2}]]
x[arg__] /; ! OrderedQ@{arg} := Signature@{arg} x @@ Sort@{arg} 
Format[x[arg__]] := Subscript[x, arg]

What to do to create a new rule that defines,
$$frac{partial ^2Q}{partial x_{1,2}, partial x_{3,4}}=frac{partial ^2Q}{partial x_{3,4}, partial x_{1,2}}$$

myD[myD[Q, x[1, 2]], x[3, 4]] 

is how to write code to get $frac{partial ^2Q}{partial x_{1,2}, partial x_{3,4}}$

One Answer

You can do something like this:

myD[a_, o__] /; ! OrderedQ@{o} := myD[a, Sequence @@ Sort@{o}]

myD[myD[Q, x[1, 2]], x[3, 4]] 

enter image description here

This will ensure that the coordinates after which the expression is differentiated are always sorted. You can define another order instead of Sort{o}, but the key is that all equivalent forms are converted into a single canonical version:

myD[myD[Q, x[1, 2]], x[3, 4]] == myD[myD[Q, x[3, 4]], x[1, 2]] 
(* True *)

Correct answer by Lukas Lang on July 27, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP