Question: How to define an ordering on partial derivatives?

Notional example:
I use mtaylor compute the Taylor expansion of a function f (U) of several variables U1, .., UN.
In the resul the terms are ordered this way:

  • the leftmost term is f (P) where P denotes the point where the expansion is done
  • followed by a succession of terms :
    • firstly ranked according to the total order of derivation of  f.
    • and among terms of same derivation order, ranked in some kind of lexicographic order

For instance

Vars    := [seq(U[i], i=1..2)]:
AtPoint := [seq(P[i], i=1..2)]:
mt      := mtaylor(f(Vars[]), Vars =~ AtPoint, 3)

 

f(P[1], P[2])+(D[1](f))(P[1], P[2])*(U[1]-P[1])+(D[2](f))(P[1], P[2])*(U[2]-P[2])+(1/2)*(D[1, 1](f))(P[1], P[2])*(U[1]-P[1])^2+(D[1, 2](f))(P[1], P[2])*(U[1]-P[1])*(U[2]-P[2])+(1/2)*(D[2, 2](f))(P[1], P[2])*(U[2]-P[2])^2

(1)

map(t -> op([0, 0], select(has, [op(t)], D)[]), [op(mt)][2..-1])

[D[1], D[2], D[1, 1], D[1, 2], D[2, 2]]

(2)
 

 

Download mtaylor.mw

How could I define another ordering of the terms in this mtaylor expansion?
For instance 1 being identified to some letter and 2 to another one such that 1 <  2 a lexicographic order would be 

D[1], D[1, 1], D[1, 2], D[2], D[2, 2]

Thanks in advance

Please Wait...