Spring 2014: Academy of Science Research Cluster 

Topic: Grobner Bases 

 

During the spring of 2014 our research cluster investigated multivariate division and Grobner bases. We mostly considered examples working in the ring of complex polynomials in 3 variables. However, we did also look at Grobner bases in non-commutative rings and their application to proving certain tricky ring propositions.



Some random examples
 

 

> restart;
with(plots):
with(LinearAlgebra):
with(Groebner);
 

[Basis, FGLM, HilbertDimension, HilbertPolynomial, HilbertSeries, Homogenize, InitialForm, InterReduce, IsBasis, IsProper, IsZeroDimensional, LeadingCoefficient, LeadingMonomial, LeadingTerm, MatrixOr...
[Basis, FGLM, HilbertDimension, HilbertPolynomial, HilbertSeries, Homogenize, InitialForm, InterReduce, IsBasis, IsProper, IsZeroDimensional, LeadingCoefficient, LeadingMonomial, LeadingTerm, MatrixOr...
[Basis, FGLM, HilbertDimension, HilbertPolynomial, HilbertSeries, Homogenize, InitialForm, InterReduce, IsBasis, IsProper, IsZeroDimensional, LeadingCoefficient, LeadingMonomial, LeadingTerm, MatrixOr...
[Basis, FGLM, HilbertDimension, HilbertPolynomial, HilbertSeries, Homogenize, InitialForm, InterReduce, IsBasis, IsProper, IsZeroDimensional, LeadingCoefficient, LeadingMonomial, LeadingTerm, MatrixOr...
[Basis, FGLM, HilbertDimension, HilbertPolynomial, HilbertSeries, Homogenize, InitialForm, InterReduce, IsBasis, IsProper, IsZeroDimensional, LeadingCoefficient, LeadingMonomial, LeadingTerm, MatrixOr...
[Basis, FGLM, HilbertDimension, HilbertPolynomial, HilbertSeries, Homogenize, InitialForm, InterReduce, IsBasis, IsProper, IsZeroDimensional, LeadingCoefficient, LeadingMonomial, LeadingTerm, MatrixOr...
(1)
 

 

Let's increase the amount of information which Maple displays... 

 

> infolevel[GroebnerBasis] := 2:
 

 

Example: Given a set of polynomials F, let's find a reduced Grobner basis relative to several different term orderings. 

 

> F := [x^3 - 3*x*y, x^2*y - 2*y^2 + x];
 

[`+`(`*`(`^`(x, 3)), `-`(`*`(3, `*`(x, `*`(y))))), `+`(`*`(`^`(x, 2), `*`(y)), `-`(`*`(2, `*`(`^`(y, 2)))), x)] (2)
 

> Basis(F, plex(x,y));  # lexicographic order with x > y
 

 

-> FGb
 

total time:         0.017 sec
 

-> FGLM algorithm
total monomials  : 8
total time   (sec) 0.9e-2
[`+`(`-`(`*`(3, `*`(`^`(y, 3)))), `*`(`^`(y, 6))), `+`(`-`(`*`(2, `*`(`^`(y, 2)))), `*`(`^`(y, 5)), x)] (3)
 

> Basis(F, tdeg(x,y));  
 

 

-> FGb
 

total time:         0.009 sec
[`+`(`*`(`^`(y, 3)), `*`(x, `*`(y))), `+`(`*`(`^`(y, 2), `*`(x)), `*`(`^`(x, 2))), `+`(`*`(`^`(x, 2), `*`(y)), `-`(`*`(2, `*`(`^`(y, 2)))), x), `+`(`*`(`^`(x, 3)), `-`(`*`(3, `*`(x, `*`(y)))))] (4)
 

> Basis(F, grlex(x,y));  
 

 

-> F4 algorithm
 

total time:         0.009 sec
[`+`(`*`(`^`(y, 3)), `*`(x, `*`(y))), `+`(`*`(`^`(y, 2), `*`(x)), `*`(`^`(x, 2))), `+`(`*`(`^`(x, 2), `*`(y)), `-`(`*`(2, `*`(`^`(y, 2)))), x), `+`(`*`(`^`(x, 3)), `-`(`*`(3, `*`(x, `*`(y)))))] (5)
 

 

Example: Linear Algebra 

 

We can solve linear algebra problems with Grobner bases -- in an astoundingly inefficient way! 

 

> A := <<1,2,3>|<4,5,6>|<7,8,9>>;
 

Matrix(%id = 18446744078120973726) (6)
 

 

Our linear system... 

 

> A.<x,y,z> = <18,15,12>;
 

Vector[column](%id = 18446744078120974086) = Vector[column](%id = 18446744078120974206) (7)
 

 

We can make Maple do Gaussian elimination in order to find the solution... 

 

> ReducedRowEchelonForm(<A|<18,15,12>>);
 

Matrix(%id = 18446744078120975166) (8)
 

 

x = `+`(`-`(10), t) 

y = `+`(7, `-`(`*`(2, `*`(t)))) 

z = t 

 

Now let's solve using a Grobner basis. 

 

> Sys := [seq((A.<x,y,z>)[i] - <18,15,12>[i],i=1..3)];
 

[`+`(x, `*`(4, `*`(y)), `*`(7, `*`(z)), `-`(18)), `+`(`*`(2, `*`(x)), `*`(5, `*`(y)), `*`(8, `*`(z)), `-`(15)), `+`(`*`(3, `*`(x)), `*`(6, `*`(y)), `*`(9, `*`(z)), `-`(12))] (9)
 

> Basis(Sys,plex(x,y,z));
 

 

-> FGb
 

total time:         0.006 sec
-> Groebner Walk
 

total time:         0.003 sec
[`+`(`-`(7), y, `*`(2, `*`(z))), `+`(`-`(z), 10, x)] (10)
 

 

So `+`(`-`(7), y, `*`(2, `*`(z))) = 0 and `+`(`-`(z), 10, x) = 0.  Thus... 

 

x = `+`(`-`(10), t) 

y = `+`(7, `-`(`*`(2, `*`(t)))) 

z = t 

 

...the same as before. 

 

What if we reverse the order of the variable (i.e. swap columns in our coefficient matrix)? Say swap x and z's positions. 

 

> B := <<7,8,9>|<4,5,6>|<1,2,3>>;
 

Matrix(%id = 18446744078120970950) (11)
 

> ReducedRowEchelonForm(<B|<18,15,12>>);
 

Matrix(%id = 18446744078120971790) (12)
 

 

Now our solution is... 

 

x = t 

y = `+`(`-`(13), `-`(`*`(2, `*`(t)))) 

z = `+`(10, t) 

 

Our linear polynomials plugged into the basis function are the same... 

 

> Sys := [seq((B.<z,y,x>)[i] - <18,15,12>[i],i=1..3)];
 

[`+`(x, `*`(4, `*`(y)), `*`(7, `*`(z)), `-`(18)), `+`(`*`(2, `*`(x)), `*`(5, `*`(y)), `*`(8, `*`(z)), `-`(15)), `+`(`*`(3, `*`(x)), `*`(6, `*`(y)), `*`(9, `*`(z)), `-`(12))] (13)
 

 

However, we use a different lexicographic ordering: zthen y then x. 

 

> Basis(Sys,plex(z,y,x));
 

 

-> Groebner Walk
 

total time:         0.002 sec
[`+`(y, 13, `*`(2, `*`(x))), `+`(z, `-`(10), `-`(x))] (14)
 

 

x = t 

y = `+`(`-`(13), `-`(`*`(2, `*`(t)))) 

z = `+`(10, t) 

 

The same as above! 

 

So the lexicographic ordering effects our answer in the same way as the ordering of our columns in our coefficient matrix does. 

 

 

Example: Euclidean Algorithm 

 

When we compute a reduced Grobner basis for a set of polynomials in 1 variable, we are just finding the greatest common divisor. Buchberger's algorithm in this case is essentially the same as the Euclidean algorithm. 

 

> Sys := [(x-5)^2*(x^2+9)^3*x*(x-1),(x-5)*(x^2+9)^2*x*(x+6)^5,x*(x^2+9)];
 

[`*`(`^`(`+`(x, `-`(5)), 2), `*`(`^`(`+`(`*`(`^`(x, 2)), 9), 3), `*`(x, `*`(`+`(x, `-`(1)))))), `*`(`+`(x, `-`(5)), `*`(`^`(`+`(`*`(`^`(x, 2)), 9), 2), `*`(x, `*`(`^`(`+`(x, 6), 5))))), `*`(x, `*`(`+`... (15)
 

> Basis(Sys,plex(x));
 

 

-> FGb
 

total time:         0.007 sec
[`+`(`*`(`^`(x, 3)), `*`(9, `*`(x)))] (16)
 

 

Example: Points of Intersection 

 

Let's use a Grobner basis to determine the points of intersection of `+`(`*`(`^`(x, 2)), `*`(`^`(y, 2))) = 25 and xy = 1. 

 

> Sys := [x^2+y^2-25,x*y-1];
 

[`+`(`*`(`^`(x, 2)), `*`(`^`(y, 2)), `-`(25)), `+`(`*`(x, `*`(y)), `-`(1))] (17)
 

> Basis(Sys,plex(x,y));
 

 

-> FGb
 

total time:         0.006 sec
-> FGLM algorithm
total monomials  : 6
total time   (sec) 0.1e-2
[`+`(1, `-`(`*`(25, `*`(`^`(y, 2)))), `*`(`^`(y, 4))), `+`(`-`(`*`(25, `*`(y))), `*`(`^`(y, 3)), x)] (18)
 

 

We get  x = `+`(`*`(25, `*`(y)), `-`(`*`(`^`(y, 3)))) and `+`(1, `-`(`*`(25, `*`(`^`(y, 2)))), `*`(`^`(y, 4))) = 0. The second equation is quadratic in `*`(`^`(y, 2)) so it can be solved (by hand)... 

 

> ys := [solve(y^4-25*y^2+1=0)];
 

[`+`(`*`(`/`(3, 2), `*`(`^`(3, `/`(1, 2)))), `-`(`*`(`/`(1, 2), `*`(`^`(23, `/`(1, 2)))))), `+`(`-`(`*`(`/`(3, 2), `*`(`^`(3, `/`(1, 2))))), `*`(`/`(1, 2), `*`(`^`(23, `/`(1, 2))))), `+`(`*`(`/`(3, 2)... (19)
 

 

These solutions can then be plugged into x = `+`(`*`(25, `*`(y)), `-`(`*`(`^`(y, 3)))) to find the x-coordinates of the points of intersection. There are 4 such points. 

 

> for y in ys do
 print('(x,y)' = (simplify(-y^3+25*y),y));
end do;
 

 

 

 

(x, y) = (`+`(`*`(`/`(3, 2), `*`(`^`(3, `/`(1, 2)))), `*`(`/`(1, 2), `*`(`^`(23, `/`(1, 2))))), `+`(`*`(`/`(3, 2), `*`(`^`(3, `/`(1, 2)))), `-`(`*`(`/`(1, 2), `*`(`^`(23, `/`(1, 2)))))))
(x, y) = (`+`(`-`(`*`(`/`(3, 2), `*`(`^`(3, `/`(1, 2))))), `-`(`*`(`/`(1, 2), `*`(`^`(23, `/`(1, 2)))))), `+`(`-`(`*`(`/`(3, 2), `*`(`^`(3, `/`(1, 2))))), `*`(`/`(1, 2), `*`(`^`(23, `/`(1, 2))))))
(x, y) = (`+`(`*`(`/`(3, 2), `*`(`^`(3, `/`(1, 2)))), `-`(`*`(`/`(1, 2), `*`(`^`(23, `/`(1, 2)))))), `+`(`*`(`/`(3, 2), `*`(`^`(3, `/`(1, 2)))), `*`(`/`(1, 2), `*`(`^`(23, `/`(1, 2))))))
(x, y) = (`+`(`-`(`*`(`/`(3, 2), `*`(`^`(3, `/`(1, 2))))), `*`(`/`(1, 2), `*`(`^`(23, `/`(1, 2))))), `+`(`-`(`*`(`/`(3, 2), `*`(`^`(3, `/`(1, 2))))), `-`(`*`(`/`(1, 2), `*`(`^`(23, `/`(1, 2))))))) (20)
 

 

Decimal approximations of these points... 

 

> for y in ys do
 print('(x,y)' = (evalf(-y^3+25*y),evalf(y)));
end do;

y := 'y':
 

 

 

 

(x, y) = (4.995991991, .200160450)
(x, y) = (-4.995991991, -.200160450)
(x, y) = (.2001603, 4.995991974)
(x, y) = (-.2001603, -4.995991974) (21)
 

 

A plot revealing the 4 points... 

 

> implicitplot({x^2+y^2=25,x*y=1},x=-5..5,y=-5..5);
 

Plot_2d
 

 

Example: No Intersection 

 

The curves `+`(`*`(`^`(x, 2)), `*`(`^`(y, 2))) = 25, xy = 1, and `+`(`*`(`^`(x, 2)), `-`(`*`(`^`(y, 2)))) = 1 have no points in common as we can see in the plot below: 

 

> implicitplot({x^2+y^2=25,x*y=1,x^2-y^2=1},x=-5..5,y=-5..5);
 

Plot_2d
 

 

Let's see if a Grobner basis will reveal this to us... 

 

> Sys := [x^2+y^2-25,x*y-1,x^2-y^2-1];
 

[`+`(`*`(`^`(x, 2)), `*`(`^`(y, 2)), `-`(25)), `+`(`*`(x, `*`(y)), `-`(1)), `+`(`*`(`^`(x, 2)), `-`(`*`(`^`(y, 2))), `-`(1))] (22)
 

> Basis(Sys,plex(x,y));
 

 

-> FGb
 

total time:         0.007 sec
[1] (23)
 

 

We are left with the single element "1" which translates to the equation "1=0". Thus there are no solutions! 

 

 

Example: Using Grobner bases to solve integer equations.  

 

Let's use a Grobner basis to make change (I don't recommend trying to teach this to your average cashier). 

 

1 penny to a penny (p) 

5 pennies to a nickel (n) 

10 pennies to a dime (d) 

25 pennies to a quarter (q) 

100 pennies to a dollar (b=buck) 

 

We encode this as... 

 

`+`(`*`(`^`(p, 5)), `-`(n)) = 0 

`+`(`*`(`^`(p, 10)), `-`(d)) = 0 

`+`(`*`(`^`(p, 25)), `-`(q)) = 0 

and 

`+`(`*`(`^`(p, 100)), `-`(b)) = 0 

 

 

> F := [p^5-n,p^10-d,p^25-q,p^100-b];
 

[`+`(`*`(`^`(p, 5)), `-`(n)), `+`(`*`(`^`(p, 10)), `-`(d)), `+`(`*`(`^`(p, 25)), `-`(q)), `+`(`*`(`^`(p, 100)), `-`(b))] (24)
 

> B := Basis(F,grlex(p,n,d,q,b));
 

 

-> F4 algorithm
 

total time:         0.008 sec
[`+`(`-`(d), `*`(`^`(n, 2))), `+`(`*`(`^`(d, 3)), `-`(`*`(n, `*`(q)))), `+`(`-`(q), `*`(`^`(d, 2), `*`(n))), `+`(`-`(b), `*`(`^`(q, 4))), `+`(`*`(`^`(p, 5)), `-`(n))] (25)
 

 

Suppose we have... 

 

2 dollars, 5 quarters, 2 dimes, 3 nickels, and 8 pennies 

 

> Change := b^2*q^5*d^2*n^3*p^8;
 

`*`(`^`(b, 2), `*`(`^`(q, 5), `*`(`^`(d, 2), `*`(`^`(n, 3), `*`(`^`(p, 8)))))) (26)
 

> NormalForm(Change, B, grlex(p,n,d,q,b));
 

`*`(`^`(b, 3), `*`(d, `*`(`^`(q, 2), `*`(`^`(p, 3), `*`(n))))) (27)
 

 

This is equivalent to... 

 

3 dollars, 2 quarters, 1 dime, 1 nickel, and 3 pennies. 

 

(Thinking of the dollar as a coin, we have a total of 3+2+1+1+3=10 coins.) 

 

 

What if we use lexicographic ordering instead of degree lex? 

 

> F := [p^5-n,p^10-d,p^25-q,p^100-b];
 

[`+`(`*`(`^`(p, 5)), `-`(n)), `+`(`*`(`^`(p, 10)), `-`(d)), `+`(`*`(`^`(p, 25)), `-`(q)), `+`(`*`(`^`(p, 100)), `-`(b))] (28)
 

> B := Basis(F,plex(p,n,d,q,b));
 

 

-> Groebner Walk
 

total time:         0.008 sec
[`+`(`-`(b), `*`(`^`(q, 4))), `+`(`*`(`^`(d, 5)), `-`(`*`(`^`(q, 2)))), `+`(`-`(`*`(`^`(d, 3), `*`(`^`(q, 3)))), `*`(n, `*`(b))), `+`(`-`(`*`(`^`(d, 3))), `*`(n, `*`(q))), `+`(`-`(q), `*`(`^`(d, 2), `... (29)
 

> Change := b^2*q^5*d^2*n^3*p^8;
 

`*`(`^`(b, 2), `*`(`^`(q, 5), `*`(`^`(d, 2), `*`(`^`(n, 3), `*`(`^`(p, 8)))))) (30)
 

> NormalForm(Change, B, plex(p,n,d,q,b));
 

`*`(`^`(d, 4), `*`(`^`(p, 3), `*`(`^`(b, 3), `*`(q)))) (31)
 

 

Now our equivalent change is... 

 

3 dollars, 1 quarter, 4 dimes, 3 pennies, but no nickels. 

 

This is a total of 3+1+4+3=11 "coins".  

 

Using the pure lexicographic ordering, the normal form looks for an equivlent (mod our relations) monomial which avoid lower value coins if at all possible. Notice we used 1 more coin, but we avoided having a nickel. We do have some pennies, but this cannot be helped.