# The ordering problem of multivariate polynomials

This is the result of Taylor expansion of a binary function

F[k_] := Sum[Binomial[k, r]*Δx^r*Δy^(k - r)*   Derivative[r, k - r][f][x0, y0], {r, 0, k}]
f[x_, y_] := x^2*y^2
Expand[Sum[F[i]/i!, {i, 0, 3}]]


$$F[\text{k\_}]\text{:=}\sum _{r=0}^k \text{\Delta x}^r \binom{k}{r} \text{\Delta y}^{k-r} f^{(r,k-r)}[\text{x0},\text{y0}]$$ $$f[\text{x\_},\text{y\_}]\text{:=}x^2 y^2$$ $$\text{Expand}\left[\sum _{i=0}^3 \frac{F[i]}{i!}\right]$$ The output is not ordered by the sum of the powers of $$\Delta x$$ and $$\Delta y$$ But I want to sort this polynomials by power order of $$\Delta x$$ and $$\Delta y$$ like this: How can I do this with functions like Collect or Simplify?

• You are aware Plus[] is Orderless, yes? Jan 29, 2020 at 0:42
• Is this related mathematica.stackexchange.com/questions/30216/…?
– kcr
Jan 29, 2020 at 0:46
• @J.M. Yes, I don't want the sorting of the results to be broken by the unordered properties of the Plus function and I want to arrange the results as required. Jan 29, 2020 at 0:51
• @PleaseCorrectGrammarMistakes Do you want this for the output or you just want to read the resulting prefactors easily?
– kcr
Jan 29, 2020 at 1:29
• @A_user_with_NoName I want to read the resulting prefactors easily.I want to write a custom function to sort the output results according to the above requirements. Jan 29, 2020 at 1:38

orderedForm[poly_, var_List] :=
HoldForm[+##] & @@
MonomialList[poly,
var][[Ordering[-Total[#] & @@@ CoefficientRules[poly, var], All,
GreaterEqual]]];
orderedForm[
Expand[Sum[
F[i]/i!, {i, 0, 3}]], {Δx, Δy}]


Interestingly, Wolfram Cloud seems to give an almost-desired answer, clearly indicating use of a differing subroutine. Posting this an an answer as it is too much for a comment:

F[k_] := Sum[Binomial[k, r]*\[CapitalDelta]x^r*\[CapitalDelta]y^(k - r)*   Derivative[r, k - r][f][x0, y0], {r, 0, k}]
f[x_, y_] := x^2*y^2
Expand[Sum[F[i]/i!, {i, 0, 3}]]


Gives

x0^2*y0^2 + 2*x0*y0^2*\[CapitalDelta]x + y0^2*\[CapitalDelta]x^2 + 2*x0^2*y0*\[CapitalDelta]y + 4*x0*y0*\[CapitalDelta]x*\[CapitalDelta]y + 2*y0*\[CapitalDelta]x^2*\[CapitalDelta]y + x0^2*\[CapitalDelta]y^2 + 2*x0*\[CapitalDelta]x*\[CapitalDelta]y^2


While close, this does not satisfy the OP’s requirements, although it does provide impetus for further investigation of the dependence of the polynomial ordering displayed.