The polynomial function changed to a set consisting of terms of polynomial function - Mathematica Stack Exchange most recent 30 from mathematica.stackexchange.com 2019-11-14T18:39:05Z https://mathematica.stackexchange.com/feeds/question/152910 https://creativecommons.org/licenses/by-sa/4.0/rdf https://mathematica.stackexchange.com/q/152910 2 The polynomial function changed to a set consisting of terms of polynomial function Emad kareem https://mathematica.stackexchange.com/users/44458 2017-08-02T15:39:47Z 2017-08-02T18:39:45Z <p>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}$$</p> <p>I want to convert the polynomial function to set consisting of terms of polynomial function as follows,</p> <p>$$\{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}\}$$</p> <p>Then, delete terms that contain another terms in the set.</p> <p>$$x_{1,2} x_{2,4}\subset x_{1,2} x_{2,3} x_{3,2} x_{2,4}$$</p> <p>so we delete $x_{1,2} x_{2,3} x_{3,2} x_{2,4}$ and we get,</p> <p>$$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}\}$$</p> <p>the mathematica code of the polynomial function $f$</p> <pre><code>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] </code></pre> <p>Thanks for the help.</p> https://mathematica.stackexchange.com/questions/152910/-/152923#152923 4 Answer by Carl Woll for The polynomial function changed to a set consisting of terms of polynomial function Carl Woll https://mathematica.stackexchange.com/users/45431 2017-08-02T17:47:40Z 2017-08-02T17:47:40Z <p>You could use <a href="http://reference.wolfram.com/language/ref/DeleteDuplicates" rel="noreferrer"><code>DeleteDuplicates</code></a> + <a href="http://reference.wolfram.com/language/ref/SortBy" rel="noreferrer"><code>SortBy</code></a>:</p> <pre><code>baseSet[f_] := DeleteDuplicates[ SortBy[MonomialList[f], {Head, Length}], Denominator[#2/#1]==1&amp; ] </code></pre> <p>For your example:</p> <pre><code>baseSet[f] //TeXForm </code></pre> <blockquote> <p>$\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\}$</p> </blockquote> https://mathematica.stackexchange.com/questions/152910/-/152932#152932 6 Answer by Daniel Lichtblau for The polynomial function changed to a set consisting of terms of polynomial function Daniel Lichtblau https://mathematica.stackexchange.com/users/51 2017-08-02T18:39:45Z 2017-08-02T18:39:45Z <p>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.</p> <pre><code>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]; </code></pre> <p>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).</p> <pre><code>dtl = GroebnerBasisDistributedTermsList[f, Variables[f]] (* Out= {{{{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]}} *) </code></pre> <p>Here we pick out our exponent vectors.</p> <pre><code>monoms = dtl[[1, All, 1]] (* Out= {{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}} *) </code></pre> <p>And now we get the minimal elements.</p> <pre><code>InternalListMin[monoms] (* Out= {{1, 1, 0, 0, 0, 0}, {0, 0, 1, 0, 0, 1}, {1, 0, 0, 0, 1, 1}, {0, 1, 1, 1, 0, 0}} *) </code></pre> <p>Some day I'll advocate for making that <code>ListMin</code> into a System-context function.</p>