MultivariatePolynomials.jl
MultivariatePolynomials.jl copied to clipboard
Greatest common divisor
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
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].
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?
I think this would make sense.