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

gcd of rational numbers

Open smaasz opened this issue 6 months ago • 4 comments

https://github.com/JuliaAlgebra/MultivariatePolynomials.jl/blob/c0fd0f0aeb3ad366fae68ebc2bb5ade0de752d2d/src/gcd.jl#L845

shouldn't it be the lcm of the denominators?

smaasz avatar Jul 16 '25 15:07 smaasz

Could you provide an example of gcd computation that is incorrect?

blegat avatar Jul 16 '25 20:07 blegat

using DynamicPolynomials
@polyvar x y z
gcd(1//2*x + 1//4*y + 1//3*z, 1)

outputs:

1//2

smaasz avatar Jul 16 '25 21:07 smaasz

You expect it to be 1 or 1//12 ?

blegat avatar Jul 17 '25 08:07 blegat

I'd expect it to be 1//12.

Note that the issue only occurs when there're more than 2 terms (as only then _simplifier is called):

using DynamicPolynomials
@polyvar x y
gcd(1//3*x + 1//4*y, 1)

outputs:

1//12

smaasz avatar Jul 17 '25 08:07 smaasz