3
$\begingroup$

I want to order lexicographically the monomials in a "parametrized polynomial", i.e. polynomials whose "symbolic bits" may be either "variables" or "parameters". For example:

In[1]:= Expand[(x + a y + a^2 z)^3] /. a^n_ -> a^Mod[n, 3] Out[1]= x^3 + y^3 + 6 x y z + z^3 + 3 x^2 y a + 3 y^2 z a + 3 x z^2 a + 3 x y^2 a^2 + 3 x^2 z a^2 + 3 y z^2 a^2 

In the polynomial above x, y, and z are intended as "variables", whereas a is intended as a "parameter".

The documentation for Mathematica states that monomials in a polynomial are ordered lexicographically by default, but if so, I don't understand why the two terms with x^2 come after the y^3 term in the polynomial above, for example.

So my question is: how can I force a lexicographic ordering of the monomials with respect to the "variables" (i.e. x, y, and z). (In particular, for the polynomial above, the symbol a should be disregarded for the ordering.)

For example, the desired ordering for the polynomial above would be

x^3 + 3 x^2 y a + 3 x^2 z a^2 + 3 x y^2 a^2 + 3 x z^2 a + 6 x y z + y^3 + 3 y^2 z a + 3 y z^2 a^2 + z^3 
$\endgroup$
2
  • $\begingroup$ something like: TraditionalForm[Expand[(x+a y+a^2 z)^3]/.a^n_->a^Mod[n,3], ParameterVariables->{a}] ? $\endgroup$ Commented Jan 15, 2014 at 17:02
  • $\begingroup$ @chuy: thanks! (I was thrown off by the fact that the docs describe ParameterVariables as "an option for GroebnerBasis and PolynomialReduce.") If you care to post your comment as an answer, I'll be glad to accept it as such. $\endgroup$ Commented Jan 15, 2014 at 17:10

1 Answer 1

4
$\begingroup$

In this case you can use something like:

TraditionalForm[Expand[(x+a y+a^2 z)^3]/.a^n_->a^Mod[n,3], ParameterVariables:>{a}] 

This information can be found in the following: http://reference.wolfram.com/mathematica/tutorial/PolynomialOrderings.html (toward the bottom)

$\endgroup$
3
  • $\begingroup$ Sorry, unfortunately, since my last comment I discovered some serious problems with this approach. I describe them in an EDIT to my post. $\endgroup$ Commented Jan 15, 2014 at 20:08
  • $\begingroup$ I suppose I don't understand your question well enough then. I thought this was primarily for display purposes. What is wrong with using MonomialList[expr, {x, y, z}, "Lexicographic"] where exp is the polynomial? $\endgroup$ Commented Jan 15, 2014 at 20:25
  • $\begingroup$ OK, now I see what's going on: the output of the original expression I posted does not reflect the internal ordering. $\endgroup$ Commented Jan 15, 2014 at 20:50

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.