diff --git a/src/NumField/Elem.jl b/src/NumField/Elem.jl index ebf8d41bd4..ce57fd9ae8 100644 --- a/src/NumField/Elem.jl +++ b/src/NumField/Elem.jl @@ -460,8 +460,7 @@ end function roots(f::PolyRingElem{<: NumFieldElem}) lf = factor(f) @assert degree(unit(lf)) == 0 - scale = inv(coeff(unit(lf), 0)) - return elem_type(base_ring(f))[-constant_coefficient(x)*scale for x = keys(lf.fac) if degree(x) == 1] + return elem_type(base_ring(f))[-constant_coefficient(x)*inv(leading_coefficient(x)) for x = keys(lf.fac) if degree(x) == 1] end ################################################################################ diff --git a/test/NumField/Elem.jl b/test/NumField/Elem.jl index 640f79d4d0..9e65b74967 100644 --- a/test/NumField/Elem.jl +++ b/test/NumField/Elem.jl @@ -245,3 +245,16 @@ end @test !isone(g^8) @test !isone(g^3) end + +# Issue with scaling of roots found by M. Zach +begin + Qx, x = QQ["x"] + K, a = number_field(x^2 + x + 1, cached = false) + Ks, s = polynomial_ring(K, "s") + L, = number_field(s^8 + 6s^4 + 1) + Ly, y = L["y"] + h = -1//4*y^8 - 3//2*y^4 - 1//4 + r = roots(h) + @test length(r) == 8 + @test all(iszero, h.(r)) +end