Package zerodim: Difference between revisions

From ApCoCoAWiki
LongLe (talk | contribs)
No edit summary
LongLe (talk | contribs)
No edit summary
Line 4: Line 4:
This package contains various functions for computing algebraic invariants of zero-dimensional schemes and related computations.
This package contains various functions for computing algebraic invariants of zero-dimensional schemes and related computations.


The basic idea behind this package is to make the linear optimization program GLPK usable in/with ApCoCoA. The package GLPK contains various functions that let you make use of the GLPK library, rather the stand-alone LP/MIP Solver glpsol.
== Mathematical Definitions ==
Let <math>K</math> be a field and let <math>P = K[x_1,\ldots,x_n]</math> be the polynomial ring over <math>K</math> in <math>n</math> indeterminates. Most of the definitions here are taken from the book [https://staff.fim.uni-passau.de/kreuzer/cabook2/CCA2.html Computational Commutative Algebra 2] by Martin Kreuzer and Lorenzo Robbiano.


<em>Important</em>: For usage under linux, the GLPK-Program glpsol must be in the ApCoCoA package directory under <code>packages/binaries/glpk/examples/glpsol</code> and you must have the permissions to read and write in this directory. For Windows, the glsol.exe has to be in the folder <code>packages\binaries\glpk\w64\glpsol.exe</code>. If you installed ApCoCoA-2 together with the GUI, this should already be the case.
=== Subalgebras ===
A subset <math>S \subseteq P</math> is called a <math>K</math>-'''subalgebra''' of <math>P</math>, if
*<math>K \subseteq S</math> and
*<math>S</math> is closed under addition and multiplication.
For a subset <math>F = \{f_1,\ldots,f_s\} \subseteq P</math>, we write
:<math>K[F] = K[f_1,\ldots,f_s] = \{p(f_1,\ldots,f_s) \mid p \in K[y_1,\ldots,y_s]\}</math>
where <math>K[y_1,\ldots,y_s]</math> is a new polynomial ring in <math>s</math> indeterminates for the '''<math>K</math>-subalgebra of <math>P</math> generated by <math>F</math>'''.


The source code of GLPK can be downloaded at [http://www.gnu.org/software/glpk/].
=== SAGBI bases ===
Let <math>\sigma</math> be a [[HowTo:Term Orderings|term ordering]] on <math>P</math> and let <math>S</math> be a <math>K</math>-subalgebra of <math>P</math>. A set <math>G \subseteq S</math> is called a <math>\sigma</math>-SAGBI basis of <math>S</math> if <math>K[{\rm LT}_\sigma(f) \mid f \in S] = K[{\rm LT}_\sigma(f) \mid f \in G]</math>.


== Optimizing Linear Systems Of Equations ==
If <math>S</math> is a [[HowTo:Gradings|graded subalgebra]] and <math>d \in \mathbb{N}</math>, then a set <math>G_{\leq d}</math> is called a '''<math>d</math>-truncated <math>\sigma</math>-SAGBI basis of <math>S</math>''', if
:''See also: [[/GLPK.LPSolve/]]
:<math>K[{\rm LT}_\sigma(f) \mid f \in S \text{ and } \deg(f) \leq d] = K[{\rm LT}_\sigma(f) \mid f \in G_{\leq d}].</math>
Let <math>n \in \mathbb{N}</math> and <math>P = \mathbb{Q}[x_1,\ldots,x_n]</math>. Let <math>f_1,\ldots,f_{s_1},g_1,\ldots,g_{s_2},h_1,\ldots,h_{s_3},c \in P</math> be linear polynomials and let <math>l_1,\ldots,l_n,u_1,\ldots,u_n \in \mathbb{Q} \cup \{- \infty,\infty\}</math>. Let <math>S</math> be the system of polynomial (in)equations
Equivalently, a set <math>G_{\leq d}</math> is a <math>d</math>-truncated <math>\sigma</math>-SAGBI basis of <math>S</math> if there is a <math>\sigma</math>-SAGBI basis of <math>S</math> with <math>G_{\leq d} = \{g \in G \mid \deg(g) \leq d\}</math>.
:<math>\left\{ \begin{array}{ccc}
  f_1(b) & = & 0 \\
  \vdots & \vdots & \vdots \\
  f_{s_1}(b) & = & 0 \\
  g_1(b) & \leq & 0 \\
  \vdots & \vdots & \vdots \\
  g_{s_2}(b) & \leq & 0 \\
  h_1(b) & \geq & 0 \\
  \vdots & \vdots & \vdots \\
  h_{s_3}(b) & \geq & 0.
\end{array}\right.</math>
Then the function <code>[[/GLPK.LPSolve/]]</code> can be used to find solution <math>b = (b_1,\ldots,b_n) \in [l_1,u_1] \times \cdots \times [l_n,u_n]</math> to <math>S</math> such that <math>c(b) = \min\{c(x) \mid x \in [l_1,u_1] \times \cdots \times [l_n,u_n] \text{ is a solution to } S\}</math> in the following way.


*Let <code>EQ</code> be the list <math>\{f_1,\ldots,f_{s_1}\}</math>, let <code>LE</code> be the list <math>\{g_1,\ldots,g_{s_2}\}</math>, and let <code>GE</code> be the list <math>\{h_1,\ldots,h_{s_3}\}</math>.
=== The Subalgebra Rewrite Relation ===
*Let <code>l</code> and <code>u</code> be the lists containing the upper and lower bounds for the <math>b_i</math> with <code>l[i]</code><math> = l_i</math> and <code>u[i]</code><math> = u_i</math>, if both are rational numbers. Instead of <math>\infty</math> and <math>- \infty</math>, write <code>l[i] = ""</code> or <code>u[i] = ""</code>. Set <code>B := [ [l[1],u[1]], [l[2],u[2]], ..., [l[n],u[n]] ]</code>.
Let <math>G \subseteq P</math> be a set of non-zero polynomials. Furthermore, let <math>\sigma</math> be a term ordering on <math>\mathbb{T}^n</math>.
*Choose a string <code>Method</code> from <code>[ "InterP", "Simplex" ]</code> depending on the method you want GLPK to use for solving the problem (<code>"InterP"</code> stands for the inter-point-method and <code>"Simplex"</code> for the simplex method)
* For <math>f, g \in P \setminus \{0\}</math>, we say that <math>f</math> '''subalgebra reduces to <math>g</math> in one step''' if there are <math>f_1,\ldots,f_s \in G</math>, a term <math>t \in \mathbb{T}^s</math>, and a constant <math>c \in K</math> such that <math>g = f - c t(f_1,\ldots,f_s)</math> and <math>{\rm LT}_\sigma(t(f_1,\ldots,f_s))</math> is not anymore in <math>{\operatorname{Supp}}(g)</math>. The path from <math>f</math> to <math>g</math> is then called a '''subalgebra reduction step''' and denoted by <math>f {\xrightarrow{G}}_{\rm ss} g</math>.
*Choose a string <code>MinMax</code> from <code>[ "Min", "Max" ]</code> depending on whether you want <math>b</math> to fulfill <math>c(b) = \min\{c(x) \mid x \in [l_1,u_1] \times \cdots \times [l_n,u_n] \text{ is a solution to } S\}</math> or <math>c(b) = \max\{c(x) \mid x \in [l_1,u_1] \times \cdots \times [l_n,u_n] \text{ is a solution to } S\}</math>.
* The transitive closure of the relation <math>{\xrightarrow{G}}_{\rm ss}</math> is denoted by <math>{\xrightarrow{G}}_{\rm s}</math> and called the '''subalgebra rewrite relation''' defined by <math>G</math>. If there are <math>f, g \in P</math> with <math>f {\xrightarrow{G}}_{\rm s} g</math>, we say that <math>f</math> '''subalgebra reduces''' to <math>g</math>.
Then call
* If <math>g \in P</math> such that there is no <math>h \in P</math> with <math>h \neq g</math> and <math>g {\xrightarrow{G}}_{\rm ss} h</math>, then <math>g</math> is called '''irreducible''' with respect to the relation <math>{\xrightarrow{G}}_{\rm s}</math>. Sometimes we may also just write that <math>g</math> is irreducible with respect to <math>G</math>.
<pre>GLPK.LPSolve(c,EQ,LE,GE,B,Method,MinMax)</pre>
A set <math>G \subseteq P</math> is called '''interreduced''' if every element <math>g \in G</math> is monic and irreducible with respect to <math>G \setminus \{g\}</math>. If <math>G</math> is a <math>\sigma</math>-SAGBI basis of <math>K[G]</math> which is interreduced, then it is called a '''reduced <math>\sigma</math>-SAGBI basis'''. Analogously to reduced Gröbner bases, it can be shown that every <math>K</math>-subalgebra has a unique reduced <math>\sigma</math>-SAGBI basis.
to get the desired solution as a list <code>b = [b1,...,bn]</code> or the empty list <code>[]</code> if the given system of (in)equalities is unsatisfiable.  


== Solving Mixed Integer Problems ==
=== The Subalgebra Division Algorithm ===
:''See also: [[/GLPK.MIPSolve/]]
Let <math>\sigma</math> be a term ordering on <math>\mathbb{T}^n</math>, <math>f \in P</math> and <math>G = \{f_1,\ldots,f_s\} \subseteq P</math> be a set of non-zero polynomials. Consider the following sequence of instructions.
Let <math>I, J \subseteq \{1,\ldots,n\}</math> be disjoint sets. If additionally, a solution <math>b = (b_1,\ldots,b_n)</math> with <math>b_i \in \mathbb{N}</math> for <math>i \in I</math> and <math>b_j \in \{0,1\}</math> for <math>j \in J</math> is searched, then one can use the function <code>[[/GLPK.MIPSolve/]]</code>. Together with <code>c</code>, <code>EQ</code>, <code>LE</code>, <code>GE</code>, <code>B</code> and <code>MinMax</code> from above, the code
# Set <math>g := f</math>.
<pre>GLPK.MIPSolve(c,EQ,LE,GE,B,I,J,MinMax)</pre>
# Write <math>g = c_1t_1 + \cdots + c_m t_m</math> with <math>t_i \in \mathbb{T}^n</math>, <math>c_i \in K</math> for <math>i = 1,\ldots,m</math>, and <math>t_1 \geq_\sigma \cdots \geq_\sigma t_m</math>. Set <math>k := 1</math>.
produces the desired solution or <code>[]</code> if the given system has no such solution.
# If <math>k = m+1</math>, stop and return <math>g</math>. Otherwise, check whether there is a term <math>t \in \mathbb{T}^s</math> such that <math>t_k = t({\rm LT}_\sigma(f_1),\ldots,{\rm LT}_\sigma(f_s))</math>. If there is one, set <math>c = t({\rm LC}_\sigma(f_1),\ldots,{\rm LC}_\sigma(f_s))</math>, replace <math>g</math> by <math>g - \frac{c_i}{c} t(f_1,\ldots,f_s)</math> and go to step~(2). If there is none, increase <math>k</math> by one and repeat this step.
This is an algorithm which returns a polynomial <math>g \in P</math> such that <math>f {\xrightarrow{G}}_{\rm s} g</math> and <math>g</math> is irreducible with respect to <math>{\xrightarrow{G}}_{\rm s}</math>.
This algorithm clearly computes a polynomial <math>g \in P</math> with <math>f {\xrightarrow{G}}_{\rm s} g</math> and <math>g</math> is irreducible with respect to <math>G</math>.


== Package Description ==
All of the previously described definitions are implemented in the SAGBI package.
=== Basic functions ===
Given a polynomial ring <code>P</code> and a list <code>F</code> of polynomials in <code>P</code>, one can compute the reduced SAGBI basis of <math>K</math>[<code>F</code>] (with respect to the term ordering given by <code>P</code>) using the function [[/SB.SAGBI/]] - as long as a finite one exists.
<pre>
SB.SAGBI(F);
</pre>
Note that this function probably runs into an infinite loop if no finite SAGBI basis exists. This can be avoided using the function [[/SB.SAGBITimeout/]]. Given a positive integer <code>s</code>, one can type in
<pre>
SB.SAGBITimeout(F,s);
</pre>
which does the same as <code>SB.SAGBI(F)</code>, but throws an error if the computation is not finished within <code>s</code> seconds.
Given a polynomial <code>f</code> and a list of polynomials <code>G</code>, the function [[/SB.ReductionStep/]] can be used to compute a polynomial <code>g</code> with <code>f</code><math>{\xrightarrow{G}}_{\rm s}</math><code>g</code>.
<pre>
SB.ReductionStep(f,G);
</pre>
If no such polynomial exists, then <code>f</code> is returned. This function is then used by the function [[/SB.SDA/]], which is an implementation of the Subalgebra Division Algorithm described above.
<pre>SB.SDA(f,G)</pre>
Analogously to the CoCoA-5 function <code>interreduced</code>, the SAGBI package contains the function [[/SB.Interreduced/]] which takes as input a list of polynomials <code>G</code> and returns a list <code>G'</code> with <math>K[G] = K[G']</math>.
<pre>
SB.Interreduced(G);
</pre>
=== Special Functions for Graded Subalgebras ===
If <code>G</code> is a set of [[HowTo:Gradings|homogeneous]] polynomials, then there are additional functions one can use. Given a positive integer<code>d</code>, a <code>d</code>-truncated SAGBI basis can be computed using [[/SB.TruncSAGBI/]].
<pre>
SB.TruncSAGBI(G,d);
</pre>
If additionally, the Hilbert series <code>HS</code> of the subalgebra <math>K[G]</math> is given, one can call
<pre>
SB.TruncSAGBI(G,d,HS);
</pre>
which does the same as above, but computes the SAGBI basis Hilbert-driven, which may be a little bit faster.
The function [[/SB.SubalgebraHS/]] can be applied to compute the Hilbert series of a graded subalgebra.
<pre>
SB.SubalgebraHS(G);
</pre>
If furthermore <code>G</code> is a set of terms, then the function
<pre>
SB.TorRingHS(G);
</pre>
can be used to compute its Hilbert series much more efficient.
=== The Subalgebra Data Type ===
The package also introduces a new ''Data type'', i.e. a record tagged with <code>"$apcocoa/sagbi.Subalgebra"</code>. Given a polynomial ring <code>P</code> and a list of polynomials <code>G</code> from <code>P</code>, one can create the subalgebra <math>K[G]</math> using the function [[/SB.Subalgebra/]].
<pre>
Use P ::= QQ[x,y,z];
G := [x^2+y*z,z];
S := SB.Subalgebra(P,G);
</pre>
For details about the structure of this data type, see the function page.
While nearly all functionalities of the SAGBI package can be used without touching this data type, it has many advantages to do so because it stores informations of previous computations, see the example below. This is also the reason why many of the getter functions need the subalgebra to be called by reference.
The following getter function can be used to get informations about the subalgebra:
[[/SB.GetCoeffRing/]](S); -- returns the coefficient ring
[[/SB.GetGens/]](S); -- returns the set G
[[/SB.GetID/]](S); -- returns the unique ID of S
[[/SB.GetLTSA/]](ref S); -- returns the subalgebra K[LT(f) | f in S]
[[/SB.GetRing/]](S); -- returns P
[[/SB.GetSAGBI/]](ref S); -- returns the reduced SAGBI basis of S (if a finite one exists)
If additionally, <code>G</code> is a set of homogeneous polynomials, one can call the following getter functions:
[[/SB.GetHS/]](ref S); -- returns the Hilbert Series of S
[[/SB.GetTruncSAGBI/]](ref S,d); -- returns a d-truncated SAGBI basis of S
[[/SB.GetTruncDeg/]](S); -- returns the truncation degree of the currently stored SAGBI basis
To optain a <math>K</math>-vector space basis of the set <math>K[G]_d</math> of all homogeneous polynomials of degree <math>d</math> in <math>K[G]</math>, the function [[/SB.GetInDeg/]] can be used:
[[/SB.GetInDeg/]](S);
=== Testing Subalgebra Membership ===
Let <code>f</code> be a polynomial in the polynomial ring <code>P</code>, let <code>G</code> be a list of polynomials in <code>P</code> and let <code>S</code> be a subalgebra generated by <code>G</code>. Then the SAGBI package provides four functions to check whether <code>f</code> is an element of the subalgebra <code>S</code>:
[[/SB.IsInSubalgebra/]](f,G);
[[/SB.IsInSA/]](f,S);
If <code>G</code> is a list of homogeneous polynomials, the following functions can also be used:
[[/SB.IsInSubalgebra_SAGBI/]](f,G);
[[/SB.IsInSA_SAGBI/]](f,ref S);
While the first two functions test the membership using implicitization, these two functions use truncated SAGBI bases for the membership test, which ''may'' be more efficient. It depends on the application which of these two possibilities is the fastest one.
=== Example for the Subalgebra Data Type ===
So what advantages does the Subalgebra data type have? Consider the following example.
<pre>
Use P ::= QQ[x,y,z];
G := [x^2 -z^2,  x*y +z^2,  y^2 -2*z^2];
L := SB.SAGBI(G);
f := x^10*y^2 +x^6*y^6 -2*x^10*z^2 -5*x^8*y^2*z^2 +6*x^5*y^5*z^2 +10*x^8*z^4 +10*x^6*y^2*z^4 +15*x^4*y^4*z^4 -20*x^6*z^6 -10*x^4*y^2*z^6 +20*x^3*y^3*z^6 +20*x^4*z^8 +20*x^2*y^2*z^8 -10*x^2*z^10 +6*x*y*z^10 -y^2*z^10 +3*z^12;
b := SB.IsInSubalgebra(f,G);
h := SB.SubalgebraHS(G);
</pre>
While this is only a simple example, the second code is much faster. At the time this is written, the second computation is approximately two times as fast as the first one.
[[Category:Package sagbi]]
[[Category:ApCoCoA Packages]]
[[Category:ApCoCoA Packages]]
[[Category:Package glpk]]

Revision as of 18:45, 17 November 2022

This article is about a function from ApCoCoA-2. If you are looking for the ApCoCoA-1 version of it, see Category:ApCoCoA-1:Package ZeroDim.

This page describes the zerodim package. For a complete list of functions, see Category:Package zerodim.

This package contains various functions for computing algebraic invariants of zero-dimensional schemes and related computations.

Mathematical Definitions

Let K be a field and let P=K[x1,,xn] be the polynomial ring over K in n indeterminates. Most of the definitions here are taken from the book Computational Commutative Algebra 2 by Martin Kreuzer and Lorenzo Robbiano.

Subalgebras

A subset SP is called a K-subalgebra of P, if

  • KS and
  • S is closed under addition and multiplication.

For a subset F={f1,,fs}P, we write

K[F]=K[f1,,fs]={p(f1,,fs)pK[y1,,ys]}

where K[y1,,ys] is a new polynomial ring in s indeterminates for the K-subalgebra of P generated by F.

SAGBI bases

Let σ be a term ordering on P and let S be a K-subalgebra of P. A set GS is called a σ-SAGBI basis of S if K[LTσ(f)fS]=K[LTσ(f)fG].

If S is a graded subalgebra and d, then a set Gd is called a d-truncated σ-SAGBI basis of S, if

K[LTσ(f)fS and deg(f)d]=K[LTσ(f)fGd].

Equivalently, a set Gd is a d-truncated σ-SAGBI basis of S if there is a σ-SAGBI basis of S with Gd={gGdeg(g)d}.

The Subalgebra Rewrite Relation

Let GP be a set of non-zero polynomials. Furthermore, let σ be a term ordering on 𝕋n.

  • For f,gP{0}, we say that f subalgebra reduces to g in one step if there are f1,,fsG, a term t𝕋s, and a constant cK such that g=fct(f1,,fs) and LTσ(t(f1,,fs)) is not anymore in Supp(g). The path from f to g is then called a subalgebra reduction step and denoted by fGssg.
  • The transitive closure of the relation Gss is denoted by Gs and called the subalgebra rewrite relation defined by G. If there are f,gP with fGsg, we say that f subalgebra reduces to g.
  • If gP such that there is no hP with hg and gGssh, then g is called irreducible with respect to the relation Gs. Sometimes we may also just write that g is irreducible with respect to G.

A set GP is called interreduced if every element gG is monic and irreducible with respect to G{g}. If G is a σ-SAGBI basis of K[G] which is interreduced, then it is called a reduced σ-SAGBI basis. Analogously to reduced Gröbner bases, it can be shown that every K-subalgebra has a unique reduced σ-SAGBI basis.

The Subalgebra Division Algorithm

Let σ be a term ordering on 𝕋n, fP and G={f1,,fs}P be a set of non-zero polynomials. Consider the following sequence of instructions.

  1. Set g:=f.
  2. Write g=c1t1++cmtm with ti𝕋n, ciK for i=1,,m, and t1σσtm. Set k:=1.
  3. If k=m+1, stop and return g. Otherwise, check whether there is a term t𝕋s such that tk=t(LTσ(f1),,LTσ(fs)). If there is one, set c=t(LCσ(f1),,LCσ(fs)), replace g by gcict(f1,,fs) and go to step~(2). If there is none, increase k by one and repeat this step.

This is an algorithm which returns a polynomial gP such that fGsg and g is irreducible with respect to Gs. This algorithm clearly computes a polynomial gP with fGsg and g is irreducible with respect to G.

Package Description

All of the previously described definitions are implemented in the SAGBI package.

Basic functions

Given a polynomial ring P and a list F of polynomials in P, one can compute the reduced SAGBI basis of K[F] (with respect to the term ordering given by P) using the function SB.SAGBI - as long as a finite one exists.

SB.SAGBI(F);

Note that this function probably runs into an infinite loop if no finite SAGBI basis exists. This can be avoided using the function SB.SAGBITimeout. Given a positive integer s, one can type in

SB.SAGBITimeout(F,s);

which does the same as SB.SAGBI(F), but throws an error if the computation is not finished within s seconds. Given a polynomial f and a list of polynomials G, the function SB.ReductionStep can be used to compute a polynomial g with fGsg.

SB.ReductionStep(f,G);

If no such polynomial exists, then f is returned. This function is then used by the function SB.SDA, which is an implementation of the Subalgebra Division Algorithm described above.

SB.SDA(f,G)

Analogously to the CoCoA-5 function interreduced, the SAGBI package contains the function SB.Interreduced which takes as input a list of polynomials G and returns a list G' with K[G]=K[G].

SB.Interreduced(G);

Special Functions for Graded Subalgebras

If G is a set of homogeneous polynomials, then there are additional functions one can use. Given a positive integerd, a d-truncated SAGBI basis can be computed using SB.TruncSAGBI.

SB.TruncSAGBI(G,d);

If additionally, the Hilbert series HS of the subalgebra K[G] is given, one can call

SB.TruncSAGBI(G,d,HS);

which does the same as above, but computes the SAGBI basis Hilbert-driven, which may be a little bit faster. The function SB.SubalgebraHS can be applied to compute the Hilbert series of a graded subalgebra.

SB.SubalgebraHS(G);

If furthermore G is a set of terms, then the function

SB.TorRingHS(G);

can be used to compute its Hilbert series much more efficient.

The Subalgebra Data Type

The package also introduces a new Data type, i.e. a record tagged with "$apcocoa/sagbi.Subalgebra". Given a polynomial ring P and a list of polynomials G from P, one can create the subalgebra K[G] using the function SB.Subalgebra.

Use P ::= QQ[x,y,z];
G := [x^2+y*z,z];
S := SB.Subalgebra(P,G);

For details about the structure of this data type, see the function page. While nearly all functionalities of the SAGBI package can be used without touching this data type, it has many advantages to do so because it stores informations of previous computations, see the example below. This is also the reason why many of the getter functions need the subalgebra to be called by reference. The following getter function can be used to get informations about the subalgebra:

SB.GetCoeffRing(S); -- returns the coefficient ring
SB.GetGens(S); -- returns the set G
SB.GetID(S); -- returns the unique ID of S
SB.GetLTSA(ref S); -- returns the subalgebra K[LT(f) | f in S]
SB.GetRing(S); -- returns P
SB.GetSAGBI(ref S); -- returns the reduced SAGBI basis of S (if a finite one exists)

If additionally, G is a set of homogeneous polynomials, one can call the following getter functions:

SB.GetHS(ref S); -- returns the Hilbert Series of S
SB.GetTruncSAGBI(ref S,d); -- returns a d-truncated SAGBI basis of S
SB.GetTruncDeg(S); -- returns the truncation degree of the currently stored SAGBI basis

To optain a K-vector space basis of the set K[G]d of all homogeneous polynomials of degree d in K[G], the function SB.GetInDeg can be used:

SB.GetInDeg(S);

Testing Subalgebra Membership

Let f be a polynomial in the polynomial ring P, let G be a list of polynomials in P and let S be a subalgebra generated by G. Then the SAGBI package provides four functions to check whether f is an element of the subalgebra S:

SB.IsInSubalgebra(f,G);
SB.IsInSA(f,S);

If G is a list of homogeneous polynomials, the following functions can also be used:

SB.IsInSubalgebra_SAGBI(f,G);
SB.IsInSA_SAGBI(f,ref S);

While the first two functions test the membership using implicitization, these two functions use truncated SAGBI bases for the membership test, which may be more efficient. It depends on the application which of these two possibilities is the fastest one.

Example for the Subalgebra Data Type

So what advantages does the Subalgebra data type have? Consider the following example.

Use P ::= QQ[x,y,z];
G := [x^2 -z^2,  x*y +z^2,  y^2 -2*z^2];
L := SB.SAGBI(G);
f := x^10*y^2 +x^6*y^6 -2*x^10*z^2 -5*x^8*y^2*z^2 +6*x^5*y^5*z^2 +10*x^8*z^4 +10*x^6*y^2*z^4 +15*x^4*y^4*z^4 -20*x^6*z^6 -10*x^4*y^2*z^6 +20*x^3*y^3*z^6 +20*x^4*z^8 +20*x^2*y^2*z^8 -10*x^2*z^10 +6*x*y*z^10 -y^2*z^10 +3*z^12;
b := SB.IsInSubalgebra(f,G);
h := SB.SubalgebraHS(G);

While this is only a simple example, the second code is much faster. At the time this is written, the second computation is approximately two times as fast as the first one.