2
$\begingroup$

I have the following polynomial function $$f= x_{1,2} x_{2,4}+x_{1,3} x_{3,2} x_{2,4}+x_{1,2} x_{2,3} x_{3,2} x_{2,4}+x_{1,3} x_{3,4}+x_{1,2} x_{2,3} x_{3,4}$$

I want to convert the polynomial function to set consisting of terms of polynomial function as follows,

$$\{x_{1,2} x_{2,4},x_{1,3} x_{3,2} x_{2,4},x_{1,2} x_{2,3} x_{3,2} x_{2,4},x_{1,3} x_{3,4},x_{1,2} x_{2,3} x_{3,4}\}$$

Then, delete terms that contain another terms in the set.

$$x_{1,2} x_{2,4}\subset x_{1,2} x_{2,3} x_{3,2} x_{2,4}$$

so we delete $x_{1,2} x_{2,3} x_{3,2} x_{2,4}$ and we get,

$$S=\{x_{1,2} x_{2,4},x_{1,3} x_{3,4},x_{1,3} x_{3,2} x_{2,4},x_{1,2} x_{2,3} x_{3,4}\}$$

the mathematica code of the polynomial function $f$

f=Subscript[x, 1, 2] Subscript[x, 2, 4] + 
 Subscript[x, 1, 3] Subscript[x, 2, 4] Subscript[x, 3, 2] + 
 Subscript[x, 1, 2] Subscript[x, 2, 3] Subscript[x, 2, 4] Subscript[x,
   3, 2] + Subscript[x, 1, 3] Subscript[x, 3, 4] + 
 Subscript[x, 1, 2] Subscript[x, 2, 3] Subscript[x, 3, 4]

Thanks for the help.

$\endgroup$
2
  • 1
    $\begingroup$ Shouldn't $S$ contain $x_{1,3}x_{3,4}$? $\endgroup$ Commented Aug 2, 2017 at 17:16
  • $\begingroup$ @FalafelPita This is a watery mistake thanks for a note. see new update $\endgroup$ Commented Aug 2, 2017 at 17:20

2 Answers 2

4
$\begingroup$

You could use DeleteDuplicates + SortBy:

baseSet[f_] := DeleteDuplicates[
    SortBy[MonomialList[f], {Head, Length}],
    Denominator[#2/#1]==1&
]

For your example:

baseSet[f] //TeXForm

$\left\{x_{1,2} x_{2,4},x_{1,3} x_{3,4},x_{1,2} x_{2,3} x_{3,4},x_{1,3} x_{2,4} x_{3,2}\right\}$

$\endgroup$
1
  • $\begingroup$ Thank you very much for this right answer $\endgroup$ Commented Aug 2, 2017 at 18:08
7
$\begingroup$

This method is overkill for the given example but could be useful for larger problems of this type. It uses two steps, both with non-System context functions. The first is to get the monomials as lists of exponent vectors and corresponding coefficients (the latter of which we will ignore). Then we use a function that effectively finds the minimal exponent vectors, discarding the rest.

f = x[1, 2] x[2, 4] + x[1, 3] x[2, 4] x[3, 2] + 
   x[1, 2] x[2, 3] x[2, 4] x[3, 2] + x[1, 3] x[3, 4] + 
   x[1, 2] x[2, 3] x[3, 4];

Here is the list of monomial/coefficient pairs along with the ordering of variables that was used to create it (useful for converting back to monomials but I am omitting that step).

dtl = GroebnerBasis`DistributedTermsList[f, Variables[f]]

(* Out[291]= {{{{1, 1, 0, 1, 1, 0}, 1}, {{1, 1, 0, 0, 0, 0}, 
   1}, {{1, 0, 0, 0, 1, 1}, 1}, {{0, 1, 1, 1, 0, 0}, 
   1}, {{0, 0, 1, 0, 0, 1}, 1}}, {x[1, 2], x[2, 4], x[1, 3],
  x[3, 2], x[2, 3], x[3, 4]}} *)

Here we pick out our exponent vectors.

monoms = dtl[[1, All, 1]]

(* Out[293]= {{1, 1, 0, 1, 1, 0}, {1, 1, 0, 0, 0, 0}, 
{1, 0, 0, 0, 1, 1}, {0, 1, 1, 1, 0, 0}, {0, 0, 1, 0, 0, 1}} *)

And now we get the minimal elements.

Internal`ListMin[monoms]

(* Out[301]= {{1, 1, 0, 0, 0, 0}, {0, 0, 1, 0, 0, 1},
 {1, 0, 0, 0, 1, 1}, {0, 1, 1, 1, 0, 0}} *)

Some day I'll advocate for making that ListMin into a System-context function.

$\endgroup$
4
  • 2
    $\begingroup$ May I ask what Internal`ListMin does? Is it fair to say that it eliminates a subset of of rows so that the output matrix has MatrixRank equal to number of rows? $\endgroup$
    – QuantumDot
    Commented Aug 3, 2017 at 1:26
  • 3
    $\begingroup$ Given a list of lists of real values, all of the same length, Internal`ListMin removes any that has all elements greater or equal to elements of another. In effect if finds minimal elements. If the notion of a "Pareto front" is familiar, it is useful for finding those elements that give such a front. Lower hull supporting set (not necessarily convex) might be another way to view it. (Whether these help one to understand the function depends on one's familiarity with them, I realize.) $\endgroup$ Commented Aug 3, 2017 at 16:00
  • $\begingroup$ @DanielLichtblau Thanks. But why isn't there an analogous ListMax functionality internally? $\endgroup$
    – user688486
    Commented Nov 7, 2023 at 15:20
  • $\begingroup$ @user688486 Since ListMin is an internal function, there's no good reason to add what amounts to syntactic sugar for the "max" counterpart. It would just be -Internal`ListMin[-list]. $\endgroup$ Commented Nov 7, 2023 at 17:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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