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$
  • 1
    $\begingroup$ Shouldn't $S$ contain $x_{1,3}x_{3,4}$? $\endgroup$ – FalafelPita Aug 2 '17 at 17:16
  • $\begingroup$ @FalafelPita This is a watery mistake thanks for a note. see new update $\endgroup$ – Emad kareem Aug 2 '17 at 17:20
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$
  • $\begingroup$ Thank you very much for this right answer $\endgroup$ – Emad kareem Aug 2 '17 at 18:08
6
$\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$
  • 1
    $\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 Aug 3 '17 at 1:26
  • 2
    $\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$ – Daniel Lichtblau Aug 3 '17 at 16:00

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.