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

Greatest common divisor

Open ahumenberger opened this issue 5 years ago • 3 comments

The gcd behaviour seems weird:

@polyvar x

gcd(2*x^2 + 4, 2*x) # Result: 4.0

gcd(2*x^2 + 2, x) # Result: 2.0

gcd(4*x^2 + 8*x + 4, 4 * x^2) # Result: 1.0

gcd(2*x^2 + 4*x, 6*x) # Result: 6.0x

ahumenberger avatar Aug 08 '19 10:08 ahumenberger

The gcd is only defined up to an invertible element of the field. If a polynomial with Integer coefficients is considered as a polynomial in ℝ[x] then this is correct. Also note the promotion to Float64 which seems to happen here: https://github.com/JuliaAlgebra/MultivariatePolynomials.jl/blob/95dc00abe46138936ae37218f0eeb57a4204415c/src/division.jl#L27

The questions is whether we want to treat a polynomial with Integer coefficients as a polynomial in ℤ[x].

saschatimme avatar Aug 08 '19 11:08 saschatimme

The questions is whether we want to treat a polynomial with Integer coefficients as a polynomial in ℤ[x].

If I'm explicitly constructing a Polynomial{true, Int} I would expect it to be treated as a polynomial in ℤ[x]. What's your take on this?

ahumenberger avatar Aug 08 '19 11:08 ahumenberger

I think this would make sense.

saschatimme avatar Aug 08 '19 11:08 saschatimme