Suppose I have the following list of monomials:
How could I manipulate it to get
such that they are in order by the total degree of the multivariate monomials?
It is important that although x*y, x^2, and y^2 all have the same degree, the x*y comes first.
I was vague with my sorting conditions. Let me further define the problem.
The following could be considered Pascal's triangle of monomials:
| 1 x | y x^2 x*y y^2 x^3 x^2*y | x*y^2 y^3 ... x^2*y^2 ... |
My goal is to ultimately extract a number of monomials from this triangle SYMMETRICALLY (from the centerline), starting at the top and moving outward from the centerline, moving to the next line in the triangle when needed. For example, if I want 4 monomials, I should get:
If i want 8 monomials, I should get:
A tricky case is if I want 9 monomials:
I can form a form of this triangle by creating the following matrix (easily generated):
1 x x^2 x^3 ... y x*y x^2*y x^3*y y^2 x*y^2 x^2*y^2 x^3*y^2 y^3 x*y^3 x^2*y^3 x^3*y^3 . . .
So if I need a list of
n monomials (assuming n is a valid number that lends to the symmetrical requirement), then I generate a size
When I flatten the resulting matrix, I obtain a list similar to the one I originally posted, that I feel if could be sorted based on the symmetry rules, would allow me to obtain the desired number of monomials.
If anybody has a better approach to this, I would be most grateful.