Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Greatest common divisor #118

Open
ahumenberger opened this issue Aug 8, 2019 · 3 comments
Open

Greatest common divisor #118

ahumenberger opened this issue Aug 8, 2019 · 3 comments

Comments

@ahumenberger
Copy link
Contributor

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
@saschatimme
Copy link
Collaborator

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:

(coefficient(t1) / coefficient(t2)) * _div(monomial(t1), monomial(t2))

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

@ahumenberger
Copy link
Contributor Author

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?

@saschatimme
Copy link
Collaborator

I think this would make sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants