1
$\begingroup$

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$ enter image description here But I want to sort this polynomials by power order of $\Delta x$ and $\Delta y$ like this: enter image description here How can I do this with functions like Collect or Simplify?

$\endgroup$
6
  • $\begingroup$ You are aware Plus[] is Orderless, yes? $\endgroup$ Jan 29, 2020 at 0:42
  • $\begingroup$ Is this related mathematica.stackexchange.com/questions/30216/…? $\endgroup$
    – kcr
    Jan 29, 2020 at 0:46
  • $\begingroup$ @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. $\endgroup$ Jan 29, 2020 at 0:51
  • $\begingroup$ @PleaseCorrectGrammarMistakes Do you want this for the output or you just want to read the resulting prefactors easily? $\endgroup$
    – kcr
    Jan 29, 2020 at 1:29
  • $\begingroup$ @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. $\endgroup$ Jan 29, 2020 at 1:38

2 Answers 2

1
$\begingroup$
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}]
$\endgroup$
1
$\begingroup$

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

Image of the above Wolfram Cloud Input & Ouput

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.