Groebner.jl icon indicating copy to clipboard operation
Groebner.jl copied to clipboard

Reduce a Polynomial by a Groebner Basis

Open polka125 opened this issue 10 months ago • 2 comments

Hi, is there a way to reduce a polynomial by a Groebner basis?

Say, I have

using Groebner
@polyvar x y
basis = Groebner.groebner([x - y, x*y])
p = x^2

Now I want to check whether $p$ belongs to the ideal, and want to have something like Groebner.reduce(p, basis) == 0, is there any way to express this?

polka125 avatar Apr 26 '24 14:04 polka125

Hi! There is Groebner.normalform. You can try normalform(basis, p).

Unfortunately, I think in your example it would not work, due to a bug in the way Groebner handles DynamicPolynomials.

Until I fix it, I would recommend using Groebner with AbstractAlgebra, it should be more stable and tested.

julia> using Groebner, AbstractAlgebra
julia> R, (x,y) = QQ["x","y"]
julia> basis = groebner([x - y, x*y])
julia> p = x^2
julia> normalform(basis, p)
0

PS. you can still trick DynamicPolynomials into doing the right thing by something like:

julia> @polyvar x y
julia> basis = Groebner.groebner([x - y, x*y])
julia> p = x^2
julia> normalform(basis, p)                # will fail
julia> normalform(basis, p + 0*x*y)
0

So you can add a fictional term 0*[product of all variables] to your polynomials to make it work.

Let me know if you have further questions.

sumiya11 avatar Apr 26 '24 23:04 sumiya11

I guess this is the same bug @sumiya11

using Groebner
using DynamicPolynomials
@polyvar x y u v l;
normalform([x^2+y^2-1], x)

with output DimensionMismatch: all inputs to eachindex must have the same indices, got Base.OneTo(2) and Base.OneTo(3).

linus-md avatar May 15 '24 11:05 linus-md

With the new version of Groebner (0.8.0) this is fixed.

sumiya11 avatar Sep 21 '24 00:09 sumiya11