How can I reorder the factors in the terms of a polynomial? Consider
poly1 = \!\(\*SubsuperscriptBox[\(x\), \(1\), \(3\)] + \*SubsuperscriptBox[\(x\), \(2\), \(3\)] + \*SubsuperscriptBox[\(x\), \(3\), \(3\)]\ - \ \(TraditionalForm\`\*SuperscriptBox[SubscriptBox[\(σ\), \(1\)], \(3\)]\)\) /. Subscript[σ, 1] -> (Subscript[x, 1] + Subscript[x, 2] + Subscript[x, 3]) // Expand
$$\begin{align*}-3 x_2 x_1^2-3 x_3 x_1^2-3 x_2^2 x_1-3 x_3^2 x_1-6 x_2 x_3 x_1-3 x_2 x_3^2-3 x_2^2 x_3\tag{1}\end{align*}$$
MonomialList[poly1, {Subscript[x, 1], Subscript[x, 2], Subscript[x, 3]}, "Lexicographic"]
$$\begin{align*}\left\{-3 x_1^2 x_2,-3 x_1^2 x_3,-3 x_1 x_2^2,-6 x_1 x_2 x_3,-3 x_1 x_3^2,-3 x_2^2 x_3,-3 x_2 x_3^2\right\}\tag{2}\end{align*}$$
% /. List -> Plus
$$\begin{align*}-3 x_2 x_1^2-3 x_3 x_1^2-3 x_2^2 x_1-3 x_3^2 x_1-6 x_2 x_3 x_1-3 x_2 x_3^2-3 x_2^2 x_3\tag{3}\end{align*}$$
Question1: How can I get
$$\begin{align*}-3 x_1^2 x_2-3 x_1^2 x_3-3 x_1 x_2^2-6 x_1 x_2 x_3-3 x_1 x_3^2-3 x_2^2 x_3-3 x_2 x_3^2\tag{4}\end{align*}$$
Question2: Even better if possible, how can I get
$$\begin{align*}-3\left( x_1^2 x_2+x_2^2x_1+\text{...}\right)-6 x_1 x_2 x_3\tag{5}\end{align*}$$
My goal is to keep the order of the terms in (2) unchanged when I copy (4)/(5) into an inline formula cell.
Row@MonomialList[..]
work for you, or do want the TeX output? I'm not sure I'm understanding the question correctly. $\endgroup$Row@%
, and the result can be copied to anInlineFormula
Cell. $\endgroup$Row
works in this case because of the negative coefficients. For positive coefficients, you'd have to insert a "+". $\endgroup$PolynomialForm
, but it doesn't seem to work quite right (see 9483, 15744, etc.). $\endgroup$