Groebner.jl
Groebner.jl copied to clipboard
Reduce a Polynomial by a Groebner Basis
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?
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.
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)
.
With the new version of Groebner (0.8.0) this is fixed.